变更台账导出功能完成
This commit is contained in:
@@ -9,3 +9,13 @@ export function changeLedgerListApi(params:any) {
|
||||
});
|
||||
}
|
||||
|
||||
// 导出
|
||||
export function exportChangeLedgerApi(params:any) {
|
||||
return request({
|
||||
url: `/api/reports/changes/export`,
|
||||
method: 'get',
|
||||
params,
|
||||
responseType: 'blob', // 重点,responseType设置为 blob
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import { useRouterPush } from '@/hooks/common/router';
|
||||
import { tagTextColor, tagBgColor, tagBorderColor, getTimeRangeStamp, formatTimestamp } from '@/utils/common';
|
||||
import { systemConfigApi } from '@/service/api/system';
|
||||
import { orgListApi } from '@/service/api/user';
|
||||
import { changeLedgerListApi } from '@/service/api/changeLedger';
|
||||
import { urgeApi } from '@/service/api/change';
|
||||
import { changeLedgerListApi, exportChangeLedgerApi } from '@/service/api/changeLedger';
|
||||
|
||||
const { routerPushByKey } = useRouterPush();
|
||||
const themeStore = useThemeStore();
|
||||
@@ -88,8 +88,40 @@ const revokeSaving = ref<boolean>(false);
|
||||
const list = ref<any[]>([]);
|
||||
|
||||
// 导出台账
|
||||
const exportChanges = () => {
|
||||
window.$message?.info('还差接口');
|
||||
const exportChanges = async () => {
|
||||
loading.value = true;
|
||||
const {data,error} = await exportChangeLedgerApi({
|
||||
kw: formInfo.value.kw,
|
||||
type: formInfo.value.type,
|
||||
level: formInfo.value.level,
|
||||
status: formInfo.value.status,
|
||||
org_id: formInfo.value.org_id,
|
||||
apply_time_start: formatTimestamp(formInfo.value.apply_time_start),
|
||||
apply_time_end: formatTimestamp(formInfo.value.apply_time_end),
|
||||
});
|
||||
if(!error){
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
// 确保 res 为 Blob 类型(若 API 返回 ArrayBuffer 或原始数据,需适配)
|
||||
let blob;
|
||||
if (data instanceof Blob) {
|
||||
blob = data;
|
||||
} else {
|
||||
// 假设返回的是二进制数据(如 ArrayBuffer),指定 MIME 类型
|
||||
blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
||||
}
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = '变更台账.xlsx'; // 推荐使用 download 属性
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
// 清理:移除链接并释放 URL 对象
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
// 自定义渲染展开图标
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useEcharts } from '@/hooks/common/echarts';
|
||||
|
||||
defineOptions({
|
||||
@@ -8,6 +8,10 @@ defineOptions({
|
||||
|
||||
const props = defineProps(['data','typeList'])
|
||||
|
||||
watch(() => props.data, (newVal:any) => {
|
||||
init();
|
||||
});
|
||||
|
||||
const { domRef, updateOptions } = useEcharts(() => ({
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useEcharts } from '@/hooks/common/echarts';
|
||||
|
||||
defineOptions({
|
||||
@@ -7,6 +7,9 @@ defineOptions({
|
||||
});
|
||||
|
||||
const props = defineProps(['data'])
|
||||
watch(() => props.data, (newVal:any) => {
|
||||
init();
|
||||
});
|
||||
|
||||
const { domRef, updateOptions } = useEcharts(() => ({
|
||||
tooltip: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { watch, nextTick } from 'vue';
|
||||
import { useEcharts } from '@/hooks/common/echarts';
|
||||
|
||||
defineOptions({
|
||||
@@ -7,6 +7,11 @@ defineOptions({
|
||||
});
|
||||
|
||||
const props = defineProps(['data','total'])
|
||||
watch(() => [props.data, props.total], () => {
|
||||
nextTick(() => {
|
||||
init();
|
||||
});
|
||||
},{immediate: true,deep: true});
|
||||
|
||||
const { domRef, updateOptions } = useEcharts(() => ({
|
||||
tooltip: {
|
||||
@@ -24,7 +29,7 @@ const { domRef, updateOptions } = useEcharts(() => ({
|
||||
},
|
||||
},
|
||||
title: {
|
||||
text: `{a|${props.total}}\n{b|已评价}`,
|
||||
text: '',
|
||||
textStyle: {
|
||||
rich: {
|
||||
a: {
|
||||
@@ -77,6 +82,7 @@ function init() {
|
||||
name: item.label,
|
||||
value: item.count
|
||||
}));
|
||||
opts.title.text = `{a|${props.total}}\n{b|已评价}`;
|
||||
opts.series[0].data = result || [];
|
||||
opts.series[0].color = ["#52c41a", "#faad14", "#f5222d", "#94A3B8"];
|
||||
return opts;
|
||||
|
||||
Reference in New Issue
Block a user