index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  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' :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>
  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. console.log(22,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.instanceList = 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.instanceList.length > 0) { // 预制体报工
  331. this.objData.workReportInfo.formedNum = this.objData.instanceList.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.reportWeight
  433. }
  434. })
  435. if (!bol) {
  436. uni.showToast({
  437. title: `请完善第${_i}处置方式`,
  438. icon: 'none'
  439. })
  440. return false
  441. }
  442. }
  443. if (this.objData.productRecycleList.length > 0) { // 副产品
  444. // let bol
  445. // bol = this.objData.productRecycleList.every(e => {
  446. // return e.recycleQuantity >= 0 && e.warehouseId
  447. // })
  448. const isRecycle = await this.checkRecycle()
  449. if (!isRecycle) {
  450. return false
  451. }
  452. }
  453. if (this.taskType == 4 && this.clientEnvironmentId != 3) {
  454. const isPack = await this.checkPack()
  455. if (!isPack) {
  456. return false
  457. }
  458. }
  459. if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask 1是 判断是否首工序
  460. const isFirstTask = await this.checkFirstTask()
  461. if (!isFirstTask) {
  462. return false
  463. }
  464. }
  465. jobSave(this.objData).then(res => {
  466. uni.hideLoading();
  467. if (this.taskType == 4) {
  468. uni.showModal({
  469. title: '提示',
  470. content: '打包完成是否去入库!',
  471. confirmText: '确认', //这块是确定按钮的文字
  472. success: rr => {
  473. if (rr.confirm) {
  474. uni.navigateTo({
  475. url: `/pages/pda/warehousing/index?workOrderId=${this.id}&taskId=${this.taskId}&workReportId=${res}`
  476. })
  477. } else {
  478. uni.navigateBack()
  479. }
  480. }
  481. })
  482. } else {
  483. uni.navigateBack()
  484. }
  485. }).finally(() => {
  486. setTimeout(function() {
  487. uni.hideLoading();
  488. }, 3000);
  489. })
  490. },
  491. checkRecycle() {
  492. uni.hideLoading();
  493. return new Promise((resolve) => {
  494. uni.showModal({
  495. title: '提示',
  496. content: '是否跳过副产品回收处置!',
  497. confirmText: '确认', //这块是确定按钮的文字
  498. success: function(res) {
  499. if (res.confirm) {
  500. resolve(true)
  501. } else {
  502. resolve(false)
  503. }
  504. }
  505. })
  506. })
  507. },
  508. checkPack() {
  509. uni.hideLoading();
  510. return new Promise((resolve) => {
  511. let packInfo = this.$refs.packRef.getData()
  512. this.objData.packInfo = packInfo
  513. this.objData.taskType = this.taskType
  514. if (packInfo.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(this
  515. .objData
  516. .notFormedList[0].notFormedNum)) {
  517. uni.hideLoading();
  518. uni.showModal({
  519. title: '提示',
  520. content: '合格品数量加不合格品数量不等于包装总数!',
  521. confirmText: '确认', //这块是确定按钮的文字
  522. success: function(res) {
  523. if (res.confirm) {
  524. resolve(true)
  525. } else {
  526. resolve(false)
  527. }
  528. }
  529. })
  530. } else {
  531. resolve(true)
  532. }
  533. })
  534. },
  535. checkFirstTask() {
  536. uni.hideLoading();
  537. return new Promise((resolve) => {
  538. if (this.objData.formedNumLast != Number(this.objData.workReportInfo['formedNum']) + Number(
  539. this.objData.notFormedList[0].notFormedNum)) {
  540. uni.showModal({
  541. title: '提示',
  542. content: '合格品数量加不合格品数量不等于上道工序数量!',
  543. confirmText: '确认', //这块是确定按钮的文字
  544. success: function(res) {
  545. if (res.confirm) {
  546. resolve(true)
  547. } else {
  548. resolve(false)
  549. }
  550. }
  551. })
  552. } else {
  553. resolve(true)
  554. }
  555. })
  556. },
  557. }
  558. }
  559. </script>
  560. <style lang="scss" scoped>
  561. .content-box {
  562. height: 100vh;
  563. overflow: hidden;
  564. display: flex;
  565. flex-direction: column;
  566. }
  567. .list_box {
  568. flex: 1;
  569. overflow: hidden;
  570. padding: 4rpx 0;
  571. .u-list {
  572. height: 100% !important;
  573. }
  574. .card_box {
  575. padding: 16rpx 20rpx;
  576. }
  577. }
  578. .bottom-wrapper {
  579. .btn_box {
  580. width: 750rpx;
  581. height: 88rpx;
  582. line-height: 88rpx;
  583. background: $theme-color;
  584. text-align: center;
  585. font-size: 36rpx;
  586. font-style: normal;
  587. font-weight: 400;
  588. color: #fff;
  589. }
  590. }
  591. .operate_box {
  592. padding: 10rpx 160rpx;
  593. /deep/ .u-button {
  594. width: 160rpx;
  595. }
  596. }
  597. .search_list {
  598. min-height: 500rpx;
  599. padding: 0 32rpx;
  600. }
  601. </style>