Commit 26acc102 by Jaxon

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

1 parent b721e7cb
......@@ -5,16 +5,18 @@
label="模板类型:"
prop="templateType">
<el-radio-group v-model="curParamsConfig.templateType">
<el-radio :label="1">
<el-radio label="ParamsType1">
适配通用配置
</el-radio>
<el-radio :label="2">
<el-radio label="ParamsType2">
适配渗透率配置
</el-radio>
</el-radio-group>
</el-form-item>
<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" />
<span>新增商品一列</span>
</el-button>
......@@ -27,8 +29,7 @@
</div>
</div>
<div class="table-wrapper">
<!-- <ParamsType2 :config-index="configIndex"></ParamsType2> -->
<ParamsType1 :config-index="configIndex"></ParamsType1>
<!-- <component :is="curParamsConfig.templateType" :config-index="configIndex"></component> -->
</div>
</div>
......@@ -40,7 +41,6 @@ import { mapState } from "vuex";
import ParamsType1 from "./type1.vue";
import ParamsType2 from "./type2.vue";
console.log(1);
export default {
name: "",
components: {
......@@ -78,7 +78,7 @@ export default {
}
this.curParamsConfig.products.push({
productLabel: "",
productValue: [""],
productValue: [undefined],
optionList: [],
});
},
......@@ -92,14 +92,14 @@ export default {
console.log("product change", value);
},
handleAppendTableRow() {
const lastPriceRange = last(this.curParamsConfig.priceRange);
const nPriceRange = [undefined, undefined];
if (lastPriceRange && lastPriceRange[1]) {
nPriceRange[0] = lastPriceRange[1] + (this.curParamsConfig.assessmentFactor.componentProps.precision ? 1 : 0.01);
nPriceRange[1] = undefined;
}
this.curParamsConfig.priceRange.push(nPriceRange);
this.curParamsConfig.commissionTypes.push(undefined);
const templateType = this.curParamsConfig.templateType;
// this.curParamsConfig[templateType].push({
// priceRange: [undefined, undefined],
// });
// this.curParamsConfig.priceRange.push(nPriceRange);
// this.curParamsConfig.commissionTypes.push(undefined);
},
},
};
......
......@@ -2,14 +2,14 @@
<div class="params-config-table">
<el-table border
class="params-config-table"
:data="curParamsConfig.priceRange">
:data="curParamsConfig.ParamsType1">
<el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
min-width="312px">
width="270px">
<template #default="{ $index }">
<div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.priceRange[$index][0]"
<EditableText v-model="curParamsConfig.ParamsType1[$index].priceRange[0]"
:controls="false"
:disabled="$index === 0"
type="number"
......@@ -29,7 +29,7 @@
<el-table-column align="center"
label="提成方式"
min-width="152px"
min-width="180"
prop="commissionTypes">
<template #default="{ $index }">
<el-select v-model="curParamsConfig.commissionTypes[$index]"
......@@ -137,6 +137,14 @@ export default {
return res;
},
paramsTables: {
get() {
return this.formData.paramConfigList[this.configIndex].ParamsType1;
},
set(value) {
this.formData.paramConfigList[this.configIndex].ParamsType1 = value;
},
},
curParamsConfig: {
get() {
return this.formData.paramConfigList[this.configIndex];
......@@ -159,6 +167,7 @@ export default {
this.curParamsConfig.products.splice(productCol, 1);
},
handleCommissionTypesChange() {},
// 删除行
handleRemoveTableRow(row) {
this.curParamsConfig.priceRange.splice(row, 1);
......
......@@ -5,7 +5,7 @@
:data="curParamsConfig.priceRange">
<el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
min-width="312px">
width="270px">
<template #default="{ $index }">
<div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.priceRange[$index][0]"
......@@ -25,6 +25,60 @@
</div>
</template>
</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>
</div>
</template>
......@@ -32,11 +86,14 @@
<script>
import { mapState } from "vuex";
import EditableText from "@/components/editableText/index.vue";
import { paramConfigConditionType } from "../performanceRuleSelection/options.js";
import { Type0, Type1, Type2 } from "./type2components/index.js";
export default {
name: "",
components: {
EditableText,
Type0,
},
props: {
configIndex: {
......@@ -47,25 +104,55 @@ export default {
},
data() {
return {
paramConfigConditionType,
};
},
computed: {
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]),
curParamsConfig: {
get() {
return this.formData.paramConfigList[this.configIndex];
},
set(value) {
this.formData.paramConfigList[this.configIndex] = value;
},
curParamsConfig() {
return this.formData.paramConfigList[this.configIndex];
},
getProductDefineListOptions() {
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() {
},
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>
......
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 = [
sort: 12,
},
];
export const paramConfigConditionType = {
0: {
component: "Type0",
},
1: {
component: "Type1",
},
2: {
component: "Type2",
},
};
// 模板对象
// 模板对象 一个table 对应一个paramConfigListTemplate数据
// 也对应 type1.vue 与 type2.vue 中的 curParamsConfig
export const paramConfigListTemplate = {
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: [
[0, undefined],
],
......@@ -161,7 +208,7 @@ export const paramConfigListTemplate = {
products: [
{
productLabel: "",
productValue: [""],
productValue: [undefined],
optionList: [],
},
],
......
......@@ -46,26 +46,35 @@ export default {
getters: {
},
mutations: {
// 设置提成基数
setCommissionBases(state, value) {
state.formData.commissionBases = value;
},
// 设置提成方式
setCommissionTypes(state, value) {
state.formData.commissionTypes = value;
},
// 更新参数
updateFormField(state, { key, value }) {
set(state.formData, key, value);
},
// 设置商品分类
setProductDefineList(state, productDefineList) {
const data = normalizeTree(productDefineList);
data.unshift({ label: "全部", value: -1, leaf: false });
state.productDefineList = data;
},
// 设置提成方式的下拉框选项
setCommissionTypesOptions(state, options) {
console.log("options", options);
state.commissionTypesOptions = options.map((item, index) => ({
label: commissionTypeEnum[item].label,
value: commissionTypeEnum[item].value,
}));
},
// 操作考核因子
touchAssessment(state, selectedItems) {
state.formData.assessmentFactor = selectedItems.sort((a, b) => a.sort - b.sort);
console.log("selectedItems", selectedItems);
if (!Array.isArray(state.formData.paramConfigList)) {
state.formData.paramConfigList = [];
}
......@@ -82,13 +91,14 @@ export default {
? existingConfigMap.get(sort)
: {
...structuredClone(paramConfigListTemplate),
priceRangeProps: item.rangeProps,
title: item.label,
rangeProps: item.rangeProps,
assessmentFactor: item,
sort,
};
});
},
},
actions: {
setFormField({ commit }, payload) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!