Commit bf1b77e8 by crushh

update: 优化

parent c1380ab7
...@@ -1059,6 +1059,11 @@ export default { ...@@ -1059,6 +1059,11 @@ export default {
this.limitTimesNum = Math.min.apply(null, this.limitTimesNumArr); this.limitTimesNum = Math.min.apply(null, this.limitTimesNumArr);
this.couponCardStock = Math.min.apply(null, this.couponCardStockArr); this.couponCardStock = Math.min.apply(null, this.couponCardStockArr);
} }
const params = {
coupCardId: this.cardList.map(item => item.coupCardId).join(','),
proType: 1,
};
this.getCardCost(params);
} }
this.couponStatus = this.cardList.some(item => { this.couponStatus = this.cardList.some(item => {
return item.status === 0; return item.status === 0;
...@@ -1086,7 +1091,7 @@ export default { ...@@ -1086,7 +1091,7 @@ export default {
this.showCardDialog = true; this.showCardDialog = true;
}, },
// 子组件触发方法 // 子组件触发方法
async selectCard (arr) { selectCard (arr) {
console.log(arr); console.log(arr);
if (arr.length + this.cardList.length > 15) { if (arr.length + this.cardList.length > 15) {
this.$message.error(`最多支持添加15张卡券,目前一共选择${arr.length + this.cardList.length}张卡券`); this.$message.error(`最多支持添加15张卡券,目前一共选择${arr.length + this.cardList.length}张卡券`);
...@@ -1120,32 +1125,39 @@ export default { ...@@ -1120,32 +1125,39 @@ export default {
coupCardId: this.cardList.map(item => item.coupCardId).join(','), coupCardId: this.cardList.map(item => item.coupCardId).join(','),
proType: 1, proType: 1,
}; };
const res = await request.post('/api-integral-mall/get-integral-mall-CashCost', qs.stringify(params)); this.getCardCost(params);
if (res.data.errorCode === 0) { }
if (res.data.result.costValue) { },
this.costValueArr = []; async getCardCost (params) {
const arr = res.data.result.costValue.split(','); const res = await request.post('/api-integral-mall/get-integral-mall-CashCost', qs.stringify(params));
arr.forEach(item => { if (res.data.errorCode === 0) {
this.costValueArr.push(Number(item)); if (res.data.result.costValue) {
}); this.costValueArr = [];
const sum = this.costValueArr.reduce(function (prev, cur, index, array) { const arr = res.data.result.costValue.split(',');
return prev + cur; arr.forEach(item => {
}); this.costValueArr.push(Number(item));
this.costValue = sum; });
} const sum = this.costValueArr.reduce(function (prev, cur, index, array) {
} else { return prev + cur;
this.$message.error(res.data.message); });
this.costValue = sum;
} }
} else {
this.$message.error(res.data.message);
} }
}, },
deleteCard (index) { deleteCard (index) {
this.cardList.splice(index, 1); this.cardList.splice(index, 1);
this.cardCouponList.splice(index, 1); this.cardCouponList.splice(index, 1);
this.costValueArr.splice(index, 1); this.costValueArr.splice(index, 1);
const sum = this.costValueArr.reduce(function (prev, cur, index, array) { if (this.costValueArr.length) {
return prev + cur; const sum = this.costValueArr.reduce(function (prev, cur, index, array) {
}); return prev + cur;
this.costValue = sum; });
this.costValue = sum;
} else {
this.costValue = 0;
}
if (this.cardList.length > 0) { if (this.cardList.length > 0) {
this.limitTimesNumArr = []; this.limitTimesNumArr = [];
this.couponCardStockArr = []; this.couponCardStockArr = [];
...@@ -1286,9 +1298,12 @@ export default { ...@@ -1286,9 +1298,12 @@ export default {
async submitForm (couponForm) { async submitForm (couponForm) {
this.couponForm.detailDescription = this.$refs.tinymceWrap.tinymceHtml; this.couponForm.detailDescription = this.$refs.tinymceWrap.tinymceHtml;
const proReferIdArr = []; const proReferIdArr = [];
if (this.cardList.length === 0) { if (!this.cardList.length) {
this.$message.error('请选择卡券'); this.$message.error('请选择卡券');
return false; return false;
} else if (this.isCopy && this.cardList.filter(item => item.status != 1).length) {
this.$message.error('选择了无效卡券,无法保存');
return false;
} else { } else {
for (const item of this.cardList) { for (const item of this.cardList) {
proReferIdArr.push(item.coupCardId); proReferIdArr.push(item.coupCardId);
......
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