diff --git a/src/components/JsonExcel.vue b/src/components/JsonExcel.vue new file mode 100644 index 0000000..6405913 --- /dev/null +++ b/src/components/JsonExcel.vue @@ -0,0 +1,307 @@ + + + diff --git a/src/main.js b/src/main.js index b3f7e28..942f347 100644 --- a/src/main.js +++ b/src/main.js @@ -13,7 +13,7 @@ import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/a import { isAuth } from '@/utils' import { accessField } from '@/utils' import cloneDeep from 'lodash/cloneDeep' -import JsonExcel from 'vue-json-excel' +import JsonExcel from '@/components/JsonExcel.vue' import i18n from '@/i18n/i18n' import './utils/directives' import decimalUtil from '@/utils/decimalUtil.js' diff --git a/src/views/modules/project/projectInfo/projectInfo.vue b/src/views/modules/project/projectInfo/projectInfo.vue index 5767cd9..c6c911e 100644 --- a/src/views/modules/project/projectInfo/projectInfo.vue +++ b/src/views/modules/project/projectInfo/projectInfo.vue @@ -479,6 +479,8 @@ addOrUpdateVisible:false, filterVisible:false, isFilterSearch: false, + listQueried: false, + exportParams: null, filterSearchData: {}, nodeOptions: [], approvalList: [], @@ -1594,15 +1596,30 @@ }) }, - //导出excel + //导出excel:仅导出已经查询出的全部数据,未查询时不导出 async createExportData() { - this.searchData.limit = -1 - this.searchData.page = 1 - await projectInfoSearch(this.searchData).then(({data}) => { - this.exportList= data.page.list; + if (!this.listQueried) { + return [] + } + if (this.isFilterSearch) { + const params = Object.assign({}, this.filterSearchData, { + no: 1, + size: -1, + site: this.$store.state.user.site, + userName: this.$store.state.user.name, + userId: String(this.$store.state.user.id) + }) + const {data} = await projectInfoSearchByAnyField(params) + return (data && data.page && data.page.list) || [] + } + const params = Object.assign({}, this.exportParams || this.searchData, { + page: 1, + limit: -1, + userId: this.$store.state.user.id, + menuId: this.menuId }) - - return this.exportList; + const {data} = await projectInfoSearch(params) + return (data && data.page && data.page.list) || [] }, startDownload() { @@ -1669,6 +1686,11 @@ this.searchData.page = this.pageIndex this.searchData.userId = this.$store.state.user.id this.searchData.menuId = this.menuId + if (!keepFilter) { + this.isFilterSearch = false + } + this.listQueried = true + this.exportParams = Object.assign({}, this.searchData) projectInfoSearch(this.searchData).then(({data}) => { if (data.code == 0) { this.dataList1 = data.page.list @@ -2532,6 +2554,7 @@ this.filterSearchData = params this.filterVisible = false this.isFilterSearch = true + this.listQueried = true }, hasProjectManager (source) { if (!source) { @@ -2584,6 +2607,9 @@ this.searchData.page = this.pageIndex this.searchData.userId = this.$store.state.user.id this.searchData.menuId = this.menuId + this.listQueried = true + this.exportParams = Object.assign({}, this.searchData) + this.isFilterSearch = false projectInfoSearch(this.searchData).then(({data}) => { if (data.code == 0) { this.dataList1 = data.page.list diff --git a/src/views/modules/proofing/requestForProofing.vue b/src/views/modules/proofing/requestForProofing.vue index 9dd0d1c..4adb492 100644 --- a/src/views/modules/proofing/requestForProofing.vue +++ b/src/views/modules/proofing/requestForProofing.vue @@ -1027,6 +1027,8 @@ export default { }, // 其它 exportLoading: false, + listQueried: false, + exportParams: null, dataListLoading: false, // 初始页签 activeTable: 'attribute', @@ -2334,6 +2336,9 @@ export default { menuId: this.$route.meta.menuId } this.dataListLoading = true + this.listQueried = true + this.isFilterSearch = false + this.exportParams = Object.assign({}, params) proofingInformationSearch(params).then(({data}) => { if (data && data.code === 0) { this.dataList = data.page.list @@ -2492,6 +2497,9 @@ export default { ...this.searchData, createBy: this.$store.state.user.name, } + this.listQueried = true + this.isFilterSearch = false + this.exportParams = Object.assign({}, params) proofingInformationSearch(params).then(({data}) => { if (data.code === 0) { this.dataList = data.page.list @@ -3620,12 +3628,28 @@ export default { * 导出excel */ async createExportData() { - this.searchData.limit = -1 - this.searchData.page = 1 - await proofingInformationSearch(this.searchData).then(({data}) => { - this.resultList = data.page.list + if (!this.listQueried) { + return [] + } + if (this.isFilterSearch) { + const params = Object.assign({}, this.filterSearchData, { + site: this.$store.state.user.site, + menuId: '103001', + no: 1, + size: -1, + userId: String(this.$store.state.user.id), + userName: this.$store.state.user.name + }) + const {data} = await proofingInformationSearchAny(params) + return (data && data.page && data.page.list) || [] + } + const params = Object.assign({}, this.exportParams || this.searchData, { + page: 1, + limit: -1, + createBy: this.$store.state.user.name }) - return this.resultList + const {data} = await proofingInformationSearch(params) + return (data && data.page && data.page.list) || [] }, startDownload() { this.exportLoading = true @@ -4173,6 +4197,7 @@ export default { }) this.filterSearchData = params this.isFilterSearch = true + this.listQueried = true this.filterVisible = false },