Commit db2b31ac by zhangxw

营销活动bug修复

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