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