徐景良 2024-11-21 15:38:25 +08:00
commit 231be12de0
7 changed files with 555 additions and 175 deletions

View File

@ -132,6 +132,8 @@ enum Api {
GeoStyleBindLayer = '/api/GeoStyle/BindLayer',
// 非法采矿-统计列表
CaseOffenceMinerals = '/api/DroneCaseInfoMinerals/CaseOffenceMinerals',
// 非法采矿-统计列表New
CaseOffenceMineralsNew = '/api/DroneCaseInfoMinerals/CaseOffenceMineralsNew',
}
export const getPositionsTree = (params?: AccountParams) =>
defHttp.get<AccountListGetResultModel>({ url: Api.PositionsTree, params });
@ -495,4 +497,7 @@ export const GeoStylePage = (params) =>
defHttp.get({ url: Api.GeoStylePage, params });
// 非法采矿-统计列表
export const CaseOffenceMinerals = (params: ReportParams) =>
defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffenceMinerals, params });
defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffenceMinerals, params });
// 非法采矿-统计列表New
export const CaseOffenceMineralsNew = (params: ReportParams) =>
defHttp.get<StatisticalListGetResultModel>({ url: Api.CaseOffenceMineralsNew, params });

View File

@ -1,7 +1,7 @@
<template>
<div class="show-map-div">
<div class="select-menu">
<div class="add-on-map" v-if="selectType !== 2">
<div class="add-on-map">
<a-checkbox v-model:checked="addOnMap" @change="(e) => addOnMapChange(e.target.checked)">
叠加到地图
</a-checkbox>
@ -9,7 +9,7 @@
<a-radio-group v-model:value="selectType" button-style="solid" size="small">
<a-radio-button :value="0">专题图</a-radio-button>
<!-- <a-radio-button :value="1">截图</a-radio-button> -->
<a-radio-button :value="2">天地图</a-radio-button>
<!-- <a-radio-button :value="2">天地图</a-radio-button> -->
</a-radio-group>
</div>
<div class="slider-menu">
@ -68,8 +68,8 @@
</a-tooltip> -->
</div>
<div class="expandShow-menu">
<FullscreenOutlined
v-if="(addOnMap || selectType == 2) && !expandShow"
<FullscreenOutlined
v-if="addOnMap && !expandShow"
:style="{
position: 'absolute',
fontSize: '28px',
@ -81,7 +81,7 @@
@click="expand(!expandShow)"
/>
<FullscreenExitOutlined
v-if="(addOnMap || selectType == 2) && expandShow"
v-if="addOnMap && expandShow"
:style="{
position: 'fixed',
fontSize: '35px',
@ -93,8 +93,9 @@
@click="expand(!expandShow)"
/>
</div>
<template v-if="selectType === 0 && !addOnMap">
<a-image
<template v-if="selectType === 0">
<a-image
v-if="!addOnMap"
:width="470"
:height="470"
:src="convertValidUrl(showData.url)"
@ -105,24 +106,24 @@
</template>
<template v-if="selectType === 1 && !addOnMap">
<a-image
v-if="!addOnMap"
:width="470"
:height="470"
:src="convertValidUrl(showData.urlxian)"
:src="convertValidUrl(showData.urlxian)"
:preview="{
src: showData.previewUrlXian,
}"
/>
</template>
<template v-if="selectType === 2 || addOnMap">
<ModalMap
:width="modalMapWidth"
:height="modalMapHeight"
:zIndex="modalMapZIndex"
:position="modalMapPosition"
:centerAndZoom="props.data"
@getMap="getMap"
/>
</template>
<ModalMap
v-if="addOnMap"
:width="modalMapWidth"
:height="modalMapHeight"
:zIndex="modalMapZIndex"
:position="modalMapPosition"
:centerAndZoom="props.data"
@getMap="getMap"
/>
</div>
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="土地分类">
@ -134,7 +135,6 @@
</a-tab-pane>
<a-tab-pane key="2" tab="耕地占用">
<ShowTableList
v-if="props.data.length > 1"
:columns="landPlanningColumns"
:data="plowLandOccupyTable"
:title="'土地规划查询结果'"
@ -145,66 +145,61 @@
<script setup lang="ts">
import { ref, defineProps, computed, watch, onMounted } from 'vue';
import ShowTableList from '@/views/dashboard/test/components/ShowTableList/index.vue';
import {
PlusCircleOutlined,
MinusCircleOutlined,
ExpandOutlined,
FullscreenOutlined,
FullscreenExitOutlined
PlusCircleOutlined,
MinusCircleOutlined,
FullscreenOutlined,
FullscreenExitOutlined,
} from '@ant-design/icons-vue';
import Icon from '@/components/Icon/Icon.vue';
import ShowTableList from '@/views/dashboard/test/components/ShowTableList/index.vue';
import ModalMap from './ModalMap/index.vue';
import mapboxgl from 'mapbox-gl';
//
import { getAppEnvConfig } from '@/utils/env';
import { result } from 'node_modules/@types/lodash-es';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
const VITE_GLOB_API_URL_VAR = ref<String>(VITE_GLOB_API_URL + '/');
const props = defineProps(['data']);
const basciQuery = ref([]);
let map;
onMounted(() => {
if (props.data) {
activeKey.value = '1';
}
});
// URL
function convertValidUrl(url: string): boolean {
const regex =
/^(?:http|ftp)s?:\/\/(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[?[A-F0-9]*:[A-F0-9:]+\]?)(?::\d+)?(?:\/?|[\/?]\S+)$/i;
let result: any = regex.test(url) ? url : VITE_GLOB_API_URL_VAR.value + url;
return result;
}
//
const activeKey = ref('1');
//
const addOnMap = ref(true);
//
const selectType = ref(0);
watch(
//
() => activeKey.value,
() => {
if (addOnMap.value) {
//
if(map) {
if (map.getLayer('radar-layer')) {
map.removeLayer('radar-layer');
}
if (map.getSource('radar')) {
map.removeSource('radar');
}
}
}
//
addOnMapChange(true);
selectType.value = 2;
addOnMap.value = false;
if (addOnMap.value) {
addOnMapChange(true);
}
},
);
watch(
//
() => selectType.value,
() => {
//
if (addOnMap.value) {
addOnMapChange(true);
}
},
);
//
const landClassifyTable = computed(() => {
let data;
props.data?.forEach((item, index) => {
if (item.name == '土地分类') {
data = { ...item };
}
//
if (index == 0) {
//
let fourpoint = JSON.parse(`[${item.fourpoint}]`);
setTimeout(() => {
moveLocation(fourpoint);
@ -212,31 +207,31 @@ import { result } from 'node_modules/@types/lodash-es';
//
addOnMapChange(true);
}
if (item.name == '土地分类') {
data = { ...item };
}
if(item.url){
changeTransparentColorToWhite(convertValidUrl(item.url)).then(resultImageUrl => {
//
if (item.url && !item.previewUrl) {
changeTransparentColorToWhite(convertValidUrl(item.url)).then((resultImageUrl) => {
item.previewUrl = resultImageUrl;
});
}
if(item.urlxian){
changeTransparentColorToWhite(convertValidUrl(item.urlxian)).then(resultImageUrl => {
if (item.urlxian && !item.previewUrlXian) {
changeTransparentColorToWhite(convertValidUrl(item.urlxian)).then((resultImageUrl) => {
item.previewUrlXian = resultImageUrl;
});
}
});
return data && data.list;
});
const plowLandOccupyTable = computed(() => {
let data;
props.data?.forEach((item) => {
if (item.name == '耕地占用') {
data = { ...item };
data = { ...item };
}
});
return data && data.list;
});
const showData = computed(() => {
let data;
switch (activeKey.value) {
@ -256,9 +251,7 @@ import { result } from 'node_modules/@types/lodash-es';
return data;
}
});
const addOnMap = ref(false);
const selectType = ref(2);
//
const landClassificationColumns = [
{
title: '地类名称',
@ -272,7 +265,7 @@ import { result } from 'node_modules/@types/lodash-es';
title: '联合属性',
dataIndex: 'stats',
key: 'stats',
width: 90,
width: 100,
sorter: (a, b) => a.stats.length - b.stats.length,
sortDirections: ['descend', 'ascend'],
},
@ -280,7 +273,7 @@ import { result } from 'node_modules/@types/lodash-es';
title: '面积(亩)',
dataIndex: 'area',
key: 'area',
width: 200,
width: 150,
sorter: (a, b) => a.area - b.area,
sortDirections: ['descend', 'ascend'],
},
@ -305,7 +298,7 @@ import { result } from 'node_modules/@types/lodash-es';
map = value;
};
//
// ------------------------------------------------------------------------------------------------
const addOnMapChange = (value) => {
setTimeout(async () => {
let url: any = '';
@ -333,6 +326,7 @@ import { result } from 'node_modules/@types/lodash-es';
url = convertValidUrl(data.urlxian);
fourpoint = JSON.parse(`[${data.fourpoint}]`);
}
//
let image = new Image();
image.crossOrigin = 'anonymous';
image.src = url;
@ -341,18 +335,14 @@ import { result } from 'node_modules/@types/lodash-es';
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
// Canvas
const ctx = canvas.getContext('2d');
// Canvas
ctx.drawImage(image, 0, 0, image.width, image.height);
// CanvasURL
const dataURL = canvas.toDataURL('image/png');
//
if(map) {
if (map) {
if (map.getLayer('radar-layer')) {
map.removeLayer('radar-layer');
}
@ -360,11 +350,10 @@ import { result } from 'node_modules/@types/lodash-es';
map.removeSource('radar');
}
}
//
map.addSource('radar', {
type: 'image',
url: dataURL,
url: url,
coordinates: fourpoint,
paint: {
'raster-opacity': 1,
@ -412,7 +401,6 @@ import { result } from 'node_modules/@types/lodash-es';
const nw = points[0];
const ne = points[1];
const se = points[2];
const sw = points[3];
const latRange = Math.abs(nw[1] - se[1]);
const lngRange = Math.abs(nw[0] - ne[0]);
//
@ -422,7 +410,82 @@ import { result } from 'node_modules/@types/lodash-es';
return Math.min(zoomLat * 1.05, zoomLng * 1.05).toFixed(2);
}
// ------------------------------------------------
// --------------------------------------------------------------------------------------------------------------
const modalMapWidth = ref('470px');
const modalMapHeight = ref('470px');
const modalMapZIndex = ref(10);
const modalMapPosition = ref('absolute');
const expandShow = ref(false);
//
function expand(value) {
if (value) {
modalMapWidth.value = '100%';
modalMapHeight.value = '100%';
modalMapZIndex.value = 1011;
modalMapPosition.value = 'fixed';
} else {
modalMapWidth.value = '470px';
modalMapHeight.value = '470px';
modalMapZIndex.value = 10;
modalMapPosition.value = 'absolute';
}
setTimeout(() => {
map.resize();
}, 100);
expandShow.value = value;
}
// ------------------------------------------------------------------------------------------------------------
// URL
function convertValidUrl(url: string): boolean {
const regex =
/^(?:http|ftp)s?:\/\/(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[?[A-F0-9]*:[A-F0-9:]+\]?)(?::\d+)?(?:\/?|[\/?]\S+)$/i;
let result: any = regex.test(url) ? url : VITE_GLOB_API_URL_VAR.value + url;
return result;
}
//
async function changeTransparentColorToWhite(imageUrl) {
return new Promise((resolve, reject) => {
// Image
const img = new Image();
img.crossOrigin = 'Anonymous'; //
img.src = imageUrl;
img.onload = () => {
// canvas
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// canvas
canvas.width = img.width;
canvas.height = img.height;
// canvas
ctx.drawImage(img, 0, 0);
// canvas
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
//
for (let i = 0; i < data.length; i += 4) {
if (data[i + 3] === 0) {
// alpha 0
data[i] = 255; //
data[i + 1] = 255; // 绿
data[i + 2] = 255; //
data[i + 3] = 255; // alpha
}
}
// canvas
ctx.putImageData(imageData, 0, 0);
// canvas URL
const resultImageUrl = canvas.toDataURL('image/png');
// URL
resolve(resultImageUrl);
};
img.onerror = (error) => {
reject(error);
};
});
}
// -----------------------------------------------------------------------------------------------------------
const nowSliderValue = ref<number>(10);
//
const marks = ref<Record<number, any>>({
@ -453,72 +516,6 @@ import { result } from 'node_modules/@types/lodash-es';
function changeSliderShow() {
sliderShow.value = !sliderShow.value;
}
// -------------------------------------------------------
const modalMapWidth = ref('470px');
const modalMapHeight = ref('470px');
const modalMapZIndex = ref(10);
const modalMapPosition = ref('absolute');
const expandShow = ref(false);
function expand(value) {
if (value) {
modalMapWidth.value = '100%';
modalMapHeight.value = '100%';
modalMapZIndex.value = 1011;
modalMapPosition.value = 'fixed';
} else {
modalMapWidth.value = '470px';
modalMapHeight.value = '470px';
modalMapZIndex.value = 10;
modalMapPosition.value = 'absolute';
}
setTimeout(()=>{
map.resize();
}, 100);
expandShow.value = value;
}
//
async function changeTransparentColorToWhite(imageUrl) {
return new Promise((resolve, reject) => {
// Image
const img = new Image();
img.crossOrigin = 'Anonymous'; //
img.src = imageUrl;
img.onload = () => {
// canvas
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
// canvas
canvas.width = img.width;
canvas.height = img.height;
// canvas
ctx.drawImage(img, 0, 0);
// canvas
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
//
for (let i = 0; i < data.length; i += 4) {
if (data[i + 3] === 0) { // alpha 0
data[i] = 255; //
data[i + 1] = 255; // 绿
data[i + 2] = 255; //
data[i + 3] = 255; // alpha
}
}
// canvas
ctx.putImageData(imageData, 0, 0);
// canvas URL
const resultImageUrl = canvas.toDataURL('image/png');
// URL
resolve(resultImageUrl);
};
img.onerror = (error) => {
reject(error);
};
});
}
</script>
<style lang="scss" scoped>

View File

@ -1,13 +1,15 @@
<template>
<!-- <div class="control-show">
<div>
<!-- <div class="control-show">
<a-radio-group v-model:value="select" button-style="solid" size="small">
<a-radio-button :value="0">专题图</a-radio-button>
<a-radio-button :value="1">截图</a-radio-button>
</a-radio-group>
</div> -->
<a-image :width="470" :height="470" :src="get(url)" />
<div class="footer" v-if="haveFooter">
<slot name="footer" />
<a-image :width="470" :height="470" :src="get(url)" />
<div class="footer" v-if="haveFooter">
<slot name="footer" />
</div>
</div>
</template>
@ -52,6 +54,5 @@
::v-deep .ant-image-mask {
display: none !important;
// background: red !important;
}
</style>
</style>

View File

@ -80,6 +80,92 @@ export const columns: BasicColumn[] = [
},
];
// 无人机发现违法行为情况统计明细表-table
export const columnsNew: BasicColumn[] = [
{
title: 'countyid',
dataIndex: '县区id',
ifShow: false,
},
{
title: '县区',
dataIndex: 'countyname',
width: 100,
fixed: 'left',
},
{
title: '下发线索总数(个)',
dataIndex: 'xfwtzs',
width: 150,
},
{
title: '总数',
children: [
{
title: '已完成(个)',
dataIndex: 'ywc',
width: 100,
},
{
title: '未完成(个)',
dataIndex: 'wwc',
width: 100,
},
{
title: '完成率(%',
dataIndex: 'wcl',
width: 100,
},
]
},
{
title: '定性',
children: [
{
title: '合法(个)',
dataIndex: 'dxhf',
width: 100,
},
{
title: '违法(个)',
dataIndex: 'dxwf',
width: 100,
},
{
title: '其他(个)',
dataIndex: 'dxqt',
width: 100,
},
{
title: '未定性(个)',
dataIndex: 'dxwdx',
width: 100,
},
]
},
{
title: '分类',
children: [
{
title: '非法开采(个)',
dataIndex: 'flffkc',
width: 100,
},
{
title: '非法加工(个)',
dataIndex: 'flffjg',
width: 100,
},
]
},
{
title: '超期未报(个)',
dataIndex: 'cqwb',
fixed: 'right',
width: 100,
},
];
// 无人机发现违法行为情况统计明细表-搜索
export const searchFormSchema: FormSchema[] = [
{

View File

@ -4,14 +4,6 @@
<template #toolbar>
<PermissionBtn @btnEvent="buttonClick"></PermissionBtn>
</template>
<template #bodyCell="{ column, record }">
<!-- 整改率 -->
<template v-if="column.key === 'zgl'"> {{ record.zgl }}% </template>
<!-- 驳回率 -->
<template v-if="column.key === 'bhl'"> {{ record.bhl }}% </template>
<!-- 上报率 -->
<template v-if="column.key === 'sbl'"> {{ record.sbl }}% </template>
</template>
</BasicTable>
</div>
</template>
@ -23,8 +15,8 @@
import { PermissionBtn } from '@/components/PermissionBtn/index';
import { PageWrapper } from '@/components/Page';
import { cloneDeep } from 'lodash-es';
import { CaseOffenceMinerals } from '@/api/demo/system';
import { columns, searchFormSchema } from './index.data';
import { CaseOffenceMineralsNew } from '@/api/demo/system';
import { columnsNew, searchFormSchema } from './index.data';
import { useMessage } from '@/hooks/web/useMessage';
import { getAppEnvConfig } from '@/utils/env';
import axios from 'axios';
@ -36,8 +28,8 @@
//
const searchParams = ref();
const [registerTable] = useTable({
api: CaseOffenceMinerals,
columns: columns,
api: CaseOffenceMineralsNew,
columns: columnsNew,
// title: '',
// titleHelpMessage: '',
formConfig: {
@ -53,8 +45,8 @@
pagination: false,
beforeFetch: (data) => {
//
console.log(data);
//
// console.log(data);
// -
if (Object.keys(data).length == 0) {
var temp = {
startTime: dayjs('2024-08-01').startOf('day').format('YYYY-MM-DD'),
@ -63,7 +55,16 @@
searchParams.value = temp;
return temp;
}
//
// -
if (data.startTime === undefined && data.endTime === undefined) {
var temp = {
startTime: dayjs('2024-08-01').startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().endOf('day').add(-1, 'day').format('YYYY-MM-DD HH:mm:ss'),
};
searchParams.value = temp;
return temp;
}
// -
if (data.startTime && data.endTime) {
var temp = {
startTime: dayjs(data.startTime).startOf('day').format('YYYY-MM-DD'),
@ -72,7 +73,8 @@
searchParams.value = temp;
return temp;
}
if (data.startTime === null || data.endTime === undefined) {
// X
if (data.startTime === null && data.endTime === undefined) {
searchParams.value = {};
}
},
@ -86,7 +88,9 @@
let params: any = {};
let afterTitle = '';
if (
if (searchParams.value?.startTime === undefined && searchParams.value?.endTime === undefined) {
afterTitle = afterTitle;
} else if (
dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD') ===
dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD')
) {
@ -100,17 +104,21 @@
switch (exportType) {
case '':
url = VITE_GLOB_API_URL + '/api/DroneCaseInfoMinerals/CaseOfMineralsToExcel';
url = VITE_GLOB_API_URL + '/api/DroneCaseInfoMinerals/CaseOfMineralsToExcelNew';
fileName = '汇总表 ' + afterTitle + '.xls';
break;
default:
break;
}
params = {
startTime: dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD'),
endTime: dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
};
if (
!(searchParams.value?.startTime === undefined && searchParams.value?.endTime === undefined)
) {
params = {
startTime: dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD'),
endTime: dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
};
}
axios({
method: 'post',

View File

@ -0,0 +1,96 @@
import { BasicColumn, FormSchema } from '@/components/Table';
import dayjs from 'dayjs';
// 无人机发现违法行为情况统计明细表-table
export const columns: BasicColumn[] = [
{
title: 'countyid',
dataIndex: '县区id',
ifShow: false,
},
{
title: '县区',
dataIndex: 'countyname',
width: 100,
fixed: 'left',
},
{
title: '下发问题总数',
dataIndex: 'xfwtzs',
width: 100,
},
{
title: '合法',
dataIndex: 'hf',
width: 100,
},
{
title: '其他',
dataIndex: 'qt',
width: 100,
},
{
title: '违法',
dataIndex: 'wf',
width: 100,
},
{
title: '已完成归档',
dataIndex: 'ywcgd',
width: 100,
},
{
title: '未完成归档',
dataIndex: 'wwcgd',
width: 100,
},
{
title: '未完成归档',
width: 200,
children: [
{
title: '违法采矿',
dataIndex: 'wfck',
width: 100,
},
{
title: '违法加工',
dataIndex: 'wfjg',
width: 100,
},
],
},
{
title: '整改率',
dataIndex: 'zgl',
fixed: 'right',
width: 100,
},
{
title: '驳回率',
dataIndex: 'bhl',
fixed: 'right',
width: 100,
},
{
title: '上报率',
dataIndex: 'sbl',
fixed: 'right',
width: 100,
},
];
// 无人机发现违法行为情况统计明细表-搜索
export const searchFormSchema: FormSchema[] = [
{
field: '[startTime, endTime]',
label: '日期范围',
component: 'RangePicker',
colProps: { span: 8 },
componentProps: {
format: 'YYYY-MM-DD',
placeholder: ['开始日期', '结束日期'],
defaultValue: [dayjs('2024-08-01', 'YYYY-MM-DD'), dayjs(dayjs().add(-1, 'day'), 'YYYY-MM-DD')]
},
},
];

View File

@ -0,0 +1,187 @@
<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<PermissionBtn @btnEvent="buttonClick"></PermissionBtn>
</template>
<template #bodyCell="{ column, record }">
<!-- 整改率 -->
<template v-if="column.key === 'zgl'"> {{ record.zgl }}% </template>
<!-- 驳回率 -->
<template v-if="column.key === 'bhl'"> {{ record.bhl }}% </template>
<!-- 上报率 -->
<template v-if="column.key === 'sbl'"> {{ record.sbl }}% </template>
</template>
</BasicTable>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, watch, createVNode, unref } from 'vue';
import { useModal } from '@/components/Modal';
import { BasicTable, useTable } from '@/components/Table';
import { PermissionBtn } from '@/components/PermissionBtn/index';
import { PageWrapper } from '@/components/Page';
import { cloneDeep } from 'lodash-es';
import { CaseOffenceMinerals } from '@/api/demo/system';
import { columns, searchFormSchema } from './index.data';
import { useMessage } from '@/hooks/web/useMessage';
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();
const [registerTable] = useTable({
api: CaseOffenceMinerals,
columns: columns,
// title: '',
// titleHelpMessage: '',
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
},
showIndexColumn: false,
striped: false,
bordered: true,
canResize: false,
useSearchForm: true,
showTableSetting: true,
pagination: false,
beforeFetch: (data) => {
//
// console.log(data);
// -
if (Object.keys(data).length == 0) {
var temp = {
startTime: dayjs('2024-08-01').startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().endOf('day').add(-1, 'day').format('YYYY-MM-DD HH:mm:ss'),
};
searchParams.value = temp;
return temp;
}
// -
if (data.startTime === undefined && data.endTime === undefined) {
var temp = {
startTime: dayjs('2024-08-01').startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().endOf('day').add(-1, 'day').format('YYYY-MM-DD HH:mm:ss'),
};
searchParams.value = temp;
return temp;
}
// -
if (data.startTime && data.endTime) {
var temp = {
startTime: dayjs(data.startTime).startOf('day').format('YYYY-MM-DD'),
endTime: dayjs(data.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
};
searchParams.value = temp;
return temp;
}
// X
if (data.startTime === null && data.endTime === undefined) {
searchParams.value = {};
}
},
afterFetch: (res) => {},
});
//
function handleExport(exportType) {
let url = '';
let fileName = '';
let params: any = {};
let afterTitle = '';
if (searchParams.value?.startTime === undefined && searchParams.value?.endTime === undefined) {
afterTitle = afterTitle;
} else if (
dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD') ===
dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD')
) {
afterTitle = dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD');
} else {
afterTitle =
dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD') +
'至' +
dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD');
}
switch (exportType) {
case '':
url = VITE_GLOB_API_URL + '/api/DroneCaseInfoMinerals/CaseOfMineralsToExcel';
fileName = '汇总表 ' + afterTitle + '.xls';
break;
default:
break;
}
if (
!(searchParams.value?.startTime === undefined && searchParams.value?.endTime === undefined)
) {
params = {
startTime: dayjs(searchParams.value?.startTime).startOf('day').format('YYYY-MM-DD'),
endTime: dayjs(searchParams.value?.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
};
}
axios({
method: 'post',
url: url,
params: params,
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);
});
}
//
const buttonClick = async (type) => {
switch (type) {
case 'btnExport':
handleExport('');
break;
default:
break;
}
};
</script>
<style lang="less" scoped>
#closeIconButton {
width: 40px;
height: 50px;
line-height: 50px;
float: right;
text-align: center;
cursor: pointer;
}
.exportbutton {
width: 510px;
height: 60px;
margin: 5px;
}
::v-deep .ant-table-container table {
line-height: 1.1 !important;
.ant-table-row {
td {
padding-top: 8px !important;
padding-bottom: 8px !important;
}
}
}
</style>