导出功能

main
zhufu 2025-04-07 11:32:59 +08:00
parent bf367c9f9a
commit 66e9cf9512
4 changed files with 112 additions and 8 deletions

View File

@ -49,11 +49,14 @@
import { PageList, Detail, AddOrEdit, Delete } from '@/api/IdleFarming'
import InsertModal from './InsertModal.vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import axios from 'axios';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
defineOptions({ name: 'RoleManagement' });
const showInfoData = ref();
const modalTitle = ref('')
const [registerTable, { reload }] = useTable({
const [registerTable, { reload, getForm }] = useTable({
title: '农业生产设施',
api: PageList,
columns,
@ -78,13 +81,36 @@
},
});
const open = ref<boolean>(false);
function onBtnClicked(domId) {
async function onBtnClicked(domId) {
switch (domId) {
case 'add':
modalTitle.value = '新增'
showInfoData.value = JSON.parse(JSON.stringify(defaultValue))
open.value = true;
break;
case 'export':
const filters = await getForm();
const values = filters?.getFieldsValue();
const fileName = '农业生产设施表' + new Date().getTime() + '.xls';
axios({
method: 'get',
url: VITE_GLOB_API_URL + '/api/IdleFarming/Export',
params: values,
headers: {
'X-Token': localStorage.getItem('X-Token'),
},
responseType: 'blob',
}).then((res) => {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(res.data);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
});
break;
default:
break;
}

View File

@ -49,11 +49,14 @@
import { PageList, Detail, AddOrEdit, Delete } from '@/api/IdleHouse'
import InsertModal from './InsertModal.vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import axios from 'axios';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
defineOptions({ name: 'RoleManagement' });
const showInfoData = ref();
const modalTitle = ref('')
const [registerTable, { reload }] = useTable({
const [registerTable, { reload, getForm }] = useTable({
title: '房屋',
api: PageList,
columns,
@ -78,13 +81,36 @@
},
});
const open = ref<boolean>(false);
function onBtnClicked(domId) {
async function onBtnClicked(domId) {
switch (domId) {
case 'add':
modalTitle.value = '新增'
showInfoData.value = JSON.parse(JSON.stringify(defaultValue))
open.value = true;
break;
case 'export':
const filters = await getForm();
const values = filters?.getFieldsValue();
const fileName = '房屋表' + new Date().getTime() + '.xls';
axios({
method: 'get',
url: VITE_GLOB_API_URL + '/api/IdleHouse/Export',
params: values,
headers: {
'X-Token': localStorage.getItem('X-Token'),
},
responseType: 'blob',
}).then((res) => {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(res.data);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
});
break;
default:
break;
}

View File

@ -49,11 +49,14 @@
import { PageList, Detail, AddOrEdit, Delete } from '@/api/IdleLand'
import InsertModal from './InsertModal.vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import axios from 'axios';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
defineOptions({ name: 'RoleManagement' });
const showInfoData = ref();
const modalTitle = ref('')
const [registerTable, { reload }] = useTable({
const [registerTable, { reload, getForm }] = useTable({
title: '土地资源',
api: PageList,
columns,
@ -78,13 +81,36 @@
},
});
const open = ref<boolean>(false);
function onBtnClicked(domId) {
async function onBtnClicked(domId) {
switch (domId) {
case 'add':
modalTitle.value = '新增'
showInfoData.value = JSON.parse(JSON.stringify(defaultValue))
open.value = true;
break;
case 'export':
const filters = await getForm();
const values = filters?.getFieldsValue();
const fileName = '土地资源表' + new Date().getTime() + '.xls';
axios({
method: 'get',
url: VITE_GLOB_API_URL + '/api/IdleLand/Export',
params: values,
headers: {
'X-Token': localStorage.getItem('X-Token'),
},
responseType: 'blob',
}).then((res) => {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(res.data);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
});
break;
default:
break;
}

View File

@ -49,11 +49,14 @@
import { PageList, Detail, AddOrEdit, Delete } from '@/api/IdleWaters'
import InsertModal from './InsertModal.vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import axios from 'axios';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
defineOptions({ name: 'RoleManagement' });
const showInfoData = ref();
const modalTitle = ref('')
const [registerTable, { reload }] = useTable({
const [registerTable, { reload, getForm }] = useTable({
title: '土地资源',
api: PageList,
columns,
@ -78,13 +81,36 @@
},
});
const open = ref<boolean>(false);
function onBtnClicked(domId) {
async function onBtnClicked(domId) {
switch (domId) {
case 'add':
modalTitle.value = '新增'
showInfoData.value = JSON.parse(JSON.stringify(defaultValue))
open.value = true;
break;
case 'export':
const filters = await getForm();
const values = filters?.getFieldsValue();
const fileName = '水域表' + new Date().getTime() + '.xls';
axios({
method: 'get',
url: VITE_GLOB_API_URL + '/api/IdleWaters/Export',
params: values,
headers: {
'X-Token': localStorage.getItem('X-Token'),
},
responseType: 'blob',
}).then((res) => {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(res.data);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
});
break;
default:
break;
}