detail copy.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view class="maintenance-container">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="保养工单详情" @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode"></uni-nav-bar>
  4. <view class="maintenance-wrapper">
  5. <view class="maintenance-content">
  6. <KdTabs v-model="active" @change="handleTabChange" :list="['基本信息', '保养设备']" />
  7. <view class="kd-baseInfo" v-show="active === 0">
  8. <view class="kd-cell">
  9. <text class="kd-label">工单编号</text>
  10. <text class="kd-content">{{ worksheetInfo.workOrderCode }}</text>
  11. </view>
  12. <view class="kd-cell">
  13. <text class="kd-label">计划名称</text>
  14. <text class="kd-content">{{ worksheetInfo.planName }}</text>
  15. </view>
  16. <view class="kd-cell">
  17. <text class="kd-label">设备分类</text>
  18. <text class="kd-content">{{ worksheetInfo.equiTypeName }}</text>
  19. </view>
  20. <view class="kd-cell">
  21. <text class="kd-label">保养设备总数</text>
  22. <text class="kd-content text-warning">{{ worksheetInfo.equipCount - worksheetInfo.awaitInspectSum || 0 }}/{{ worksheetInfo.equipCount }}</text>
  23. </view>
  24. <view class="kd-cell">
  25. <text class="kd-label">计划完成时长</text>
  26. <text class="kd-content">{{ worksheetInfo.duration }}分钟</text>
  27. </view>
  28. <view class="kd-cell">
  29. <text class="kd-label">实际完成时长</text>
  30. <text class="kd-content">{{ finishTime(worksheetInfo.acceptTime, worksheetInfo.finishTime) }}</text>
  31. </view>
  32. <view class="kd-cell">
  33. <text class="kd-label">实际开始时间</text>
  34. <text class="kd-content">{{ worksheetInfo.acceptTime }}</text>
  35. </view>
  36. <view class="kd-cell">
  37. <text class="kd-label">实际完成时间</text>
  38. <text class="kd-content">{{ worksheetInfo.finishTime }}</text>
  39. </view>
  40. <!-- <u-button type="primary" size="large" text="开始执行"></u-button> -->
  41. <template v-if="worksheetInfo.status">
  42. <template v-if="worksheetInfo.status.code === 0">
  43. <button class="btn-execute" type="primary" @click="handleExecute">开始执行</button>
  44. <div class="apply-box">
  45. <!-- <button
  46. class="btn-reassignment"
  47. type="primary"
  48. @click="sparepartApply"
  49. >
  50. 申请备品备件
  51. </button> -->
  52. </div>
  53. </template>
  54. <template v-else-if="worksheetInfo.status.code === 1">
  55. <button class="btn-execute" type="primary" @click="handleReport">报工</button>
  56. </template>
  57. <button v-else-if="worksheetInfo.status.code === 3" :disabled="true" class="btn-execute" type="primary">已报工</button>
  58. <div class="apply-box">
  59. <button v-if="worksheetInfo.status.code !== 3" class="btn-reassignment" type="primary" @click="sparepartApply">申请备品备件</button>
  60. <button v-if="worksheetInfo.status.code === 0" class="btn-reassignment" type="primary" @click="handleAssign">转派</button>
  61. </div>
  62. </template>
  63. </view>
  64. <view class="kd-equipment" v-show="active === 1">
  65. <view class="kd-type-box">
  66. <text :class="{ 'type—active': typeActive === index }" v-for="(item, index) in equpStatus" :key="index" @click="typeChange(index)">{{ item.name }}</text>
  67. </view>
  68. <view class="kd-list-container">
  69. <u-list @scrolltolower="scrolltolower">
  70. <u-list-item v-for="(item, index) in euqiList" :key="index">
  71. <view class="kd-card">
  72. <view class="kd-card-wrapper">
  73. <view class="kd-cell">
  74. <text class="kd-label">设备编码</text>
  75. <text class="kd-content">{{ item.equiCode }}</text>
  76. </view>
  77. <view class="kd-cell">
  78. <text class="kd-label">设备名称</text>
  79. <text class="kd-content">{{ item.equiName }}</text>
  80. </view>
  81. <view class="kd-cell">
  82. <text class="kd-label">设备型号</text>
  83. <text class="kd-content">{{ item.equiModel }}</text>
  84. </view>
  85. <view class="kd-cell">
  86. <text class="kd-label">设备位置</text>
  87. <text class="kd-content">{{ item.equiLocation }}</text>
  88. </view>
  89. <view class="kd-cell">
  90. <text class="kd-label">执行结果</text>
  91. <text class="kd-content">
  92. <text class="status-box text-warning" v-if="item.resultStatus === 0">待保养</text>
  93. <text class="status-box text-primary" v-else-if="item.resultStatus === 1">完成保养</text>
  94. <text class="status-box text-danger" v-else-if="item.resultStatus === 2">缺陷</text>
  95. <text class="status-box text-primary" v-else-if="item.resultStatus === 3">已报修</text>
  96. </text>
  97. </view>
  98. </view>
  99. <view class="card-footer">
  100. <button type="primary" class="primary-btn" @click="handleCheck(item)" v-if="worksheetInfo.status && worksheetInfo.status.code === 1">执行</button>
  101. <template v-if="worksheetInfo.status && worksheetInfo.status.code === 3">
  102. <button type="default" v-if="item.resultStatus === 2" @click="handLbx(item)">报修</button>
  103. <button type="default" v-else-if="item.resultStatus === 3" @click="handLbxDetail(item)">报修详情</button>
  104. </template>
  105. <button type="default" v-if="[0, 3].includes(worksheetInfo.status && worksheetInfo.status.code)" @click="checkDetail(item)">保养详情</button>
  106. </view>
  107. </view>
  108. </u-list-item>
  109. </u-list>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <uni-popup ref="inputDialog" type="dialog">
  115. <uni-popup-dialog
  116. ref="inputClose"
  117. mode="input"
  118. title="您当前已超出计划完成时间,请填写原因"
  119. placeholder="请输入内容"
  120. :before-close="true"
  121. @close="handleClose"
  122. @confirm="timeoutCauseConfirm"></uni-popup-dialog>
  123. </uni-popup>
  124. <u-modal :show="modalShow" title="提示" @confirm="modalShow = false">
  125. <view>
  126. 您还有
  127. <text class="text-warning">{{ worksheetInfo.awaitInspectSum }}</text>
  128. 台设备待检,不可报工
  129. </view>
  130. </u-modal>
  131. <Assign ref="assignRef" @success="assignSuccess" />
  132. <!-- <ScanCode @scancodedate="scancodedate" :model="'uni'"></ScanCode> -->
  133. </view>
  134. </template>
  135. <script>
  136. import { get, post, postJ } from '@/utils/api.js'
  137. import Assign from '@/components/Assign.vue'
  138. import CellInfo from '@/components/CellInfo.vue'
  139. import KdTabs from '@/components/KdTabs.vue'
  140. import dayjs from 'dayjs'
  141. import ScanCode from '@/components/ScanCode.vue'
  142. export default {
  143. components: {
  144. CellInfo,
  145. KdTabs,
  146. Assign,
  147. ScanCode
  148. },
  149. data() {
  150. return {
  151. modalShow: false,
  152. active: 0,
  153. typeActive: 0,
  154. statusList: {
  155. 0: '待接收',
  156. 1: '执行中',
  157. 3: '已完成'
  158. },
  159. pageId: '',
  160. workOrderCode: '',
  161. worksheetInfo: {
  162. equiList: [],
  163. workOrder: {}
  164. },
  165. equpStatus: [
  166. // {
  167. // name: '全部',
  168. // value: []
  169. // },
  170. {
  171. name: '待执行',
  172. value: [0]
  173. },
  174. {
  175. name: '已执行',
  176. value: [1, 2, 3]
  177. },
  178. {
  179. name: '缺陷',
  180. value: [2]
  181. },
  182. {
  183. name: '全部',
  184. value: []
  185. }
  186. ],
  187. euqiList: [],
  188. equipPage: 1,
  189. isEnd: false,
  190. barType: 0,
  191. qrContent: null
  192. }
  193. },
  194. async onLoad(options) {
  195. this.workOrderCode = options.workOrderCode
  196. this.pageId = options.id
  197. // 设备台账跳转详情
  198. if (options.qrContent) {
  199. this.qrContent = options.qrContent
  200. await this.getInfo()
  201. this.cbScancodedate({ code: this.qrContent })
  202. }
  203. },
  204. onShow() {
  205. this.getInfo()
  206. this.typeChange(0)
  207. let _this = this
  208. uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
  209. uni.$on('scancodedate', function (data) {
  210. _this.cbScancodedate(data)
  211. })
  212. },
  213. onHide() {
  214. uni.$off('scancodedate')
  215. },
  216. onUnload() {
  217. uni.$off('scancodedate')
  218. },
  219. methods: {
  220. // 扫码枪扫码
  221. cbScancodedate(data) {
  222. this.Scancodedate(data.code)
  223. },
  224. // 相机扫码
  225. HandlScanCode() {
  226. let _this = this
  227. uni.scanCode({
  228. onlyFromCamera: true,
  229. success: function (res) {
  230. _this.Scancodedate(res.result)
  231. }
  232. })
  233. },
  234. Scancodedate(code) {
  235. let _this = this
  236. if (this.worksheetInfo.status.code === 0) {
  237. uni.showModal({
  238. title: '提示',
  239. content: '工单未开启执行,不可进行保养操作,请先点击“开始执行”!',
  240. confirmText: '开始执行', //这块是确定按钮的文字
  241. cancelText: '取消', //这块是取消的文字
  242. success: function (res) {
  243. if (res.confirm) {
  244. _this.handleExecute() // 执行确认后的操作
  245. } else {
  246. // 执行取消后的操作
  247. }
  248. }
  249. })
  250. return
  251. }
  252. this.qrContent = code.trim()
  253. this.barType = this.setBarType(this.qrContent)
  254. _this.getData()
  255. },
  256. // 设置barType
  257. setBarType(val) {
  258. let index = val.indexOf('@_@')
  259. let result = 0
  260. if (index !== -1) {
  261. let item = val.substr(index + 3, 1)
  262. if (item) {
  263. result = Number(item)
  264. }
  265. }
  266. return result
  267. },
  268. // 根据条码请求设备数据
  269. getData() {
  270. let par = {
  271. barType: this.barType,
  272. qrContent: this.qrContent
  273. }
  274. uni.showLoading({
  275. title: '加载中',
  276. mask: true
  277. })
  278. postJ(this.apiUrl + '/scan/getAssetInfo', par)
  279. .then(res => {
  280. console.log('扫码接口返回', res)
  281. let data = res.data
  282. this.matchEquipment(data)
  283. })
  284. .finally(() => {
  285. uni.hideLoading()
  286. })
  287. },
  288. matchEquipment(data) {
  289. let par = {
  290. assetCode: data.assetCode,
  291. workOrderId: this.worksheetInfo.id
  292. }
  293. console.log('par', par)
  294. post(this.apiUrl + '/workOrder/scanMatching', par).then(res => {
  295. let data = res.data
  296. if (!data) {
  297. uni.showModal({
  298. title: '提示',
  299. content: '本工单中,无此设备!',
  300. confirmText: '好的', //这块是确定按钮的文字
  301. showCancel: false,
  302. success: function (res) {
  303. if (res.confirm) {
  304. // 执行确认后的操作
  305. } else {
  306. // 执行取消后的操作
  307. }
  308. }
  309. })
  310. } else {
  311. // 未报工
  312. if (this.worksheetInfo.status.code === 1) {
  313. this.handleCheck(data)
  314. }
  315. // 已报工
  316. if (this.worksheetInfo.status.code === 3) {
  317. this.checkDetail(data)
  318. }
  319. }
  320. })
  321. },
  322. back() {
  323. uni.navigateBack({
  324. delta: 1
  325. })
  326. },
  327. handleAssign() {
  328. this.$refs.assignRef.open(this.pageId)
  329. },
  330. assignSuccess() {
  331. this.back()
  332. },
  333. finishTime(start, end) {
  334. if (!end) return ''
  335. let dur = new Date(end).getTime() - new Date(start).getTime()
  336. return Math.ceil(dur / 1000 / 60) + '分钟'
  337. },
  338. // 申请备品备件
  339. sparepartApply() {
  340. uni.navigateTo({
  341. url: `/pages/maintenance/sparepart/sparepart?planCode=${this.worksheetInfo.planCode}&sourceId=${this.worksheetInfo.id}&sourceCode=${this.worksheetInfo.workOrderCode}`
  342. })
  343. },
  344. // 申请备品备件详情
  345. sparepartDetail() {
  346. uni.navigateTo({
  347. url: `/pages/maintenance/sparepart/sparepartDetail?applyOrder=${this.worksheetInfo.applyOrder}`
  348. })
  349. },
  350. // 报工
  351. handleReport() {
  352. // if (
  353. // new Date(this.worksheetInfo.planFinishTime).getTime() <
  354. // new Date().getTime()
  355. // ) {
  356. // this.$refs.inputDialog.open()
  357. // return
  358. // }
  359. this._report()
  360. },
  361. handleClose() {
  362. this.$refs.inputDialog.close()
  363. },
  364. timeoutCauseConfirm(value) {
  365. if (!value) {
  366. uni.showToast({
  367. title: '请输入超时原因',
  368. icon: 'none'
  369. })
  370. return
  371. }
  372. this.$refs.inputDialog.close()
  373. this._report(value)
  374. },
  375. _report(timeoutCause = '') {
  376. post(
  377. this.apiUrl + '/workOrder/reportWork',
  378. {
  379. workOrderId: this.pageId,
  380. timeoutCause
  381. },
  382. true,
  383. false
  384. )
  385. .then(res => {
  386. let _this = this
  387. if (res?.success) {
  388. let data = res.data
  389. if (data.length) {
  390. uni.showModal({
  391. title: '提示',
  392. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  393. cancelText: '取消', // 取消按钮的文字
  394. confirmText: '报修', // 确认按钮的文字
  395. showCancel: true, // 是否显示取消按钮,默认为 true
  396. success: res => {
  397. if (res.confirm) {
  398. if (data.length > 1) {
  399. uni.navigateTo({
  400. url: `/pages/maintenance/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.pageId}&chooseTab=true`
  401. })
  402. } else {
  403. uni.navigateTo({
  404. url: `/pages/repair/repair/index?source=5&workOrderCode=${this.workOrderCode}&equiCode=${data[0].equiCode}&equiId=${data[0].equiId}&workOrderId=${this.pageId}&equiName=${data[0].equiName}&equiModel=${data[0].equiModel}&equiLocation=${data[0].equiLocation}`
  405. })
  406. }
  407. } else {
  408. _this.getInfo()
  409. }
  410. }
  411. })
  412. } else {
  413. uni.showToast({
  414. icon: 'success',
  415. title: '操作成功!',
  416. duration: 2000
  417. })
  418. this.getInfo()
  419. }
  420. }
  421. })
  422. .catch(res => {
  423. if (res.code === '4444') {
  424. this.$refs.inputDialog.open()
  425. } else if (res.code === '5555') {
  426. this.modalShow = true
  427. // uni.showModal({
  428. // title: '提示',
  429. // content: `您还有 ${this.worksheetInfo.awaitInspectSum} 台设备待检,不可报工`,
  430. // success: function (res) {},
  431. // showCancel: false
  432. // })
  433. }
  434. })
  435. },
  436. // 执行工单
  437. handleExecute() {
  438. post(this.apiUrl + '/workOrder/execute', {
  439. workOrderCode: this.workOrderCode
  440. }).then(res => {
  441. if (res?.success && res.data) {
  442. uni.showToast({
  443. icon: 'success',
  444. title: '操作成功!',
  445. duration: 2000
  446. })
  447. this.active = 1
  448. this.getInfo()
  449. }
  450. })
  451. },
  452. //巡点检设备加载更多
  453. scrolltolower() {
  454. if (this.isEnd) return
  455. this.equipPage++
  456. this.getEquipList()
  457. },
  458. // 巡点检设备列表
  459. getEquipList() {
  460. const params = {
  461. workOrderId: this.pageId,
  462. resultStatus: this.equpStatus[this.typeActive].value
  463. }
  464. post(this.apiUrl + `/workOrder/getEquipmentListApp?page=${this.equipPage}&size=10`, params, true).then(res => {
  465. if (res?.success) {
  466. if (this.equipPage === 1) {
  467. this.euqiList = res.data.records
  468. } else {
  469. this.euqiList.push(...res.data.records)
  470. }
  471. this.isEnd = this.euqiList.length >= res.data.total
  472. }
  473. })
  474. },
  475. handleTabChange(value) {
  476. if (value === 1) {
  477. this.typeChange(0)
  478. }
  479. },
  480. // 设备状态切换
  481. typeChange(type) {
  482. this.typeActive = type
  483. this.equipPage = 1
  484. this.getEquipList()
  485. },
  486. handleCheck({ id, equiName, equiCode, sparePartsJson }) {
  487. this.$store.commit('maintenance/SET_SPAREPARTSJSON', sparePartsJson)
  488. uni.navigateTo({
  489. url: `/pages/maintenance/check/index?workOrderId=${this.pageId}&id=${id}&equiName=${equiName}&equiCode=${equiCode}&applyOrder=${this.worksheetInfo.applyOrder}&workOrderCode=${this.worksheetInfo.workOrderCode}`
  490. })
  491. },
  492. checkDetail({ id, equiName, equiCode, sparePartsJson }) {
  493. this.$store.commit('maintenance/SET_SPAREPARTSJSON', sparePartsJson)
  494. uni.navigateTo({
  495. url: `/pages/maintenance/check/detail?workOrderId=${this.pageId}&id=${id}&equiName=${equiName}&equiCode=${equiCode}&applyOrder=${this.worksheetInfo.applyOrder}&workOrderCode=${this.worksheetInfo.workOrderCode}`
  496. })
  497. },
  498. getInfo() {
  499. post(this.apiUrl + '/workOrder/getDetailsApp', {
  500. workOrderCode: this.workOrderCode
  501. }).then(res => {
  502. if (res?.success) {
  503. this.worksheetInfo = res.data
  504. }
  505. })
  506. },
  507. // 报修
  508. handLbx(item) {
  509. uni.navigateTo({
  510. url: `/pages/repair/repair/index?source=4&workOrderCode=${this.workOrderCode}&equiCode=${item.equiCode}&equiId=${item.equiId}&workOrderId=${this.pageId}&equiName=${item.equiName}&equiModel=${item.equiModel}&equiLocation=${item.equiLocation}`
  511. })
  512. },
  513. // 报修详情
  514. handLbxDetail(item) {
  515. uni.navigateTo({
  516. url: `/pages/repair/detail/detail?id=${item.repairId}`
  517. })
  518. }
  519. }
  520. }
  521. </script>
  522. <style lang="scss" scoped>
  523. @import '@/components/submitted.scss';
  524. .list-cell {
  525. display: flex;
  526. align-items: center;
  527. justify-content: space-between;
  528. color: $uni-text-color-grey;
  529. padding: 5rpx 20rpx;
  530. }
  531. .font-sm {
  532. font-size: $uni-font-size-sm;
  533. }
  534. .font-text {
  535. color: $uni-text-color;
  536. }
  537. .btn-execute {
  538. background-color: $j-primary-border-green;
  539. width: 450rpx;
  540. margin-top: 10vh;
  541. }
  542. .btn-reassignment {
  543. color: $uni-color-primary;
  544. background-color: transparent;
  545. border: none;
  546. box-shadow: none;
  547. &::after {
  548. display: none;
  549. }
  550. }
  551. .maintenance-container {
  552. position: fixed;
  553. top: 0;
  554. bottom: 0;
  555. width: 100vw;
  556. display: flex;
  557. flex-direction: column;
  558. /deep/.u-popup {
  559. flex: none !important;
  560. }
  561. }
  562. .maintenance-wrapper {
  563. position: relative;
  564. flex: 1;
  565. }
  566. .maintenance-content {
  567. padding-top: 40rpx;
  568. box-sizing: border-box;
  569. // height: calc(100vh - 88rpx);
  570. position: absolute;
  571. top: 0;
  572. bottom: 0;
  573. left: 0;
  574. right: 0;
  575. display: flex;
  576. flex-direction: column;
  577. }
  578. .kd-cell {
  579. line-height: 90rpx;
  580. border-bottom: 1px dashed #dadada;
  581. display: flex;
  582. justify-content: space-between;
  583. .kd-label {
  584. display: inline-block;
  585. width: 7em;
  586. font-weight: bold;
  587. }
  588. .kd-content {
  589. flex: 1;
  590. text-align: left;
  591. word-break: break-all;
  592. }
  593. }
  594. .kd-baseInfo {
  595. padding: 0 32rpx;
  596. font-size: 28rpx;
  597. }
  598. .kd-equipment {
  599. flex: 1;
  600. display: flex;
  601. flex-direction: column;
  602. overflow: hidden;
  603. .kd-type-box {
  604. text-align: center;
  605. padding: 26rpx 0;
  606. text {
  607. display: inline-block;
  608. width: 120rpx;
  609. padding: 4rpx 0;
  610. color: #333;
  611. margin: 0 8rpx;
  612. &.type—active {
  613. background-color: rgba(215, 215, 215, 1);
  614. }
  615. }
  616. }
  617. .kd-list-container {
  618. flex: 1;
  619. display: flex;
  620. flex-direction: column;
  621. overflow: hidden;
  622. padding: 12rpx 18rpx;
  623. background-color: $page-bg;
  624. .u-list {
  625. flex: 1;
  626. height: 100% !important;
  627. }
  628. }
  629. }
  630. .kd-card {
  631. background-color: #fff;
  632. margin-bottom: 20rpx;
  633. padding: 8rpx 0;
  634. font-size: 28rpx;
  635. word-break: break-all;
  636. .kd-card-wrapper {
  637. padding: 0 30rpx;
  638. border-bottom: 1px solid #dadada;
  639. }
  640. .kd-cell {
  641. line-height: 60rpx;
  642. }
  643. .kd-cell:last-of-type {
  644. border-bottom: none;
  645. }
  646. .status-box {
  647. margin-right: 16rpx;
  648. }
  649. .card-footer {
  650. display: flex;
  651. justify-content: flex-end;
  652. align-items: center;
  653. padding: 8rpx 0 20rpx;
  654. button {
  655. width: 180rpx;
  656. height: 56rpx;
  657. line-height: 56rpx;
  658. font-size: 28rpx;
  659. margin: 0 8rpx;
  660. }
  661. .primary-btn {
  662. background-color: $j-primary-border-green;
  663. }
  664. }
  665. }
  666. .apply-box {
  667. width: 70%;
  668. margin: 0 auto;
  669. display: flex;
  670. align-items: center;
  671. justify-content: space-around;
  672. }
  673. </style>