1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-11 05:11:59 +08:00

Set value to filter lookups list (#343)

* Set value to filter lookups list

* change data client version

* bugfix display value without label

Co-authored-by: Edwin Betancourt <EdwinBetanc0urt@hotmail.com>
Co-authored-by: Yamel Senih <ysenih@erpya.com>
This commit is contained in:
Leonel Matos 2020-04-09 00:42:24 -04:00 committed by GitHub
parent b653f430cd
commit 6258abb6e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 4 deletions

View File

@ -158,12 +158,14 @@ export function getLookup({
export function getLookupList({
tableName,
query,
valuesList,
pageToken,
pageSize
}) {
return Instance.call(this).requestListLookupFromReference({
tableName,
query,
valuesList,
pageToken,
pageSize
})

View File

@ -12,6 +12,8 @@
:allow-create="metadata.isSelectCreated"
:collapse-tags="!isSelectMultiple"
:disabled="isDisabled"
remote
:remote-method="getRemoteList"
@change="preHandleChange"
@visible-change="getDataLookupList"
@clear="clearLookup"
@ -289,7 +291,6 @@ export default {
directQuery: this.metadata.reference.directQuery,
value: this.value
})
// set empty list and empty option
this.changeBlankOption()
const list = []
@ -299,6 +300,25 @@ export default {
// set empty value
this.value = this.blankOption.key
}
},
getRemoteList(value) {
if (!isNaN(value)) {
value = parseInt(value, 10)
}
if (!this.isLoading && String(value.length > 2)) {
setTimeout(() => {
this.isLoading = true
this.$store.dispatch('getLookupListFromServer', {
parentUuid: this.metadata.parentUuid,
containerUuid: this.metadata.containerUuid,
tableName: this.metadata.reference.tableName,
query: this.metadata.reference.query,
valueToFilter: value
})
.then(response => {
this.isLoading = false
})
}, 250)
}
}
</script>

View File

@ -92,7 +92,8 @@ const lookup = {
parentUuid,
containerUuid,
tableName,
query
query,
valueToFilter
}) {
if (isEmptyValue(query)) {
return
@ -106,9 +107,15 @@ const lookup = {
isBooleanToString: true
}).value
}
const valuesList = []
if (!isEmptyValue(valueToFilter)) {
valuesList.push(valueToFilter)
}
return getLookupList({
tableName,
query: parsedQuery
query: parsedQuery,
valuesList
})
.then(lookupListResponse => {
const list = []