details.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="领料" background-color="#F7F9FA"
  4. color="#404446" @clickLeft="back"></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. <view class="title_box rx-bc">
  9. <view class="left rx-sc">
  10. <view class="round">{{ index + 1 }}</view>
  11. <view class="code">工单编号:{{ item.code }}</view>
  12. </view>
  13. <view class="right_box rx-ec" v-if="clientEnvironmentId!==9">
  14. <u-button type="success" size="small" class="u-reset-button" v-if="isOutsource == 0"
  15. @click="addPicking(item.workOrderId, item)" text="添加物料"></u-button>
  16. </view>
  17. </view>
  18. <view class="material rx-ss" v-for="(mate, idx) in item.bomList" :key="idx">
  19. <view class="left rx-ss" @click="mate.checked = !mate.checked">
  20. <view class="zdy_check rx-cc" :class="{ check_active: mate.checked }">
  21. <u-icon size="28" v-if='mate.checked' name='checkbox-mark'></u-icon>
  22. </view>
  23. </view>
  24. <view class="content_table">
  25. <view class="item">
  26. <view class="lable rx-cc">物料编码</view>
  27. <view class="content">
  28. {{ mate.categoryCode }}
  29. </view>
  30. </view>
  31. <view class="item">
  32. <view class="lable rx-cc">名称</view>
  33. <view class="content">{{ mate.categoryName }}</view>
  34. </view>
  35. <view class="item rx-sc">
  36. <view class="rx ww55 ">
  37. <view class="lable rx-cc">牌号</view>
  38. <view class="content ">{{ mate.brandNum }}</view>
  39. </view>
  40. <view class="rx ww45">
  41. <view class="lable rx-cc ww80">数量</view>
  42. <view class="content content_num">
  43. <input class="uni-input" v-model="mate.demandQuantity" type="digit" :disabled="clientEnvironmentId==9"></input>
  44. <view class="unit">{{ mate.unit }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="item">
  49. <view class="lable rx-cc">领料仓库</view>
  50. <view class="content pd4">
  51. <zxz-uni-data-select :localdata="mate.warehouseList" v-model="mate.warehouseId"
  52. dataValue='id' format='{name}' dataKey="name" filterable
  53. :clear='false'></zxz-uni-data-select>
  54. </view>
  55. </view>
  56. <view class="item" v-if="clientEnvironmentId==21">
  57. <view class="lable rx-cc">库存可用量</view>
  58. <view class="content ">{{ mate.waitOutInWeight }}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view>
  63. <instanceBom :list='item.instanceList2'></instanceBom>
  64. <modelBom :workOrderId='item.workOrderId' :modelList='item.modelList'
  65. :modelList2='item.modelList2' :code='item.code' @hendDel='hendDel'>
  66. </modelBom>
  67. <boatBom :palletList='item.palletList' :palletList2='item.palletList2' :code='item.code'
  68. :resObj='item' @hendDel='hendDel'>
  69. </boatBom>
  70. <packingBom :list='item.packingList2'></packingBom>
  71. <semiProductBom
  72. :list="[...item.semiProductList2, ...item.productList2, ...item.junkProductList2]">
  73. </semiProductBom>
  74. <view style="height: 80rpx;"></view>
  75. <view class='flex_btn' v-if='isPick' @click="openDetails">已有领料单</view>
  76. </view>
  77. </view>
  78. <view class="out_box" v-if="isOutsource == 1">
  79. <view class="out_text" @click="getListOutsource()">重新获取委外领料单</view>
  80. </view>
  81. </u-list>
  82. </view>
  83. <view class="bottom-wrapper">
  84. <view class="btn_box" @click="save">提交</view>
  85. </view>
  86. <outsourceOrder ref="outsourceRef" @outsourceEmit="outsourceFn"></outsourceOrder>
  87. </view>
  88. </template>
  89. <script>
  90. import instanceBom from './components/instanceBom.vue'
  91. import modelBom from './components/modelBom.vue'
  92. import boatBom from './components/boatBom.vue'
  93. import packingBom from './components/packingBom'
  94. import semiProductBom from './components/semiProductBom'
  95. import outsourceOrder from './components/outsourceOrder'
  96. import {
  97. znPdaPage,
  98. workorderList,
  99. listOutsourceInWarehouse,
  100. listOutsource
  101. } from '@/api/pda/workOrder.js'
  102. import {
  103. VirtualPagination
  104. } from '@/utils/pages.js'
  105. import {
  106. batchSave,
  107. pickDetails,
  108. findVoucherList
  109. } from '@/api/pda/picking.js'
  110. export default {
  111. components: {
  112. instanceBom,
  113. modelBom,
  114. boatBom,
  115. packingBom,
  116. semiProductBom,
  117. outsourceOrder
  118. },
  119. data() {
  120. return {
  121. idsList: [],
  122. List: [],
  123. pagination:{},
  124. classificationList: [], //分类数据
  125. newList:[],
  126. taskId: null,
  127. isPick: false,
  128. isOutsource: 0,
  129. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  130. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  131. }
  132. },
  133. onLoad(options) {
  134. console.log(options,'1111111111');
  135. let queryArray = decodeURIComponent(options.arr);
  136. this.idsList = JSON.parse(queryArray);
  137. this.isOutsource = Number(options.isOutsource) || 0
  138. this.taskId = options.taskId
  139. console.log(this.clientEnvironmentId, 'this.clientEnvironmentId');
  140. if (this.clientEnvironmentId == 21) {
  141. this.getZnList()
  142. } else {
  143. this.getList()
  144. }
  145. if (this.idsList.length == 1) {
  146. this.getPick()
  147. }
  148. if (this.isOutsource == 1) {
  149. this.getListOutsource()
  150. }
  151. },
  152. onShow() {
  153. uni.$off("setSelectList");
  154. uni.$on("setSelectList", (selectList, id) => {
  155. this.List.forEach(m => {
  156. if (m.workOrderId == id) {
  157. let instanceList2 = [] // 投料
  158. let modelList2 = [] // 模具
  159. let palletList2 = []
  160. let packingList2 = [] // 包装
  161. let semiProductList2 = [] //半成品
  162. let productList2 = [] // 产品
  163. let junkProductList2 = [] //废品
  164. selectList.forEach(f => {
  165. if (![5, 8, 13, 23, 9, 28].includes(f.rootCategoryLevelId)) {
  166. f.automatic = 1
  167. instanceList2 = instanceList2.concat(f)
  168. } else if (f.rootCategoryLevelId == 5) { // 模具
  169. f.automatic = 1
  170. modelList2 = modelList2.concat(f)
  171. } else if (f.rootCategoryLevelId == 8) { // 舟皿
  172. f.automatic = 1
  173. palletList2 = palletList2.concat(f)
  174. } else if (f.rootCategoryLevelId == 13) {
  175. f.automatic = 1
  176. packingList2 = packingList2.concat(f)
  177. } else if (f.rootCategoryLevelId == 23) {
  178. f.automatic = 1
  179. semiProductList2 = semiProductList2.concat(f)
  180. } else if (f.rootCategoryLevelId == 9) {
  181. f.automatic = 1
  182. productList2 = productList2.concat(f)
  183. } else if (f.rootCategoryLevelId == 28) {
  184. f.automatic = 1
  185. junkProductList2 = junkProductList2.concat(f)
  186. }
  187. })
  188. this.$set(m, 'instanceList2', instanceList2)
  189. this.$set(m, 'modelList2', modelList2)
  190. this.$set(m, 'palletList2', palletList2)
  191. this.$set(m, 'packingList2', packingList2)
  192. this.$set(m, 'semiProductList2', semiProductList2)
  193. this.$set(m, 'productList2', productList2)
  194. this.$set(m, 'junkProductList2', junkProductList2)
  195. }
  196. })
  197. });
  198. },
  199. methods: {
  200. scrolltolower() {
  201. let arr = this.pagination.nextPage();
  202. if(arr.length){
  203. this.List[0].bomList = [...this.List[0].bomList, ...arr]
  204. }
  205. },
  206. save() {
  207. let _arr = []
  208. _arr = this.newList.map(m => {
  209. if (m.bomList.length > 0) {
  210. let bomList = m.bomList.filter(f => f.checked)
  211. m['bomDetailDTOSList'] = [...bomList, ...m.modelList, ...m.palletList]
  212. }
  213. m.instanceList = [...m.instanceList2, ...m.modelList2, ...m.palletList2, ...m.packingList2, ...
  214. m.semiProductList2, ...m.productList2, ...m.junkProductList2
  215. ]
  216. m.isOutsource = this.isOutsource
  217. return {
  218. ...m
  219. }
  220. })
  221. if (this.clientEnvironmentId == 21) {
  222. findVoucherList({workOrderId:this.idsList[0]}).then(res => {
  223. uni.navigateTo({
  224. url: `/pages/pda/picking/index/index?pickStatus=1`,
  225. });
  226. })
  227. } else {
  228. batchSave(_arr).then(res => {
  229. uni.navigateTo({
  230. url: `/pages/pda/picking/index/index?pickStatus=1`,
  231. });
  232. })
  233. }
  234. },
  235. // 中赢保存
  236. getZnList() {
  237. znPdaPage({
  238. // ids: ,
  239. workId: this.idsList[0]
  240. }).then(res => {
  241. console.log(res, 'res');
  242. if (res?.length) {
  243. let List = res.map(m => {
  244. m.workOrderId = m.id
  245. let modelList = []
  246. let palletList = []
  247. // let bomList = []
  248. // m.bomDetailDTOS.forEach((f, i) => {
  249. // if (f.rootCategoryLevelId == 5) {
  250. // f.automatic = 2
  251. // modelList = modelList.concat(f)
  252. // }
  253. // if (f.rootCategoryLevelId == 8) {
  254. // f.automatic = 2
  255. // palletList = palletList.concat(f)
  256. // }
  257. // if (f.rootCategoryLevelId != 5 && f.rootCategoryLevelId != 8) {
  258. // f.automatic = 2
  259. // bomList = bomList.concat(f)
  260. // }
  261. // })
  262. m['modelList'] = modelList
  263. m['palletList'] = palletList
  264. // m['bomList'] = bomList
  265. m['modelList2'] = []
  266. m['instanceList2'] = []
  267. m['palletList2'] = []
  268. m['packingList2'] = []
  269. m['semiProductList2'] = []
  270. m['productList2'] = []
  271. m['junkProductList2'] = []
  272. delete m.id
  273. return {
  274. ...m
  275. }
  276. })
  277. this.newList =JSON.parse(JSON.stringify(List));
  278. this.pagination = new VirtualPagination(List[0].bomList, 10);
  279. List[0].bomList = this.pagination.getCurrentPageData();
  280. this.List = List;
  281. }
  282. })
  283. },
  284. getList() {
  285. workorderList({
  286. ids: this.idsList,
  287. taskId: this.taskId
  288. }).then(res => {
  289. console.log('领料列表', res)
  290. this.List = res.map(m => {
  291. m.workOrderId = m.id
  292. let modelList = []
  293. let palletList = []
  294. let bomList = []
  295. m.bomDetailDTOS.forEach((f, i) => {
  296. if (f.rootCategoryLevelId == 5) {
  297. f.automatic = 2
  298. modelList = modelList.concat(f)
  299. }
  300. if (f.rootCategoryLevelId == 8) {
  301. f.automatic = 2
  302. palletList = palletList.concat(f)
  303. }
  304. if (f.rootCategoryLevelId != 5 && f.rootCategoryLevelId != 8) {
  305. f.automatic = 2
  306. bomList = bomList.concat(f)
  307. }
  308. })
  309. m['modelList'] = modelList
  310. m['palletList'] = palletList
  311. m['bomList'] = bomList
  312. m['modelList2'] = []
  313. m['instanceList2'] = []
  314. m['palletList2'] = []
  315. m['packingList2'] = []
  316. m['semiProductList2'] = []
  317. m['productList2'] = []
  318. m['junkProductList2'] = []
  319. delete m.id
  320. return {
  321. ...m
  322. }
  323. })
  324. })
  325. },
  326. hendDel(type, code, list) {
  327. if (type == 'modelBom') {
  328. console.log(list.length)
  329. if (list.length == 0) {
  330. }
  331. this.List.forEach(f => {
  332. if (f.code == code) {
  333. if (list.length == 0) {
  334. f.modelList2 = []
  335. f.modelList = []
  336. return false
  337. }
  338. f.modelList2 = list.filter(t => t.automatic == 1)
  339. f.modelList = list.filter(t => t.automatic == 2)
  340. }
  341. })
  342. }
  343. if (type == 'boatBom') {
  344. this.List.forEach(f => {
  345. if (f.code == code) {
  346. if (list.length == 0) {
  347. f.palletList2 = []
  348. f.palletList = []
  349. return false
  350. }
  351. f.palletList2 = list.filter(t => t.automatic == 1)
  352. f.palletList = list.filter(t => t.automatic == 2)
  353. }
  354. })
  355. }
  356. this.$forceUpdate()
  357. },
  358. getListOutsource(list) {
  359. let param = {
  360. workOrderId: this.idsList,
  361. taskId: this.taskId
  362. }
  363. listOutsource(param).then(res => {
  364. if (res) {
  365. this.$refs.outsourceRef.open(res)
  366. } else {
  367. uni.showToast({
  368. title: '暂无委外申请单',
  369. icon: 'none'
  370. })
  371. }
  372. })
  373. },
  374. outsourceFn(list) {
  375. this.outsourceInWarehouseFn(list)
  376. },
  377. addPicking(id, item) {
  378. const storageKey = Date.now() + "";
  379. let arr = [...item.instanceList2, ...item.modelList2, ...item.palletList2, ...item.packingList2, ...item
  380. .semiProductList2, ...item.productList2, ...item.junkProductList2
  381. ]
  382. uni.setStorageSync(storageKey, arr);
  383. uni.navigateTo({
  384. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=pick&taskId=${this.taskId}`
  385. })
  386. },
  387. getPick() {
  388. pickDetails(this.idsList).then(res => {
  389. if (res && res.length > 0) {
  390. this.isPick = true
  391. }
  392. })
  393. },
  394. outsourceInWarehouseFn(list) {
  395. let param = {
  396. outsourceOrder: list || [],
  397. workOrderId: this.idsList[0],
  398. taskId: this.taskId
  399. }
  400. listOutsourceInWarehouse(param).then(res => {
  401. res.list.map(m => {
  402. m.isOut = 1
  403. return {
  404. ...m
  405. }
  406. })
  407. let _arr = [...this.List[0].instanceList2, ...res.list]
  408. this.$set(this.List[0], 'instanceList2', _arr)
  409. this.$forceUpdate()
  410. })
  411. },
  412. openDetails() {
  413. let url = `/pages/pda/picking/bill/index?id=${this.idsList[0]}`
  414. uni.navigateTo({
  415. url
  416. })
  417. },
  418. },
  419. beforeDestroy() {
  420. uni.hideLoading();
  421. },
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. .content-box {
  426. height: 100vh;
  427. overflow: hidden;
  428. display: flex;
  429. flex-direction: column;
  430. }
  431. .list_box {
  432. flex: 1;
  433. overflow: hidden;
  434. padding: 4rpx 0;
  435. .u-list {
  436. height: 100% !important;
  437. }
  438. .card_box {
  439. padding: 16rpx 24rpx;
  440. }
  441. .title_box {
  442. .round {
  443. width: 32rpx;
  444. height: 32rpx;
  445. line-height: 32rpx;
  446. border-radius: 50%;
  447. background: $theme-color;
  448. color: #fff;
  449. text-align: center;
  450. font-size: 20rpx;
  451. }
  452. .code {
  453. margin-left: 16rpx;
  454. font-family: PingFang SC;
  455. font-size: 28rpx;
  456. font-style: normal;
  457. font-weight: 400;
  458. color: $theme-color;
  459. }
  460. }
  461. .right_box {}
  462. .material {
  463. margin-top: 10rpx;
  464. .left {
  465. width: 40rpx;
  466. }
  467. .zdy_check {
  468. width: 30rpx;
  469. height: 30rpx;
  470. border: 2rpx solid #c8c9cc;
  471. border-radius: 4rpx;
  472. }
  473. .check_active {
  474. background: $theme-color;
  475. border: 2rpx solid $theme-color;
  476. /deep/ .u-icon__icon {
  477. color: #fff !important;
  478. }
  479. }
  480. .content_table {
  481. width: 652rpx;
  482. border: 2rpx solid $border-color;
  483. .item {
  484. display: flex;
  485. border-bottom: 2rpx solid $border-color;
  486. .lable {
  487. width: 132rpx;
  488. text-align: center;
  489. background-color: #F7F9FA;
  490. font-size: 26rpx;
  491. border-right: 2rpx solid $border-color;
  492. flex-shrink: 0;
  493. }
  494. .ww80 {
  495. width: 80rpx;
  496. }
  497. .content {
  498. width: 518rpx;
  499. min-height: 64rpx;
  500. font-size: 28rpx;
  501. line-height: 28rpx;
  502. font-style: normal;
  503. font-weight: 400;
  504. padding: 18rpx 8rpx;
  505. box-sizing: border-box;
  506. word-wrap: break-word;
  507. flex-grow: 1 !important;
  508. }
  509. .content_num {
  510. display: flex;
  511. align-items: center;
  512. padding: 0 4rpx;
  513. /deep/ .uni-input-input {
  514. border: 2rpx solid #F0F8F2;
  515. background: #F0F8F2;
  516. color: $theme-color;
  517. }
  518. .unit {
  519. width: 90rpx;
  520. text-align: center;
  521. font-size: 24rpx;
  522. color: #404446;
  523. }
  524. }
  525. .pd4 {
  526. padding: 4rpx 8rpx;
  527. }
  528. &:last-child {
  529. border-bottom: none;
  530. }
  531. }
  532. .ww55 {
  533. width: 55%;
  534. }
  535. .ww45 {
  536. width: 45%;
  537. }
  538. }
  539. }
  540. }
  541. .bottom-wrapper {
  542. .btn_box {
  543. width: 750rpx;
  544. height: 88rpx;
  545. line-height: 88rpx;
  546. background: $theme-color;
  547. text-align: center;
  548. font-size: 36rpx;
  549. font-style: normal;
  550. font-weight: 400;
  551. color: #fff;
  552. }
  553. }
  554. .flex_btn {
  555. position: fixed;
  556. right: 0;
  557. bottom: 160rpx;
  558. width: 140rpx;
  559. height: 66rpx;
  560. line-height: 66rpx;
  561. border-radius: 22rpx 0 0 22rpx;
  562. background: $theme-color;
  563. text-align: center;
  564. font-size: 22rpx;
  565. font-style: normal;
  566. font-weight: 400;
  567. color: #fff;
  568. }
  569. .out_box {
  570. margin: 20rpx;
  571. display: flex;
  572. justify-content: center;
  573. color: $theme-color;
  574. font-size: 28rpx;
  575. }
  576. </style>