Commit 26acc102 by Jaxon

chron: 工资绩效 - 优化store数据结构

1 parent b721e7cb
...@@ -5,16 +5,18 @@ ...@@ -5,16 +5,18 @@
label="模板类型:" label="模板类型:"
prop="templateType"> prop="templateType">
<el-radio-group v-model="curParamsConfig.templateType"> <el-radio-group v-model="curParamsConfig.templateType">
<el-radio :label="1"> <el-radio label="ParamsType1">
适配通用配置 适配通用配置
</el-radio> </el-radio>
<el-radio :label="2"> <el-radio label="ParamsType2">
适配渗透率配置 适配渗透率配置
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<div class="table-btn-wrapper"> <div class="table-btn-wrapper">
<el-button size="small" @click="handleAppendTableColProduct"> <el-button v-if="curParamsConfig.templateType === 'ParamsType1'"
size="small"
@click="handleAppendTableColProduct">
<i class="el-icon-plus" style="font-size:14px" /> <i class="el-icon-plus" style="font-size:14px" />
<span>新增商品一列</span> <span>新增商品一列</span>
</el-button> </el-button>
...@@ -27,8 +29,7 @@ ...@@ -27,8 +29,7 @@
</div> </div>
</div> </div>
<div class="table-wrapper"> <div class="table-wrapper">
<!-- <ParamsType2 :config-index="configIndex"></ParamsType2> --> <!-- <component :is="curParamsConfig.templateType" :config-index="configIndex"></component> -->
<ParamsType1 :config-index="configIndex"></ParamsType1>
</div> </div>
</div> </div>
...@@ -40,7 +41,6 @@ import { mapState } from "vuex"; ...@@ -40,7 +41,6 @@ import { mapState } from "vuex";
import ParamsType1 from "./type1.vue"; import ParamsType1 from "./type1.vue";
import ParamsType2 from "./type2.vue"; import ParamsType2 from "./type2.vue";
console.log(1);
export default { export default {
name: "", name: "",
components: { components: {
...@@ -78,7 +78,7 @@ export default { ...@@ -78,7 +78,7 @@ export default {
} }
this.curParamsConfig.products.push({ this.curParamsConfig.products.push({
productLabel: "", productLabel: "",
productValue: [""], productValue: [undefined],
optionList: [], optionList: [],
}); });
}, },
...@@ -92,14 +92,14 @@ export default { ...@@ -92,14 +92,14 @@ export default {
console.log("product change", value); console.log("product change", value);
}, },
handleAppendTableRow() { handleAppendTableRow() {
const lastPriceRange = last(this.curParamsConfig.priceRange); const templateType = this.curParamsConfig.templateType;
const nPriceRange = [undefined, undefined];
if (lastPriceRange && lastPriceRange[1]) { // this.curParamsConfig[templateType].push({
nPriceRange[0] = lastPriceRange[1] + (this.curParamsConfig.assessmentFactor.componentProps.precision ? 1 : 0.01); // priceRange: [undefined, undefined],
nPriceRange[1] = undefined; // });
}
this.curParamsConfig.priceRange.push(nPriceRange); // this.curParamsConfig.priceRange.push(nPriceRange);
this.curParamsConfig.commissionTypes.push(undefined); // this.curParamsConfig.commissionTypes.push(undefined);
}, },
}, },
}; };
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
<div class="params-config-table"> <div class="params-config-table">
<el-table border <el-table border
class="params-config-table" class="params-config-table"
:data="curParamsConfig.priceRange"> :data="curParamsConfig.ParamsType1">
<el-table-column align="center" <el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`" :label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
min-width="312px"> width="270px">
<template #default="{ $index }"> <template #default="{ $index }">
<div class="assessment-factor-column"> <div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.priceRange[$index][0]" <EditableText v-model="curParamsConfig.ParamsType1[$index].priceRange[0]"
:controls="false" :controls="false"
:disabled="$index === 0" :disabled="$index === 0"
type="number" type="number"
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<el-table-column align="center" <el-table-column align="center"
label="提成方式" label="提成方式"
min-width="152px" min-width="180"
prop="commissionTypes"> prop="commissionTypes">
<template #default="{ $index }"> <template #default="{ $index }">
<el-select v-model="curParamsConfig.commissionTypes[$index]" <el-select v-model="curParamsConfig.commissionTypes[$index]"
...@@ -137,6 +137,14 @@ export default { ...@@ -137,6 +137,14 @@ export default {
return res; return res;
}, },
paramsTables: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType1;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType1 = value;
},
},
curParamsConfig: { curParamsConfig: {
get() { get() {
return this.formData.paramConfigList[this.configIndex]; return this.formData.paramConfigList[this.configIndex];
...@@ -159,6 +167,7 @@ export default { ...@@ -159,6 +167,7 @@ export default {
this.curParamsConfig.products.splice(productCol, 1); this.curParamsConfig.products.splice(productCol, 1);
}, },
handleCommissionTypesChange() {},
// 删除行 // 删除行
handleRemoveTableRow(row) { handleRemoveTableRow(row) {
this.curParamsConfig.priceRange.splice(row, 1); this.curParamsConfig.priceRange.splice(row, 1);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
:data="curParamsConfig.priceRange"> :data="curParamsConfig.priceRange">
<el-table-column align="center" <el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`" :label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
min-width="312px"> width="270px">
<template #default="{ $index }"> <template #default="{ $index }">
<div class="assessment-factor-column"> <div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.priceRange[$index][0]" <EditableText v-model="curParamsConfig.priceRange[$index][0]"
...@@ -25,6 +25,60 @@ ...@@ -25,6 +25,60 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center"
label="商品分类"
width="180">
<template #default="{ $index }">
<el-cascader v-model="curParamsConfig.products[$index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
</el-cascader>
</template>
</el-table-column>
<el-table-column align="center">
<template #header>
<el-select v-model="curParamsConfig.commissionTypes"
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="{ row }">
<component :is="paramConfigConditionType[curParamsConfig.condition].component"></component>
</template>
</el-table-column>
<el-table-column align="center"
fixed="right"
label="操作"
width="120">
<template #default="{ $index }">
<el-button v-if="curParamsConfig.condition === 0"
type="text"
@click="handleChangeCondition()">
设置条件
</el-button>
<el-button v-else
type="text"
@click="handleCancelConditionSetting()">
取消条件
</el-button>
<el-button type="text"
@click="handleRemoveTableRow($index)">
删除
</el-button>
</template>
</el-table-column>
</el-table> </el-table>
</div> </div>
</template> </template>
...@@ -32,11 +86,14 @@ ...@@ -32,11 +86,14 @@
<script> <script>
import { mapState } from "vuex"; import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue"; import EditableText from "@/components/editableText/index.vue";
import { paramConfigConditionType } from "../performanceRuleSelection/options.js";
import { Type0, Type1, Type2 } from "./type2components/index.js";
export default { export default {
name: "", name: "",
components: { components: {
EditableText, EditableText,
Type0,
}, },
props: { props: {
configIndex: { configIndex: {
...@@ -47,25 +104,55 @@ export default { ...@@ -47,25 +104,55 @@ export default {
}, },
data() { data() {
return { return {
paramConfigConditionType,
}; };
}, },
computed: { computed: {
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]), ...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]),
curParamsConfig: { curParamsConfig() {
get() {
return this.formData.paramConfigList[this.configIndex]; return this.formData.paramConfigList[this.configIndex];
}, },
set(value) { getProductDefineListOptions() {
this.formData.paramConfigList[this.configIndex] = value; const res = [];
}, if (this.formData.goodsConfigTypes.includes("0")) {
res.push({
label: "品类",
value: -2,
children: [],
});
console.warn("获取品类数据");
}
if (this.formData.goodsConfigTypes.includes("-1")) {
res.push({
label: "商品/套餐",
value: -1,
children: this.productDefineList,
});
}
return res;
}, },
}, },
mounted() { mounted() {
}, },
methods: { methods: {
handleCommissionTypesChange() {},
handleRemoveTableRow() {},
handleCancelConditionSetting() {
this.curParamsConfig.condition = 0;
},
handleChangeCondition(index) {
if (this.curParamsConfig.condition >= 2) {
this.curParamsConfig.condition = 1;
return;
}
this.curParamsConfig.condition += 1;
},
handleProductChange(value) {
console.log("product change", value);
},
}, },
}; };
</script> </script>
......
export { default as Type0 } from './type0.vue'
export { default as Type1 } from './type1.vue'
export { default as Type2 } from './type2.vue'
<template>
<div class="">
<el-input></el-input>
</div>
</template>
<script>
export default {
name: "",
props: {
},
data() {
return {
};
},
computed: {
},
mounted() {
},
methods: {
},
};
</script>
<style scoped lang="scss">
</style>
<template>
<div class="">
<el-input></el-input>
<span>且按不足</span>
<el-input></el-input>
<span>订单数每单扣减</span>
<el-input></el-input>
<span>元.区间时执行</span>
</div>
</template>
<script>
export default {
name: "",
props: {
},
data() {
return {
};
},
computed: {
},
mounted() {
},
methods: {
},
};
</script>
<style scoped lang="scss">
</style>
<template>
<div class="">
<el-input></el-input>
<span>且</span>
<el-select></el-select>
<span>渗透率在</span>
<el-input></el-input>
<span>~</span>
<el-input></el-input>
<span>区间时执行</span>
</div>
</template>
<script>
export default {
name: "",
props: {
},
data() {
return {
};
},
computed: {
},
mounted() {
},
methods: {
},
};
</script>
<style scoped lang="scss">
</style>
...@@ -149,11 +149,58 @@ export const assessmentFactorOptions = [ ...@@ -149,11 +149,58 @@ export const assessmentFactorOptions = [
sort: 12, sort: 12,
}, },
]; ];
export const paramConfigConditionType = {
0: {
component: "Type0",
},
1: {
component: "Type1",
},
2: {
component: "Type2",
},
};
// 模板对象 // 模板对象 一个table 对应一个paramConfigListTemplate数据
// 也对应 type1.vue 与 type2.vue 中的 curParamsConfig
export const paramConfigListTemplate = { export const paramConfigListTemplate = {
title: "", title: "",
templateType: 2, // 对应下面两个大数组
templateType: "ParamsType1",
// sort:在添加的时候输入
// priceRangeProps 在新增时动态插入
ParamsType1: [
{
priceRange: [0, undefined],
commissionTypes: undefined,
products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
},
],
ParamsType2: [
{
// 渗透率的条件
condition: 0,
priceRange: [0, undefined],
commissionTypes: undefined,
products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
},
],
// 渗透率的条件
condition: 0,
priceRange: [ priceRange: [
[0, undefined], [0, undefined],
], ],
...@@ -161,7 +208,7 @@ export const paramConfigListTemplate = { ...@@ -161,7 +208,7 @@ export const paramConfigListTemplate = {
products: [ products: [
{ {
productLabel: "", productLabel: "",
productValue: [""], productValue: [undefined],
optionList: [], optionList: [],
}, },
], ],
......
...@@ -46,26 +46,35 @@ export default { ...@@ -46,26 +46,35 @@ export default {
getters: { getters: {
}, },
mutations: { mutations: {
// 设置提成基数
setCommissionBases(state, value) {
state.formData.commissionBases = value;
},
// 设置提成方式
setCommissionTypes(state, value) {
state.formData.commissionTypes = value;
},
// 更新参数
updateFormField(state, { key, value }) { updateFormField(state, { key, value }) {
set(state.formData, key, value); set(state.formData, key, value);
}, },
// 设置商品分类
setProductDefineList(state, productDefineList) { setProductDefineList(state, productDefineList) {
const data = normalizeTree(productDefineList); const data = normalizeTree(productDefineList);
data.unshift({ label: "全部", value: -1, leaf: false }); data.unshift({ label: "全部", value: -1, leaf: false });
state.productDefineList = data; state.productDefineList = data;
}, },
// 设置提成方式的下拉框选项
setCommissionTypesOptions(state, options) { setCommissionTypesOptions(state, options) {
console.log("options", options);
state.commissionTypesOptions = options.map((item, index) => ({ state.commissionTypesOptions = options.map((item, index) => ({
label: commissionTypeEnum[item].label, label: commissionTypeEnum[item].label,
value: commissionTypeEnum[item].value, value: commissionTypeEnum[item].value,
})); }));
}, },
// 操作考核因子
touchAssessment(state, selectedItems) { touchAssessment(state, selectedItems) {
state.formData.assessmentFactor = selectedItems.sort((a, b) => a.sort - b.sort); state.formData.assessmentFactor = selectedItems.sort((a, b) => a.sort - b.sort);
console.log("selectedItems", selectedItems);
if (!Array.isArray(state.formData.paramConfigList)) { if (!Array.isArray(state.formData.paramConfigList)) {
state.formData.paramConfigList = []; state.formData.paramConfigList = [];
} }
...@@ -82,13 +91,14 @@ export default { ...@@ -82,13 +91,14 @@ export default {
? existingConfigMap.get(sort) ? existingConfigMap.get(sort)
: { : {
...structuredClone(paramConfigListTemplate), ...structuredClone(paramConfigListTemplate),
priceRangeProps: item.rangeProps,
title: item.label, title: item.label,
rangeProps: item.rangeProps,
assessmentFactor: item, assessmentFactor: item,
sort, sort,
}; };
}); });
}, },
}, },
actions: { actions: {
setFormField({ commit }, payload) { setFormField({ commit }, payload) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!