index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
  4. color="#000" @clickLeft="back" right-icon="scan" @clickRight="HandlScanCode">
  5. </uni-nav-bar>
  6. <view class="list_box">
  7. <u-list @scrolltolower="scrolltolower">
  8. <view class="card_box">
  9. <workOrderBom :item='objData' v-if='objData' @handleScan='handleScan'></workOrderBom>
  10. <paramBom v-if='paramDetailList.length != 0' :list='paramDetailList'></paramBom>
  11. <deviceBom v-if='objData.equipmentList.length != 0' :list='objData.equipmentList'></deviceBom>
  12. <modelBom v-if='objData.modelList.length != 0' :list='objData.modelList' pattern='job'
  13. ref='modelRef'>
  14. </modelBom>
  15. <jobBom v-if='isLoad' :item='objData'
  16. :notFormed='objData.notFormedList' @penalize='penalize' @modeNum='modeNum'></jobBom>
  17. <palletBom :palletList='objData.palletList'></palletBom>
  18. <oneJobBom v-if='objData.instanceList && objData.instanceList.length != 0 && taskType != 4' :item='objData'
  19. :list='objData.instanceList'>
  20. </oneJobBom>
  21. <byProductBom v-if='objData.productRecycleList.length != 0 ' :list='objData.productRecycleList'
  22. @penalize='penalize'>
  23. </byProductBom>
  24. <turnoverBom v-if='objData.turnover.length != 0' :list='objData.turnover' :wordItem='objData'
  25. pattern='job' @handleScan='handleScan'>
  26. </turnoverBom>
  27. <aridRegion v-if='objData.aridRegionList.length != 0' :list='objData.aridRegionList'
  28. :remainingTime='remainingTime' @handleScan='handleScan' :isType='true'></aridRegion>
  29. <packingBom :taskId='taskId' :workOrderId='id' :objData='objData' ref="packRef"
  30. v-if='taskType == 4 && objData'></packingBom>
  31. <view class="operate_box rx-sc">
  32. <u-button size="small" class="u-reset-button" type="success" @click="handAdd">手动添加</u-button>
  33. </view>
  34. </view>
  35. </u-list>
  36. </view>
  37. <view class="bottom-wrapper">
  38. <view class="btn_box" @click="save">一键报工</view>
  39. </view>
  40. <SearchPopup mode="bottom" v-if='searchShow'>
  41. <template v-slot:list>
  42. <view class="search_list">
  43. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  44. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  45. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  46. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  47. </u-form-item>
  48. </u-form>
  49. </view>
  50. </template>
  51. <template v-slot:operate>
  52. <view class="operate_box rx-bc">
  53. <u-button size="small" class="u-reset-button" @click="searchCancel">
  54. 取消
  55. </u-button>
  56. <u-button type="success" size="small" class="u-reset-button" @click="popupOk">
  57. 确定
  58. </u-button>
  59. </view>
  60. </template>
  61. </SearchPopup>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. getByIdReport,
  67. getByCodeReport,
  68. jobSave
  69. } from '@/api/pda/jobBooking.js'
  70. import {
  71. scanLedger,
  72. getWarehouseList,
  73. } from '@/api/pda/workOrder.js'
  74. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  75. import deviceBom from '../../feeding/components/deviceBom.vue'
  76. import modelBom from '../../feeding/components/modelBom.vue'
  77. import jobBom from '../components/jobBom.vue'
  78. import palletBom from '../components/palletBom.vue'
  79. import oneJobBom from '../components/oneJobBom.vue'
  80. import byProductBom from '../components/byProductBom'
  81. import turnoverBom from '../components/turnoverBom.vue'
  82. import aridRegion from '../../feeding/components/aridRegion.vue'
  83. import paramBom from '../../feeding/components/paramBom.vue'
  84. import packingBom from '../components/packingBom.vue'
  85. import SearchPopup from '../../components/searchPopup.vue'
  86. export default {
  87. components: {
  88. workOrderBom,
  89. deviceBom,
  90. modelBom,
  91. jobBom,
  92. palletBom,
  93. oneJobBom,
  94. byProductBom,
  95. turnoverBom,
  96. aridRegion,
  97. paramBom,
  98. packingBom,
  99. SearchPopup
  100. },
  101. data() {
  102. return {
  103. title: '',
  104. taskType: 1,
  105. isLoad: true,
  106. objData: {
  107. equipmentList: [],
  108. modelList: [],
  109. turnover: [],
  110. productRecycleList: [],
  111. aridRegionList: [],
  112. palletList: [],
  113. workReportInfo: {
  114. },
  115. notFormedList: [], // 报工-不合格
  116. },
  117. searchShow: false,
  118. warehouseList: [],
  119. formData: {
  120. warehouseId: ''
  121. },
  122. penalizeIndex: null,
  123. paramDetailList: [],
  124. remainingTime: 0,
  125. id: null,
  126. taskId: null,
  127. }
  128. },
  129. onLoad(options) {
  130. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  131. this.taskType = options.taskType
  132. this.id = options.id
  133. this.taskId = options.taskId
  134. this.getList()
  135. },
  136. onShow() {
  137. uni.$off("setSelectList");
  138. uni.$on("setSelectList", (selectList, id) => {
  139. let turnover = []
  140. let equipmentList = [] // 生产设备
  141. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  142. selectList.forEach(f => {
  143. if (f.rootCategoryLevelId == 4) { // 生产设备
  144. if (isEquipment) {
  145. equipmentList = this.objData.equipmentList
  146. } else {
  147. equipmentList = equipmentList.concat(f)
  148. }
  149. }
  150. if (f.rootCategoryLevelId == 7) { // 周转车
  151. turnover = turnover.concat(f)
  152. }
  153. })
  154. this.$set(this.objData, 'equipmentList', equipmentList)
  155. this.$set(this.objData, 'turnover', turnover)
  156. this.$forceUpdate()
  157. });
  158. },
  159. methods: {
  160. // 相机扫码
  161. HandlScanCode() {
  162. let _this = this
  163. uni.scanCode({
  164. success: function(res) {
  165. _this.scanItAllData(res.result)
  166. }
  167. })
  168. },
  169. scanItAllData(result) {
  170. scanLedger(result).then(res => {
  171. if ( res[0].rootCategoryLevelId == 4) { // 设备
  172. let isFals = this.objData.equipmentList.some(m => m.code == result)
  173. if (isFals) {
  174. uni.showToast({
  175. title: '设备已存在',
  176. icon: 'none'
  177. })
  178. return false
  179. }
  180. this.objData.equipmentList.push(res[0])
  181. this.$forceUpdate()
  182. }
  183. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  184. if (this.objData.modelList.length == 0) {
  185. this.objData.modelList = res
  186. this.$forceUpdate()
  187. } else {
  188. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  189. uni.showToast({
  190. title: '模具不匹配',
  191. icon: 'none'
  192. })
  193. } else {
  194. uni.showToast({
  195. title: '设备匹配成功',
  196. icon: 'none'
  197. })
  198. }
  199. }
  200. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  201. let isFals = this.objData.turnover.some(m => m.code == result)
  202. if (isFals) {
  203. uni.showToast({
  204. title: '周转车已存在',
  205. icon: 'none'
  206. })
  207. return false
  208. }
  209. this.objData.turnover.push(res[0])
  210. this.$forceUpdate()
  211. }
  212. })
  213. },
  214. handleScan(id, type) {
  215. let _this = this
  216. uni.scanCode({
  217. success: function(res) {
  218. _this.scanData(res.result, type, id)
  219. }
  220. })
  221. },
  222. scanData(result, type, id) {
  223. if (type == 'wordOrder') {
  224. getByCodeReport(result, this.taskId).then(res => {
  225. this.objData = res
  226. if (!this.objData.hasOwnProperty('turnover')) {
  227. this.objData['turnover'] = []
  228. }
  229. if (!this.objData.hasOwnProperty('aridRegionList')) {
  230. this.objData['aridRegionList'] = []
  231. }
  232. })
  233. } else if (type == 'turnover') {
  234. let isFals = this.objData.turnover.some(m => m.code == result)
  235. if (isFals) {
  236. uni.showToast({
  237. title: '周转车已存在',
  238. icon: 'none'
  239. })
  240. return false
  241. }
  242. getByCodeReport(result, this.taskId).then(res => {
  243. this.objData.turnover[id] = res
  244. })
  245. }
  246. },
  247. getList() {
  248. this.isLoad = false
  249. getByIdReport(this.id, this.taskId).then(res => {
  250. console.log('11', res)
  251. this.objData = res
  252. if (!this.objData.hasOwnProperty('turnover')) {
  253. this.objData['turnover'] = []
  254. }
  255. if (!this.objData.hasOwnProperty('aridRegionList')) {
  256. this.objData['aridRegionList'] = []
  257. }
  258. if (!this.objData.hasOwnProperty('instanceList')) {
  259. this.objData['instanceList'] = []
  260. }
  261. // this.taskType = res.currentTaskDiagram.type
  262. this.objData.palletList = [{
  263. categoryLevelId: '',
  264. categoryLevelName: '',
  265. categoryId: '',
  266. rootCategoryLevelId: '',
  267. code: '',
  268. name: '',
  269. specification: '',
  270. brandNum: '',
  271. modelType: '',
  272. quantity: '',
  273. unit: ''
  274. }]
  275. this.objData.workReportInfo = {
  276. formingNum: null,
  277. formingWeight: null,
  278. formedNum: null,
  279. formedWeight: null,
  280. taskId: this.taskId
  281. }
  282. this.objData.notFormedList = [{
  283. notFormedNum: null,
  284. notFormedWeight: null,
  285. weightUnit: res.weightUnit,
  286. unit: res.unit,
  287. warehouseId: null, // 处置 仓库id
  288. }]
  289. if (this.objData.instanceList.length > 0) { // 预制体报工
  290. this.objData.workReportInfo.formedNum = this.objData.instanceList.length
  291. }
  292. this.objData.workReportInfo.formingNum = res.formingNum
  293. this.objData.workReportInfo.formingWeight = res.formingWeight
  294. this.objData.workReportInfo.unit = res.unit
  295. this.objData.workReportInfo.weightUnit = res.weightUnit
  296. this.objData.workReportInfo.workOrderId = res.workOrderId
  297. this.paramDetailList = []
  298. this.paramDetailList = res.paramDetailList.map(m => {
  299. if (m.extInfo.textType == 5) {
  300. this.remainingTime = m.extInfo.remainingTime
  301. }
  302. return {
  303. ...m.extInfo
  304. }
  305. })
  306. }).finally(() => {
  307. this.isLoad = true
  308. })
  309. },
  310. scrolltolower() {},
  311. handAdd() {
  312. const storageKey = Date.now() + "";
  313. uni.setStorageSync(storageKey, this.objData || {});
  314. uni.navigateTo({
  315. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  316. })
  317. },
  318. penalize(index) {
  319. if (index || index == 0) {
  320. this.penalizeIndex = index
  321. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  322. } else {
  323. this.penalizeIndex = null
  324. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  325. }
  326. this.$forceUpdate()
  327. if (this.warehouseList.length == 0) {
  328. getWarehouseList().then(res => {
  329. this.warehouseList = res
  330. this.searchShow = true
  331. })
  332. } else {
  333. this.searchShow = true
  334. }
  335. },
  336. inputChange(e) {
  337. console.log(e)
  338. },
  339. searchCancel() {
  340. this.searchShow = false
  341. },
  342. popupOk() {
  343. if (this.penalizeIndex == null) {
  344. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  345. } else {
  346. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  347. }
  348. this.$forceUpdate()
  349. this.searchShow = false
  350. },
  351. modeNum(num) {
  352. if (this.objData.modelList.length == 0) {
  353. return false
  354. }
  355. this.$refs.modelRef.setNum(num)
  356. },
  357. async save() {
  358. uni.showLoading({
  359. title: '加载中'
  360. });
  361. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  362. uni.showToast({
  363. title: '请输入合格品数量',
  364. icon: 'none'
  365. })
  366. return false
  367. }
  368. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  369. // uni.showToast({
  370. // title: '请输入合格品重量',
  371. // icon: 'none'
  372. // })
  373. // return false
  374. // }
  375. // if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  376. // uni.showToast({
  377. // title: '请点击不合格品处置,选择仓库',
  378. // icon: 'none'
  379. // })
  380. // return false
  381. // }
  382. // 预制体
  383. if (this.objData.instanceList.length > 0 && this.taskType != 4) {
  384. let bol
  385. let _i
  386. bol = this.objData.instanceList.every((e, i) => {
  387. _i = i + 1
  388. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  389. })
  390. if (!bol) {
  391. uni.showToast({
  392. title: `请完善第${_i}处置方式`,
  393. icon: 'none'
  394. })
  395. return false
  396. }
  397. }
  398. if (this.objData.productRecycleList.length > 0) { // 副产品
  399. // let bol
  400. // bol = this.objData.productRecycleList.every(e => {
  401. // return e.recycleQuantity >= 0 && e.warehouseId
  402. // })
  403. const isRecycle = await this.checkRecycle()
  404. if (!isRecycle) {
  405. return false
  406. }
  407. }
  408. if (this.taskType == 4) {
  409. const isPack = await this.checkPack()
  410. if (!isPack) {
  411. return false
  412. }
  413. }
  414. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 1是 判断是否首工序
  415. const isFirstTask = await this.checkFirstTask()
  416. if (!isFirstTask) {
  417. return false
  418. }
  419. }
  420. jobSave(this.objData).then(res => {
  421. uni.hideLoading();
  422. if (this.taskType == 4) {
  423. uni.showModal({
  424. title: '提示',
  425. content: '打包完成是否去入库!',
  426. confirmText: '确认', //这块是确定按钮的文字
  427. success: rr => {
  428. if (rr.confirm) {
  429. uni.navigateTo({
  430. url: `/pages/pda/warehousing/index?workOrderId=${this.id}&taskId=${this.taskId}&workReportId=${res}`
  431. })
  432. } else {
  433. uni.navigateBack()
  434. }
  435. }
  436. })
  437. } else {
  438. uni.navigateBack()
  439. }
  440. }).finally(() => {
  441. setTimeout(function() {
  442. uni.hideLoading();
  443. }, 3000);
  444. })
  445. },
  446. checkRecycle() {
  447. uni.hideLoading();
  448. return new Promise((resolve) => {
  449. uni.showModal({
  450. title: '提示',
  451. content: '是否跳过副产品回收处置!',
  452. confirmText: '确认', //这块是确定按钮的文字
  453. success: function(res) {
  454. if (res.confirm) {
  455. resolve(true)
  456. } else {
  457. resolve(false)
  458. }
  459. }
  460. })
  461. })
  462. },
  463. checkPack() {
  464. uni.hideLoading();
  465. return new Promise((resolve) => {
  466. let packInfo = this.$refs.packRef.getData()
  467. this.objData.packInfo = packInfo
  468. this.objData.taskType = this.taskType
  469. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  470. .objData
  471. .notFormedList[0].notFormedNum)) {
  472. uni.hideLoading();
  473. uni.showModal({
  474. title: '提示',
  475. content: '合格品数量加不合格品数量不等于包装总数!',
  476. confirmText: '确认', //这块是确定按钮的文字
  477. success: function(res) {
  478. if (res.confirm) {
  479. resolve(true)
  480. } else {
  481. resolve(false)
  482. }
  483. }
  484. })
  485. } else {
  486. resolve(true)
  487. }
  488. })
  489. },
  490. checkFirstTask() {
  491. uni.hideLoading();
  492. return new Promise((resolve) => {
  493. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(
  494. this.objData.notFormedList[0].notFormedNum)) {
  495. uni.showModal({
  496. title: '提示',
  497. content: '合格品数量加不合格品数量不等于上道工序数量!',
  498. confirmText: '确认', //这块是确定按钮的文字
  499. success: function(res) {
  500. if (res.confirm) {
  501. resolve(true)
  502. } else {
  503. resolve(false)
  504. }
  505. }
  506. })
  507. } else {
  508. resolve(true)
  509. }
  510. })
  511. },
  512. }
  513. }
  514. </script>
  515. <style lang="scss" scoped>
  516. .content-box {
  517. height: 100vh;
  518. overflow: hidden;
  519. display: flex;
  520. flex-direction: column;
  521. }
  522. .list_box {
  523. flex: 1;
  524. overflow: hidden;
  525. padding: 4rpx 0;
  526. .u-list {
  527. height: 100% !important;
  528. }
  529. .card_box {
  530. padding: 16rpx 20rpx;
  531. }
  532. }
  533. .bottom-wrapper {
  534. .btn_box {
  535. width: 750rpx;
  536. height: 88rpx;
  537. line-height: 88rpx;
  538. background: $theme-color;
  539. text-align: center;
  540. font-size: 36rpx;
  541. font-style: normal;
  542. font-weight: 400;
  543. color: #fff;
  544. }
  545. }
  546. .operate_box {
  547. padding: 10rpx 160rpx;
  548. /deep/ .u-button {
  549. width: 160rpx;
  550. }
  551. }
  552. .search_list {
  553. min-height: 500rpx;
  554. padding: 0 32rpx;
  555. }
  556. </style>