Commit e9606252 by zhangxw

营销活动bug修复

1 parent 810d3af2
...@@ -416,8 +416,6 @@ export default { ...@@ -416,8 +416,6 @@ export default {
this.directPackages = list.map(item => ({ this.directPackages = list.map(item => ({
...item, ...item,
productType: item.packageCode ? 0 : 1, productType: item.packageCode ? 0 : 1,
// 套餐字段映射:优先使用 packageId(接口返回字段),其次 packageCode
packageId: item.packageId || item.packageCode,
packageName: item.packageName || "", packageName: item.packageName || "",
tabName: item.tabName || item.packageName || "", tabName: item.tabName || item.packageName || "",
packageCode: item.packageCode || "", packageCode: item.packageCode || "",
...@@ -469,8 +467,6 @@ export default { ...@@ -469,8 +467,6 @@ export default {
const packages = (series.packageList || []).map(item => ({ const packages = (series.packageList || []).map(item => ({
...item, ...item,
productType: 0, productType: 0,
// 套餐字段映射:优先使用 packageId(接口返回字段),其次 packageCode
packageId: item.packageId || item.packageCode,
packageName: item.packageName || "", packageName: item.packageName || "",
tabName: item.tabName || "", tabName: item.tabName || "",
packageCode: item.packageCode || "", packageCode: item.packageCode || "",
...@@ -644,10 +640,10 @@ export default { ...@@ -644,10 +640,10 @@ export default {
const currentPackages = this.seriesPackages[seriesId] || []; const currentPackages = this.seriesPackages[seriesId] || [];
this.tempSelectedItems = currentPackages.map((item) => { this.tempSelectedItems = currentPackages.map((item) => {
if (item.productType === 0) { if (item.productType === 0) {
// 套餐:优先使用 packageId(来自选择弹窗接口数据),其次尝试 packageCode 或 code // 套餐
return { return {
...item, ...item,
packageId: item.packageId || item.packageCode || item.code, packageCode: item.packageCode,
productType: 0, productType: 0,
productName: item.packageName || item.productName || "", productName: item.packageName || item.productName || "",
}; };
...@@ -671,18 +667,18 @@ export default { ...@@ -671,18 +667,18 @@ export default {
return; return;
} }
// 按车系模式:用 packageId/goodsCode 做唯一匹配,保留已编辑数据 // 按车系模式:用 packageCode/goodsCode 做唯一匹配,保留已编辑数据
const existingList = this.seriesPackages[this.currentSeriesId] || []; const existingList = this.seriesPackages[this.currentSeriesId] || [];
const existingMap = {}; const existingMap = {};
existingList.forEach((item) => { existingList.forEach((item) => {
const key = item.productType == 0 ? (item.packageId) : (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) => {
// 唯一匹配key:套餐用 packageId,商品用 goodsCode // 唯一匹配key:套餐用 packageCode,商品用 goodsCode
const matchKey = item.productType === 0 ? (item.packageId) : item.goodsCode; const matchKey = item.productType === 0 ? (item.packageCode) : item.goodsCode;
if (matchKey && existingMap[matchKey]) { if (matchKey && existingMap[matchKey]) {
// 已存在:保留原有编辑数据,但同步最新门店数 // 已存在:保留原有编辑数据,但同步最新门店数
const merged = { ...existingMap[matchKey] }; const merged = { ...existingMap[matchKey] };
...@@ -748,17 +744,17 @@ export default { ...@@ -748,17 +744,17 @@ export default {
// 执行添加直接模式套餐/商品(公共逻辑) // 执行添加直接模式套餐/商品(公共逻辑)
doAddDirectPackages(selectedItems) { doAddDirectPackages(selectedItems) {
// 用 packageId/goodsCode 做唯一匹配,保留已编辑数据 // 用 packageCode/goodsCode 做唯一匹配,保留已编辑数据
const existingMap = {}; const existingMap = {};
this.directPackages.forEach((item) => { this.directPackages.forEach((item) => {
const key = item.productType === 0 ? (item.packageId || item.packageCode || item.code) : (item.goodsCode || item.code); 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) => {
// 唯一匹配key:套餐用 packageId,商品用 goodsCode // 唯一匹配key:套餐用 packageCode,商品用 goodsCode
const matchKey = item.productType === 0 ? (item.packageId || item.packageCode) : item.goodsCode; const matchKey = item.productType === 0 ? (item.packageCode) : item.goodsCode;
if (matchKey && existingMap[matchKey]) { if (matchKey && existingMap[matchKey]) {
// 已存在:保留原有编辑数据,但同步最新门店数 // 已存在:保留原有编辑数据,但同步最新门店数
const merged = { ...existingMap[matchKey] }; const merged = { ...existingMap[matchKey] };
...@@ -1073,7 +1069,7 @@ export default { ...@@ -1073,7 +1069,7 @@ export default {
productType: 0, productType: 0,
productName: item.packageName || item.productName, productName: item.packageName || item.productName,
productAlias: item.productAlias, productAlias: item.productAlias,
packageCode: item.packageId, packageCode: item.packageCode,
sortOrder: i + 1, sortOrder: i + 1,
tabName: item.tabName, tabName: item.tabName,
tabDescription: item.tabDescription, tabDescription: item.tabDescription,
...@@ -1174,10 +1170,10 @@ export default { ...@@ -1174,10 +1170,10 @@ export default {
return; return;
} }
this.currentSeriesId = ""; // 标记为直接模式 this.currentSeriesId = ""; // 标记为直接模式
// 提取原始标识字段用于弹窗回显,确保 packageId/goodsCode 字段存在 // 提取原始标识字段用于弹窗回显,确保 packageCode/goodsCode 字段存在
this.tempSelectedItems = (this.directPackages || []).map((item) => { this.tempSelectedItems = (this.directPackages || []).map((item) => {
if (item.productType === 0) { if (item.productType === 0) {
return { ...item, productType: 0, packageId: item.packageId || item.packageCode || item.code, productName: item.packageName || item.productName || "" }; return { ...item, productType: 0, packageCode: item.packageCode, productName: item.packageName || item.productName || "" };
} }
return { ...item, productType: 1, goodsCode: item.goodsCode || item.code, productName: item.productName || "" }; return { ...item, productType: 1, goodsCode: item.goodsCode || item.code, productName: item.productName || "" };
}); });
......
...@@ -54,14 +54,14 @@ ...@@ -54,14 +54,14 @@
<!-- 手风琴列表(Sortable 拖拽整个 item) --> <!-- 手风琴列表(Sortable 拖拽整个 item) -->
<el-collapse v-model="activeNames" class="package-collapse"> <el-collapse v-model="activeNames" class="package-collapse">
<el-collapse-item v-for="(pkg, index) in localList" <el-collapse-item v-for="(pkg, index) in localList"
:key="pkg.packageId" :key="pkg.packageCode"
class="package-item" class="package-item"
:name="pkg.packageId"> :name="pkg.packageCode">
<!-- 标题行:模拟表格的一行数据 --> <!-- 标题行:模拟表格的一行数据 -->
<template slot="title"> <template slot="title">
<div class="collapse-row" <div class="collapse-row"
:class="{ 'is-expanded': activeNames.includes(pkg.packageId) }" :class="{ 'is-expanded': activeNames.includes(pkg.packageCode) }"
@click.stop @click.stop
@keydown.stop @keydown.stop
@keyup.stop> @keyup.stop>
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
</span> </span>
<span class="col col-index" <span class="col col-index"
style="cursor: pointer;" style="cursor: pointer;"
@click.stop="toggleExpand(pkg.packageId)"> @click.stop="toggleExpand(pkg.packageCode)">
<i :class="[activeNames.includes(pkg.packageId) ? 'el-icon-arrow-down' : 'el-icon-arrow-right']"></i> <i :class="[activeNames.includes(pkg.packageCode) ? 'el-icon-arrow-down' : 'el-icon-arrow-right']"></i>
{{ index + 1 }} {{ index + 1 }}
</span> </span>
<span class="col col-name" <span class="col col-name"
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
size="mini" size="mini"
:class="{ 'is-error': pkg.tabNameError }" :class="{ 'is-error': pkg.tabNameError }"
@input="clearError(pkg, 'tabNameError')" /> @input="clearError(pkg, 'tabNameError')" />
<div class="sub-text">{{ pkg.packageId }}</div> <div class="sub-text">{{ pkg.packageCode }}</div>
</span> </span>
<span class="col col-tabDescription" <span class="col col-tabDescription"
@keydown.stop @keydown.stop
...@@ -223,7 +223,7 @@ ...@@ -223,7 +223,7 @@
</template> </template>
<!-- 展开内容:子商品 div 模拟表格 --> <!-- 展开内容:子商品 div 模拟表格 -->
<div v-loading="packageLoadingMap[pkg.packageId]" <div v-loading="packageLoadingMap[pkg.packageCode]"
class="collapse-content"> class="collapse-content">
<!-- 子商品表头 --> <!-- 子商品表头 -->
<div class="sub-table-header"> <div class="sub-table-header">
...@@ -325,35 +325,35 @@ export default { ...@@ -325,35 +325,35 @@ export default {
* 切换套餐项展开/收起(只有点击箭头/排序号区域才触发) * 切换套餐项展开/收起(只有点击箭头/排序号区域才触发)
* 展开时若套餐无子商品数据,自动请求接口获取 * 展开时若套餐无子商品数据,自动请求接口获取
*/ */
toggleExpand(packageId) { toggleExpand(packageCode) {
const idx = this.activeNames.indexOf(packageId); const idx = this.activeNames.indexOf(packageCode);
if (idx > -1) { if (idx > -1) {
this.activeNames.splice(idx, 1); this.activeNames.splice(idx, 1);
} else { } else {
this.activeNames.push(packageId); this.activeNames.push(packageCode);
// 展开时检查是否需要加载子商品 // 展开时检查是否需要加载子商品
this.loadPackageProducts(packageId); this.loadPackageProducts(packageCode);
} }
}, },
/** /**
* 加载套餐子商品数据(每次展开时调用,合并新旧数据保留用户输入) * 加载套餐子商品数据(每次展开时调用,合并新旧数据保留用户输入)
*/ */
loadPackageProducts(packageId) { loadPackageProducts(packageCode) {
const idx = this.localList.findIndex(p => p.packageId === packageId); 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.packageId) if (!pkg.packageCode)
return; return;
// 设置loading状态 // 设置loading状态
this.$set(this.packageLoadingMap, packageId, true); this.$set(this.packageLoadingMap, packageCode, true);
// 保存旧的子商品数据(用于合并) // 保存旧的子商品数据(用于合并)
const oldItems = pkg.packageItems || []; const oldItems = pkg.packageItems || [];
getGoodsDataByPackage({ packageId: pkg.packageId }).then((res) => { getGoodsDataByPackage({ packageId: pkg.packageCode }).then((res) => {
if (!res || !res.length) { if (!res || !res.length) {
// 如果新数据为空,清空子商品列表 // 如果新数据为空,清空子商品列表
pkg.packageItems = []; pkg.packageItems = [];
...@@ -385,7 +385,7 @@ export default { ...@@ -385,7 +385,7 @@ export default {
pkg.packageItems = mergedItems; pkg.packageItems = mergedItems;
}).finally(() => { }).finally(() => {
// 清除loading状态 // 清除loading状态
this.$set(this.packageLoadingMap, packageId, false); this.$set(this.packageLoadingMap, packageCode, false);
}); });
}, },
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
label="套餐ID" label="套餐ID"
width="200"> width="200">
<template #default="scope"> <template #default="scope">
{{ emptyFilter(scope.row.packageId) }} {{ emptyFilter(scope.row.packageCode) }}
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
套餐 ({{ packageItems.length }}) 套餐 ({{ packageItems.length }})
</div> </div>
<div v-for="(item, index) in packageItems" <div v-for="(item, index) in packageItems"
:key="`pkg_${item.packageId || index}`" :key="`pkg_${item.packageCode || index}`"
class="selected-item"> class="selected-item">
<div class="item-info"> <div class="item-info">
<div class="item-name"> <div class="item-name">
...@@ -437,8 +437,9 @@ export default { ...@@ -437,8 +437,9 @@ export default {
const tabKey = isPackage ? "package" : "product"; const tabKey = isPackage ? "package" : "product";
eventRequest(params) eventRequest(params)
.then((res) => { .then((res) => {
const savedIds = (this.selectedMap[tabKey] || []).map(item => (isPackage ? item.packageId : item.goodsCode)); const savedIds = (this.selectedMap[tabKey] || []).map(item => (isPackage ? item.packageCode : item.goodsCode));
res?.list?.forEach((val) => { res?.list?.forEach((val) => {
val.packageCode = val.packageId;
val.productName = val.productName || val.packageName; val.productName = val.productName || val.packageName;
val.upgradeProductId = val.productId; val.upgradeProductId = val.productId;
}); });
...@@ -448,7 +449,7 @@ export default { ...@@ -448,7 +449,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.tableRef) { if (this.$refs.tableRef) {
this.tableData.forEach((row) => { this.tableData.forEach((row) => {
if (savedIds.includes(isPackage ? row.packageId : row.goodsCode)) { if (savedIds.includes(isPackage ? row.packageCode : row.goodsCode)) {
this.$refs.tableRef.toggleRowSelection(row, true); this.$refs.tableRef.toggleRowSelection(row, true);
} }
}); });
...@@ -489,7 +490,7 @@ export default { ...@@ -489,7 +490,7 @@ export default {
return; return;
} }
const isPackage = this.activeTab === "0"; const isPackage = this.activeTab === "0";
const idField = isPackage ? "packageId" : "goodsCode"; const idField = isPackage ? "packageCode" : "goodsCode";
const tabKey = isPackage ? "package" : "product"; const tabKey = isPackage ? "package" : "product";
// 当前页所有数据的 id 集合 // 当前页所有数据的 id 集合
const currentPageIds = this.tableData.map(row => row[idField]); const currentPageIds = this.tableData.map(row => row[idField]);
...@@ -511,13 +512,13 @@ export default { ...@@ -511,13 +512,13 @@ export default {
// 移除已选项 // 移除已选项
handleRemoveItem(item) { handleRemoveItem(item) {
const tab = item.productType === 0 ? "package" : "product"; const tab = item.productType === 0 ? "package" : "product";
const idx = this.selectedMap[tab].findIndex(s => tab === "package" ? s.packageId === item.packageId : s.goodsCode === item.goodsCode); const idx = this.selectedMap[tab].findIndex(s => tab === "package" ? s.packageCode === item.packageCode : s.goodsCode === item.goodsCode);
if (idx === -1) if (idx === -1)
return; return;
this.selectedMap[tab].splice(idx, 1); this.selectedMap[tab].splice(idx, 1);
// 取消表格中的选中状态 // 取消表格中的选中状态
this.$nextTick(() => { this.$nextTick(() => {
const row = this.tableData.find(s => tab === "package" ? s.packageId === item.packageId : s.goodsCode === item.goodsCode); const row = this.tableData.find(s => tab === "package" ? s.packageCode === item.packageCode : s.goodsCode === item.goodsCode);
if (row && this.$refs.tableRef) { if (row && this.$refs.tableRef) {
this.$refs.tableRef.toggleRowSelection(row, false); this.$refs.tableRef.toggleRowSelection(row, false);
} }
......
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
getMerchantData() { getMerchantData() {
const params = { const params = {
goodsCode: this.storeRow.goodsCode, goodsCode: this.storeRow.goodsCode,
packageCode: this.storeRow.packageId, packageCode: this.storeRow.packageCode,
activityId: this.storeRow?.activityId, activityId: this.storeRow?.activityId,
merchantIds: this.merchantList?.map((val) => { merchantIds: this.merchantList?.map((val) => {
return val.merchantId; return val.merchantId;
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<div class="card-content"> <div class="card-content">
<!-- ========== 直接选择模式:套餐+商品都有时显示子tab ========== --> <!-- ========== 直接选择模式:套餐+商品都有时显示子tab ========== -->
<template v-if="detailData.configMode === 'direct' && directSplit.packages.length && directSplit.products.length"> <template v-if="detailData.configMode === 'direct' && directSplit.packages && directSplit.packages.length && directSplit.products && directSplit.products.length">
<el-tabs v-model="directSubActiveTab" class="sub-tabs direct-sub-tabs"> <el-tabs v-model="directSubActiveTab" class="sub-tabs direct-sub-tabs">
<el-tab-pane name="direct_package"> <el-tab-pane name="direct_package">
<template #label> <template #label>
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
</template> </template>
<!-- 直接模式:只有套餐或只有商品 --> <!-- 直接模式:只有套餐或只有商品 -->
<template v-else-if="detailData.configMode === 'direct' && detailData.directPackages.length"> <template v-else-if="detailData.configMode === 'direct' && detailData.directPackages && detailData.directPackages.length">
<MixedDetailTable :list="detailData.directPackages" /> <MixedDetailTable :list="detailData.directPackages" />
</template> </template>
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
:name="String(series.carSeriesId)"> :name="String(series.carSeriesId)">
<!-- 该车系同时有套餐和商品:显示子tabs --> <!-- 该车系同时有套餐和商品:显示子tabs -->
<template v-if="series.packageList.length && series.goodsList.length"> <template v-if="series.packageList && series.packageList.length && series.goodsList && series.goodsList.length">
<el-tabs class="sub-tabs" :value="getSeriesSubTabId(series.carSeriesId)"> <el-tabs class="sub-tabs" :value="getSeriesSubTabId(series.carSeriesId)">
<el-tab-pane :name="`package_${series.carSeriesId}`"> <el-tab-pane :name="`package_${series.carSeriesId}`">
<template #label> <template #label>
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
<!-- 该车系只有套餐或只有商品:单表展示 --> <!-- 该车系只有套餐或只有商品:单表展示 -->
<template v-else> <template v-else>
<MixedDetailTable :list="series.packageList.length ? series.packageList : series.goodsList.length ? series.goodsList : []" /> <MixedDetailTable :list="series.packageList && series.packageList.length ? series.packageList : series.goodsList && series.goodsList.length ? series.goodsList : []" />
</template> </template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -426,6 +426,7 @@ export default { ...@@ -426,6 +426,7 @@ export default {
getActivityCarSeries() { getActivityCarSeries() {
this.startLoading(); this.startLoading();
getMarketingActivityCarSeries({ activityId: this.activityId, includeDetail: true, pageSize: 999 }).then((res) => { getMarketingActivityCarSeries({ activityId: this.activityId, includeDetail: true, pageSize: 999 }).then((res) => {
console.log(res, "222222");
this.activeSeriesId = String(res?.[0]?.carSeriesId || ""); this.activeSeriesId = String(res?.[0]?.carSeriesId || "");
this.detailData.seriesList = res || []; this.detailData.seriesList = res || [];
}).finally(() => this.endLoading()); }).finally(() => this.endLoading());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!