resetIndex.uvue 19 KB

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