fix 80839

This commit is contained in:
danshihao
2024-01-16 16:40:37 +08:00
parent 82d36e362e
commit 8abb605a62
2 changed files with 30 additions and 9 deletions
+29 -8
View File
@@ -12,7 +12,6 @@
allowClear
option-filter-prop="children"
:filterOption="false"
:not-found-content="null"
@search="lazySearch"
@popupScroll="lazyPopupScroll"
@dropdownVisibleChange="handleDropdownOpen">
@@ -102,12 +101,19 @@ export default {
type: Number,
require: false,
default: 50
},
// 没有企业idcompanyId)就不进行搜索
notCompanyIdCancelSearch: {
type: Boolean,
require: false,
default: false
}
},
data() {
return {
contactsList: [], // 该企业下联系人列表
lazyContactsList: [], // 该企业下联系人列表 (懒加载)
searchContactsList: [], // 搜索的全下拉 (懒加载)
isFirstOpen: true, // 编辑状态下是否为第一次打开
contactId: this.value
}
@@ -116,6 +122,7 @@ export default {
// this.initContacts = null
this.contactsList = []
this.lazyContactsList = []
this.searchContactsList = []
// 编辑 第一次不回显的问题
this.getContactsList()
},
@@ -149,8 +156,14 @@ export default {
methods: {
// 懒加载搜索
lazySearch (val) {
this.lazyContactsList = []
this.lazyContactsList = this.contactsList.filter(item => item.name.includes(val)).slice(0, this.lazySize)
// 搜索后就只需要一直从searchContactsList里取懒加载的部分数据
if (val) {
this.searchContactsList = this.contactsList.filter(item => item.name.includes(val))
} else {
this.searchContactsList = this.contactsList
}
// 显示部分搜索结果
this.lazyContactsList = this.searchContactsList.slice(0, this.lazySize)
},
// 懒加载滚动
lazyPopupScroll: debounce(function (e) {
@@ -165,11 +178,11 @@ export default {
// 当下拉框滚动条到达底部的时候
if (scrollHeight < clientHeight + 5) {
console.log('scroll end')
const allLen = this.contactsList.length
const allLen = this.searchContactsList.length
const showLen = this.lazyContactsList.length
// 如果总长度大于显示长度,那就添加
if (allLen > showLen) {
this.lazyContactsList = this.contactsList.slice(0, showLen + this.lazySize)
this.lazyContactsList = this.searchContactsList.slice(0, showLen + this.lazySize)
}
}
}
@@ -184,6 +197,8 @@ export default {
} else {
params.companyId = null
}
// 如果没有id就不调用接口
if (this.notCompanyIdCancelSearch && !params.companyId) return
// 是否调用无权限接口
if (this.isLimit) {
// 调用无权限接口
@@ -191,9 +206,12 @@ export default {
getContactsByCompanyNoLimit(params).then(res => {
this.contactsList = res.result
if (this.lazy) {
// 回显的用户显示再最前面
// 完整的所有下拉,回显的用户显示再最前面
const findIndex = this.contactsList.findIndex(item => item.id === this.value)
this.contactsList.unshift(this.contactsList.splice(findIndex, 1)[0])
// 搜索的所有下拉
this.searchContactsList = this.contactsList
// 显示的所有下拉
this.lazyContactsList = this.contactsList.slice(0, this.lazySize)
}
if (this.initContacts && this.initContacts.id) {
@@ -207,9 +225,12 @@ export default {
getContactsByCompany(params).then(res => {
this.contactsList = res.result || []
if (this.lazy) {
// 回显的用户显示再最前面
// 完整的所有下拉,回显的用户显示再最前面
const findIndex = this.contactsList.findIndex(item => item.id === this.value)
this.contactsList.unshift(this.contactsList.splice(findIndex, 1))
this.contactsList.unshift(this.contactsList.splice(findIndex, 1)[0])
// 搜索的所有下拉
this.searchContactsList = this.contactsList
// 显示的所有下拉
this.lazyContactsList = this.contactsList.slice(0, this.lazySize)
}
if (this.initContacts && this.initContacts.id) {
+1 -1
View File
@@ -87,7 +87,7 @@
v-decorator="[`payDraftingGroupSubItemContactsList[${index}].contactsId`, {rules: [{ required: index === 0, validator: index === 0 ? validateContactRequired : validateContact }],validateTrigger: 'change'}]"
:maxLength='50'
isLimit
lazy
not-company-id-cancel-search
:ref="`selectContacts${index}`"></select-contacts>
</a-form-item>
</a-col>