batchCopyDialog.vue
4.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
<template>
<d2-dialog title="批量复制"
:is-visible.sync="batchCopyVisible"
width="600px"
btn-ok-label="确定"
@confirmDialog="handleBatchCopyConfirm"
@closeDialog="handleBatchCopyClose"
class="relateStore">
<el-form label-width="120px" :rules="rules" :model="selectData" ref="batchCopyForm">
<el-form-item label="业务场景:">
<el-input style="width: 370px;" v-model="sceneList[selectedScene]" disabled></el-input>
</el-form-item>
<el-form-item label="复制门店:" prop="selectMerchantObj">
<el-select v-model="selectData.selectMerchantObj" remote reserve-keyword multiple collapse-tags
placeholder="请选择复制门店" @visible-change="visibleChange" :remote-method="remoteMethod"
v-el-select-loadmore="interestsLoadmore" style="width: 370px;" value-key="merchantId" filterable>
<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 { getList, getAccountMerchantList } from '@/api/merchant'
import { sceneList } from '@/common/constants.js'
export default {
name: 'RelateStoreDialog',
data() {
return {
storeData: [],
// 分页
total: 0,
currentPage: 1,
pageSize: 20,
searchMerchantName: '',
sceneList,
selectData: {},
rules: { selectMerchantObj: [{ required: true, message: '请选择复制门店', trigger: 'blur' }] }
}
},
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
},
selectedScene: {
type: Number
}
},
mounted() {
this.getList()
},
methods: {
getList() {
const storeApi = [1, 2, 3].includes(this.selectedScene) ? getList : getAccountMerchantList // 会员权益/积分商城场景 上架门店是账户中心所有门店
storeApi({
// merchantIdName: ![1, 2, 3].includes(this.selectedScene) ? this.searchMerchantName : '',
merchantName: this.searchMerchantName,
currentPage: this.currentPage,
pageSize: this.pageSize,
scene: this.selectedScene
}).then(res => {
res?.list?.forEach(val => { // 账户中心门店返回商户号字段是merchantNo
if (val.merchantNo) val.merchantId = val.merchantNo
})
this.storeData = this.storeData.concat(res.list)
})
},
// 获取上架门店
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>