|
|
@@ -384,46 +384,38 @@ function handleValidateButtonClick(e: MouseEvent) {
|
|
|
let rightsDesc = '';
|
|
|
let num = 0;
|
|
|
|
|
|
- // 组装权益配置为数组格式
|
|
|
- const benefitArray: any[] = [];
|
|
|
+ // 组装权益配置为扁平对象格式
|
|
|
+ const benefitObj: any = {};
|
|
|
if (isCheckedOilPerLiterDiscount.value) {
|
|
|
num += 1;
|
|
|
rightsDesc += `${num}、全省中国石化加油站加油优惠${form.benefitConfigJson.oilPerLiterDiscount}元/升;\n `;
|
|
|
- benefitArray.push({
|
|
|
- oilPerLiterDiscount: form.benefitConfigJson.oilPerLiterDiscount,
|
|
|
- oilIcon: form.benefitConfigJson.oilIcon,
|
|
|
- oilRoutePath: form.benefitConfigJson.oilRoutePath
|
|
|
- });
|
|
|
+ benefitObj.oilPerLiterDiscount = form.benefitConfigJson.oilPerLiterDiscount;
|
|
|
+ benefitObj.oilIcon = form.benefitConfigJson.oilIcon;
|
|
|
+ benefitObj.oilRoutePath = form.benefitConfigJson.oilRoutePath;
|
|
|
}
|
|
|
if (isCheckedMallDiscountRate.value) {
|
|
|
num += 1;
|
|
|
rightsDesc += `${num}、市民请结合平台超6000+快消品优惠${form.benefitConfigJson.mallDiscountRate}%;\n `;
|
|
|
- benefitArray.push({
|
|
|
- mallDiscountRate: form.benefitConfigJson.mallDiscountRate,
|
|
|
- mallIcon: form.benefitConfigJson.mallIcon,
|
|
|
- mallRoutePath: form.benefitConfigJson.mallRoutePath
|
|
|
- });
|
|
|
+ benefitObj.mallDiscountRate = form.benefitConfigJson.mallDiscountRate;
|
|
|
+ benefitObj.mallIcon = form.benefitConfigJson.mallIcon;
|
|
|
+ benefitObj.mallRoutePath = form.benefitConfigJson.mallRoutePath;
|
|
|
}
|
|
|
if (isCheckedChargePerKwhDiscount.value) {
|
|
|
num += 1;
|
|
|
rightsDesc += `${num}、全省贵阳城投充电桩充电优惠${form.benefitConfigJson.chargePerKwhDiscount}元/度;\n `;
|
|
|
- benefitArray.push({
|
|
|
- chargePerKwhDiscount: form.benefitConfigJson.chargePerKwhDiscount,
|
|
|
- chargeIcon: form.benefitConfigJson.chargeIcon,
|
|
|
- chargeRoutePath: form.benefitConfigJson.chargeRoutePath
|
|
|
- });
|
|
|
+ benefitObj.chargePerKwhDiscount = form.benefitConfigJson.chargePerKwhDiscount;
|
|
|
+ benefitObj.chargeIcon = form.benefitConfigJson.chargeIcon;
|
|
|
+ benefitObj.chargeRoutePath = form.benefitConfigJson.chargeRoutePath;
|
|
|
}
|
|
|
if (isCheckedParkingDiscountRate.value) {
|
|
|
num += 1;
|
|
|
rightsDesc += `${num}、全场18000+贵阳城投停车位停车优惠${form.benefitConfigJson.parkingDiscountRate}%;\n `;
|
|
|
- benefitArray.push({
|
|
|
- parkingDiscountRate: form.benefitConfigJson.parkingDiscountRate,
|
|
|
- parkingIcon: form.benefitConfigJson.parkingIcon,
|
|
|
- parkingRoutePath: form.benefitConfigJson.parkingRoutePath
|
|
|
- });
|
|
|
+ benefitObj.parkingDiscountRate = form.benefitConfigJson.parkingDiscountRate;
|
|
|
+ benefitObj.parkingIcon = form.benefitConfigJson.parkingIcon;
|
|
|
+ benefitObj.parkingRoutePath = form.benefitConfigJson.parkingRoutePath;
|
|
|
}
|
|
|
|
|
|
- form.benefitConfigJson = JSON.stringify(benefitArray);
|
|
|
+ form.benefitConfigJson = JSON.stringify(benefitObj);
|
|
|
|
|
|
// 处理优惠券配置
|
|
|
if (!isCheckedCouponConfigJson.value) {
|
|
|
@@ -510,28 +502,30 @@ async function getDetail() {
|
|
|
// 获取详情接口
|
|
|
const res = await fetchTypeDetail(route.query.id);
|
|
|
if (res.data) {
|
|
|
- model.value = res.data;
|
|
|
- model.value.benefitConfigJson = parseBenefitConfig(res.data.benefitConfigJson);
|
|
|
+ // 先解析所有JSON字段,避免直接赋值字符串触发模板v-for报错
|
|
|
+ const benefitConfig = parseBenefitConfig(res.data.benefitConfigJson);
|
|
|
+ const couponParsed = parseConfigWithIcon(res.data.couponConfigJson);
|
|
|
+ const giftParsed = parseConfigWithIcon(res.data.giftConfigJson);
|
|
|
|
|
|
- // 处理配置权益勾选状态
|
|
|
- if (model.value.benefitConfigJson.oilPerLiterDiscount) isCheckedOilPerLiterDiscount.value = true;
|
|
|
- if (model.value.benefitConfigJson.mallDiscountRate) isCheckedMallDiscountRate.value = true;
|
|
|
- if (model.value.benefitConfigJson.chargePerKwhDiscount) isCheckedChargePerKwhDiscount.value = true;
|
|
|
- if (model.value.benefitConfigJson.parkingDiscountRate) isCheckedParkingDiscountRate.value = true;
|
|
|
+ // 赋值前先处理好JSON字段
|
|
|
+ const data = { ...res.data };
|
|
|
+ data.benefitConfigJson = benefitConfig;
|
|
|
+ data.couponIcon = couponParsed.icon;
|
|
|
+ data.couponRoutePath = couponParsed.routePath;
|
|
|
+ data.couponConfigJson = couponParsed.list.length ? couponParsed.list : [{ couponId: '', count: 1 }];
|
|
|
+ data.giftIcon = giftParsed.icon;
|
|
|
+ data.giftRoutePath = giftParsed.routePath;
|
|
|
+ data.giftConfigJson = giftParsed.list;
|
|
|
|
|
|
- // 处理优惠券配置
|
|
|
- if (model.value.couponConfigJson) isCheckedCouponConfigJson.value = true;
|
|
|
- const couponParsed = parseConfigWithIcon(res.data.couponConfigJson);
|
|
|
- model.value.couponIcon = couponParsed.icon;
|
|
|
- model.value.couponRoutePath = couponParsed.routePath;
|
|
|
- model.value.couponConfigJson = couponParsed.list;
|
|
|
+ model.value = data;
|
|
|
|
|
|
- // 处理赠品配置
|
|
|
- if (model.value.giftConfigJson) isCheckedGiftConfigJson.value = true;
|
|
|
- const giftParsed = parseConfigWithIcon(res.data.giftConfigJson);
|
|
|
- model.value.giftIcon = giftParsed.icon;
|
|
|
- model.value.giftRoutePath = giftParsed.routePath;
|
|
|
- model.value.giftConfigJson = giftParsed.list;
|
|
|
+ // 处理配置权益勾选状态
|
|
|
+ if (benefitConfig.oilPerLiterDiscount) isCheckedOilPerLiterDiscount.value = true;
|
|
|
+ if (benefitConfig.mallDiscountRate) isCheckedMallDiscountRate.value = true;
|
|
|
+ if (benefitConfig.chargePerKwhDiscount) isCheckedChargePerKwhDiscount.value = true;
|
|
|
+ if (benefitConfig.parkingDiscountRate) isCheckedParkingDiscountRate.value = true;
|
|
|
+ if (res.data.couponConfigJson) isCheckedCouponConfigJson.value = true;
|
|
|
+ if (res.data.giftConfigJson) isCheckedGiftConfigJson.value = true;
|
|
|
}
|
|
|
}
|
|
|
|