index.vue 9.6 KB

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