Commit e2d0c346 by Jaxon

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

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