modify(dataTable): filters

This commit is contained in:
songwanli2025@163.com 2020-03-27 15:06:53 +08:00
parent d89ce7d156
commit 2415b45290
2 changed files with 13 additions and 14 deletions

View File

@ -69,10 +69,10 @@ import NEmpty from '../../Empty'
import NPagination from '../../Pagination'
import formatLength from '../../_utils/css/formatLength'
function createShallowClonedArray (array) {
if (Array.isArray(array)) return array.map(createShallowClonedObject)
return array
}
// function createShallowClonedArray (array) {
// if (Array.isArray(array)) return array.map(createShallowClonedObject)
// return array
// }
function createShallowClonedObject (object) {
if (!object) return object
@ -486,8 +486,15 @@ export default {
this.$emit('sorter-change', createShallowClonedObject(sorter))
},
changeFilters (filters, sourceColumn) {
this.internalActiveFilters = !filters ? {} : filters
this.$emit('filters-change', createShallowClonedObject(this.internalActiveFilters), createShallowClonedObject(sourceColumn))
if (!filters) {
this.internalActiveFilters = {}
this.$emit('filters-change', {}, createShallowClonedObject(sourceColumn))
} else if (Object.prototype.toString.call(filters) === '[object Object]') {
this.internalActiveFilters = filters
this.$emit('filters-change', createShallowClonedObject(filters), createShallowClonedObject(sourceColumn))
} else {
console.error('[naive-ui/dataTable]: filters is not a Object')
}
},
scrollMainTableBodyToTop () {
const {

View File

@ -40,14 +40,6 @@ import NDataTableFilterMenu from './FilterMenu'
import NPopover from '../../../Popover'
import funnel from '../../../_icons/funnel'
// function createFilterOptionValues (activeFilters, column) {
// // const activeFilterOptionValues = activeFilters
// // .filter(filter => filter.columnKey === column.key)
// // .map(filter => filter.filterOptionValue)
// const activeFilterOptionValues = activeFilters[column.key]
// return activeFilterOptionValues
// }
function createActiveFilters (allFilters, columnKey, filterOptionValues) {
if (!Array.isArray(filterOptionValues)) {
filterOptionValues = [filterOptionValues]