Commit e704ecea authored by 何远江's avatar 何远江

工厂调拨优化

parent af4b9314
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
<view class="items">PL:{{ ele.PLNR }}</view> <view class="items">PL:{{ ele.PLNR }}</view>
<view class="items">退货库位:{{ ele.NLPLA }}</view> <view class="items">退货库位:{{ ele.NLPLA }}</view>
<view class="items">数量:{{ ele.PACMG }}</view> <view class="items">数量:{{ ele.PACMG }}</view>
<view class="boxBtn"> <!-- <view class="boxBtn">
<u-button class="botBtn" size="mini" type="primary" plain @click="deleGonds()"> <u-button class="botBtn" size="mini" type="primary" plain @click="deleGonds(idx)">
<u-icon name="trash" size="28"></u-icon> <u-icon name="trash" size="28"></u-icon>
删除 删除
</u-button> </u-button>
</view> </view> -->
</view> </view>
</view> </view>
</view> </view>
...@@ -59,7 +59,8 @@ export default { ...@@ -59,7 +59,8 @@ export default {
default: function () { default: function () {
return {}; return {};
} }
}, },
itemIndex: Number
}, },
computed: { computed: {
totalVistaNum() { totalVistaNum() {
...@@ -74,8 +75,8 @@ export default { ...@@ -74,8 +75,8 @@ export default {
created() { created() {
}, },
methods: { methods: {
deleGonds() { deleGonds(idx) {
this.$emit('deleGonds',this.item) this.$emit('deleGonds',this.itemIndex, idx)
}, },
} }
}; };
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</StickyNavBar> </StickyNavBar>
<ContentLoadingMore class="cardbox" :list="goodsList"> <ContentLoadingMore class="cardbox" :list="goodsList">
<view class="cardContent" v-for="(item, index) in goodsList" :key="index"> <view class="cardContent" v-for="(item, index) in goodsList" :key="index">
<scanningList :item="item" :list="item.details" /> <scanningList :item="item" :list="item.details" :itemIndex="index" @deleGonds="deleGonds" />
</view> </view>
</ContentLoadingMore> </ContentLoadingMore>
<BottomBtn :btnArr="btnArr" @getBtnHandle="getBtnHandle"></BottomBtn> <BottomBtn :btnArr="btnArr" @getBtnHandle="getBtnHandle"></BottomBtn>
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
import ContentLoadingMore from "@/components/ContentLoadingMore/index.vue"; import ContentLoadingMore from "@/components/ContentLoadingMore/index.vue";
import BottomBtn from "@/components/BottomBtn/index.vue"; import BottomBtn from "@/components/BottomBtn/index.vue";
import scanningList from "./scanningList.vue"; import scanningList from "./scanningList.vue";
import { parseTime } from "@/utils/ruoyi"; import {
parseTime
} from "@/utils/ruoyi";
export default { export default {
components: { components: {
StickyNavBar, StickyNavBar,
...@@ -45,7 +47,7 @@ ...@@ -45,7 +47,7 @@
return { return {
wxparams: "", wxparams: "",
ebeln: '', ebeln: '',
catchPl: [], catchPl: [],
btnArr: [{ btnArr: [{
style: "", style: "",
type: "warning", type: "warning",
...@@ -102,49 +104,83 @@ ...@@ -102,49 +104,83 @@
}); });
}, },
goSubmit() { goSubmit() {
if (this.goodsList.length == 0) return if (this.goodsList.length == 0) return
if (this.goodsList.some(item => item.MENGE != item.details.reduce((acc, cur) => acc + cur.PACMG, 0))){ if (this.goodsList.some(item => item.MENGE != item.details.reduce((acc, cur) => acc + cur.PACMG, 0))) {
return this.$u.toast("请确认物料数量是否正确") return this.$u.toast("请确认物料数量是否正确")
} }
const params = { const params = {
BLDAT: parseTime(new Date(), "{y}{m}{d}"), BLDAT: parseTime(new Date(), "{y}{m}{d}"),
lfsnr: this.ebeln, lfsnr: this.ebeln,
item: this.goodsList.reduce((acc, cur) => { item: this.goodsList.reduce((acc, cur) => {
acc.push(...cur.details.map(item => { acc.push(...cur.details.map(item => {
return { return {
...cur, ...cur,
...item, ...item,
EBELN: this.ebeln, EBELN: this.ebeln,
EBELP: cur.EBELP EBELP: cur.EBELP
} }
})) }))
return acc return acc
}, []) }, [])
} }
this.$u.api.sapApi.sapAllot(params).then(res => { this.$u.api.sapApi.sapAllot(params).then(res => {
const errobj = res.find(item => item.TYPE == 'E') const errobj = res.find(item => item.TYPE == 'E')
if (errobj) { if (errobj) {
return this.$u.toast(errobj.MESSAGE) return this.$u.toast(errobj.MESSAGE)
} }
this.$u.toast(res[0].MESSAGE) this.$u.toast(res[0].MESSAGE)
setTimeout(() => { setTimeout(() => {
this.goBack() this.goBack()
}, 3000); }, 3000);
}) })
}, },
/**
* 删除PL,因为有拆分的PL情况, 要删除关联的的PL
*/
deleGonds(index, detailIndex, detail) {},
handleInputPlnr(e) { handleInputPlnr(e) {
if (!e) return if (!e) return
if (this.catchPl.length > 0) { if (this.catchPl.length > 0) {
if (!this.catchPl.inculdes(e)) { if (!this.catchPl.inculdes(e)) {
this.getPlnr(e); this.getPlnr(e);
} else { } else {
this.reset() this.reset()
this.$u.toast("请不要重复扫码") this.$u.toast("请不要重复扫码")
} }
return return
} }
this.getPlnr(e); this.getPlnr(e);
},
setPL(blpls) {
blpls.forEach(item => {
// 记录如有拆分,剩余数量
const remainder = item.PACMG
// 查询相同工厂,相同物料编码的条目,且还未分配满数量的
let goods = this.goodsList.find(v => item.MATNR == v.MATNR && item.WERKS == v.RESWK && v
.total != v.MENGE)
// 如果有满足条件的物料
while (goods != undefined) {
// 需求量
const reqNum = goods.MENGE - (goods.total || 0)
// 如果需求量大于等于剩余量,直接分配
if (reqNum >= remainder) {
goods.details.push({...item, PACMG: remainder})
// 累加已经分配的数量
goods.total += remainder
// 终止循环条件
goods = undefined
} else {
// 如果需求量小于剩余量,需要使用拆分
goods.details.push({...item, PACMG: reqNum})
goods.total += reqNum
remainder -= reqNum
// 还有剩余数量,需要继续遍历添加
goods = this.goodsList.find(v => item.MATNR == v.MATNR && item.WERKS == v.RESWK && v
.total != v.MENGE)
}
}
})
}, },
getPlnr(plnr) { getPlnr(plnr) {
this.isDisabled = true; this.isDisabled = true;
...@@ -155,25 +191,21 @@ ...@@ -155,25 +191,21 @@
ztype: "002", ztype: "002",
}) })
.then((res) => { .then((res) => {
// 验证查询PL是否成功 // 验证查询PL是否成功
if (res.MSG.some(item => { if (res.MSG.some(item => {
if (item.TYPE == 'E') { if (item.TYPE == 'E') {
this.$u.toast(item.MESSAGE) this.$u.toast(item.MESSAGE)
return true return true
} }
return false return false
})) { })) {
return this.reset() return this.reset()
} }
if (res.BLPL.length == 0) { if (res.BLPL.length == 0) {
return this.$u.toast("未查询到该条码信息") return this.$u.toast("未查询到该条码信息")
} }
// 匹配相同物料添加进details this.setPL(res.BLPL)
res.BLPL.forEach(item => { this.reset()
const goods = this.goodsList.find(v => item.MATNR == v.MATNR && item.WERKS ==v.RESWK)
goods && goods.details.push(item)
})
this.reset()
}); });
}, },
}, },
...@@ -315,4 +347,4 @@ ...@@ -315,4 +347,4 @@
.checkedCase { .checkedCase {
margin-top: 10rpx; margin-top: 10rpx;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment