relateStoreDialog.vue
7.27 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!-- 关联门店弹窗 -->
<template>
<d2-dialog btn-ok-label="确定"
class="relateStore"
width="70%"
:is-visible.sync="relateStoreVisible"
:title="title"
@closeDialog="handleRelateStoreClose"
@confirmDialog="handleRelateStoreConfirm">
<slot />
<el-row class="tableCon">
<div class="tableBox">
<el-table ref="seletingTable"
class="table"
height="464px"
border
:data="selectingData"
@select="handleChange"
@select-all="handleAll">
<el-table-column align="center"
type="selection"
width="55" />
<el-table-column align="center"
label="商户名称"
prop="merchantName">
</el-table-column>
<el-table-column align="center"
label="商户地址"
min-width="160"
prop="address">
</el-table-column>
<el-table-column align="center"
label="商户号"
prop="merchantId">
</el-table-column>
<el-table-column align="center"
label="商户类型"
prop="yqMerchantName">
<template #default="scope">
<span>{{ merchantClassifyList.find(item => String(item.confId) === String(scope.row.merchantType)).confLabel }}</span>
</template>
</el-table-column>
<!-- <el-table-column prop="yqMerchantName" label="服务对接" align="center">
</el-table-column>
<el-table-column prop="yqMerchantId" label="服务对接商户号" align="center">
</el-table-column> -->
</el-table>
<el-pagination layout="total, prev, pager, next"
background
small
:current-page.sync="currentPage"
:page-size="pageSize"
:total="total"
@current-change="handleCurrentChange" />
</div>
<el-table class="tableBox table"
height="464px"
border
:data="selectedData">
<el-table-column align="center"
label="商户名称"
prop="merchantName">
<template #default="scope">
<span>{{ scope.row.merchantName }}</span>
</template>
</el-table-column>
<el-table-column align="center"
label="商户号"
prop="merchantId">
<template #default="scope">
<span>{{ scope.row.merchantId }}</span>
</template>
</el-table-column>
<el-table-column align="center"
label="删除"
width="50px">
<template #default="scope">
<el-button class="el-icon-delete"
type="text"
@click="handleDelete(scope.row)" />
</template>
</el-table-column>
</el-table>
</el-row>
</d2-dialog>
</template>
<script>
import { merchantClassifyList } from "@/common/constants.js";
export default {
name: "RelateStoreDialog",
props: {
title: {
type: String,
default: "上架商户",
},
relateStoreVisible: {
type: Boolean,
default: false,
},
storeApi: {
type: Function,
default: () => { },
},
storeSelected: {
type: Array,
default: () => [],
},
storeSearchForm: {
type: Object,
default: () => { },
},
selectedScene: {
type: Number,
},
},
data() {
return {
merchantClassifyList,
selectedData: [],
selectingData: [],
// 分页
total: 0,
currentPage: 1,
pageSize: 20,
};
},
mounted() {
this.selectedData = this.storeSelected;
this.getSelectingList();
},
methods: {
recoverySelection() {
const exitIds = this.selectedData.map(item => item.merchantId);
this.selectingData.forEach((item) => {
exitIds.includes(item.merchantId)
&& this.$refs.seletingTable.toggleRowSelection(item, true);
});
},
getSelectingList() {
// 会员权益/积分商城获取账户中心所有门店 接口不同 接口新增查询参数merchantName 不需单独处理
// if ([0, 4].includes(this.selectedScene)) {
// // 会员权益,积分商城场景查询门店名称参数
// _storeSearchForm.merchantIdName = _storeSearchForm.merchantName // 账户中心所有门店接口查询条件
// }
this.storeApi({
...this.storeSearchForm,
currentPage: this.currentPage,
pageSize: this.pageSize,
merchantTypeList: [6, 7, 8],
}).then((res) => {
res?.list?.forEach((val) => {
// 账户中心门店返回商户号字段是merchantNo
if (val.merchantNo) {
val.merchantId = Number(val.merchantNo);
}
val?.sceneList?.forEach((subVal) => {
if (String(subVal.scene) === String(this.selectedScene)) {
val.yqMerchantId = subVal?.yqMerchant?.merchantId || "-";
val.yqMerchantName = subVal?.yqMerchant?.merchantName || "-";
}
});
});
this.selectingData = res.list;
this.total = res.total;
this.$nextTick(() => {
this.recoverySelection();
});
});
},
handleChange(selection, row) {
const addOrDelete = !!selection.find(
item => item.merchantId === row.merchantId,
);
addOrDelete
? this.selectedData.push(row)
: (this.selectedData = this.selectedData.filter(
item => item.merchantId !== row.merchantId,
));
},
handleAll(selection) {
this.selectingData.forEach((item) => {
const isExit = this.selectedData.findIndex(
subItem => subItem.merchantId === item.merchantId,
);
if (selection.length && isExit === -1) {
this.selectedData.push(item);
} else if (!selection.length && isExit !== -1) {
this.selectedData.splice(isExit, 1);
}
});
},
handleDelete(row) {
this.selectedData = this.selectedData.filter(
item => item.merchantId !== row.merchantId,
);
const obj = this.selectingData.find(v => String(v.merchantId) === String(row.merchantId));
this.$refs.seletingTable.toggleRowSelection(obj);
},
handleCurrentChange(val) {
this.currentPage = val;
this.getSelectingList();
},
handleRelateStoreConfirm() {
this.$emit("handleRelateStoreConfirm", this.selectedData);
},
handleRelateStoreClose() {
this.$emit("handleRelateStoreClose");
},
},
};
</script>
<style lang="scss">
.relateStore .table {
margin: 0 auto 20px !important;
width: 98%;
}
.relateStore .tableCon {
margin-top: 20px;
display: flex;
.tableBox {
flex: 1;
}
}
.service-store .relateStore .el-table .cell,
.d2-form .relateStore .el-table .cell {
line-height: 26px !important;
}
.service-store .relateStore .el-table--medium td,
.d2-form .relateStore .el-table--medium td {
padding: 6px 8px !important;
}
.relateStore .red {
color: red;
}
.relateStore .tip-icon {
position: absolute;
display: inline-block;
height: 10px;
width: 10px;
line-height: 10px;
color: #ffffff;
background-color: red;
border: 1px solid red;
border-radius: 50%;
cursor: pointer;
font-size: 6px;
margin-left: 2px;
}
</style>