resumeIndex.uvue 23 KB

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