index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="保养中" @clickLeft="back">
  4. <!-- <view class="nav-right" slot="right">
  5. <view class="text-box" @click="goRegister"> 备件使用登记 </view>
  6. </view> -->
  7. </uni-nav-bar>
  8. <view class="check-content">
  9. <view class="title">
  10. {{ equiName }}
  11. <text>{{ equiCode }}</text>
  12. </view>
  13. <!-- 选择状态栏 -->
  14. <view class="select-bar" v-if="showSelectBar">
  15. <view class="select-actions">
  16. <view class="select-all" @click="selectAll">
  17. <checkbox :checked="allSelected" color="#157a2c" />
  18. <text>{{ allSelected ? '取消全选' : '全选' }}</text>
  19. </view>
  20. <view class="selected-count">
  21. <text>已选择 {{ selectedCount }} 项</text>
  22. </view>
  23. </view>
  24. <view class="batch-btn" @click="openBatchDialog" :class="{ disabled: selectedCount === 0 }">
  25. <text>批量操作</text>
  26. </view>
  27. <view class="close-select" @click="closeSelectBar">
  28. <text>取消选择</text>
  29. </view>
  30. </view>
  31. <view class="batch-trigger" @click="openSelectBar" v-if="!showSelectBar">
  32. <text>批量操作</text>
  33. </view>
  34. <view class="check-list">
  35. <CheckCard v-for="(item, index) in equipList" :item="item" class="mb20" :index="index"></CheckCard>
  36. </view>
  37. <view class="footer">
  38. <view class="btn" @click="back">返回</view>
  39. <view class="btn primary" @click="handleSave">保存</view>
  40. </view>
  41. </view>
  42. <!-- 批量操作弹窗 -->
  43. <uni-popup ref="batchPopup" type="bottom">
  44. <view class="batch-popup-content">
  45. <view class="popup-header">
  46. <text class="header-title">批量操作</text>
  47. <view class="close-btn" @click="closeBatchPopup">
  48. <text class="close-icon">×</text>
  49. </view>
  50. </view>
  51. <view class="popup-body">
  52. <view class="select-info">
  53. <text>已选择 {{ selectedCount }} 项</text>
  54. </view>
  55. <view class="action-btn status-btn" @click="batchSetStatus(1)">
  56. <text class="status-icon normal-icon">✓</text>
  57. <text>批量设为正常</text>
  58. </view>
  59. <view class="action-btn status-btn" @click="batchSetStatus(-1)">
  60. <text class="status-icon abnormal-icon">✗</text>
  61. <text>批量设为异常</text>
  62. </view>
  63. </view>
  64. </view>
  65. </uni-popup>
  66. <u-modal :show.sync="visible" class="maintenance-order" :showCancelButton="true" @confirm="confirm"
  67. @cancel="cancel" :closeOnClickOverlay="true">
  68. <view class="" style="flex: 1">
  69. <view class="title">备件使用登记</view>
  70. <view class="register-content">
  71. <view class="inner">
  72. <view class="col" v-for="item in applyEquiPartList">
  73. {{ item.name }}({{ item.code }}/{{ item.model }})
  74. <u-number-box v-model="item.usedNum" :step="1" :min="item.min"
  75. :max="item.num"></u-number-box>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </u-modal>
  81. <uni-popup ref="inputDialog" type="dialog">
  82. <uni-popup-dialog ref="inputClose" mode="input" title="您当前已超出计划完成时间,请填写原因" placeholder="请输入内容"
  83. :before-close="true" @close="handleClose" @confirm="timeoutCauseConfirm"></uni-popup-dialog>
  84. </uni-popup>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. getDeviceInfo,
  90. mattersChecked
  91. } from '@/api/myTicket/index.js'
  92. import {
  93. post,
  94. postJ
  95. } from '@/utils/api.js'
  96. import CheckCard from './components/CheckCard.vue'
  97. export default {
  98. components: {
  99. CheckCard
  100. },
  101. data() {
  102. return {
  103. registerObj: [],
  104. visible: false,
  105. pageId: '',
  106. page: 1,
  107. equipList: [],
  108. isEnd: false,
  109. equiName: '',
  110. equiCode: '',
  111. workOrderId: '',
  112. applyEquiPartList: [],
  113. originList: [],
  114. workOrderCode: '',
  115. showSelectBar: false,
  116. allSelected: false
  117. }
  118. },
  119. computed: {
  120. selectedCount() {
  121. return this.equipList.filter(item => item.checked).length
  122. }
  123. },
  124. onLoad(options) {
  125. // this.pageId = options.id
  126. // this.workOrderId = options.workOrderId
  127. // this.equiName = options.equiName
  128. // this.equiCode = options.equiCode
  129. // this.workOrderCode = options.workOrderCode
  130. this.id = options.id
  131. this.getList()
  132. // this.getApplyEquiPartList(+options.workOrderId, options.id)
  133. // this.getUsePartList(+options.workOrderId, options.id);
  134. },
  135. // onReachBottom () {
  136. // if (this.isEnd) return
  137. // this.page++
  138. // this.getList()
  139. // },
  140. methods: {
  141. back() {
  142. uni.navigateBack({
  143. delta: 1
  144. })
  145. },
  146. confirm() {
  147. this.originList = uni.$u.deepClone(this.applyEquiPartList)
  148. this.visible = false
  149. },
  150. cancel() {
  151. this.applyEquiPartList = uni.$u.deepClone(this.originList)
  152. this.visible = false
  153. },
  154. goRegister() {
  155. uni.navigateTo({
  156. url: `/pages/maintenance/check/register?workOrderCode=${this.workOrderCode}&workOrderId=${this.workOrderId}&equipmentCode=${this.equiCode}`
  157. })
  158. },
  159. getApplyEquiPartList(workOrderId, planEquiId) {
  160. post(this.apiUrl + '/stockOutApply/getApplyEquiPartList', {
  161. workOrderId,
  162. planEquiId
  163. }).then(res => {
  164. if (res?.success) {
  165. this.originList = res.data.map(i => {
  166. i.min = i.usedNum
  167. return i
  168. })
  169. this.applyEquiPartList = uni.$u.deepClone(this.originList)
  170. }
  171. })
  172. },
  173. // getUsePartList(workOrderId, planEquiId){
  174. // post(this.apiUrl + '/stockOutApply/getUsePartList', {workOrderId, planEquiId}).then(res => {
  175. // if(res?.success){
  176. // this.originList = res.data
  177. // this.applyEquiPartList = uni.$u.deepClone(this.originList)
  178. // }
  179. // })
  180. // },
  181. handleSave() {
  182. console.log(this.equipList, '-------')
  183. let isAllPass = true
  184. isAllPass = this.equipList.every(item => item.status > -1)
  185. let params = {
  186. id: this.equipList[0].id,
  187. executeStatus: isAllPass ? 1 : 2,
  188. isAbnormal: isAllPass ? 1 : 0,
  189. workItems: this.equipList.map(item => {
  190. return {
  191. content: item.content,
  192. name: item.name,
  193. norm: item.norm,
  194. operationGuide: item.operationGuide,
  195. result: item.result,
  196. serialNum: item.serialNum,
  197. status: item.status == -1 ? -1 : 1,
  198. // 新增 拍照数据
  199. photoList: item.photoList || []
  200. }
  201. })
  202. }
  203. mattersChecked(params).then(data => {
  204. uni.showToast({
  205. duration: 2000,
  206. title: '保存成功!'
  207. })
  208. this.back()
  209. })
  210. // let _this = this
  211. // const params = {
  212. // itemList: this.equipList,
  213. // planEquiId: this.pageId,
  214. // workOrderId: +this.workOrderId,
  215. // workOrderType: 2,
  216. // stockOutApplyPartList: this.originList.filter(i => !!i.usedNum)
  217. // }
  218. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  219. // if (res?.success) {
  220. // if (res.data) {
  221. // uni.showModal({
  222. // title: '提示',
  223. // content: '所有设备已执行完,是否报工?',
  224. // cancelText: '取消', // 取消按钮的文字
  225. // confirmText: '报工', // 确认按钮的文字
  226. // showCancel: true, // 是否显示取消按钮,默认为 true
  227. // success: res => {
  228. // if (res.confirm) {
  229. // _this._report()
  230. // } else {
  231. // _this.back()
  232. // }
  233. // }
  234. // })
  235. // } else {
  236. // uni.showToast({
  237. // duration: 2000,
  238. // title: '保存成功!'
  239. // })
  240. // this.back()
  241. // }
  242. // }
  243. // })
  244. },
  245. handleClose() {
  246. this.$refs.inputDialog.close()
  247. },
  248. timeoutCauseConfirm(value) {
  249. if (!value) {
  250. uni.showToast({
  251. title: '请输入超时原因',
  252. icon: 'none'
  253. })
  254. return
  255. }
  256. this.$refs.inputDialog.close()
  257. this._report(value)
  258. },
  259. _report(timeoutCause = '') {
  260. post(
  261. this.apiUrl + '/workOrder/reportWork', {
  262. workOrderId: this.workOrderId,
  263. timeoutCause
  264. },
  265. true,
  266. false
  267. )
  268. .then(res => {
  269. if (res?.success) {
  270. let data = res.data
  271. if (data.length) {
  272. uni.showModal({
  273. title: '提示',
  274. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  275. cancelText: '取消', // 取消按钮的文字
  276. confirmText: '报修', // 确认按钮的文字
  277. showCancel: true, // 是否显示取消按钮,默认为 true
  278. success: res => {
  279. if (res.confirm) {
  280. if (data.length > 1) {
  281. uni.navigateTo({
  282. url: `/pages/maintenance/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`
  283. })
  284. } else {
  285. uni.navigateTo({
  286. 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}`
  287. })
  288. }
  289. } else {
  290. _this.back()
  291. }
  292. }
  293. })
  294. } else {
  295. uni.showToast({
  296. icon: 'success',
  297. title: '操作成功!',
  298. duration: 2000
  299. })
  300. _this.back()
  301. }
  302. }
  303. })
  304. .catch(res => {
  305. if (res.code === '4444') {
  306. this.$refs.inputDialog.open()
  307. }
  308. })
  309. },
  310. // 打开选择栏
  311. openSelectBar() {
  312. this.showSelectBar = true
  313. },
  314. // 关闭选择栏
  315. closeSelectBar() {
  316. this.showSelectBar = false
  317. this.equipList.forEach(item => {
  318. item.checked = false
  319. })
  320. this.allSelected = false
  321. },
  322. // 全选/取消全选
  323. selectAll() {
  324. this.allSelected = !this.allSelected
  325. this.equipList.forEach(item => {
  326. item.checked = this.allSelected
  327. })
  328. },
  329. // 打开批量操作弹窗
  330. openBatchDialog() {
  331. if (this.selectedCount === 0) {
  332. uni.showToast({
  333. title: '请先选择要操作的项目',
  334. icon: 'none'
  335. })
  336. return
  337. }
  338. this.$refs.batchPopup.open()
  339. },
  340. // 关闭批量操作弹窗
  341. closeBatchPopup() {
  342. this.$refs.batchPopup.close()
  343. },
  344. // 批量设置状态
  345. batchSetStatus(status) {
  346. const statusText = status === 1 ? '正常' : '异常'
  347. uni.showModal({
  348. title: '确认提示',
  349. content: `确认将选中的 ${this.selectedCount} 项设置为${statusText}吗?`,
  350. success: (res) => {
  351. if (res.confirm) {
  352. this.equipList.forEach(item => {
  353. if (item.checked) {
  354. item.status = status
  355. item.result = statusText
  356. }
  357. })
  358. uni.showToast({
  359. title: '批量设置成功',
  360. icon: 'success'
  361. })
  362. this.closeBatchPopup()
  363. this.closeSelectBar()
  364. }
  365. }
  366. })
  367. },
  368. getList() {
  369. getDeviceInfo({
  370. id: this.id
  371. }).then(data => {
  372. this.equiName = data.name
  373. this.equiCode = data.code
  374. this.equipList = data.workItems.map(item => {
  375. return {
  376. ...item,
  377. id: data.id,
  378. status: 1,
  379. result: '正常',
  380. executeStatus: 1,
  381. checked: false
  382. }
  383. })
  384. })
  385. // const { page } = this
  386. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: +this.workOrderId }, true).then(res => {
  387. // if (res?.success) {
  388. // res.data.records.forEach(item => {
  389. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  390. // })
  391. // if (page === 1) {
  392. // this.equipList = res.data.records
  393. // } else {
  394. // this.equipList.push(...res.data.records)
  395. // }
  396. // this.isEnd = this.equipList.length >= res.data.total
  397. // }
  398. // })
  399. }
  400. }
  401. }
  402. </script>
  403. <style lang="scss" scoped>
  404. .check-content {
  405. box-sizing: border-box;
  406. display: flex;
  407. flex-direction: column;
  408. padding-bottom: 100rpx;
  409. .title {
  410. line-height: 80rpx;
  411. display: flex;
  412. justify-content: space-between;
  413. padding: 0 30rpx;
  414. }
  415. .check-list {
  416. flex: 1;
  417. overflow: auto;
  418. padding: 0 30rpx 100rpx;
  419. }
  420. .footer {
  421. height: 100rpx;
  422. display: flex;
  423. position: fixed;
  424. bottom: 0;
  425. width: 100vw;
  426. border: 1rpx solid $j-primary-border-green;
  427. background: #fff;
  428. z-index: 99;
  429. .btn {
  430. display: flex;
  431. flex: 1;
  432. justify-content: center;
  433. align-items: center;
  434. border-radius: 0;
  435. &.primary {
  436. background-color: $j-primary-border-green;
  437. color: #fff;
  438. }
  439. }
  440. }
  441. .mb20 {
  442. margin-bottom: 20rpx;
  443. }
  444. .batch-trigger {
  445. padding: 20rpx 30rpx;
  446. text-align: right;
  447. text {
  448. background-color: #157a2c;
  449. color: #fff;
  450. padding: 10rpx 30rpx;
  451. border-radius: 8rpx;
  452. font-size: 28rpx;
  453. }
  454. }
  455. .select-bar {
  456. background-color: #f5f5f5;
  457. padding: 20rpx 30rpx;
  458. display: flex;
  459. justify-content: space-between;
  460. align-items: center;
  461. border-bottom: 1rpx solid #e0e0e0;
  462. .select-actions {
  463. display: flex;
  464. align-items: center;
  465. flex: 1;
  466. .select-all {
  467. display: flex;
  468. align-items: center;
  469. margin-right: 20rpx;
  470. text {
  471. margin-left: 10rpx;
  472. font-size: 28rpx;
  473. }
  474. }
  475. .selected-count {
  476. font-size: 28rpx;
  477. color: #666;
  478. }
  479. }
  480. .batch-btn {
  481. background-color: #157a2c;
  482. color: #fff;
  483. padding: 10rpx 30rpx;
  484. border-radius: 8rpx;
  485. font-size: 28rpx;
  486. margin: 0 10rpx;
  487. &.disabled {
  488. background-color: #ccc;
  489. opacity: 0.6;
  490. }
  491. }
  492. .close-select {
  493. padding: 10rpx 20rpx;
  494. background-color: #fff;
  495. border-radius: 8rpx;
  496. font-size: 28rpx;
  497. }
  498. }
  499. }
  500. .nav-right {
  501. position: relative;
  502. .text-box {
  503. white-space: nowrap;
  504. padding: 4rpx;
  505. border: 1rpx solid rgba(242, 242, 242, 1);
  506. }
  507. }
  508. .maintenance-order {
  509. /deep/ .u-modal__content {
  510. padding: 0 !important;
  511. .u-number-box__minus,
  512. .u-number-box__plus,
  513. .u-number-box__input {
  514. font-size: 30rpx;
  515. height: 1.4em !important;
  516. }
  517. }
  518. .title {
  519. background-color: rgba(51, 51, 51, 1);
  520. line-height: 60rpx;
  521. text-align: center;
  522. color: #fff;
  523. }
  524. .register-content {
  525. padding: 20rpx;
  526. .inner {
  527. border: 1rpx solid rgba(242, 242, 242, 1);
  528. .col {
  529. font-size: 28rpx;
  530. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  531. display: flex;
  532. padding: 10rpx;
  533. justify-content: space-between;
  534. }
  535. }
  536. }
  537. }
  538. .batch-popup-content {
  539. background-color: #fff;
  540. border-radius: 20rpx 20rpx 0 0;
  541. padding: 30rpx;
  542. z-index: 1000;
  543. .popup-header {
  544. display: flex;
  545. justify-content: space-between;
  546. align-items: center;
  547. padding-bottom: 30rpx;
  548. border-bottom: 1rpx solid #e0e0e0;
  549. .header-title {
  550. font-size: 36rpx;
  551. font-weight: bold;
  552. color: #333;
  553. }
  554. .close-btn {
  555. width: 60rpx;
  556. height: 60rpx;
  557. display: flex;
  558. align-items: center;
  559. justify-content: center;
  560. .close-icon {
  561. font-size: 60rpx;
  562. color: #999;
  563. line-height: 1;
  564. }
  565. }
  566. }
  567. .popup-body {
  568. padding: 30rpx 0;
  569. .select-info {
  570. padding: 20rpx 0;
  571. text-align: center;
  572. color: #666;
  573. font-size: 28rpx;
  574. }
  575. .action-btn {
  576. display: flex;
  577. align-items: center;
  578. padding: 25rpx 30rpx;
  579. margin: 0 0 20rpx 0;
  580. background-color: #f5f5f5;
  581. border-radius: 12rpx;
  582. font-size: 30rpx;
  583. &:active {
  584. background-color: #e0e0e0;
  585. }
  586. text {
  587. margin-left: 20rpx;
  588. }
  589. }
  590. .status-btn {
  591. .status-icon {
  592. width: 40rpx;
  593. height: 40rpx;
  594. border-radius: 50%;
  595. display: flex;
  596. align-items: center;
  597. justify-content: center;
  598. font-size: 28rpx;
  599. color: #fff;
  600. margin-left: 0;
  601. }
  602. .normal-icon {
  603. background-color: #157a2c;
  604. }
  605. .abnormal-icon {
  606. background-color: #ff4444;
  607. }
  608. }
  609. }
  610. }
  611. </style>