Commit 3875ee58 by Jaxon

fix(performanceScheme): 修复业务类型切换时商品品类未清空的问题

- 新增业务类型与品类选项的映射枚举
- 重构品类数据存储结构,按业务类型分类存储
- 业务类型变更时自动清空相关商品选择
- 优化品类选择器组件,根据业务类型动态加载选项
- 调整样式布局,修复输入框宽度问题
1 parent 80e0c3a3
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 class="">
<el-cascader clearable
:options="options"
:options="getOptions"
placeholder="请选择商品品类"
:props="{ checkStrictly: true, label: 'categoryName', value: 'categoryType' }"
:show-all-levels="false"
......@@ -13,13 +13,14 @@
<script>
import { mapState } from "vuex";
import { bizAdaptationOptionsEnum } from "../../utils/enum.js";
export default {
name: "",
props: {
options: {
type: Array,
default: () => [],
goodsCategory: {
type: Number,
require: true,
},
value: {
type: Array,
......@@ -32,7 +33,10 @@ export default {
};
},
computed: {
...mapState("PerformanceFormStore", ["formData", "goodsCategory"]),
...mapState("PerformanceFormStore", ["formData", "options"]),
getOptions() {
return this.options[bizAdaptationOptionsEnum[this.formData.businessType]] || [];
},
},
mounted() {
......
......@@ -32,15 +32,21 @@
align-items: center;
justify-content: center;
padding-right: 10px;
.el-input {
min-width: 80px;
> .el-input_showing {
width: 135px;
flex-shrink: 0;
}
.el-input-number {
min-width: 80px;
> .el-input-number {
width: 135px;
flex-shrink: 0;
.el-input {
width: 135px;
}
}
.el-input_showing {
.el-input {
min-width: 80px;
}
.tag {
margin: 0 6px;
}
......
......@@ -67,7 +67,7 @@
</el-button> -->
<GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="curParamsConfig.ParamsType1Products[index].productLabel"
:options="goodsCategoryOptions"
:goods-category="goodsCategory"
@change="handleProductChange" />
<el-cascader v-else
......@@ -144,7 +144,6 @@ export default {
...mapState("PerformanceFormStore", {
formData: "formData",
commissionTypesOptions: "commissionTypesOptions",
goodsCategoryOptions: "goodsCategory",
}),
...mapGetters("PerformanceFormStore", ["getProductDefineListOptions"]),
productDefineListOptions() {
......@@ -216,8 +215,6 @@ export default {
// 验证价格范围:结束值必须大于起始值
handlePriceRangeChange(rowIndex, rangeIndex) {
console.log("asda");
const priceRange = this.curParamsConfig.ParamsType1[rowIndex].priceRange;
const startValue = Number(priceRange[0]);
const endValue = Number(priceRange[1]);
......
......@@ -3,7 +3,7 @@
<el-table border :data="curParamsConfig.ParamsType2">
<el-table-column align="center"
:label="`考核因子${curParamsConfig.sort}:${curParamsConfig.title}`"
width="270px">
width="320px">
<template #default="{ $index }">
<div class="assessment-factor-column">
<EditableText v-model="curParamsConfig.ParamsType2[$index].priceRange[0]"
......@@ -32,11 +32,13 @@
<!-- 品类cascader -->
<GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="curParamsConfig.ParamsType2[$index].productLabel"
:options="goodsCategoryOptions"
clearable
:goods-category="goodsCategory"
@change="handleProductChange" />
<!-- 圈定套餐/商品 cascader -->
<el-cascader v-else
v-model="curParamsConfig.ParamsType2[$index].productLabel"
clearable
:options="getProductDefineListOptions"
:show-all-levels="false"
@change="handleProductChange">
......@@ -142,7 +144,6 @@ export default {
formData: "formData",
productDefineList: "productDefineList",
commissionTypesOptions: "commissionTypesOptions",
goodsCategoryOptions: "goodsCategory",
}),
...mapGetters("PerformanceFormStore", ["getProductDefineListOptions"]),
goodsCategory: {
......
......@@ -20,7 +20,7 @@
<GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="productValue"
clearable
:options="goodsCategoryOptions"
:goods-category="goodsCategory"
@change="handleProductChange" />
<el-cascader v-else
......@@ -62,7 +62,7 @@
<GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="productValue1"
clearable
:options="goodsCategoryOptions"
:goods-category="goodsCategory"
@change="handleProductChange" />
<el-cascader v-else
......@@ -134,7 +134,6 @@ export default {
...mapState("PerformanceFormStore", {
formData: "formData",
productDefineList: "productDefineList",
goodsCategoryOptions: "goodsCategory",
}),
...mapGetters("PerformanceFormStore", ["getProductDefineListOptions"]),
......
......@@ -14,7 +14,7 @@
<GoodsCategoryCascader v-if="goodsCategory === 0"
v-model="productValue"
clearable
:options="goodsCategoryOptions"
:goods-category="goodsCategory"
@change="handleProductChange" />
<!-- 圈定套餐/商品 cascader -->
<el-cascader v-else
......@@ -62,7 +62,6 @@ export default {
...mapState("PerformanceFormStore", {
formData: "formData",
productDefineList: "productDefineList",
goodsCategoryOptions: "goodsCategory",
}),
...mapGetters("PerformanceFormStore", ["getProductDefineListOptions"]),
// 路径太长 简化
......
......@@ -153,6 +153,7 @@ export default {
]),
...mapActions("PerformanceFormStore", [
"setCommissionTypesOptions",
"onBusinessTypeChange",
]),
handleGoodsConfigTypesGroupChange(e) {
......@@ -193,12 +194,12 @@ export default {
handleAssessmentFactorChange(value) {
this.touchAssessment(value);
// 只验证当前字段
this.validateCurrentField("assessmentFactorValue");
// // 只验证当前字段
// this.validateCurrentField("assessmentFactorValue");
},
handleBusinessTypeChange() {
// 只验证当前字段
this.validateCurrentField("businessType");
handleBusinessTypeChange(e) {
// 清空所有商品值
this.onBusinessTypeChange(e);
},
// 验证当前字段(只验证单个字段,不触发全表单验证)
validateCurrentField(prop) {
......
import { isArray, set } from "lodash-es";
import { normalizeTree } from "@/common/treeData";
import { baseConfig } from "@/main";
import { commissionTypeEnum, paramConfigListTemplate, assessmentFactorOptions as staticAssessmentFactorOptions } from "../components/performanceRuleSelection/options.js";
export default {
......@@ -40,6 +41,15 @@ export default {
],
storeConfig: { table: [], effectiveTime: "" },
},
options: {
// 品类 -> 轻改
lightModification: [],
// 品类 -> 权益
benefitProduct: [],
// 品类 -> 延保
extendedWarrantyProduct: [],
},
// 品类数据
goodsCategory: [
],
......@@ -177,8 +187,33 @@ export default {
});
},
// 设置品类数据
setGoodsCategory(state, goodsCategory) {
state.goodsCategory = goodsCategory;
setGoodsCategory(state, goodsCategoryOptions) {
const { goodsCategoryType } = baseConfig;
if (!goodsCategoryType) {
console.error("main.baseConfig 未配置 goodsCategoryType, 无法生成品类数据");
return;
}
// #延保类商品分类
const extendedInsurance = goodsCategoryType["smartcarlife.goodsType.extendedInsurance"];
const extendedWarrantyProduct = [];
// 权益
const equityType = goodsCategoryType["smartcarlife.goodsType.equity.type"];
const benefitProduct = [];
// 轻改
const lightModification = [];
for (const item of goodsCategoryOptions) {
if (item.categoryType === extendedInsurance) {
extendedWarrantyProduct.push(item);
} else if (item.categoryType === equityType) {
benefitProduct.push(item);
} else {
lightModification.push(item);
}
}
state.options.lightModification = lightModification;
state.options.benefitProduct = benefitProduct;
state.options.extendedWarrantyProduct = extendedWarrantyProduct;
},
setFormData(state, formData) {
Object.assign(state.formData, formData);
......@@ -213,7 +248,7 @@ export default {
clearParamsType2Condition(state, params2Index) {
const params2Table = state.formData.paramConfigList[params2Index].ParamsType2;
if (isArray(params2Table) && params2Table.length) {
const { conditionType0, conditionType1, conditionType2, conditionType3, conditionType4 } = structuredClone(paramConfigListTemplate);
const { ParamsType2: [{ conditionType0, conditionType1, conditionType2, conditionType3, conditionType4 }] } = structuredClone(paramConfigListTemplate);
for (const rows of params2Table) {
Object.assign(rows, {
......@@ -233,14 +268,41 @@ export default {
const params1Table = state.formData.paramConfigList[params1Index].ParamsType1Products;
if (isArray(params1Table) && params1Table.length) {
params1Table.forEach((item, index) => {
item.productValue[row] = undefined;
item.productValue.splice(row, 1, undefined);
});
}
},
},
actions: {
// 设置提成方式的下拉框选项
onBusinessTypeChange({ state, commit }, options) {
if (isArray(state.formData.paramConfigList)) {
for (const [tableIndex, table] of state.formData.paramConfigList.entries()) {
// 如果处于品类,全清
if (table.goodsCategory === 0) {
if (table.templateType === "ParamsType1" && isArray(table.ParamsType1) && isArray(table.ParamsType1Products)) {
// 清空列的 商品
for (const colItem of table.ParamsType1Products) {
colItem.productLabel = [];
}
// 清空 列的 商品值
for (const [rowIndex, rowItem] of table.ParamsType1.entries()) {
console.log("rowIndex", rowIndex);
commit("clearParamsType1ProductValue", { params1Index: tableIndex, row: rowIndex });
}
}
if (table.templateType === "ParamsType2" && isArray(table.ParamsType2)) {
for (const [rowIndex, rowItem] of table.ParamsType2.entries()) {
// 清空 行首的商品
rowItem.productLabel = [];
}
commit("clearParamsType2Condition", tableIndex);
}
}
}
}
},
// 提成方式改变的时候 设置提成方式的下拉框选项
setCommissionTypesOptions({ state, commit }, options) {
state.commissionTypesOptions = options.map((item, index) => ({
label: commissionTypeEnum[item].label,
......
// 适配业务的值 对应的 vuex中 options 的 对应品类的名字
export const bizAdaptationOptionsEnum = {
0: "lightModification",
1: "extendedWarrantyProduct",
2: "benefitProduct",
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!