index.vue 16 KB

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