details.vue 17 KB

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