details.vue 18 KB

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