Commit e2d0c346 by Jaxon

feat: 在门店提成方案配置中添加排序和门店名称显示

- 在 convertBackendToData.js 中添加 sortTable 函数,对 ParamsType2 按价格区间起始值排序
- 在 configureStoreCommissionPlan.vue 中显示当前配置的门店名称
- 在 planList.vue 中传递门店名称到编辑页面,优化模板语法
1 parent 719a43f2
<!-- 门店提成方案 --> <!-- 门店提成方案 -->
<template> <template>
<div class="container"> <div class="container">
<d2-table <d2-table ref="table"
ref="table" :before-search-fn="beforeSearchFn"
:search-form="searchFormSearch" :get-list-api="getListApi"
:table-params="tableParams" :search-form="searchFormSearch"
:get-list-api="getListApi" :table-params="tableParams">
:before-search-fn="beforeSearchFn" <template #merchantNames="scope">
> {{ scope.scope.merchantNames || '-' }} {{ scope.scope.merchantId }}
<template slot="merchantNames" slot-scope="scope"> </template>
{{scope.scope.merchantNames||'-'}} {{scope.scope.merchantId}} <template #brandNames="scope">
</template> <template v-if="scope.scope.brandNames && scope.scope.brandNames.length > 20">
<template slot="brandNames" slot-scope="scope"> <el-popover placement="top"
<template popper-class="brand_popver"
v-if="scope.scope.brandNames && scope.scope.brandNames.length > 20" trigger="hover"
> width="300">
<el-popover <div class="brand-box">
placement="top" {{ brandFilter(scope.scope) }}
width="300" </div>
popper-class="brand_popver" <template #reference>
trigger="hover" <div>
> {{ brandFilter(scope.scope, 30) }}
<div class="brand-box"> </div>
{{ brandFilter(scope.scope) }} </template>
</div> </el-popover>
<div slot="reference"> </template>
{{ brandFilter(scope.scope, 30) }} <span v-else>{{ scope.scope.brandNames || "-" }}</span>
</div> </template>
</el-popover> <template #schemeNames="scope">
</template> <template v-if="
<span v-else>{{ scope.scope.brandNames || "-" }}</span> scope.scope.schemeNames
</template> && scope.scope.schemeNames.split(',').length > 0
<template slot="schemeNames" slot-scope="scope"> ">
<template <div v-for="(item, index) in scope.scope.schemeNames.split(',')"
v-if=" :key="index">
scope.scope.schemeNames && {{ item || "-" }}
scope.scope.schemeNames.split(',').length > 0 </div>
" </template>
>
<div
v-for="(item, index) in scope.scope.schemeNames.split(',')"
:key="index"
>
{{ item || "-" }}
</div>
</template>
<span v-else>-</span> <span v-else>-</span>
</template> </template>
<div slot="auth-button" slot-scope="scope"> <template #auth-button="scope">
<!-- 编辑 --> <div>
<span style="margin-right: 10px"> <!-- 编辑 -->
<auth-button :data="scope.scope" :show-btn-ids="['9121202']" /> <span style="margin-right: 10px">
</span> <auth-button :data="scope.scope" :show-btn-ids="['9121202']" />
</div> </span>
</d2-table> </div>
</div> </template>
</d2-table>
</div>
</template> </template>
<script> <script>
import { getStoreConfigList } from "@api/salaryManagement" import { getStoreConfigList } from "@api/salaryManagement";
import { deepClone, getStatusItem } from "@/common/util" import { deepClone, getStatusItem } from "@/common/util";
export default { export default {
props: {
searchForm: {
type: Object,
default: () => {},
},
baseData: {
type: Object,
default: () => {},
},
},
data() { data() {
return { return {
getStatusItem, getStatusItem,
...@@ -68,68 +74,59 @@ export default { ...@@ -68,68 +74,59 @@ export default {
getListApi: getStoreConfigList, getListApi: getStoreConfigList,
// 表格参数 // 表格参数
tableParams: { tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list", listName: "list",
tableOption: { tableOption: {
width: "100" width: "100",
}, },
tableColumns: [ tableColumns: [
{ {
label: "门店名称", label: "门店名称",
prop: "merchantNames", prop: "merchantNames",
addHtml: "merchantNames" addHtml: "merchantNames",
}, },
{ {
label: "品牌", label: "品牌",
prop: "brandNames", prop: "brandNames",
width: "200", width: "200",
addHtml: "brandNames" addHtml: "brandNames",
}, },
{ {
label: "提成方案名称", label: "提成方案名称",
prop: "schemeNames" prop: "schemeNames",
// addHtml: "schemeNames" // addHtml: "schemeNames"
}, },
{ {
label: "适配业务", label: "适配业务",
prop: "businessTypes", prop: "businessTypes",
formatter: (cellValue) => { formatter: (cellValue) => {
if (!cellValue.businessTypes) return "-" if (!cellValue.businessTypes)
let str = [] return "-";
let str = [];
cellValue.businessTypes.split(",").forEach((item) => { cellValue.businessTypes.split(",").forEach((item) => {
str.push( str.push(
this.getStatusItem(this.baseData, "businessTypeOpts", item) this.getStatusItem(this.baseData, "businessTypeOpts", item),
) );
}) });
return str.join(",") return str.join(",");
} },
} },
] ],
} },
} };
},
props: {
searchForm: {
type: Object,
default: () => {}
},
baseData: {
type: Object,
default: () => {}
}
}, },
mounted() {}, mounted() {},
methods: { methods: {
keyDowmGetList() { keyDowmGetList() {
this.$refs.table.refreshTable(true, true) this.$refs.table.refreshTable(true, true);
}, },
beforeSearchFn() { beforeSearchFn() {
return new Promise((resolve) => { return new Promise((resolve) => {
this.searchFormSearch = { this.searchFormSearch = {
...this.searchForm ...this.searchForm,
} };
resolve() resolve();
}) });
}, },
brandFilter(ele, lenght) { brandFilter(ele, lenght) {
if (ele.brandNames) { if (ele.brandNames) {
...@@ -137,28 +134,28 @@ export default { ...@@ -137,28 +134,28 @@ export default {
? ele.brandNames?.length > lenght ? ele.brandNames?.length > lenght
? ele.brandNames.substring(0, lenght) + "\u2026" ? ele.brandNames.substring(0, lenght) + "\u2026"
: ele.brandNames.substring(0, lenght) : ele.brandNames.substring(0, lenght)
: ele.brandNames : ele.brandNames;
} else { } else {
return "-" return "-";
} }
}, },
getOptions() { getOptions() {
this.showFormData?.forEach((item, index) => { this.showFormData?.forEach((item, index) => {
if (item.type == "select") { if (item.type == "select") {
if ( if (
this.baseData[item.optionsName].length && this.baseData[item.optionsName].length
this.baseData[item.optionsName][0][ && this.baseData[item.optionsName][0][
this.showFormData[index].optionLabel this.showFormData[index].optionLabel
] !== "全部" ] !== "全部"
) { ) {
const temp = {} const temp = {};
temp[this.showFormData[index].optionId] = "" temp[this.showFormData[index].optionId] = "";
temp[this.showFormData[index].optionLabel] = "全部" temp[this.showFormData[index].optionLabel] = "全部";
this.baseData[item.optionsName].unshift(temp) this.baseData[item.optionsName].unshift(temp);
} }
this.showFormData[index].optionList = this.baseData[item.optionsName] this.showFormData[index].optionList = this.baseData[item.optionsName];
} }
}) });
}, },
// 编辑方案 // 编辑方案
handleToEdit(row) { handleToEdit(row) {
...@@ -167,12 +164,14 @@ export default { ...@@ -167,12 +164,14 @@ export default {
path: "/configureStoreCommissionPlan", path: "/configureStoreCommissionPlan",
query: { query: {
id: row.merchantId, id: row.merchantId,
name: `${row.merchantNames || "-"}${row.merchantId || "-"} `,
}, },
}); });
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.m-t-40 { .m-t-40 {
margin-top: 40px; margin-top: 40px;
...@@ -186,6 +185,7 @@ export default { ...@@ -186,6 +185,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
} }
</style> </style>
<style> <style>
.brand_popver { .brand_popver {
height: auto !important; height: auto !important;
......
...@@ -185,6 +185,9 @@ export function coverParamConfigList(paramConfigList) { ...@@ -185,6 +185,9 @@ export function coverParamConfigList(paramConfigList) {
if (baseTable.goodsCategory === -1) { if (baseTable.goodsCategory === -1) {
baseTable.goodsCategory = 0; baseTable.goodsCategory = 0;
} }
sortTable(baseTable, baseTable.templateType);
_paramConfigList.push(baseTable); _paramConfigList.push(baseTable);
} }
} }
...@@ -192,6 +195,20 @@ export function coverParamConfigList(paramConfigList) { ...@@ -192,6 +195,20 @@ export function coverParamConfigList(paramConfigList) {
return _paramConfigList; return _paramConfigList;
} }
function sortTable(table, rangePath) {
// // 先根据 rangePath 排序
// table.sort((a, b) => {
// const aPrice = a[rangePath];
// const bPrice = b[rangePath];
// return aPrice - bPrice;
// });
return table.ParamsType2.sort((a, b) => {
// 获取 a 和 b 的第一个区间的起始值
const priceA = a.priceRange[0][0];
const priceB = b.priceRange[0][0];
return priceA - priceB; // 升序排列
});
}
// 转换 门店数据 // 转换 门店数据
function dealInterfaceBrand(brandList) { function dealInterfaceBrand(brandList) {
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
class="form-performance-name" class="form-performance-name"
label-width="170px" label-width="170px"
:model="formData" :model="formData"
:rules="rules" :rules="rules">
:validate-on-rule-change="false">
<div class="warp-box"> <div class="warp-box">
<div class="title space-b"> <div class="title space-b">
<div class="title-wrap"> <div class="title-wrap">
<span>渠道配置</span> <span>渠道配置</span>
<span class="merchant-wrapper">当前配置门店: {{ merchantName }} </span>
</div> </div>
</div> </div>
<div class="warp-content"> <div class="warp-content">
...@@ -132,6 +132,7 @@ export default { ...@@ -132,6 +132,7 @@ export default {
props: {}, props: {},
data() { data() {
return { return {
merchantName: "",
loading: { loading: {
page: false, page: false,
}, },
...@@ -181,6 +182,12 @@ export default { ...@@ -181,6 +182,12 @@ export default {
}, },
async mounted() { async mounted() {
console.log("this.$route.query", this.$route.query); console.log("this.$route.query", this.$route.query);
console.log("this.$route.query", this.$route.query.name);
if (this.$route.query?.name) {
this.merchantName = this.$route.query?.name;
console.log("merchantName", this.merchantName);
}
if (this.$route.query?.id) { if (this.$route.query?.id) {
await this.getData(this.$route.query?.id); await this.getData(this.$route.query?.id);
} }
...@@ -325,4 +332,21 @@ export default { ...@@ -325,4 +332,21 @@ export default {
<style scoped lang="scss"> <style scoped lang="scss">
@import "./common.scss"; @import "./common.scss";
.warp-box {
> .title {
flex: 1;
.title-wrap {
width: 100%;
display: flex;
justify-content: space-between;
.merchant-wrapper {
opacity: 1;
color: #666666;
font-size: 14px;
font-weight: 400;
line-height: 22px;
}
}
}
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!