index.uvue 23 KB

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