batchCopyDialog.vue
4.83 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
<template>
<d2-dialog btn-ok-label="确定"
class="relateStore"
:is-visible.sync="batchCopyVisible"
title="批量复制"
width="600px"
@closeDialog="handleBatchCopyClose"
@confirmDialog="handleBatchCopyConfirm">
<el-form ref="batchCopyForm"
label-width="120px"
:model="selectData"
:rules="rules">
<el-form-item label="业务场景:">
<el-input v-model="selectedSceneObj.name"
disabled
style="width: 370px;">
</el-input>
</el-form-item>
<el-form-item label="复制门店:" prop="selectMerchantObj">
<el-select v-model="selectData.selectMerchantObj"
v-el-select-loadmore="interestsLoadmore"
collapse-tags
filterable
multiple
placeholder="请选择复制门店"
remote
:remote-method="remoteMethod"
reserve-keyword
style="width: 370px;"
value-key="merchantId"
@visible-change="visibleChange">
<el-option v-for="subItem in storeData"
:key="subItem.merchantId"
:label="subItem.merchantName"
:value="subItem" />
</el-select>
</el-form-item>
</el-form>
<div class="tips">
说明:批量复制至新门店后,系统自动按操作商品,自动更新补充商品对应的上架门店
</div>
</d2-dialog>
</template>
<script>
import { getAccountMerchantList, getList } from "@/api/merchant";
import { sceneList } from "@/common/constants.js";
export default {
name: "RelateStoreDialog",
directives: {
"el-select-loadmore": {
bind(el, binding) {
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector(
".el-select-dropdown .el-select-dropdown__wrap",
);
SELECTWRAP_DOM.addEventListener("scroll", function () {
const condition
= this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
}, 100);
},
},
},
props: {
batchCopyVisible: {
type: Boolean,
default: false,
},
selectedSceneObj: {
type: Object,
},
baseSceneList: {
type: Array
}
},
data() {
return {
storeData: [],
// 分页
total: 0,
currentPage: 1,
pageSize: 20,
searchMerchantName: "",
sceneList,
selectData: {},
rules: { selectMerchantObj: [{ required: true, message: "请选择复制门店", trigger: "blur" }] },
};
},
mounted() {
this.getList();
},
methods: {
getList() {
const storeApi = this.filterBaseSceneCodeBySceneType([1, 2, 3]).includes(this.selectedSceneObj?.baseSceneCode) ? getList : getAccountMerchantList; // 售前会员权益升级、售后会员权益升级、售前延保、售后延保场景 上架门店是账户中心所有门店
storeApi({
merchantName: this.searchMerchantName,
currentPage: this.currentPage,
pageSize: this.pageSize,
baseSceneCode: this.selectedSceneObj?.baseSceneCode,
}).then((res) => {
res?.list?.forEach((val) => { // 账户中心门店返回商户号字段是merchantNo
if (val.merchantNo)
val.merchantId = val.merchantNo;
});
this.storeData = this.storeData.concat(res.list);
});
},
filterBaseSceneCodeBySceneType(targetTypes) {
const types = [].concat(targetTypes)
return this.baseSceneList?.flatMap(val =>
types.includes(val.sceneType) ? [val.baseSceneCode] : []
) || []
},
// 获取上架门店
remoteMethod(query) {
this.searchMerchantName = query;
this.currentPage = 1;
this.storeData = [];
this.getList(); // 请求接口
},
visibleChange(data) {
// 获取焦点重新渲染下拉框数据
if (data) {
if (this.searchMerchantName) {
this.searchMerchantName = "";
this.currentPage = 1;
this.storeData = [];
this.getList();
}
}
},
// 获取更多上架门店
interestsLoadmore() {
setTimeout(() => {
this.currentPage = this.currentPage + 1;
if (this.allPages < this.currentPage) {
this.currentPage = this.allPages;
return;
}
this.getList();
}, 10);
},
handleBatchCopyConfirm() {
this.$refs.batchCopyForm.validate((valid) => {
if (valid) {
this.$emit("handleBatchCopyConfirm", this.selectData?.selectMerchantObj);
}
});
},
handleBatchCopyClose() {
this.$emit("handleBatchCopyClose");
},
},
};
</script>
<style lang="scss">
.tips {
font-size: 14px;
color: #999;
}
</style>