index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. workItems: this.equipList.map(item => {
  137. return {
  138. content: item.content,
  139. name: item.name,
  140. norm: item.norm,
  141. operationGuide: item.operationGuide,
  142. result: item.result,
  143. serialNum: item.serialNum,
  144. status: item.status,
  145. // 新增 拍照数据
  146. photoList: item.photoList || []
  147. }
  148. })
  149. }
  150. mattersChecked(params).then(data => {
  151. uni.showToast({
  152. duration: 2000,
  153. title: '保存成功!'
  154. })
  155. this.back()
  156. })
  157. // let _this = this
  158. // const params = {
  159. // itemList: this.equipList,
  160. // planEquiId: this.pageId,
  161. // workOrderId: +this.workOrderId,
  162. // workOrderType: 2,
  163. // stockOutApplyPartList: this.originList.filter(i => !!i.usedNum)
  164. // }
  165. // postJ(this.apiUrl + `/workOrder/itemsInspect`, params, true).then(res => {
  166. // if (res?.success) {
  167. // if (res.data) {
  168. // uni.showModal({
  169. // title: '提示',
  170. // content: '所有设备已执行完,是否报工?',
  171. // cancelText: '取消', // 取消按钮的文字
  172. // confirmText: '报工', // 确认按钮的文字
  173. // showCancel: true, // 是否显示取消按钮,默认为 true
  174. // success: res => {
  175. // if (res.confirm) {
  176. // _this._report()
  177. // } else {
  178. // _this.back()
  179. // }
  180. // }
  181. // })
  182. // } else {
  183. // uni.showToast({
  184. // duration: 2000,
  185. // title: '保存成功!'
  186. // })
  187. // this.back()
  188. // }
  189. // }
  190. // })
  191. },
  192. handleClose() {
  193. this.$refs.inputDialog.close()
  194. },
  195. timeoutCauseConfirm(value) {
  196. if (!value) {
  197. uni.showToast({
  198. title: '请输入超时原因',
  199. icon: 'none'
  200. })
  201. return
  202. }
  203. this.$refs.inputDialog.close()
  204. this._report(value)
  205. },
  206. _report(timeoutCause = '') {
  207. post(
  208. this.apiUrl + '/workOrder/reportWork', {
  209. workOrderId: this.workOrderId,
  210. timeoutCause
  211. },
  212. true,
  213. false
  214. )
  215. .then(res => {
  216. if (res?.success) {
  217. let data = res.data
  218. if (data.length) {
  219. uni.showModal({
  220. title: '提示',
  221. content: `有${data.length}台设备被标记为缺陷,是否要报修?`,
  222. cancelText: '取消', // 取消按钮的文字
  223. confirmText: '报修', // 确认按钮的文字
  224. showCancel: true, // 是否显示取消按钮,默认为 true
  225. success: res => {
  226. if (res.confirm) {
  227. if (data.length > 1) {
  228. uni.navigateTo({
  229. url: `/pages/maintenance/detail/detail?workOrderCode=${this.workOrderCode}&id=${this.workOrderId}&chooseTab=true`
  230. })
  231. } else {
  232. uni.navigateTo({
  233. 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}`
  234. })
  235. }
  236. } else {
  237. _this.back()
  238. }
  239. }
  240. })
  241. } else {
  242. uni.showToast({
  243. icon: 'success',
  244. title: '操作成功!',
  245. duration: 2000
  246. })
  247. _this.back()
  248. }
  249. }
  250. })
  251. .catch(res => {
  252. if (res.code === '4444') {
  253. this.$refs.inputDialog.open()
  254. }
  255. })
  256. },
  257. getList() {
  258. getDeviceInfo({
  259. id: this.id
  260. }).then(data => {
  261. this.equiName = data.name
  262. this.equiCode = data.code
  263. this.equipList = data.workItems.map(item => {
  264. return {
  265. ...item,
  266. id: data.id,
  267. executeStatus: 1
  268. }
  269. })
  270. })
  271. // const { page } = this
  272. // post(this.apiUrl + `/workOrder/getEquipmentItemsListApp?size=10&page=${page}`, { planEquiId: +this.pageId, workOrderId: +this.workOrderId }, true).then(res => {
  273. // if (res?.success) {
  274. // res.data.records.forEach(item => {
  275. // item.isNormal = item.isNormal === null || item.isNormal === undefined ? 1 : item.isNormal
  276. // })
  277. // if (page === 1) {
  278. // this.equipList = res.data.records
  279. // } else {
  280. // this.equipList.push(...res.data.records)
  281. // }
  282. // this.isEnd = this.equipList.length >= res.data.total
  283. // }
  284. // })
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .check-content {
  291. box-sizing: border-box;
  292. display: flex;
  293. flex-direction: column;
  294. padding-bottom: 100rpx;
  295. .title {
  296. line-height: 80rpx;
  297. display: flex;
  298. justify-content: space-between;
  299. padding: 0 30rpx;
  300. }
  301. .check-list {
  302. flex: 1;
  303. overflow: auto;
  304. padding: 0 30rpx 100rpx;
  305. }
  306. .footer {
  307. height: 100rpx;
  308. display: flex;
  309. position: fixed;
  310. bottom: 0;
  311. width: 100vw;
  312. border: 1rpx solid $j-primary-border-green;
  313. background: #fff;
  314. z-index: 100;
  315. .btn {
  316. display: flex;
  317. flex: 1;
  318. justify-content: center;
  319. align-items: center;
  320. border-radius: 0;
  321. &.primary {
  322. background-color: $j-primary-border-green;
  323. color: #fff;
  324. }
  325. }
  326. }
  327. .mb20 {
  328. margin-bottom: 20rpx;
  329. }
  330. }
  331. .nav-right {
  332. position: relative;
  333. .text-box {
  334. white-space: nowrap;
  335. padding: 4rpx;
  336. border: 1rpx solid rgba(242, 242, 242, 1);
  337. }
  338. }
  339. .maintenance-order {
  340. /deep/ .u-modal__content {
  341. padding: 0 !important;
  342. .u-number-box__minus,
  343. .u-number-box__plus,
  344. .u-number-box__input {
  345. font-size: 30rpx;
  346. height: 1.4em !important;
  347. }
  348. }
  349. .title {
  350. background-color: rgba(51, 51, 51, 1);
  351. line-height: 60rpx;
  352. text-align: center;
  353. color: #fff;
  354. }
  355. .register-content {
  356. padding: 20rpx;
  357. .inner {
  358. border: 1rpx solid rgba(242, 242, 242, 1);
  359. .col {
  360. font-size: 28rpx;
  361. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  362. display: flex;
  363. padding: 10rpx;
  364. justify-content: space-between;
  365. }
  366. }
  367. }
  368. }
  369. </style>