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