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