getMerchantListMixin.js
1.9 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
export default {
data () {
return {
merchantObj: {
nothing: false,
data: [],
currentPage: 1,
name: '',
loading: false,
total: 0
}
}
},
mounted () {
},
methods: {
selectFocus () {
const { configForm } = this
if (!configForm.merchantId) {
this.merchantObj.data = []
this.merchantObj.name = ''
this.merchantObj.currentPage = 1
this.getMerchantList()
}
},
onReachBottom () {
const { total, currentPage } = this.merchantObj
if (Math.ceil(total / 50) > currentPage) {
this.merchantObj.currentPage += 1
this.getMerchantList()
} else this.merchantObj.nothing = true
},
remoteMethod (val) {
this.merchantObj.name = val
if (val) {
this.merchantObj.loading = true
this.configForm.merchantId = ''
this.merchantObj.nothing = false
this.merchantObj.data = []
this.merchantObj.currentPage = 1
this.getMerchantList(val)
}
},
async getMerchantList () {
const { currentPage, data, name } = this.merchantObj,
{ list, total } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage,
merchantName: name
})
this.merchantObj.total = total
list && list.map(e => {
data.push({
confId: e.merchantNo,
confName: e.merchantName,
})
})
this.merchantObj.data = data
this.merchantObj.loading = false
},
},
directives: {
'reachbottom': {
inserted (el, binding) {
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()
})
}
}
},
}