Commit bdaef0ae by Jaxon

feat(绩效方案): 新增品类配置组件并重构商品选择逻辑

- 新增 GoodsCategoryCascader 组件用于品类级联选择
- 将业务适配字段从 checkList 重命名为 businessType
- 在 store 中新增 goodsCategory 状态管理品类数据
- 重构参数配置表,将商品选择从圈定商品切换为品类选择
- 优化 type2 条件类型的表单组件,使用 EditableText 替代原生输入框
- 移除冗余的 getDetail API 调用,优化初始化加载逻辑
1 parent 0887b676
<template>
<div>
<el-form-item label="适配业务:" prop="checkList">
<el-radio-group v-model="checkList">
<el-form-item label="适配业务:" prop="businessType">
<el-radio-group v-model="businessType">
<el-radio label="0">
轻改
</el-radio>
......@@ -30,7 +30,7 @@ export default {
};
},
computed: {
checkList: bindFormFields("checkList"),
businessType: bindFormFields("businessType"),
},
mounted() {
......
<template>
<div class="">
<el-cascader :options="goodsCategory"
:props="{ checkStrictly: true, label: 'categoryName', value: 'categoryType' }"
:show-all-levels="false"
:value="value"
@change="handleProductChange">
</el-cascader>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "",
props: {
value: {
type: Array,
default: () => [],
},
},
data() {
return {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions", "goodsCategory"]),
},
mounted() {
},
methods: {
handleProductChange(value) {
this.$emit("input", value);
this.$emit("change", value);
},
},
};
</script>
......@@ -73,11 +73,12 @@ export default {
},
methods: {
// 为ParamConfigTyp1 添加列
handleAppendTableColProduct() {
if (this.curParamsConfig.templateType !== "ParamsType1") {
return;
}
if (this.curParamsConfig.products.length >= 10) {
if (this.curParamsConfig.ParamsType1Products.length >= 10) {
this.$message.warning("最多添加列商品");
}
this.curParamsConfig.ParamsType1Products.push({
......@@ -85,19 +86,11 @@ export default {
});
},
// 提成方式改变
handleCommissionTypesChange(row) {
// TODO: 清空当前行的所有 products[index].productValue[$index] 的值
this.curParamsConfig.ParamsType1Products.forEach((product) => {
this.$set(product.productValue, row, undefined);
});
},
handleProductChange(value) {
console.log("product change", value);
},
// 新增一行
handleAppendTableRow() {
const templateType = this.curParamsConfig.templateType;
const lastPriceRange = last(this.curParamsConfig.priceRange);
const lastPriceRange = last(this.curParamsConfig[templateType])?.priceRange || [0, 0];
const nPriceRange = [undefined, undefined];
if (lastPriceRange && lastPriceRange[1]) {
nPriceRange[0] = lastPriceRange[1] + (this.curParamsConfig.priceRangeProps.precision ? 1 : 0.01);
......
......@@ -3,7 +3,6 @@
<el-table border
class="params-config-table"
:data="curParamsConfig.ParamsType1">
<el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
width="270px">
......@@ -50,11 +49,14 @@
width="180px">
<template #header="{ $index }">
<div>
<el-cascader v-model="curParamsConfig.ParamsType1Products[index].productLabel"
<GoodsCategoryCascader v-model="curParamsConfig.ParamsType1Products[index].productLabel" @change="handleProductChange" />
<!-- <el-cascader v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader>
</el-cascader> -->
<el-button style="position: absolute;right:6px;"
title="删除列"
......@@ -94,12 +96,14 @@
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import GoodsCategoryCascader from "../goodsCategoryCascader/index.vue";
import { commissionTypeEnum } from "../performanceRuleSelection/options";
export default {
name: "",
components: {
EditableText,
GoodsCategoryCascader,
},
props: {
......
......@@ -30,27 +30,36 @@
label="商品分类"
width="180">
<template #default="{ $index }">
<el-cascader v-model="curParamsConfig.ParamsType2[$index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader>
<div>
<!-- 品类cascader -->
<!-- <el-cascader v-model="curParamsConfig.ParamsType2[$index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader> -->
<!-- 圈定套餐/商品 cascader -->
<GoodsCategoryCascader v-model="curParamsConfig.ParamsType2[$index].productLabel" @change="handleProductChange" />
<span class="el-icon-sort icon"
style="line-height:normal;height:14px; vertical-align: middle;"
@click="handleChangeGoodsConfigTypes($index)">
</span>
</div>
</template>
</el-table-column>
<el-table-column align="center">
<template #header>
<el-form-item>
<el-select v-model="curParamsConfig.ParamsType2CommissionTypes"
placeholder="请选择"
style="width:120px"
@change="handleCommissionTypesChange">
<el-option v-for="subItem in commissionTypesOptions"
:key="subItem.value"
:label="subItem.label"
:value="subItem.value" />
</el-select>
</el-form-item>
<el-select v-model="curParamsConfig.ParamsType2CommissionTypes"
placeholder="请选择"
style="width:120px"
@change="handleCommissionTypesChange">
<el-option v-for="subItem in commissionTypesOptions"
:key="subItem.value"
:label="subItem.label"
:value="subItem.value" />
</el-select>
</template>
<template #default="{ $index }">
......@@ -96,6 +105,7 @@
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import GoodsCategoryCascader from "../goodsCategoryCascader/index.vue";
import { paramConfigConditionType } from "../performanceRuleSelection/options.js";
import { Type0, Type1, Type2 } from "./type2components/index.js";
......@@ -103,6 +113,7 @@ export default {
name: "",
components: {
EditableText,
GoodsCategoryCascader,
Type0,
Type1,
Type2,
......@@ -120,7 +131,7 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]),
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions", "goodsCategory"]),
curParamsConfig() {
return this.formData.paramConfigList[this.configIndex];
},
......@@ -150,8 +161,12 @@ export default {
},
methods: {
// 提成方式改变
handleCommissionTypesChange() {},
handleRemoveTableRow() {},
// 删除行
handleRemoveTableRow(row) {
this.curParamsConfig.ParamsType2.splice(row, 1);
},
// 取消设置条件
handleCancelConditionSetting(row) {
this.curParamsConfig.ParamsType2[row].condition = 0;
......
<template>
<div class="param-config-type-2-condition-type">
<el-form-item>
<el-input v-model="conditionTypeValue"></el-input>
</el-form-item>
<EditableText v-model="conditionTypeValue"
:controls="false"
type="number"
v-bind="getComponentsProp">
</EditableText>
</div>
</template>
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import { commissionTypeEnum } from "../../performanceRuleSelection/options";
export default {
name: "",
components: {
EditableText,
},
props: {
configIndex: {
type: Number,
......@@ -27,11 +34,24 @@ export default {
};
},
// v-bind="curParamsConfig.ParamsType1[$index].commissionTypes && commissionTypeEnum[curParamsConfig.ParamsType1[$index].commissionTypes].componentProps"
computed: {
...mapState("PerformanceFormStore", ["formData"]),
conditionTypeValue() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType0;
paramsType2CommissionTypes() {
return this.formData.paramConfigList[this.configIndex].ParamsType2CommissionTypes;
},
getComponentsProp() {
return this.paramsType2CommissionTypes ? commissionTypeEnum[this.paramsType2CommissionTypes].componentProps : {};
},
conditionTypeValue: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType0;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType0 = value;
},
},
},
mounted() {
......@@ -44,5 +64,10 @@ export default {
</script>
<style scoped lang="scss">
.param-config-type-2-condition-type {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
</style>
<template>
<div class="param-config-type-2-condition-type">
<el-input v-model="triggerCondition"></el-input>
<span>且</span>
<el-select v-model="productValue"></el-select>
<span>渗透率在</span>
<el-input v-model="permeabilityMin"></el-input>
<span>~</span>
<el-input v-model="permeabilityMax"></el-input>
<span>区间时执行</span>
<EditableText v-model="triggerCondition"
:controls="false"
type="number"
v-bind="getComponentsProp">
</EditableText>
<span class="label">且</span>
<el-cascader v-model="productValue"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader>
<span class="label">渗透率在</span>
<EditableText v-model="permeabilityMin"
:controls="false"
:max="100"
:min="0"
:precision="2"
type="number">
</EditableText>
<span class="label">~</span>
<EditableText v-model="permeabilityMax"
:controls="false"
:max="100"
:min="0"
:precision="2"
type="number">
</EditableText>
<span class="label">区间时执行</span>
</div>
</template>
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import { commissionTypeEnum } from "../../performanceRuleSelection/options";
export default {
name: "",
components: {
EditableText,
},
props: {
configIndex: {
type: Number,
......@@ -33,34 +58,99 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
...mapState("PerformanceFormStore", ["formData", "productDefineList"]),
// 商品选择项
getProductDefineListOptions() {
const res = [];
if (this.formData.goodsConfigTypes.includes("0")) {
res.push({
label: "品类",
value: -2,
children: [],
});
}
if (this.formData.goodsConfigTypes.includes("-1")) {
res.push({
label: "商品/套餐",
value: -1,
children: this.productDefineList,
});
}
triggerCondition() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.triggerCondition;
return res;
},
// 路径太长 简化
paramsType2CommissionTypes() {
return this.formData.paramConfigList[this.configIndex].ParamsType2CommissionTypes;
},
// 提成方式 的值 决定 的 组件传参
getComponentsProp() {
return this.paramsType2CommissionTypes ? commissionTypeEnum[this.paramsType2CommissionTypes].componentProps : {};
},
productLabel() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productLabel;
triggerCondition: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.triggerCondition;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.triggerCondition = value;
},
},
productValue() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productValue;
productLabel: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productLabel;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productLabel = value;
},
},
permeabilityMin() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMin;
productValue: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productValue;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productValue = value;
},
},
permeabilityMax() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMax;
permeabilityMin: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMin;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMin = value;
},
},
permeabilityMax: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMax;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMax = value;
},
},
},
mounted() {
},
methods: {
// TODO: 商品切换
handleProductChange() {
},
},
};
</script>
<style scoped lang="scss">
.param-config-type-2-condition-type {
> span.label {
color: #666666;
font-size: 14px;
font-weight: 400;
line-height: 18px;
margin: 0 6px;
}
}
</style>
<template>
<div class="param-config-type-2-condition-type">
<el-input v-model="triggerCondition"></el-input>
<span>且按不足</span>
<el-input v-model="deductRate"></el-input>
<span>订单数每单扣减</span>
<el-input v-model="perOrderDeductAmount"></el-input>
<span>元.区间时执行</span>
<EditableText v-model="triggerCondition"
:controls="false"
type="number"
v-bind="getComponentsProp">
</EditableText>
<span class="label">且按不足</span>
<EditableText v-model="deductRate"
:controls="false"
:max="100"
:min="0"
:precision="2"
type="number">
</EditableText>
<span class="label">订单数每单扣减</span>
<EditableText v-model="perOrderDeductAmount"
:controls="false"
:max="999999"
:min="0"
:precision="2"
type="number">
</EditableText>
<span class="label">元.区间时执行</span>
</div>
</template>
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import { commissionTypeEnum } from "../../performanceRuleSelection/options";
export default {
name: "",
components: {
EditableText,
},
props: {
configIndex: {
type: Number,
......@@ -32,15 +53,38 @@ export default {
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
triggerCondition() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.triggerCondition;
// 路径太长 简化
paramsType2CommissionTypes() {
return this.formData.paramConfigList[this.configIndex].ParamsType2CommissionTypes;
},
// 提成方式 的值 决定 的 组件传参
getComponentsProp() {
return this.paramsType2CommissionTypes ? commissionTypeEnum[this.paramsType2CommissionTypes].componentProps : {};
},
deductRate() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.deductRate;
triggerCondition: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.triggerCondition;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.triggerCondition = value;
},
},
perOrderDeductAmount() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.perOrderDeductAmount;
deductRate: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.deductRate;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.deductRate = value;
},
},
perOrderDeductAmount: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.perOrderDeductAmount;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.perOrderDeductAmount = value;
},
},
},
......@@ -54,5 +98,13 @@ export default {
</script>
<style scoped lang="scss">
.param-config-type-2-condition-type {
> span.label {
color: #666666;
font-size: 14px;
font-weight: 400;
line-height: 18px;
margin: 0 6px;
}
}
</style>
......@@ -176,7 +176,7 @@ export const paramConfigListTemplate = {
// 如果
ParamsType1Products: [
{
productLabel: "",
productLabel: [],
productValue: [undefined],
optionList: [],
},
......@@ -215,31 +215,17 @@ export const paramConfigListTemplate = {
deductRate: undefined,
// 每单扣减金额
perOrderDeductAmount: undefined,
},
// 渗透率的条件
condition: 0,
priceRange: [0, undefined],
commissionTypes: undefined,
productLabel: "",
productLabel: [],
productValue: [undefined],
optionList: [],
},
],
// 渗透率的条件
condition: 0,
priceRange: [
[0, undefined],
],
commissionTypes: [undefined],
products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
};
// 模板对象
......
......@@ -7,6 +7,8 @@ export default {
state: {
formData: {
checkList: [],
// 适配业务
businessType: undefined,
// 考核因子
assessmentFactor: [],
schemaName: "",
......@@ -39,11 +41,14 @@ export default {
effectiveTime: "",
},
},
// 品类数据
goodsCategory: [],
// 圈定商品/套餐的数据
productDefineList: [],
// 提成方式 下拉选择框数据
commissionTypesOptions: [],
// 门店和品牌
merchantBrandRefList: []
merchantBrandRefList: [],
},
getters: {
getMerchantBrandRefList(state) {
......@@ -109,6 +114,10 @@ export default {
};
});
},
// 设置品类数据
setGoodsCategory(state, goodsCategory) {
state.goodsCategory = goodsCategory;
},
},
actions: {
......
......@@ -71,16 +71,14 @@
<script>
import { mapMutations, mapState } from "vuex";
import { getTargetProductConfigListAPI, getPerformanceConfigDetailAPI } from "@/api/resident";
import { getAllCategory } from "@/api/product.js";
import { getTargetProductConfigListAPI } from "@/api/resident";
import ChannelConfig from "../components/channelConfig/index.vue";
import ParamConfigList from "../components/paramConfigList/index.vue";
import PerformanceRuleSelection from "../components/performanceRuleSelection/index.vue";
import StoreApply from "../components/storeApply/index.vue";
import { bindFormFields } from "../store/helper.js";
console.log("StoreApply", StoreApply);
console.log("PerformanceRuleSelection", PerformanceRuleSelection);
export default {
name: "PerformanceScheme",
components: {
......@@ -105,10 +103,9 @@ export default {
},
async mounted() {
await this.initLoad();
await this.getDetail();
},
methods: {
...mapMutations("PerformanceFormStore", ["setProductDefineList"]),
...mapMutations("PerformanceFormStore", ["setProductDefineList", "setGoodsCategory"]),
submitTest() {
this.$refs.formTest1.validate((valid) => {
if (valid) {
......@@ -119,22 +116,13 @@ export default {
handleSubmit() {
console.log(this.formData);
},
async getDetail() {
const res = await getPerformanceConfigDetailAPI({ configId: this.formData.id });
console.log("res", res);
},
async initLoad() {
// 获取品类
const { list } = await getAllCategory({ pageSize: 9999, currentPage: 1 });
this.setGoodsCategory(list);
// 获取圈定商品/套餐
const res = await getTargetProductConfigListAPI({ currentPage: 1, pageSize: 999 });
const productDefineList = res?.list.map(item => ({
id: item.id,
defineType: item.defineType,
defineName: item.defineName,
itemList: (item.itemList || []).map(it => ({
itemId: it.itemId,
itemName: it.itemName,
})),
}));
this.setProductDefineList(productDefineList);
this.setProductDefineList(res?.list);
},
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!