details.vue 18 KB

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