Browse Source

快速筛选/检索/分页bug修复

master
xuhuajiao 1 month ago
parent
commit
dba5560f96
  1. 8
      src/views/archivesManage/managementLibrary/anjuan/tableList.vue
  2. 114
      src/views/archivesManage/managementLibrary/index.vue
  3. 12
      src/views/archivesManage/managementLibrary/mixins/index.js
  4. 8
      src/views/collectReorganizi/collectionLibrary/anjuan/tableList.vue
  5. 123
      src/views/collectReorganizi/collectionLibrary/index.vue
  6. 12
      src/views/collectReorganizi/collectionLibrary/mixins/index.js

8
src/views/archivesManage/managementLibrary/anjuan/tableList.vue

@ -377,13 +377,21 @@ export default {
this.page.size = size
this.page.page = 0
localStorage.setItem('currentPageSize', size)
this.syncQueryFromHeader()
this.loadTableData()
},
handleCurrentPage(pageVal) {
this.currentPage = pageVal
this.page.page = pageVal - 1
localStorage.setItem('currentPage', JSON.stringify(this.page.page))
this.syncQueryFromHeader()
this.loadTableData()
},
// 翻页前同步 CollectHeader 的检索条件
syncQueryFromHeader() {
if (this.$refs.collectHeaderRef && this.$refs.collectHeaderRef.query) {
this.query.search = this.$refs.collectHeaderRef.query.search
}
}
}
}

114
src/views/archivesManage/managementLibrary/index.vue

