Merge remote-tracking branch 'origin/dev' into dev

pull/104/head
李强 2023-08-21 11:08:50 +08:00
commit 83c702298a
3 changed files with 53 additions and 48 deletions

View File

@ -351,11 +351,16 @@ class CustomDjangoFilterBackend(DjangoFilterBackend):
queries = [] queries = []
for search_term_key in filterset.data.keys(): for search_term_key in filterset.data.keys():
orm_lookup = self.find_filter_lookups(orm_lookups, search_term_key) orm_lookup = self.find_filter_lookups(orm_lookups, search_term_key)
# print(search_term_key, orm_lookup) if not orm_lookup or filterset.data.get(search_term_key) == '':
if not orm_lookup:
continue continue
filterset_data_len = len(filterset.data.getlist(search_term_key))
if filterset_data_len == 1:
query = Q(**{orm_lookup: filterset.data[search_term_key]}) query = Q(**{orm_lookup: filterset.data[search_term_key]})
queries.append(query) queries.append(query)
elif filterset_data_len == 2:
orm_lookup += '__range'
query = Q(**{orm_lookup: filterset.data.getlist(search_term_key)})
queries.append(query)
if len(queries) > 0: if len(queries) > 0:
conditions.append(reduce(operator.and_, queries)) conditions.append(reduce(operator.and_, queries))
queryset = queryset.filter(reduce(operator.and_, conditions)) queryset = queryset.filter(reduce(operator.and_, conditions))

View File

@ -170,26 +170,26 @@ export default {
} }
}, },
watch: { watch: {
value: { // value: {
handler (value, oldVal) { // handler (value, oldVal) {
// inputv-modelvalue // // inputv-modelvalue
// watchvaluechange // // watchvaluechange
// changevalueform-data-change // // changevalueform-data-change
this.$emit('change', value) // this.$emit('change', value)
this.$emit('input', value) // this.$emit('input', value)
// currentValue // // currentValue
if (Array.isArray(value) && value.length === 0) { // if (Array.isArray(value) && value.length === 0) {
this.currentValue = null // this.currentValue = null
this.multipleSelection = null // this.multipleSelection = null
} else { // } else {
if (value && this.dispatch) { // if (value && this.dispatch) {
this.dispatch('ElFormItem', 'el.form.blur') // this.dispatch('ElFormItem', 'el.form.blur')
} // }
} // }
}, // },
deep: true, // deep: true,
immediate: true // immediate: true
}, // },
multipleSelection: { multipleSelection: {
handler (newValue, oldVal) { handler (newValue, oldVal) {
const { tableConfig } = this._elProps const { tableConfig } = this._elProps
@ -202,26 +202,26 @@ export default {
}, },
deep: true, deep: true,
immediate: true immediate: true
},
currentValue (newValue, oldVal) {
const { tableConfig } = this._elProps
const { value } = this.dict
if (newValue) {
if (!tableConfig.multiple) {
if (newValue[0]) {
this.$emit('input', newValue[0][value])
this.$emit('change', newValue[0][value])
}
} else {
console.log(newValue)
const result = newValue.map((item) => {
return item[value]
})
this.$emit('input', result)
this.$emit('change', result)
}
}
} }
// currentValue (newValue, oldVal) {
// const { tableConfig } = this._elProps
// const { value } = this.dict
// if (newValue) {
// if (!tableConfig.multiple) {
// if (newValue[0]) {
// this.$emit('input', newValue[0][value])
// this.$emit('change', newValue[0][value])
// }
// } else {
// console.log(newValue)
// const result = newValue.map((item) => {
// return item[value]
// })
// this.$emit('input', result)
// this.$emit('change', result)
// }
// }
// }
}, },
mounted () { mounted () {
// currentValue // currentValue