<el-select
v-model="row.paramValue"
placeholder="请选择"
class="w100"
clearable
filterable
v-loadmore="getDictList"
:multiple="row.isMultiple"
:collapse-tags="row.isMultiple"
@focus="handleFocus($event, row, rowIndex)"
@change="changeParamValue($event, row, rowIndex)"
>
<el-option
v-for="(item, index) in row.dictList"
:key="row.paramName + '_' + index"
:label="item.text"
:value="item.value"
>
</el-option>
<el-option
v-if="row.isLoading"
label="加载中..."
value="-1"
v-loading="row.isLoading"
disabled
class="fs12"
></el-option>
<el-option v-if="row.noMore" label="没有更多数据了" value="0" disabled class="fs12"></el-option>
</el-select>
getDictList() {
const item = this.configForm.data[this.currentIndex]
if (!item.isLazy) {
return
}
if (item.noMore) {
return
}
item.isLoading = true
item.pageNo++
const params = {
reportId: this.addForm.typeId,
paramName: item.paramName,
pageNo: item.pageNo,
dbCode: item.dbCode
}
API.queryParamPageList(params).then((res) => {
if (res.data.length < 1) {
item.noMore = true
} else {
item.noMore = false
let restDict = []
const _i = this.handleDict.find((n) => n.paramName === item.paramName && n.dbCode === item.dbCode)
if (_i) {
res.data.map((x) => {
if (_i.addList && _i.addList.length > 0 && !_i.addList.find((n) => n.value === x.value)) {
restDict.push(x)
}
})
} else {
restDict = res.data
}
console.log(restDict, 'restDict', restDict.length)
item.dictList.push(...restDict)
}
item.isLoading = false
this.$set(this.configForm.data, this.currentIndex, item)
})
},
directives: {
loadmore: {
inserted(el, binding) {
const selectWrapEl = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
selectWrapEl.addEventListener('scroll', function () {
const flag = this.scrollHeight - this.scrollTop <= this.clientHeight
if (flag) {
console.log('触底')
binding.value()
}
})
}
}
}