details.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  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' pType="feed" @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. if(this.clientEnvironmentId == 3) {
  176. if(this.List[0] && this.List[0].executorTime && this.List[0].executorTime != undefined ) {
  177. } else {
  178. uni.showToast({
  179. title: `请先选择时间投料时间`,
  180. icon: 'none'
  181. })
  182. return false
  183. }
  184. }
  185. batchSave(this.List).then(res => {
  186. uni.redirectTo({
  187. url: `/pages/pda/feeding/index/index?feedStatus=1`,
  188. });
  189. })
  190. },
  191. checkCache(type) {
  192. uni.hideLoading();
  193. return new Promise((resolve) => {
  194. if (type == 1) {
  195. feedSaveCache(this.List).then(rr => {
  196. uni.showToast({
  197. title: `已经缓存`,
  198. icon: 'none'
  199. })
  200. })
  201. resolve(false)
  202. } else if (type == 2) {
  203. resolve(true)
  204. }
  205. })
  206. },
  207. getList() {
  208. workorderList({
  209. ids: this.idsList,
  210. taskId: this.taskId
  211. }).then(res => {
  212. this.List = res.map(m => {
  213. m.workOrderId = m.id
  214. m.instanceList = [] // 物料
  215. m.equipmentList = [] // 设备
  216. m.modelList = [] // 模具
  217. m.aridRegionList = [] // 干燥区
  218. m.packingList = [] // 包装
  219. m.palletList = [] // 舟皿
  220. m.revolvingDiskList = [] // 周转盘
  221. m.semiProductList = [] //半成品
  222. if (m.pickOutInList.length > 0) {
  223. m.pickOutInList.forEach(f => {
  224. if (f.rootCategoryLevelId == 1) {
  225. m.instanceList.push(f)
  226. } else if (f.rootCategoryLevelId == 4) {
  227. m.modelList.push(f)
  228. } else if (f.rootCategoryLevelId == 5) {
  229. m.modelList.push(f)
  230. } else if (f.rootCategoryLevelId == 11) {
  231. m.aridRegionList.push(f)
  232. } else if (f.rootCategoryLevelId == 13) {
  233. m.packingList.push(f)
  234. } else if (f.rootCategoryLevelId == 8) {
  235. m.palletList.push(f)
  236. } else if (f.rootCategoryLevelId == 26) {
  237. m.revolvingDiskList.push(f)
  238. } else if ([23, 2, 9, 28].includes(Number(f
  239. .rootCategoryLevelId))) {
  240. m.semiProductList.push(f)
  241. }
  242. })
  243. }
  244. // 处理字段
  245. m.quality == '' ? m.quality = {} : ''
  246. if (!Object.prototype.hasOwnProperty.call(m, 'product')) {
  247. m.product = '{}'
  248. }
  249. delete m.id
  250. if (this.taskId) {
  251. m.taskId = this.taskId
  252. m.taskName = this.taskName
  253. }
  254. return {
  255. ...m
  256. }
  257. })
  258. }).finally(() => {
  259. this.getCacheFn()
  260. })
  261. },
  262. handleScan(id, type) {
  263. uni.scanCode({
  264. success: (res) => {
  265. this.scanData(res.result, type, id)
  266. }
  267. })
  268. },
  269. scanData(result, type, id) {
  270. if (type == 'wordOrder') {
  271. let isFals = this.List.some(m => m.code == result)
  272. if (isFals) {
  273. uni.showToast({
  274. title: '工单已存在',
  275. icon: 'none'
  276. })
  277. return false
  278. }
  279. getByCode(result).then(res => {
  280. let _arr = this.List
  281. _arr.forEach((e, index) => {
  282. if (e.workOrderId == id && res) {
  283. _arr[index] = res
  284. }
  285. })
  286. this.List = _arr
  287. this.$forceUpdate()
  288. })
  289. }
  290. },
  291. scanIt(id) {
  292. uni.scanCode({
  293. success: (res) => {
  294. this.scanItData(res.result, id)
  295. }
  296. })
  297. },
  298. scanItData(result, id) {
  299. scanLedger(result).then(res => {
  300. let _arr = []
  301. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  302. _arr = this.List
  303. _arr.forEach((e, index) => {
  304. if (e.workOrderId == id) {
  305. _arr[index].equipmentList = _arr[index].equipmentList.concat(res)
  306. }
  307. })
  308. this.List = _arr
  309. this.$forceUpdate()
  310. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  311. _arr = this.List
  312. _arr.forEach((e, index) => {
  313. if (e.workOrderId == id) {
  314. _arr[index].modelList = res
  315. }
  316. })
  317. this.List = _arr
  318. this.$forceUpdate()
  319. } else if (res.length >= 1 && [1].includes(Number(res[0].rootCategoryLevelId))) { // 物料
  320. _arr = this.List
  321. _arr.forEach((e, index) => {
  322. if (e.workOrderId == id) {
  323. _arr[index].instanceList = _arr[index].instanceList.concat(res)
  324. }
  325. })
  326. this.List = _arr
  327. this.$forceUpdate()
  328. } else if (res.length >= 1 && [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))) {
  329. _arr = this.List
  330. _arr.forEach((e, index) => {
  331. if (e.workOrderId == id) {
  332. _arr[index].semiProductList = _arr[index].semiProductList.concat(res)
  333. }
  334. })
  335. this.List = _arr
  336. this.$forceUpdate()
  337. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 11) { // 干燥区
  338. _arr = this.List
  339. _arr.forEach((e, index) => {
  340. if (e.workOrderId == id) {
  341. let isFals = _arr[index].aridRegionList.some(m => m.code == res[0]
  342. .aridRegionList[0].code)
  343. if (isFals) {
  344. uni.showToast({
  345. title: '干燥区已存在',
  346. icon: 'none'
  347. })
  348. return false
  349. }
  350. let _obj = res[0].aridRegionList[0]
  351. if (_obj.status == 0) {
  352. _obj['name'] = res[0].name
  353. _obj['region'] = res[0].extInfo.region
  354. _arr[index].aridRegionList = _arr[index].aridRegionList.concat(res[0]
  355. .aridRegionList)
  356. } else {
  357. uni.showToast({
  358. title: '干燥区已占用',
  359. icon: 'none'
  360. })
  361. }
  362. }
  363. })
  364. this.List = _arr
  365. this.$forceUpdate()
  366. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  367. _arr = this.List
  368. _arr.forEach((e, index) => {
  369. if (e.workOrderId == id) {
  370. let isFals = _arr[index].turnover.some(m => m.code == res[0].code)
  371. if (isFals) {
  372. uni.showToast({
  373. title: '周转车已存在',
  374. icon: 'none'
  375. })
  376. return false
  377. }
  378. _arr.forEach((e, index) => {
  379. if (e.workOrderId == id) {
  380. _arr[index].turnover = _arr[index].turnover.concat(res)
  381. }
  382. })
  383. this.List = _arr
  384. this.$forceUpdate()
  385. }
  386. })
  387. }
  388. })
  389. },
  390. // 全部扫一扫
  391. handlScanCode() {
  392. uni.scanCode({
  393. success: (res) => {
  394. this.scanItAllData(res.result)
  395. }
  396. })
  397. },
  398. scanItAllData(result) {
  399. scanLedger(result).then(res => {
  400. let _arr = []
  401. if (res.length == 1 && res[0].rootCategoryLevelId == 4) { // 设备
  402. _arr = this.List
  403. _arr.forEach((e, index) => {
  404. res['extInfo'].fixCode = res.fixCode
  405. e.equipmentList = e.equipmentList.concat(res)
  406. })
  407. this.List = _arr
  408. this.$forceUpdate()
  409. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 5) { // 模具
  410. _arr = this.List
  411. _arr.forEach((e, index) => {
  412. e.modelList = res
  413. })
  414. this.List = _arr
  415. this.$forceUpdate()
  416. } else if (res.length >= 1 && [1].includes(Number(res[0].rootCategoryLevelId))) {
  417. _arr = this.List
  418. _arr.forEach((e, index) => {
  419. e.instanceList = e.instanceList.concat(res)
  420. })
  421. this.List = _arr
  422. this.$forceUpdate()
  423. } else if (res.length >= 1 && [23, 2, 9, 28].includes(Number(res[0].rootCategoryLevelId))) {
  424. _arr = this.List
  425. _arr.forEach((e, index) => {
  426. e.semiProductList = e.semiProductList.concat(res)
  427. })
  428. this.List = _arr
  429. this.$forceUpdate()
  430. } else if (res.length >= 1 && res[0].rootCategoryLevelId == 7) { // 周转车
  431. _arr = this.List
  432. if (_arr.length == 1) {
  433. _arr.forEach((e, index) => {
  434. e.turnover = e.turnover.concat(res)
  435. })
  436. this.List = _arr
  437. this.$forceUpdate()
  438. } else if (_arr.length > 1) {
  439. uni.showToast({
  440. title: '多个工单通过下面单个扫一扫添加',
  441. icon: 'none'
  442. })
  443. }
  444. }
  445. })
  446. },
  447. getCacheFn() {
  448. let parma = {
  449. workOrderIds: this.idsList,
  450. taskId: this.taskId,
  451. type: 2
  452. }
  453. feedGetCache(parma).then(res => {
  454. if (res.length == 0) {
  455. return false
  456. }
  457. let objList = res[0].extInfo.objList
  458. this.List.forEach(f => {
  459. objList.forEach(o => {
  460. if (f.workOrderId == o.workOrderId && f.taskId == o.taskId) {
  461. f['instanceList'] = o.instanceList || []
  462. f['equipmentList'] = o.equipmentList || []
  463. f['modelList'] = o.modelList || []
  464. f['aridRegionList'] = o.aridRegionList || []
  465. f['packingList'] = o.packingList || []
  466. f['palletList'] = o.palletList || []
  467. f['instanceList'] = o.instanceList || []
  468. f['revolvingDiskList'] = o.revolvingDiskList || []
  469. f['semiProductList'] = o.semiProductList || []
  470. this.$forceUpdate()
  471. }
  472. })
  473. })
  474. })
  475. },
  476. removeCacheFn() {
  477. uni.showModal({
  478. title: '缓存',
  479. content: '是否清空缓存!',
  480. confirmText: '确认', //这块是确定按钮的文字
  481. success: rr => {
  482. if (rr.confirm) {
  483. let parma = {
  484. workOrderIds: this.idsList,
  485. taskId: this.taskId,
  486. type: 2
  487. }
  488. removeCache(parma).then(res => {
  489. this.getList()
  490. })
  491. }
  492. }
  493. })
  494. },
  495. handAdd(id) {
  496. const storageKey = Date.now() + "";
  497. uni.setStorageSync(storageKey, this.List || []);
  498. uni.navigateTo({
  499. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=feed&taskId=${this.taskId}`
  500. })
  501. },
  502. openDetails(id) {
  503. const storageKey = Date.now() + "";
  504. uni.setStorageSync(storageKey, this.List || []);
  505. let url = `/pages/pda/feeding/single?id=${id}&taskId=${this.taskId}&storageKey=${storageKey}`
  506. uni.navigateTo({
  507. url
  508. })
  509. },
  510. },
  511. beforeDestroy() {
  512. uni.hideLoading();
  513. },
  514. }
  515. </script>
  516. <style lang="scss" scoped>
  517. .content-box {
  518. height: 100vh;
  519. overflow: hidden;
  520. display: flex;
  521. flex-direction: column;
  522. }
  523. .list_box {
  524. flex: 1;
  525. overflow: hidden;
  526. padding: 4rpx 0;
  527. .u-list {
  528. height: 100% !important;
  529. }
  530. .card_box {
  531. padding: 16rpx;
  532. }
  533. }
  534. .bottom-wrapper {
  535. width: 100%;
  536. display: flex;
  537. align-items: center;
  538. justify-content: space-around;
  539. .btn_box {
  540. width: 50%;
  541. height: 88rpx;
  542. line-height: 88rpx;
  543. background: $theme-color;
  544. text-align: center;
  545. font-size: 36rpx;
  546. font-style: normal;
  547. font-weight: 400;
  548. color: #fff;
  549. &:first-child {
  550. border-right: 2rpx solid #fff;
  551. }
  552. }
  553. }
  554. .operate_box {
  555. position: fixed;
  556. right: 0;
  557. top: 400rpx;
  558. /deep/ .u-button {
  559. margin-top: 20rpx;
  560. width: 150rpx;
  561. border-radius: 22rpx 0 0 22rpx;
  562. opacity: 0.6;
  563. font-size: 22rpx;
  564. }
  565. }
  566. .operate_box2 {
  567. display: flex;
  568. /deep/ .u-button {
  569. margin-top: 20rpx;
  570. width: 150rpx;
  571. }
  572. }
  573. .flex_btn {
  574. position: fixed;
  575. right: 0;
  576. bottom: 160rpx;
  577. width: 40rpx;
  578. height: 50rpx;
  579. line-height: 66rpx;
  580. border-radius: 22rpx 0 0 22rpx;
  581. background: $theme-color;
  582. text-align: center;
  583. font-size: 22rpx;
  584. font-style: normal;
  585. font-weight: 400;
  586. color: #fff;
  587. opacity: 0.6;
  588. .jiantou {
  589. width: 30rpx;
  590. height: 30rpx;
  591. }
  592. }
  593. .flex_btn2 {
  594. position: fixed;
  595. right: 0;
  596. bottom: 160rpx;
  597. width: 126rpx;
  598. min-height: 140rpx;
  599. line-height: 62rpx;
  600. border-radius: 22rpx 0 0 22rpx;
  601. background: $theme-color;
  602. text-align: center;
  603. font-size: 22rpx;
  604. font-style: normal;
  605. font-weight: 400;
  606. color: #fff;
  607. opacity: 0.7;
  608. .close_box {
  609. height: 50rpx;
  610. line-height: 50rpx;
  611. width: 126rpx;
  612. text-align: left;
  613. .close {
  614. width: 40rpx;
  615. height: 40rpx;
  616. padding: 6rpx 10rpx;
  617. }
  618. }
  619. }
  620. </style>