index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. <view class="check-list">
  14. <CheckCard v-for="(item, index) in equipList" :item="item" class="mb20" :index="index"></CheckCard>
  15. </view>
  16. <view class="footer">
  17. <view class="btn" @click="back">返回</view>
  18. <view class="btn primary" @click="handleSave">保存</view>
  19. </view>
  20. </view>
  21. <u-modal :show.sync="visible" class="maintenance-order" :showCancelButton="true" @confirm="confirm"
  22. @cancel="cancel" :closeOnClickOverlay="true">
  23. <view class="" style="flex: 1">
  24. <view class="title">备件使用登记</view>
  25. <view class="register-content">
  26. <view class="inner">
  27. <view class="col" v-for="item in applyEquiPartList">
  28. {{ item.name }}({{ item.code }}/{{ item.model }})
  29. <u-number-box v-model="item.usedNum" :step="1" :min="item.min"
  30. :max="item.num"></u-number-box>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </u-modal>
  36. <uni-popup ref="inputDialog" type="dialog">
  37. <uni-popup-dialog ref="inputClose" mode="input" title="您当前已超出计划完成时间,请填写原因" placeholder="请输入内容"
  38. :before-close="true" @close="handleClose" @confirm="timeoutCauseConfirm"></uni-popup-dialog>
  39. </uni-popup>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. getDeviceInfo,
  45. mattersChecked
  46. } from '@/api/myTicket/index.js'
  47. import {
  48. post,
  49. postJ
  50. } from '@/utils/api.js'
  51. import CheckCard from './components/CheckCard.vue'
  52. export default {
  53. components: {
  54. CheckCard
  55. },
  56. data() {
  57. return {
  58. registerObj: [],
  59. visible: false,
  60. pageId: '',
  61. page: 1,
  62. equipList: [],
  63. isEnd: false,
  64. equiName: '',
  65. equiCode: '',
  66. workOrderId: '',
  67. applyEquiPartList: [],
  68. originList: [],
  69. workOrderCode: ''
  70. }
  71. },
  72. onLoad(options) {
  73. // this.pageId = options.id
  74. // this.workOrderId = options.workOrderId
  75. // this.equiName = options.equiName
  76. // this.equiCode = options.equiCode
  77. // this.workOrderCode = options.workOrderCode
  78. this.id = options.id
  79. this.getList()
  80. // this.getApplyEquiPartList(+options.workOrderId, options.id)
  81. // this.getUsePartList(+options.workOrderId, options.id);
  82. },
  83. // onReachBottom () {
  84. // if (this.isEnd) return
  85. // this.page++
  86. // this.getList()
  87. // },
  88. methods: {
  89. back() {
  90. uni.navigateBack({
  91. delta: 1
  92. })
  93. },
  94. confirm() {
  95. this.originList = uni.$u.deepClone(this.applyEquiPartList)
  96. this.visible = false
  97. },
  98. cancel() {
  99. this.applyEquiPartList = uni.$u.deepClone(this.originList)
  100. this.visible = false
  101. },
  102. goRegister() {
  103. uni.navigateTo({
  104. url: `/pages/maintenance/check/register?workOrderCode=${this.workOrderCode}&workOrderId=${this.workOrderId}&equipmentCode=${this.equiCode}`
  105. })
  106. },
  107. getApplyEquiPartList(workOrderId, planEquiId) {
  108. post(this.apiUrl + '/stockOutApply/getApplyEquiPartList', {
  109. workOrderId,
  110. planEquiId
  111. }).then(res => {
  112. if (res?.success) {
  113. this.originList = res.data.map(i => {
  114. i.min = i.usedNum
  115. return i
  116. })
  117. this.applyEquiPartList = uni.$u.deepClone(this.originList)
  118. }
  119. })
  120. },
  121. // getUsePartList(workOrderId, planEquiId){
  122. // post(this.apiUrl + '/stockOutApply/getUsePartList', {workOrderId, planEquiId}).then(res => {
  123. // if(res?.success){
  124. // this.originList = res.data
  125. // this.applyEquiPartList = uni.$u.deepClone(this.originList)
  126. // }
  127. // })
  128. // },
  129. handleSave() {
  130. console.log(this.equipList, '-------')
  131. let isAllPass = true
  132. isAllPass = this.equipList.every(item => item.status > -1)
  133. let params = {
  134. id: this.equipList[0].id,
  135. executeStatus: isAllPass ? 1 : 2,
  136. isAbnormal: isAllPass ? 1 : 0,
  137. workItems: this.equipList.map(item => {
  138. return {
  139. content: item.content,
  140. name: item.name,
  141. norm: item.norm,
  142. operationGuide: item.operationGuide,
  143. result: item.result,
  144. serialNum: item.serialNum,
  145. status: item.status == -1 ? -1 : 1,
  146. // 新增 拍照数据
  147. photoList: item.photoList || []
  148. }
  149. })
  150. }
  151. mattersChecked(params).then(data => {
  152. uni.showToast({
  153. duration: 2000,
  154. title: '保存成功!'
  155. })
  156. this.back()
  157. })
  158. // let _this = this
  159. // const params = {
  160. // itemList: this.equipList,
  161. // planEquiId: this.pageId,
  162. // workOrderId: +this.workOrderId,
  163. // workOrderType: 2,
  164. // stockOutApplyPartList: this.originList.filter(i => !!i.usedNum)
  165. // }
  166. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  167. // if (res?.success) {
  168. // if (res.data) {
  169. // uni.showModal({
  170. // title: '提示',
  171. // content: '所有设备已执行完,是否报工?',
  172. // cancelText: '取消', // 取消按钮的文字
  173. // confirmText: '报工', // 确认按钮的文字
  174. // showCancel: true, // 是否显示取消按钮,默认为 true
  175. // success: res => {
  176. // if (res.confirm) {
  177. // _this._report()
  178. // } else {
  179. // _this.back()
  180. // }
  181. // }
  182. // })
  183. // } else {
  184. // uni.showToast({
  185. // duration: 2000,
  186. // title: '保存成功!'
  187. // })
  188. // this.back()
  189. // }
  190. // }
  191. // })
  192. },
  193. handleClose() {
  194. this.$refs.inputDialog.close()
  195. },
  196. timeoutCauseConfirm(value) {
  197. if (!value) {
  198. uni.showToast({
  199. title: '请输入超时原因',
  200. icon: 'none'
  201. })
  202. return
  203. }
  204. this.$refs.inputDialog.close()
  205. this._report(value)
  206. },
  207. _report(timeoutCause = '') {
  208. post(
  209. this.apiUrl + '/workOrder/reportWork', {
  210. workOrderId: this.workOrderId,
  211. timeoutCause
  212. },
  213. true,
  214. false
  215. )
  216. .then(res => {
  217. if (res?.success) {
  218. let data = res.data
  219. if (data.length) {
  220. uni.showModal({
  221. title: '提示',
  222. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  223. cancelText: '取消', // 取消按钮的文字
  224. confirmText: '报修', // 确认按钮的文字
  225. showCancel: true, // 是否显示取消按钮,默认为 true
  226. success: res => {
  227. if (res.confirm) {
  228. if (data.length > 1) {
  229. uni.navigateTo({
  230. url: `/pages/maintenance/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`
  231. })
  232. } else {
  233. uni.navigateTo({
  234. 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}`
  235. })
  236. }
  237. } else {
  238. _this.back()
  239. }
  240. }
  241. })
  242. } else {
  243. uni.showToast({
  244. icon: 'success',
  245. title: '操作成功!',
  246. duration: 2000
  247. })
  248. _this.back()
  249. }
  250. }
  251. })
  252. .catch(res => {
  253. if (res.code === '4444') {
  254. this.$refs.inputDialog.open()
  255. }
  256. })
  257. },
  258. getList() {
  259. getDeviceInfo({
  260. id: this.id
  261. }).then(data => {
  262. this.equiName = data.name
  263. this.equiCode = data.code
  264. this.equipList = data.workItems.map(item => {
  265. return {
  266. ...item,
  267. id: data.id,
  268. status: 1,
  269. result: '正常',
  270. executeStatus: 1
  271. }
  272. })
  273. })
  274. // const { page } = this
  275. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: +this.workOrderId }, true).then(res => {
  276. // if (res?.success) {
  277. // res.data.records.forEach(item => {
  278. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  279. // })
  280. // if (page === 1) {
  281. // this.equipList = res.data.records
  282. // } else {
  283. // this.equipList.push(...res.data.records)
  284. // }
  285. // this.isEnd = this.equipList.length >= res.data.total
  286. // }
  287. // })
  288. }
  289. }
  290. }
  291. </script>
  292. <style lang="scss" scoped>
  293. .check-content {
  294. box-sizing: border-box;
  295. display: flex;
  296. flex-direction: column;
  297. padding-bottom: 100rpx;
  298. .title {
  299. line-height: 80rpx;
  300. display: flex;
  301. justify-content: space-between;
  302. padding: 0 30rpx;
  303. }
  304. .check-list {
  305. flex: 1;
  306. overflow: auto;
  307. padding: 0 30rpx 100rpx;
  308. }
  309. .footer {
  310. height: 100rpx;
  311. display: flex;
  312. position: fixed;
  313. bottom: 0;
  314. width: 100vw;
  315. border: 1rpx solid $j-primary-border-green;
  316. background: #fff;
  317. z-index: 100;
  318. .btn {
  319. display: flex;
  320. flex: 1;
  321. justify-content: center;
  322. align-items: center;
  323. border-radius: 0;
  324. &.primary {
  325. background-color: $j-primary-border-green;
  326. color: #fff;
  327. }
  328. }
  329. }
  330. .mb20 {
  331. margin-bottom: 20rpx;
  332. }
  333. }
  334. .nav-right {
  335. position: relative;
  336. .text-box {
  337. white-space: nowrap;
  338. padding: 4rpx;
  339. border: 1rpx solid rgba(242, 242, 242, 1);
  340. }
  341. }
  342. .maintenance-order {
  343. /deep/ .u-modal__content {
  344. padding: 0 !important;
  345. .u-number-box__minus,
  346. .u-number-box__plus,
  347. .u-number-box__input {
  348. font-size: 30rpx;
  349. height: 1.4em !important;
  350. }
  351. }
  352. .title {
  353. background-color: rgba(51, 51, 51, 1);
  354. line-height: 60rpx;
  355. text-align: center;
  356. color: #fff;
  357. }
  358. .register-content {
  359. padding: 20rpx;
  360. .inner {
  361. border: 1rpx solid rgba(242, 242, 242, 1);
  362. .col {
  363. font-size: 28rpx;
  364. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  365. display: flex;
  366. padding: 10rpx;
  367. justify-content: space-between;
  368. }
  369. }
  370. }
  371. }
  372. </style>