resumeIndex.uvue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <view class="detail-page">
  3. <scroll-view class="detail-content" :scroll-y="true">
  4. <!-- 工单信息 -->
  5. <view class="info-section">
  6. <view class="section-title">
  7. <text class="section-title-text">工单信息</text>
  8. </view>
  9. <view class="info-card">
  10. <view class="info-item">
  11. <text class="info-label">工单编码</text>
  12. <text class="info-value">{{ detailData.workOrderProjectNo ?? '' }}</text>
  13. </view>
  14. <view class="info-item">
  15. <text class="info-label">工单类型</text>
  16. <text class="info-value">{{ detailData.orderType == 1 ? '维修工单' : '维保工单' }}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="info-label">风机编号</text>
  20. <text class="info-value">{{ detailData.pcsDeviceName ?? '' }}</text>
  21. </view>
  22. <view class="info-item">
  23. <text class="info-label">维保中心</text>
  24. <text class="info-value">{{ detailData.gxtCenter ?? '' }}</text>
  25. </view>
  26. <view class="info-item">
  27. <text class="info-label">场站</text>
  28. <text class="info-value">{{ detailData.pcsStationName ?? '' }}</text>
  29. </view>
  30. <!-- <view class="info-item">
  31. <text class="info-label">品牌</text>
  32. <text class="info-value">{{ detailData.model ?? '' }}</text>
  33. </view> -->
  34. <view class="info-item">
  35. <text class="info-label">机型</text>
  36. <text class="info-value">{{ detailData.brand ?? '' }} {{ detailData.model ?? '' }}</text>
  37. </view>
  38. <view class="info-item">
  39. <text class="info-label">下发时间</text>
  40. <text class="info-value">{{ detailData.assignTime ?? '' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- <view class="info-section">
  45. <view class="section-title">
  46. <text class="section-title-text">工作负责人</text>
  47. </view>
  48. <view class="info-card">
  49. <view class="info-item">
  50. <input class="input" type="text" placeholder="请输入工作负责人" v-model="teamLeaderName" />
  51. </view>
  52. </view>
  53. </view> -->
  54. <!-- 工单流转 -->
  55. <!-- <view class="info-section">
  56. <view class="section-title">
  57. <text class="section-title-text">工单流转</text>
  58. </view>
  59. <view class="info-card" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 0">
  60. <view class="flow-item" v-for="(flow, index) in detailData.workOrderFlowList" :key="index">
  61. <view class="flow-header">
  62. <text class="flow-operator">{{ flow.operatorName ?? '未知操作人' }}</text>
  63. <text class="flow-time">{{ flow.actionTime ?? '' }}</text>
  64. </view>
  65. <view class="flow-content">
  66. <text class="flow-action">{{ getActionTypeName(flow.actionType) }}</text>
  67. <text class="flow-remark" v-if="flow.actionRemark">{{ flow.actionRemark }}</text>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="info-card" v-else>
  72. <view class="no-data">暂无流转记录</view>
  73. </view>
  74. </view> -->
  75. </scroll-view>
  76. <!-- 接单按钮 -->
  77. <view class="accept-button-container" v-if="checkPermi(['gxt:maintenance:order:resume','gxt:repairOrder:resume'])">
  78. <button class="accept-button" @click="handleResumeOrder">恢 复</button>
  79. </view>
  80. <!-- 加载中状态 -->
  81. <view v-if="loading" class="loading-mask">
  82. <text class="loading-text">加载中...</text>
  83. </view>
  84. </view>
  85. </template>
  86. <script setup lang="uts">
  87. import { ref } from 'vue'
  88. import type { acceptOrderInfo } from '../../../types/order'
  89. import type { WorkOrderFlow } from '../../../types/flow'
  90. import { getOrderInfoById, getRepairOrderInfoById, resumeOrder } from '../../../api/order/detail'
  91. import type { SysDictData } from '../../../types/dict'
  92. import { getDictDataByType } from '../../../api/dict/index'
  93. import { getUserList } from '../../../api/user/list'
  94. import type { UserInfo } from '../../../types/user'
  95. import {checkPermi} from '../../../utils/storage'
  96. const teamLeaderName = ref<string>("")
  97. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  98. // 添加字典加载状态
  99. const dictLoaded = ref<boolean>(false)
  100. // 详情数据
  101. const detailData = ref<acceptOrderInfo>({
  102. orderType: 0,
  103. id: 0,
  104. teamLeaderId: 0,
  105. acceptUserId: 0,
  106. teamLeaderName: null,
  107. acceptUserName: null,
  108. acceptTime: null,
  109. assignTime: null,
  110. assignUserName: null,
  111. status: 0,
  112. workOrderProjectNo: null,
  113. workOrderStatus: null,
  114. gxtCenterId: 0,
  115. gxtCenter: null,
  116. pcsStationId: 0,
  117. pcsStationName: null,
  118. pcsDeviceId: 0,
  119. pcsDeviceName: null,
  120. brand: null,
  121. model: null,
  122. createTime: null,
  123. workOrderFlowList: null,
  124. suspendReason: null,
  125. rejectionReason: null
  126. })
  127. // 选择器选项类型
  128. type PickerOption = {
  129. label: string
  130. value: string
  131. }
  132. // 选中的负责人信息
  133. const selectedTeamLeaderId = ref<string>('')
  134. const rejectReason = ref<string>('')
  135. const selectedTeamLeaderIndex = ref<number>(-1)
  136. const teamLeaderNameOptions = ref<PickerOption[]>([])
  137. const showLeaderPicker = ref<boolean>(false)
  138. // 获取负责人列表(使用用户列表接口)
  139. const loadTeamLeaderList = async (): Promise<void> => {
  140. try {
  141. const deptId = detailData.value.gxtCenterId
  142. const result = await getUserList(deptId)
  143. const resultObj = result as UTSJSONObject
  144. if (resultObj['code'] == 200) {
  145. const data = resultObj['data'] as any[]
  146. const leaders: UserInfo[] = []
  147. const options: PickerOption[] = []
  148. if (data.length > 0) {
  149. for (let i = 0; i < data.length; i++) {
  150. const item = data[i] as UTSJSONObject
  151. let leader: UserInfo = {
  152. userName: item['userName'] as string,
  153. nickName: item['nickName'] as string,
  154. userId: new Int32Array([item['userId'] != null ? (item['userId'] as number) : 0]),
  155. phone: item['phonenumber'] as string,
  156. deptName : item['deptName'] != null ? (item['deptName'] as string) : ''
  157. }
  158. leaders.push(leader)
  159. // 构建选择器选项(只使用用户名)
  160. options.push({
  161. label: leader.nickName,
  162. value: leader.userId.toString()
  163. })
  164. }
  165. }
  166. // teamLeaderList.value = leaders
  167. teamLeaderNameOptions.value = options
  168. }
  169. } catch (e: any) {
  170. console.error('获取负责人列表失败:', e.message)
  171. }
  172. }
  173. // 获取工单状态字典列表
  174. const loadStatusDictList = async (): Promise<void> => {
  175. try {
  176. const result = await getDictDataByType('gxt_repair_order_flow_action_type')
  177. const resultObj = result as UTSJSONObject
  178. if (resultObj['code'] == 200) {
  179. const data = resultObj['data'] as any[]
  180. const dictData: SysDictData[] = []
  181. if (data.length > 0) {
  182. for (let i = 0; i < data.length; i++) {
  183. const item = data[i] as UTSJSONObject
  184. // 只提取需要的字段
  185. const dictItem: SysDictData = {
  186. dictValue: item['dictValue'] as string | null,
  187. dictLabel: item['dictLabel'] as string | null,
  188. dictCode: null,
  189. dictSort: null,
  190. dictType: null,
  191. cssClass: null,
  192. listClass: null,
  193. isDefault: null,
  194. status: null,
  195. default: null,
  196. createTime: null,
  197. remark: null
  198. }
  199. dictData.push(dictItem)
  200. }
  201. }
  202. statusDictList.value = dictData
  203. dictLoaded.value = true
  204. }
  205. } catch (e: any) {
  206. console.error('获取工单状态字典失败:', e.message)
  207. dictLoaded.value = true
  208. }
  209. }
  210. // 处理恢复操作
  211. const handleResumeOrder = async (): Promise<void> => {
  212. detailData.value.rejectionReason = rejectReason.value
  213. detailData.value.workOrderStatus = 'to_finish'
  214. try {
  215. const result = await resumeOrder(detailData.value)
  216. const resultObj = result as UTSJSONObject
  217. const code = resultObj['code'] as number
  218. if (code == 200) {
  219. uni.showToast({
  220. title: '恢复成功',
  221. icon: 'success'
  222. })
  223. // 使用事件总线通知列表页面刷新
  224. uni.$emit('refreshOrderList', {})
  225. // 接单成功后返回上一页
  226. setTimeout(() => {
  227. uni.navigateBack()
  228. }, 1000)
  229. }
  230. } catch (error) {
  231. console.error('请求失败:', error);
  232. }
  233. }
  234. const loading = ref<boolean>(false)
  235. // 获取操作类型名称
  236. const getActionTypeName = (item: string | null): string | null => {
  237. if (item == null) return ''
  238. // const orderInfoItem = item as orderInfo
  239. const rawStatus = item
  240. if (rawStatus==null) return ''
  241. // 如果字典尚未加载,返回原始值
  242. if (!dictLoaded.value) {
  243. return rawStatus
  244. }
  245. // 查找字典中对应的标签
  246. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  247. return dictItem!=null ? dictItem.dictLabel : rawStatus
  248. }
  249. // 加载详情数据
  250. const loadDetail = async (id: string, orderType?: number): Promise<void> => {
  251. try {
  252. loading.value = true
  253. let result: any;
  254. // 根据orderType决定调用哪个API
  255. if (orderType == 1) {
  256. // 维修工单
  257. result = await getRepairOrderInfoById(id)
  258. } else {
  259. // 维保工单
  260. result = await getOrderInfoById(id)
  261. }
  262. // 提取响应数据
  263. const resultObj = result as UTSJSONObject
  264. const code = resultObj['code'] as number
  265. const data = resultObj['data'] as UTSJSONObject | null
  266. if (code == 200 && data != null) {
  267. // 处理工单流转列表
  268. let workOrderFlowList: WorkOrderFlow[] | null = null
  269. let flowList: UTSJSONObject[] = []
  270. if (orderType == 1) {
  271. // 维修工单
  272. flowList = data['repairOrderFlowList'] as UTSJSONObject[]
  273. } else {
  274. // 维保工单
  275. flowList = data['workOrderFlowList'] as UTSJSONObject[]
  276. }
  277. if (flowList.length > 0) {
  278. workOrderFlowList = []
  279. for (let i = 0; i < flowList.length; i++) {
  280. const flowItem = flowList[i]
  281. const flow: WorkOrderFlow = {
  282. id: flowItem['id'] as Number,
  283. orderId: flowItem['orderId'] as Number,
  284. orderCode: flowItem['orderCode'] as string,
  285. actionType: flowItem['actionType'] as string,
  286. fromStatus: flowItem['fromStatus'] as string | null,
  287. toStatus: flowItem['toStatus'] as string,
  288. operatorId: flowItem['operatorId'] as Number | null,
  289. operatorName: flowItem['operatorName'] as string | null,
  290. actionTime: flowItem['actionTime'] as string,
  291. actionRemark: flowItem['actionRemark'] as string | null,
  292. createBy: flowItem['createBy'] as string | null,
  293. createTime: flowItem['createTime'] as string | null
  294. }
  295. workOrderFlowList.push(flow)
  296. }
  297. }
  298. // 转换数据
  299. const orderDtail: acceptOrderInfo = {
  300. orderType: data['orderType'] as Number,
  301. id: data['id'] as Number,
  302. teamLeaderId: data['teamLeaderId'] != null ? (data['teamLeaderId'] as Number) : 0,
  303. acceptUserId: data['acceptUserId'] != null ? (data['acceptUserId'] as Number) : 0,
  304. teamLeaderName: data['teamLeaderName'] as string | null,
  305. acceptUserName: data['acceptUserName'] as string | null,
  306. acceptTime: data['acceptTime'] as string | null,
  307. assignTime: data['assignTime'] as string | null,
  308. assignUserName: data['assignUserName'] as string | null,
  309. status: (data['status']==null)?0:data['status'] as Number,
  310. workOrderProjectNo: data['workOrderProjectNo'] as string | null,
  311. workOrderStatus: data['workOrderStatus'] as string | null,
  312. gxtCenterId: data['gxtCenterId'] as Number | 0,
  313. gxtCenter: data['gxtCenter'] as string | null,
  314. pcsStationId: data['pcsStationId'] as Number | 0,
  315. pcsStationName: data['pcsStationName'] as string | null,
  316. pcsDeviceId: data['pcsDeviceId'] as Number | 0,
  317. pcsDeviceName: data['pcsDeviceName'] as string | null,
  318. brand: data['brand'] as string | null,
  319. model: data['model'] as string | null,
  320. createTime: data['createTime'] as string | null,
  321. workOrderFlowList: workOrderFlowList,
  322. suspendReason: data['suspendReason'] as string | null,
  323. rejectionReason: data['rejectionReason'] as string | null
  324. }
  325. detailData.value = orderDtail
  326. // 如果工单数据中已有负责人信息,设置到输入框中
  327. if (orderDtail.teamLeaderName != null && orderDtail.teamLeaderName.length > 0) {
  328. teamLeaderName.value = orderDtail.teamLeaderName as string
  329. }
  330. loadTeamLeaderList()
  331. } else {
  332. const msg = resultObj['msg'] as string | null
  333. uni.showToast({
  334. title: msg ?? '加载失败',
  335. icon: 'none'
  336. })
  337. }
  338. } catch (e: any) {
  339. uni.showToast({
  340. title: e.message ?? '加载失败',
  341. icon: 'none'
  342. })
  343. } finally {
  344. loading.value = false
  345. }
  346. }
  347. // 页面加载
  348. onLoad((options: any) => {
  349. const params = options as UTSJSONObject
  350. const id = params['id'] as string | null
  351. const orderTypeParam = params['orderType'] as string | null
  352. if (id != null && orderTypeParam != null) {
  353. // 先尝试从参数中获取orderType
  354. const orderTypeNumber = parseInt(orderTypeParam)
  355. loadDetail(id, orderTypeNumber)
  356. }
  357. })
  358. // 初始化
  359. onMounted(() => {
  360. loadStatusDictList()
  361. })
  362. </script>
  363. <style lang="scss">
  364. .detail-page {
  365. flex: 1;
  366. background-color: #e8f0f9;
  367. }
  368. .detail-content {
  369. flex: 1;
  370. padding: 20rpx 0;
  371. }
  372. .info-section {
  373. margin: 0 30rpx 24rpx;
  374. .section-title {
  375. position: relative;
  376. padding-left: 20rpx;
  377. margin-bottom: 20rpx;
  378. &::before {
  379. // content: '';
  380. position: absolute;
  381. left: 0;
  382. top: 50%;
  383. transform: translateY(-50%);
  384. width: 8rpx;
  385. height: 32rpx;
  386. background-color: #007aff;
  387. border-radius: 4rpx;
  388. }
  389. &-text {
  390. font-size: 32rpx;
  391. font-weight: bold;
  392. color: #333333;
  393. }
  394. }
  395. .info-card {
  396. background-color: #ffffff;
  397. border-radius: 16rpx;
  398. padding: 30rpx;
  399. .info-item {
  400. flex-direction: row;
  401. padding: 20rpx 0;
  402. border-bottom: 1rpx solid #f0f0f0;
  403. &:last-child {
  404. border-bottom: none;
  405. }
  406. &.full-width {
  407. flex-direction: column;
  408. .info-label {
  409. margin-bottom: 12rpx;
  410. }
  411. .info-value {
  412. line-height: 44rpx;
  413. }
  414. }
  415. .info-label {
  416. width: 240rpx;
  417. font-size: 28rpx;
  418. color: #666666;
  419. white-space: nowrap;
  420. }
  421. .info-value {
  422. flex: 1;
  423. font-size: 28rpx;
  424. color: #333333;
  425. text-align: right;
  426. &.highlight {
  427. color: #007aff;
  428. font-weight: bold;
  429. }
  430. &.input {
  431. text-align: left;
  432. border: 1rpx solid #e0e0e0;
  433. border-radius: 8rpx;
  434. padding: 10rpx;
  435. }
  436. }
  437. }
  438. .flow-item {
  439. padding: 20rpx 0;
  440. border-bottom: 1rpx solid #f0f0f0;
  441. &:last-child {
  442. border-bottom: none;
  443. }
  444. .flow-header {
  445. flex-direction: row;
  446. justify-content: space-between;
  447. margin-bottom: 10rpx;
  448. .flow-operator {
  449. font-size: 28rpx;
  450. color: #333333;
  451. font-weight: bold;
  452. }
  453. .flow-time {
  454. font-size: 24rpx;
  455. color: #999999;
  456. }
  457. }
  458. .flow-content {
  459. flex-direction: column;
  460. .flow-action {
  461. font-size: 26rpx;
  462. color: #666666;
  463. margin-bottom: 8rpx;
  464. }
  465. .flow-remark {
  466. font-size: 24rpx;
  467. color: #999999;
  468. background-color: #f5f5f5;
  469. padding: 10rpx;
  470. border-radius: 8rpx;
  471. }
  472. }
  473. }
  474. .no-data {
  475. text-align: center;
  476. padding: 40rpx 0;
  477. font-size: 28rpx;
  478. color: #999999;
  479. }
  480. }
  481. }
  482. .accept-button-container {
  483. padding: 30rpx 30rpx 50rpx;
  484. background-color: #ffffff;
  485. display: flex;
  486. flex-direction: row;
  487. justify-content: space-between;
  488. align-items: center;
  489. .accept-button {
  490. width: 100%;
  491. height: 80rpx;
  492. background-color: #007aff;
  493. color: #ffffff;
  494. font-size: 32rpx;
  495. border-radius: 16rpx;
  496. border: none;
  497. &:active {
  498. background-color: #0062cc;
  499. }
  500. }
  501. .reject-btn {
  502. width: 45%;
  503. height: 80rpx;
  504. background-color: #ff4d4f;
  505. color: #ffffff;
  506. font-size: 32rpx;
  507. border-radius: 16rpx;
  508. border: none;
  509. &:active {
  510. background-color: #d9363e;
  511. }
  512. }
  513. }
  514. .loading-mask {
  515. position: absolute;
  516. top: 0;
  517. left: 0;
  518. right: 0;
  519. bottom: 0;
  520. justify-content: center;
  521. align-items: center;
  522. background-color: rgba(0, 0, 0, 0.3);
  523. .loading-text {
  524. padding: 30rpx 60rpx;
  525. background-color: rgba(0, 0, 0, 0.7);
  526. color: #ffffff;
  527. font-size: 28rpx;
  528. border-radius: 12rpx;
  529. }
  530. }
  531. .picker-modal {
  532. position: fixed;
  533. top: 0;
  534. left: 0;
  535. right: 0;
  536. bottom: 0;
  537. z-index: 1000;
  538. }
  539. .modal-mask {
  540. position: absolute;
  541. top: 0;
  542. left: 0;
  543. right: 0;
  544. bottom: 0;
  545. background-color: rgba(0, 0, 0, 0.5);
  546. }
  547. .modal-content {
  548. position: absolute;
  549. bottom: 0;
  550. left: 0;
  551. right: 0;
  552. background-color: #ffffff;
  553. border-top-left-radius: 16rpx;
  554. border-top-right-radius: 16rpx;
  555. max-height: 700rpx;
  556. }
  557. .modal-header {
  558. flex-direction: row;
  559. justify-content: space-between;
  560. align-items: center;
  561. padding: 30rpx;
  562. border-bottom: 1rpx solid #f0f0f0;
  563. }
  564. .modal-title {
  565. font-size: 32rpx;
  566. font-weight: bold;
  567. color: #333333;
  568. }
  569. .modal-close {
  570. font-size: 28rpx;
  571. color: #007aff;
  572. }
  573. .modal-body {
  574. max-height: 600rpx;
  575. }
  576. .picker-option {
  577. flex-direction: row;
  578. justify-content: space-between;
  579. align-items: center;
  580. padding: 24rpx 30rpx;
  581. border-bottom: 1rpx solid #f0f0f0;
  582. }
  583. .picker-option.selected {
  584. background-color: #f8f9fa;
  585. }
  586. .option-text {
  587. font-size: 28rpx;
  588. color: #333333;
  589. }
  590. .option-check {
  591. font-size: 28rpx;
  592. color: #007aff;
  593. }
  594. .form-picker {
  595. flex: 1;
  596. }
  597. .picker-display {
  598. flex-direction: row;
  599. justify-content: space-between;
  600. align-items: center;
  601. min-height: 40rpx;
  602. }
  603. .selected-value {
  604. font-size: 28rpx;
  605. color: #333333;
  606. }
  607. .placeholder {
  608. font-size: 28rpx;
  609. color: #999999;
  610. }
  611. .arrow {
  612. font-size: 24rpx;
  613. color: #999999;
  614. margin-left: 12rpx;
  615. }
  616. .reject-reason-textarea {
  617. width: 100%;
  618. min-height: 100rpx;
  619. line-height: 1.5;
  620. }
  621. </style>