index.vue 18 KB

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