index.uvue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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.teamLeaderName ?? '' }}</text>
  29. </view>
  30. <view class="info-item">
  31. <text class="info-label">工作结束时间</text>
  32. <text class="info-value">{{ detailData.realEndTime ?? '' }}</text>
  33. </view>
  34. <view class="info-item">
  35. <text class="info-label">状态</text>
  36. <text class="info-value">{{ getScoringStatusText(detailData.scoringStatus) }}</text>
  37. </view>
  38. <view class="info-item" v-if="detailData.orderType == 1 && detailData.maintenanceType != null && detailData.maintenanceType != ''">
  39. <text class="info-label">检修类型</text>
  40. <text class="info-value">{{ getMaintenanceTypeText(detailData.maintenanceType) }}</text>
  41. </view>
  42. <view class="info-item" v-if="detailData.orderType == 2 && detailData.inspectionType != null && detailData.inspectionType != ''">
  43. <text class="info-label">维保类型</text>
  44. <text class="info-value">{{ getInspectionTypeText(detailData.inspectionType) }}</text>
  45. </view>
  46. <!-- <view class="info-item" v-if="detailData.workSummary != null && detailData.workSummary != ''">
  47. <text class="info-label">{{ detailData.orderType == 1 ? '维修总结' : '维保总结' }}</text>
  48. <text class="info-value">{{ detailData.workSummary ?? '' }}</text>
  49. </view> -->
  50. </view>
  51. </view>
  52. <!-- 工作总结 -->
  53. <view class="info-section" v-if="detailData.workSummary != null && detailData.workSummary != ''">
  54. <view class="section-title">
  55. <text class="section-title-text">{{ detailData.orderType == 1 ? '维修总结' : '维保总结' }}</text>
  56. </view>
  57. <view class="info-card">
  58. <view class="summary-content">
  59. <text class="summary-text">{{ detailData.workSummary ?? '' }}</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 得分明细 -->
  64. <view class="info-section">
  65. <view class="section-title">
  66. <text class="section-title-text">得分明细</text>
  67. </view>
  68. <view class="info-card">
  69. <!-- 表格头部 -->
  70. <view class="table-header">
  71. <text class="table-cell score-col">检修员</text>
  72. <text class="table-cell score-col">自评得分</text>
  73. <text class="table-cell score-col">复评得分</text>
  74. <text class="table-cell score-col">终评得分</text>
  75. <!-- <text class="table-cell score-col">确认状态</text> -->
  76. </view>
  77. <!-- 表格行数据 -->
  78. <view class="table-row" v-for="(person, index) in detailData.scorePersonList" :key="index">
  79. <text class="table-cell score-col">
  80. {{ person.nickName }}
  81. <text class="table-cell score-col" v-if="person.isLeader == 1">(负责人)</text>
  82. </text>
  83. <text class="table-cell score-col">{{ person.selfScore !== null ? formatNumber(person.selfScore) : '-' }}</text>
  84. <text class="table-cell score-col">{{ person.reviewScore !== null ? formatNumber(person.reviewScore) : '-' }}</text>
  85. <text class="table-cell score-col">{{ person.finalScore !== null ? formatNumber(person.finalScore) : '-' }}</text>
  86. <!-- <text class="table-cell score-col">{{ person.confirmStatus !== null ? getConfirmStatusText(person.confirmStatus) : '-' }}</text> -->
  87. </view>
  88. </view>
  89. </view>
  90. </scroll-view>
  91. <!-- 加载中状态 -->
  92. <view v-if="loading" class="loading-mask">
  93. <text class="loading-text">加载中...</text>
  94. </view>
  95. </view>
  96. </template>
  97. <script setup lang="uts">
  98. import { ref, reactive } from 'vue'
  99. import { getOrderScoreDetail } from '../../../api/score/index'
  100. import { getDictDataByType } from '@/api/dict/index'
  101. import type { SysDictData } from '@/types/dict'
  102. // 人员得分对象
  103. type ScorePersonItem = {
  104. nickName: string | null
  105. selfScore: number | null
  106. reviewScore: number | null
  107. finalScore: number | null
  108. confirmStatus: number | null
  109. isLeader: number | null
  110. }
  111. // 详情数据
  112. type DetailDataType = {
  113. orderType: Number
  114. id: Number
  115. workOrderProjectNo: string | null
  116. pcsDeviceName: string | null
  117. pcsStationName: string | null
  118. teamLeaderName: string | null
  119. realEndTime: string | null
  120. scoringStatus: string | null
  121. workSummary: string | null
  122. maintenanceType: string | null
  123. inspectionType: string | null
  124. itemCompletionFactor: number | null
  125. itemCompletionFactorSum: number | null
  126. scorePersonList: ScorePersonItem[]
  127. }
  128. const detailData = reactive<DetailDataType>({
  129. orderType: 0 as Number,
  130. id: 0 as Number,
  131. workOrderProjectNo: null,
  132. pcsDeviceName: null,
  133. pcsStationName: null,
  134. teamLeaderName: null,
  135. realEndTime: null,
  136. scoringStatus: null,
  137. workSummary: null,
  138. maintenanceType: null,
  139. inspectionType: null,
  140. itemCompletionFactor: null,
  141. itemCompletionFactorSum: null,
  142. scorePersonList: []
  143. })
  144. const loading = ref<boolean>(false)
  145. // 字典数据
  146. const scoringStatusDictList = ref<SysDictData[]>([])
  147. const maintenanceTypeDictList = ref<SysDictData[]>([])
  148. const inspectionTypeDictList = ref<SysDictData[]>([])
  149. // 获取工单评分状态字典
  150. const loadScoringStatusDictList = async (): Promise<void> => {
  151. try {
  152. const result = await getDictDataByType('gxt_scoring_status')
  153. const resultObj = result as UTSJSONObject
  154. if (resultObj['code'] == 200) {
  155. const data = resultObj['data'] as any[]
  156. const dictData: SysDictData[] = []
  157. if (data != null && data.length > 0) {
  158. for (let i = 0; i < data.length; i++) {
  159. const item = data[i] as UTSJSONObject
  160. const dictItem: SysDictData = {
  161. dictValue: item['dictValue'] as string | null,
  162. dictLabel: item['dictLabel'] as string | null,
  163. dictCode: null,
  164. dictSort: null,
  165. dictType: null,
  166. cssClass: null,
  167. listClass: null,
  168. isDefault: null,
  169. status: null,
  170. default: null,
  171. createTime: null,
  172. remark: null
  173. }
  174. dictData.push(dictItem)
  175. }
  176. }
  177. scoringStatusDictList.value = dictData
  178. }
  179. } catch (e: any) {
  180. console.error('获取工单评分状态字典失败:', e.message)
  181. }
  182. }
  183. // 获取检修类型字典
  184. const loadMaintenanceTypeDictList = async (): Promise<void> => {
  185. try {
  186. const result = await getDictDataByType('gxt_maintenance_type')
  187. const resultObj = result as UTSJSONObject
  188. if (resultObj['code'] == 200) {
  189. const data = resultObj['data'] as any[]
  190. const dictData: SysDictData[] = []
  191. if (data != null && data.length > 0) {
  192. for (let i = 0; i < data.length; i++) {
  193. const item = data[i] as UTSJSONObject
  194. const dictItem: SysDictData = {
  195. dictValue: item['dictValue'] as string | null,
  196. dictLabel: item['dictLabel'] as string | null,
  197. dictCode: null,
  198. dictSort: null,
  199. dictType: null,
  200. cssClass: null,
  201. listClass: null,
  202. isDefault: null,
  203. status: null,
  204. default: null,
  205. createTime: null,
  206. remark: null
  207. }
  208. dictData.push(dictItem)
  209. }
  210. }
  211. maintenanceTypeDictList.value = dictData
  212. }
  213. } catch (e: any) {
  214. console.error('获取检修类型字典失败:', e.message)
  215. }
  216. }
  217. // 获取维保类型字典
  218. const loadInspectionTypeDictList = async (): Promise<void> => {
  219. try {
  220. const result = await getDictDataByType('gxt_inspection_type')
  221. const resultObj = result as UTSJSONObject
  222. if (resultObj['code'] == 200) {
  223. const data = resultObj['data'] as any[]
  224. const dictData: SysDictData[] = []
  225. if (data != null && data.length > 0) {
  226. for (let i = 0; i < data.length; i++) {
  227. const item = data[i] as UTSJSONObject
  228. const dictItem: SysDictData = {
  229. dictValue: item['dictValue'] as string | null,
  230. dictLabel: item['dictLabel'] as string | null,
  231. dictCode: null,
  232. dictSort: null,
  233. dictType: null,
  234. cssClass: null,
  235. listClass: null,
  236. isDefault: null,
  237. status: null,
  238. default: null,
  239. createTime: null,
  240. remark: null
  241. }
  242. dictData.push(dictItem)
  243. }
  244. }
  245. inspectionTypeDictList.value = dictData
  246. }
  247. } catch (e: any) {
  248. console.error('获取维保类型字典失败:', e.message)
  249. }
  250. }
  251. // 获取工单评分状态文本
  252. const getScoringStatusText = (status: string | null): string => {
  253. if (status == null || status == '') return ''
  254. const dictItem = scoringStatusDictList.value.find(dict => dict.dictValue == status)
  255. return dictItem != null ? (dictItem.dictLabel ?? status) : status
  256. }
  257. // 获取检修类型文本
  258. const getMaintenanceTypeText = (type: string | null): string => {
  259. if (type == null || type == '') return ''
  260. const dictItem = maintenanceTypeDictList.value.find(dict => dict.dictValue == type)
  261. return dictItem != null ? (dictItem.dictLabel ?? type) : type
  262. }
  263. // 获取维保类型文本
  264. const getInspectionTypeText = (type: string | null): string => {
  265. if (type == null || type == '') return ''
  266. const dictItem = inspectionTypeDictList.value.find(dict => dict.dictValue == type)
  267. return dictItem != null ? (dictItem.dictLabel ?? type) : type
  268. }
  269. // 获取确认状态文本
  270. const getConfirmStatusText = (status: number | null): string => {
  271. if (status == null) return '未知'
  272. switch (status) {
  273. case 0: return '未确认'
  274. case 1: return '已确认'
  275. case 2: return '已反馈'
  276. default: return '未知状态'
  277. }
  278. }
  279. // Format number to fixed 2 decimal places
  280. const formatNumber = (value: number | string | null): string => {
  281. if (value == null) return '0.00'
  282. // Convert value to string properly to avoid ClassCastException
  283. const stringValue = value.toString()
  284. const num = parseFloat(stringValue)
  285. if (isNaN(num)) return '0.00'
  286. return num.toFixed(2)
  287. }
  288. // 加载详情数据
  289. const loadDetail = async (id: string, orderType: string): Promise<void> => {
  290. try {
  291. loading.value = true
  292. const result = await getOrderScoreDetail(orderType, id)
  293. // 提取响应数据
  294. const resultObj = result as UTSJSONObject
  295. const code = resultObj.get('code') as number
  296. const data = resultObj.get('data') as UTSJSONObject | null
  297. if (code == 200 && data != null) {
  298. // 填充基本数据
  299. const orderTypeValue = data.get('orderType')
  300. detailData.orderType = (orderTypeValue != null ? (orderTypeValue as number) : 0) as Number
  301. const idValue = data.get('id')
  302. detailData.id = (idValue != null ? (idValue as number) : 0) as Number
  303. detailData.workOrderProjectNo = data.get('workOrderProjectNo') as string | null
  304. detailData.pcsDeviceName = data.get('pcsDeviceName') as string | null
  305. detailData.pcsStationName = data.get('pcsStationName') as string | null
  306. detailData.teamLeaderName = data.get('teamLeaderName') as string | null
  307. detailData.realEndTime = data.get('realEndTime') as string | null
  308. detailData.scoringStatus = data.get('scoringStatus') as string | null
  309. // 根据工单类型设置总结内容
  310. detailData.workSummary = (detailData.orderType == 1 ?
  311. data.get('content') :
  312. data.get('realContent')) as string | null
  313. // 类型信息
  314. detailData.maintenanceType = data.get('maintenanceType') as string | null
  315. detailData.inspectionType = data.get('inspectionType') as string | null
  316. const itemCompletionFactorValue = data.get('itemCompletionFactor')
  317. detailData.itemCompletionFactor = itemCompletionFactorValue != null ?
  318. (itemCompletionFactorValue as number) : null
  319. const itemCompletionFactorSumValue = data.get('itemCompletionFactorSum')
  320. detailData.itemCompletionFactorSum = itemCompletionFactorSumValue != null ?
  321. (itemCompletionFactorSumValue as number) : null
  322. // 人员得分列表
  323. const scorePersonList = (detailData.orderType == 1 ?
  324. data.get('repairOrderPersonList') :
  325. data.get('workOrderPersonList')) as UTSJSONObject[] | null
  326. if (scorePersonList != null) {
  327. const processedList: ScorePersonItem[] = []
  328. for (let i = 0; i < scorePersonList.length; i++) {
  329. const person = scorePersonList[i]
  330. const item: ScorePersonItem = {
  331. nickName: person.get('nickName') as string | null,
  332. selfScore: (person.get('selfScore') != null ? person.get('selfScore') as number : null),
  333. reviewScore: (person.get('reviewScore') != null ? person.get('reviewScore') as number : null),
  334. finalScore: (person.get('finalScore') != null ? person.get('finalScore') as number : null),
  335. confirmStatus: (person.get('confirmStatus') != null ? person.get('confirmStatus') as number : null),
  336. isLeader: (person.get('isLeader') != null ? person.get('isLeader') as number : null)
  337. }
  338. processedList.push(item)
  339. }
  340. detailData.scorePersonList = processedList
  341. } else {
  342. detailData.scorePersonList = []
  343. }
  344. } else {
  345. const msg = (resultObj.get('msg') as string | null) ?? '加载失败'
  346. uni.showToast({
  347. title: msg,
  348. icon: 'none'
  349. })
  350. }
  351. } catch (e: any) {
  352. uni.showToast({
  353. title: e.message ?? '加载失败',
  354. icon: 'none'
  355. })
  356. } finally {
  357. loading.value = false
  358. }
  359. }
  360. // 页面加载
  361. onLoad((options: any) => {
  362. const params = options as UTSJSONObject
  363. const id = params.get('id') as string | null
  364. const orderType = params.get('orderType') as string | null
  365. if (id != null && orderType != null) {
  366. loadScoringStatusDictList()
  367. loadMaintenanceTypeDictList()
  368. loadInspectionTypeDictList()
  369. loadDetail(id, orderType)
  370. }
  371. })
  372. </script>
  373. <style lang="scss">
  374. .detail-page {
  375. flex: 1;
  376. background-color: #e8f0f9;
  377. }
  378. .detail-content {
  379. flex: 1;
  380. padding: 20rpx 0;
  381. }
  382. .info-section {
  383. margin: 0 30rpx 24rpx;
  384. .section-title {
  385. position: relative;
  386. padding-left: 20rpx;
  387. margin-bottom: 20rpx;
  388. &::before {
  389. position: absolute;
  390. left: 0;
  391. top: 50%;
  392. transform: translateY(-50%);
  393. width: 8rpx;
  394. height: 32rpx;
  395. background-color: #007aff;
  396. border-radius: 4rpx;
  397. }
  398. &-text {
  399. font-size: 32rpx;
  400. font-weight: bold;
  401. color: #333333;
  402. }
  403. }
  404. .info-card {
  405. background-color: #ffffff;
  406. border-radius: 16rpx;
  407. padding: 30rpx;
  408. .info-item {
  409. flex-direction: row;
  410. padding: 20rpx 0;
  411. border-bottom: 1rpx solid #f0f0f0;
  412. &:last-child {
  413. border-bottom: none;
  414. }
  415. .info-label {
  416. width: 240rpx;
  417. font-size: 28rpx;
  418. color: #666666;
  419. white-space: nowrap;
  420. }
  421. .info-value {
  422. flex: 1;
  423. font-size: 28rpx;
  424. color: #333333;
  425. text-align: right;
  426. }
  427. }
  428. .summary-content {
  429. .summary-text {
  430. font-size: 28rpx;
  431. color: #333333;
  432. line-height: 44rpx;
  433. }
  434. }
  435. /* 表格样式 */
  436. .table-header, .table-row {
  437. flex-direction: row;
  438. padding: 20rpx 0;
  439. border-bottom: 1rpx solid #f0f0f0;
  440. &:last-child {
  441. border-bottom: none;
  442. }
  443. }
  444. .table-header {
  445. background-color: #f8f8f8;
  446. font-weight: bold;
  447. }
  448. .table-cell {
  449. font-size: 26rpx;
  450. color: #333;
  451. text-align: center;
  452. &.name-col {
  453. flex: 2;
  454. text-align: left;
  455. }
  456. &.score-col {
  457. flex: 1;
  458. }
  459. &.status-col {
  460. flex: 1;
  461. }
  462. }
  463. }
  464. }
  465. .loading-mask {
  466. position: absolute;
  467. top: 0;
  468. left: 0;
  469. right: 0;
  470. bottom: 0;
  471. justify-content: center;
  472. align-items: center;
  473. background-color: rgba(0, 0, 0, 0.3);
  474. .loading-text {
  475. padding: 30rpx 60rpx;
  476. background-color: rgba(0, 0, 0, 0.7);
  477. color: #ffffff;
  478. font-size: 28rpx;
  479. border-radius: 12rpx;
  480. }
  481. }
  482. </style>