@ -206,6 +206,12 @@ export default {
handleYearData(data) {
this.yearChildData = data
this.classifyLoading = true
// 保存所有勾选叶子节点的 key,树重建后统一恢复勾选状态
const checkedKeys = this.$refs.classifyTree.getCheckedNodes(true).map(node => node.id)
// 保存所有展开节点的 key,数据变化后统一恢复,避免重建后节点全部收起
const expandedKeys = this.$refs.classifyTree.store._getAllNodes()
.filter(node => node.expanded && node.key != null)
.map(node => node.key)
setTimeout(() => {
if (this.classifyTree.length !== 0 && this.classifyTree[0].dictionaryName === '年度') {
this.classifyTree = this.classifyTree.slice(1)
@ -222,6 +228,17 @@ export default {
this.classifyTree.unshift({ id: -1, dictionaryName: '年度', dictionaryCode: 'archive_year', childDictionarys: newYearArr })
}
this.classifyLoading = false
// el-tree 数据变化后重建内部节点会重置勾选与展开状态,需统一恢复以保持操作连续性
this.$nextTick(() => {
// 恢复勾选状态
this.$refs.classifyTree.setCheckedKeys(checkedKeys)
expandedKeys.forEach(key => {
const node = this.$refs.classifyTree.getNode(key)
if (node) {
node.expanded = true
}
})
})
}, 500)
},
filterData(data) {
@ -593,80 +610,31 @@ export default {
}
})
if (data.id) {
const selectedParentVal = this.$refs.classifyTree.getNode(data.id).parent.data.dictionaryCode
switch (selectedParentVal) {
case 'security_class':
if (res.find(obj => obj.dictionaryCode === 'security_class')) {
this.smartQuery.security_class = null
} else {
if (groupedData.security_class) {
this.smartQuery.security_class = groupedData.security_class.join(',')
} else {
this.smartQuery.security_class = null
}
}
break
case 'retention':
if (res.find(obj => obj.dictionaryCode === 'retention')) {
this.smartQuery.retention = null
} else {
if (groupedData.retention) {
this.smartQuery.retention = groupedData.retention.join(',')
} else {
this.smartQuery.retention = null
}
}
break
case 'doc_type':
if (res.find(obj => obj.dictionaryCode === 'doc_type')) {
this.smartQuery.doc_type = null
} else {
if (groupedData.doc_type) {
this.smartQuery.doc_type = groupedData.doc_type.join(',')
} else {
this.smartQuery.doc_type = null
}
}
break
case 'medium_type':
if (res.find(obj => obj.dictionaryCode === 'medium_type')) {
this.smartQuery.medium_type = null
} else {
if (groupedData.medium_type) {
this.smartQuery.medium_type = groupedData.medium_type.join(',')
} else {
this.smartQuery.medium_type = null
}
}
break
case 'organ_or_function':
if (res.find(obj => obj.dictionaryCode === 'organ_or_function')) {
this.smartQuery.organ_or_function = null
} else {
if (groupedData.organ_or_function) {
this.smartQuery.organ_or_function = groupedData.organ_or_function.join(',')
} else {
this.smartQuery.organ_or_function = null
}
}
break
default:
if (groupedData.archive_year) {
this.smartQuery.archive_year = groupedData.archive_year.join(',')
} else {
this.smartQuery.archive_year = null
}
// if (res.find(obj => obj.dictionaryCode === 'archive_year')) {
// this.smartQuery.archive_year = null
// } else {
// if (groupedData.archive_year) {
// this.smartQuery.archive_year = groupedData.archive_year.join(',')
// } else {
// this.smartQuery.archive_year = null
// }
// }
// 统一计算所有字段:父级被勾选(全选)则置 null,否则用子节点的值
const parentChecked = {}
res.forEach(item => {
if (item.dictionaryCode) {
parentChecked[item.dictionaryCode] = true
}
})
const fields = ['security_class', 'retention', 'doc_type', 'medium_type', 'organ_or_function']
fields.forEach(field => {
if (parentChecked[field]) {
// 父级被勾选(全选)→ 清除筛选
this.smartQuery[field] = null
} else if (groupedData[field]) {
this.smartQuery[field] = groupedData[field].join(',')
} else {
this.smartQuery[field] = null
}
})
// 年度:父级全选则置 null,否则用勾选的子节点值
if (parentChecked['archive_year']) {
this.smartQuery.archive_year = null
} else if (groupedData.archive_year) {
this.smartQuery.archive_year = groupedData.archive_year.join(',')
} else {
this.smartQuery.archive_year = null
}
this.$nextTick(() => {
this.handlePageList('quickFilter')

12
src/views/archivesManage/managementLibrary/mixins/index.js

@ -187,8 +187,8 @@ export const manageLibraryCrud = {
})
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
if (type === 'search') {
// projectObj.projectData = res.list.content
@ -216,8 +216,8 @@ export const manageLibraryCrud = {
})
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$parent.$parent.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
// 搜索/新增/编辑 非 案卷是主页的时候
if (type === 'search') {
@ -247,8 +247,8 @@ export const manageLibraryCrud = {
})
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$parent.$parent.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
if (type === 'search') {
console.log('wjObj', wjObj)

8
src/views/collectReorganizi/collectionLibrary/anjuan/tableList.vue

@ -350,13 +350,21 @@ export default {
this.page.size = size
this.page.page = 0
localStorage.setItem('currentPageSize', size)
this.syncQueryFromHeader()
this.loadTableData()
},
handleCurrentPage(pageVal) {
this.currentPage = pageVal
this.page.page = pageVal - 1
localStorage.setItem('currentPage', JSON.stringify(this.page.page))
this.syncQueryFromHeader()
this.loadTableData()
},
// 翻页前同步 collectHeader 的检索条件
syncQueryFromHeader() {
if (this.$refs.collectHeaderRef && this.$refs.collectHeaderRef.query) {
this.query.search = this.$refs.collectHeaderRef.query.search
}
}
}
}

123
src/views/collectReorganizi/collectionLibrary/index.vue

@ -172,6 +172,12 @@ export default {
handleYearData(data) {
this.yearChildData = data
this.classifyLoading = true
// 保存所有勾选叶子节点的 key,树重建后统一恢复勾选状态
const checkedKeys = this.$refs.classifyTree.getCheckedNodes(true).map(node => node.id)
// 保存所有展开节点的 key,数据变化后统一恢复,避免重建后节点全部收起
const expandedKeys = this.$refs.classifyTree.store._getAllNodes()
.filter(node => node.expanded && node.key != null)
.map(node => node.key)
setTimeout(() => {
if (this.classifyTree.length !== 0 && this.classifyTree[0].dictionaryName === '年度') {
this.classifyTree = this.classifyTree.slice(1)
@ -188,6 +194,17 @@ export default {
this.classifyTree.unshift({ id: -1, dictionaryName: '年度', dictionaryCode: 'archive_year', childDictionarys: newYearArr })
}
this.classifyLoading = false
// el-tree 数据变化后重建内部节点会重置勾选与展开状态,需统一恢复以保持操作连续性
this.$nextTick(() => {
// 恢复勾选状态
this.$refs.classifyTree.setCheckedKeys(checkedKeys)
expandedKeys.forEach(key => {
const node = this.$refs.classifyTree.getNode(key)
if (node) {
node.expanded = true
}
})
})
}, 500)
},
filterData(data) {
@ -397,13 +414,17 @@ export default {
localStorage.removeItem('currentPageSize')
localStorage.removeItem('currentPage')
this.smartQuery = {
// 'retention': null, // 保管期限
// 'security_class': null, // 密级
// 'doc_type': null, // 文种
// 'medium_type': null, // 载体类型
'archive_year': null // 年度
// 'organ_or_function': null, // 机构与类型
// 'fonds_no': null // 全宗
'retention': null, // 保管期限
'security_class': null, // 密级
'doc_type': null, // 文种
'medium_type': null, // 载体类型
'archive_year': null, // 年度
'organ_or_function': null, // 机构与类型
'fonds_no': null // 全宗
}
// 清空分类树的勾选状态
if (this.$refs.classifyTree) {
this.$refs.classifyTree.setCheckedKeys([])
}
this.parentsProjectId = null
this.parentsAnjuanId = null
@ -615,71 +636,31 @@ export default {
}
})
if (data.id) {
const selectedParentVal = this.$refs.classifyTree.getNode(data.id).parent.data.dictionaryCode
switch (selectedParentVal) {
case 'security_class':
if (res.find(obj => obj.dictionaryCode === 'security_class')) {
this.smartQuery.security_class = null
} else {
if (groupedData.security_class) {
this.smartQuery.security_class = groupedData.security_class.join(',')
} else {
this.smartQuery.security_class = null
}
}
break
case 'retention':
if (res.find(obj => obj.dictionaryCode === 'retention')) {
this.smartQuery.retention = null
} else {
if (groupedData.retention) {
this.smartQuery.retention = groupedData.retention.join(',')
} else {
this.smartQuery.retention = null
}
}
break
case 'doc_type':
if (res.find(obj => obj.dictionaryCode === 'doc_type')) {
this.smartQuery.doc_type = null
} else {
if (groupedData.doc_type) {
this.smartQuery.doc_type = groupedData.doc_type.join(',')
} else {
this.smartQuery.doc_type = null
}
}
break
case 'medium_type':
if (res.find(obj => obj.dictionaryCode === 'medium_type')) {
this.smartQuery.medium_type = null
} else {
if (groupedData.medium_type) {
this.smartQuery.medium_type = groupedData.medium_type.join(',')
} else {
this.smartQuery.medium_type = null
}
}
break
case 'organ_or_function':
if (res.find(obj => obj.dictionaryCode === 'organ_or_function')) {
this.smartQuery.organ_or_function = null
} else {
if (groupedData.organ_or_function) {
this.smartQuery.organ_or_function = groupedData.organ_or_function.join(',')
} else {
this.smartQuery.organ_or_function = null
}
}
break
default:
if (groupedData.archive_year) {
this.smartQuery.archive_year = groupedData.archive_year.join(',')
} else {
this.smartQuery.archive_year = null
}
// 统一计算所有字段:父级被勾选(全选)则置 null,否则用子节点的值
const parentChecked = {}
res.forEach(item => {
if (item.dictionaryCode) {
parentChecked[item.dictionaryCode] = true
}
})
const fields = ['security_class', 'retention', 'doc_type', 'medium_type', 'organ_or_function']
fields.forEach(field => {
if (parentChecked[field]) {
// 父级被勾选(全选)→ 清除筛选
this.smartQuery[field] = null
} else if (groupedData[field]) {
this.smartQuery[field] = groupedData[field].join(',')
} else {
this.smartQuery[field] = null
}
})
// 年度:父级全选则置 null,否则用勾选的子节点值
if (parentChecked['archive_year']) {
this.smartQuery.archive_year = null
} else if (groupedData.archive_year) {
this.smartQuery.archive_year = groupedData.archive_year.join(',')
} else {
this.smartQuery.archive_year = null
}
this.$nextTick(() => {
this.handlePageList('quickFilter')

12
src/views/collectReorganizi/collectionLibrary/mixins/index.js

@ -170,8 +170,8 @@ export const collectionLibraryCrud = {
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
if (type === 'search') {
// projectObj.projectData = res.list.content
@ -199,8 +199,8 @@ export const collectionLibraryCrud = {
})
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$parent.$parent.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
// 搜索/新增/编辑 非 案卷是主页的时候
if (type === 'search') {
@ -230,8 +230,8 @@ export const collectionLibraryCrud = {
})
this.page.total = res.list.totalElements
this.yearData = res.yearGroup
if (this.yearData && type !== 'quickFilter') {
this.$parent.$parent.$emit('myYearEvent', this.yearData)
if (this.yearData) {
this.parentsData.handleYearData(this.yearData)
}
if (type === 'search') {
// wjObj.anjuanData = res.list.content

Loading…
Cancel
Save