shutdownIndex.uvue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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">{{ workOrderProjectNo ?? '' }}</text>
  13. </view>
  14. <view class="info-item">
  15. <text class="info-label">风机编号</text>
  16. <text class="info-value">{{ pcsDeviceName ?? '' }}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="info-label">维保中心</text>
  20. <text class="info-value">{{ gxtCenter ?? '' }}</text>
  21. </view>
  22. <view class="info-item">
  23. <text class="info-label">场站</text>
  24. <text class="info-value">{{ pcsStationName ?? '' }}</text>
  25. </view>
  26. <view class="info-item">
  27. <text class="info-label">机型</text>
  28. <text class="info-value">{{ brand ?? '' }} {{ model ?? '' }}</text>
  29. </view>
  30. <view class="info-item">
  31. <text class="info-label">下发时间</text>
  32. <text class="info-value">{{ assignTime ?? '' }}</text>
  33. </view>
  34. <view class="info-item" v-if="realStartTime != ''">
  35. <text class="info-label">开始时间</text>
  36. <text class="info-value">{{ realStartTime ?? '' }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="info-section">
  41. <view class="info-card">
  42. <view class="info-item">
  43. <view class="info-label">
  44. <text class="form-label required">停机时间<text style="color: red;">*</text></text>
  45. </view>
  46. <view class="info-value">
  47. <view class="form-picker" @click="showshutdownTimePicker = true">
  48. <input
  49. class="input-field"
  50. placeholder="请选择停机时间"
  51. v-model="pauseTime"
  52. type="none"
  53. />
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 时间选择器弹窗 -->
  60. <!-- Start Date Picker -->
  61. <l-popup v-model="showshutdownTimePicker" position="bottom">
  62. <l-date-time-picker
  63. title="选择停机时间"
  64. :mode="1 | 2 | 4 | 8 | 16"
  65. format="YYYY-MM-DD HH:mm"
  66. :modelValue="pauseTime"
  67. confirm-btn="确定"
  68. cancel-btn="取消"
  69. @confirm="onStartDateConfirm"
  70. @cancel="showshutdownTimePicker = false">
  71. </l-date-time-picker>
  72. </l-popup>
  73. </scroll-view>
  74. <!-- 接单按钮 -->
  75. <view class="accept-button-container" v-if="checkPermi(orderType == '2' ? ['gxt:maintenance:order:shutdown'] : ['gxt:repairOrder:shutdown'])">
  76. <button class="accept-button" @click="handleShutdownOrder">{{ isDealing ? '停机中...' : '停 机' }}</button>
  77. </view>
  78. <!-- 加载中状态 -->
  79. <view v-if="loading" class="loading-mask">
  80. <text class="loading-text">加载中...</text>
  81. </view>
  82. </view>
  83. </template>
  84. <script setup lang="uts">
  85. import { ref } from 'vue'
  86. import type { acceptOrderInfo } from '../../../types/order'
  87. import type { WorkOrderFlow } from '../../../types/flow'
  88. import { getOrderInfoById, getRepairOrderInfoById, shutdownOrder } from '../../../api/order/detail'
  89. import type { SysDictData } from '../../../types/dict'
  90. import { getDictDataByType } from '../../../api/dict/index'
  91. import type { UserInfo } from '../../../types/user'
  92. import {checkPermi} from '../../../utils/storage'
  93. const teamLeaderName = ref<string>("")
  94. const statusDictList = ref<SysDictData[]>([]) // 工单状态字典列表
  95. // 添加字典加载状态
  96. const dictLoaded = ref<boolean>(false)
  97. const pauseTime = ref<string>("")
  98. // 工单信息
  99. const orderId = ref<string>('')
  100. const workOrderProjectNo = ref<string>('')
  101. const workOrderStatus = ref<string>('')
  102. const orderType = ref<string>('')
  103. const pcsDeviceName = ref<string>('')
  104. const gxtCenter = ref<string>('')
  105. const pcsStationName = ref<string>('')
  106. const brand = ref<string>('')
  107. const model = ref<string>('')
  108. const assignTime = ref<string>('')
  109. const realStartTime = ref<string>('')
  110. const showshutdownTimePicker = ref<boolean>(false)
  111. function onStartDateConfirm(value: string) {
  112. // 检查结束时间是否小于新的停机时间
  113. pauseTime.value = value
  114. showshutdownTimePicker.value = false
  115. }
  116. // 获取工单状态字典列表
  117. const loadStatusDictList = async (): Promise<void> => {
  118. try {
  119. const result = await getDictDataByType('gxt_repair_order_flow_action_type')
  120. const resultObj = result as UTSJSONObject
  121. if (resultObj['code'] == 200) {
  122. const data = resultObj['data'] as any[]
  123. const dictData: SysDictData[] = []
  124. if (data.length > 0) {
  125. for (let i = 0; i < data.length; i++) {
  126. const item = data[i] as UTSJSONObject
  127. // 只提取需要的字段
  128. const dictItem: SysDictData = {
  129. dictValue: item['dictValue'] as string | null,
  130. dictLabel: item['dictLabel'] as string | null,
  131. dictCode: null,
  132. dictSort: null,
  133. dictType: null,
  134. cssClass: null,
  135. listClass: null,
  136. isDefault: null,
  137. status: null,
  138. default: null,
  139. createTime: null,
  140. remark: null
  141. }
  142. dictData.push(dictItem)
  143. }
  144. }
  145. statusDictList.value = dictData
  146. dictLoaded.value = true
  147. }
  148. } catch (e: any) {
  149. console.error('获取工单状态字典失败:', e.message)
  150. dictLoaded.value = true
  151. }
  152. }
  153. const isDealing = ref(false)
  154. const hasDealed = ref(false)
  155. // 处理接单操作
  156. const handleShutdownOrder = async (): Promise<void> => {
  157. if (pauseTime.value.trim() === '') {
  158. uni.showToast({
  159. title: '请选择停机时间',
  160. icon: 'none'
  161. })
  162. return
  163. }
  164. // 2. 时间格式转换(兼容字符串/Date类型,统一转为时间戳对比)
  165. const pauseTimeStamp = new Date(pauseTime.value).getTime();
  166. const currentTimeStamp = new Date().getTime(); // 当前系统时间戳
  167. // 处理realStartTime(开工打卡时间),空值时为0
  168. const realStartTimeStamp = realStartTime.value != '' ? new Date(realStartTime.value).getTime() : 0;
  169. // 3. 校验1:停机时间不能大于当前时间
  170. if (pauseTimeStamp > currentTimeStamp) {
  171. uni.showToast({
  172. title: '停机时间不能晚于当前时间',
  173. icon: 'none'
  174. })
  175. return
  176. }
  177. // 4. 校验2:realStartTime不为空时,停机时间不能小于开工时间
  178. if (realStartTimeStamp > 0 && pauseTimeStamp < realStartTimeStamp) {
  179. uni.showToast({
  180. title: '停机时间不能早于开始时间',
  181. icon: 'none'
  182. })
  183. return
  184. }
  185. if (isDealing.value || hasDealed.value) return // 双重保险
  186. isDealing.value = true
  187. try {
  188. const submitData = {
  189. id: orderId.value,
  190. workOrderProjectNo: workOrderProjectNo.value,
  191. workOrderStatus: workOrderStatus.value,
  192. pauseTime: pauseTime.value
  193. } as UTSJSONObject;
  194. const result = await shutdownOrder(submitData)
  195. const resultObj = result as UTSJSONObject
  196. const code = resultObj['code'] as number
  197. if (code == 200) {
  198. uni.showToast({
  199. title: '停机成功',
  200. icon: 'success'
  201. })
  202. hasDealed.value = true
  203. // 使用事件总线通知列表页面刷新
  204. uni.$emit('refreshOrderList', {})
  205. uni.$emit('refreshAssignedCount')
  206. uni.$emit('refreshOverdueCount')
  207. uni.$emit('refreshApproveCount')
  208. uni.$emit('refreshSuspendedCount')
  209. // 接单成功后返回上一页
  210. setTimeout(() => {
  211. uni.navigateBack()
  212. }, 800)
  213. } else {
  214. // 处理业务错误
  215. uni.showToast({
  216. title: resultObj['msg'] as string,
  217. icon: 'none'
  218. })
  219. }
  220. } catch (error: any) {
  221. console.error('请求失败:', error);
  222. uni.showToast({
  223. title: error.message ?? '挂起失败',
  224. icon: 'none'
  225. })
  226. } finally {
  227. isDealing.value = false // 无论成功失败都解锁
  228. }
  229. }
  230. const loading = ref<boolean>(false)
  231. // 获取操作类型名称
  232. const getActionTypeName = (item: string | null): string | null => {
  233. if (item == null) return ''
  234. // const orderInfoItem = item as orderInfo
  235. const rawStatus = item
  236. if (rawStatus==null) return ''
  237. // 如果字典尚未加载,返回原始值
  238. if (!dictLoaded.value) {
  239. return rawStatus
  240. }
  241. // 查找字典中对应的标签
  242. const dictItem = statusDictList.value.find(dict => dict.dictValue == rawStatus)
  243. return dictItem!=null ? dictItem.dictLabel : rawStatus
  244. }
  245. // 加载详情数据
  246. const loadDetail = async (id: string, orderType?: number): Promise<void> => {
  247. try {
  248. loading.value = true
  249. let result: any;
  250. // 根据orderType决定调用哪个API
  251. if (orderType == 1) {
  252. // 维修工单
  253. result = await getRepairOrderInfoById(id)
  254. } else {
  255. // 维保工单
  256. result = await getOrderInfoById(id)
  257. }
  258. // 提取响应数据
  259. const resultObj = result as UTSJSONObject
  260. const code = resultObj['code'] as number
  261. const data = resultObj['data'] as UTSJSONObject | null
  262. if (code == 200 && data != null) {
  263. orderId.value = id
  264. workOrderStatus.value = (data['workOrderStatus'] as string | null) ?? ''
  265. workOrderProjectNo.value = (data['workOrderProjectNo'] as string | null) ?? ''
  266. pcsDeviceName.value = (data['pcsDeviceName'] as string | null) ?? ''
  267. gxtCenter.value = (data['gxtCenter'] as string | null) ?? ''
  268. pcsStationName.value = (data['pcsStationName'] as string | null) ?? ''
  269. brand.value = (data['brand'] as string | null) ?? ''
  270. model.value = (data['model'] as string | null) ?? ''
  271. assignTime.value = (data['assignTime'] as string | null) ?? ''
  272. realStartTime.value = (data['realStartTime'] as string | null) ?? ''
  273. } else {
  274. const msg = resultObj['msg'] as string | null
  275. uni.showToast({
  276. title: msg ?? '加载失败',
  277. icon: 'none'
  278. })
  279. }
  280. } catch (e: any) {
  281. uni.showToast({
  282. title: e.message ?? '加载失败',
  283. icon: 'none'
  284. })
  285. } finally {
  286. loading.value = false
  287. }
  288. }
  289. // 页面加载
  290. onLoad((options: any) => {
  291. const params = options as UTSJSONObject
  292. const id = params['id'] as string | null
  293. const orderTypeParam = params['orderType'] as string | null
  294. if (id != null && orderTypeParam != null) {
  295. orderType.value = orderTypeParam
  296. // 先尝试从参数中获取orderType
  297. const orderTypeNumber = parseInt(orderTypeParam)
  298. loadDetail(id, orderTypeNumber)
  299. }
  300. })
  301. // 初始化
  302. onMounted(() => {
  303. // loadStatusDictList()
  304. })
  305. </script>
  306. <style lang="scss">
  307. .detail-page {
  308. flex: 1;
  309. background-color: #e8f0f9;
  310. }
  311. .detail-content {
  312. flex: 1;
  313. padding: 20rpx 0;
  314. }
  315. .info-section {
  316. margin: 0 30rpx 24rpx;
  317. .section-title {
  318. position: relative;
  319. padding-left: 20rpx;
  320. margin-bottom: 20rpx;
  321. &::before {
  322. // content: '';
  323. position: absolute;
  324. left: 0;
  325. top: 50%;
  326. transform: translateY(-50%);
  327. width: 8rpx;
  328. height: 32rpx;
  329. background-color: #007aff;
  330. border-radius: 4rpx;
  331. }
  332. &-text {
  333. font-size: 32rpx;
  334. font-weight: bold;
  335. color: #333333;
  336. }
  337. }
  338. .info-card {
  339. background-color: #ffffff;
  340. border-radius: 16rpx;
  341. padding: 30rpx;
  342. .info-item {
  343. flex-direction: row;
  344. padding: 20rpx 0;
  345. border-bottom: 1rpx solid #f0f0f0;
  346. &:last-child {
  347. border-bottom: none;
  348. }
  349. &.full-width {
  350. flex-direction: column;
  351. .info-label {
  352. margin-bottom: 12rpx;
  353. }
  354. .info-value {
  355. line-height: 44rpx;
  356. }
  357. }
  358. .info-label {
  359. width: 240rpx;
  360. font-size: 28rpx;
  361. color: #666666;
  362. white-space: nowrap;
  363. }
  364. .info-value {
  365. flex: 1;
  366. font-size: 28rpx;
  367. color: #333333;
  368. text-align: left;
  369. &.highlight {
  370. color: #007aff;
  371. font-weight: bold;
  372. }
  373. &.input {
  374. text-align: left;
  375. border: 1rpx solid #e0e0e0;
  376. border-radius: 8rpx;
  377. padding: 10rpx;
  378. }
  379. }
  380. }
  381. .flow-item {
  382. padding: 20rpx 0;
  383. border-bottom: 1rpx solid #f0f0f0;
  384. &:last-child {
  385. border-bottom: none;
  386. }
  387. .flow-header {
  388. flex-direction: row;
  389. justify-content: space-between;
  390. margin-bottom: 10rpx;
  391. .flow-operator {
  392. font-size: 28rpx;
  393. color: #333333;
  394. font-weight: bold;
  395. }
  396. .flow-time {
  397. font-size: 24rpx;
  398. color: #999999;
  399. }
  400. }
  401. .flow-content {
  402. flex-direction: column;
  403. .flow-action {
  404. font-size: 26rpx;
  405. color: #666666;
  406. margin-bottom: 8rpx;
  407. }
  408. .flow-remark {
  409. font-size: 24rpx;
  410. color: #999999;
  411. background-color: #f5f5f5;
  412. padding: 10rpx;
  413. border-radius: 8rpx;
  414. }
  415. }
  416. }
  417. .no-data {
  418. text-align: center;
  419. padding: 40rpx 0;
  420. font-size: 28rpx;
  421. color: #999999;
  422. }
  423. }
  424. }
  425. .accept-button-container {
  426. padding: 30rpx 30rpx 50rpx;
  427. background-color: #ffffff;
  428. .accept-button {
  429. width: 100%;
  430. height: 80rpx;
  431. background-color: #007aff;
  432. color: #ffffff;
  433. font-size: 32rpx;
  434. border-radius: 16rpx;
  435. border: none;
  436. &:active {
  437. background-color: #0062cc;
  438. }
  439. }
  440. }
  441. .loading-mask {
  442. position: absolute;
  443. top: 0;
  444. left: 0;
  445. right: 0;
  446. bottom: 0;
  447. justify-content: center;
  448. align-items: center;
  449. background-color: rgba(0, 0, 0, 0.3);
  450. .loading-text {
  451. padding: 30rpx 60rpx;
  452. background-color: rgba(0, 0, 0, 0.7);
  453. color: #ffffff;
  454. font-size: 28rpx;
  455. border-radius: 12rpx;
  456. }
  457. }
  458. .picker-modal {
  459. position: fixed;
  460. top: 0;
  461. left: 0;
  462. right: 0;
  463. bottom: 0;
  464. z-index: 1000;
  465. }
  466. .modal-mask {
  467. position: absolute;
  468. top: 0;
  469. left: 0;
  470. right: 0;
  471. bottom: 0;
  472. background-color: rgba(0, 0, 0, 0.5);
  473. }
  474. .modal-content {
  475. position: absolute;
  476. bottom: 0;
  477. left: 0;
  478. right: 0;
  479. background-color: #ffffff;
  480. border-top-left-radius: 16rpx;
  481. border-top-right-radius: 16rpx;
  482. max-height: 700rpx;
  483. }
  484. .modal-header {
  485. flex-direction: row;
  486. justify-content: space-between;
  487. align-items: center;
  488. padding: 30rpx;
  489. border-bottom: 1rpx solid #f0f0f0;
  490. }
  491. .modal-title {
  492. font-size: 32rpx;
  493. font-weight: bold;
  494. color: #333333;
  495. }
  496. .modal-close {
  497. font-size: 28rpx;
  498. color: #007aff;
  499. }
  500. .modal-body {
  501. max-height: 600rpx;
  502. }
  503. .picker-option {
  504. flex-direction: row;
  505. justify-content: space-between;
  506. align-items: center;
  507. padding: 24rpx 30rpx;
  508. border-bottom: 1rpx solid #f0f0f0;
  509. }
  510. .picker-option.selected {
  511. background-color: #f8f9fa;
  512. }
  513. .option-text {
  514. font-size: 28rpx;
  515. color: #333333;
  516. }
  517. .option-check {
  518. font-size: 28rpx;
  519. color: #007aff;
  520. }
  521. .form-picker {
  522. flex: 1;
  523. }
  524. .picker-display {
  525. flex-direction: row;
  526. justify-content: space-between;
  527. align-items: center;
  528. min-height: 40rpx;
  529. }
  530. .selected-value {
  531. font-size: 28rpx;
  532. color: #333333;
  533. }
  534. .placeholder {
  535. font-size: 28rpx;
  536. color: #999999;
  537. }
  538. .arrow {
  539. font-size: 24rpx;
  540. color: #999999;
  541. margin-left: 12rpx;
  542. }
  543. .reject-reason-textarea {
  544. width: 100%;
  545. min-height: 100rpx;
  546. line-height: 1.5;
  547. }
  548. </style>