index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  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. let _this = this
  186. uni.scanCode({
  187. success: function(res) {
  188. _this.scanItAllData(res.result)
  189. }
  190. })
  191. },
  192. scanItAllData(result) {
  193. scanLedger(result).then(res => {
  194. if (res[0].rootCategoryLevelId == 4) { // 设备
  195. let isFals = this.objData.equipmentList.some(m => m.code == result)
  196. if (isFals) {
  197. uni.showToast({
  198. title: '设备已存在',
  199. icon: 'none'
  200. })
  201. return false
  202. }
  203. this.objData.equipmentList.push(res[0])
  204. this.$forceUpdate()
  205. }
  206. if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 磨具
  207. if (this.objData.modelList.length == 0) {
  208. this.objData.modelList = res
  209. this.$forceUpdate()
  210. } else {
  211. if (this.objData.modelList[0].instanceId != res[0].instanceId) {
  212. uni.showToast({
  213. title: '模具不匹配',
  214. icon: 'none'
  215. })
  216. } else {
  217. uni.showToast({
  218. title: '设备匹配成功',
  219. icon: 'none'
  220. })
  221. }
  222. }
  223. } else if (res.length == 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  224. let isFals = this.objData.turnover.some(m => m.code == result)
  225. if (isFals) {
  226. uni.showToast({
  227. title: '周转车已存在',
  228. icon: 'none'
  229. })
  230. return false
  231. }
  232. this.objData.turnover.push(res[0])
  233. this.$forceUpdate()
  234. }
  235. })
  236. },
  237. handleScan(id, type) {
  238. let _this = this
  239. uni.scanCode({
  240. success: function(res) {
  241. _this.scanData(res.result, type, id)
  242. }
  243. })
  244. },
  245. scanData(result, type, id) {
  246. if (type == 'wordOrder') {
  247. getByCodeReport(result, this.taskId).then(res => {
  248. this.objData = res
  249. if (!this.objData.hasOwnProperty('turnover')) {
  250. this.objData['turnover'] = []
  251. }
  252. if (!this.objData.hasOwnProperty('aridRegionList')) {
  253. this.objData['aridRegionList'] = []
  254. }
  255. })
  256. } else if (type == 'turnover') {
  257. let isFals = this.objData.turnover.some(m => m.code == result)
  258. if (isFals) {
  259. uni.showToast({
  260. title: '周转车已存在',
  261. icon: 'none'
  262. })
  263. return false
  264. }
  265. getByCodeReport(result, this.taskId).then(res => {
  266. this.objData.turnover[id] = res
  267. })
  268. }
  269. },
  270. getList() {
  271. this.isLoad = false
  272. getByIdReport(this.id, this.taskId).then(res => {
  273. this.objData = res
  274. if (!this.objData.hasOwnProperty('turnover')) {
  275. this.objData['turnover'] = []
  276. }
  277. if (!this.objData.hasOwnProperty('aridRegionList')) {
  278. this.objData['aridRegionList'] = []
  279. }
  280. if (!this.objData.hasOwnProperty('instanceList')) {
  281. this.objData['instanceList'] = []
  282. }
  283. if (!this.objData.hasOwnProperty('palletList')) {
  284. this.objData['palletList'] = []
  285. }
  286. if (!this.objData.hasOwnProperty('revolvingDiskList')) {
  287. this.objData['revolvingDiskList'] = []
  288. }
  289. // this.taskType = res.currentTaskDiagram.type
  290. if (this.objData.palletList.length > 0) {
  291. this.objData.palletList = this.objData.palletList.map(m => {
  292. return {
  293. hideKc: true, // 不显示库存
  294. quantity: m.feedQuantity,
  295. ...m
  296. }
  297. })
  298. } else {
  299. // this.objData.palletList = [{
  300. // categoryLevelId: '',
  301. // categoryLevelName: '',
  302. // categoryId: '',
  303. // rootCategoryLevelId: '',
  304. // code: '',
  305. // name: '',
  306. // specification: '',
  307. // brandNum: '',
  308. // modelType: '',
  309. // quantity: '',
  310. // unit: '',
  311. // }]
  312. }
  313. if (this.taskType == 6 && this.clientEnvironmentId == 3) {
  314. this.objData.semiProductList = this.objData.pickOutInList
  315. }
  316. this.objData.workReportInfo = {
  317. formingNum: null,
  318. formingWeight: null,
  319. formedNum: null,
  320. formedWeight: null,
  321. taskId: this.taskId
  322. }
  323. this.objData.notFormedList = [{
  324. notFormedNum: null,
  325. notFormedWeight: null,
  326. weightUnit: res.weightUnit,
  327. unit: res.unit,
  328. warehouseId: null, // 处置 仓库id
  329. }]
  330. if (this.objData.semiProductList.length > 0) { // 预制体报工
  331. this.objData.workReportInfo.formedNum = this.objData.semiProductList.length
  332. }
  333. this.objData.workReportInfo.formingNum = res.formingNum
  334. this.objData.workReportInfo.formingWeight = res.formingWeight
  335. this.objData.workReportInfo.unit = res.unit
  336. this.objData.workReportInfo.weightUnit = res.weightUnit
  337. this.objData.workReportInfo.workOrderId = res.workOrderId
  338. this.paramDetailList = []
  339. this.paramDetailList = res.paramDetailList.map(m => {
  340. if (m.extInfo.textType == 5) {
  341. this.remainingTime = m.extInfo.remainingTime
  342. }
  343. return {
  344. ...m.extInfo
  345. }
  346. })
  347. }).finally(() => {
  348. this.isLoad = true
  349. })
  350. },
  351. scrolltolower() {},
  352. handAdd() {
  353. const storageKey = Date.now() + "";
  354. uni.setStorageSync(storageKey, this.objData || {});
  355. uni.navigateTo({
  356. url: `/pages/pda/workOrder/search/index?storageKey=${storageKey}&isType=job&taskId=${this.taskId}`
  357. })
  358. },
  359. penalize(index) {
  360. if (index || index == 0) {
  361. this.penalizeIndex = index
  362. this.formData.warehouseId = this.objData.productRecycleList[this.penalizeIndex].warehouseId || ''
  363. } else {
  364. this.penalizeIndex = null
  365. this.formData.warehouseId = this.objData.notFormedList[0].warehouseId || ''
  366. }
  367. this.$forceUpdate()
  368. if (this.warehouseList.length == 0) {
  369. getWarehouseList().then(res => {
  370. this.warehouseList = res
  371. this.searchShow = true
  372. })
  373. } else {
  374. this.searchShow = true
  375. }
  376. },
  377. inputChange(e) {
  378. console.log(e)
  379. },
  380. searchCancel() {
  381. this.searchShow = false
  382. },
  383. popupOk() {
  384. if (this.penalizeIndex == null) {
  385. this.$set(this.objData.notFormedList[0], 'warehouseId', this.formData.warehouseId || null)
  386. } else {
  387. this.objData.productRecycleList[this.penalizeIndex].warehouseId = this.formData.warehouseId
  388. }
  389. this.$forceUpdate()
  390. this.searchShow = false
  391. },
  392. modeNum(num) {
  393. if (this.objData.modelList.length == 0) {
  394. return false
  395. }
  396. this.$refs.modelRef.setNum(num)
  397. },
  398. async save() {
  399. uni.showLoading({
  400. title: '加载中'
  401. });
  402. if (!this.objData.workReportInfo['formedNum'] && this.objData.workReportInfo['formedNum'] != 0) {
  403. uni.showToast({
  404. title: '请输入合格品数量',
  405. icon: 'none'
  406. })
  407. return false
  408. }
  409. // if (!this.objData.workReportInfo['formedWeight'] && this.objData.workReportInfo['formedWeight'] != 0) {
  410. // uni.showToast({
  411. // title: '请输入合格品重量',
  412. // icon: 'none'
  413. // })
  414. // return false
  415. // }
  416. // if (this.objData.notFormedList[0].notFormedNum > 0 && !this.objData.notFormedList[0].warehouseId) {
  417. // uni.showToast({
  418. // title: '请点击不合格品处置,选择仓库',
  419. // icon: 'none'
  420. // })
  421. // return false
  422. // }
  423. // 预制体
  424. if (this.objData.instanceList.length > 0 && this.taskType != 4) {
  425. let bol
  426. let _i
  427. bol = this.objData.instanceList.every((e, i) => {
  428. _i = i + 1
  429. if (this.taskType == 6) {
  430. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId
  431. } else {
  432. return e.extInfo.hasOwnProperty('taskId') && e.extInfo.taskId && e.extInfo
  433. .reportWeight
  434. }
  435. })
  436. if (!bol) {
  437. uni.showToast({
  438. title: `请完善第${_i}处置方式`,
  439. icon: 'none'
  440. })
  441. return false
  442. }
  443. }
  444. if (this.objData.productRecycleList.length > 0) { // 副产品
  445. // let bol
  446. // bol = this.objData.productRecycleList.every(e => {
  447. // return e.recycleQuantity >= 0 && e.warehouseId
  448. // })
  449. const isRecycle = await this.checkRecycle()
  450. if (!isRecycle) {
  451. return false
  452. }
  453. }
  454. if (this.taskType == 4 && this.clientEnvironmentId != 3) {
  455. const isPack = await this.checkPack()
  456. if (!isPack) {
  457. return false
  458. }
  459. }
  460. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 1是 判断是否首工序
  461. const isFirstTask = await this.checkFirstTask()
  462. if (!isFirstTask) {
  463. return false
  464. }
  465. }
  466. jobSave(this.objData).then(res => {
  467. uni.hideLoading();
  468. if (this.taskType == 4) {
  469. uni.showModal({
  470. title: '提示',
  471. content: '打包完成是否去入库!',
  472. confirmText: '确认', //这块是确定按钮的文字
  473. success: rr => {
  474. if (rr.confirm) {
  475. uni.navigateTo({
  476. url: `/pages/pda/warehousing/index?workOrderId=${this.id}&taskId=-1&workReportId=${res}`
  477. })
  478. } else {
  479. uni.navigateBack()
  480. }
  481. }
  482. })
  483. } else {
  484. uni.navigateBack()
  485. }
  486. }).finally(() => {
  487. setTimeout(function() {
  488. uni.hideLoading();
  489. }, 3000);
  490. })
  491. },
  492. checkRecycle() {
  493. uni.hideLoading();
  494. return new Promise((resolve) => {
  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. })
  508. },
  509. checkPack() {
  510. uni.hideLoading();
  511. return new Promise((resolve) => {
  512. let packInfo = this.$refs.packRef.getData()
  513. this.objData.packInfo = packInfo
  514. this.objData.taskType = this.taskType
  515. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  516. .objData
  517. .notFormedList[0].notFormedNum)) {
  518. uni.hideLoading();
  519. uni.showModal({
  520. title: '提示',
  521. content: '合格品数量加不合格品数量不等于包装总数!',
  522. confirmText: '确认', //这块是确定按钮的文字
  523. success: function(res) {
  524. if (res.confirm) {
  525. resolve(true)
  526. } else {
  527. resolve(false)
  528. }
  529. }
  530. })
  531. } else {
  532. resolve(true)
  533. }
  534. })
  535. },
  536. checkFirstTask() {
  537. uni.hideLoading();
  538. return new Promise((resolve) => {
  539. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(
  540. this.objData.notFormedList[0].notFormedNum)) {
  541. uni.showModal({
  542. title: '提示',
  543. content: '合格品数量加不合格品数量不等于上道工序数量!',
  544. confirmText: '确认', //这块是确定按钮的文字
  545. success: function(res) {
  546. if (res.confirm) {
  547. resolve(true)
  548. } else {
  549. resolve(false)
  550. }
  551. }
  552. })
  553. } else {
  554. resolve(true)
  555. }
  556. })
  557. },
  558. }
  559. }
  560. </script>
  561. <style lang="scss" scoped>
  562. .content-box {
  563. height: 100vh;
  564. overflow: hidden;
  565. display: flex;
  566. flex-direction: column;
  567. }
  568. .list_box {
  569. flex: 1;
  570. overflow: hidden;
  571. padding: 4rpx 0;
  572. .u-list {
  573. height: 100% !important;
  574. }
  575. .card_box {
  576. padding: 16rpx 20rpx;
  577. }
  578. }
  579. .bottom-wrapper {
  580. .btn_box {
  581. width: 750rpx;
  582. height: 88rpx;
  583. line-height: 88rpx;
  584. background: $theme-color;
  585. text-align: center;
  586. font-size: 36rpx;
  587. font-style: normal;
  588. font-weight: 400;
  589. color: #fff;
  590. }
  591. }
  592. .operate_box {
  593. padding: 10rpx 160rpx;
  594. /deep/ .u-button {
  595. width: 160rpx;
  596. }
  597. }
  598. .search_list {
  599. min-height: 500rpx;
  600. padding: 0 32rpx;
  601. }
  602. </style>