details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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"></uni-nav-bar>
  5. <view class="list_box">
  6. <u-list @scrolltolower="scrolltolower">
  7. <view v-for="(item,index) in List" :key="index" class="card_box">
  8. <workOrderBom :item='item' @handleScan='handleScan'></workOrderBom>
  9. <paramBom v-if='item.paramDetailList.length != 0' :list='item.paramDetailList'></paramBom>
  10. <deviceBom v-if='item.equipmentList.length != 0' :workOrderId='item.workOrderId'
  11. :list='item.equipmentList' @scanIt='scanIt'></deviceBom>
  12. <productsBom v-if="item.product != null && item.product != '{}'" :productsObj="item.product">
  13. </productsBom>
  14. <modelBom v-if='item.modelList.length != 0' :workOrderId='item.workOrderId' :list='item.modelList'
  15. @scanIt='scanIt'>
  16. </modelBom>
  17. <instanceBom v-if='item.instanceList.length != 0' :workOrderId='item.workOrderId'
  18. :list='item.instanceList' :equipmentList="item.equipmentList"
  19. :currentTaskDiagram="item.currentTaskDiagram"></instanceBom>
  20. <semiProductBom v-if='item.semiProductList.length != 0' :workOrderId='item.workOrderId'
  21. :list='item.semiProductList' :equipmentList="item.equipmentList"
  22. :currentTaskDiagram="item.currentTaskDiagram"></semiProductBom>
  23. <turnoverBom v-if='item.turnover.length != 0' :list='item.turnover' :wordItem='item' pattern='feed'
  24. @handleScan='handleScan' @handleDel='handleDel'></turnoverBom>
  25. <aridRegion v-if='item.aridRegionList.length != 0' :list='item.aridRegionList'
  26. @handleScan='handleScan'></aridRegion>
  27. <palletBom v-if='item.palletList.length != 0' :palletList='item.palletList'></palletBom>
  28. <revolvingDiskBom v-if="item.revolvingDiskList.length != 0"
  29. :revolvingDiskList="item.revolvingDiskList"></revolvingDiskBom>
  30. <packingBom v-if='item.packingList.length != 0' :list='item.packingList'></packingBom>
  31. <view class='flex_btn' @click="openDetails(item.workOrderId)">出库单</view>
  32. <view :class="[ idsList.length == 1 ? 'operate_box' :'operate_box2'] ">
  33. <u-button size="small" class="u-reset-button" type="success"
  34. @click="handAdd(item.workOrderId)">手动添加</u-button>
  35. <u-button size="small" class="u-reset-button" type="success"
  36. @click="scanIt(item.workOrderId)">扫一扫</u-button>
  37. </view>
  38. </view>
  39. </u-list>
  40. </view>
  41. <view class="bottom-wrapper">
  42. <view class="btn_box" @click="save(1)">缓存</view>
  43. <view class="btn_box" @click="save(2)">一键投料</view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import workOrderBom from './components/workOrderBom.vue'
  49. import deviceBom from './components/deviceBom.vue'
  50. import modelBom from './components/modelBom.vue'
  51. import instanceBom from './components/instanceBom.vue'
  52. import semiProductBom from './components/semiProductBom'
  53. import aridRegion from './components/aridRegion'
  54. import paramBom from './components/paramBom.vue'
  55. import turnoverBom from './components/turnoverBom.vue'
  56. import packingBom from './components/packingBom.vue'
  57. import productsBom from './components/productsBom.vue'
  58. import palletBom from './components/palletBom'
  59. import revolvingDiskBom from './components/revolvingDiskBom'
  60. import {
  61. workorderList,
  62. getByCode,
  63. scanLedger,
  64. feedSaveCache,
  65. feedGetCache
  66. } from '@/api/pda/workOrder.js'
  67. import {
  68. batchSave
  69. } from '@/api/pda/feeding.js'
  70. export default {
  71. components: {
  72. workOrderBom,
  73. deviceBom,
  74. modelBom,
  75. instanceBom,
  76. semiProductBom,
  77. aridRegion,
  78. paramBom,
  79. turnoverBom,
  80. packingBom,
  81. productsBom,
  82. palletBom,
  83. revolvingDiskBom,
  84. },
  85. data() {
  86. return {
  87. title: '',
  88. idsList: [],
  89. List: [],
  90. taskId: null,
  91. clientEnvironmentId: null,
  92. }
  93. },
  94. onLoad(options) {
  95. this.title = options.taskName ? options.taskName + '-投料' : '投料'
  96. let queryArray = decodeURIComponent(options.arr);
  97. this.idsList = JSON.parse(queryArray);
  98. this.taskId = options.taskId
  99. this.taskName = options.taskName
  100. this.getList()
  101. this.clientEnvironmentId = uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").clientEnvironmentId
  102. },
  103. onShow() {
  104. uni.$off("setSelectList");
  105. uni.$on("setSelectList", (selectList, id) => {
  106. this.List.forEach(m => {
  107. if (m.workOrderId == id) {
  108. let modelList = [] // 模具
  109. let instanceList = [] // 投料
  110. let aridRegionList = [] // 干燥区
  111. let equipmentList = [] // 生产设备
  112. let palletList = [] // 舟皿
  113. let revolvingDiskList = [] // 周转盘
  114. let semiProductList = [] // 半成品
  115. let turnover = [] //周转车
  116. selectList.forEach(f => {
  117. if (f.rootCategoryLevelId == 4) {
  118. equipmentList = equipmentList.concat(f)
  119. }
  120. if (f.rootCategoryLevelId == 5) {
  121. modelList = modelList.concat(f)
  122. } else if (f.rootCategoryLevelId == 1) {
  123. instanceList = instanceList.concat(f)
  124. } else if (f.rootCategoryLevelId == 11) {
  125. aridRegionList = aridRegionList.concat(f)
  126. } else if (f.rootCategoryLevelId == 7) {
  127. turnover = turnover.concat(f)
  128. } else if (f.rootCategoryLevelId == 8) {
  129. palletList = palletList.concat(f)
  130. } else if (f.rootCategoryLevelId == 26) {
  131. revolvingDiskList = revolvingDiskList.concat(f)
  132. } else if ([23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))) {
  133. semiProductList = semiProductList.concat(f)
  134. }
  135. })
  136. this.$set(m, 'modelList', modelList)
  137. this.$set(m, 'instanceList', instanceList)
  138. this.$set(m, 'aridRegionList', aridRegionList)
  139. this.$set(m, 'equipmentList', equipmentList)
  140. this.$set(m, 'turnover', turnover)
  141. this.$set(m, 'palletList', palletList)
  142. this.$set(m, 'revolvingDiskList', revolvingDiskList)
  143. this.$set(m, 'semiProductList', semiProductList)
  144. }
  145. })
  146. });
  147. },
  148. methods: {
  149. scrolltolower() {},
  150. async save(type) {
  151. this.List.forEach(f => {
  152. f.instanceList.forEach(e => {
  153. if (Object.prototype.hasOwnProperty.call(e, 'type')) {
  154. e.extInfo['type'] = e.type
  155. }
  156. e.extInfo['isConsumable'] = e.isConsumable
  157. })
  158. })
  159. const isCache = await this.checkCache(type)
  160. if (!isCache) {
  161. return false
  162. }
  163. batchSave(this.List).then(res => {
  164. uni.redirectTo({
  165. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  166. });
  167. })
  168. },
  169. checkCache(type) {
  170. uni.hideLoading();
  171. return new Promise((resolve) => {
  172. if (type == 1) {
  173. feedSaveCache(this.List).then(rr => {
  174. uni.showToast({
  175. title: `已经缓存`,
  176. icon: 'none'
  177. })
  178. })
  179. resolve(false)
  180. } else if (type == 2) {
  181. resolve(true)
  182. }
  183. })
  184. },
  185. getList() {
  186. workorderList({
  187. ids: this.idsList,
  188. taskId: this.taskId
  189. }).then(res => {
  190. this.List = res.map(m => {
  191. m.workOrderId = m.id
  192. m.instanceList = [] // 物料
  193. m.equipmentList = [] // 设备
  194. m.modelList = [] // 模具
  195. m.aridRegionList = [] // 干燥区
  196. m.packingList = [] // 包装
  197. m.palletList = [] // 舟皿
  198. m.revolvingDiskList = [] // 周转盘
  199. m.semiProductList = [] //半成品
  200. if (m.pickOutInList.length > 0) {
  201. m.pickOutInList.forEach(f => {
  202. if (f.rootCategoryLevelId == 1) {
  203. m.instanceList.push(f)
  204. } else if (f.rootCategoryLevelId == 4) {
  205. m.modelList.push(f)
  206. } else if (f.rootCategoryLevelId == 5) {
  207. m.modelList.push(f)
  208. } else if (f.rootCategoryLevelId == 11) {
  209. m.aridRegionList.push(f)
  210. } else if (f.rootCategoryLevelId == 13) {
  211. m.packingList.push(f)
  212. } else if (f.rootCategoryLevelId == 8) {
  213. m.palletList.push(f)
  214. } else if (f.rootCategoryLevelId == 26) {
  215. m.revolvingDiskList.push(f)
  216. } else if ([23, 2, 9, 28].includes(Number(f.rootCategoryLevelId))) {
  217. m.semiProductList.push(f)
  218. }
  219. })
  220. }
  221. // 处理字段
  222. m.quality == '' ? m.quality = {} : ''
  223. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  224. m.product = '{}'
  225. }
  226. delete m.id
  227. if (this.taskId) {
  228. m.taskId = this.taskId
  229. m.taskName = this.taskName
  230. }
  231. return {
  232. ...m
  233. }
  234. })
  235. }).finally(() => {
  236. this.getCacheFn()
  237. })
  238. },
  239. handleScan(id, type) {
  240. uni.scanCode({
  241. success: (res) => {
  242. this.scanData(res.result, type, id)
  243. }
  244. })
  245. },
  246. scanData(result, type, id) {
  247. if (type == 'wordOrder') {
  248. let isFals = this.List.some(m => m.code == result)
  249. if (isFals) {
  250. uni.showToast({
  251. title: '工单已存在',
  252. icon: 'none'
  253. })
  254. return false
  255. }
  256. getByCode(result).then(res => {
  257. let _arr = this.List
  258. _arr.forEach((e, index) => {
  259. if (e.workOrderId == id && res) {
  260. _arr[index] = res
  261. }
  262. })
  263. this.List = _arr
  264. this.$forceUpdate()
  265. })
  266. }
  267. },
  268. scanIt(id) {
  269. uni.scanCode({
  270. success: (res) => {
  271. this.scanItData(res.result, id)
  272. }
  273. })
  274. },
  275. scanItData(result, id) {
  276. scanLedger(result).then(res => {
  277. let _arr = []
  278. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  279. _arr = this.List
  280. _arr.forEach((e, index) => {
  281. if (e.workOrderId == id) {
  282. _arr[index].equipmentList = _arr[index].equipmentList.concat(res)
  283. }
  284. })
  285. this.List = _arr
  286. this.$forceUpdate()
  287. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  288. _arr = this.List
  289. _arr.forEach((e, index) => {
  290. if (e.workOrderId == id) {
  291. _arr[index].modelList = res
  292. }
  293. })
  294. this.List = _arr
  295. this.$forceUpdate()
  296. } else if (res.length >= 1 && [1].includes(Number(res[0].rootCategoryLevelId))) { // 物料
  297. _arr = this.List
  298. _arr.forEach((e, index) => {
  299. if (e.workOrderId == id) {
  300. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  301. }
  302. })
  303. this.List = _arr
  304. this.$forceUpdate()
  305. } else if (res.length >= 1 && [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))) {
  306. _arr = this.List
  307. _arr.forEach((e, index) => {
  308. if (e.workOrderId == id) {
  309. _arr[index].semiProductList = _arr[index].semiProductList.concat(res)
  310. }
  311. })
  312. this.List = _arr
  313. this.$forceUpdate()
  314. }
  315. else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  316. _arr = this.List
  317. _arr.forEach((e, index) => {
  318. if (e.workOrderId == id) {
  319. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  320. .aridRegionList[0].code)
  321. if (isFals) {
  322. uni.showToast({
  323. title: '干燥区已存在',
  324. icon: 'none'
  325. })
  326. return false
  327. }
  328. let _obj = res[0].aridRegionList[0]
  329. if (_obj.status == 0) {
  330. _obj['name'] = res[0].name
  331. _obj['region'] = res[0].extInfo.region
  332. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  333. .aridRegionList)
  334. } else {
  335. uni.showToast({
  336. title: '干燥区已占用',
  337. icon: 'none'
  338. })
  339. }
  340. }
  341. })
  342. this.List = _arr
  343. this.$forceUpdate()
  344. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  345. _arr = this.List
  346. _arr.forEach((e, index) => {
  347. if (e.workOrderId == id) {
  348. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  349. if (isFals) {
  350. uni.showToast({
  351. title: '周转车已存在',
  352. icon: 'none'
  353. })
  354. return false
  355. }
  356. _arr.forEach((e, index) => {
  357. if (e.workOrderId == id) {
  358. _arr[index].turnover = _arr[index].turnover.concat(res)
  359. }
  360. })
  361. this.List = _arr
  362. this.$forceUpdate()
  363. }
  364. })
  365. }
  366. })
  367. },
  368. // 全部扫一扫
  369. handlScanCode() {
  370. uni.scanCode({
  371. success: (res) => {
  372. this.scanItAllData(res.result)
  373. }
  374. })
  375. },
  376. scanItAllData(result) {
  377. scanLedger(result).then(res => {
  378. let _arr = []
  379. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  380. _arr = this.List
  381. _arr.forEach((e, index) => {
  382. res['extInfo'].fixCode = res.fixCode
  383. e.equipmentList = e.equipmentList.concat(res)
  384. })
  385. this.List = _arr
  386. this.$forceUpdate()
  387. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  388. _arr = this.List
  389. _arr.forEach((e, index) => {
  390. e.modelList = res
  391. })
  392. this.List = _arr
  393. this.$forceUpdate()
  394. } else if (res.length >= 1 && [1].includes(Number(res[0].rootCategoryLevelId))) {
  395. _arr = this.List
  396. _arr.forEach((e, index) => {
  397. e.instanceList = e.instanceList.concat(res)
  398. })
  399. this.List = _arr
  400. this.$forceUpdate()
  401. } else if (res.length >= 1 && [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))) {
  402. _arr = this.List
  403. _arr.forEach((e, index) => {
  404. e.semiProductList = e.semiProductList.concat(res)
  405. })
  406. this.List = _arr
  407. this.$forceUpdate()
  408. }
  409. })
  410. },
  411. getCacheFn() {
  412. let parma = {
  413. workOrderIds: this.idsList,
  414. taskId: this.taskId
  415. }
  416. feedGetCache(parma).then(res => {
  417. if (res.length == 0) {
  418. return false
  419. }
  420. let objList = res[0].extInfo.objList
  421. this.List.forEach(f => {
  422. objList.forEach(o => {
  423. if (f.workOrderId == o.workOrderId && f.taskId == o.taskId) {
  424. f['instanceList'] = o.instanceList || []
  425. f['equipmentList'] = o.equipmentList || []
  426. f['modelList'] = o.modelList || []
  427. f['aridRegionList'] = o.aridRegionList || []
  428. f['packingList'] = o.packingList || []
  429. f['palletList'] = o.palletList || []
  430. f['instanceList'] = o.instanceList || []
  431. f['revolvingDiskList'] = o.revolvingDiskList || []
  432. f['semiProductList'] = o.semiProductList || []
  433. this.$forceUpdate()
  434. }
  435. })
  436. })
  437. })
  438. },
  439. handAdd(id) {
  440. const storageKey = Date.now() + "";
  441. uni.setStorageSync(storageKey, this.List || []);
  442. uni.navigateTo({
  443. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  444. })
  445. },
  446. openDetails(id) {
  447. const storageKey = Date.now() + "";
  448. uni.setStorageSync(storageKey, this.List || []);
  449. let url = `/pages/pda/feeding/single?id=${id}&taskId=${this.taskId}&storageKey=${storageKey}`
  450. uni.navigateTo({
  451. url
  452. })
  453. },
  454. },
  455. }
  456. </script>
  457. <style lang="scss" scoped>
  458. .content-box {
  459. height: 100vh;
  460. overflow: hidden;
  461. display: flex;
  462. flex-direction: column;
  463. }
  464. .list_box {
  465. flex: 1;
  466. overflow: hidden;
  467. padding: 4rpx 0;
  468. .u-list {
  469. height: 100% !important;
  470. }
  471. .card_box {
  472. padding: 16rpx;
  473. }
  474. }
  475. .bottom-wrapper {
  476. width: 100%;
  477. display: flex;
  478. align-items: center;
  479. justify-content: space-around;
  480. .btn_box {
  481. width: 50%;
  482. height: 88rpx;
  483. line-height: 88rpx;
  484. background: $theme-color;
  485. text-align: center;
  486. font-size: 36rpx;
  487. font-style: normal;
  488. font-weight: 400;
  489. color: #fff;
  490. &:first-child {
  491. border-right: 2rpx solid #fff;
  492. }
  493. }
  494. }
  495. .operate_box {
  496. position: fixed;
  497. right: 0;
  498. top: 400rpx;
  499. /deep/ .u-button {
  500. margin-top: 20rpx;
  501. width: 150rpx;
  502. border-radius: 22rpx 0 0 22rpx;
  503. opacity: 0.6;
  504. }
  505. }
  506. .operate_box2 {
  507. display: flex;
  508. /deep/ .u-button {
  509. margin-top: 20rpx;
  510. width: 150rpx;
  511. }
  512. }
  513. .flex_btn {
  514. position: fixed;
  515. right: 0;
  516. bottom: 160rpx;
  517. width: 140rpx;
  518. height: 66rpx;
  519. line-height: 66rpx;
  520. border-radius: 22rpx 0 0 22rpx;
  521. background: $theme-color;
  522. text-align: center;
  523. font-size: 22rpx;
  524. font-style: normal;
  525. font-weight: 400;
  526. color: #fff;
  527. opacity: 0.6;
  528. }
  529. </style>