resetIndex.uvue 18 KB

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