index.vue 18 KB

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