channelConfigDialog.vue
5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!-- 渠道配置弹框 -->
<template>
<d2-dialog class="channel-config-dialog"
:is-visible="channelConfigVisible"
title="渠道配置"
width="800px"
@closeDialog="handleClose"
@confirmDialog="handleConfirm">
<div v-loading="loading" class="channel-config-content">
<el-table border
class="channel-config-table"
:data="tableData">
<el-table-column align="center"
label="支付渠道"
prop="paymentChannel"
width="200" />
<el-table-column align="center"
label="收款主体"
prop="payeeSubjectName"
width="180" />
<el-table-column align="center" label="可用子公司">
<template #default="scope">
<div class="select-cell">
<el-select v-model="scope.row.platformMerchantIds"
collapse-tags
filterable
multiple
placeholder="请选择"
style="width: 100%">
<el-option v-for="item in platformMerchantList"
:key="item.merchantId"
:label="item.merchantName"
:value="item.merchantId" />
</el-select>
</div>
</template>
</el-table-column>
</el-table>
<div class="channel-config-tips">
<p class="tips-title">
说明:
</p>
<p>设置支付渠道&收款主体的可用子公司后,使用该子公司的门店+业务仅可以对对应支付渠道&收款主体产生的流水进行补单</p>
</div>
</div>
</d2-dialog>
</template>
<script>
import {
getPaymentChannelConfigList,
savePaymentChannelConfig,
} from "@api/grounding";
import { getPlatformMerchantList } from "@api/index";
// 前两列固定数据:支付渠道、收款主体(设计稿固定展示)
const FIXED_ROWS = [
{ payeeSubject: 1, paymentChannel: "银盛&嘀加智慧云", payeeSubjectName: "嘀加智慧云" },
{ payeeSubject: 2, paymentChannel: "银盛&嘀加智慧云", payeeSubjectName: "欢腾" },
{ payeeSubject: 3, paymentChannel: "通联&广联数科", payeeSubjectName: "广联数科" },
];
export default {
name: "ChannelConfigDialog",
props: {
channelConfigVisible: {
type: Boolean,
default: false,
},
},
data() {
return {
loading: false,
tableData: [],
platformMerchantList: [],
};
},
watch: {
channelConfigVisible: {
handler(val) {
if (val) {
this.initData();
}
},
immediate: true, // 弹框初始化时即调用两个查询接口
},
},
methods: {
initData() {
this.loading = true;
Promise.all([this.fetchPlatformMerchantList(), this.fetchChannelConfigList()])
.finally(() => {
this.loading = false;
});
},
// 获取平台方/子公司下拉选项(第三列下拉依赖此接口)
fetchPlatformMerchantList() {
return getPlatformMerchantList({}).then((res) => {
const list = res || [];
list.unshift({ merchantId: -1, merchantName: "嘀加智慧云" });
this.platformMerchantList = list;
});
},
// 获取渠道配置:仅第三列绑定的值依赖此接口
fetchChannelConfigList() {
return getPaymentChannelConfigList({}).then((res) => {
const apiList = res || [];
const mapByPayee = {};
apiList.forEach((item) => {
const key = item.payeeSubject;
if (!mapByPayee[key])
mapByPayee[key] = [];
const ids = item.platformMerchantIds ?? (item.platformMerchantId != null ? [item.platformMerchantId] : []);
if (Array.isArray(ids)) {
ids.forEach(id => id != null && id !== "" && mapByPayee[key].push(id));
}
});
this.tableData = FIXED_ROWS.map(row => ({
...row,
platformMerchantIds: mapByPayee[row.payeeSubject] || [],
}));
});
},
handleClose() {
this.$emit("dialogClose");
},
handleConfirm() {
const list = [];
this.tableData.forEach((row) => {
const ids = row.platformMerchantIds || [];
ids.forEach((id) => {
list.push({
platformMerchantId: String(id),
payeeSubject: String(row.payeeSubject ?? ""),
});
});
});
const params = { dataString: JSON.stringify({ list }) };
this.loading = true;
savePaymentChannelConfig(params)
.then(() => {
this.$message.success("保存成功");
this.handleClose();
})
.catch(() => {
this.$message.error("保存失败");
})
.finally(() => {
this.loading = false;
});
},
},
};
</script>
<style lang="scss" scoped>
.channel-config-content {
padding: 0 20px;
}
/* 排除全局 element.scss 对表格的影响 */
.channel-config-table {
::v-deep .el-table--medium td {
padding: 12px 0 !important;
}
}
.select-cell {
padding: 0 20px;
/* 取消全局 .el-tag 固定宽度,el-select 多选标签在 .el-select__tags 内 */
::v-deep .el-select__tags .el-tag {
width: auto !important;
min-width: auto !important;
font-size: 12px !important;
}
}
.channel-config-tips {
margin-top: 20px;
padding: 12px 16px;
background: #f6f8fa;
border-radius: 4px;
color: #666;
font-size: 14px;
.tips-title {
font-weight: 500;
color: #333;
margin-bottom: 8px;
}
p {
margin: 4px 0;
line-height: 1.6;
}
}
</style>