fix: 报表支持导出
This commit is contained in:
parent
cd66c3b714
commit
9917ca25f6
@ -1,4 +1,4 @@
|
||||
import { post } from "@/utils/request";
|
||||
import { get, post } from "@/utils/request";
|
||||
|
||||
interface PreviewItemParams {
|
||||
previewId: string | number;
|
||||
@ -20,12 +20,3 @@ export function searchInfo(data: PreviewItemParams) {
|
||||
});
|
||||
}
|
||||
|
||||
export function exportTable(data: PreviewItemParams) {
|
||||
return post({
|
||||
url: '/api/v1/preview/export',
|
||||
data: {
|
||||
preview_id: data.previewId,
|
||||
filter: data.filter,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
/>
|
||||
<a-range-picker v-else-if="item.type === 'time'" class="date-item" v-model:value="filterData[item.name]" @change="toFilt" />
|
||||
</div>
|
||||
<div v-if="isExport" class="filter-item"><a-button type="primary" @click="toExport">导出</a-button></div>
|
||||
<div v-if="isExport" class="filter-item"><a :href="`${YCODE_BASEURL}/api/v1/preview/export?preview_id=${previewId}&filter=${JSON.stringify(getFilter())}`" target="_blank"><a-button type="primary">导出</a-button></a></div>
|
||||
</div>
|
||||
<div class="y-table-content">
|
||||
<a-table
|
||||
@ -58,7 +58,13 @@ import { reactive, ref } from "vue";
|
||||
import { useDebounceFn } from "@vueuse/core";
|
||||
import _ from "lodash";
|
||||
|
||||
const YCODE_BASEURL = import.meta.env.VITE_YCODE_BASEURL
|
||||
|
||||
const props = defineProps({
|
||||
previewId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
filterConfig: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
@ -115,7 +121,6 @@ const getFilter = () => {
|
||||
};
|
||||
|
||||
const getData = () => {
|
||||
|
||||
emit("toFilt", {
|
||||
filter: getFilter(),
|
||||
page: pageState.page,
|
||||
@ -131,13 +136,6 @@ const pageChange = () => {
|
||||
getData();
|
||||
};
|
||||
|
||||
const toExport = () => {
|
||||
emit("toExport", {
|
||||
filter: getFilter(),
|
||||
page: pageState.page,
|
||||
perPage: pageState.perPage,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
@ -39,6 +39,7 @@
|
||||
<div class="card-content">
|
||||
<y-table
|
||||
v-if="item.data.type === VIEW_TYPE.TABLE"
|
||||
:preview-id="item.id"
|
||||
:filter-config="item.data.filter"
|
||||
:data-list="item.data.data"
|
||||
:column-config="item.data.header"
|
||||
@ -46,8 +47,8 @@
|
||||
:title="item.data.preview_name"
|
||||
:is-export="item.data.is_export"
|
||||
@toFilt="
|
||||
(params?:object) => {
|
||||
handleSingle(ids[index], params);
|
||||
(params?:object) => {
|
||||
handleSingle(ids[index], params);
|
||||
}
|
||||
"
|
||||
></y-table>
|
||||
@ -78,6 +79,7 @@
|
||||
<div class="card-content">
|
||||
<y-table
|
||||
v-if="item.data.type === VIEW_TYPE.TABLE"
|
||||
:preview-id="item.id"
|
||||
:filter-config="item.data.filter"
|
||||
:data-list="item.data.data"
|
||||
:column-config="item.data.header"
|
||||
|
@ -89,7 +89,7 @@
|
||||
/>
|
||||
<a-range-picker v-if="item.type === 'time'" class="date-item" v-model:value="previewData.filterData[item.name]" @change="toFilt" />
|
||||
</div>
|
||||
<div v-if="previewData.isExport" class="filter-item"><a-button @click="toExport">导出</a-button></div>
|
||||
<div v-if="previewData.isExport" class="filter-item"><a-button type="primary">导出</a-button></div>
|
||||
</div>
|
||||
<div class="y-table-content">
|
||||
<a-table
|
||||
@ -355,10 +355,6 @@ const toFilt = () => {
|
||||
previewData.page = 1;
|
||||
toPreview({});
|
||||
};
|
||||
|
||||
const toExport = () => {
|
||||
// exportTable()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
@ -73,6 +73,7 @@
|
||||
<div class="right-box">
|
||||
<y-table
|
||||
v-if="selectViewInfo.type === 'table'"
|
||||
:previewId="selectedRowId"
|
||||
:filter-config="selectViewInfo.filter"
|
||||
:data-list="selectViewInfo.data"
|
||||
:column-config="selectViewInfo.header"
|
||||
@ -83,10 +84,6 @@
|
||||
(params) => {
|
||||
toGetViewInfo(params);
|
||||
}"
|
||||
@toExport="
|
||||
(params) => {
|
||||
toExport(params)
|
||||
}"
|
||||
/>
|
||||
<y-chart v-else-if="selectViewInfo.type === 'chart'" :chartCfg="selectViewInfo.config" :title="selectViewInfo.preview_name" :filter-config="selectViewInfo.filter" @toFilt="toGetViewInfo" />
|
||||
<div class="preview-area" v-else>
|
||||
@ -101,7 +98,6 @@
|
||||
<script setup>
|
||||
import { onMounted, ref, reactive } from "vue";
|
||||
import { getProModular, getViewList, getViewInfo, deleteView } from "./service";
|
||||
import { exportTable } from "@/api/preview/index";
|
||||
import { viewListCols } from "./config";
|
||||
import yTable from "@/components/common/y-table.vue";
|
||||
import { message } from "ant-design-vue";
|
||||
@ -159,15 +155,6 @@ const toGetViewInfo = (params = {}) => {
|
||||
});
|
||||
};
|
||||
|
||||
const toExport = (params = {}) => {
|
||||
exportTable({
|
||||
previewId: selectedRowId.value,
|
||||
...params,
|
||||
}).then(() => {
|
||||
message.success("导出成功");
|
||||
});
|
||||
}
|
||||
|
||||
const onProjectChange = (val) => {
|
||||
modularSel.value = projectSel.value.find((item) => item.value === val).child;
|
||||
modularId.value = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user