Commit ac15f071 by crushh

udpate: 完成复制

parent 1041ba5c
......@@ -332,11 +332,9 @@
<div>
<el-button
type="text"
@click="getLink(scope.row)"
v-if="scope.row.canEdit && $getButtonLimit($buttonCode.couponPromote)"
:limit-code="$buttonCode.couponPromote"
@click="goAdd(scope.row,'couponCopy')"
>
推广
复制
</el-button>
<el-button
type="text"
......@@ -362,12 +360,6 @@
>
上架
</el-button>
<!-- <el-button
type="text"
@click="goAdd(scope.row,'couponCopy')"
>
复制
</el-button> -->
<el-button
type="text"
@click="goAdd(scope.row,'couponEdit')"
......@@ -377,13 +369,16 @@
编辑
</el-button>
<el-dropdown
v-if="(scope.row.isDifferentialPricing || scope.row.canEdit)&& ($getButtonLimit($buttonCode.couponTieredPricing)|| $getButtonLimit($buttonCode.couponDelete) || $getButtonLimit($buttonCode.couponDetail) || $getButtonLimit($buttonCode.couponConversion))"
v-if="(scope.row.isDifferentialPricing || scope.row.canEdit)&& ($getButtonLimit($buttonCode.couponTieredPricing)||$getButtonLimit($buttonCode.couponPromote)|| $getButtonLimit($buttonCode.couponDelete) || $getButtonLimit($buttonCode.couponDetail) || $getButtonLimit($buttonCode.couponConversion))"
style="margin-left:20px;"
@command="command => handleCommand(command, scope.row, scope.$index)"
placement="bottom-start"
>
<span class="el-dropdown-link" style="color:#1890ff;cursor: pointer;"> <i class="el-icon-more" /> </span>
<el-dropdown-menu slot="dropdown" style="width:110px;">
<el-dropdown-item command="5" v-if="$getButtonLimit($buttonCode.couponPromote)" :limit-code="$buttonCode.couponPromote">
推广
</el-dropdown-item>
<el-dropdown-item command="0" v-if="$getButtonLimit($buttonCode.couponDetail)" :limit-code="$buttonCode.couponDetail">
查看详情
</el-dropdown-item>
......@@ -396,6 +391,9 @@
<el-dropdown-item command="3" v-if="scope.row.canEdit && $getButtonLimit($buttonCode.couponDelete)" :limit-code="$buttonCode.couponDelete">
删除
</el-dropdown-item>
<el-dropdown-item command="3" v-if="scope.row.canEdit && $getButtonLimit($buttonCode.couponDelete)" :limit-code="$buttonCode.couponDelete">
删除
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<!-- <el-popover placement="top" width="160" v-model="scope.row.visible2" style="margin-left:8px">
......@@ -676,6 +674,8 @@ export default {
.catch(() => {
});
} else if (command == 5) {
this.getLink(item);
}
},
// 跳转到兑换记录
......
......@@ -29,7 +29,7 @@
>
<div class="section-content">
<h3>选择卡券</h3>
<el-form-item label="选择卡券" required v-show="mallProId === '-1'">
<el-form-item label="选择卡券" required v-show="mallProId === '-1'||isCopy">
<el-button plain @click="showCard" :disabled="cardList.length >= addCardMax">
添加卡券
</el-button>
......@@ -91,13 +91,16 @@
</template>
</el-table-column>
<el-table-column label="库存" prop="couponStock" />
<el-table-column label="操作" v-show="mallProId === '-1'">
<el-table-column label="操作">
<template slot-scope="scope">
<dm-delete @confirm="deleteCard(scope.$index)" tips="确定删除该卡券吗?">
<dm-delete @confirm="deleteCard(scope.$index)" tips="确定删除该卡券吗?" v-if="mallProId === '-1' || isCopy">
<el-button type="text">
删除
</el-button>
</dm-delete>
<el-button type="text" v-else :disabled="true">
删除
</el-button>
</template>
</el-table-column>
<el-table-column label="卡券状态" v-if="mallProId !== '-1'">
......@@ -502,6 +505,7 @@
:cardLimit="cardLimit"
:cardType="cardType"
@selectCard="selectCard"
tableColumnType="checkbox"
ref="dmcard"
/>
</div>
......@@ -659,6 +663,7 @@ export default {
},
uuid: '',
}, // 可见配置的数据源
isCopy: this.$route.meta.type == 'copy',
isNew: true, // 编辑旧商品时,是否确认转换为新数据格式
};
},
......@@ -1017,6 +1022,11 @@ export default {
} else if (useNewStoreWidget == 1) { // 使用卡券门店选择器
this.visibleData.uuid = storeWidgetId;
}
if (this.isCopy) { // 老数据复制时 使用上架规则那套新模式
this.isNew = true;
this.visibleData.uuid = '';
this.visibleData.useNewStoreWidget = 1;
}
console.log(this.visibleData);
this.visibleData = Object.assign({}, this.visibleData);
},
......@@ -1076,51 +1086,55 @@ export default {
this.showCardDialog = true;
},
// 子组件触发方法
selectCard (val) {
async selectCard (arr) {
console.log(arr);
if (arr.length + this.cardList.length > 15) {
this.$message.error(`最多支持添加15张卡券,目前一共选择${arr.length + this.cardList.length}张卡券`);
return;
}
this.showCardDialog = false;
// this.cardList = [];
if (val) {
if (arr.length) {
// 重复卡券去掉
if (
!this.cardList.find(row => {
return row.coupCardId === val.coupCardId;
})
) {
this.cardList.push(val);
this.cardCouponList.push({
proRefId: val.coupCardId,
proRefName: val.cardName,
integralCost: undefined,
cashCost: undefined,
});
this.limitTimesNumArr.push(val.cardLimit);
this.couponCardStockArr.push(val.couponStock);
} else {
this.$message.error('重复的卡券不允许');
return;
}
// this.limitTimes = val.cardLimit;
this.limitTimes = Math.min.apply(null, this.limitTimesNumArr);
this.limitTimesNum = Math.min.apply(null, this.limitTimesNumArr);
this.couponCardStock = Math.min.apply(null, this.couponCardStockArr);
this.couponForm.limitTimesStatus = true;
arr.forEach((val) => {
if (
!this.cardList.find(row => {
return row.coupCardId === val.coupCardId;
})
) {
this.cardList.push(val);
this.cardCouponList.push({
proRefId: val.coupCardId,
proRefName: val.cardName,
integralCost: undefined,
cashCost: undefined,
});
this.limitTimesNumArr.push(val.cardLimit);
this.couponCardStockArr.push(val.couponStock);
this.limitTimes = Math.min.apply(null, this.limitTimesNumArr);
this.limitTimesNum = Math.min.apply(null, this.limitTimesNumArr);
this.couponCardStock = Math.min.apply(null, this.couponCardStockArr);
this.couponForm.limitTimesStatus = true;
}
});
const params = {
coupCardId: val.coupCardId,
coupCardId: this.cardList.map(item => item.coupCardId).join(','),
proType: 1,
};
request.post('/api-integral-mall/get-integral-mall-CashCost', qs.stringify(params)).then(res => {
if (res.data.errorCode === 0) {
this.costValueArr.push(res.data.result.costValue);
// 计算数组的总和
const res = await request.post('/api-integral-mall/get-integral-mall-CashCost', qs.stringify(params));
if (res.data.errorCode === 0) {
if (res.data.result.costValue) {
const arr = res.data.result.costValue.split(',');
arr.forEach(item => {
this.costValueArr.push(Number(item));
});
const sum = this.costValueArr.reduce(function (prev, cur, index, array) {
return prev + cur;
});
this.costValue = sum;
} else {
this.$message.error(res.data.message);
}
});
} else {
this.$message.error(res.data.message);
}
}
},
deleteCard (index) {
......@@ -1331,7 +1345,7 @@ export default {
if (valid) {
let params = {
proName: this.cardList.length > 1 ? this.couponForm.proName : this.cardList[0].cardName,
integralMallProId: this.mallProId === '-1' ? '' : this.mallProId, // 礼品id
integralMallProId: this.isCopy ? '' : (this.mallProId === '-1' ? '' : this.mallProId), // 礼品id
proType: 1, // 优惠券
proReferId: proReferIdArr.join(','), // 卡券id
dataDialogueId: this.couponForm.dataDialogueId, // 数据对话id
......@@ -1398,11 +1412,11 @@ export default {
this.$router.push({
name: 'coupon',
});
this.submitLoading = false;
} else {
this.$message.error(res.data.message);
this.submitLoading = false;
}
}).finally(() => {
this.submitLoading = false;
});
},
goBack () {
......
......@@ -1145,8 +1145,8 @@ export default {
proType: 1,
};
request.post('/api-integral-mall/get-integral-mall-CashCost', qs.stringify(params)).then(res => {
if (res.data.errorCode === 0) {
this.couponCostValue = res.data.result.costValue;
if (res.data.errorCode === 0 && res.data.result.costValue) {
this.couponCostValue = Number(res.data.result.costValue);
} else {
this.$message.error(res.data.message);
}
......@@ -1245,7 +1245,7 @@ export default {
this.giftForm.virtualStock = data.virtualStock; // 库存
this.currentStock = data.virtualStock;
if (this.isCopy && data.giftType == 0 && data.changeType == 5) {
this.giftForm.virtualStock = ''; // 库存
this.giftForm.virtualStock = ''; // 清空虚拟礼品库存
this.currentStock = '';
}
this.giftForm.proCodeQuery = data.proCodeQuery; // 条形码
......@@ -1258,6 +1258,15 @@ export default {
this.isDifferentialPricing = this.giftForm.ladder[0];
}
if (this.isDifferentialPricing && data.gradeProSkus && data.gradeProSkus.length > 0) {
if (this.isCopy) { // 复制时重置阶梯价 giftProSkuId
data.gradeProSkus.forEach(item => {
if (item.skuList && item.skuList.length) {
item.skuList.forEach(it => {
it.giftProSkuId = '';
});
}
});
}
this.list3 = data.gradeProSkus; // 阶梯价详情
this.submitLadderList = data.gradeProSkus;
} else {
......@@ -1395,6 +1404,11 @@ export default {
}
}
if (data.skuJsonList) {
if (this.isCopy) { // 复制时重置规格 giftProSkuId
data.skuJsonList.forEach(item => {
item.giftProSkuId = '';
});
}
this.submitSkuJson = data.skuJsonList;
} else {
this.submitSkuJson = [];
......@@ -1497,9 +1511,6 @@ export default {
} else {
this.isNew = false;
}
if (this.isCopy) {
this.isNew = true;
}
if (useNewStoreWidget == 0) { // 使用老的门店控件 (兼容老数据)
const type = Number(showStore);
this.visibleData.sendChildData.storeType = type; // :0所有 1门店分组 2部分门店
......@@ -1512,6 +1523,11 @@ export default {
} else if (useNewStoreWidget == 1) { // 使用卡券门店选择器
this.visibleData.uuid = storeWidgetId;
}
if (this.isCopy) { // 老数据复制时 使用上架规则那套新模式
this.isNew = true;
this.visibleData.uuid = '';
this.visibleData.useNewStoreWidget = 1;
}
console.log(this.visibleData);
this.visibleData = Object.assign({}, this.visibleData);
},
......@@ -1930,8 +1946,6 @@ export default {
return false;
}
this.skuList = val;
// console.log('skuList', this.skuList);
// return;
this.handleSku();
if (this.isDifferentialPricing) {
......@@ -2252,7 +2266,6 @@ export default {
virtualStock: this.isEdit ? this.giftForm.virtualStock - (this.currentStock || 0) : this.giftForm.virtualStock, //库存
timeZones: '', //部分时段
changeType: this.giftType === 0 ? String(this.giftForm.changeType) : this.giftForm.changeTypeList.join(','), //配送方式
// pickUpPoint:this.giftForm.pickUpPointType ===2?this.giftForm.pickUpPoint.join(','):'-1',//门店自提
refundType: this.giftForm.refundType, //售后
giftProStandardJson: this.giftProStandardJson ? JSON.stringify(this.giftProStandardJson) : '', //规格列表
skuJson: this.submitSkuJson.length ? JSON.stringify(this.submitSkuJson) : '', //sku数据
......
......@@ -1661,7 +1661,6 @@ export default {
} else {
this.submitSkuJson = [];
}
// 获取头部
this.skuHeaderList = [];
......
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