index.vue 17 KB

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