index.vue 9.7 KB

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