index.uvue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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.pcsStationName ?? '' }}</text>
  25. </view>
  26. <view class="info-item">
  27. <text class="info-label">机型</text>
  28. <text class="info-value">{{ detailData.brand ?? '' }} {{ detailData.model ?? '' }}</text>
  29. </view>
  30. <view class="info-item" v-if="returnType">
  31. <text class="info-label">结单退回原因</text>
  32. <text class="info-value">{{ getReturnTypeName(returnType)}}</text>
  33. </view>
  34. <view class="info-item" v-if="returnReason">
  35. <text class="info-label">结单退回说明</text>
  36. <text class="info-value">{{ returnReason}}</text>
  37. </view>
  38. <view class="info-item" v-if="acceptReturnType">
  39. <text class="info-label">接单退回原因</text>
  40. <text class="info-value">{{ getAcceptReturnTypeName(acceptReturnType)}}</text>
  41. </view>
  42. <view class="info-item" v-if="acceptReturnReason">
  43. <text class="info-label">接单退回说明</text>
  44. <text class="info-value">{{ acceptReturnReason}}</text>
  45. </view>
  46. <view class="info-item">
  47. <text class="info-label">{{getLabel(detailData)}}</text>
  48. <text class="info-value">{{ getDisplayTime(detailData) }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 工单流转 -->
  53. <view class="info-section">
  54. <view class="section-title">
  55. <text class="section-title-text">工单流转</text>
  56. <text @click="toggleFlowList" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 1" class="toggle-btn">{{ isFlowListExpanded ? '收起' : '展开' }}</text>
  57. </view>
  58. <view class="info-card" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 0">
  59. <view class="flow-item" v-for="(flow, index) in displayedFlowList" :key="index">
  60. <view class="flow-header">
  61. <text class="flow-operator">{{ flow.operatorName ?? '未知操作人' }}</text>
  62. <text class="flow-time">{{ flow.actionTime ?? '' }}</text>
  63. </view>
  64. <view class="flow-content">
  65. <text class="flow-action">{{ getActionTypeName(flow.actionType) }}</text>
  66. <!-- <text class="flow-remark" v-if="flow.actionRemark">{{ flow.actionRemark }}</text> -->
  67. </view>
  68. </view>
  69. </view>
  70. <view class="info-card" v-else>
  71. <view class="no-data">暂无流转记录</view>
  72. </view>
  73. </view>
  74. </scroll-view>
  75. <!-- 加载中状态 -->
  76. <view v-if="loading" class="loading-mask">
  77. <text class="loading-text">加载中...</text>
  78. </view>
  79. </view>
  80. </template>
  81. <script setup lang="uts">
  82. import { ref, computed } from 'vue'
  83. import type { acceptOrderInfo } from '../../../types/order'
  84. import type { WorkOrderFlow } from '../../../types/flow'
  85. import { getOrderInfoById, getRepairOrderInfoById } from '../../../api/order/detail'
  86. import type { SysDictData } from '../../../types/dict'
  87. import { getDictDataByType } from '../../../api/dict/index'
  88. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  89. // 添加字典加载状态
  90. const dictLoaded = ref<boolean>(false)
  91. const returnType = ref<string>("")
  92. const returnReason = ref<string>("")
  93. const acceptReturnType = ref<string>("")
  94. const acceptReturnReason = ref<string>("")
  95. const returnTypeDictList = ref<SysDictData[]>([]) // 退回原因字典列表
  96. const acceptReturnTypeDictList = ref<SysDictData[]>([]) // 退回原因字典列表
  97. const formatDate = (dateString: string): string => {
  98. if (dateString == '' || dateString == null) return ''
  99. const date = new Date(dateString)
  100. const year = date.getFullYear()
  101. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  102. const day = date.getDate().toString().padStart(2, '0')
  103. const hours = date.getHours().toString().padStart(2, '0')
  104. const minutes = date.getMinutes().toString().padStart(2, '0')
  105. return `${year}-${month}-${day} ${hours}:${minutes}`
  106. }
  107. // 根据状态显示不同的时间label
  108. const getLabel = (item : acceptOrderInfo): string|null => {
  109. if (item == null) return null
  110. // 如果是"待接单"状态,显示派单时间
  111. if (item.workOrderStatus == 'assigned') {
  112. return '下发时间'
  113. } else if(item.workOrderStatus == 'to_finish') {
  114. if(item.workEndTime != null) {
  115. return '结束时间'
  116. }
  117. return '接单时间'
  118. } else if(item.workOrderStatus == 'to_approve') {
  119. return '申请挂起时间'
  120. } else if(item.workOrderStatus == 'suspended') {
  121. return '审批通过时间'
  122. } else if(item.workOrderStatus == 'return' || item.workOrderStatus == 'accept_return') {
  123. return '退回时间'
  124. } else if(item.workOrderStatus == 'completed') {
  125. return '结单时间'
  126. } else if(item.workOrderStatus == "archived") {
  127. return '归档时间'
  128. }
  129. // 默认显示创建时间
  130. return '创建时间'
  131. }
  132. // 根据状态显示不同的时间
  133. const getDisplayTime = (item : acceptOrderInfo): string|null => {
  134. if (item == null) return null
  135. let showTime = ref<string|null>('')
  136. // 如果是"待接单"状态,显示派单时间
  137. if (item.workOrderStatus == 'assigned') {
  138. showTime.value = item.assignTime
  139. } else if(item.workOrderStatus == 'to_finish') {
  140. showTime.value = item.acceptTime
  141. } else if(item.workOrderStatus == 'to_approve') {
  142. showTime.value = item.updateTime
  143. } else if(item.workOrderStatus == 'suspended') {
  144. showTime.value = item.updateTime
  145. } else if(item.workOrderStatus == 'return' || item.workOrderStatus == 'accept_return') {
  146. showTime.value = item.updateTime
  147. } else if(item.workOrderStatus == 'completed') {
  148. showTime.value = item.updateTime
  149. } else if(item.workOrderStatus == "archived") {
  150. showTime.value = item.updateTime
  151. } else {
  152. if (item.createTime != null && item.createTime.length >= 3) {
  153. showTime.value = item.createTime.slice(0, -3);
  154. } else {
  155. showTime.value = item.createTime != null ? item.createTime : '';
  156. }
  157. }
  158. return showTime.value
  159. // return formatDate(showTime.value ?? '')
  160. }
  161. // 获取工单状态字典列表
  162. const loadStatusDictList = async (): Promise<void> => {
  163. try {
  164. const result = await getDictDataByType('gxt_repair_order_flow_action_type')
  165. const resultObj = result as UTSJSONObject
  166. if (resultObj['code'] == 200) {
  167. const data = resultObj['data'] as any[]
  168. const dictData: SysDictData[] = []
  169. if (data.length > 0) {
  170. for (let i = 0; i < data.length; i++) {
  171. const item = data[i] as UTSJSONObject
  172. // 只提取需要的字段
  173. const dictItem: SysDictData = {
  174. dictValue: item['dictValue'] as string | null,
  175. dictLabel: item['dictLabel'] as string | null,
  176. dictCode: null,
  177. dictSort: null,
  178. dictType: null,
  179. cssClass: null,
  180. listClass: null,
  181. isDefault: null,
  182. status: null,
  183. default: null,
  184. createTime: null,
  185. remark: null
  186. }
  187. dictData.push(dictItem)
  188. }
  189. }
  190. statusDictList.value = dictData
  191. dictLoaded.value = true
  192. }
  193. } catch (e: any) {
  194. console.error('获取工单状态字典失败:', e.message)
  195. dictLoaded.value = true
  196. }
  197. }
  198. // 详情数据
  199. const detailData = ref<acceptOrderInfo>({
  200. orderType: 0,
  201. id: 0,
  202. teamLeaderId: 0,
  203. acceptUserId: 0,
  204. teamLeaderName: null,
  205. acceptUserName: null,
  206. acceptTime: null,
  207. assignTime: null,
  208. assignUserName: null,
  209. status: 0,
  210. workOrderProjectNo: null,
  211. workOrderStatus: null,
  212. gxtCenterId: 0,
  213. gxtCenter: null,
  214. pcsStationId: 0,
  215. pcsStationName: null,
  216. pcsDeviceId: 0,
  217. pcsDeviceName: null,
  218. brand: null,
  219. model: null,
  220. createTime: null,
  221. workOrderFlowList: null,
  222. suspendReason: null,
  223. rejectionReason: null,
  224. updateTime: null, // 新增字段
  225. workEndTime: null // 新增字段
  226. })
  227. const loading = ref<boolean>(false)
  228. // 控制工单流转列表是否展开
  229. const isFlowListExpanded = ref<boolean>(false)
  230. // 计算显示的工单流转列表
  231. const displayedFlowList = computed(() => {
  232. if (detailData.value.workOrderFlowList == null) return []
  233. // 如果已经展开,则显示全部
  234. if (isFlowListExpanded.value) {
  235. return detailData.value.workOrderFlowList
  236. }
  237. // 默认只显示最后一条
  238. const length = detailData.value.workOrderFlowList.length
  239. return length > 0 ? [detailData.value.workOrderFlowList[length - 1]] : []
  240. })
  241. // 切换工单流转列表的展开/收起状态
  242. const toggleFlowList = () => {
  243. isFlowListExpanded.value = !isFlowListExpanded.value
  244. }
  245. // 获取操作类型名称
  246. const getActionTypeName = (item: string | null): string | null => {
  247. if (item == null) return ''
  248. // const orderInfoItem = item as orderInfo
  249. const rawStatus = item
  250. if (rawStatus==null) return ''
  251. // 如果字典尚未加载,返回原始值
  252. if (dictLoaded.value == false) {
  253. return rawStatus
  254. }
  255. // 查找字典中对应的标签
  256. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  257. return dictItem!=null ? dictItem.dictLabel : rawStatus
  258. }
  259. const getReturnTypeName = (item: string | null): string | null => {
  260. if (item == null) return ''
  261. // const orderInfoItem = item as orderInfo
  262. const rawStatus = item
  263. if (rawStatus==null) return ''
  264. // 如果字典尚未加载,返回原始值
  265. if (dictLoaded.value == false) {
  266. return rawStatus
  267. }
  268. // 查找字典中对应的标签
  269. const dictItem = returnTypeDictList.value.find(dict => dict.dictValue == rawStatus)
  270. return dictItem!=null ? dictItem.dictLabel : rawStatus
  271. }
  272. const getAcceptReturnTypeName = (item: string | null): string | null => {
  273. if (item == null) return ''
  274. // const orderInfoItem = item as orderInfo
  275. const rawStatus = item
  276. if (rawStatus==null) return ''
  277. // 如果字典尚未加载,返回原始值
  278. if (dictLoaded.value == false) {
  279. return rawStatus
  280. }
  281. // 查找字典中对应的标签
  282. const dictItem = acceptReturnTypeDictList.value.find(dict => dict.dictValue == rawStatus)
  283. return dictItem!=null ? dictItem.dictLabel : rawStatus
  284. }
  285. const loadReturnDictList = async (returnTypeDict: string): Promise<void> => {
  286. try {
  287. const result = await getDictDataByType(returnTypeDict)
  288. const resultObj = result as UTSJSONObject
  289. if (resultObj['code'] == 200) {
  290. const data = resultObj['data'] as any[]
  291. const dictData: SysDictData[] = []
  292. if (data.length > 0) {
  293. for (let i = 0; i < data.length; i++) {
  294. const item = data[i] as UTSJSONObject
  295. // 只提取需要的字段
  296. const dictItem: SysDictData = {
  297. dictValue: item['dictValue'] as string | null,
  298. dictLabel: item['dictLabel'] as string | null,
  299. dictCode: null,
  300. dictSort: null,
  301. dictType: null,
  302. cssClass: null,
  303. listClass: null,
  304. isDefault: null,
  305. status: null,
  306. default: null,
  307. createTime: null,
  308. remark: null
  309. }
  310. dictData.push(dictItem)
  311. }
  312. }
  313. if(returnTypeDict == 'gxt_return_type') {
  314. returnTypeDictList.value = dictData
  315. } else {
  316. acceptReturnTypeDictList.value = dictData
  317. }
  318. }
  319. } catch (e: any) {
  320. console.error('获取工单状态字典失败:', e.message)
  321. }
  322. }
  323. // 加载详情数据
  324. const loadDetail = async (id: string, orderType?: number): Promise<void> => {
  325. try {
  326. loading.value = true
  327. let result: any;
  328. // 根据orderType决定调用哪个API
  329. if (orderType == 1) {
  330. // 维修工单
  331. result = await getRepairOrderInfoById(id)
  332. } else {
  333. // 维保工单
  334. result = await getOrderInfoById(id)
  335. }
  336. // 提取响应数据
  337. const resultObj = result as UTSJSONObject
  338. const code = resultObj['code'] as number
  339. const data = resultObj['data'] as UTSJSONObject | null
  340. if (code == 200 && data != null) {
  341. // 处理工单流转列表
  342. let workOrderFlowList: WorkOrderFlow[] | null = null
  343. let flowList: UTSJSONObject[] = []
  344. if (orderType == 1) {
  345. // 维修工单
  346. flowList = data['repairOrderFlowList'] as UTSJSONObject[]
  347. } else {
  348. // 维保工单
  349. flowList = data['workOrderFlowList'] as UTSJSONObject[]
  350. }
  351. if (flowList != null) {
  352. workOrderFlowList = []
  353. for (let i = 0; i < flowList.length; i++) {
  354. const flowItem = flowList[i]
  355. const flow: WorkOrderFlow = {
  356. id: flowItem['id'] as Number,
  357. orderId: flowItem['orderId'] as Number,
  358. orderCode: flowItem['orderCode'] as string,
  359. actionType: flowItem['actionType'] as string,
  360. fromStatus: flowItem['fromStatus'] as string | null,
  361. toStatus: flowItem['toStatus'] as string,
  362. operatorId: flowItem['operatorId'] as Number | null,
  363. operatorName: flowItem['operatorName'] as string | null,
  364. actionTime: flowItem['actionTime'] as string,
  365. actionRemark: flowItem['actionRemark'] as string | null,
  366. createBy: flowItem['createBy'] as string | null,
  367. createTime: flowItem['createTime'] as string | null
  368. }
  369. workOrderFlowList.push(flow)
  370. }
  371. }
  372. // 转换数据
  373. const orderDtail: acceptOrderInfo = {
  374. orderType: data['orderType'] as Number,
  375. id: data['id'] as Number,
  376. teamLeaderId: data['teamLeaderId'] != null ? (data['teamLeaderId'] as Number) : 0,
  377. acceptUserId: data['acceptUserId'] != null ? (data['acceptUserId'] as Number) : 0,
  378. teamLeaderName: data['teamLeaderName'] as string | null,
  379. acceptUserName: data['acceptUserName'] as string | null,
  380. acceptTime: data['acceptTime'] as string | null,
  381. assignTime: data['assignTime'] as string | null,
  382. assignUserName: data['assignUserName'] as string | null,
  383. status: (data['status']==null)?0:data['status'] as Number,
  384. workOrderProjectNo: data['workOrderProjectNo'] as string | null,
  385. workOrderStatus: data['workOrderStatus'] as string | null,
  386. gxtCenterId: data['gxtCenterId'] as Number | 0,
  387. gxtCenter: data['gxtCenter'] as string | null,
  388. pcsStationId: data['pcsStationId'] as Number | 0,
  389. pcsStationName: data['pcsStationName'] as string | null,
  390. pcsDeviceId: data['pcsDeviceId'] as Number | 0,
  391. pcsDeviceName: data['pcsDeviceName'] as string | null,
  392. brand: data['brand'] as string | null,
  393. model: data['model'] as string | null,
  394. createTime: data['createTime'] as string | null,
  395. workOrderFlowList: workOrderFlowList,
  396. suspendReason: data['suspendReason'] as string | null,
  397. rejectionReason: data['rejectionReason'] as string | null,
  398. updateTime: data['updateTime'] as string | null, // 新增字段
  399. workEndTime: data['workEndTime'] as string | null // 新增字段
  400. }
  401. detailData.value = orderDtail
  402. await loadReturnDictList('gxt_return_type')
  403. await loadReturnDictList('gxt_accept_return_type')
  404. returnType.value = (data['returnType'] as string | null) ?? ''
  405. returnReason.value = (data['returnReason'] as string | null) ?? ''
  406. acceptReturnType.value = (data['acceptReturnType'] as string | null) ?? ''
  407. acceptReturnReason.value = (data['acceptReturnReason'] as string | null) ?? ''
  408. } else {
  409. const msg = resultObj['msg'] as string | null
  410. uni.showToast({
  411. title: msg ?? '加载失败',
  412. icon: 'none'
  413. })
  414. }
  415. } catch (e: any) {
  416. uni.showToast({
  417. title: e.message ?? '加载失败',
  418. icon: 'none'
  419. })
  420. } finally {
  421. loading.value = false
  422. }
  423. }
  424. // 页面加载
  425. onLoad((options: any) => {
  426. const params = options as UTSJSONObject
  427. const id = params['id'] as string | null
  428. const orderTypeParam = params['orderType'] as string | null
  429. if (id != null && orderTypeParam != null) {
  430. // 先尝试从参数中获取orderType
  431. const orderTypeNumber = parseInt(orderTypeParam)
  432. loadDetail(id, orderTypeNumber)
  433. }
  434. })
  435. // 初始化
  436. onMounted(() => {
  437. loadStatusDictList()
  438. })
  439. </script>
  440. <style lang="scss">
  441. .detail-page {
  442. flex: 1;
  443. background-color: #e8f0f9;
  444. }
  445. .detail-content {
  446. flex: 1;
  447. padding: 20rpx 0;
  448. }
  449. .info-section {
  450. margin: 0 30rpx 24rpx;
  451. .section-title {
  452. position: relative;
  453. padding-left: 20rpx;
  454. margin-bottom: 20rpx;
  455. flex-direction: row;
  456. justify-content: space-between;
  457. align-items: center;
  458. &::before {
  459. // content: '';
  460. position: absolute;
  461. left: 0;
  462. top: 50%;
  463. transform: translateY(-50%);
  464. width: 8rpx;
  465. height: 32rpx;
  466. background-color: #007aff;
  467. border-radius: 4rpx;
  468. }
  469. &-text {
  470. font-size: 32rpx;
  471. font-weight: bold;
  472. color: #333333;
  473. }
  474. .toggle-btn {
  475. padding-right: 20rpx;
  476. font-size: 28rpx;
  477. color: #165dff;
  478. }
  479. }
  480. .info-card {
  481. background-color: #ffffff;
  482. border-radius: 16rpx;
  483. padding: 30rpx;
  484. .info-item {
  485. flex-direction: row;
  486. padding: 20rpx 0;
  487. border-bottom: 1rpx solid #f0f0f0;
  488. &:last-child {
  489. border-bottom: none;
  490. }
  491. &.full-width {
  492. flex-direction: column;
  493. .info-label {
  494. margin-bottom: 12rpx;
  495. }
  496. .info-value {
  497. line-height: 44rpx;
  498. }
  499. }
  500. .info-label {
  501. width: 240rpx;
  502. font-size: 28rpx;
  503. color: #666666;
  504. white-space: nowrap;
  505. }
  506. .info-value {
  507. flex: 1;
  508. font-size: 28rpx;
  509. color: #333333;
  510. text-align: right;
  511. &.highlight {
  512. color: #007aff;
  513. font-weight: bold;
  514. }
  515. }
  516. }
  517. .flow-item {
  518. padding: 20rpx 0;
  519. border-bottom: 1rpx solid #f0f0f0;
  520. &:last-child {
  521. border-bottom: none;
  522. }
  523. .flow-header {
  524. flex-direction: row;
  525. justify-content: space-between;
  526. margin-bottom: 10rpx;
  527. .flow-operator {
  528. font-size: 28rpx;
  529. color: #333333;
  530. font-weight: bold;
  531. }
  532. .flow-time {
  533. font-size: 24rpx;
  534. color: #999999;
  535. }
  536. }
  537. .flow-content {
  538. flex-direction: column;
  539. .flow-action {
  540. font-size: 26rpx;
  541. color: #666666;
  542. margin-bottom: 8rpx;
  543. }
  544. .flow-remark {
  545. font-size: 24rpx;
  546. color: #999999;
  547. background-color: #f5f5f5;
  548. padding: 10rpx;
  549. border-radius: 8rpx;
  550. }
  551. }
  552. }
  553. .no-data {
  554. text-align: center;
  555. padding: 40rpx 0;
  556. font-size: 28rpx;
  557. color: #999999;
  558. }
  559. }
  560. }
  561. .loading-mask {
  562. position: absolute;
  563. top: 0;
  564. left: 0;
  565. right: 0;
  566. bottom: 0;
  567. justify-content: center;
  568. align-items: center;
  569. background-color: rgba(0, 0, 0, 0.3);
  570. .loading-text {
  571. padding: 30rpx 60rpx;
  572. background-color: rgba(0, 0, 0, 0.7);
  573. color: #ffffff;
  574. font-size: 28rpx;
  575. border-radius: 12rpx;
  576. }
  577. }
  578. </style>