Commit 4ef2b838 by Jaxon

feat(绩效方案): 新增商品品类"全部"选项并重构商品选择组件

- 在商品品类选择器中新增"全部"选项,支持全品类选择
- 重构商品选择逻辑,将ProductDefineCascader和GoodsCategoryCascader整合到ProductCascader组件中
- 优化品类选择禁用逻辑,防止"全部"选项与其他选项同时选择
- 修复前后端数据转换中商品配置类型为-1时的处理逻辑
- 更新商品品类选择器的数据来源,使用Vuex getter统一管理
1 parent 417fcbd8
......@@ -4249,7 +4249,7 @@
"dependencies": {
"@vue/vue-loader-v15": {
"version": "npm:vue-loader@15.11.1",
"resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-15.11.1.tgz",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.11.1.tgz",
"integrity": "sha512-0iw4VchYLePqJfJu9s62ACWUXeSqM30SQqlIftbYWM3C+jpPcEHKSPUZBLjSF9au4HTHQ/naF6OGnO3Q/qGR3Q==",
"dev": true,
"requires": {
......@@ -4262,7 +4262,7 @@
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/hash-sum/-/hash-sum-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha512-fUs4B4L+mlt8/XAtSOGMUO1TXmAelItBPtJG7CyHJfYTdDjwisntGO2JQz7oUsatOY9o68+57eziUVNw/mRHmA==",
"dev": true
}
......@@ -13557,7 +13557,7 @@
},
"json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmmirror.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"dev": true
},
......@@ -13856,7 +13856,7 @@
},
"lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmmirror.com/lodash.merge/-/lodash.merge-4.6.2.tgz",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
......@@ -19445,7 +19445,7 @@
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
"integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==",
"dev": true
},
......
<template>
<div class="">
<el-cascader clearable
:options="getOptions"
:options="getGoodsCategory"
placeholder="请选择商品品类"
:props="{ checkStrictly: true, label: 'categoryName', value: 'categoryType' }"
:show-all-levels="false"
......@@ -12,8 +12,7 @@
</template>
<script>
import { mapState } from "vuex";
import { bizAdaptationOptionsEnum } from "../../utils/enum.js";
import { mapGetters, mapState } from "vuex";
export default {
name: "",
......@@ -34,9 +33,7 @@ export default {
},
computed: {
...mapState("PerformanceFormStore", ["formData", "options"]),
getOptions() {
return this.options[bizAdaptationOptionsEnum[this.formData.businessType]] || [];
},
...mapGetters("PerformanceFormStore", ["getGoodsCategory"]),
},
mounted() {
......
......@@ -81,16 +81,15 @@
<el-form-item :prop="`paramConfigList.${configIndex}.ParamsType1Products.${index}.productLabel`"
:rules="[
{ required: true, trigger: 'blur', message: '商品不能为空' },
{
validator: validGoodsCategory,
trigger: 'blur',
tableIndex: configIndex,
rowIndex: index,
templateType: 'ParamsType1Products',
},
]">
<GoodsCategoryCascader v-if="goodsCategory === 0"
<ProductCascader v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:config-index="configIndex"
:row-index="index"
:use-goods-cascader-type="goodsCategory === 0"
@change="handleProductChange" />
<!-- <GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:goods-category="goodsCategory"
@change="handleProductChange" />
......@@ -103,7 +102,7 @@
:props="{ checkStrictly: true }"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader>
</el-cascader> -->
</el-form-item>
<el-button style="position: absolute;right:6px;top:50%; transform: translate(0, -50%);padding:0"
......@@ -152,12 +151,14 @@ import EditableText from "@/components/editableText/index.vue";
import { validGoodsCategory, validPriceRange } from "../../utils/rules.js";
import GoodsCategoryCascader from "../goodsCategoryCascader/index.vue";
import { assessmentFactorOptions, commissionTypeEnum } from "../performanceRuleSelection/options";
import ProductCascader from "../productCascader/index.vue";
export default {
name: "",
components: {
EditableText,
GoodsCategoryCascader,
ProductCascader,
},
props: {
......
......@@ -3,7 +3,6 @@
<el-cascader clearable
:options="computedOptions"
placeholder="请选择"
:props="{ checkStrictly: true }"
:show-all-levels="false"
:value="value"
@change="handleProductChange">
......@@ -14,6 +13,12 @@
<script>
import { mapGetters, mapState } from "vuex";
// <!-- 圈定套餐/商品 cascader -->
// <ProductDefineCascader v-else
// v-model=" curParamsConfig.ParamsType1Products[index] .productLabel "
// :config-index="configIndex"
// :index="index" />
export default {
name: "ProductDefineCascader",
props: {
......
<template>
<div class="">
<el-cascader clearable
:options="computedGoodsCategory"
placeholder="请选择商品品类"
:props="{
checkStrictly: true,
label: 'categoryName',
value: 'categoryType',
}"
:show-all-levels="false"
:value="value"
@change="handleProductChange"
@visible-change="handleVisibleChange">
</el-cascader>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
name: "GoodsCategoryCascader",
props: {
value: {
type: Array,
default: () => [],
},
/**
* Config Index in formData.paramConfigList
* Used to isolate the scope of disabled checks to the current assessment factor table.
*/
configIndex: {
type: Number,
default: undefined,
},
/**
* Index of the current item in the list (ParamsType1Products or ParamsType2)
* Used to identify "self" to avoid filtering out other identical selections.
*/
index: {
type: Number,
default: undefined,
},
/**
* Whether to allow duplicate selections.
* true: Allows duplicate selections within the same table, but still prevents containment relationships.
* false: Globally unique within the table (no duplicates, no containment).
*/
allowRepeat: {
type: Boolean,
default: false,
},
/**
* Value of the "All" option.
* If this value is encountered, it is treated as containing everything.
*/
allValue: {
type: [String, Number],
default: -1,
},
/**
* Business type to determine the data source.
* 0: lightModification
* 1: benefitProduct
* 2: extendedWarrantyProduct
*/
businessType: {
type: Number,
default: 0,
},
/**
* Path to the value in the item object.
* Supports dot notation for nested paths (e.g., "conditionType4.productValue").
*/
valuePath: {
type: String,
default: "productLabel",
},
/**
* List of all value paths to check for conflicts in the same row.
* If not provided, defaults to [valuePath].
*/
conflictPaths: {
type: Array,
default: () => [],
},
},
data() {
return {
visible: false,
};
},
computed: {
...mapState("PerformanceFormStore", [
"formData",
"options",
]),
...mapGetters("PerformanceFormStore", [
"getGoodsCategory",
]),
occupiedPaths() {
const paths = [];
if (this.configIndex == null) {
console.warn("configIndex必传", this.configIndex);
return [];
}
const table = this.formData.paramConfigList[this.configIndex];
if (!table) {
console.warn("table找不到", this.configIndex);
return [];
}
// Determine check paths
const pathsToCheck
= this.conflictPaths && this.conflictPaths.length > 0
? this.conflictPaths
: [this.valuePath];
// Type 1
if (table.templateType === "ParamsType1") {
table.ParamsType1Products.forEach((item, itemIdx) => {
pathsToCheck.forEach((path) => {
// Skip self: matches both index and path
if (itemIdx === this.index) {
return;
}
const val = this.getValueByPath(item, path);
if (Array.isArray(val) && val.length > 0) {
paths.push(val);
}
});
});
}
// Type 2
if (table.templateType === "ParamsType2") {
table.ParamsType2.forEach((item, itemIdx) => {
pathsToCheck.forEach((path) => {
// Skip self: matches both index and path
if (itemIdx === this.index) {
return;
}
const val = this.getValueByPath(item, path);
if (Array.isArray(val) && val.length > 0) {
paths.push(val);
}
});
});
}
return paths;
},
computedGoodsCategory() {
// Fast path: if no source data, return empty
const occupiedPaths = this.occupiedPaths;
const allValue = this.allValue;
const myValue = this.value || [];
// Check if I have selected "All" (Local Lock)
const iHaveAll = myValue.length === 1 && myValue[0] == allValue;
// Check if I have selected something else (Local Lock)
const iHaveOthers = myValue.length > 0 && !iHaveAll;
// Check if "All" is selected by anyone else (Global Lock)
const hasAllSelectedByOthers = occupiedPaths.some(
path => path.length === 1 && path[0] == allValue,
);
const process = (nodes, parentPath) => {
return nodes.map((node) => {
// Build path for current node
const currentPath = parentPath
? [...parentPath, node.categoryType]
: [node.categoryType];
// Check if this node is "All" (loose equality)
const isAllNode = node.categoryType == allValue;
let isDisabled = !!node.disabled;
if (isAllNode) {
// 1. If I have selected "Others", "All" is disabled
if (iHaveOthers) {
isDisabled = true;
}
// 2. If others have selected "All", check allowRepeat
else if (hasAllSelectedByOthers) {
isDisabled = !this.allowRepeat;
}
// 3. If any other items are occupied (by others), "All" is disabled
else {
const hasOthersOccupied = occupiedPaths.some(
path =>
!(path.length === 1 && path[0] == allValue),
);
if (hasOthersOccupied) {
isDisabled = true;
}
}
} else {
// Logic for "Other" Nodes
// 1. If I have selected "All", "Others" are disabled
if (iHaveAll) {
isDisabled = true;
}
// 2. If others have selected "All", "Others" are disabled
else if (hasAllSelectedByOthers) {
isDisabled = true;
}
// 3. Standard containment check against occupiedPaths
else {
isDisabled = occupiedPaths.some((occupied) => {
const len = Math.min(
currentPath.length,
occupied.length,
);
// Check for prefix match
let isPrefixMatch = true;
for (let i = 0; i < len; i++) {
if (currentPath[i] != occupied[i]) {
isPrefixMatch = false;
break;
}
}
if (isPrefixMatch) {
// If strict containment (lengths differ) -> Parent/Child conflict
if (
currentPath.length !== occupied.length
) {
return true;
}
// If exact match (lengths same) -> Duplicate
return !this.allowRepeat;
}
return false;
});
}
}
const newNode = {
...node,
disabled: isDisabled,
};
if (newNode.children && newNode.children.length > 0) {
newNode.children = process(
newNode.children,
currentPath,
);
}
return newNode;
});
};
return process(this.getGoodsCategory, null);
},
},
mounted() {},
methods: {
getValueByPath(obj, path) {
if (!obj || !path)
return undefined;
const keys = path.split(".");
let result = obj;
for (const key of keys) {
if (result === null || result === undefined)
return undefined;
result = result[key];
}
return result;
},
handleProductChange(value) {
this.$emit("input", value);
this.$emit("change", value);
},
handleVisibleChange(isVisible) {
this.visible = isVisible;
},
},
};
</script>
<template>
<el-cascader clearable
:options="computedOptions"
placeholder="请选择"
:show-all-levels="false"
:value="value"
@change="handleProductChange">
</el-cascader>
</template>
<script>
import { mapGetters, mapState } from "vuex";
// <!-- 圈定套餐/商品 cascader -->
// <ProductDefineCascader v-else
// v-model=" curParamsConfig.ParamsType1Products[index] .productLabel "
// :config-index="configIndex"
// :index="index" />
export default {
name: "ProductDefineCascader",
props: {
value: {
type: Array,
default: () => [],
},
/**
* Config Index in formData.paramConfigList
* Used to isolate the scope of disabled checks to the current assessment factor table.
*/
configIndex: {
type: Number,
require: true,
},
/**
* Index of the current item in the list
* Used to identify "self" to avoid filtering out other identical selections.
*/
index: {
type: Number,
require: true,
},
/**
* Whether to allow duplicate selections.
*/
allowRepeat: {
type: Boolean,
default: false,
},
/**
* Value of the "All" option.
*/
allValue: {
type: [String, Number],
default: -1,
},
/**
* Custom label/value field names
*/
/**
* Path to the value in the item object.
* Supports dot notation for nested paths (e.g., "conditionType4.productValue").
*/
valuePath: {
type: String,
default: "productLabel",
},
/**
* List of all value paths to check for conflicts in the same row.
* If not provided, defaults to [valuePath].
*/
conflictPaths: {
type: Array,
default: () => [],
},
},
data() {
return {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
...mapGetters("PerformanceFormStore", ["getProductDefineListOptions"]),
occupiedPaths() {
const paths = [];
if (this.configIndex == null) {
console.warn("configIndex必传", this.configIndex);
return [];
}
const table = this.formData.paramConfigList[this.configIndex];
if (!table) {
console.warn("table找不到", this.configIndex);
return [];
}
// Determine check paths
// Type 1
if (table.templateType === "ParamsType1") {
table.ParamsType1Products.forEach((item, itemIdx) => {
// Skip self
if (itemIdx === this.index) {
return;
}
const val = item.productLabel;
if (Array.isArray(val) && val.length > 0) {
paths.push(val);
}
});
}
// Type 2
if (table.templateType === "ParamsType2") {
table.ParamsType2.forEach((item, itemIdx) => {
// Skip self
if (itemIdx === this.index) {
return;
}
const val = item.productLabel;
if (Array.isArray(val) && val.length > 0) {
paths.push(val);
}
});
}
return paths;
},
hasAll() {
return this.occupiedPaths.some(path => path[0] === this.allValue);
},
computedOptions() {
if (!this.getProductDefineListOptions || !this.getProductDefineListOptions.length)
return [];
// 提取其他行已选的值(由于是一列,取 path[0])
const otherSelectedValues = this.occupiedPaths.map(path => path[0]);
return this.getProductDefineListOptions.map((item) => {
let isDisabled = !!item.disabled;
// 需求1:如果其他行选择了“全部”,则当前行所有选项禁用
if (this.hasAll) {
isDisabled = true;
}
// 需求2:如果其他行选择了当前选项,则禁用当前选项
if (otherSelectedValues.includes(item.value)) {
isDisabled = true;
}
// 返回新对象,避免修改 Vuex 中的原始数据
return {
...item,
disabled: isDisabled,
};
});
},
},
mounted() {},
methods: {
handleProductChange(value) {
this.$emit("input", value);
this.$emit("change", value);
},
},
};
</script>
<template>
<div class="">
<!-- <GoodsCategoryCascader v-if="useGoodsCascaderType"
v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:goods-category="goodsCategory"
<GoodsCategoryCascader v-if="useGoodsCascaderType"
:business-type="formData.businessType"
:config-index="configIndex"
:index="rowIndex"
:value="value"
@change="handleProductChange" />
<el-cascader v-else
v-model="curParamsConfig.ParamsType1Products[index].productLabel"
clearable
:options="productDefineListOptions"
:placeholder="goodsCategory === 2 ? '请选择' : '请选择圈定商品/套餐'"
:props="{ checkStrictly: true }"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader> -->
<!-- 圈定套餐/商品 cascader -->
<ProductDefine v-else
:config-index="configIndex"
:index="rowIndex"
:value="value"
@change="handleProductChange" />
</div>
</template>
<script>
import { mapState } from "vuex";
import GoodsCategoryCascader from "./components/goodsCategoryCascader/index.vue";
import ProductDefine from "./components/productDefine/index.vue";
export default {
name: "",
components: {
ProductDefine,
GoodsCategoryCascader,
},
props: {
value: {
type: Array,
......@@ -29,6 +37,14 @@ export default {
type: Boolean,
default: false,
},
configIndex: {
type: Number,
require: true,
},
rowIndex: {
type: Number,
require: true,
},
},
data() {
......@@ -37,12 +53,18 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", {
formData: "formData",
}),
},
mounted() {
},
methods: {
handleProductChange(value) {
this.$emit("input", value);
this.$emit("change", value);
},
},
};
......
......@@ -3,6 +3,7 @@ import { getPerformanceConfigDetailAPI, getTargetProductConfigListAPI, postSalar
import { normalizeTree } from "@/common/treeData";
import { baseConfig } from "@/main";
import { commissionTypeEnum, paramConfigListTemplate, assessmentFactorOptions as staticAssessmentFactorOptions } from "../components/performanceRuleSelection/options.js";
import { bizAdaptationOptionsEnum, categoryAll } from "../utils/enum.js";
import { buildMerchantBrandPayload, convertDataToBackend } from "../utils/index.js";
export default {
......@@ -69,7 +70,24 @@ export default {
// 直接返回根级的 merchantBrandRefList
return state.merchantBrandRefList;
},
getGoodsCategory(state) {
const options = state.options[bizAdaptationOptionsEnum[state.formData.businessType]];
if (!options) {
return [];
}
if (!options.length) {
return [];
}
return [structuredClone(categoryAll), ...options];
},
getProductDefineListOptions(state) {
if (!state.formData.goodsConfigTypes) {
return [];
}
if (!state.formData.goodsConfigTypes.includes("1")) {
return [];
}
return state.productDefineList.map(item => ({
label: item.label,
value: item.value,
......@@ -102,7 +120,6 @@ export default {
// 设置商品分类
setProductDefineList(state, productDefineList) {
const data = normalizeTree(productDefineList);
data.unshift({ label: "全部", value: -1, leaf: false });
state.productDefineList = data;
},
......
......@@ -87,8 +87,11 @@ export function coverParamConfigList(paramConfigList) {
productValue: [],
optionList: [],
};
console.log("firstColItem", firstColItem);
if ([1, 2].includes(firstColItem.goodsConfigType)) {
firstColItem.productDefineId && paramsTypeProductsItem.productLabel.push(firstColItem.productDefineId);
} else if (firstColItem.goodsConfigType === -1) {
paramsTypeProductsItem.productLabel = [-1];
} else {
setBackendGoods(firstColItem, paramsTypeProductsItem);
}
......@@ -121,7 +124,12 @@ export function coverParamConfigList(paramConfigList) {
priceRange: [rowItem.startValue, rowItem.endValue],
productLabel: [],
};
setBackendAllGoods(rowItem, paramsType2Item);
if (rowItem.goodsConfigType === -1) {
paramsType2Item.productLabel = [-1];
} else {
console.log("rowItem", rowItem);
setBackendAllGoods(rowItem, paramsType2Item);
}
if (conditionType === 0) {
paramsType2Item.conditionType0 = rowItem.commissionTypeValue;
......@@ -130,7 +138,11 @@ export function coverParamConfigList(paramConfigList) {
triggerCondition: rowItem.commissionTypeValue,
productValue: [],
};
setBackendConditionGoods(rowItemParamConfig[0], paramsType2Item[conditionKey], "productValue");
if (rowItem.goodsConfigType === -1) {
paramsType2Item[conditionKey].productValue = [-1];
} else {
setBackendConditionGoods(rowItemParamConfig[0], paramsType2Item[conditionKey], "productValue");
}
// 到这里 conditionType4 已经解决
if (conditionType === 3) {
......@@ -153,12 +165,15 @@ export function coverParamConfigList(paramConfigList) {
paramsType2Item[conditionKey].permeabilityMin = rowItemParamConfig[0].conditionStartValue;
paramsType2Item[conditionKey].permeabilityMax = rowItemParamConfig[0].conditionEndValue;
paramsType2Item[conditionKey].productValue = [];
setBackendConditionGoods(rowItemParamConfig[0], paramsType2Item[conditionKey], "productValue");
paramsType2Item[conditionKey].productValue1 = [];
setBackendConditionGoods(rowItemParamConfig[1], paramsType2Item[conditionKey], "productValue1");
console.log("rowItemParamConfig[1].conditionStartValue", rowItemParamConfig[1].conditionStartValue);
if (rowItem.goodsConfigType === -1) {
paramsType2Item[conditionKey].productValue = [-1];
paramsType2Item[conditionKey].productValue1 = [-1];
} else {
setBackendConditionGoods(rowItemParamConfig[0], paramsType2Item[conditionKey], "productValue");
setBackendConditionGoods(rowItemParamConfig[1], paramsType2Item[conditionKey], "productValue1");
}
paramsType2Item[conditionKey].permeabilityMin1 = rowItemParamConfig[1].conditionStartValue === null ? undefined : rowItemParamConfig[1].conditionStartValue;
paramsType2Item[conditionKey].permeabilityMax1 = rowItemParamConfig[1].conditionEndValue === null ? undefined : rowItemParamConfig[1].conditionEndValue;
}
......@@ -166,6 +181,10 @@ export function coverParamConfigList(paramConfigList) {
baseTable.ParamsType2.push(paramsType2Item);
}
});
if (baseTable.goodsCategory === -1) {
baseTable.goodsCategory = 0;
}
_paramConfigList.push(baseTable);
}
}
......
......@@ -7,3 +7,8 @@ export const bizAdaptationOptionsEnum = {
// 权益
1: "benefitProduct",
};
export const categoryAll = {
categoryType: -1,
categoryName: "全部",
};
......@@ -8,12 +8,11 @@ const commissionTypesCoverCommissionBase = {
GDJE: "SJDDS",
};
export function convertDataToBackend(formData) {
const goodsOptions = store.state.PerformanceFormStore.options;
const productDefineList = store.state.PerformanceFormStore.productDefineList;
console.log("store.getters", store.getters);
const productDefineList = store.getters["PerformanceFormStore/getProductDefineListOptions"];
const goodsCategory = store.getters["PerformanceFormStore/getGoodsCategory"];
const { paramConfigList, merchantBrandRefList, ...data } = formData;
const goodsCategory = goodsOptions[bizAdaptationOptionsEnum[data.businessType]];
const requestData = {
// 注意是scheme
......@@ -40,35 +39,47 @@ export function convertDataToBackend(formData) {
if (templateType === "ParamsType1") {
// 处理ParamsType1 类型的表格
coverParamsType1(ParamsType1, ParamsType1Products, (item, { rowItem, row }, { productColItem, colIndex }) => {
requestData.paramConfigList.push({
const table = {
...item,
assessmentFactor: paramConfig.assessmentFactorOptions.value,
goodsConfigType: paramConfig.goodsCategory,
commissionTypeValue: productColItem.productValue[row],
...paramConfig.goodsCategory === 0
};
console.log("paramConfig.ParamsType1Products[colIndex].productLabel");
if (paramConfig.ParamsType1Products[colIndex]?.productLabel?.[0] === -1) {
table.goodsConfigType = -1;
} else {
Object.assign(table, paramConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, paramConfig.ParamsType1Products[colIndex].productLabel)
: buildProductDefinePayload(productDefineList, paramConfig.ParamsType1Products[colIndex].productLabel),
});
: buildProductDefinePayload(productDefineList, paramConfig.ParamsType1Products[colIndex].productLabel));
}
requestData.paramConfigList.push(table);
});
}
if (templateType === "ParamsType2") {
coverParamsType2(ParamsType2, (result, { paramsType2Item, paramsType2Index }) => {
requestData.paramConfigList.push({
const table = {
...result,
commissionType: paramConfig.ParamsType2CommissionTypes,
commissionBase: commissionTypesCoverCommissionBase[paramConfig.ParamsType2CommissionTypes],
assessmentFactor: paramConfig.assessmentFactorOptions.value,
goodsConfigType: paramConfig.goodsCategory,
...paramConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, paramsType2Item.productLabel)
: buildProductDefinePayload(productDefineList, paramsType2Item.productLabel),
performanceParamConfigConditions: getPerformanceParamConfigConditions(paramsType2Item, paramConfig, goodsCategory, productDefineList),
});
};
if (paramsType2Item.productLabel?.[0] === -1) {
table.goodsConfigType = -1;
} else {
Object.assign(table, paramConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, paramsType2Item.productLabel)
: buildProductDefinePayload(productDefineList, paramsType2Item.productLabel));
}
requestData.paramConfigList.push(table);
});
}
}
console.log("convertDataToBackend", merchantBrandRefList);
// 整理门店
if (merchantBrandRefList && merchantBrandRefList.length) {
requestData.merchantBrandRefList = buildMerchantBrandPayload(merchantBrandRefList, data.businessType);
......@@ -91,9 +102,9 @@ function getPerformanceParamConfigConditions(paramsType2Item, paramsConfig, good
name: "conditionProductDefineName",
type: "conditionGoodsConfigType",
};
console.log("paramsConfigdddsss", paramsConfig);
console.log("goodsCategory", goodsCategory);
if (paramsType2Item.condition === 0) {
return [];
}
const conditionItem = [{
conditionType: paramsType2Item.condition,
conditionGoodsConfigType: paramsConfig.goodsCategory,
......@@ -101,9 +112,6 @@ function getPerformanceParamConfigConditions(paramsType2Item, paramsConfig, good
// conditionEndValue: "",
}];
if (paramsType2Item.condition === 0) {
return [];
}
// 合并到 conditionItem 的第一位里
let extend = {};
......@@ -129,21 +137,34 @@ function getPerformanceParamConfigConditions(paramsType2Item, paramsConfig, good
extend.conditionStartValue = conditionParamsData.permeabilityMin;
extend.conditionEndValue = conditionParamsData.permeabilityMax;
extend = {
...extend,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue || [], buildProductDefinePayloadOptions),
};
conditionItem.push({
if (conditionParamsData?.productValue?.[0] === -1) {
extend.conditionGoodsConfigType = -1;
} else {
extend = {
...extend,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue || [], buildProductDefinePayloadOptions),
};
}
let conditionItem1 = {
conditionType: paramsType2Item.condition,
conditionStartValue: conditionParamsData.permeabilityMin1,
conditionEndValue: conditionParamsData.permeabilityMax1,
conditionGoodsConfigType: paramsConfig.goodsCategory,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue1 || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue1 || [], buildProductDefinePayloadOptions),
});
};
if (conditionParamsData.productValue1?.[0] === -1) {
conditionItem1.conditionGoodsConfigType = -1;
} else {
conditionItem1 = {
...conditionItem1,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue1 || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue1 || [], buildProductDefinePayloadOptions),
};
}
conditionItem.push(conditionItem1);
}
if (paramsType2Item.condition === 2) {
extend.conditionEndValue = conditionParamsData.deductRate;
......@@ -153,12 +174,16 @@ function getPerformanceParamConfigConditions(paramsType2Item, paramsConfig, good
extend.conditionCommissionTypeValue = conditionParamsData.increaseReward;
}
if (paramsType2Item.condition === 4) {
extend = {
...extend,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue || [], buildProductDefinePayloadOptions),
};
if (conditionParamsData?.productValue?.[0] === -1) {
extend.conditionGoodsConfigType = -1;
} else {
extend = {
...extend,
...paramsConfig.goodsCategory === 0
? buildGoodsTypePayload(goodsCategory, conditionParamsData.productValue || [], buildGoodsTypePayloadOptions)
: buildProductDefinePayload(productDefineList, conditionParamsData.productValue || [], buildProductDefinePayloadOptions),
};
}
}
conditionItem[0] = {
......@@ -215,7 +240,9 @@ function buildGoodsTypePayload(tree, pathIds, options = {
if (!pathIds || !Array.isArray(pathIds) || pathIds.length === 0) {
return result;
}
console.log("pathIds", pathIds);
console.log("tree", tree);
pathIds.forEach((id, index) => {
let node = {};
traverseTree(tree, (_node) => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!