index.vue 18 KB

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