resumeIndex.uvue 22 KB

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