Commit 8b09042c by Jaxon

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

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