index.uvue 15 KB

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