CN-1062 fix:右侧列表进行条件查询后,左侧filter应保持之前的选中

This commit is contained in:
hyx
2023-06-11 10:52:28 +08:00
parent e8483e8e91
commit e62573391a
2 changed files with 31 additions and 8 deletions

View File

@@ -157,6 +157,9 @@ export default {
listUrl: api.knowledgeBaseList, listUrl: api.knowledgeBaseList,
tableId: 'knowledgeBaseTable', // 需要分页的table的id用于记录每页数量 tableId: 'knowledgeBaseTable', // 需要分页的table的id用于记录每页数量
isSelectedStatus: false, isSelectedStatus: false,
filterParams: {},
checkedCategoryIds: [],
checkedStatusIds: [],
keyWord: '', keyWord: '',
showConfirmDialog: false, showConfirmDialog: false,
delItemList: [], delItemList: [],
@@ -168,12 +171,13 @@ export default {
}, },
methods: { methods: {
onSearch () { onSearch () {
const params = { let params = {
...this.filterParams,
name: this.keyWord name: this.keyWord
} }
this.clearList() this.clearList()
this.search(params) this.search(params)
this.$refs.knowledgeFilter.reloadFilter() this.$refs.knowledgeFilter.reloadFilter(this.checkedCategoryIds,this.checkedStatusIds)
}, },
reloadRowList () { reloadRowList () {
this.getTableData() this.getTableData()
@@ -314,11 +318,14 @@ export default {
} }
}) })
}, },
reload (params, isAll, isClearType) { reload (params, isAll, isClearType,checkedCategoryIds,checkedStatusIds) {
this.disableDelete = true this.disableDelete = true
this.isSelectedStatus = false this.isSelectedStatus = false
this.batchDeleteObjs = [] this.batchDeleteObjs = []
this.secondBatchDeleteObjs = [] this.secondBatchDeleteObjs = []
this.filterParams = params
this.checkedCategoryIds = checkedCategoryIds
this.checkedStatusIds = checkedStatusIds
params = { params = {
...params, ...params,
name: this.keyWord name: this.keyWord
@@ -426,6 +433,7 @@ export default {
mounted () { mounted () {
const curMode = this.$router.currentRoute.value.query.listMode const curMode = this.$router.currentRoute.value.query.listMode
this.listMode = curMode || 'list' this.listMode = curMode || 'list'
this.filterParams = {}
}, },
computed: { computed: {
} }

View File

@@ -80,7 +80,7 @@ export default {
typeData: [], typeData: [],
statusData: [], statusData: [],
defaultCheckedCategory: [], defaultCheckedCategory: [],
defaultCheckedStatus: [0, 1], defaultCheckedStatus: [],
filterParams: {} filterParams: {}
} }
}, },
@@ -196,7 +196,7 @@ export default {
} }
} }
this.filterParams = params this.filterParams = params
this.$emit('reload', params, true) this.$emit('reload', params, true,false,this.defaultCheckedCategory,this.defaultCheckedStatus)
} }
}, },
getAllTableData (params) { getAllTableData (params) {
@@ -227,6 +227,7 @@ export default {
}, },
initTypeData () { initTypeData () {
this.filterCategoryData.data = [] this.filterCategoryData.data = []
let categoryIds = []
this.typeData.forEach((type, typeIndex) => { this.typeData.forEach((type, typeIndex) => {
const categoryLabel = knowledgeBaseCategory.find(t => t.value === type.name) const categoryLabel = knowledgeBaseCategory.find(t => t.value === type.name)
const categoryId = typeIndex const categoryId = typeIndex
@@ -238,7 +239,7 @@ export default {
type: 0, type: 0,
children: [] children: []
} }
this.defaultCheckedCategory.push(categoryId) categoryIds.push(categoryId)
this.filterCategoryData.data.push(category) this.filterCategoryData.data.push(category)
const sourceList = type.sourceList const sourceList = type.sourceList
sourceList.forEach((item, sourceIndex) => { sourceList.forEach((item, sourceIndex) => {
@@ -253,11 +254,15 @@ export default {
category.children.push(source) category.children.push(source)
}) })
}) })
if(this.defaultCheckedCategory.length === 0){
this.defaultCheckedCategory = categoryIds
}
}, },
initStatusData () { initStatusData () {
const enableCount = 0 const enableCount = 0
const disableCount = 0 const disableCount = 0
this.filterStatusData.data = [] this.filterStatusData.data = []
let statusIds = []
this.statusData.forEach((data, index) => { this.statusData.forEach((data, index) => {
this.filterStatusData.data.push({ this.filterStatusData.data.push({
id: index, id: index,
@@ -266,10 +271,20 @@ export default {
count: data.count, count: data.count,
type: 0 type: 0
}) })
statusIds.push(index)
}) })
if(this.defaultCheckedStatus.length === 0){
this.defaultCheckedStatus = statusIds
}
}, },
reloadFilter (params) { reloadFilter (checkedCategoryIds ,checkedStatusIds) {
this.getAllTableData(params) if(checkedCategoryIds && checkedCategoryIds.length > 0){
this.defaultCheckedCategory = checkedCategoryIds
}
if(checkedStatusIds && checkedStatusIds.length > 0){
this.defaultCheckedStatus = checkedStatusIds
}
this.getAllTableData()
} }
}, },
mounted () { mounted () {