Commit 8a6f5547 authored by xiangzj's avatar xiangzj

生产计划和包材计划

parent 77948db1
...@@ -177,6 +177,7 @@ ...@@ -177,6 +177,7 @@
let product = {} let product = {}
_this.planinnerLists = _this.planinnerLists.map((item, i) => { _this.planinnerLists = _this.planinnerLists.map((item, i) => {
if (i === fromIndex) { if (i === fromIndex) {
item.description = selectedProduct.SHORT_TEXT
item.product_info = { item.product_info = {
...selectedProduct, ...selectedProduct,
product_id: selectedProduct.PRODUCT_ID product_id: selectedProduct.PRODUCT_ID
...@@ -188,7 +189,7 @@ ...@@ -188,7 +189,7 @@
return item return item
}) })
_this.updateNoQuotaData(fromIndex, '', product); // _this.updateNoQuotaData(fromIndex, '', product);
}) })
}, },
...@@ -222,34 +223,39 @@ ...@@ -222,34 +223,39 @@
}, },
async updateNoQuotaData(productIndex, mode = '', product) { async updateNoQuotaData(productIndex, mode = '', product) {
console.log('updateNoQuotaData---entry', productIndex, mode, product) console.log('updateNoQuotaData---entry', productIndex, mode, product)
let item_inner = [] const {
PRODUCT_ID,
let productAfterInit = this.updateProductByInit(productIndex, mode, product) SHORT_TEXT
} = product.product_info
let productAfterInit = []
this.planinnerLists.forEach(item => {
productAfterInit.push({
...item,
product_id: PRODUCT_ID,
description: SHORT_TEXT,
})
});
console.log('productAfterInit', productAfterInit) console.log('productAfterInit', productAfterInit)
const flag = productAfterInit.every(function(item){
// 产品编号和件数 都有才请求 return item.product_id
if (!(productAfterInit?.product_info?.product_id && });
productAfterInit?.planqty_box)) { console.log(flag,'90909')
if(!flag){
return return
} }
item_inner = [productAfterInit]
const params = { const params = {
'user_bp': this.userInfo.code,
"head": this.HEADINFO, "head": this.HEADINFO,
"item": item_inner, "item": productAfterInit,
} }
const res = await apiUpdateProduceMaterialPlanData(params) const res = await apiUpdateProduceMaterialPlanData(params)
console.log('updateNoQuotaData', res) console.log('updateNoQuotaData', res)
this.HEADINFO.tby_dmbtr = res.data.head.tby_dmbtr || 0 this.HEADINFO.tby_dmbtr = res.data.head.tby_dmbtr || 0
this.planinnerLists = this.planinnerLists.map((item, i) => { this.planinnerLists = this.planinnerLists.map((item, i) => {
if (i === productIndex) { item = {
item = { ...item,
...item, ...product,
...product, ...res.data.item[i]
...res.DATA
}
} }
return item return item
}) })
...@@ -266,6 +272,7 @@ ...@@ -266,6 +272,7 @@
let obj = {} let obj = {}
this.planinnerLists = this.planinnerLists.map((item, i) => { this.planinnerLists = this.planinnerLists.map((item, i) => {
if (i === productIndex) { if (i === productIndex) {
item.product_id = PRODUCT_ID
item.product_id = PRODUCT_ID item.product_id = PRODUCT_ID
item.description = SHORT_TEXT item.description = SHORT_TEXT
item.planqty_box = item.planqty_box item.planqty_box = item.planqty_box
...@@ -286,7 +293,8 @@ ...@@ -286,7 +293,8 @@
"product_id": "", "product_id": "",
"description": "", "description": "",
"SHORT_TEXT": "", "SHORT_TEXT": "",
'product_info': {} 'product_info': {},
...this.productInitInfo
} }
this.planinnerLists.unshift(product) this.planinnerLists.unshift(product)
}, },
...@@ -317,29 +325,41 @@ ...@@ -317,29 +325,41 @@
this.HEADINFO.preorder = e.detail.value === false ? 0 : 1 this.HEADINFO.preorder = e.detail.value === false ? 0 : 1
}, },
async submit() { async submit() {
let res1 = null
const params = { try{
USER_BP: this.userInfo.code, const params = {
HEAD: this.HEADINFO, USER_BP: this.userInfo.code,
ITEM: this.planinnerLists HEAD: this.HEADINFO,
ITEM: this.planinnerLists
}
res1 = await apiUpdateProduceMaterialOrder(params)
if(res1.msgtype !== 'S'){
return
}
}catch(e){
//TODO handle the exception
} }
const res = await apiUpdateProduceMaterialOrder(params) try{
const { head, item } = res1
const params2 = {
USER_BP: this.userInfo.code,
ROLE:'WLY001',
MODE: 'SUBMIT',
head,
item
}
// this.HEADINFO = HEAD2
// this.planinnerLists = ITEM2
const res2 = await apiSubmitProduceMaterialOrder(params2)
if(res2.msgtype !== 'S'){
return
}
this.orderInfo = res.HEAD
const { head, item } = res this.$refs.popup.open('center')
const params2 = { }catch(e){
USER_BP: this.userInfo.code, //TODO handle the exception
ROLE:'WLY001',
MODE: 'SUBMIT',
head,
item
} }
// this.HEADINFO = HEAD2
// this.planinnerLists = ITEM2
const res2 = await apiSubmitProduceMaterialOrder(params2)
this.orderInfo = res.HEAD
this.$refs.popup.open('center')
}, },
resetData() { resetData() {
this.planinnerLists = [] this.planinnerLists = []
...@@ -529,7 +549,7 @@ ...@@ -529,7 +549,7 @@
.swipe-right-block { .swipe-right-block {
width: 152rpx; width: 152rpx;
background: linear-gradient(90deg, #fb4d61, #ff0f00 100%); background: #ff0f00;
border-radius: 0px 8px 8px 0px; border-radius: 0px 8px 8px 0px;
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -540,6 +560,7 @@ ...@@ -540,6 +560,7 @@
width: 152rpx; width: 152rpx;
display: flex; display: flex;
align-items: center; align-items: center;
text-align: center;
justify-content: center; justify-content: center;
color: #fff; color: #fff;
font-size: 34rpx; font-size: 34rpx;
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<view class="popup-content-content"> <view class="popup-content-content">
<text class="popup-content-content__title">提交成功</text> <text class="popup-content-content__title">提交成功</text>
<!-- <text class="popup-content-content__title2">生产计划编号:{{ orderInfo.OBJECT_ID }}</text> --> <!-- <text class="popup-content-content__title2">生产计划编号:{{ orderInfo.OBJECT_ID }}</text> -->
<text class="popup-content-content__title2">生产计划单号:{{ orderInfo.PRODPL_ID }}</text> <text class="popup-content-content__title2">生产计划单号:{{ orderInfo.prodpl_id }}</text>
</view> </view>
<view class="popup-content-foot"> <view class="popup-content-foot">
<text class="popup-content-foot__btn" @click="resetData()">继续添加</text> <text class="popup-content-foot__btn" @click="resetData()">继续添加</text>
...@@ -116,13 +116,14 @@ ...@@ -116,13 +116,14 @@
checked: false, checked: false,
'planqty_box': 0, 'planqty_box': 0,
'total': 0, 'total': 0,
'description': '请选择', 'description': '',
'product_info': {}, 'product_info': {},
}], }],
HEADINFO: {}, HEADINFO: {},
productInitInfo: {}, productInitInfo: {},
orderInfo: { orderInfo: {
PRODPL_ID: '' prodpl_id: ''
}, },
} }
}, },
...@@ -152,9 +153,10 @@ ...@@ -152,9 +153,10 @@
let product = {} let product = {}
_this.planinnerLists = _this.planinnerLists.map((item, i) => { _this.planinnerLists = _this.planinnerLists.map((item, i) => {
if (i === fromIndex) { if (i === fromIndex) {
item.description = selectedProduct.SHORT_TEXT
item.product_info = { item.product_info = {
...selectedProduct, ...selectedProduct,
product_id: selectedProduct.PRODUCT_ID prod_id: selectedProduct.PRODUCT_ID
} }
product = { product = {
...item ...item
...@@ -163,7 +165,7 @@ ...@@ -163,7 +165,7 @@
return item return item
}) })
_this.updateNoQuotaData(fromIndex, '', product); // _this.updateNoQuotaData(fromIndex, '', product);
}) })
}, },
...@@ -197,23 +199,29 @@ ...@@ -197,23 +199,29 @@
}, },
async updateNoQuotaData(productIndex, mode = '', product) { async updateNoQuotaData(productIndex, mode = '', product) {
console.log('updateNoQuotaData---entry', productIndex, mode, product) console.log('updateNoQuotaData---entry', productIndex, mode, product)
let item_inner = [] // let productAfterInit = this.updateProductByInit(productIndex, mode, product)
const {
let productAfterInit = this.updateProductByInit(productIndex, mode, product) PRODUCT_ID,
SHORT_TEXT
} = product.product_info
let productAfterInit = []
this.planinnerLists.forEach(item => {
productAfterInit.push({
...item,
prod_id: PRODUCT_ID,
description: SHORT_TEXT
})
});
console.log('productAfterInit', productAfterInit) console.log('productAfterInit', productAfterInit)
const flag = productAfterInit.every(function(item){
// 产品编号和件数 都有才请求 return item.prod_id
if (!(productAfterInit?.product_info?.product_id && });
productAfterInit?.planqty_box)) { if(!flag){
return return
} }
item_inner = [productAfterInit]
const params = { const params = {
"head": this.HEADINFO, "head": this.HEADINFO,
"item": item_inner, "item": productAfterInit,
} }
const res = await apiUpdateProducePlanData(params) const res = await apiUpdateProducePlanData(params)
console.log('updateNoQuotaData', res) console.log('updateNoQuotaData', res)
...@@ -223,7 +231,7 @@ ...@@ -223,7 +231,7 @@
item = { item = {
...item, ...item,
...product, ...product,
...res.data[0] ...res.data.item[i]
} }
} }
return item return item
...@@ -238,17 +246,25 @@ ...@@ -238,17 +246,25 @@
PRODUCT_ID, PRODUCT_ID,
SHORT_TEXT SHORT_TEXT
} = product.product_info } = product.product_info
let obj = {} this.planinnerLists = this.planinnerLists.forEach(item => {
this.planinnerLists = this.planinnerLists.map((item, i) => { item = {
if (i === productIndex) { ...item,
item.PROD_ID = PRODUCT_ID prod_id: PRODUCT_ID,
item.description = SHORT_TEXT description: SHORT_TEXT
item.planqty_box = item.planqty_box
obj = item
} }
return item });
}) return this.planinnerLists
return obj // let obj = {}
// this.planinnerLists = this.planinnerLists.map((item, i) => {
// if (i === productIndex) {
// item.prod_id = PRODUCT_ID
// item.description = SHORT_TEXT
// item.planqty_box = item.planqty_box
// obj = item
// }
// return item
// })
// return obj
}, },
selectProduct(index) { selectProduct(index) {
uni.navigateTo({ uni.navigateTo({
...@@ -264,7 +280,8 @@ ...@@ -264,7 +280,8 @@
"short_text": "", "short_text": "",
'net_price': '', 'net_price': '',
'net_value': '', 'net_value': '',
'product_info': {} 'product_info': {},
...this.productInitInfo
} }
this.planinnerLists.unshift(product) this.planinnerLists.unshift(product)
}, },
...@@ -298,13 +315,34 @@ ...@@ -298,13 +315,34 @@
this.HEADINFO.preorder = e.detail.value === false ? 0 : 1 this.HEADINFO.preorder = e.detail.value === false ? 0 : 1
}, },
async submit() { async submit() {
// const flag = this.planinnerLists.every(function(item){
// console.log(item,'')
// return item.description
// });
// console.log(flag,'123321')
// if(!flag){
// uni.showToast({
// title: '请先选择产品',
// duration: 2000,
// icon: 'none'
// });
// return
// }
let res1 = null
try{ try{
const params = { const params = {
head: this.HEADINFO, head: this.HEADINFO,
item: this.planinnerLists item: this.planinnerLists
} }
const res = await apiUpdateProduceOrder(params) res1 = await apiUpdateProduceOrder(params)
const { head, item } = res.data if(res1.msgtype !== 'S'){
return
}
}catch(e){
//TODO handle the exception
}
try{
const { head, item } = res1.data
const params2 = { const params2 = {
ROLE:'WLY001', ROLE:'WLY001',
MODE: 'SUBMIT', MODE: 'SUBMIT',
...@@ -314,9 +352,10 @@ ...@@ -314,9 +352,10 @@
// this.HEADINFO = HEAD2 // this.HEADINFO = HEAD2
// this.planinnerLists = ITEM2 // this.planinnerLists = ITEM2
const res2 = await apiSubmitProduceOrder(params2) const res2 = await apiSubmitProduceOrder(params2)
if(res2.msgtype !== 'S'){
this.orderInfo = res.DATA1 return
}
this.orderInfo = {...res1.data.head}
this.$refs.popup.open('center') this.$refs.popup.open('center')
}catch(e){ }catch(e){
//TODO handle the exception //TODO handle the exception
...@@ -493,7 +532,7 @@ ...@@ -493,7 +532,7 @@
.swipe-right-block { .swipe-right-block {
width: 152rpx; width: 152rpx;
background: linear-gradient(90deg, #fb4d61, #ff0f00 100%); background: #ff0f00;
border-radius: 0px 8px 8px 0px; border-radius: 0px 8px 8px 0px;
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -504,6 +543,7 @@ ...@@ -504,6 +543,7 @@
width: 152rpx; width: 152rpx;
display: flex; display: flex;
align-items: center; align-items: center;
text-align: center;
color: #fff; color: #fff;
font-size: 34rpx; font-size: 34rpx;
font-weight: 500; font-weight: 500;
......
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