index.vue 16 KB

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