index.uvue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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">
  31. <text class="info-label">创建时间</text>
  32. <text class="info-value">{{ detailData.createTime ?? '' }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 工单流转 -->
  37. <view class="info-section">
  38. <view class="section-title">
  39. <text class="section-title-text">工单流转</text>
  40. <text @click="toggleFlowList" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 1" class="toggle-btn">{{ isFlowListExpanded ? '收起' : '展开' }}</text>
  41. </view>
  42. <view class="info-card" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 0">
  43. <view class="flow-item" v-for="(flow, index) in displayedFlowList" :key="index">
  44. <view class="flow-header">
  45. <text class="flow-operator">{{ flow.operatorName ?? '未知操作人' }}</text>
  46. <text class="flow-time">{{ flow.actionTime ?? '' }}</text>
  47. </view>
  48. <view class="flow-content">
  49. <text class="flow-action">{{ getActionTypeName(flow.actionType) }}</text>
  50. <!-- <text class="flow-remark" v-if="flow.actionRemark">{{ flow.actionRemark }}</text> -->
  51. </view>
  52. </view>
  53. </view>
  54. <view class="info-card" v-else>
  55. <view class="no-data">暂无流转记录</view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. <!-- 加载中状态 -->
  60. <view v-if="loading" class="loading-mask">
  61. <text class="loading-text">加载中...</text>
  62. </view>
  63. </view>
  64. </template>
  65. <script setup lang="uts">
  66. import { ref, computed } from 'vue'
  67. import type { acceptOrderInfo } from '../../../types/order'
  68. import type { WorkOrderFlow } from '../../../types/flow'
  69. import { getOrderInfoById, getRepairOrderInfoById } from '../../../api/order/detail'
  70. import type { SysDictData } from '../../../types/dict'
  71. import { getDictDataByType } from '../../../api/dict/index'
  72. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  73. // 添加字典加载状态
  74. const dictLoaded = ref<boolean>(false)
  75. // 获取工单状态字典列表
  76. const loadStatusDictList = async (): Promise<void> => {
  77. try {
  78. const result = await getDictDataByType('gxt_repair_order_flow_action_type')
  79. const resultObj = result as UTSJSONObject
  80. if (resultObj['code'] == 200) {
  81. const data = resultObj['data'] as any[]
  82. const dictData: SysDictData[] = []
  83. if (data.length > 0) {
  84. for (let i = 0; i < data.length; i++) {
  85. const item = data[i] as UTSJSONObject
  86. // 只提取需要的字段
  87. const dictItem: SysDictData = {
  88. dictValue: item['dictValue'] as string | null,
  89. dictLabel: item['dictLabel'] as string | null,
  90. dictCode: null,
  91. dictSort: null,
  92. dictType: null,
  93. cssClass: null,
  94. listClass: null,
  95. isDefault: null,
  96. status: null,
  97. default: null,
  98. createTime: null,
  99. remark: null
  100. }
  101. dictData.push(dictItem)
  102. }
  103. }
  104. statusDictList.value = dictData
  105. dictLoaded.value = true
  106. }
  107. } catch (e: any) {
  108. console.error('获取工单状态字典失败:', e.message)
  109. dictLoaded.value = true
  110. }
  111. }
  112. // 详情数据
  113. const detailData = ref<acceptOrderInfo>({
  114. orderType: 0,
  115. id: 0,
  116. teamLeaderId: 0,
  117. acceptUserId: 0,
  118. teamLeaderName: null,
  119. acceptUserName: null,
  120. acceptTime: null,
  121. assignTime: null,
  122. assignUserName: null,
  123. status: 0,
  124. workOrderProjectNo: null,
  125. workOrderStatus: null,
  126. gxtCenterId: 0,
  127. gxtCenter: null,
  128. pcsStationId: 0,
  129. pcsStationName: null,
  130. pcsDeviceId: 0,
  131. pcsDeviceName: null,
  132. brand: null,
  133. model: null,
  134. createTime: null,
  135. workOrderFlowList: null,
  136. suspendReason: null,
  137. rejectionReason: null,
  138. updateTime: null, // 新增字段
  139. workEndTime: null // 新增字段
  140. })
  141. const loading = ref<boolean>(false)
  142. // 控制工单流转列表是否展开
  143. const isFlowListExpanded = ref<boolean>(false)
  144. // 计算显示的工单流转列表
  145. const displayedFlowList = computed(() => {
  146. if (detailData.value.workOrderFlowList == null) return []
  147. // 如果已经展开,则显示全部
  148. if (isFlowListExpanded.value) {
  149. return detailData.value.workOrderFlowList
  150. }
  151. // 默认只显示最后一条
  152. const length = detailData.value.workOrderFlowList.length
  153. return length > 0 ? [detailData.value.workOrderFlowList[length - 1]] : []
  154. })
  155. // 切换工单流转列表的展开/收起状态
  156. const toggleFlowList = () => {
  157. isFlowListExpanded.value = !isFlowListExpanded.value
  158. }
  159. // 获取操作类型名称
  160. const getActionTypeName = (item: string | null): string | null => {
  161. if (item == null) return ''
  162. // const orderInfoItem = item as orderInfo
  163. const rawStatus = item
  164. if (rawStatus==null) return ''
  165. // 如果字典尚未加载,返回原始值
  166. if (dictLoaded.value == false) {
  167. return rawStatus
  168. }
  169. // 查找字典中对应的标签
  170. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  171. return dictItem!=null ? dictItem.dictLabel : rawStatus
  172. }
  173. // 加载详情数据
  174. const loadDetail = async (id: string, orderType?: number): Promise<void> => {
  175. try {
  176. loading.value = true
  177. let result: any;
  178. // 根据orderType决定调用哪个API
  179. if (orderType == 1) {
  180. // 维修工单
  181. result = await getRepairOrderInfoById(id)
  182. } else {
  183. // 维保工单
  184. result = await getOrderInfoById(id)
  185. }
  186. // 提取响应数据
  187. const resultObj = result as UTSJSONObject
  188. const code = resultObj['code'] as number
  189. const data = resultObj['data'] as UTSJSONObject | null
  190. if (code == 200 && data != null) {
  191. // 处理工单流转列表
  192. let workOrderFlowList: WorkOrderFlow[] | null = null
  193. let flowList: UTSJSONObject[] = []
  194. if (orderType == 1) {
  195. // 维修工单
  196. flowList = data['repairOrderFlowList'] as UTSJSONObject[]
  197. } else {
  198. // 维保工单
  199. flowList = data['workOrderFlowList'] as UTSJSONObject[]
  200. }
  201. if (flowList != null) {
  202. workOrderFlowList = []
  203. for (let i = 0; i < flowList.length; i++) {
  204. const flowItem = flowList[i]
  205. const flow: WorkOrderFlow = {
  206. id: flowItem['id'] as Number,
  207. orderId: flowItem['orderId'] as Number,
  208. orderCode: flowItem['orderCode'] as string,
  209. actionType: flowItem['actionType'] as string,
  210. fromStatus: flowItem['fromStatus'] as string | null,
  211. toStatus: flowItem['toStatus'] as string,
  212. operatorId: flowItem['operatorId'] as Number | null,
  213. operatorName: flowItem['operatorName'] as string | null,
  214. actionTime: flowItem['actionTime'] as string,
  215. actionRemark: flowItem['actionRemark'] as string | null,
  216. createBy: flowItem['createBy'] as string | null,
  217. createTime: flowItem['createTime'] as string | null
  218. }
  219. workOrderFlowList.push(flow)
  220. }
  221. }
  222. // 转换数据
  223. const orderDtail: acceptOrderInfo = {
  224. orderType: data['orderType'] as Number,
  225. id: data['id'] as Number,
  226. teamLeaderId: data['teamLeaderId'] != null ? (data['teamLeaderId'] as Number) : 0,
  227. acceptUserId: data['acceptUserId'] != null ? (data['acceptUserId'] as Number) : 0,
  228. teamLeaderName: data['teamLeaderName'] as string | null,
  229. acceptUserName: data['acceptUserName'] as string | null,
  230. acceptTime: data['acceptTime'] as string | null,
  231. assignTime: data['assignTime'] as string | null,
  232. assignUserName: data['assignUserName'] as string | null,
  233. status: (data['status']==null)?0:data['status'] as Number,
  234. workOrderProjectNo: data['workOrderProjectNo'] as string | null,
  235. workOrderStatus: data['workOrderStatus'] as string | null,
  236. gxtCenterId: data['gxtCenterId'] as Number | 0,
  237. gxtCenter: data['gxtCenter'] as string | null,
  238. pcsStationId: data['pcsStationId'] as Number | 0,
  239. pcsStationName: data['pcsStationName'] as string | null,
  240. pcsDeviceId: data['pcsDeviceId'] as Number | 0,
  241. pcsDeviceName: data['pcsDeviceName'] as string | null,
  242. brand: data['brand'] as string | null,
  243. model: data['model'] as string | null,
  244. createTime: data['createTime'] as string | null,
  245. workOrderFlowList: workOrderFlowList,
  246. suspendReason: data['suspendReason'] as string | null,
  247. rejectionReason: data['rejectionReason'] as string | null,
  248. updateTime: data['updateTime'] as string | null, // 新增字段
  249. workEndTime: data['workEndTime'] as string | null // 新增字段
  250. }
  251. detailData.value = orderDtail
  252. } else {
  253. const msg = resultObj['msg'] as string | null
  254. uni.showToast({
  255. title: msg ?? '加载失败',
  256. icon: 'none'
  257. })
  258. }
  259. } catch (e: any) {
  260. uni.showToast({
  261. title: e.message ?? '加载失败',
  262. icon: 'none'
  263. })
  264. } finally {
  265. loading.value = false
  266. }
  267. }
  268. // 页面加载
  269. onLoad((options: any) => {
  270. const params = options as UTSJSONObject
  271. const id = params['id'] as string | null
  272. const orderTypeParam = params['orderType'] as string | null
  273. if (id != null && orderTypeParam != null) {
  274. // 先尝试从参数中获取orderType
  275. const orderTypeNumber = parseInt(orderTypeParam)
  276. loadDetail(id, orderTypeNumber)
  277. }
  278. })
  279. // 初始化
  280. onMounted(() => {
  281. loadStatusDictList()
  282. })
  283. </script>
  284. <style lang="scss">
  285. .detail-page {
  286. flex: 1;
  287. background-color: #e8f0f9;
  288. }
  289. .detail-content {
  290. flex: 1;
  291. padding: 20rpx 0;
  292. }
  293. .info-section {
  294. margin: 0 30rpx 24rpx;
  295. .section-title {
  296. position: relative;
  297. padding-left: 20rpx;
  298. margin-bottom: 20rpx;
  299. flex-direction: row;
  300. justify-content: space-between;
  301. align-items: center;
  302. &::before {
  303. // content: '';
  304. position: absolute;
  305. left: 0;
  306. top: 50%;
  307. transform: translateY(-50%);
  308. width: 8rpx;
  309. height: 32rpx;
  310. background-color: #007aff;
  311. border-radius: 4rpx;
  312. }
  313. &-text {
  314. font-size: 32rpx;
  315. font-weight: bold;
  316. color: #333333;
  317. }
  318. .toggle-btn {
  319. padding-right: 20rpx;
  320. font-size: 28rpx;
  321. color: #165dff;
  322. }
  323. }
  324. .info-card {
  325. background-color: #ffffff;
  326. border-radius: 16rpx;
  327. padding: 30rpx;
  328. .info-item {
  329. flex-direction: row;
  330. padding: 20rpx 0;
  331. border-bottom: 1rpx solid #f0f0f0;
  332. &:last-child {
  333. border-bottom: none;
  334. }
  335. &.full-width {
  336. flex-direction: column;
  337. .info-label {
  338. margin-bottom: 12rpx;
  339. }
  340. .info-value {
  341. line-height: 44rpx;
  342. }
  343. }
  344. .info-label {
  345. width: 240rpx;
  346. font-size: 28rpx;
  347. color: #666666;
  348. white-space: nowrap;
  349. }
  350. .info-value {
  351. flex: 1;
  352. font-size: 28rpx;
  353. color: #333333;
  354. text-align: right;
  355. &.highlight {
  356. color: #007aff;
  357. font-weight: bold;
  358. }
  359. }
  360. }
  361. .flow-item {
  362. padding: 20rpx 0;
  363. border-bottom: 1rpx solid #f0f0f0;
  364. &:last-child {
  365. border-bottom: none;
  366. }
  367. .flow-header {
  368. flex-direction: row;
  369. justify-content: space-between;
  370. margin-bottom: 10rpx;
  371. .flow-operator {
  372. font-size: 28rpx;
  373. color: #333333;
  374. font-weight: bold;
  375. }
  376. .flow-time {
  377. font-size: 24rpx;
  378. color: #999999;
  379. }
  380. }
  381. .flow-content {
  382. flex-direction: column;
  383. .flow-action {
  384. font-size: 26rpx;
  385. color: #666666;
  386. margin-bottom: 8rpx;
  387. }
  388. .flow-remark {
  389. font-size: 24rpx;
  390. color: #999999;
  391. background-color: #f5f5f5;
  392. padding: 10rpx;
  393. border-radius: 8rpx;
  394. }
  395. }
  396. }
  397. .no-data {
  398. text-align: center;
  399. padding: 40rpx 0;
  400. font-size: 28rpx;
  401. color: #999999;
  402. }
  403. }
  404. }
  405. .loading-mask {
  406. position: absolute;
  407. top: 0;
  408. left: 0;
  409. right: 0;
  410. bottom: 0;
  411. justify-content: center;
  412. align-items: center;
  413. background-color: rgba(0, 0, 0, 0.3);
  414. .loading-text {
  415. padding: 30rpx 60rpx;
  416. background-color: rgba(0, 0, 0, 0.7);
  417. color: #ffffff;
  418. font-size: 28rpx;
  419. border-radius: 12rpx;
  420. }
  421. }
  422. </style>