index.uvue 30 KB

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