Commit db2b31ac by zhangxw

营销活动bug修复

1 parent 245573aa
......@@ -321,8 +321,9 @@ export default {
this.loadingCount++;
},
endLoading() {
if (this.loadingCount > 0)
if (this.loadingCount > 0) {
this.loadingCount--;
}
},
getTagList() {
this.startLoading();
......@@ -332,17 +333,21 @@ export default {
},
// 活动时间变更:统一补齐秒(新增时选择器可能只到分)
handleTimeChange(val) {
if (!val || !Array.isArray(val) || val.length !== 2)
if (!val || !Array.isArray(val) || val.length !== 2) {
return;
}
const padSeconds = (timeStr) => {
if (!timeStr)
if (!timeStr) {
return "";
}
// 已有秒则直接返回,否则补 :00
if (timeStr.length === 19 && timeStr[10] === " " && timeStr[13] === ":")
if (timeStr.length === 19 && timeStr[10] === " " && timeStr[13] === ":") {
return timeStr;
}
// 格式为 yyyy-MM-dd HH:mm 时补秒
if (timeStr.length === 16)
if (timeStr.length === 16) {
return timeStr + ":00";
}
return timeStr;
};
this.$set(this.formData.activityTime, 0, padSeconds(val[0]));
......@@ -354,8 +359,9 @@ export default {
setTimeout(() => {
document.querySelectorAll(".el-date-range-picker .el-time-panel").forEach((panel) => {
const lists = panel.querySelectorAll(".el-time-spinner__list");
if (lists.length < 3)
if (lists.length < 3) {
return;
}
// 隐藏秒列表
lists[2].style.display = "none";
......@@ -391,8 +397,9 @@ export default {
getDetail() {
this.startLoading();
getMarketingActivityDetail({ activityId: this.activityId }).then((res) => {
if (!res)
if (!res) {
return;
}
// 回显基本信息
this.formData.activityName = res.activityName || "";
this.formData.activityTime = [res.startTime || "", res.endTime || ""];
......@@ -449,8 +456,9 @@ export default {
getMarketingActivityCarSeries(params).then((res) => {
// 接口返回的是数组(不是 { list: [] } 结构)
const list = Array.isArray(res) ? res : (res?.list || []);
if (!list.length)
if (!list.length) {
return;
}
// 映射车系列表
this.selectedSeries = list.map(series => ({
id: series.carSeriesId,
......@@ -672,8 +680,9 @@ export default {
const existingMap = {};
existingList.forEach((item) => {
const key = item.productType == 0 ? (item.packageCode) : (item.goodsCode);
if (key)
if (key) {
existingMap[key] = item;
}
});
const newList = selectedItems.map((item) => {
......@@ -748,8 +757,9 @@ export default {
const existingMap = {};
this.directPackages.forEach((item) => {
const key = item.productType === 0 ? (item.packageCode) : (item.goodsCode);
if (key)
if (key) {
existingMap[key] = item;
}
});
this.directPackages = selectedItems.map((item) => {
......@@ -884,20 +894,23 @@ export default {
if (!item.name || !item.name.trim()) {
item.nameError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "选项卡名称";
}
}
if (!item.tabDescription || !item.tabDescription.trim()) {
item.tabDescriptionError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "选项卡描述";
}
}
if (!item.discountPrice && item.discountPrice !== 0) {
item.discountPriceError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "优惠价";
}
}
if (item.discountPrice && item.price) {
const discount = Number.parseFloat(item.discountPrice);
......@@ -905,8 +918,9 @@ export default {
if (!isNaN(discount) && !isNaN(price) && discount > price) {
item.discountPriceError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "优惠价";
}
}
}
});
......@@ -923,24 +937,27 @@ export default {
if (!item.name || !item.name.trim()) {
item.nameError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "选项卡名称";
}
}
// 选项卡描述必填
if (!item.tabDescription || !item.tabDescription.trim()) {
item.tabDescriptionError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "选项卡描述";
}
}
// 优惠价必填
if (!item.discountPrice && item.discountPrice !== 0) {
item.discountPriceError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "优惠价";
}
}
// 优惠价不能大于现售价
......@@ -950,8 +967,9 @@ export default {
if (!isNaN(discount) && !isNaN(price) && discount > price) {
item.discountPriceError = true;
hasError = true;
if (!firstErrorField)
if (!firstErrorField) {
firstErrorField = "优惠价";
}
}
}
});
......@@ -986,8 +1004,9 @@ export default {
// 提交
handleSubmit() {
if (this.submitting)
if (this.submitting) {
return;
}
this.submitting = true;
// 1. 校验基本信息
......@@ -1019,10 +1038,23 @@ export default {
}
// 3. 校验活动商品/套餐
if (!this.getTotalPackageCount()) {
this.$message.warning("请至少设置一个商品或套餐");
this.submitting = false;
return;
if (this.selectedSeries.length) {
// 按车系配置:每个车系都要至少有一个商品/套餐
for (const series of this.selectedSeries) {
const count = (this.seriesPackages[series.id] || []).length;
if (!count) {
this.$message.warning(`${series.name || series.seriesName}请至少设置一个商品或套餐`);
this.submitting = false;
return;
}
}
} else {
// 直接配置:至少要有一个商品/套餐
if (!this.directPackages.length) {
this.$message.warning("请至少设置一个商品或套餐");
this.submitting = false;
return;
}
}
// 4. 校验套餐/商品数量上限(直接模式最大100条,车系模式每车系最大100条)
......@@ -1158,8 +1190,9 @@ export default {
this.submitting = false;
});
// 埋点
if (this.pageType == "add")
if (this.pageType == "add") {
this.setReportTrackData(0, "marketing-activity-add", {});
}
});
},
......
......@@ -32,13 +32,13 @@
<span class="h-col h-col-main">是否主推</span>
<span class="h-col h-col-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="h-col h-col-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
......@@ -214,8 +214,9 @@ export default {
watch: {
directProductList(val) {
// 只在初始化/增删时同步,拖拽排序时不覆盖(通过 _isDragging 标记)
if (this._isDragging)
if (this._isDragging) {
return;
}
if (val && val.length) {
this.localList = [...val];
} else {
......@@ -247,16 +248,18 @@ export default {
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
return (data ?? "") === "";
},
initSortable() {
if (!this.$refs.sortableBody)
if (!this.$refs.sortableBody) {
return;
}
if (this.sortableInstance) {
this.sortableInstance.destroy();
......
......@@ -23,13 +23,13 @@
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
......@@ -139,8 +139,9 @@ export default {
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
......
......@@ -23,13 +23,13 @@
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
......@@ -139,8 +139,9 @@ export default {
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
......
......@@ -32,13 +32,13 @@
<span class="h-col h-col-main">是否主推</span>
<span class="h-col h-col-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="h-col h-col-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
......@@ -282,8 +282,9 @@ export default {
watch: {
directPackageList(val) {
// 只在初始化/增删时同步,拖拽排序时不覆盖(通过 _isDragging 标记)
if (this._isDragging)
if (this._isDragging) {
return;
}
if (val && val.length) {
this.localList = [...val];
} else {
......@@ -314,8 +315,9 @@ export default {
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
......@@ -341,11 +343,13 @@ export default {
*/
loadPackageProducts(packageCode) {
const idx = this.localList.findIndex(p => p.packageCode === packageCode);
if (idx < 0)
if (idx < 0) {
return;
}
const pkg = this.localList[idx];
if (!pkg.packageCode)
if (!pkg.packageCode) {
return;
}
// 设置loading状态
this.$set(this.packageLoadingMap, packageCode, true);
......@@ -394,8 +398,9 @@ export default {
* Sortable 直接操作 el-collapse-item,子商品在内容区天然跟随
*/
initSortable() {
if (!this.$refs.sortableList)
if (!this.$refs.sortableList) {
return;
}
// 销毁旧实例
if (this.sortableInstance) {
......@@ -404,8 +409,9 @@ export default {
}
const el = this.$refs.sortableList.querySelector(".el-collapse");
if (!el)
if (!el) {
return;
}
this.sortableInstance = new Sortable(el, {
ghostClass: "ghost-row",
......@@ -495,11 +501,13 @@ export default {
*/
syncPackageDiscountError(subRow) {
const pkg = this.localList.find(p => (p.packageItems || []).includes(subRow));
if (!pkg)
if (!pkg) {
return;
}
const packageItems = pkg.packageItems || [];
if (!packageItems.length)
if (!packageItems.length) {
return;
}
const allValid = packageItems.every((p) => {
const val = Number.parseFloat(p.discountPrice);
return p.discountPrice !== "" && p.discountPrice != null && !isNaN(val) && val >= 0;
......
......@@ -22,13 +22,13 @@
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<el-tooltip content="页面展示主图,建议尺寸 664x336px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<el-tooltip content="列表中展示的缩略图,建议尺寸 88x120px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
......@@ -99,8 +99,9 @@ export default {
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
if (this.filterEmpty(num)) {
return "-";
}
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!