Commit 8b09042c by Jaxon

feat(performance): 新增门店提成方案配置功能并修复相关问题

- 新增获取方案详情API `getConfigMerchantDetail`
- 修复价格范围计算精度问题,统一使用0.01递增
- 优化数据转换逻辑,处理空值情况避免报错
- 新增组件内路由守卫,离开时重置表单数据
- 完善商品分类和圈定商品的数据加载
- 修复级联选择器配置,支持严格检查模式
- 优化业务类型切换逻辑,自动加载对应方案
- 重构Vuex store,新增表单重置功能
- 格式化代码并更新配置中心URL
1 parent e1ced013
...@@ -602,6 +602,12 @@ export function postBrandMerchant(data) { ...@@ -602,6 +602,12 @@ export function postBrandMerchant(data) {
data.method = `dj.staff.api.performance.config.valid.merchant.brand.by.merchant`; data.method = `dj.staff.api.performance.config.valid.merchant.brand.by.merchant`;
return request(data, "post"); return request(data, "post");
} }
// 新增 工资绩效 方案
export function getConfigMerchantDetail(data) {
data.method = `dj.staff.api.performance.config.merchant.detail`;
return request(data, "post");
}
// 校验圈定产品/套餐是否可被删除 // 校验圈定产品/套餐是否可被删除
export function checkProductDefineAPI(data) { export function checkProductDefineAPI(data) {
data.method = `${path2}merchantPerformanceProductDefine.deleteValid`; data.method = `${path2}merchantPerformanceProductDefine.deleteValid`;
......
import { BrowserTracing } from "@sentry/tracing";
// 接入sentry
import * as Sentry from "@sentry/vue";
import { Request } from "glsk-toolkit";
// Vue // Vue
import Vue from "vue" import Vue from "vue";
// import axios from 'axios' // import { GLCombiForm } from "glsx-components" // 权限按钮 (根据权限动态创建)
// import i18n from './i18n' import VueLazyload from "vue-lazyload";
import App from "./App"
import { config } from "@/common/baseConfig";
import GLMapSdk from "@/common/glsk-mapapi-sdk";
import notice from "@/common/notice";
import util from "@/libs/util.js";
// 针对template模板中使用可选链操作符
import chaining from "@/plugin/chaining";
// 核心插件 // 核心插件
import d2Admin from "@/plugin/d2admin" import d2Admin from "@/plugin/d2admin";
// store // store
import store from "@/store/index" import store from "@/store/index";
// 针对template模板中使用可选链操作符 // import axios from 'axios'
import chaining from "@/plugin/chaining" // import i18n from './i18n'
import App from "./App";
// 接入sentry
import * as Sentry from "@sentry/vue"
import { BrowserTracing } from "@sentry/tracing"
// import D2Crud from '@d2-projects/d2-crud' // import D2Crud from '@d2-projects/d2-crud'
// 菜单和路由设置 // 菜单和路由设置
import router from "./router" import router from "./router";
import "default-passive-events" import "default-passive-events";
import notice from "@/common/notice" import "element-ui/lib/theme-chalk/index.css";
import "element-ui/lib/theme-chalk/index.css"
import { config } from "@/common/baseConfig"
import GLMapSdk from "@/common/glsk-mapapi-sdk"
// import { GLCombiForm } from "glsx-components" // 权限按钮 (根据权限动态创建)
import VueLazyload from "vue-lazyload"
import { Request } from "glsk-toolkit"
import util from "@/libs/util.js"
Vue.prototype.$mapapi = new GLMapSdk() Vue.prototype.$mapapi = new GLMapSdk();
Vue.use(VueLazyload, { Vue.use(VueLazyload, {
// 懒加载默认加载图片 // 懒加载默认加载图片
loading: loading:
"https://img02.glsx.com.cn/weapp/resource/saas/dj/images/img_loading.png", "https://img02.glsx.com.cn/weapp/resource/saas/dj/images/img_loading.png",
attempt: 3 // 尝试加载次数 attempt: 3, // 尝试加载次数
}) });
// 实例化 // 实例化
process.env.NODE_ENV === "production" && process.env.NODE_ENV === "production"
Sentry.init({ && Sentry.init({
Vue, Vue,
dsn: "https://39bc80d3bb0a419a8d7d9bf5a39678e3@sentry.glsx.com.cn/24", dsn: "https://39bc80d3bb0a419a8d7d9bf5a39678e3@sentry.glsx.com.cn/24",
// dsn: 'http://6225fb8e73fb453a8455a9371f3517da@192.168.3.115:9000/4', // dsn: 'http://6225fb8e73fb453a8455a9371f3517da@192.168.3.115:9000/4',
integrations: [ integrations: [
new BrowserTracing({ new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router), routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ["localhost", "my-site-url.com", /^\//] tracingOrigins: ["localhost", "my-site-url.com", /^\//],
}) }),
], ],
// Set tracesSampleRate to 1.0 to capture 100% // Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring. // of transactions for performance monitoring.
// We recommend adjusting this value in production // We recommend adjusting this value in production
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
logErrors: true, logErrors: true,
// 解决火狐浏览器 无法捕获错误的问题 // 解决火狐浏览器 无法捕获错误的问题
beforeSend(event, hint) { beforeSend(event, hint) {
const isNonErrorException = const isNonErrorException
event.exception.values[0].value.startsWith( = event.exception.values[0].value.startsWith(
"Non-Error exception captured" "Non-Error exception captured",
) || )
hint.originalException.message.startsWith( || hint.originalException.message.startsWith(
"Non-Error exception captured" "Non-Error exception captured",
) );
if (isNonErrorException) { if (isNonErrorException) {
// We want to ignore those kind of errors // We want to ignore those kind of errors
return null return null;
} }
return event return event;
} },
// "send-default-pii": true // "send-default-pii": true
}) });
// d2Admin 已导入 // d2Admin 已导入
// import ElementUI from 'element-ui' // import ElementUI from 'element-ui'
// Vue.use(ElementUI) // Vue.use(ElementUI)
// 核心插件 // 核心插件
Vue.use(d2Admin) Vue.use(d2Admin);
Vue.use(chaining) Vue.use(chaining);
// Vue.use(GLCombiForm) // Vue.use(GLCombiForm)
Vue.prototype.notice = notice Vue.prototype.notice = notice;
const isProd = process.env.NODE_ENV === "production" const isProd = process.env.NODE_ENV === "production";
// console.log(isProd) // console.log(isProd)
if (!isProd) { if (!isProd) {
Vue.config.devtools = true Vue.config.devtools = true;
} }
Vue.prototype.$EventBus = new Vue() Vue.prototype.$EventBus = new Vue();
Vue.directive("preventReClick", { Vue.directive("preventReClick", {
bind: (el, binding) => { bind: (el, binding) => {
let time = binding.value // 防抖时间 let time = binding.value; // 防抖时间
if (!time) { if (!time) {
// 用户若不设置防抖时间,则默认1s // 用户若不设置防抖时间,则默认1s
time = 1000 time = 1000;
} }
let fun let fun;
el.addEventListener( el.addEventListener(
"click", "click",
(event) => { (event) => {
if (!fun) { if (!fun) {
// 第一次执行 // 第一次执行
fun = setTimeout(() => { fun = setTimeout(() => {
fun = null fun = null;
}, time) }, time);
} else { } else {
// 直接取消当前事件 // 直接取消当前事件
event && event.stopImmediatePropagation() event && event.stopImmediatePropagation();
} }
}, },
true true,
) );
} },
}) });
let baseConfig = config let baseConfig = config;
// 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取 // 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取
fetch( fetch(
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config" "https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config-sj",
) )
.then( .then(
(response) => { (response) => {
// 处理http响应 // 处理http响应
return response.json() return response.json();
}, },
(error) => { (error) => {
// 处理错误 // 处理错误
console.log(error) console.log(error);
} },
) )
.then((response) => { .then((response) => {
const { code, data } = response const { code, data } = response;
console.log("response", code, response) console.log("response", code, response);
if (code == "200") { if (code == "200") {
console.log(data) console.log(data);
baseConfig = data baseConfig = data;
// console.log("baseConfig", baseConfig) // console.log("baseConfig", baseConfig)
// window.$fetchConfig = data // window.$fetchConfig = data
} else { } else {
baseConfig = response baseConfig = response;
window.$fetchConfig = response window.$fetchConfig = response;
console.log(response) console.log(response);
window.$gscApi = new Request({ window.$gscApi = new Request({
...response.gsc, ...response.gsc,
// baseURL:'http://192.168.3.145:9898/gsc-vcp-web-facade', // baseURL:'http://192.168.3.145:9898/gsc-vcp-web-facade',
// baseURL: 'http://gsc.test.glsx.com.cn/gsc-vcp-web-facade', // baseURL: 'http://gsc.test.glsx.com.cn/gsc-vcp-web-facade',
session: { session: {
requiresSession: true, requiresSession: true,
sessionId: (_) => util.cookies.get("token") sessionId: _ => util.cookies.get("token"),
}, },
events: { events: {
error: (error, config) => { error: (error, config) => {
Vue.prototype.$message.error(error.msg) Vue.prototype.$message.error(error.msg);
}, },
logout: (response, config) => { logout: (response, config) => {
store.dispatch("d2admin/user/clear") store.dispatch("d2admin/user/clear");
util.cookies.remove("token") util.cookies.remove("token");
router.replace("/login") router.replace("/login");
Vue.prototype.$message.error("登录超时,请重新登录") Vue.prototype.$message.error("登录超时,请重新登录");
} },
} },
}) });
console.log(window.$gscApi, "========") console.log(window.$gscApi, "========");
} }
}) })
.finally(() => { .finally(() => {
init() init();
}) });
function init() { function init() {
new Vue({ new Vue({
router, router,
store, store,
// i18n, // i18n,
render: (h) => { render: (h) => {
// baseConfig.axios.baseURL = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router' // baseConfig.axios.baseURL = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// data // data
// console.log(data) // console.log(data)
Vue.prototype.baseConfig = baseConfig Vue.prototype.baseConfig = baseConfig;
return h(App) return h(App);
}, },
created() { created() {
// 系统配置 // 系统配置
Vue.config.devtools = true Vue.config.devtools = true;
// 展示系统信息 // 展示系统信息
this.$store.commit("d2admin/releases/versionShow") this.$store.commit("d2admin/releases/versionShow");
// 用户登录后从数据库加载一系列的设置 // 用户登录后从数据库加载一系列的设置
this.$store.dispatch("d2admin/account/load") this.$store.dispatch("d2admin/account/load");
// 获取并记录用户 UA // 获取并记录用户 UA
this.$store.commit("d2admin/ua/get") this.$store.commit("d2admin/ua/get");
// 初始化全屏监听 // 初始化全屏监听
this.$store.dispatch("d2admin/fullscreen/listen") this.$store.dispatch("d2admin/fullscreen/listen");
}, },
mounted() {} mounted() {},
}).$mount("#app") }).$mount("#app");
} }
export { baseConfig } export { baseConfig };
<template> <template>
<div> <div>
<el-form-item label="适配业务:" prop="businessType"> <el-form-item label="适配业务:" prop="businessType">
<el-radio-group v-model="businessType"> <el-radio-group v-model="businessType" @change="handleChangeBusinessType">
<el-radio :disabled="!businessTypes.includes(0)" label="0"> <el-radio :disabled="!businessTypes.includes(0)" :label="0">
轻改 轻改
</el-radio> </el-radio>
<el-radio :disabled="!businessTypes.includes(1)" label="1"> <el-radio :disabled="!businessTypes.includes(1)" :label="1">
延保 延保
</el-radio> </el-radio>
<el-radio :disabled="!businessTypes.includes(2)" label="2"> <el-radio :disabled="!businessTypes.includes(2)" :label="2">
权益 权益
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="品牌" prop="businessType"> <el-form-item label="品牌:"
<el-radio-group v-model="businessType"> prop="businessType">
<el-radio-group v-model="businessType" @change="handleChangeBusinessType">
<el-radio v-for="item in brandMerchant" <el-radio v-for="item in brandMerchant"
:key="item.businessType" :key="item.businessType"
:label="item.businessType"> :label="item.businessType">
...@@ -50,9 +51,20 @@ export default { ...@@ -50,9 +51,20 @@ export default {
}, },
}, },
async mounted() { async mounted() {
setTimeout(() => {
if (this.brandMerchant[0]?.businessType) {
this.businessType = this.brandMerchant[0].businessType;
this.handleChangeBusinessType(this.businessType);
}
}, 300);
}, },
methods: { methods: {
handleChangeBusinessType(e) {
const item = this.brandMerchant.find(item => item.businessType === e);
if (item) {
this.$emit("changeBusiness", item);
}
},
}, },
}; };
......
...@@ -92,7 +92,7 @@ export default { ...@@ -92,7 +92,7 @@ export default {
const lastPriceRange = last(this.curParamsConfig[templateType])?.priceRange || [0, 0]; const lastPriceRange = last(this.curParamsConfig[templateType])?.priceRange || [0, 0];
const nPriceRange = [undefined, undefined]; const nPriceRange = [undefined, undefined];
if (lastPriceRange && lastPriceRange[1]) { if (lastPriceRange && lastPriceRange[1]) {
nPriceRange[0] = lastPriceRange[1] + (this.curParamsConfig.priceRangeProps.precision ? 1 : 0.01); nPriceRange[0] = lastPriceRange[1] + 0.01;
nPriceRange[1] = undefined; nPriceRange[1] = undefined;
} }
this.curParamsConfig[templateType].push({ this.curParamsConfig[templateType].push({
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
v-model="curParamsConfig.ParamsType1Products[index].productLabel" v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:options="getProductDefineListOptions" :options="getProductDefineListOptions"
placeholder="请选择圈定商品/套餐" placeholder="请选择圈定商品/套餐"
:props="{ checkStrictly: true }"
:show-all-levels="false" :show-all-levels="false"
@change="handleProductChange"> @change="handleProductChange">
</el-cascader> </el-cascader>
...@@ -138,15 +139,12 @@ export default { ...@@ -138,15 +139,12 @@ export default {
computed: { computed: {
...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]), ...mapState("PerformanceFormStore", ["formData", "productDefineList", "commissionTypesOptions"]),
getProductDefineListOptions() { getProductDefineListOptions() {
const res = []; console.log("this.productDefineList", this.productDefineList);
if (this.formData.goodsConfigTypes.includes("-1")) {
res.push({ return this.productDefineList.map(item => ({
label: "商品/套餐", label: item.label,
value: -1, value: item.value,
children: this.productDefineList, }));
});
}
return res;
}, },
paramsTables: { paramsTables: {
get() { get() {
...@@ -168,7 +166,6 @@ export default { ...@@ -168,7 +166,6 @@ export default {
return this.formData.goodsConfigTypes.length >= 2 && !this.hasSelectedProduct; return this.formData.goodsConfigTypes.length >= 2 && !this.hasSelectedProduct;
}, },
hasSelectedProduct() { hasSelectedProduct() {
console.log("this.curParamsConfig.ParamsType1Products.filter(product => product.productLabel.length > 0);", this.curParamsConfig.ParamsType1Products.find(product => product.productLabel.length > 0));
return this.curParamsConfig.ParamsType1Products.find(product => product.productLabel.length > 0); return this.curParamsConfig.ParamsType1Products.find(product => product.productLabel.length > 0);
}, },
curParamsConfig: { curParamsConfig: {
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
<el-form-item label="商品分类:" <el-form-item label="商品分类:"
prop="goodsConfigTypes"> prop="goodsConfigTypes">
<el-checkbox-group v-model="goodsConfigTypes" <el-checkbox-group v-model="goodsConfigTypes"
class="checkbox-group-product-category "> class="checkbox-group-product-category "
@change="handleGoodsConfigTypesGroupChange">
<el-checkbox label="0"> <el-checkbox label="0">
品类 品类
</el-checkbox> </el-checkbox>
...@@ -142,6 +143,13 @@ export default { ...@@ -142,6 +143,13 @@ export default {
methods: { methods: {
...mapMutations("PerformanceFormStore", ["setProductDefineList", "touchAssessment", "setCommissionTypesOptions", "setCommissionBases", "setCommissionTypes"]), ...mapMutations("PerformanceFormStore", ["setProductDefineList", "touchAssessment", "setCommissionTypesOptions", "setCommissionBases", "setCommissionTypes"]),
handleGoodsConfigTypesGroupChange(e) {
if (e.length === 1) {
// TODO: 强力设置表格内的所有goodType
}
},
/** /**
* 更新关联的复选框 * 更新关联的复选框
* @param {Array} currentValues 当前变化的值 * @param {Array} currentValues 当前变化的值
...@@ -219,7 +227,6 @@ export default { ...@@ -219,7 +227,6 @@ export default {
handleAssessmentFactorChange(value) { handleAssessmentFactorChange(value) {
// 根据 value 数组从 assessmentFactorOptions 中找出对应的完整项 // 根据 value 数组从 assessmentFactorOptions 中找出对应的完整项
const selectedItems = this.assessmentFactorOptions.filter(item => value.includes(item.value)); const selectedItems = this.assessmentFactorOptions.filter(item => value.includes(item.value));
console.log(selectedItems);
this.touchAssessment(selectedItems); this.touchAssessment(selectedItems);
}, },
}, },
......
...@@ -8,7 +8,7 @@ export function convertBackendToData(data) { ...@@ -8,7 +8,7 @@ export function convertBackendToData(data) {
...handlePerformanceConfigRule(performanceConfigRule), ...handlePerformanceConfigRule(performanceConfigRule),
merchantBrandRefList: dealInterfaceBrand(merchantBrandRefList), merchantBrandRefList: dealInterfaceBrand(merchantBrandRefList),
paramConfigList: coverParamConfigList(paramConfigList), paramConfigList: coverParamConfigList(paramConfigList || data.performanceParamConfigs),
}; };
return response; return response;
} }
...@@ -84,7 +84,7 @@ export function coverParamConfigList(paramConfigList) { ...@@ -84,7 +84,7 @@ export function coverParamConfigList(paramConfigList) {
Object.keys(rowTable).forEach((rowIndex, rowEachIndex) => { Object.keys(rowTable).forEach((rowIndex, rowEachIndex) => {
const rowItem = rowTable[rowIndex][rowEachIndex]; const rowItem = rowTable[rowIndex][rowEachIndex];
paramsTypeProductsItem.productValue.push(rowItem.commissionTypeValue); paramsTypeProductsItem.productValue.push(rowItem?.commissionTypeValue);
}); });
baseTable.ParamsType1Products.push(paramsTypeProductsItem); baseTable.ParamsType1Products.push(paramsTypeProductsItem);
......
...@@ -28,6 +28,9 @@ export function convertDataToBackend(formData) { ...@@ -28,6 +28,9 @@ export function convertDataToBackend(formData) {
paramConfigList: [], paramConfigList: [],
merchantBrandRefList: [], merchantBrandRefList: [],
}; };
if (data.originPerformanceConfigId) {
requestData.originPerformanceConfigId = data.originPerformanceConfigId;
}
for (const paramConfig of paramConfigList) { for (const paramConfig of paramConfigList) {
// 每一份表格 // 每一份表格
const { templateType, ParamsType1, ParamsType1Products, ParamsType2 } = paramConfig; const { templateType, ParamsType1, ParamsType1Products, ParamsType2 } = paramConfig;
...@@ -65,7 +68,9 @@ export function convertDataToBackend(formData) { ...@@ -65,7 +68,9 @@ export function convertDataToBackend(formData) {
} }
console.log("convertDataToBackend", merchantBrandRefList); console.log("convertDataToBackend", merchantBrandRefList);
// 整理门店 // 整理门店
requestData.merchantBrandRefList = buildMerchantBrandPayload(merchantBrandRefList, data.businessType); if (merchantBrandRefList) {
requestData.merchantBrandRefList = buildMerchantBrandPayload(merchantBrandRefList, data.businessType);
}
return requestData; return requestData;
} }
......
...@@ -87,6 +87,7 @@ import StoreApply from "../components/storeApply/index.vue"; ...@@ -87,6 +87,7 @@ import StoreApply from "../components/storeApply/index.vue";
import { bindFormFields } from "../store/helper.js"; import { bindFormFields } from "../store/helper.js";
import { convertBackendToData } from "../utils/convertBackendToData.js"; import { convertBackendToData } from "../utils/convertBackendToData.js";
import { convertDataToBackend } from "../utils/index.js"; import { convertDataToBackend } from "../utils/index.js";
// 提成方案配置 // 提成方案配置
export default { export default {
name: "", name: "",
...@@ -96,6 +97,12 @@ export default { ...@@ -96,6 +97,12 @@ export default {
StoreApply, StoreApply,
DetailDialog, DetailDialog,
}, },
// 核心:组件内路由离开守卫
beforeRouteLeave(to, from, next) {
// 必须调用next(),允许路由跳转
this.resetFormData();
next();
},
props: { props: {
}, },
...@@ -117,6 +124,7 @@ export default { ...@@ -117,6 +124,7 @@ export default {
await this.getData(this.$route?.query?.id); await this.getData(this.$route?.query?.id);
} }
}, },
methods: { methods: {
...mapMutations("PerformanceFormStore", [ ...mapMutations("PerformanceFormStore", [
"setFormData", "setFormData",
...@@ -126,6 +134,7 @@ export default { ...@@ -126,6 +134,7 @@ export default {
"touchAssessment", "touchAssessment",
"setAssessmentFactorValue", "setAssessmentFactorValue",
"setParamConfigList", "setParamConfigList",
"resetFormData",
]), ]),
// 提交审核 // 提交审核
...@@ -136,8 +145,8 @@ export default { ...@@ -136,8 +145,8 @@ export default {
handleCheckClose(e) { handleCheckClose(e) {
this.detailVisible = !this.detailVisible; this.detailVisible = !this.detailVisible;
if(e.isConfirm) { if (e.isConfirm) {
this.handleCancelSubmit() this.handleCancelSubmit();
} }
}, },
// 提交保存 // 提交保存
...@@ -148,16 +157,16 @@ export default { ...@@ -148,16 +157,16 @@ export default {
}); });
if (this.formData.id) { if (this.formData.id) {
params.id = this.formData.id; params.id = this.formData.id;
if (this.formData.schemeType) { if (this.formData.schemeType) {
params.schemeType = this.formData.schemeType; params.schemeType = this.formData.schemeType;
} }
} }
let res = await postSalaryPerformanceScheme(params); let res = await postSalaryPerformanceScheme(params);
console.log(res, 'res') this.id = res;
if(res && isConfirm) { console.log(res, "res");
this.$message.success('保存成功') if (res && isConfirm) {
this.handleCancelSubmit() this.$message.success("保存成功");
this.handleCancelSubmit();
} }
// console.log("handleSubmitSave", params); // console.log("handleSubmitSave", params);
// await postSalaryPerformanceScheme(params); // await postSalaryPerformanceScheme(params);
...@@ -165,6 +174,8 @@ export default { ...@@ -165,6 +174,8 @@ export default {
}, },
// 取消按钮 // 取消按钮
handleCancelSubmit() { handleCancelSubmit() {
// 清空 vuex 数据
if (window.history.length > 1) { if (window.history.length > 1) {
this.$router.back(); this.$router.back();
} else { } else {
...@@ -181,7 +192,6 @@ export default { ...@@ -181,7 +192,6 @@ export default {
}, },
async getData(id) { async getData(id) {
const data = await getPerformanceConfigDetailAPI({ id }); const data = await getPerformanceConfigDetailAPI({ id });
console.log("getData", data);
const { merchantBrandRefList, ...performance } = convertBackendToData(data); const { merchantBrandRefList, ...performance } = convertBackendToData(data);
this.setMerchantBrandRefList(merchantBrandRefList); this.setMerchantBrandRefList(merchantBrandRefList);
const assessmentKeys = Object.keys(groupBy(performance.paramConfigList, "assessmentFactor")).map(Number); const assessmentKeys = Object.keys(groupBy(performance.paramConfigList, "assessmentFactor")).map(Number);
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
</div> </div>
</div> </div>
<div class="warp-content"> <div class="warp-content">
<ChannelConfig :brand-merchant="brandMerchantList"></ChannelConfig> <ChannelConfig v-if="brandMerchantList.length"
:brand-merchant="brandMerchantList"
@changeBusiness="handleChangeBusinessType">
</ChannelConfig>
</div> </div>
</div> </div>
<div class="warp-box"> <div class="warp-box">
...@@ -80,17 +83,28 @@ ...@@ -80,17 +83,28 @@
</el-button> </el-button>
</div> </div>
</el-form> </el-form>
<DetailDialog v-if="detailVisible"
:id="id"
:detail-visible="detailVisible"
:is-edit="true"
@dialogClose="handleCheckClose">
</DetailDialog>
</d2-container> </d2-container>
</template> </template>
<script> <script>
import { groupBy } from "lodash-es";
import { mapGetters, mapMutations, mapState } from "vuex"; import { mapGetters, mapMutations, mapState } from "vuex";
import { postBrandMerchant } from "@/api/resident"; import { getAllCategory } from "@/api/product.js";
import { getConfigMerchantDetail, getPerformanceConfigDetailAPI, getTargetProductConfigListAPI, postBrandMerchant, postSalaryPerformanceScheme } from "@/api/resident";
import detailDialog from "../../components/approvalView"; import detailDialog from "../../components/approvalView";
import ChannelConfig from "../components/channelConfig/index.vue"; import ChannelConfig from "../components/channelConfig/index.vue";
import ParamConfigList from "../components/paramConfigList/index.vue"; import ParamConfigList from "../components/paramConfigList/index.vue";
import PerformanceRuleSelection from "../components/performanceRuleSelection/index.vue"; import PerformanceRuleSelection from "../components/performanceRuleSelection/index.vue";
import { assessmentFactorOptions } from "../components/performanceRuleSelection/options.js";
import { bindFormFields } from "../store/helper.js"; import { bindFormFields } from "../store/helper.js";
import { convertBackendToData } from "../utils/convertBackendToData.js";
import { convertDataToBackend } from "../utils/index.js";
// 门店提成方案 // 门店提成方案
export default { export default {
...@@ -109,6 +123,9 @@ export default { ...@@ -109,6 +123,9 @@ export default {
brandMerchantList: [], brandMerchantList: [],
rules: { rules: {
}, },
detailVisible: false,
detailVisibleId: undefined,
pickerOptions: { pickerOptions: {
disabledDate(time) { disabledDate(time) {
// 最早:2025-01 // 最早:2025-01
...@@ -147,18 +164,63 @@ export default { ...@@ -147,18 +164,63 @@ export default {
} }
}, },
methods: { methods: {
...mapMutations("PerformanceFormStore", [
"setFormData",
"setProductDefineList",
"setGoodsCategory",
"setMerchantBrandRefList",
"touchAssessment",
"setAssessmentFactorValue",
"setParamConfigList",
"resetFormData",
]),
async handleChangeBusinessType({ id }) {
const data = await getConfigMerchantDetail({ id, merchantId: this.$route.query?.id });
const performance = convertBackendToData(data);
const assessmentKeys = Object.keys(groupBy(performance.paramConfigList, "assessmentFactor")).map(Number);
const selectAssessment = assessmentFactorOptions.filter(item => assessmentKeys.includes(item.value));
this.touchAssessment(selectAssessment);
this.setFormData({
...performance,
id,
});
this.setAssessmentFactorValue(assessmentKeys);
},
async handleSubmitCheck(isConfirm = false) {
const params = convertDataToBackend({
...this.formData,
merchantBrandRefList: this.merchantBrandRefList,
});
if (this.formData.id) {
params.id = this.formData.id;
}
if (this.formData.schemeType) {
params.schemeType = this.formData.schemeType;
}
let res = await postSalaryPerformanceScheme(params);
if (res && isConfirm) {
this.$message.success("保存成功");
this.handleCancelSubmit();
}
async handleSubmitCheck() {
// await postSalaryPerformanceScheme(convertDataToBackend({ // await postSalaryPerformanceScheme(convertDataToBackend({
// ...this.formData, // ...this.formData,
// merchantBrandRefList: this.merchantBrandRefList, // merchantBrandRefList: this.merchantBrandRefList,
// })); // }));
}, },
async getData(id) { async getData(id) {
this.brandMerchantList = await postBrandMerchant({ merchantId: id }); this.brandMerchantList = await postBrandMerchant({ merchantId: id });
// 获取品类
const { list } = await getAllCategory({ pageSize: 9999, currentPage: 1 });
this.setGoodsCategory(list);
// 获取圈定商品/套餐
const res = await getTargetProductConfigListAPI({ currentPage: 1, pageSize: 999 });
this.setProductDefineList(res?.list);
console.log(this.brandMerchantList);
}, },
handleCancel() { handleCancel() {
console.log(this.routeParams.page, "----");
// this.$EventBus.$emit("salaryPerformanceTab", { // this.$EventBus.$emit("salaryPerformanceTab", {
// tabName: this.routeParams.page // tabName: this.routeParams.page
// }) // })
......
  • @limin
    commented
    Owner

    你好,我是负责此次代码审查的资深软件开发工程师。我仔细阅读了你提交的代码,整体来看,本次提交涵盖了功能新增、Bug 修复以及部分架构优化(如 Vuex 重置),Commit 信息也非常规范。

    但在工程最佳实践、健壮性以及配置管理方面,存在几个值得关注的问题。以下是我的审查意见:

    一、关键问题与优化建议(Top 3)

    1. ❌ 严重工程实践问题:Store 中存在大量硬编码数据

    • 问题描述:在 src/views/residentManage/salaryPerformance/performanceScheme/store/performanceFormStore.js 文件中,goodsCategory 字段被硬编码了数百行的静态 JSON 数据(包含大量测试数据如 "测试类目"、"hahh1" 等)。
    • 影响分析:
      1. 代码污染:严重降低代码可读性,导致文件体积臃肿。
      2. 维护困难:品类数据通常是动态的,硬编码意味着每次后台数据变更都需要前端发版。
      3. 性能影响:增加了不必要的 Bundle 体积。
    • 优化建议:
      • 立即删除 Store 中的硬编码数据,恢复为空数组。
      • 保持在组件(如 configureStoreCommissionPlan.vue)中调用 getAllCategory 接口获取数据,并存储到 Vuex 中的逻辑(你已经写了这部分逻辑,因此 Store 中的静态数据完全是多余且有害的)。

    2. ⚠️ 逻辑健壮性问题:使用 setTimeout 处理异步数据依赖

    • 问题描述:在 src/views/residentManage/salaryPerformance/performanceScheme/components/channelConfig/index.vue 的 mounted 生命周期中,使用了 setTimeout(..., 300) 来延迟设置默认 businessType。 javascript setTimeout(() => { if (this.brandMerchant[0]?.businessType) { ... } }, 300);
    • 影响分析:这是典型的竞态条件(Race Condition)隐患。
      1. 如果父组件接口请求超过 300ms,子组件执行时 brandMerchant 仍为空,默认值设置将失效。
      2. 如果用户电脑卡顿,执行顺序不可控。
      3. 代码属于“靠运气运行”,极不稳定。
    • 优化建议:使用 watch 监听 props 的变化,或者在父组件获取到数据后再渲染子组件。 javascript // 建议修改为 watch watch: { brandMerchant: { immediate: true, handler(val) { if (val && val.length > 0 && this.businessType === undefined) { this.businessType = val[0].businessType; this.handleChangeBusinessType(this.businessType); } } } }

    3. ⚠️ 配置管理风险:main.js 中硬编码修改配置中心 URL

    • 问题描述:在 src/main.js 中,配置中心的 URL 从 dj-car-life-system-config 修改为了 dj-car-life-system-config-sj。
    • 影响分析:
      1. 如果 -sj 后缀代表特定的测试环境或临时租户,直接提交到主分支会导致生产环境获取不到配置,引发系统瘫痪。
      2. 这种环境差异应通过环境变量(.env 文件)或构建参数控制,而不是硬编码在源码中。
    • 优化建议:
      • 请确认该修改是否应当上线。
      • 如果是必须的变更,建议提取为配置项;如果是本地调试遗留,请务必回滚。

    二、评分明细

    1. 功能实现的正确性与健壮性(32/40分)

      • 扣分点:channelConfig 组件使用 setTimeout 处理数据初始化,存在严重的竞态风险;main.js 中的 URL 修改风险较高。
      • 亮点:在 approvalView.vue 中将 v-html 替换为文本插值,提升了安全性;新增了路由离开守卫重置 Store,防止数据污染。
    2. 安全性与潜在风险(28/30分)

      • 扣分点:无明显扣分。
      • 亮点:主动移除了 v-html,有效防止了潜在的 XSS 攻击风险。
    3. 最佳实践与可维护性(10/20分)

      • 扣分点:Store 文件中包含大量测试用的硬编码 JSON 数据,这是非常糟糕的工程实践;main.js 中保留了大量注释掉的旧代码,显得杂乱。
      • 亮点:Commit 信息非常清晰规范。
    4. 性能与资源利用(4/5分)

      • 扣分点:Store 中的冗余数据增加了少许包体积。
    5. 提交信息质量(5/5分)

      • 亮点:Commit message 格式规范(type: subject),内容详实,清晰地描述了修改目的和范围。

    三、总分

    总分:79分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!