index.uvue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  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" v-if="detailData.pauseTime != null && detailData.orderType == 1">
  47. <text class="info-label">发生时间</text>
  48. <text class="info-value">{{ detailData.pauseTime ?? '' }}</text>
  49. </view>
  50. <view class="info-item" v-if="detailData.pauseTime != null && detailData.orderType == 2">
  51. <text class="info-label">停机时间</text>
  52. <text class="info-value">{{ detailData.pauseTime ?? '' }}</text>
  53. </view>
  54. <view class="info-item" v-if="detailData.restartTime != null">
  55. <text class="info-label">恢复运行时间</text>
  56. <text class="info-value">{{ detailData.restartTime ?? '' }}</text>
  57. </view>
  58. <view class="info-item">
  59. <text class="info-label">{{getLabel(detailData)}}</text>
  60. <text class="info-value">{{ getDisplayTime(detailData) }}</text>
  61. </view>
  62. <view class="info-item" v-if="detailData.orderType == 2">
  63. <text class="info-label">维保类型</text>
  64. <text class="info-value">{{ inspectionTypeLabel }}</text>
  65. </view>
  66. <view class="info-item" v-if="detailData.orderType == 2">
  67. <text class="info-label">维保内容</text>
  68. <text class="info-value">{{ detailData.content ?? '' }}</text>
  69. </view>
  70. <!-- <view class="info-item" v-if="detailData.orderType == 1">
  71. <text class="info-label">故障代码</text>
  72. <text class="info-value">{{ detailData.faultCode ?? '' }}</text>
  73. </view>
  74. <view class="info-item" v-if="detailData.orderType == 1">
  75. <text class="info-label">故障条文</text>
  76. <text class="info-value">{{ detailData.faultBarcode ?? '' }}</text>
  77. </view>
  78. <view class="info-item" v-if="detailData.orderType == 1">
  79. <text class="info-label">故障描述</text>
  80. <text class="info-value">{{ detailData.faultDesc ?? '' }}</text>
  81. </view> -->
  82. <view class="info-item" v-if="detailData.orderType == 1">
  83. <text class="info-label">故障代码</text>
  84. <view class="info-value">
  85. <text class="inner-text">{{ detailData.faultCode ?? '' }}</text>
  86. </view>
  87. </view>
  88. <view class="info-item" v-if="detailData.orderType == 1">
  89. <text class="info-label">故障条文</text>
  90. <view class="info-value">
  91. <text class="inner-text">{{ detailData.faultBarcode ?? '' }}</text>
  92. </view>
  93. </view>
  94. <view class="info-item" v-if="detailData.orderType == 1">
  95. <text class="info-label">故障描述</text>
  96. <view class="info-value">
  97. <text class="inner-text">{{ detailData.faultDesc ?? '' }}</text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 附件信息 -->
  103. <view class="info-section" v-if="attachmentList.length > 0">
  104. <view class="section-title">
  105. <text class="section-title-text">附件</text>
  106. </view>
  107. <view class="info-card">
  108. <view class="image-container">
  109. <image
  110. v-for="(attachment, index) in attachmentList"
  111. :key="index"
  112. :src="attachment"
  113. :alt="'附件图片' + (index + 1)"
  114. class="attachment-image"
  115. @click="previewImage(attachment)"
  116. />
  117. </view>
  118. </view>
  119. </view>
  120. <!-- 工单流转 -->
  121. <view class="info-section">
  122. <view class="section-title">
  123. <text class="section-title-text">工单流转</text>
  124. <text @click="toggleFlowList" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 1" class="toggle-btn">{{ isFlowListExpanded ? '收起' : '展开' }}</text>
  125. </view>
  126. <view class="info-card" v-if="detailData.workOrderFlowList != null && detailData.workOrderFlowList.length > 0">
  127. <view class="flow-item" v-for="(flow, index) in displayedFlowList" :key="index">
  128. <view class="flow-header">
  129. <text class="flow-operator">{{ flow.operatorName ?? '未知操作人' }}</text>
  130. <text class="flow-time">{{ flow.actionTime ?? '' }}</text>
  131. </view>
  132. <view class="flow-content">
  133. <text class="flow-action">{{ getActionTypeName(flow.actionType) }}</text>
  134. <!-- <text class="flow-remark" v-if="flow.actionRemark">{{ flow.actionRemark }}</text> -->
  135. </view>
  136. </view>
  137. </view>
  138. <view class="info-card" v-else>
  139. <view class="no-data">暂无流转记录</view>
  140. </view>
  141. </view>
  142. </scroll-view>
  143. <!-- 加载中状态 -->
  144. <view v-if="loading" class="loading-mask">
  145. <text class="loading-text">加载中...</text>
  146. </view>
  147. </view>
  148. </template>
  149. <script setup lang="uts">
  150. import { ref, computed } from 'vue'
  151. //import type { acceptOrderInfo } from '../../../types/order'
  152. import type { WorkOrderFlow,WorkOrderFlowList } from '../../../types/flow'
  153. import { getOrderInfoById, getRepairOrderInfoById } from '../../../api/order/detail'
  154. import type { SysDictData } from '../../../types/dict'
  155. import { getDictDataByType } from '../../../api/dict/index'
  156. import { getBaseUrl } from '../../../utils/request'
  157. type OrderInfoForDetail = {
  158. orderType: Number
  159. id: Number
  160. teamLeaderId: Number | 0
  161. teamLeaderName: string | null
  162. acceptUserId: Number | 0
  163. acceptUserName: string | null
  164. acceptTime: string | null
  165. assignTime: string | null
  166. assignUserName: string | null
  167. status: Number
  168. workOrderProjectNo: string | null
  169. workOrderStatus: string | null
  170. gxtCenterId: Number | 0
  171. gxtCenter: string | null
  172. pcsStationId: Number | 0
  173. pcsStationName: string | null
  174. pcsDeviceId: Number | 0
  175. pcsDeviceName: string | null
  176. brand: string | null
  177. model: string | null
  178. createTime: string | null
  179. workOrderFlowList?: WorkOrderFlowList | null
  180. suspendReason: string | null
  181. rejectionReason: string | null
  182. updateTime: string | null // 新增字段
  183. workEndTime: string | null // 新增字段
  184. faultCode: string | null
  185. faultBarcode: string | null
  186. faultDesc: string | null
  187. pauseTime: string | null,
  188. restartTime: string | null,
  189. attachmentUrls: string | null, // 附件URLs(逗号分隔的字符串格式)
  190. content: string | null,
  191. inspectionType: string | null
  192. }
  193. // 详情数据
  194. const detailData = ref<OrderInfoForDetail>({
  195. orderType: 0,
  196. id: 0,
  197. teamLeaderId: 0,
  198. acceptUserId: 0,
  199. teamLeaderName: null,
  200. acceptUserName: null,
  201. acceptTime: null,
  202. assignTime: null,
  203. assignUserName: null,
  204. status: 0,
  205. workOrderProjectNo: null,
  206. workOrderStatus: null,
  207. gxtCenterId: 0,
  208. gxtCenter: null,
  209. pcsStationId: 0,
  210. pcsStationName: null,
  211. pcsDeviceId: 0,
  212. pcsDeviceName: null,
  213. brand: null,
  214. model: null,
  215. createTime: null,
  216. workOrderFlowList: null,
  217. suspendReason: null,
  218. rejectionReason: null,
  219. updateTime: null, // 新增字段
  220. workEndTime: null, // 新增字段
  221. faultCode: null,
  222. faultBarcode: null,
  223. faultDesc: null,
  224. pauseTime: null,
  225. restartTime: null,
  226. attachmentUrls: null,
  227. content: null,
  228. inspectionType: null
  229. })
  230. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  231. // 添加字典加载状态
  232. const dictLoaded = ref<boolean>(false)
  233. const returnType = ref<string>("")
  234. const returnReason = ref<string>("")
  235. const acceptReturnType = ref<string>("")
  236. const acceptReturnReason = ref<string>("")
  237. const returnTypeDictList = ref<SysDictData[]>([]) // 退回原因字典列表
  238. const acceptReturnTypeDictList = ref<SysDictData[]>([]) // 退回原因字典列表
  239. const inspectionTypeLabel = ref<string>("") //维保类型
  240. const formatDate = (dateString: string): string => {
  241. if (dateString == '' || dateString == null) return ''
  242. const date = new Date(dateString)
  243. const year = date.getFullYear()
  244. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  245. const day = date.getDate().toString().padStart(2, '0')
  246. const hours = date.getHours().toString().padStart(2, '0')
  247. const minutes = date.getMinutes().toString().padStart(2, '0')
  248. return `${year}-${month}-${day} ${hours}:${minutes}`
  249. }
  250. // 根据状态显示不同的时间label
  251. const getLabel = (item : OrderInfoForDetail | null): string|null => {
  252. if (item == null) return null
  253. // 如果是"待接单"状态,显示派单时间
  254. if (item.workOrderStatus == 'assigned' || item.workOrderStatus == 'auto_suspend') {
  255. return '下发时间'
  256. } else if(item.workOrderStatus == 'to_finish') {
  257. if(item.workEndTime != null) {
  258. return '结束时间'
  259. }
  260. return '接单时间'
  261. } else if(item.workOrderStatus == 'to_approve') {
  262. return '申请挂起时间'
  263. } else if(item.workOrderStatus == 'suspended') {
  264. return '审批通过时间'
  265. } else if(item.workOrderStatus == 'return' || item.workOrderStatus == 'accept_return') {
  266. return '退回时间'
  267. } else if(item.workOrderStatus == 'completed') {
  268. return '结单时间'
  269. } else if(item.workOrderStatus == "archived") {
  270. return '归档时间'
  271. }
  272. // 默认显示创建时间
  273. return '创建时间'
  274. }
  275. // 根据状态显示不同的时间
  276. const getDisplayTime = (item : OrderInfoForDetail | null): string|null => {
  277. if (item == null) return null
  278. let showTime = ref<string|null>('')
  279. // 如果是"待接单"状态,显示派单时间
  280. if (item.workOrderStatus == 'assigned' || item.workOrderStatus == 'auto_suspend') {
  281. showTime.value = item.assignTime
  282. } else if(item.workOrderStatus == 'to_finish') {
  283. showTime.value = item.acceptTime
  284. } else if(item.workOrderStatus == 'to_approve') {
  285. showTime.value = item.updateTime?.slice(0, -3) ?? ''
  286. } else if(item.workOrderStatus == 'suspended') {
  287. showTime.value = item.updateTime?.slice(0, -3) ?? ''
  288. } else if(item.workOrderStatus == 'return' || item.workOrderStatus == 'accept_return') {
  289. showTime.value = item.updateTime?.slice(0, -3) ?? ''
  290. } else if(item.workOrderStatus == 'completed') {
  291. showTime.value = item.updateTime?.slice(0, -3) ?? ''
  292. } else if(item.workOrderStatus == "archived") {
  293. showTime.value = item.updateTime?.slice(0, -3) ?? ''
  294. } else {
  295. if (item.createTime != null && item.createTime.length >= 3) {
  296. showTime.value = item.createTime.slice(0, -3);
  297. } else {
  298. showTime.value = item.createTime != null ? item.createTime : '';
  299. }
  300. }
  301. return showTime.value
  302. // return formatDate(showTime.value ?? '')
  303. }
  304. // 获取工单状态字典列表
  305. const loadStatusDictList = async (): Promise<void> => {
  306. try {
  307. const result = await getDictDataByType('gxt_repair_order_flow_action_type')
  308. const resultObj = result as UTSJSONObject
  309. if (resultObj['code'] == 200) {
  310. const data = resultObj['data'] as any[]
  311. const dictData: SysDictData[] = []
  312. if (data.length > 0) {
  313. for (let i = 0; i < data.length; i++) {
  314. const item = data[i] as UTSJSONObject
  315. // 只提取需要的字段
  316. const dictItem: SysDictData = {
  317. dictValue: item['dictValue'] as string | null,
  318. dictLabel: item['dictLabel'] as string | null,
  319. dictCode: null,
  320. dictSort: null,
  321. dictType: null,
  322. cssClass: null,
  323. listClass: null,
  324. isDefault: null,
  325. status: null,
  326. default: null,
  327. createTime: null,
  328. remark: null
  329. }
  330. dictData.push(dictItem)
  331. }
  332. }
  333. statusDictList.value = dictData
  334. dictLoaded.value = true
  335. }
  336. } catch (e: any) {
  337. console.error('获取工单状态字典失败:', e.message)
  338. dictLoaded.value = true
  339. }
  340. }
  341. const loading = ref<boolean>(false)
  342. // 控制工单流转列表是否展开
  343. const isFlowListExpanded = ref<boolean>(false)
  344. // 计算显示的工单流转列表
  345. const displayedFlowList = computed(() => {
  346. if (detailData.value.workOrderFlowList == null) return []
  347. // 如果已经展开,则显示全部
  348. if (isFlowListExpanded.value) {
  349. return detailData.value.workOrderFlowList
  350. }
  351. // 默认只显示最后一条
  352. const length = detailData.value.workOrderFlowList.length
  353. return length > 0 ? [detailData.value.workOrderFlowList[length - 1]] : []
  354. })
  355. // 切换工单流转列表的展开/收起状态
  356. const toggleFlowList = () => {
  357. isFlowListExpanded.value = !isFlowListExpanded.value
  358. }
  359. // 计算附件列表
  360. const attachmentList = computed<string[]>(() => {
  361. if (detailData.value.attachmentUrls != null && detailData.value.attachmentUrls != '') {
  362. // 按逗号分割附件URL字符串,并加上基础URL
  363. const arr = detailData.value.attachmentUrls.split(',')
  364. .map((url: string) => {
  365. const trimmedUrl = url.trim();
  366. // 如果是相对路径,加上基础URL
  367. if (trimmedUrl.startsWith('/')) {
  368. return getBaseUrl() + trimmedUrl;
  369. }
  370. return trimmedUrl;
  371. })
  372. .filter((url: string) => url.length > 0);
  373. return arr;
  374. }
  375. return []
  376. })
  377. // 预览图片
  378. const previewImage = (url: string) => {
  379. if (url == '') return
  380. // 检查是否为图片文件
  381. const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
  382. const isImage = imageExtensions.some(ext => url.toLowerCase().endsWith(ext))
  383. if (isImage) {
  384. // 如果是图片,使用uni.previewImage预览
  385. uni.previewImage({
  386. urls: [url],
  387. current: 0
  388. })
  389. } else {
  390. // 对于非图片文件,显示提示
  391. uni.showToast({
  392. title: '不支持预览此文件类型',
  393. icon: 'none',
  394. duration: 2000
  395. })
  396. }
  397. }
  398. // 获取操作类型名称
  399. const getActionTypeName = (item: string | null): string | null => {
  400. if (item == null) return ''
  401. // const orderInfoItem = item as orderInfo
  402. const rawStatus = item
  403. // 如果字典尚未加载,返回原始值
  404. if (dictLoaded.value == false) {
  405. return rawStatus
  406. }
  407. // 查找字典中对应的标签
  408. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  409. return dictItem!=null ? dictItem.dictLabel : rawStatus
  410. }
  411. const getReturnTypeName = (item: string | null): string | null => {
  412. if (item == null) return ''
  413. // const orderInfoItem = item as orderInfo
  414. const rawStatus = item
  415. // 如果字典尚未加载,返回原始值
  416. if (dictLoaded.value == false) {
  417. return rawStatus
  418. }
  419. // 查找字典中对应的标签
  420. const dictItem = returnTypeDictList.value.find(dict => dict.dictValue == rawStatus)
  421. return dictItem!=null ? dictItem.dictLabel : rawStatus
  422. }
  423. const getAcceptReturnTypeName = (item: string | null): string | null => {
  424. if (item == null) return ''
  425. // const orderInfoItem = item as orderInfo
  426. const rawStatus = item
  427. // 如果字典尚未加载,返回原始值
  428. if (dictLoaded.value == false) {
  429. return rawStatus
  430. }
  431. // 查找字典中对应的标签
  432. const dictItem = acceptReturnTypeDictList.value.find(dict => dict.dictValue == rawStatus)
  433. return dictItem!=null ? dictItem.dictLabel : rawStatus
  434. }
  435. const loadReturnDictList = async (returnTypeDict: string): Promise<void> => {
  436. try {
  437. const result = await getDictDataByType(returnTypeDict)
  438. const resultObj = result as UTSJSONObject
  439. if (resultObj['code'] == 200) {
  440. const data = resultObj['data'] as any[]
  441. const dictData: SysDictData[] = []
  442. if (data.length > 0) {
  443. for (let i = 0; i < data.length; i++) {
  444. const item = data[i] as UTSJSONObject
  445. // 只提取需要的字段
  446. const dictItem: SysDictData = {
  447. dictValue: item['dictValue'] as string | null,
  448. dictLabel: item['dictLabel'] as string | null,
  449. dictCode: null,
  450. dictSort: null,
  451. dictType: null,
  452. cssClass: null,
  453. listClass: null,
  454. isDefault: null,
  455. status: null,
  456. default: null,
  457. createTime: null,
  458. remark: null
  459. }
  460. dictData.push(dictItem)
  461. }
  462. }
  463. if(returnTypeDict == 'gxt_return_type') {
  464. returnTypeDictList.value = dictData
  465. } else {
  466. acceptReturnTypeDictList.value = dictData
  467. }
  468. }
  469. } catch (e: any) {
  470. console.error('获取工单状态字典失败:', e.message)
  471. }
  472. }
  473. // 加载详情数据
  474. const loadDetail = async (id: string, orderType?: number): Promise<void> => {
  475. try {
  476. loading.value = true
  477. let result: any;
  478. // 根据orderType决定调用哪个API
  479. if (orderType == 1) {
  480. // 维修工单
  481. result = await getRepairOrderInfoById(id)
  482. } else {
  483. // 维保工单
  484. result = await getOrderInfoById(id)
  485. }
  486. // 提取响应数据
  487. const resultObj = result as UTSJSONObject
  488. const code = resultObj['code'] as number
  489. const data = resultObj['data'] as UTSJSONObject | null
  490. if (code == 200 && data != null) {
  491. // 处理工单流转列表
  492. let workOrderFlowList: WorkOrderFlow[] | null = null
  493. let flowList: UTSJSONObject[] = []
  494. if (orderType == 1) {
  495. // 维修工单
  496. flowList = data['repairOrderFlowList'] as UTSJSONObject[]
  497. } else {
  498. // 维保工单
  499. flowList = data['workOrderFlowList'] as UTSJSONObject[]
  500. }
  501. if (flowList.length > 0) {
  502. workOrderFlowList = []
  503. for (let i = 0; i < flowList.length; i++) {
  504. const flowItem = flowList[i]
  505. const flow: WorkOrderFlow = {
  506. id: flowItem['id'] as Number,
  507. orderId: flowItem['orderId'] as Number,
  508. orderCode: flowItem['orderCode'] as string,
  509. actionType: flowItem['actionType'] as string,
  510. fromStatus: flowItem['fromStatus'] as string | null,
  511. toStatus: flowItem['toStatus'] as string,
  512. operatorId: flowItem['operatorId'] as Number | null,
  513. operatorName: flowItem['operatorName'] as string | null,
  514. actionTime: flowItem['actionTime'] as string,
  515. actionRemark: flowItem['actionRemark'] as string | null,
  516. createBy: flowItem['createBy'] as string | null,
  517. createTime: flowItem['createTime'] as string | null
  518. }
  519. workOrderFlowList.push(flow)
  520. }
  521. }
  522. // 转换数据
  523. const orderDtail: OrderInfoForDetail = {
  524. orderType: data['orderType'] as Number,
  525. id: data['id'] as Number,
  526. teamLeaderId: data['teamLeaderId'] != null ? (data['teamLeaderId'] as Number) : 0,
  527. acceptUserId: data['acceptUserId'] != null ? (data['acceptUserId'] as Number) : 0,
  528. teamLeaderName: data['teamLeaderName'] as string | null,
  529. acceptUserName: data['acceptUserName'] as string | null,
  530. acceptTime: data['acceptTime'] as string | null,
  531. assignTime: data['assignTime'] as string | null,
  532. assignUserName: data['assignUserName'] as string | null,
  533. status: (data['status']==null)?0:data['status'] as Number,
  534. workOrderProjectNo: data['workOrderProjectNo'] as string | null,
  535. workOrderStatus: data['workOrderStatus'] as string | null,
  536. gxtCenterId: data['gxtCenterId'] as Number | 0,
  537. gxtCenter: data['gxtCenter'] as string | null,
  538. pcsStationId: data['pcsStationId'] as Number | 0,
  539. pcsStationName: data['pcsStationName'] as string | null,
  540. pcsDeviceId: data['pcsDeviceId'] as Number | 0,
  541. pcsDeviceName: data['pcsDeviceName'] as string | null,
  542. brand: data['brand'] as string | null,
  543. model: data['model'] as string | null,
  544. createTime: data['createTime'] as string | null,
  545. workOrderFlowList: workOrderFlowList,
  546. suspendReason: data['suspendReason'] as string | null,
  547. rejectionReason: data['rejectionReason'] as string | null,
  548. updateTime: data['updateTime'] as string | null, // 新增字段
  549. workEndTime: data['workEndTime'] as string | null, // 新增字段
  550. faultCode: data['faultCode'] as string | null,
  551. faultBarcode: data['faultBarcode'] as string | null,
  552. faultDesc: data['faultDesc'] as string | null,
  553. pauseTime: data['pauseTime'] as string | null,
  554. restartTime: data['restartTime'] as string | null,
  555. attachmentUrls: data['attachmentUrls'] as string | null,
  556. content: data['content'] as string | null,
  557. inspectionType: data['inspectionType'] as string | null
  558. }
  559. detailData.value = orderDtail
  560. await loadReturnDictList('gxt_return_type')
  561. await loadReturnDictList('gxt_accept_return_type')
  562. returnType.value = (data['returnType'] as string | null) ?? ''
  563. returnReason.value = (data['returnReason'] as string | null) ?? ''
  564. acceptReturnType.value = (data['acceptReturnType'] as string | null) ?? ''
  565. acceptReturnReason.value = (data['acceptReturnReason'] as string | null) ?? ''
  566. if(data['orderType'] == 2 && orderDtail.inspectionType != null) {
  567. const result = await getDictDataByType("gxt_inspection_type")
  568. const resultObj = result as UTSJSONObject
  569. const dictList = resultObj['data'] as any[]
  570. if (dictList.length > 0) {
  571. const targetValueStr = orderDtail.inspectionType;
  572. const targetValueArray = targetValueStr
  573. .split(',') // 分割逗号,转为数组(单值分割后仍为长度1的数组)
  574. .map(item => item.trim());
  575. const matchedLabels = dictList.filter(dictItem => {
  576. // 统一转换为字符串匹配,避免数字/字符串类型不匹配问题
  577. const dictItemObj = dictItem as UTSJSONObject;
  578. const dictValueStr = dictItemObj['dictValue'] as string | null;
  579. // 判断当前字典项的value是否在目标值数组中
  580. if (dictValueStr == null) return false;
  581. return targetValueArray.includes(dictValueStr);
  582. }).map(dictItem => {
  583. const dictItemObj = dictItem as UTSJSONObject;
  584. const label = dictItemObj['dictLabel'] as string | null;
  585. return label ?? '';
  586. }); // 提取匹配项的label,形成label数组
  587. // 步骤4:将label数组用逗号分隔拼接,赋值给inspectionTypeLabel
  588. inspectionTypeLabel.value = matchedLabels.join(',');
  589. }
  590. }
  591. } else {
  592. const msg = resultObj['msg'] as string | null
  593. uni.showToast({
  594. title: msg ?? '加载失败',
  595. icon: 'none'
  596. })
  597. }
  598. } catch (e: any) {
  599. uni.showToast({
  600. title: e.message ?? '加载失败',
  601. icon: 'none'
  602. })
  603. } finally {
  604. loading.value = false
  605. }
  606. }
  607. // 页面加载
  608. onLoad((options: any) => {
  609. const params = options as UTSJSONObject
  610. const id = params['id'] as string | null
  611. const orderTypeParam = params['orderType'] as string | null
  612. if (id != null && orderTypeParam != null) {
  613. // 先尝试从参数中获取orderType
  614. const orderTypeNumber = parseInt(orderTypeParam)
  615. loadDetail(id, orderTypeNumber)
  616. }
  617. })
  618. // 初始化
  619. onMounted(() => {
  620. loadStatusDictList()
  621. })
  622. </script>
  623. <style lang="scss">
  624. .detail-page {
  625. flex: 1;
  626. background-color: #e8f0f9;
  627. }
  628. .detail-content {
  629. flex: 1;
  630. padding: 20rpx 0;
  631. }
  632. .info-section {
  633. margin: 0 30rpx 24rpx;
  634. .section-title {
  635. position: relative;
  636. padding-left: 20rpx;
  637. margin-bottom: 20rpx;
  638. flex-direction: row;
  639. justify-content: space-between;
  640. align-items: center;
  641. &::before {
  642. // content: '';
  643. position: absolute;
  644. left: 0;
  645. top: 50%;
  646. transform: translateY(-50%);
  647. width: 8rpx;
  648. height: 32rpx;
  649. background-color: #007aff;
  650. border-radius: 4rpx;
  651. }
  652. &-text {
  653. font-size: 32rpx;
  654. font-weight: bold;
  655. color: #333333;
  656. }
  657. .toggle-btn {
  658. padding-right: 20rpx;
  659. font-size: 28rpx;
  660. color: #165dff;
  661. }
  662. }
  663. .info-card {
  664. background-color: #ffffff;
  665. border-radius: 16rpx;
  666. padding: 30rpx;
  667. .info-item {
  668. flex-direction: row;
  669. padding: 20rpx 0;
  670. border-bottom: 1rpx solid #f0f0f0;
  671. &:last-child {
  672. border-bottom: none;
  673. }
  674. &.full-width {
  675. flex-direction: column;
  676. .info-label {
  677. margin-bottom: 12rpx;
  678. }
  679. .info-value {
  680. line-height: 44rpx;
  681. }
  682. }
  683. .info-label {
  684. width: 240rpx;
  685. font-size: 28rpx;
  686. color: #666666;
  687. white-space: nowrap;
  688. }
  689. .info-value {
  690. flex: 1;
  691. font-size: 28rpx;
  692. color: #333333;
  693. &.highlight {
  694. color: #007aff;
  695. font-weight: bold;
  696. }
  697. }
  698. }
  699. .flow-item {
  700. padding: 20rpx 0;
  701. border-bottom: 1rpx solid #f0f0f0;
  702. &:last-child {
  703. border-bottom: none;
  704. }
  705. .flow-header {
  706. flex-direction: row;
  707. justify-content: space-between;
  708. margin-bottom: 10rpx;
  709. .flow-operator {
  710. font-size: 28rpx;
  711. color: #333333;
  712. font-weight: bold;
  713. }
  714. .flow-time {
  715. font-size: 24rpx;
  716. color: #999999;
  717. }
  718. }
  719. .flow-content {
  720. flex-direction: column;
  721. .flow-action {
  722. font-size: 26rpx;
  723. color: #666666;
  724. margin-bottom: 8rpx;
  725. }
  726. .flow-remark {
  727. font-size: 24rpx;
  728. color: #999999;
  729. background-color: #f5f5f5;
  730. padding: 10rpx;
  731. border-radius: 8rpx;
  732. }
  733. }
  734. }
  735. .no-data {
  736. text-align: center;
  737. padding: 40rpx 0;
  738. font-size: 28rpx;
  739. color: #999999;
  740. }
  741. }
  742. }
  743. .loading-mask {
  744. position: absolute;
  745. top: 0;
  746. left: 0;
  747. right: 0;
  748. bottom: 0;
  749. justify-content: center;
  750. align-items: center;
  751. background-color: rgba(0, 0, 0, 0.3);
  752. .loading-text {
  753. padding: 30rpx 60rpx;
  754. background-color: rgba(0, 0, 0, 0.7);
  755. color: #ffffff;
  756. font-size: 28rpx;
  757. border-radius: 12rpx;
  758. }
  759. }
  760. .image-container {
  761. display: flex;
  762. flex-direction: row;
  763. flex-wrap: wrap;
  764. justify-content: flex-start; // 或 space-around
  765. // justify-content: space-around; /* 自动分配间距,避免挤压 */
  766. align-items: center;
  767. padding: 0 10rpx;
  768. }
  769. .attachment-image {
  770. width: 300rpx; /* 一行显示两个图片,减去间距的一半 */
  771. height: 300rpx;
  772. padding: 10rpx
  773. }
  774. </style>