index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  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 v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType != 4 && taskType != 6'
  25. :item='objData' :list='objData.semiProductList'
  26. ></semiProductJobBom>
  27. <oneJobQualityBom
  28. v-if='objData.instanceList && objData.instanceList.length != 0 && taskType ==6 && clientEnvironmentId == 3'
  29. :item='objData' :list='objData.instanceList'></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'></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>
  47. </u-list>
  48. </view>
  49. <view class="bottom-wrapper">
  50. <view class="btn_box" @click="save">一键报工</view>
  51. </view>
  52. <SearchPopup mode="bottom" v-if='searchShow'>
  53. <template v-slot:list>
  54. <view class="search_list">
  55. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  56. <u-form-item label="仓库:" class="required-form" borderBottom prop="warehouseId">
  57. <zxz-uni-data-select :localdata="warehouseList" v-model="formData.warehouseId"
  58. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  59. </u-form-item>
  60. </u-form>
  61. </view>
  62. </template>
  63. <template v-slot:operate>
  64. <view class="operate_box rx-bc">
  65. <u-button size="small" class="u-reset-button" @click="searchCancel">
  66. 取消
  67. </u-button>
  68. <u-button type="success" size="small" class="u-reset-button" @click="popupOk">
  69. 确定
  70. </u-button>
  71. </view>
  72. </template>
  73. </SearchPopup>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. getByIdReport,
  79. getByCodeReport,
  80. jobSave
  81. } from '@/api/pda/jobBooking.js'
  82. import {
  83. scanLedger,
  84. getWarehouseList,
  85. } from '@/api/pda/workOrder.js'
  86. import workOrderBom from '../../feeding/components/workOrderBom.vue'
  87. import deviceBom from '../../feeding/components/deviceBom.vue'
  88. import modelBom from '../../feeding/components/modelBom.vue'
  89. import jobBom from '../components/jobBom.vue'
  90. import palletBom from '../components/palletBom.vue'
  91. import oneJobBom from '../components/oneJobBom.vue'
  92. import semiProductJobBom from '../components/semiProductJobBom.vue'
  93. import byProductBom from '../components/byProductBom'
  94. import turnoverBom from '../components/turnoverBom.vue'
  95. import aridRegion from '../../feeding/components/aridRegion.vue'
  96. import paramBom from '../../feeding/components/paramBom.vue'
  97. import packingBom from '../components/packingBom.vue'
  98. import packingTgBom from '../components/packingTgBom'
  99. import revolvingDiskBom from '../../feeding/components/revolvingDiskBom.vue'
  100. import SearchPopup from '../../components/searchPopup.vue'
  101. import oneJobQualityBom from '../components/oneJobQualityBom.vue'
  102. export default {
  103. components: {
  104. workOrderBom,
  105. deviceBom,
  106. modelBom,
  107. jobBom,
  108. palletBom,
  109. oneJobBom,
  110. semiProductJobBom,
  111. byProductBom,
  112. turnoverBom,
  113. aridRegion,
  114. paramBom,
  115. packingBom,
  116. packingTgBom,
  117. revolvingDiskBom,
  118. SearchPopup,
  119. oneJobQualityBom
  120. },
  121. data() {
  122. return {
  123. title: '',
  124. taskType: 1,
  125. isLoad: true,
  126. objData: {
  127. equipmentList: [],
  128. modelList: [],
  129. turnover: [],
  130. productRecycleList: [],
  131. aridRegionList: [],
  132. palletList: [],
  133. workReportInfo: {
  134. },
  135. notFormedList: [], // 报工-不合格
  136. },
  137. searchShow: false,
  138. warehouseList: [],
  139. formData: {
  140. warehouseId: ''
  141. },
  142. penalizeIndex: null,
  143. paramDetailList: [],
  144. remainingTime: 0,
  145. id: null,
  146. taskId: null,
  147. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  148. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  149. }
  150. },
  151. onLoad(options) {
  152. this.title = options.taskName ? options.taskName + '-报工' : '报工'
  153. this.taskType = options.taskType
  154. this.id = options.id
  155. this.taskId = options.taskId
  156. this.getList()
  157. },
  158. onShow() {
  159. uni.$off("setSelectList");
  160. uni.$on("setSelectList", (selectList, id) => {
  161. let turnover = []
  162. let equipmentList = [] // 生产设备
  163. let isEquipment = this.objData.equipmentList.length > 0 ? true : false // 判断是否有设置
  164. selectList.forEach(f => {
  165. if (f.rootCategoryLevelId == 4) { // 生产设备
  166. if (isEquipment) {
  167. equipmentList = this.objData.equipmentList
  168. } else {
  169. equipmentList = equipmentList.concat(f)
  170. }
  171. }
  172. if (f.rootCategoryLevelId == 7) { // 周转车
  173. turnover = turnover.concat(f)
  174. }
  175. })
  176. this.$set(this.objData, 'equipmentList', equipmentList)
  177. this.$set(this.objData, 'turnover', turnover)
  178. this.$forceUpdate()
  179. });
  180. },
  181. methods: {
  182. // 相机扫码
  183. HandlScanCode() {
  184. let _this = this
  185. uni.scanCode({
  186. success: function(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. let _this = this
  238. uni.scanCode({
  239. success: function(res) {
  240. _this.scanData(res.result, type, id)
  241. }
  242. })
  243. },
  244. scanData(result, type, id) {
  245. if (type == 'wordOrder') {
  246. getByCodeReport(result, this.taskId).then(res => {
  247. this.objData = res
  248. if (!this.objData.hasOwnProperty('turnover')) {
  249. this.objData['turnover'] = []
  250. }
  251. if (!this.objData.hasOwnProperty('aridRegionList')) {
  252. this.objData['aridRegionList'] = []
  253. }
  254. })
  255. } else if (type == 'turnover') {
  256. let isFals = this.objData.turnover.some(m => m.code == result)
  257. if (isFals) {
  258. uni.showToast({
  259. title: '周转车已存在',
  260. icon: 'none'
  261. })
  262. return false
  263. }
  264. getByCodeReport(result, this.taskId).then(res => {
  265. this.objData.turnover[id] = res
  266. })
  267. }
  268. },
  269. getList() {
  270. this.isLoad = false
  271. getByIdReport(this.id, this.taskId).then(res => {
  272. this.objData = res
  273. if (!this.objData.hasOwnProperty('turnover')) {
  274. this.objData['turnover'] = []
  275. }
  276. if (!this.objData.hasOwnProperty('aridRegionList')) {
  277. this.objData['aridRegionList'] = []
  278. }
  279. if (!this.objData.hasOwnProperty('instanceList')) {
  280. this.objData['instanceList'] = []
  281. }
  282. if (!this.objData.hasOwnProperty('palletList')) {
  283. this.objData['palletList'] = []
  284. }
  285. if (!this.objData.hasOwnProperty('revolvingDiskList')) {
  286. this.objData['revolvingDiskList'] = []
  287. }
  288. // this.taskType = res.currentTaskDiagram.type
  289. if (this.objData.palletList.length > 0) {
  290. this.objData.palletList = this.objData.palletList.map(m => {
  291. return {
  292. hideKc: true, // 不显示库存
  293. quantity: m.feedQuantity,
  294. ...m
  295. }
  296. })
  297. } else {
  298. // this.objData.palletList = [{
  299. // categoryLevelId: '',
  300. // categoryLevelName: '',
  301. // categoryId: '',
  302. // rootCategoryLevelId: '',
  303. // code: '',
  304. // name: '',
  305. // specification: '',
  306. // brandNum: '',
  307. // modelType: '',
  308. // quantity: '',
  309. // unit: '',
  310. // }]
  311. }
  312. if (this.taskType == 6 && this.clientEnvironmentId == 3) {
  313. this.objData.instanceList = this.objData.pickOutInList
  314. }
  315. this.objData.workReportInfo = {
  316. formingNum: null,
  317. formingWeight: null,
  318. formedNum: null,
  319. formedWeight: null,
  320. taskId: this.taskId
  321. }
  322. this.objData.notFormedList = [{
  323. notFormedNum: null,
  324. notFormedWeight: null,
  325. weightUnit: res.weightUnit,
  326. unit: res.unit,
  327. warehouseId: null, // 处置 仓库id
  328. }]
  329. if (this.objData.instanceList.length > 0) { // 预制体报工
  330. this.objData.workReportInfo.formedNum = this.objData.instanceList.length
  331. }
  332. this.objData.workReportInfo.formingNum = res.formingNum
  333. this.objData.workReportInfo.formingWeight = res.formingWeight
  334. this.objData.workReportInfo.unit = res.unit
  335. this.objData.workReportInfo.weightUnit = res.weightUnit
  336. this.objData.workReportInfo.workOrderId = res.workOrderId
  337. this.paramDetailList = []
  338. this.paramDetailList = res.paramDetailList.map(m => {
  339. if (m.extInfo.textType == 5) {
  340. this.remainingTime = m.extInfo.remainingTime
  341. }
  342. return {
  343. ...m.extInfo
  344. }
  345. })
  346. }).finally(() => {
  347. this.isLoad = true
  348. })
  349. },
  350. scrolltolower() {},
  351. handAdd() {
  352. const storageKey = Date.now() + "";
  353. uni.setStorageSync(storageKey, this.objData || {});
  354. uni.navigateTo({
  355. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  356. })
  357. },
  358. penalize(index) {
  359. if (index || index == 0) {
  360. this.penalizeIndex = index
  361. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  362. } else {
  363. this.penalizeIndex = null
  364. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  365. }
  366. this.$forceUpdate()
  367. if (this.warehouseList.length == 0) {
  368. getWarehouseList().then(res => {
  369. this.warehouseList = res
  370. this.searchShow = true
  371. })
  372. } else {
  373. this.searchShow = true
  374. }
  375. },
  376. inputChange(e) {
  377. console.log(e)
  378. },
  379. searchCancel() {
  380. this.searchShow = false
  381. },
  382. popupOk() {
  383. if (this.penalizeIndex == null) {
  384. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  385. } else {
  386. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  387. }
  388. this.$forceUpdate()
  389. this.searchShow = false
  390. },
  391. modeNum(num) {
  392. if (this.objData.modelList.length == 0) {
  393. return false
  394. }
  395. this.$refs.modelRef.setNum(num)
  396. },
  397. async save() {
  398. uni.showLoading({
  399. title: '加载中'
  400. });
  401. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  402. uni.showToast({
  403. title: '请输入合格品数量',
  404. icon: 'none'
  405. })
  406. return false
  407. }
  408. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  409. // uni.showToast({
  410. // title: '请输入合格品重量',
  411. // icon: 'none'
  412. // })
  413. // return false
  414. // }
  415. // if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  416. // uni.showToast({
  417. // title: '请点击不合格品处置,选择仓库',
  418. // icon: 'none'
  419. // })
  420. // return false
  421. // }
  422. // 预制体
  423. if (this.objData.instanceList.length > 0 && this.taskType != 4) {
  424. let bol
  425. let _i
  426. bol = this.objData.instanceList.every((e, i) => {
  427. _i = i + 1
  428. if (this.taskType == 6) {
  429. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  430. } else {
  431. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId && e.extInfo.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=${this.taskId}&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>