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({ export function getLookupList({
tableName, tableName,
query, query,
valuesList,
pageToken, pageToken,
pageSize pageSize
}) { }) {
return Instance.call(this).requestListLookupFromReference({ return Instance.call(this).requestListLookupFromReference({
tableName, tableName,
query, query,
valuesList,
pageToken, pageToken,
pageSize pageSize
}) })

View File

@ -12,6 +12,8 @@
:allow-create="metadata.isSelectCreated" :allow-create="metadata.isSelectCreated"
:collapse-tags="!isSelectMultiple" :collapse-tags="!isSelectMultiple"
:disabled="isDisabled" :disabled="isDisabled"
remote
:remote-method="getRemoteList"
@change="preHandleChange" @change="preHandleChange"
@visible-change="getDataLookupList" @visible-change="getDataLookupList"
@clear="clearLookup" @clear="clearLookup"
@ -289,7 +291,6 @@ export default {
directQuery: this.metadata.reference.directQuery, directQuery: this.metadata.reference.directQuery,
value: this.value value: this.value
}) })
// set empty list and empty option // set empty list and empty option
this.changeBlankOption() this.changeBlankOption()
const list = [] const list = []
@ -299,7 +300,26 @@ export default {
// set empty value // set empty value
this.value = this.blankOption.key 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> </script>

View File

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