From c49d7010ae971c80babb142dd9ad0f3ca560345b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=95=E5=B5=A9?= <17854119262@163.com> Date: Wed, 10 Jul 2024 14:54:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BF=9D=E6=B3=95=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E6=83=85=E5=86=B5=E7=BB=9F=E8=AE=A1=E6=98=8E=E7=BB=86=E8=A1=A8?= =?UTF-8?q?-=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/demo/caseoffence/index.data.ts | 2 +- src/views/demo/caseoffence/index.vue | 58 ++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/views/demo/caseoffence/index.data.ts b/src/views/demo/caseoffence/index.data.ts index 189ef566..f688384e 100644 --- a/src/views/demo/caseoffence/index.data.ts +++ b/src/views/demo/caseoffence/index.data.ts @@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [ title: '县区', dataIndex: 'countyname', width: 150, - // fixed: 'left', + fixed: 'left', }, { title: '下发图斑', diff --git a/src/views/demo/caseoffence/index.vue b/src/views/demo/caseoffence/index.vue index 3f99fbd6..125ca283 100644 --- a/src/views/demo/caseoffence/index.vue +++ b/src/views/demo/caseoffence/index.vue @@ -154,14 +154,17 @@ import { PermissionBtn } from '@/components/PermissionBtn/index'; import { PageWrapper } from '@/components/Page'; import { cloneDeep } from 'lodash-es'; - import { getCaseOffence } from '@/api/demo/system'; + import { getCaseOffence, postCaseOffenceToExcel } from '@/api/demo/system'; import { columns, searchFormSchema } from './index.data'; import { useMessage } from '@/hooks/web/useMessage'; - import { MinusOutlined, CloseOutlined, CloudDownloadOutlined } from '@ant-design/icons-vue'; - import dayjs from 'dayjs'; import { RecordList } from './page'; + import { MinusOutlined, CloseOutlined, CloudDownloadOutlined } from '@ant-design/icons-vue'; + import { getAppEnvConfig } from '@/utils/env'; + import axios from 'axios'; + import dayjs from 'dayjs'; const { createMessage } = useMessage(); + const { VITE_GLOB_API_URL } = getAppEnvConfig(); // 页面表格 const searchParams = ref(); @@ -177,9 +180,9 @@ showIndexColumn: false, striped: false, bordered: true, - showSummary: true, canResize: false, useSearchForm: true, + // showTableSetting: true, pagination: false, size: 'small', handleSearchInfoFn(info) { @@ -265,6 +268,18 @@ // 标签页面的搜索条件 currentListQuery.listQuery = searchForm; } + function onEdit(targetKey: string) { + tablist.splice(parseInt(targetKey), 1); + if (tablist.length == 0) { + showRecordList.value = false; + } + if (parseInt(targetKey) > 1) { + activeKey.value = (parseInt(targetKey) - 1).toString(); + } else { + activeKey.value = '0'; + } + currentListQuery.listQuery = tablist[activeKey.value].listQuery; + } function handleTabChange(e) { currentListQuery.listQuery = tablist[e].listQuery; } @@ -280,6 +295,41 @@ } showRecordList.value = false; } + + // 直接下载接口返回的二进制流 + function handleExport() { + let params = { + startTime: dayjs(searchParams.value?.startTime).format('YYYY-MM'), + endTime: dayjs(searchParams.value?.endTime).format('YYYY-MM'), + }; + axios({ + method: 'post', + url: VITE_GLOB_API_URL + '/api/DroneCaseInfoSingle/CaseOffenceToExcel', + params: params, + headers: { + 'X-Token': localStorage.getItem('X-Token'), + }, + responseType: 'blob', + }).then((res) => { + let fileName = '无人机发现违法行为情况统计明细表' + new Date().getTime() + '.xls'; + 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); + }); + } + // 按键分类 + const buttonClick = async (type) => { + switch (type) { + case 'btnExport': + handleExport(); + break; + } + };