Commit f5aca251 by Jaxon

feat(绩效方案): 实现绩效方案提交功能并优化UI

- 新增绩效方案数据转换工具,将前端表单数据转换为后端API所需格式
- 实现绩效方案提交功能,调用后端API保存方案配置
- 优化门店选择组件样式和交互,修复模板语法问题
- 调整商品级联选择器布局,添加旋转图标
- 重构绩效规则选择组件,使用Vuex绑定表单字段
- 统一代码格式,修复ESLint警告
- 更新VS Code拼写检查配置,添加"Cascader"单词
1 parent bdaef0ae
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
"src/locales" "src/locales"
], ],
"cSpell.words": [ "cSpell.words": [
"vuex" "vuex",
"Cascader"
], ],
"explorer.compactFolders": false, "explorer.compactFolders": false,
"scm.compactFolders": false, "scm.compactFolders": false,
......
module.exports = { module.exports = {
gscPost: (url, data, _config = {}) => { gscPost: (url, data, _config = {}) => {
return window.$gscApi.post(url, data, _config) return window.$gscApi.post(url, data, _config);
} },
} };
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.
...@@ -52,119 +52,119 @@ process.env.NODE_ENV === "production" && ...@@ -52,119 +52,119 @@ process.env.NODE_ENV === "production" &&
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(
"Non-Error exception captured"
) )
|| hint.originalException.message.startsWith(
"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",
) )
.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,
...@@ -174,22 +174,22 @@ function init() { ...@@ -174,22 +174,22 @@ function init() {
// 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 };
...@@ -48,8 +48,18 @@ ...@@ -48,8 +48,18 @@
prop="productLabel" prop="productLabel"
width="180px"> width="180px">
<template #header="{ $index }"> <template #header="{ $index }">
<div> <div class="product-cascader-wrapper">
<span class="el-icon-sort icon"
style="line-height:normal;height:14px; vertical-align: middle;position: absolute;left:6px;top:50%; transform: translate(0, -50%);padding:0">
</span>
<!-- <el-button style="position: absolute;left:6px;top:50%; transform: translate(0, -50%);padding:0"
title="删除列"
type="text"
@click="handleRemoveProductsCol(index)">
<i class="el-icon-delete" />
</el-button> -->
<GoodsCategoryCascader v-model="curParamsConfig.ParamsType1Products[index].productLabel" @change="handleProductChange" /> <GoodsCategoryCascader v-model="curParamsConfig.ParamsType1Products[index].productLabel" @change="handleProductChange" />
<!-- <el-cascader v-model="curParamsConfig.ParamsType1Products[index].productLabel" <!-- <el-cascader v-model="curParamsConfig.ParamsType1Products[index].productLabel"
...@@ -58,7 +68,7 @@ ...@@ -58,7 +68,7 @@
@change="handleProductChange"> @change="handleProductChange">
</el-cascader> --> </el-cascader> -->
<el-button style="position: absolute;right:6px;" <el-button style="position: absolute;right:6px;top:50%; transform: translate(0, -50%);padding:0"
title="删除列" title="删除列"
type="text" type="text"
@click="handleRemoveProductsCol(index)"> @click="handleRemoveProductsCol(index)">
......
...@@ -201,6 +201,7 @@ export default { ...@@ -201,6 +201,7 @@ export default {
margin-left: 6px; margin-left: 6px;
cursor: pointer; cursor: pointer;
transition: color 200ms; transition: color 200ms;
transform: rotate(90deg);
&:hover { &:hover {
color: #2a58ad; color: #2a58ad;
} }
......
...@@ -95,8 +95,7 @@ export default { ...@@ -95,8 +95,7 @@ export default {
}, },
}, },
rules: {}, rules: {},
// 临时给组件用,会转换成OptionsItem 存储到 fromData里
assessmentFactorValue: [],
assessmentFactorOptions, assessmentFactorOptions,
isUpdating: false, // 防止循环更新 isUpdating: false, // 防止循环更新
// 提成基数和提成方式的对应关系:基数 <-> 方式 // 提成基数和提成方式的对应关系:基数 <-> 方式
...@@ -108,8 +107,9 @@ export default { ...@@ -108,8 +107,9 @@ export default {
}; };
}, },
computed: { computed: {
// 临时给组件用,会转换成OptionsItem 存储到 fromData里
...mapState("PerformanceFormStore", ["formData"]), ...mapState("PerformanceFormStore", ["formData"]),
assessmentFactorValue: bindFormFields("assessmentFactorValue"),
assessmentFactor: bindFormFields("assessmentFactor"), assessmentFactor: bindFormFields("assessmentFactor"),
checkList: bindFormFields("checkList"), checkList: bindFormFields("checkList"),
commissionBases: bindFormFields("commissionBases"), commissionBases: bindFormFields("commissionBases"),
......
...@@ -15,23 +15,27 @@ ...@@ -15,23 +15,27 @@
<d2-table v-if="selectedMerchantsList.length > 0" <d2-table v-if="selectedMerchantsList.length > 0"
ref="selectedMerTable" ref="selectedMerTable"
:has-page="false"
:search-form="{}" :search-form="{}"
:table-params="tableParams" :table-data="selectedMerchantsList"
:hasPage="false" :table-params="tableParams">
:table-data="selectedMerchantsList"> <template #auth-button="scope">
<div slot="auth-button" slot-scope="scope"> <div>
<el-button type="text" size="mini" @click="handleDeleteMer(scope.scope, scope.index)"> <el-button size="mini"
type="text"
@click="handleDeleteMer(scope.scope, scope.index)">
删除 删除
</el-button> </el-button>
</div> </div>
</template>
</d2-table> </d2-table>
<el-dialog :before-close="handleCloseDialog" <el-dialog v-if="dialog.storeApply.visible"
:before-close="handleCloseDialog"
custom-class="store-select-dialog" custom-class="store-select-dialog"
:title="dialog.storeApply.title" :title="dialog.storeApply.title"
:visible.sync="dialog.storeApply.visible" :visible.sync="dialog.storeApply.visible"
:width="dialog.storeApply.width" :width="dialog.storeApply.width">
v-if="dialog.storeApply.visible">
<StoreSelect ref="storeSelect" /> <StoreSelect ref="storeSelect" />
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
...@@ -46,7 +50,7 @@ ...@@ -46,7 +50,7 @@
<script> <script>
import { mapMutations, mapState } from "vuex"; import { mapMutations, mapState } from "vuex";
import { deepClone } from "@/common/util" import { deepClone } from "@/common/util";
import StoreSelect from "../storeSelect/index.vue"; import StoreSelect from "../storeSelect/index.vue";
export default { export default {
...@@ -66,35 +70,35 @@ export default { ...@@ -66,35 +70,35 @@ export default {
}, },
selectedMerchantsList: [], selectedMerchantsList: [],
tableParams: { tableParams: {
listName: 'list', listName: "list",
tableOption: true, tableOption: true,
tableColumns: [ tableColumns: [
{ {
label: '门店名称', label: "门店名称",
prop: 'merchantName', prop: "merchantName",
width: '471' width: "471",
}, },
{ {
label: '品牌名称', label: "品牌名称",
prop: 'brandName', prop: "brandName",
width: '471', width: "471",
formatter: cellValue => { formatter: (cellValue) => {
// 按 brandId 分组,相同 brandId 的子品牌放一起,并在前面展示品牌名 // 按 brandId 分组,相同 brandId 的子品牌放一起,并在前面展示品牌名
const groupMap = {}; const groupMap = {};
cellValue.checkBrands.forEach(brand => { cellValue.checkBrands.forEach((brand) => {
if (!groupMap[brand.brandId]) { if (!groupMap[brand.brandId]) {
groupMap[brand.brandId] = { groupMap[brand.brandId] = {
brandName: brand.brandName, brandName: brand.brandName,
childNames: [] childNames: [],
}; };
} }
groupMap[brand.brandId].childNames.push(brand.childName); groupMap[brand.brandId].childNames.push(brand.childName);
}); });
return Object.values(groupMap).map(item => `${item.brandName}-${item.childNames.join('/')}`).join(';') || '-'; return Object.values(groupMap).map(item => `${item.brandName}-${item.childNames.join("/")}`).join(";") || "-";
},
},
],
}, },
}
]
}
}; };
}, },
computed: { computed: {
...@@ -105,26 +109,26 @@ export default { ...@@ -105,26 +109,26 @@ export default {
methods: { methods: {
...mapMutations("PerformanceFormStore", ["setMerchantBrandRefList"]), ...mapMutations("PerformanceFormStore", ["setMerchantBrandRefList"]),
changeStoreApplyVisible() { changeStoreApplyVisible() {
this.dialog.storeApply.visible = !this.dialog.storeApply.visible this.dialog.storeApply.visible = !this.dialog.storeApply.visible;
}, },
handleCloseDialog() { handleCloseDialog() {
this.changeStoreApplyVisible() this.changeStoreApplyVisible();
}, },
handleDeleteMer(row, idx) { handleDeleteMer(row, idx) {
this.selectedMerchantsList.splice(idx, 1) this.selectedMerchantsList.splice(idx, 1);
this.setMerchantBrandRefList(deepClone(this.selectedMerchantsList)) this.setMerchantBrandRefList(deepClone(this.selectedMerchantsList));
}, },
handleDialogConfirm() { handleDialogConfirm() {
console.log(this.$refs.storeSelect.selectedMerchants) console.log(this.$refs.storeSelect.selectedMerchants);
this.selectedMerchantsList = Object.keys(this.$refs.storeSelect.selectedMerchants).map(key => this.$refs.storeSelect.selectedMerchants[key]) || [] this.selectedMerchantsList = Object.keys(this.$refs.storeSelect.selectedMerchants).map(key => this.$refs.storeSelect.selectedMerchants[key]) || [];
console.log(this.selectedMerchantsList) console.log(this.selectedMerchantsList);
if(this.selectedMerchantsList.length == 0) { if (this.selectedMerchantsList.length === 0) {
this.$message({ this.$message({
message: "请选择门店及品牌", message: "请选择门店及品牌",
type: "warning", type: "warning",
}) });
return return;
} }
// let list = [] // let list = []
// selectedMerchantsList.forEach(item => { // selectedMerchantsList.forEach(item => {
...@@ -139,8 +143,8 @@ export default { ...@@ -139,8 +143,8 @@ export default {
// }) // })
// }) // })
// }) // })
this.setMerchantBrandRefList(deepClone(this.selectedMerchantsList)) this.setMerchantBrandRefList(deepClone(this.selectedMerchantsList));
this.changeStoreApplyVisible() this.changeStoreApplyVisible();
}, },
}, },
}; };
......
<template> <template>
<div class="selection-store-wrapper" v-loading="loading"> <div v-loading="loading" class="selection-store-wrapper">
<div class="pre-select-store-wrapper"> <div class="pre-select-store-wrapper">
<div class="title"> <div class="title">
预选门店及品牌 预选门店及品牌
...@@ -88,17 +88,21 @@ ...@@ -88,17 +88,21 @@
disable-transitions disable-transitions
@close="handleRemoveSelectedBrandTag(brand, row, brandIndex)"> @close="handleRemoveSelectedBrandTag(brand, row, brandIndex)">
<el-tooltip class="tooltip-item" <el-tooltip class="tooltip-item"
:content="`${brand.brandName}+${brand.childName}`"
effect="dark" effect="dark"
:content="brand.brandName + '+' + brand.childName"
placement="top"> placement="top">
<span class="tag-txt">{{ (brand.brandName || '') + (brand.brandName ? '+' : '') + (brand.childName || '') }}</span> <span class="tag-txt">{{ (brand.brandName || '') + (brand.brandName ? '+' : '') + (brand.childName || '') }}</span>
</el-tooltip> </el-tooltip>
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="删除" align="center" width="50px"> <el-table-column align="center"
<template slot-scope="scope"> label="删除"
<el-button class="el-icon-delete" @click="handleDelete(scope.row)" type="text" /> width="50px">
<template #default="scope">
<el-button class="el-icon-delete"
type="text"
@click="handleDelete(scope.row)" />
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -108,10 +112,10 @@ ...@@ -108,10 +112,10 @@
</template> </template>
<script> <script>
// import { getStoreWithBrandList } from "@/api/mock/performance.mock.js";
import { deepClone } from "@/common/util"
import { getMerchantBrand } from "@api/resident.js"; import { getMerchantBrand } from "@api/resident.js";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
// import { getStoreWithBrandList } from "@/api/mock/performance.mock.js";
import { deepClone } from "@/common/util";
export default { export default {
name: "", name: "",
...@@ -126,7 +130,7 @@ export default { ...@@ -126,7 +130,7 @@ export default {
name: "", name: "",
currentPage: 1, currentPage: 1,
pageSize: 20, pageSize: 20,
total: 0 total: 0,
}, },
merchantTable: [], merchantTable: [],
selectedMerchants: {}, selectedMerchants: {},
...@@ -149,11 +153,11 @@ export default { ...@@ -149,11 +153,11 @@ export default {
const list = deepClone(this.getMerchantBrandRefList || []); const list = deepClone(this.getMerchantBrandRefList || []);
if (list.length > 0) { if (list.length > 0) {
const selected = {}; const selected = {};
list.forEach(item => { list.forEach((item) => {
selected[item.merchantId] = { selected[item.merchantId] = {
merchantId: item.merchantId, merchantId: item.merchantId,
merchantName: item.merchantName, merchantName: item.merchantName,
checkBrands: item.checkBrands || [] checkBrands: item.checkBrands || [],
}; };
}); });
this.selectedMerchants = selected; this.selectedMerchants = selected;
......
import { last } from "lodash-es";
import store from "@/store";
export function convertDataToBackend(formData) {
console.log("formData", formData);
const goodsCategory = store.state.PerformanceFormStore.goodsCategory;
const productDefineList = store.state.PerformanceFormStore.productDefineList;
const { paramConfigList, merchantBrandRefList, ...data } = formData;
const requestData = {
schemaName: data.schemaName,
businessType: data.businessType,
effectiveMonth: data.storeConfig.effectiveMonth,
performanceConfigRule: {
assessmentFactors: data.assessmentFactorValue.join(","),
commissionBases: data.commissionBases.join(","),
commissionTypes: data.commissionTypes.join(","),
goodsConfigTypes: data.goodsConfigTypes.join(","),
},
paramConfigList: [],
merchantBrandRefList: [],
};
for (const paramConfig of paramConfigList) {
// 每一份表格
const { templateType, ParamsType1, ParamsType1Products } = paramConfig;
console.log(paramConfig);
if (templateType === "ParamsType1") {
// 处理ParamsType1 类型的表格
coverParamsType1(ParamsType1, ParamsType1Products, (item, { rowItem, row }, { productColItem, colIndex }) => {
requestData.paramConfigList.push({
...item,
assessmentFactor: paramConfig.assessmentFactor.value,
goodsConfigType: paramConfig.goodsConfigType,
...paramConfig.goodsConfigType === 0
? buildGoodsTypePayload(goodsCategory, paramConfig.ParamsType1Products[colIndex].productLabel)
: buildProductDefinePayload(productDefineList, paramConfig.ParamsType1Products[colIndex].productLabel),
});
});
}
}
// 整理门店
requestData.merchantBrandRefList = buildMerchantBrandPayload(merchantBrandRefList, data.businessType);
console.log("performanceConfigRule", requestData);
return requestData;
}
function buildProductDefinePayload(tree, pathIds) {
let currentLevel = tree;
let targetNode = null;
for (const id of pathIds) {
targetNode = currentLevel.find(item => item.id === id);
if (!targetNode)
break;
currentLevel = targetNode.children || [];
}
return {
productDefineId: targetNode?.id ?? null,
productDefineName: targetNode?.label ?? null,
};
}
function buildGoodsTypePayload(tree, pathIds) {
const result = {};
let currentLevel = tree;
pathIds.forEach((id, index) => {
const node = currentLevel.find(item => item.categoryType === id);
if (!node)
return;
if (index === 0) {
result.goodsType = node.categoryType;
result.goodsTypeName = node.categoryName;
} else if (index === 1) {
result.secondaryGoodsType = node.categoryType;
result.secondaryGoodsTypeName = node.categoryName;
} else if (index === 2) {
result.thirdLevelGoodsType = node.categoryType;
result.thirdLevelGoodsTypeName = node.categoryName;
}
currentLevel = node.children || [];
});
return result;
}
function coverParamsType1(ParamsType1, ParamsType1Products, fn) {
ParamsType1.forEach((rowItem, row) => {
ParamsType1Products.forEach((productColItem, colIndex) => {
const result = {
templateType: 1,
startValue: rowItem.priceRange[0],
endValue: rowItem.priceRange[1],
commissionType: rowItem.commissionTypes,
commissionBase: productColItem.productValue[row],
};
// 还要加多 一个goodsConfigType 字段
if (fn && typeof fn === "function") {
fn(result, { rowItem, row }, { productColItem, colIndex });
}
});
});
}
function buildMerchantBrandPayload(
merchantBrandRefList,
businessType,
) {
const result = [];
merchantBrandRefList.forEach((merchant) => {
const {
merchantId,
merchantName,
checkBrands = [],
} = merchant;
checkBrands.forEach((brand) => {
result.push({
merchantId,
merchantName,
brandId: brand.brandId,
brandName: brand.brandName,
childId: brand.childId,
childName: brand.childName,
businessType: String(businessType),
});
});
});
return result;
}
...@@ -72,12 +72,13 @@ ...@@ -72,12 +72,13 @@
<script> <script>
import { mapMutations, mapState } from "vuex"; import { mapMutations, mapState } from "vuex";
import { getAllCategory } from "@/api/product.js"; import { getAllCategory } from "@/api/product.js";
import { getTargetProductConfigListAPI } from "@/api/resident"; import { getTargetProductConfigListAPI, postSalaryPerformanceScheme } from "@/api/resident";
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 StoreApply from "../components/storeApply/index.vue"; import StoreApply from "../components/storeApply/index.vue";
import { bindFormFields } from "../store/helper.js"; import { bindFormFields } from "../store/helper.js";
import { convertDataToBackend } from "../utils/index.js";
export default { export default {
name: "PerformanceScheme", name: "PerformanceScheme",
...@@ -94,7 +95,7 @@ export default { ...@@ -94,7 +95,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState("PerformanceFormStore", ["formData"]), ...mapState("PerformanceFormStore", ["formData", "merchantBrandRefList"]),
schemaName: bindFormFields("schemaName"), schemaName: bindFormFields("schemaName"),
}, },
...@@ -113,8 +114,11 @@ export default { ...@@ -113,8 +114,11 @@ export default {
} }
}); });
}, },
handleSubmit() { async handleSubmit() {
console.log(this.formData); await postSalaryPerformanceScheme(convertDataToBackend({
...this.formData,
merchantBrandRefList: this.merchantBrandRefList,
}));
}, },
async initLoad() { async initLoad() {
// 获取品类 // 获取品类
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!