Commit 862da4e8 by Jaxon

feat(performanceScheme): 重构绩效方案模块的组件与状态管理

- 将绩效表单 store 导入路径修正为独立模块
- 修复 API 路径中的双斜杠错误并添加调试日志
- 重构参数配置组件的数据结构,分离 ParamsType1 和 ParamsType2 的字段定义
- 实现绩效规则选择中提成基数与提成方式的联动勾选逻辑
- 完善门店选择组件的品牌多选与已选状态管理
- 统一组件导出方式并移除旧的 index.js 入口文件
- 在 jsconfig 中添加 @api 路径映射以支持模块化导入
1 parent 26acc102
Showing 20 changed files with 746 additions and 418 deletions
......@@ -35,4 +35,4 @@
}
},
"i18n-ally.sourceLanguage": "zh-chs"
}
}
\ No newline at end of file
......@@ -3,17 +3,22 @@
"target": "ES2020",
// "jsx": "react-jsx",
// "lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ES2020"],
"lib": [
"ES2020"
],
"useDefineForClassFields": true,
/* Paths */
"baseUrl": ".",
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"paths": {
"@/*": ["src/*"]
"@/*": [
"src/*"
],
"@api/*": [
"src/api/*"
]
},
"resolveJsonModule": true,
"allowImportingTsExtensions": false,
......@@ -23,8 +28,14 @@
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"skipLibCheck": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", ".git"]
}
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist",
".git"
]
}
\ No newline at end of file
......@@ -5,129 +5,132 @@
* @Last Modified time: 2021-06-30 14:30:41
*/
import axiosPackage from "axios";
import util from "@/libs/util.js";
import { baseConfig } from "@/main";
// import axios from "@/plugin/axios"
import axios from "@/plugin/axios/index_code";
import RequestMethods from "./request.methods";
import sign from "./sign";
import axios from "@/plugin/axios/index_code"
import sign from "./sign"
import RequestMethods from "./request.methods"
import util from "@/libs/util.js"
import { baseConfig } from "@/main"
import axiosPackage from "axios"
const request = (
params = {},
method = RequestMethods.GET,
noSignAttr = [],
options = {}
) => {
// 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = ""
if (params.method.includes("dj.api.smartcarlife")) {
apiName = "dj"
} else if (params.method.includes("dj.api.script")) {
apiName = "script"
} else if (params.method.includes("dj.staff.api")) {
apiName = "staff"
} else if (params.method.includes("dj.smartcarlife.stock")) {
apiName = "dj.smartcarlife"
} else if (params.method.includes("risk.manage.api")) {
apiName = "riskmanage"
}else {
// console.log(params.method.split(".api"))
apiName = params.method.split(".api")[0]
}
function request(params = {}, method = RequestMethods.GET, noSignAttr = [], options = {}) {
// 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = "";
if (params.method.includes("dj.api.smartcarlife")) {
apiName = "dj";
} else if (params.method.includes("dj.api.script")) {
apiName = "script";
} else if (params.method.includes("dj.staff.api")) {
apiName = "staff";
} else if (params.method.includes("dj.smartcarlife.stock")) {
apiName = "dj.smartcarlife";
} else if (params.method.includes("risk.manage.api")) {
apiName = "riskmanage";
} else {
// console.log(params.method.split(".api"))
apiName = params.method.split(".api")[0];
}
// console.log("params.method", params.method)
// console.log("apiName", apiName)
// 为空报错
if (!apiName) {
throw new Error("apiName is null")
}
const mappingName = {
"dj.smartcarlife": "axios",
dj: "axios",
scrm: "axios2",
merchants: "axios3",
reportExport: "axios4",
"glsx.accounts.biz.common.pictureUpload": "common",
clue: "axios5",
"dj.businessSchool": "axios6",
script: "axios7",
staff: "axios9",
riskmanage:"axios10",
}
const baseApiName = mappingName[apiName]
// console.log(baseApiName, "baseApiName")
// params.appKey = baseConfig[baseApiName].appkey
if (baseApiName == "common") {
params.app_key = baseConfig[baseApiName].appkey
} else {
params.appKey = baseConfig[baseApiName].appkey
}
// console.log("params.appKey", params.appKey)
params.timestamp = new Date().getTime()
params.v = "1.0.0"
params.format = "json"
params.locale = "zh_CN"
if (params.method !== "dj.api.user.login") {
params.sessionId = util.cookies.get("token")
}
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = baseConfig[baseApiName].baseURL
// const url = "/api"
/**
* 调后端接口,请使用以下代码。
*/
const signWay = {
"dj.smartcarlife": "sha1",
dj: "sha1",
scrm: "sha1",
glsx: "md5",
"glsx.accounts.biz.common.pictureUpload": "md5",
clue: "sha1",
script: "sha1",
staff: "sha1",
riskmanage:'sha1'
}
// console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret
const CancelToken = axiosPackage.CancelToken
var reqData =
method === RequestMethods.POST
? {
baseURL: "/",
data: sign(params, noSignAttr, secret, signWay[apiName])
}
: { params: sign(params, noSignAttr, secret, signWay[apiName]) }
// console.log("params.method", params.method)
// console.log("apiName", apiName)
// 为空报错
if (!apiName) {
throw new Error("apiName is null");
}
const mappingName = {
"dj.smartcarlife": "axios",
"dj": "axios",
"scrm": "axios2",
"merchants": "axios3",
"reportExport": "axios4",
"glsx.accounts.biz.common.pictureUpload": "common",
"clue": "axios5",
"dj.businessSchool": "axios6",
"script": "axios7",
"staff": "axios9",
"riskmanage": "axios10",
};
const baseApiName = mappingName[apiName];
// console.log(baseApiName, "baseApiName")
// params.appKey = baseConfig[baseApiName].appkey
if (baseApiName == "common") {
params.app_key = baseConfig[baseApiName].appkey;
} else {
params.appKey = baseConfig[baseApiName].appkey;
}
// console.log("params.appKey", params.appKey)
params.timestamp = new Date().getTime();
params.v = "1.0.0";
params.format = "json";
params.locale = "zh_CN";
if (params.method !== "dj.api.user.login") {
params.sessionId = util.cookies.get("token");
}
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = baseConfig[baseApiName].baseURL;
// const url = "/api"
/**
* 调后端接口,请使用以下代码。
*/
const signWay = {
"dj.smartcarlife": "sha1",
"dj": "sha1",
"scrm": "sha1",
"glsx": "md5",
"glsx.accounts.biz.common.pictureUpload": "md5",
"clue": "sha1",
"script": "sha1",
"staff": "sha1",
"riskmanage": "sha1",
};
// console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret;
const CancelToken = axiosPackage.CancelToken;
let reqData
= method === RequestMethods.POST
? {
baseURL: "/",
data: sign(params, noSignAttr, secret, signWay[apiName]),
}
: { params: sign(params, noSignAttr, secret, signWay[apiName]) };
reqData = Object.assign(reqData, options, {})
// 请求进度
if (params?.onProcess) {
reqData.onUploadProgress = params.onProcess
}
// 取消请求
if (params?.cancelFun) {
reqData.cancelToken = new CancelToken(function excutor (c) {
params.cancelFun.cancel = c
})
}
// console.log(method === RequestMethods.POST)
// console.log(url)
// console.log(options)
// console.log(reqData)
let axiosParams = {
url,
method,
...reqData
}
if (options.returnAll) axiosParams.headers = { 'return-all': true }
return axios(axiosParams)
reqData = Object.assign(reqData, options, {});
// 请求进度
if (params?.onProcess) {
reqData.onUploadProgress = params.onProcess;
}
// 取消请求
if (params?.cancelFun) {
reqData.cancelToken = new CancelToken((c) => {
params.cancelFun.cancel = c;
});
}
// console.log(method === RequestMethods.POST)
// console.log(url)
// console.log(options)
// console.log(reqData)
let axiosParams = {
url,
method,
...reqData,
};
if (options.returnAll)
axiosParams.headers = { "return-all": true };
return axios(axiosParams);
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
}
export default request;
export default request
import Vue from "vue";
import Vuex from "vuex";
import { performanceFormStore } from "@/views/residentManage/salaryPerformance/performanceScheme";
import performanceFormStore from "@/views/residentManage/salaryPerformance/performanceScheme/store/performanceFormStore.js";
import d2admin, { storeResets } from "./modules/d2admin";
import FinancialRules from "./modules/FinancialRules";
import goodsInfoData from "./modules/goodsInfoData";
......
import request from "@/api/request";
console.log("request", request);
const path = "dj.staff.api.service.merchant.";
// 分页查询费用类目
export function getStoreWithBrandList(data) {
// data.method = `${path}selectFeeCategoryList`
data.method = `${path}page.with.brand//1.0.0`;
data.method = `${path}page.with.brand/1.0.0`;
data.url = "http://127.0.0.1:4523/m1/7746299-7491170-default/";
return request(data);
}
......@@ -29,7 +29,7 @@
</div>
</div>
<div class="table-wrapper">
<!-- <component :is="curParamsConfig.templateType" :config-index="configIndex"></component> -->
<component :is="curParamsConfig.templateType" :config-index="configIndex"></component>
</div>
</div>
......@@ -38,6 +38,7 @@
<script>
import { last } from "lodash-es";
import { mapState } from "vuex";
import { paramConfigListTemplate } from "../performanceRuleSelection/options.js";
import ParamsType1 from "./type1.vue";
import ParamsType2 from "./type2.vue";
......@@ -73,18 +74,21 @@ export default {
},
methods: {
handleAppendTableColProduct() {
if (this.curParamsConfig.templateType !== "ParamsType1") {
return;
}
if (this.curParamsConfig.products.length >= 10) {
this.$message.warning("最多添加列商品");
}
this.curParamsConfig.products.push({
productLabel: "",
productValue: [undefined],
optionList: [],
this.curParamsConfig.ParamsType1Products.push({
...structuredClone(paramConfigListTemplate.ParamsType1Products[0]),
});
},
// 提成方式改变
handleCommissionTypesChange(row) {
// TODO: 清空当前行的所有 products[index].productValue[$index] 的值
this.curParamsConfig.products.forEach((product) => {
this.curParamsConfig.ParamsType1Products.forEach((product) => {
this.$set(product.productValue, row, undefined);
});
},
......@@ -93,13 +97,16 @@ export default {
},
handleAppendTableRow() {
const templateType = this.curParamsConfig.templateType;
// this.curParamsConfig[templateType].push({
// priceRange: [undefined, undefined],
// });
// this.curParamsConfig.priceRange.push(nPriceRange);
// this.curParamsConfig.commissionTypes.push(undefined);
const lastPriceRange = last(this.curParamsConfig.priceRange);
const nPriceRange = [undefined, undefined];
if (lastPriceRange && lastPriceRange[1]) {
nPriceRange[0] = lastPriceRange[1] + (this.curParamsConfig.priceRangeProps.precision ? 1 : 0.01);
nPriceRange[1] = undefined;
}
this.curParamsConfig[templateType].push({
...structuredClone(paramConfigListTemplate[templateType][0]),
priceRange: nPriceRange,
});
},
},
};
......
......@@ -13,15 +13,15 @@
:controls="false"
:disabled="$index === 0"
type="number"
v-bind="curParamsConfig.componentProps">
v-bind="curParamsConfig.priceRangeProps">
</EditableText>
<div class="tag">
-
</div>
<EditableText v-model="curParamsConfig.priceRange[$index][1]"
<EditableText v-model="curParamsConfig.ParamsType1[$index].priceRange[1]"
:controls="false"
type="number"
v-bind="curParamsConfig.componentProps">
v-bind="curParamsConfig.priceRangeProps">
</EditableText>
</div>
</template>
......@@ -32,7 +32,7 @@
min-width="180"
prop="commissionTypes">
<template #default="{ $index }">
<el-select v-model="curParamsConfig.commissionTypes[$index]"
<el-select v-model="curParamsConfig.ParamsType1[$index].commissionTypes"
placeholder="请选择"
style="width:120px"
@change="handleCommissionTypesChange($index)">
......@@ -43,15 +43,14 @@
</el-select>
</template>
</el-table-column>
<el-table-column v-for="(product, index) in curParamsConfig.products"
<el-table-column v-for="(product, index) in curParamsConfig.ParamsType1Products"
:key="index"
align="center"
prop="productLabel"
width="180px">
<template #header>
<template #header="{ $index }">
<div>
<el-cascader v-model="curParamsConfig.products[index].productLabel"
<el-cascader v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
......@@ -67,9 +66,9 @@
</template>
<template #default="{ $index }">
<EditableText v-model="curParamsConfig.products[index].productValue[$index]"
<EditableText v-model="curParamsConfig.ParamsType1Products[index].productValue[$index]"
:controls="false"
v-bind="curParamsConfig.commissionTypes[$index] && commissionTypeEnum[curParamsConfig.commissionTypes[$index]].componentProps"
v-bind="curParamsConfig.ParamsType1[$index].commissionTypes && commissionTypeEnum[curParamsConfig.ParamsType1[$index].commissionTypes].componentProps"
type="number">
</EditableText>
</template>
......@@ -164,17 +163,21 @@ export default {
// 删除商品列
handleRemoveProductsCol(productCol) {
this.curParamsConfig.products.splice(productCol, 1);
this.curParamsConfig.ParamsType1Products.splice(productCol, 1);
},
handleCommissionTypesChange() {},
// 清空该行所有productValue
handleCommissionTypesChange(row) {
this.curParamsConfig.ParamsType1Products.forEach((product) => {
this.$set(product.productValue, row, undefined);
});
},
// 删除行
handleRemoveTableRow(row) {
this.curParamsConfig.priceRange.splice(row, 1);
this.curParamsConfig.commissionTypes.splice(row, 1);
// 同步删除 products 里每个 product.productValue 的对应行
if (Array.isArray(this.curParamsConfig.products)) {
this.curParamsConfig.products.forEach((product) => {
this.curParamsConfig.ParamsType1.splice(row, 1);
// 同步删除 ParamsType1Products 里每个 product.productValue 的对应行
if (Array.isArray(this.curParamsConfig.ParamsType1Products)) {
this.curParamsConfig.ParamsType1Products.forEach((product) => {
if (Array.isArray(product.productValue)) {
product.productValue.splice(row, 1);
}
......
......@@ -2,25 +2,25 @@
<div class="params-config-table">
<el-table border
class="params-config-table"
:data="curParamsConfig.priceRange">
:data="curParamsConfig.ParamsType2">
<el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
width="270px">
<template #default="{ $index }">
<div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.priceRange[$index][0]"
<EditableText v-model="curParamsConfig.ParamsType2[$index].priceRange[0]"
:controls="false"
:disabled="$index === 0"
type="number"
v-bind="curParamsConfig.componentProps">
v-bind="curParamsConfig.priceRangeProps">
</EditableText>
<div class="tag">
-
</div>
<EditableText v-model="curParamsConfig.priceRange[$index][1]"
<EditableText v-model="curParamsConfig.ParamsType2[$index].priceRange[1]"
:controls="false"
type="number"
v-bind="curParamsConfig.componentProps">
v-bind="curParamsConfig.priceRangeProps">
</EditableText>
</div>
</template>
......@@ -30,7 +30,7 @@
label="商品分类"
width="180">
<template #default="{ $index }">
<el-cascader v-model="curParamsConfig.products[$index].productLabel"
<el-cascader v-model="curParamsConfig.ParamsType2[$index].productLabel"
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
......@@ -40,20 +40,30 @@
<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>
<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>
</template>
<template #default="{ row }">
<component :is="paramConfigConditionType[curParamsConfig.condition].component"></component>
<template #default="{ $index }">
<div class="condition-wrapper">
<component :is="paramConfigConditionType[curParamsConfig.ParamsType2[$index].condition].component"
:config-index="configIndex"
:row="$index" />
<span v-if="curParamsConfig.ParamsType2[$index].condition !== 0"
class="el-icon-sort icon"
style="line-height:normal;height:14px; vertical-align: middle;"
@click="handleChangeCondition($index)">
</span>
</div>
</template>
</el-table-column>
......@@ -62,14 +72,14 @@
label="操作"
width="120">
<template #default="{ $index }">
<el-button v-if="curParamsConfig.condition === 0"
<el-button v-if="curParamsConfig.ParamsType2[$index].condition === 0"
type="text"
@click="handleChangeCondition()">
@click="curParamsConfig.ParamsType2[$index].condition = 1">
设置条件
</el-button>
<el-button v-else
type="text"
@click="handleCancelConditionSetting()">
@click="handleCancelConditionSetting($index)">
取消条件
</el-button>
<el-button type="text"
......@@ -94,6 +104,8 @@ export default {
components: {
EditableText,
Type0,
Type1,
Type2,
},
props: {
configIndex: {
......@@ -140,15 +152,18 @@ export default {
methods: {
handleCommissionTypesChange() {},
handleRemoveTableRow() {},
handleCancelConditionSetting() {
this.curParamsConfig.condition = 0;
// 取消设置条件
handleCancelConditionSetting(row) {
this.curParamsConfig.ParamsType2[row].condition = 0;
},
handleChangeCondition(index) {
if (this.curParamsConfig.condition >= 2) {
this.curParamsConfig.condition = 1;
// 条件变化
handleChangeCondition(row) {
const curCondition = this.curParamsConfig.ParamsType2[row].condition;
if (curCondition >= 2) {
this.curParamsConfig.ParamsType2[row].condition = 1;
return;
}
this.curParamsConfig.condition += 1;
this.curParamsConfig.ParamsType2[row].condition += 1;
},
handleProductChange(value) {
console.log("product change", value);
......@@ -161,6 +176,21 @@ export default {
.params-config-table {
width: 100%;
margin-bottom: 20px !important;
.condition-wrapper {
display: flex;
width: 100%;
bottom: 1px solid red;
align-items: center;
justify-content: flex-start;
> .icon {
margin-left: 6px;
cursor: pointer;
transition: color 200ms;
&:hover {
color: #2a58ad;
}
}
}
::v-deep .el-table {
.el-table__header {
th {
......
export { default as Type0 } from './type0.vue'
export { default as Type1 } from './type1.vue'
export { default as Type2 } from './type2.vue'
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 class="param-config-type-2-condition-type">
<el-form-item>
<el-input v-model="conditionTypeValue"></el-input>
</el-form-item>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "",
props: {
configIndex: {
type: Number,
required: true,
},
row: {
type: Number,
required: true,
},
},
data() {
......@@ -16,10 +28,14 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
conditionTypeValue() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType0;
},
},
mounted() {
console.log("当前组件所有 inject 内容:", this.$parent); // Vue2 内部属性,存储注入的内容
},
methods: {
......
<template>
<div class="">
<el-input></el-input>
<span>且按不足</span>
<el-input></el-input>
<span>订单数每单扣减</span>
<el-input></el-input>
<span>元.区间时执行</span>
<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>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "",
props: {
configIndex: {
type: Number,
required: true,
},
row: {
type: Number,
required: true,
},
},
data() {
......@@ -21,7 +33,24 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
triggerCondition() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.triggerCondition;
},
productLabel() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productLabel;
},
productValue() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.productValue;
},
permeabilityMin() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMin;
},
permeabilityMax() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType1.permeabilityMax;
},
},
mounted() {
......
<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 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>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "",
props: {
configIndex: {
type: Number,
required: true,
},
row: {
type: Number,
required: true,
},
},
data() {
......@@ -23,6 +31,17 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData"]),
triggerCondition() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.triggerCondition;
},
deductRate() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.deductRate;
},
perOrderDeductAmount() {
return this.formData.paramConfigList[this.configIndex].ParamsType2[this.row].conditionType2.perOrderDeductAmount;
},
},
mounted() {
......
......@@ -99,6 +99,12 @@ export default {
assessmentFactorValue: [],
assessmentFactorOptions,
isUpdating: false, // 防止循环更新
// 提成基数和提成方式的对应关系:基数 <-> 方式
commissionMapping: {
GMV: "BL", // GMV产值 <-> 比例
DDTC: "XS", // 单店总提成 <-> 系数
DDSL: "GDJE", // 升级订单数 <-> 固定金额
},
};
},
computed: {
......@@ -111,97 +117,86 @@ export default {
goodsConfigTypes: bindFormFields("goodsConfigTypes"),
paramConfigList: bindFormFields("paramConfigList"),
},
watch: {
commissionTypes(newVal) {
// TODO: 还需要清空下方表格所有提成方式的值
this.setCommissionTypesOptions(newVal);
},
},
mounted() {
},
methods: {
...mapMutations("PerformanceFormStore", ["setProductDefineList", "touchAssessment", "setCommissionTypesOptions"]),
...mapMutations("PerformanceFormStore", ["setProductDefineList", "touchAssessment", "setCommissionTypesOptions", "setCommissionBases", "setCommissionTypes"]),
/**
* 更新关联的复选框
* @param {Array} currentValues 当前变化的值
* @param {Array} targetValues 目标值数组
* @param {boolean} isBasesToTypes 是否从基数更新到方式
*/
updateLinkedCheckboxes(currentValues, targetValues, isBasesToTypes) {
const newTargetValues = [...targetValues];
Object.entries(this.commissionMapping).forEach(([baseKey, typeKey]) => {
if (isBasesToTypes) {
// 从基数更新方式
if (currentValues.includes(baseKey)) {
// 基数包含 -> 方式要包含
if (!newTargetValues.includes(typeKey)) {
newTargetValues.push(typeKey);
}
} else {
// 基数不包含 -> 方式要移除
const index = newTargetValues.indexOf(typeKey);
if (index > -1)
newTargetValues.splice(index, 1);
}
} else {
// 从方式更新基数
if (currentValues.includes(typeKey)) {
// 方式包含 -> 基数要包含
if (!newTargetValues.includes(baseKey)) {
newTargetValues.push(baseKey);
}
} else {
// 方式不包含 -> 基数要移除
const index = newTargetValues.indexOf(baseKey);
if (index > -1)
newTargetValues.splice(index, 1);
}
}
});
return newTargetValues;
},
handleGoodsConfigTypesChange(value) {
this.dialog.defineProducts.visible = true;
},
handleDefineProductsDialogClose(productDefineList) {
this.setProductDefineList(productDefineList);
this.dialog.defineProducts.visible = false;
},
handleCommissionBasesChange(e) {
if (this.isUpdating)
return;
this.isUpdating = true;
const newTypes = [...this.commissionTypes];
// GMV 产值 <-> 比例 (BL)
if (e.includes("GMV")) {
if (!newTypes.includes("BL"))
newTypes.push("BL");
} else {
const index = newTypes.indexOf("BL");
if (index > -1)
newTypes.splice(index, 1);
}
// 单店总提成 <-> 系数 (XS)
if (e.includes("DDTC")) {
if (!newTypes.includes("XS"))
newTypes.push("XS");
} else {
const index = newTypes.indexOf("XS");
if (index > -1)
newTypes.splice(index, 1);
}
// 升级订单数 <-> 固定金额 (GDJE)
if (e.includes("DDSL")) {
if (!newTypes.includes("GDJE"))
newTypes.push("GDJE");
} else {
const index = newTypes.indexOf("GDJE");
if (index > -1)
newTypes.splice(index, 1);
}
this.$set(this, "commissionTypes", newTypes);
const newTypes = this.updateLinkedCheckboxes(e, this.commissionTypes, true);
this.setCommissionTypes(newTypes);
this.$nextTick(() => {
this.isUpdating = false;
});
},
handleCommissionTypesChange(e) {
if (this.isUpdating)
return;
this.isUpdating = true;
const newBases = [...this.commissionBases];
// 比例 (BL) <-> GMV 产值
if (e.includes("BL")) {
if (!newBases.includes("GMV"))
newBases.push("GMV");
} else {
const index = newBases.indexOf("GMV");
if (index > -1)
newBases.splice(index, 1);
}
// 系数 (XS) <-> 单店总提成
if (e.includes("XS")) {
if (!newBases.includes("DDTC"))
newBases.push("DDTC");
} else {
const index = newBases.indexOf("DDTC");
if (index > -1)
newBases.splice(index, 1);
}
// 固定金额 (GDJE) <-> 升级订单数
if (e.includes("GDJE")) {
if (!newBases.includes("DDSL"))
newBases.push("DDSL");
} else {
const index = newBases.indexOf("DDSL");
if (index > -1)
newBases.splice(index, 1);
}
this.$set(this, "commissionBases", newBases);
const newBases = this.updateLinkedCheckboxes(e, this.commissionBases, false);
this.setCommissionBases(newBases);
this.$nextTick(() => {
this.isUpdating = false;
});
......
......@@ -170,32 +170,60 @@ export const paramConfigListTemplate = {
// sort:在添加的时候输入
// priceRangeProps 在新增时动态插入
// 只有paramsType1 需要. 这里不是paramsType1Table的行数据
// 每一个item 代表 一列
// productValue里的顺序按照 row拍
// 如果
ParamsType1Products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
// 下面两个数据都是放到table中, 一个item对应一行所需的数据
ParamsType1: [
{
priceRange: [0, undefined],
commissionTypes: undefined,
products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
},
],
// 只有paramsType2 需要. 这里不是paramsType1Table的行数据
ParamsType2CommissionTypes: undefined,
ParamsType2: [
{
// 仅有一个输入框
conditionType0: undefined,
conditionType1: {
// 触发条件
triggerCondition: undefined,
// 商品占位
productLabel: undefined,
// 商品值
productValue: undefined,
// 渗透率上下限
permeabilityMin: undefined,
permeabilityMax: undefined,
},
conditionType2: {
// 触发条件
triggerCondition: undefined,
// 渗透率上下限
// 扣减比例
deductRate: undefined,
// 每单扣减金额
perOrderDeductAmount: undefined,
},
// 渗透率的条件
condition: 0,
priceRange: [0, undefined],
commissionTypes: undefined,
products: [
{
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
productLabel: "",
productValue: [undefined],
optionList: [],
},
],
......
<template>
<div class="selection-store-wrapper">
<div class="pre-select-store-wrapper select-store-wrapper">
<div class="title">
预选门店及品牌
</div>
<div class="search-wrapper">
<el-input placeholder="请输入门店名称/商户号" style="width:362px" />
<el-input placeholder="请输入品牌名称" style="width:142px;margin-left: 12px;" />
<el-button size="small"
style="margin-left: 12px"
type="primary">
查询
</el-button>
</div>
<div class="store-list-wrapper">
<el-table>
<el-table-column label="门店名称"
prop="name" />
<el-table-column label="品牌名称"
prop="account" />
</el-table>
</div>
</div>
<div class="select-store-wrapper select-wrapper">
<div class="title">
已选门店及品牌
</div>
<div class="actions-wrapper">
<div>
门店名称(x项)
</div>
<div>
<el-button type="te xt">
清空
</el-button>
</div>
</div>
<div class="store-list-wrapper">
<el-tree></el-tree>
</div>
</div>
<baseDialog :dialog-config="dialog.storeApply.visible"
:is-show.sync="dialog.storeApply.visible"
@handleClick="handleDialogConfirm">
</baseDialog>
</div>
<!-- <el-form class=""
label-width="170px"
:model="formData"
:rules="rules">
<div class="selection-table-store-wrapper">
<el-form-item label="分配门店账号:" prop="name">
<el-button size="small" @click="handleSelectStores">
<i class="el-icon-plus" style="font-size:14px" />
<span>选择门店</span>
</el-button>
<el-table :data="formData.table"
style="width: 100%">
<el-table-column label="门店名称"
prop="name" />
<el-table-column label="品牌名称"
prop="account" />
</el-table>
</el-form-item>
<el-form-item label="生效月份:" prop="effectiveTime">
<!-- <el-form-item label="生效月份:" prop="effectiveTime">
<el-date-picker v-model="formData.effectiveTime"
placeholder="选择日期"
type="month">
</el-date-picker>
</el-form-item>
</el-form-item> -->
<el-dialog :before-close="handleCloseDialog"
custom-class="store-select-dialog"
:title="dialog.storeApply.title"
:visible.sync="dialog.storeApply.visible"
width="70%">
<StoreSelect />
<template #footer>
<span class="dialog-footer">
<el-button @click="dialog.storeApply.visible = false">取消</el-button>
<el-button type="primary" @click="dialog.storeApply.visible = false">确定</el-button>
</span>
</template>
</el-dialog>
</el-form> -->
</div>
</template>
<script>
import { getStoreWithBrandList } from "../../api/index.js";
import StoreSelect from "../storeSelect/index.vue";
export default {
name: "",
props: {
formData: {
type: Object,
default: () => ({
}),
},
name: "StoreApply",
components: {
StoreSelect,
},
data() {
return {
......@@ -102,6 +45,7 @@ export default {
storeApply: {
title: "选择门店",
width: "60%",
visible: false,
},
},
......@@ -111,46 +55,44 @@ export default {
},
async mounted() {
const data = await getStoreWithBrandList();
console.log("data", data);
},
methods: {
handleSelectStores() {},
handleCloseDialog() {},
handleSelectStores() {
this.dialog.storeApply.visible = true;
},
handleDialogConfirm() {},
},
};
</script>
<style scoped lang="scss">
.selection-store-wrapper {
display: flex;
width: 100%;
.select-store-wrapper {
&.pre-select-store-wrapper {
flex: 1;
min-width: 616px;
.search-wrapper {
display: flex;
align-content: center;
padding: 12px 16px;
}
}
&.select-store-wrapper {
margin-left: 24px;
min-width: 39%;
> .actions-wrapper {
display: flex;
align-content: center;
justify-content: space-between;
padding: 12px 16px;
::v-deep .store-select-dialog {
.el-dialog__header {
border-bottom: 1px solid #e5e5e5;
}
.el-dialog__title {
color: #1d1d1d;
font-size: 16px;
font-weight: 500;
line-height: 20px;
}
.el-dialog__body {
padding-top: 20px;
padding-bottom: 20px;
.el-table {
&::before {
width: 0;
height: 0;
}
}
> .title {
padding: 0 16px;
line-height: 48px;
background: #f5f5f5;
color: #333;
font-size: 16px;
}
.el-dialog__footer {
border-top: 1px solid #e5e5e5;
padding-bottom: 10px;
.el-button {
width: auto;
}
}
}
......
<template>
<div class="">
<div class="selection-store-wrapper">
<div class="pre-select-store-wrapper">
<div class="title">
预选门店及品牌
</div>
<div class="search-wrapper">
<el-input v-model="queryParams.merchantName"
placeholder="请输入门店名称"
style="width:180px" />
<el-input v-model="queryParams.merchantId"
placeholder="请输入商户号"
style="width:180px;margin-left: 12px" />
<el-input v-model="queryParams.brandName"
placeholder="请输入品牌名称"
style="width:142px;margin-left: 12px;" />
<el-button size="small"
style="margin-left: 12px"
type="primary"
@click="getData">
查询
</el-button>
</div>
<div class="store-list-wrapper">
<el-table :data="merchantTable" height="450">
<el-table-column label="门店名称"
prop="merchantName" />
<el-table-column label="品牌名称">
<template #default="{ row, ...scope }">
<div>
<el-checkbox v-model="row.checkAll"
:indeterminate="row.isIndeterminate"
@change="handleCheckBrandAllChange($event, row, scope.$index)">
全选
</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="row.checkBrands" @change="handleCheckedBrandChange($event, row, scope.$index)">
<el-checkbox v-for="brand in row.merchantBrandList"
:key="brand.brandId"
:label="brand.brandId">
{{ brand.brandName }}
</el-checkbox>
</el-checkbox-group>
</div>
</template>
</el-table-column>
</el-table>
<div style="padding-bottom:12px;">
<el-pagination background
:current-page="queryParams.pageNum"
:page-size="queryParams.pageSize"
:page-sizes="[5, 10, 20, 30, 40]"
:total="queryParams.total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange" />
</div>
</div>
</div>
<div class="selected-store-wrapper select-wrapper">
<div class="title">
已选门店及品牌
</div>
<div class="actions-wrapper">
<div class="selected-count">
门店名称({{ getSelectedMerchantTable.length }}项)
</div>
<el-button type="text"
@click="handleClearSelected">
清空
</el-button>
</div>
<div class="store-list-wrapper">
<el-table :data="getSelectedMerchantTable" height="450">
<el-table-column label="门店名称"
prop="merchantName" />
<el-table-column label="品牌名称">
<template #default="{ row }">
<el-tag v-for="(brand, brandIndex) in row.checkBrands"
:key="brand.brandId"
closable
disable-transitions
@close="handleRemoveSelectedBrandTag(brand, row, brandIndex)">
{{ brand.brandName }}
</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</template>
<script>
// import { getStoreWithBrandList } from "@/api/mock/performance.mock.js";
import { getMerchantBrand } from "@api/resident.js";
export default {
name: "",
props: {
......@@ -12,21 +109,171 @@ export default {
},
data() {
return {
queryParams: {
merchantId: "",
merchantName: "",
brandName: "",
name: "",
currentPage: 1,
pageSize: 20,
total: 99,
},
merchantTable: [],
selectedMerchants: {},
};
},
computed: {
getSelectedMerchantTable() {
// 从selectedMerchants直接读取,不再依赖merchantTable
return Object.values(this.selectedMerchants);
},
},
mounted() {
async mounted() {
await this.getData();
},
methods: {
handleCurrentChange() {},
handleSizeChange() {},
handleCheckBrandAllChange(val, row, index) {
if (val) {
// 全选:保存所有品牌的brandId
row.checkBrands = row.merchantBrandList.map(brand => brand.brandId);
// 同时更新selectedMerchants,保存完整的品牌对象
const selectedBrands = row.merchantBrandList.map(brand => ({
brandId: brand.brandId,
brandName: brand.brandName,
}));
this.$set(this.selectedMerchants, row.merchantId, {
merchantId: row.merchantId,
merchantName: row.merchantName,
checkBrands: selectedBrands,
});
} else {
// 取消全选
row.checkBrands = [];
this.$delete(this.selectedMerchants, row.merchantId);
}
row.isIndeterminate = false;
},
handleCheckedBrandChange(value, row, index) {
// value 是 brandId 数组
row.checkAll = value.length === row.merchantBrandList.length;
row.isIndeterminate = value.length > 0 && value.length < row.merchantBrandList.length;
// 将 brandId 数组转换为品牌对象数组,保存到 selectedMerchants
if (value.length > 0) {
const selectedBrands = value.map((brandId) => {
const brand = row.merchantBrandList.find(b => b.brandId === brandId);
return {
brandId: brand.brandId,
brandName: brand.brandName,
};
});
this.$set(this.selectedMerchants, row.merchantId, {
merchantId: row.merchantId,
merchantName: row.merchantName,
checkBrands: selectedBrands,
});
} else {
this.$delete(this.selectedMerchants, row.merchantId);
}
},
handleRemoveSelectedBrandTag(brand, row, brandIndex) {
// 从selectedMerchants中删除该品牌
const selectedMerchant = this.selectedMerchants[row.merchantId];
if (selectedMerchant) {
const idx = selectedMerchant.checkBrands.findIndex(b => b.brandId === brand.brandId);
if (idx > -1) {
selectedMerchant.checkBrands.splice(idx, 1);
}
// 如果没有品牌了,删除整个门店
if (selectedMerchant.checkBrands.length === 0) {
this.$delete(this.selectedMerchants, row.merchantId);
}
}
// 同时更新merchantTable中对应行的checkBrands (存储的是brandId)
const merchantRow = this.merchantTable.find(m => m.merchantId === row.merchantId);
if (merchantRow) {
const idx = merchantRow.checkBrands.findIndex(bid => bid === brand.brandId);
if (idx > -1) {
merchantRow.checkBrands.splice(idx, 1);
}
merchantRow.checkAll = merchantRow.checkBrands.length === merchantRow.merchantBrandList.length;
merchantRow.isIndeterminate = merchantRow.checkBrands.length > 0 && merchantRow.checkBrands.length < merchantRow.merchantBrandList.length;
}
},
/**
* 清空已选的所有门店和品牌
*/
handleClearSelected() {
// 清空selectedMerchants
this.selectedMerchants = {};
// 同时清空merchantTable中每一行的checkBrands
this.merchantTable.forEach((merchant) => {
merchant.checkBrands = [];
merchant.checkAll = false;
merchant.isIndeterminate = false;
});
},
async getData() {
console.log("this.queryParams", this.queryParams);
const { pageNum, list, pageSize } = await getMerchantBrand(this.queryParams);
list.forEach((merchant, index) => {
merchant.checkAll = false;
merchant.isIndeterminate = false;
merchant.checkBrands = [];
});
this.merchantTable = list;
this.queryParams.currentPage = pageNum;
this.queryParams.pageSize = pageSize;
},
},
};
</script>
<style scoped lang="scss">
.selection-store-wrapper {
display: flex;
width: 100%;
> .pre-select-store-wrapper {
flex: 1;
min-width: 616px;
.search-wrapper {
display: flex;
align-content: center;
padding: 12px 16px;
}
}
> .selected-store-wrapper {
margin-left: 24px;
min-width: 39%;
> .actions-wrapper {
display: flex;
justify-content: space-between;
padding: 12px 16px;
.selected-count {
line-height: 36px;
}
}
}
.selected-store-wrapper,
.pre-select-store-wrapper {
border: 1px solid #e5e5e5;
.actions-wrapper,
.search-wrapper {
border-bottom: 1px solid #e5e5e5;
}
> .title {
line-height: 23px;
color: #333333;
font-size: 16px;
padding: 12px 16px;
background: #f5f5f5;
}
}
}
</style>
export { default as FormItemHelp } from "./components/formItemHelp/index.vue";
export { default as ParamConfigList } from "./components/paramConfigList/index.vue";
export * from "./components/performanceRuleSelection/options.js";
export { default as StoreApply } from "./components/storeApply/index.vue";
export { default as StoreSelect } from "./components/storeSelect/index.vue";
export * from "./store/helper.js";
export { default as performanceFormStore } from "./store/performanceFormStore.js";
......@@ -74,6 +74,7 @@ export default {
},
// 操作考核因子
touchAssessment(state, selectedItems) {
console.log("selectedItems", selectedItems);
state.formData.assessmentFactor = selectedItems.sort((a, b) => a.sort - b.sort);
if (!Array.isArray(state.formData.paramConfigList)) {
state.formData.paramConfigList = [];
......@@ -91,7 +92,7 @@ export default {
? existingConfigMap.get(sort)
: {
...structuredClone(paramConfigListTemplate),
priceRangeProps: item.rangeProps,
priceRangeProps: item.componentProps,
title: item.label,
assessmentFactor: item,
sort,
......
......@@ -5,8 +5,7 @@
label-width="170px"
:model="formData"
:rules="rules">
<!-- <div class="warp-box">
<div class="warp-box">
<div class="title space-b">
<div class="title-wrap">
<span>渠道配置</span>
......@@ -48,7 +47,7 @@
class="params-config-list"
:config-index="index" />
</div>
</div> -->
</div>
<div class="warp-box">
<div class="title space-b">
......@@ -79,6 +78,9 @@ import PerformanceRuleSelection from "../components/performanceRuleSelection/ind
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: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!