|
|
import { FetchInitCategoryViewTable } from '@/api/collect/collect' import { FetchInitContorlView } from '@/api/archivesManage/library' import { FetchDictionaryTree } from '@/api/system/dict' import { crud } from '@crud/crud' export const manageLibraryCrud = { mixins: [crud()], // 组件共用属性
data() { return { getTableDisplayFieldsLoading: false, tableDisplayFields: [], projectData: [], anjuanData: [], junneiData: [], fileData: [], arrySort: [], page: { page: localStorage.getItem('currentPage') ? parseInt(localStorage.getItem('currentPage')) : 0, size: 10, total: 0 }, timer: null, query: { search: null, project_class: null, archive_ctg_no: null }, classifyTree: [], classifyLoading: false, parentsId: null } }, // 组件挂载时的共用方法
mounted() { }, // 组件共用方法
methods: { // 筛选可销毁/可开放文件
handleFilterChange(val) { console.log('this.collectLevel:', this.collectLevel) console.log('选中的值为:', this.parentsData.checklist) this.handleSearch(this.collectLevel) }, // 缓存用户对于固定栏操作习惯
statusBarChecked(val) { this.fixedStatusBar = val localStorage.setItem('statusBarFixedType', val) }, hasValue(obj) { for (const key in obj) { if (obj.hasOwnProperty(key) && obj[key] !== null && obj[key] !== '') { return true } } return false }, handleSearch(categoryLevel) { const queryResult = this.hasValue(this.query) console.log(queryResult) if (localStorage.getItem('currentPage') && !queryResult && this.selectStatus.length === 0 && this.parentsData.checklist.length === 0) { this.page.page = parseInt(localStorage.getItem('currentPage')) } else { this.page.page = 0 } this.parentsData.$refs.classifyTree.setCurrentKey(null) // this.smartQuery = {
// 'retention': null,
// 'security_class': null,
// 'doc_type': null,
// 'medium_type': null,
// 'archive_year': null,
// 'fonds_no': null
// }
this.smartQuery = this.parentsData.smartQuery // 2 项目 3 案卷 /文件 4 卷内 6 文件
if (this.isTitleType === 2) { this.parentsId = null this.$parent.getTableDisplayFieldsLoading = true } else if (this.isTitleType === 3) { if (this.selectedCategory.arrangeType === 1) { this.parentsId = null } else { if (this.activeIndex === 1) { this.parentsId = null } else { this.parentsId = this.parentsData.parentsProjectId } } this.$parent.getTableDisplayFieldsLoading = true } else if (this.isTitleType === 4) { // 卷内
this.$parent.$parent.getTableDisplayFieldsLoading = true this.parentsId = this.parentsData.parentsAnjuanId } else if (this.isTitleType === 6) { // 原文
if (this.selectedCategory.arrangeType === 1) { this.parentsId = this.parentsData.parentsAnjuanId this.$parent.getTableDisplayFieldsLoading = true } else { this.$parent.$parent.getTableDisplayFieldsLoading = true if (this.parentsData.isTabFile) { this.parentsId = this.parentsData.parentsAnjuanId } else { this.parentsId = this.parentsData.parentsJuanneiId } } } setTimeout(() => { this.getViewTable(categoryLevel, this.parentsId, 'search') }, 200) }, getViewTable(categoryLevel, parentsId, type) { this.getTableDisplayFieldsLoading = true this.tableDisplayFields = [] FetchInitCategoryViewTable({ categoryId: this.selectedCategory.id, categoryLevel: categoryLevel }).then((res) => { if (res) { this.arrySort = [] this.tableDisplayFields = res const orderSortArry = this.tableDisplayFields.filter(item => item.queue).sort((a, b) => a.queue - b.queue) orderSortArry.forEach(item => { if (item.displayOrderBy) { this.arrySort.push(item.fieldName + ',' + item.displayOrderBy) } }) this.$nextTick(() => { this.getViewTableList(categoryLevel, parentsId, type) }) } }) }, getViewTableList(categoryLevel, parentsId, type) { console.log('checklist', this.parentsData.checklist) const currentPageSize = localStorage.getItem('currentPageSize') if (currentPageSize) { this.page.size = parseInt(currentPageSize) } else { this.page.size = 10 } const params = { 'parentId': parentsId, 'categoryId': this.selectedCategory.id, 'categoryLevel': categoryLevel, 'ignore': false, // 'isdel': (this.parentsData.isdel && this.selectedCategory.arrangeType === 2 && categoryLevel === 3) ? false : this.parentsData.isdel,
'isdel': this.parentsData.isdel === true ? this.parentsData.isdel : false, 'checkTypes': this.selectStatus && this.selectStatus.length !== 0 ? this.selectStatus.join(',') : null, 'search': this.query.search, 'retention': this.smartQuery.retention, 'security_class': this.smartQuery.security_class, 'medium_type': this.smartQuery.medium_type, 'doc_type': this.smartQuery.doc_type, 'archive_year': this.smartQuery.archive_year, 'organ_or_function': this.smartQuery.organ_or_function, 'fonds_no': this.smartQuery.fonds_no, 'project_class': this.query.project_class, 'archive_ctg_no': this.query.archive_ctg_no, 'page': this.page.page, 'size': this.page.size, 'sort': this.arrySort, 'canOpen': this.parentsData.checklist && this.parentsData.checklist.length === 0 ? null : (this.parentsData.checklist && this.parentsData.checklist.includes(1) ? true : null), 'canDestroy': this.parentsData.checklist && this.parentsData.checklist.length === 0 ? null : (this.parentsData.checklist && this.parentsData.checklist.includes(2) ? true : null) } FetchInitContorlView(params).then((res) => { if (res.code !== 500) { this.parentsData.listCategory = res.category const baseCategory = res.category.id if (categoryLevel === 1) { // 项目
const projectObj = this.parentsData.$refs.projectEle // this.projectData = res.list.content
this.projectData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) this.page.total = res.list.totalElements this.yearData = res.yearGroup if (this.yearData && type !== 'quickFilter') { this.$emit('myYearEvent', this.yearData) } if (type === 'search') { // projectObj.projectData = res.list.content
this.projectData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) projectObj.currentPage = this.page.page + 1 // projectObj.page.page = 1
// projectObj.page.size = 10
projectObj.page.total = res.list.totalElements projectObj.getTableDisplayFieldsLoading = false } } else if (categoryLevel === 2) { // 案卷
const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList // this.anjuanData = res.list.content
this.anjuanData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) this.page.total = res.list.totalElements this.yearData = res.yearGroup if (this.yearData && type !== 'quickFilter') { this.$parent.$parent.$emit('myYearEvent', this.yearData) } // 搜索/新增/编辑 非 案卷是主页的时候
if (type === 'search') { // anjuanObj.anjuanData = res.list.content
anjuanObj.anjuanData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) anjuanObj.currentPage = this.page.page + 1 // anjuanObj.page.page = 1
// anjuanObj.page.size = 10
anjuanObj.page.total = res.list.totalElements anjuanObj.getTableDisplayFieldsLoading = false } } else if (categoryLevel === 3) { if (this.isTitleType === 3) { // 案卷下的未整理 / 文件为主页时
const wjObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList // this.anjuanData = res.list.content
this.anjuanData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) this.page.total = res.list.totalElements this.yearData = res.yearGroup if (this.yearData && type !== 'quickFilter') { this.$parent.$parent.$emit('myYearEvent', this.yearData) } if (type === 'search') { console.log('wjObj', wjObj) // wjObj.anjuanData = res.list.content
wjObj.anjuanData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) wjObj.currentPage = this.page.page + 1 // wjObj.page.page = 1
// wjObj.page.size = 10
wjObj.page.total = res.list.totalElements wjObj.getTableDisplayFieldsLoading = false } } else { // 卷内
// this.junneiData = res.list.content
this.junneiData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) this.page.total = res.list.totalElements if (type === 'search') { this.parentsData.$refs.juanneiEle.junneiData = res.list.content this.parentsData.$refs.juanneiEle.currentPage = this.page.page + 1 // this.parentsData.$refs.fileEle.page.page = 1
// this.parentsData.$refs.fileEle.page.size = 10
this.parentsData.$refs.juanneiEle.page.total = res.list.totalElements this.parentsData.$refs.juanneiEle.getTableDisplayFieldsLoading = false } } } else { // 原文
// this.fileData = res.list.content
this.fileData = res.list.content.map(item => { return { ...item, baseCategory: baseCategory } }) this.page.total = res.list.totalElements if (type === 'search') { this.parentsData.$refs.fileEle.fileData = res.list.content this.parentsData.$refs.fileEle.currentPage = this.page.page + 1 this.parentsData.$refs.fileEle.page.total = res.list.totalElements this.parentsData.$refs.fileEle.getTableDisplayFieldsLoading = false } } } this.getTableDisplayFieldsLoading = false this.crud.selections = [] if (categoryLevel === 3) { // 按件
if (this.isTitleType === 3) { const wjObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList wjObj.selections = [] wjObj.$refs.table.clearSelection() // 清空选中
wjObj.$refs.table.setCurrentRow(-1) // 清除高亮
} else { const juanneiObj = this.parentsData.$refs.juanneiEle juanneiObj.selections = [] juanneiObj.$refs.table.clearSelection() juanneiObj.$refs.table.setCurrentRow(-1) } } else if (categoryLevel === 2) { // 按卷
const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList anjuanObj.selections = [] anjuanObj.$refs.table.clearSelection() anjuanObj.$refs.table.setCurrentRow(-1) } else if (categoryLevel === 1) { // 项目
const projectObj = this.parentsData.$refs.projectEle projectObj.selections = [] projectObj.$refs.table.clearSelection() projectObj.$refs.table.setCurrentRow(-1) } else { const fileObj = this.parentsData.$refs.fileEle fileObj.selections = [] fileObj.$refs.table.clearSelection() fileObj.$refs.table.setCurrentRow(-1) } }) }, // 项目级别 - 阶段分类
getDictsList(type) { FetchDictionaryTree().then((res) => { const filterCodes = ['project_class'] let filteredItems = JSON.parse(JSON.stringify(res)).filter(item => filterCodes.includes(item.dictionaryCode)) filteredItems = this.addLevelToDictionaryList(filteredItems, 1)
if (type === 1) { let fiterData = [] fiterData = filteredItems.flatMap(item => { const level2Childs = item.childDictionarys.filter(child => { return child.dictionaryParents === item.id && child.level === 2 }) return level2Childs }) if (this.parentsData.parentsProjectRow) { console.log(this.parentsData.parentsProjectRow.project_class) const anjuanObj = this.parentsData.$refs.anjuanEle.$refs.ajContent.$refs.tableList anjuanObj.$refs.collectHeaderRef.projectOptions = [] if (this.parentsData.parentsProjectRow.project_class !== '') { const findDic = fiterData.find(item => item.dictionaryName === this.parentsData.parentsProjectRow.project_class) anjuanObj.$refs.collectHeaderRef.projectOptions.push(findDic) } else { console.log(fiterData) anjuanObj.$refs.collectHeaderRef.projectOptions = fiterData } } } else { if (this.selectedCategory.arrangeType === 3) { const projectObj = this.$refs.projectEle // this.projectOptions = this.filterData(filteredItems, filteredItems[0].id)
projectObj.$refs.collectHeaderRef.projectOptions = filteredItems.flatMap(item => { const level2Childs = item.childDictionarys.filter(child => { return child.dictionaryParents === item.id && child.level === 2 }) // 将满足条件的子项目的childDictionarys设置为空数组,因为项目页不需要
level2Childs.forEach(child => { child.childDictionarys = [] }) return level2Childs }) } } }).catch(err => { console.log(err) }) }, // 显示第一级和第二级
// filterData(data, targetId) {
// return data.filter(item => {
// if (item.id === targetId || item.dictionaryParents === targetId) {
// if (item.childDictionarys && item.childDictionarys.length > 0) {
// item.childDictionarys = this.filterData(item.childDictionarys, targetId)
// }
// return true
// }
// return false
// })
// },
// 给筛选出来的数据加level 方便后面是否可点击
addLevelToDictionaryList(dictionaryList, level) { dictionaryList.forEach(dictionary => { dictionary.level = level if (dictionary.childDictionarys) { dictionary.childDictionarys = this.addLevelToDictionaryList(dictionary.childDictionarys, level + 1) } }) return dictionaryList }, normalizerProject(node) { if ((node.childDictionarys && !node.childDictionarys.length) || node.childDictionarys === null) { delete node.childDictionarys } return { id: node.dictionaryName, label: `${node.dictionaryName} - ${node.dictionaryCode}`, children: node.childDictionarys, isDisabled: this.isTitleType === 3 ? node.level !== 3 : node.level === 1 } }, /* 重新渲染table组件 防止table-fixed 错位 配合watch-table数据 */ doLayout() { this.$nextTick(() => { this.$refs.table.doLayout() }) } } }
|