planList.vue 5.05 KB
<!-- 门店提成方案 -->
<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>
            <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";

export default {
	props: {
		searchForm: {
			type: Object,
			default: () => {},
		},
		baseData: {
			type: Object,
			default: () => {},
		},
	},
	data() {
		return {
			getStatusItem,
			searchFormSearch: {},
			getListApi: getStoreConfigList,
			// 表格参数
			tableParams: {
				btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
				listName: "list",
				tableOption: {
					width: "100",
				},
				tableColumns: [
					{
						label: "门店名称",
						prop: "merchantNames",
						addHtml: "merchantNames",
					},
					{
						label: "品牌",
						prop: "brandNames",
						width: "200",
						addHtml: "brandNames",
					},
					{
						label: "提成方案名称",
						prop: "schemeNames",
						// addHtml: "schemeNames"
					},
					{
						label: "适配业务",
						prop: "businessTypes",
						formatter: (cellValue) => {
							if (!cellValue.businessTypes)
								return "-";
							let str = [];
							cellValue.businessTypes.split(",").forEach((item) => {
								str.push(
									this.getStatusItem(this.baseData, "businessTypeOpts", item),
								);
							});
							return str.join(",");
						},
					},
				],
			},
		};
	},
	mounted() {},
	methods: {
		keyDowmGetList() {
			this.$refs.table.refreshTable(true, true);
		},
		beforeSearchFn() {
			return new Promise((resolve) => {
				this.searchFormSearch = {
					...this.searchForm,
				};
				resolve();
			});
		},
		brandFilter(ele, lenght) {
			if (ele.brandNames) {
				return lenght
					? ele.brandNames?.length > lenght
						? ele.brandNames.substring(0, lenght) + "\u2026"
						: ele.brandNames.substring(0, lenght)
					: ele.brandNames;
			} else {
				return "-";
			}
		},
		getOptions() {
			this.showFormData?.forEach((item, index) => {
				if (item.type == "select") {
					if (
						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);
					}
					this.showFormData[index].optionList = this.baseData[item.optionsName];
				}
			});
		},
		// 编辑方案
		handleToEdit(row) {
			console.log(row);
			this.$router.push({
				path: "/configureStoreCommissionPlan",
				query: {
					id: row.merchantId,
					name: `${row.merchantNames || "-"}${row.merchantId || "-"} `,
				},
			});
		},
	},
};
</script>

<style lang="scss" scoped>
.m-t-40 {
	margin-top: 40px;
}
.container {
	margin-top: 8px;
}
.brand-box {
	font-size: 12px;
	padding: 10px;
	box-sizing: border-box;
}
</style>

<style>
.brand_popver {
	height: auto !important;
	max-height: 200px;
	overflow: auto !important;
	min-height: 0;
	padding: 0 !important;
	box-sizing: border-box;
}
</style>