diff --git a/src/views/system/archiveStatistics/mixins/statistics.js b/src/views/system/archiveStatistics/mixins/statistics.js new file mode 100644 index 0000000..9204136 --- /dev/null +++ b/src/views/system/archiveStatistics/mixins/statistics.js @@ -0,0 +1,228 @@ +import { FetchInitBorrowerNumStatistics, FetchInitArchivesTypeNum, FetchInitArchivesTypeStatistics, FetchStorageStatistics, FetchInitArchivesSearchRanking, FetchInitAddArchivesStatistics } from '@/api/archivesManage/statistics' +// import qs from 'qs' +export const statisticsCrud = { + // 组件共用属性 + data() { + return { + cateDate: '', + typeDate: '', + inOutStorageDate: '', + arcSearchDate: '', + arcAddDate: '', + pickerOptions: { + disabledDate(time) { + return time.getTime() > Date.now() - 8.64e6 + } + }, + lendData: [], + cateData: [], + typeData: [], + storageData: { + storageMonths: [], + inStorageData: [], + outStorageData: [] + }, + searchAcrivesData: { + searchName: [], + searchValue: [] + }, + addArcivesData: { + addArcivesMonth: [], + addArcivesNum: [] + } + } + }, + // 组件挂载时的共用方法 + mounted() { + this.getBorrowerNumSta() + this.getArchivesTypeNum() + this.getArchivesTypeStatistics() + this.getStorageStatistics() + this.getArchivesSearchRanking() + this.getAddArchivesStatistics() + }, + // 组件共用方法 + methods: { + // 档案借阅统计 + getBorrowerNumSta() { + FetchInitBorrowerNumStatistics().then(res => { + if (res) { + delete res.total + // 固定排序 '在库档案', '已借档案', '待借档案', '逾期档案', '异常档案' + const borrowerArr = [] + for (const i in res) { + const obj = {} + obj.name = i + obj.value = res[i] + if (i === 'inStorage') { + obj.sequence = 1 + } else if (i === 'borrow') { + obj.sequence = 2 + } else if (i === 'waitBorrow') { + obj.sequence = 3 + } else if (i === 'overdue') { + obj.sequence = 4 + } else if (i === 'abnormal') { + obj.sequence = 5 + } + borrowerArr.push(obj) + } + this.arrSortByKey(borrowerArr, 'sequence', false) + borrowerArr.forEach(item => { + this.lendData.push(item.value) + }) + } + }) + }, + // 档案类别 - 年选择 + handleCateDate() { + this.cateData = [] + this.getArchivesTypeNum() + }, + // 档案类别 + getArchivesTypeNum() { + let params + if (this.cateDate) { + params = { + 'year': this.cateDate + } + } else { + params = { + 'year': null + } + } + FetchInitArchivesTypeNum(params).then(res => { + if (res) { + for (const i in res) { + this.cateData.push(res[i]) + } + } + }) + }, + // 档案类型 - 月选择 + handleTypeDate() { + console.log(this.typeDate) + this.typeData = [] + this.getArchivesTypeStatistics() + }, + // 档案类型 + getArchivesTypeStatistics() { + let params + if (this.typeDate) { + params = { + 'yearMonth': this.typeDate + } + } else { + params = { + 'yearMonth': null + } + } + FetchInitArchivesTypeStatistics(params).then(res => { + if (res) { + res.map(item => { + const obj = {} + obj.name = item.archivesType + obj.value = item.archivesNum + this.typeData.push(obj) + }) + } + }) + }, + // 档案类别 - 年选择 + handleStorageDate() { + console.log(this.inOutStorageDate) + this.getStorageStatistics() + }, + // 出入库管理情况 + getStorageStatistics() { + let params + let getYear + if (this.inOutStorageDate) { + params = { + 'year': this.inOutStorageDate + } + getYear = this.inOutStorageDate + } else { + params = { + 'year': null + } + getYear = new Date().getFullYear() + } + FetchStorageStatistics(params).then(res => { + if (res) { + this.storageData.storageMonths = [] + res.months.forEach(item => { + this.storageData.storageMonths.push(getYear + '/' + item) + }) + this.storageData.inStorageData = res.inStorage + this.storageData.outStorageData = res.outStorage + } + }) + }, + handleSearchDate() { + this.getArchivesSearchRanking() + }, + // 档案检索排名 + getArchivesSearchRanking() { + let params + if (this.arcSearchDate) { + params = { + 'yearMonth': this.arcSearchDate + } + } else { + params = { + 'yearMonth': null + } + } + FetchInitArchivesSearchRanking(params).then(res => { + if (res) { + this.arrSortByKey(res, 'num', true) + this.searchAcrivesData.searchName = res.map(item => item.cnName) + this.searchAcrivesData.searchValue = res.map(item => item.num) + } + }) + }, + handleArcAddSta() { + this.getAddArchivesStatistics() + }, + // 档案实际情况 + getAddArchivesStatistics() { + let params + let getYear + if (this.arcAddDate) { + params = { + 'year': this.arcAddDate + } + getYear = this.arcAddDate + } else { + params = { + 'year': null + } + getYear = new Date().getFullYear() + } + FetchInitAddArchivesStatistics(params).then(res => { + if (res) { + this.addArcivesData.addArcivesMonth = [] + res.months.forEach(item => { + this.addArcivesData.addArcivesMonth.push(getYear + '/' + item) + }) + this.addArcivesData.addArcivesNum = res.nums + } + }) + }, + // array: 需要进行排序的数组 + // key: 根据某个属性进行排序 + // order: 升序/降序 true:升序 false:降序 + arrSortByKey(array, property, order) { + return array.sort(function(a, b) { + const value1 = a[property] + const value2 = b[property] + if (order) { // 升序 + return value1 - value2 + } else { // 降序 + return value2 - value1 + } + }) + } + } +}