details.vue 16 KB

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