shutdownIndex.uvue 16 KB

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