添加水温分析菜单

This commit is contained in:
扈兆增 2026-06-26 14:56:54 +08:00
parent be3936d1bd
commit 1b4f036c6e
19 changed files with 6760 additions and 346 deletions

View File

@ -13,6 +13,10 @@
"@ant-design/icons-vue": "^7.0.1", "@ant-design/icons-vue": "^7.0.1",
"@element-plus/icons-vue": "^2.0.10", "@element-plus/icons-vue": "^2.0.10",
"@types/js-cookie": "^3.0.2", "@types/js-cookie": "^3.0.2",
"@univerjs-pro/exchange-client": "0.15.0",
"@univerjs/core": "0.14.0",
"@univerjs/preset-sheets-core": "^0.14.0",
"@univerjs/presets": "^0.14.0",
"@vueuse/core": "^9.1.1", "@vueuse/core": "^9.1.1",
"@wangeditor/editor": "^5.0.0", "@wangeditor/editor": "^5.0.0",
"@wangeditor/editor-for-vue": "^5.1.10", "@wangeditor/editor-for-vue": "^5.1.10",
@ -27,6 +31,7 @@
"element-plus": "^2.2.27", "element-plus": "^2.2.27",
"esri-leaflet": "^3.0.19", "esri-leaflet": "^3.0.19",
"exceljs": "^4.4.0", "exceljs": "^4.4.0",
"file-saver": "^2.0.5",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
@ -40,6 +45,8 @@
"path-to-regexp": "^6.2.0", "path-to-regexp": "^6.2.0",
"pdfjs-dist": "^6.0.227", "pdfjs-dist": "^6.0.227",
"pinia": "^2.0.12", "pinia": "^2.0.12",
"react": "18",
"react-dom": "18",
"screenfull": "^6.0.0", "screenfull": "^6.0.0",
"sortablejs": "^1.14.0", "sortablejs": "^1.14.0",
"video.js": "^8.23.7", "video.js": "^8.23.7",

File diff suppressed because it is too large Load Diff

View File

@ -159,6 +159,31 @@ export function getSurfaceTempMonthList(data) {
data data
}); });
} }
// 表层水温 - 数据分析 - 断面
export function getSurfaceTempAnalysisList(data) {
return request({
url: '/wt/msstbprpt/eng/GetKendoList',
method: 'post',
data
});
}
// 表层水温 - 数据分析 - excel
export function getSurfaceTempAnalysisExcel(data) {
return request({
url: '/wt/wtrvAmend/dayAmend/GetKendoListCust',
method: 'post',
data
});
}
// 表层水温 - 数据分析 - 保存
export function saveSurfaceTempAnalysisExcel(data) {
return request({
url: '/wt/wtrvAmend/dayAmend/saveAmendData',
method: 'post',
data
});
}
// 过鱼设施名称 - 断面 // 过鱼设施名称 - 断面
export function getFishReleaseMonitorSectionList(data) { export function getFishReleaseMonitorSectionList(data) {
return request({ return request({

View File

@ -17,6 +17,14 @@ export function getSelectForDropdown(data: any) {
data data
}); });
} }
// 所在河段下拉列表
export function getRvcdDropdown(params: any) {
return request({
url: '/env/rvcd/selectForDropdown',
method: 'get',
params: params
});
}
//电站下拉列表 //电站下拉列表
export function getEngInfoDropdown(data: any) { export function getEngInfoDropdown(data: any) {
return request({ return request({
@ -25,6 +33,22 @@ export function getEngInfoDropdown(data: any) {
data data
}); });
} }
// 根据id获取电站信息
export function getEngInfoById(params: any) {
return request({
url: '/env/engInfo/getById',
method: 'get',
params
});
}
// 所在位置下拉列表
export function getAddvcdDropdown(data: any) {
return request({
url: '/env/addvcd/selectForDropdown',
method: 'post',
data
});
}
// 重新验证并更新行数据 // 重新验证并更新行数据
export function revalidateAndUpdateRow(data: any) { export function revalidateAndUpdateRow(data: any) {
return request({ return request({

View File

@ -2,7 +2,7 @@ import request from '@/utils/request';
// 顶部tabs // 顶部tabs
export function baseMsstbprpt(data: any) { export function baseMsstbprpt(data: any) {
return request({ return request({
url: '/api/dec-lygk-base-server/base/msstbprpt/GetKendoList', url: '/vd/msstbprpt/GetKendoList',
method: 'post', method: 'post',
data data
}); });
@ -10,7 +10,7 @@ export function baseMsstbprpt(data: any) {
// 实时视频 // 实时视频
export function envVdTreeGetKendoListCust(data: any) { export function envVdTreeGetKendoListCust(data: any) {
return request({ return request({
url: '/api/wmp-env-server/env/vd/tree/GetKendoListCust', url: '/vd/tree/GetKendoListCust',
method: 'post', method: 'post',
data data
}); });
@ -18,7 +18,7 @@ export function envVdTreeGetKendoListCust(data: any) {
// 录像 // 录像
export function envVdRunDataGetKendoList(data: any) { export function envVdRunDataGetKendoList(data: any) {
return request({ return request({
url: '/api/wmp-env-server/env/vd/runData/GetKendoListCust', url: '/vd/runData/GetKendoListCust',
method: 'post', method: 'post',
data data
}); });

View File

@ -38,7 +38,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, onMounted, watch, nextTick, h, useSlots } from 'vue'; import { ref, computed, onMounted, watch, nextTick, h, useSlots } from 'vue';
import { message } from 'ant-design-vue'; import { message, Tooltip } from 'ant-design-vue';
import { calcTableScrollY } from '@/utils/index'; import { calcTableScrollY } from '@/utils/index';
import { exportTable as exportTableUtil } from '@/utils/exportExcel'; import { exportTable as exportTableUtil } from '@/utils/exportExcel';
@ -222,7 +222,7 @@ const getList = async (filter?: Record<string, any>) => {
let finalTotal = 0; let finalTotal = 0;
if (props.transformData) { if (props.transformData) {
const result:any = props.transformData(res); const result: any = props.transformData(res);
finalRecords = result.records || result.data || []; finalRecords = result.records || result.data || [];
finalTotal = result.total || 0; finalTotal = result.total || 0;
} else { } else {
@ -256,7 +256,7 @@ const getList = async (filter?: Record<string, any>) => {
const handleTableChange = (pag: any, filters: any, sorter: any) => { const handleTableChange = (pag: any, filters: any, sorter: any) => {
// sorter field order // sorter field order
const isSortChange = sorter && sorter.field && sorter.order !== undefined; const isSortChange = sorter && sorter.field && sorter.order !== undefined;
if (isSortChange) { if (isSortChange) {
// 1 // 1
internalSort.value = { field: sorter.field, order: sorter.order }; internalSort.value = { field: sorter.field, order: sorter.order };
@ -268,11 +268,11 @@ const handleTableChange = (pag: any, filters: any, sorter: any) => {
page.value = 1; page.value = 1;
emit('sort-change', { field: '', order: null }); emit('sort-change', { field: '', order: null });
} }
// 使 // 使
page.value = pag.current; page.value = pag.current;
size.value = pag.pageSize; size.value = pag.pageSize;
// //
getList(); getList();
}; };
@ -575,7 +575,7 @@ const enhancedColumns = computed(() => {
return props.columns.map(col => { return props.columns.map(col => {
const enhancedCol: any = { ...col }; const enhancedCol: any = { ...col };
// sort sorter: true sorter sortOrder // sort sorter: true
const isSortable = enhancedCol.sort === true || enhancedCol.sorter === true; const isSortable = enhancedCol.sort === true || enhancedCol.sorter === true;
if (isSortable) { if (isSortable) {
enhancedCol.sorter = true; enhancedCol.sorter = true;
@ -592,7 +592,6 @@ const enhancedColumns = computed(() => {
customCell: createMergeCellHandler(col) customCell: createMergeCellHandler(col)
}; };
// slots.customRender slots
if (enhancedCol.slots?.customRender) { if (enhancedCol.slots?.customRender) {
const { slots, ...restCol } = enhancedCol; const { slots, ...restCol } = enhancedCol;
return { return {
@ -605,26 +604,61 @@ const enhancedColumns = computed(() => {
return enhancedCol; return enhancedCol;
} }
// slots.customRender slots bodyCell dataIndex // slots.customRender slots
if (enhancedCol.slots?.customRender) { if (enhancedCol.slots?.customRender) {
const { slots, ...restCol } = enhancedCol; const { slots, ...restCol } = enhancedCol;
return { return {
...restCol, ...restCol,
// slotName bodyCell 使
_slotName: slots.customRender, _slotName: slots.customRender,
...(props.enableEllipsis ? { ellipsis: true } : {}) ...(props.enableEllipsis ? { ellipsis: true } : {})
}; };
} }
// customRender // ellipsis customRender使 Tooltip
if (enhancedCol.customRender) { if (props.enableEllipsis && !enhancedCol.customRender) {
return { return {
...enhancedCol, ...enhancedCol,
...(props.enableEllipsis && !enhancedCol.ellipsis ? { ellipsis: true } : {}) ellipsis: true,
customRender: ({ text }: { text: any }) => {
// text
if (text === null || text === undefined || text === '') {
return props.emptyPlaceholder;
}
// 使 h Tooltip
return h(
'div',
{
style: {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}
},
h(
Tooltip,
{
title: String(text)
},
{
default: () => String(text)
}
)
);
}
}; };
} }
// ellipsis // customRender ellipsis
if (enhancedCol.customRender) {
return {
...enhancedCol,
...(props.enableEllipsis && !enhancedCol.ellipsis
? { ellipsis: true }
: {})
};
}
//
if (!props.enableEllipsis) return enhancedCol; if (!props.enableEllipsis) return enhancedCol;
return { return {
@ -633,7 +667,6 @@ const enhancedColumns = computed(() => {
}; };
}); });
}); });
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
tableScrollY.value = calcTableScrollY(tableContainerRef.value); tableScrollY.value = calcTableScrollY(tableContainerRef.value);
@ -681,7 +714,7 @@ watch(
// enableRowHighlight true // enableRowHighlight true
::v-deep(.ant-table-tbody > tr.row-clicked > td) { ::v-deep(.ant-table-tbody > tr.row-clicked > td) {
background-color: v-bind( background-color: v-bind(
'props.enableRowHighlight ? "#e6f7ff" : "transparent"' 'props.enableRowHighlight ? "#e6f7ff" : "#ffffff"'
) !important; ) !important;
} }

View File

@ -101,12 +101,14 @@ interface Props {
hycdList: any[]; hycdList: any[];
topHynmLoading: boolean; topHynmLoading: boolean;
hycdLoading: boolean; hycdLoading: boolean;
dvtpList: any[];
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
topHynmList: () => [], topHynmList: () => [],
hycdList: () => [], hycdList: () => [],
topHynmLoading: false, topHynmLoading: false,
hycdLoading: false hycdLoading: false,
dvtpList: () => []
}); });
const basicSearchRef = ref<any>(); const basicSearchRef = ref<any>();
@ -120,11 +122,7 @@ const jcdt = ref({
min: null, min: null,
max: null max: null
}); });
const dvtpList = ref<any[]>([
{ label: '堤坝式', value: '0' },
{ label: '引水式', value: '1' },
{ label: '混合式', value: '2' }
]);
const dvtp = ref([]); const dvtp = ref([]);
const initSearchData = { const initSearchData = {
rvcd: 'all', rvcd: 'all',
@ -134,7 +132,12 @@ const initSearchData = {
baseId: null, baseId: null,
hbrvcd: null, hbrvcd: null,
bldsttCcode: null, bldsttCcode: null,
dtin: 'all' dtin: 'all',
jcdt: {
min: null,
max: null
},
dvtp: []
}; };
const isHide = ref<boolean>(false); const isHide = ref<boolean>(false);
const searchData = ref<any>({ ...initSearchData }); const searchData = ref<any>({ ...initSearchData });
@ -260,11 +263,13 @@ const disabledEndDate = (current: Dayjs) => {
const onSearchFinish = (values: any) => { const onSearchFinish = (values: any) => {
values.ttpwr = ttpwr.value; values.ttpwr = ttpwr.value;
if (jcdt.value.min) if (jcdt.value?.min) {
values.jcdt.min = dayjs(jcdt.value.min).format('YYYY-MM-DD') + ' 00:00:00'; values.jcdt.min = dayjs(jcdt.value.min).format('YYYY-MM-DD') + ' 00:00:00';
if (jcdt.value.max) }
if (jcdt.value?.max) {
values.jcdt.max = dayjs(jcdt.value.max).format('YYYY-MM-DD') + ' 00:00:00'; values.jcdt.max = dayjs(jcdt.value.max).format('YYYY-MM-DD') + ' 00:00:00';
values.dvtp = dvtp.value; }
if (dvtp.value.length > 0) values.dvtp = dvtp.value;
emit('search-finish', { ...values }); emit('search-finish', { ...values });
}; };

View File

@ -1,5 +1,5 @@
<template> <template>
<!-- 第一步输入数据来源 --> <!-- 第一步输入修改依据 -->
<a-modal <a-modal
v-model:open="dataSourceVisible" v-model:open="dataSourceVisible"
title="删除电站" title="删除电站"
@ -8,12 +8,11 @@
@ok="handleDataSourceConfirm" @ok="handleDataSourceConfirm"
> >
<div> <div>
<p style="color: red; margin-bottom: 8px;"> <p style="color: red; margin-bottom: 8px">请输入修改依据以继续删除操作</p>
请输入数据来源以继续删除操作 <a-textarea
</p>
<a-input
v-model:value="dataSource" v-model:value="dataSource"
placeholder="请输入数据来源" placeholder="请输入修改依据"
:rows="4"
/> />
</div> </div>
</a-modal> </a-modal>
@ -28,11 +27,9 @@
@ok="handleFinalDelete" @ok="handleFinalDelete"
> >
<div> <div>
<p style="color: red; font-weight: bold;"> <p style="color: red; font-weight: bold">请慎重操作</p>
请慎重操作此操作不可恢复
</p>
<p>电站名称{{ deleteRecord?.stnm }}</p> <p>电站名称{{ deleteRecord?.stnm }}</p>
<p>数据来源{{ dataSource }}</p> <p>修改依据{{ dataSource || '无' }}</p>
<p>确定要删除该电站吗</p> <p>确定要删除该电站吗</p>
</div> </div>
</a-modal> </a-modal>
@ -59,12 +56,8 @@ const open = (record: any, callback: Function) => {
onSuccess.value = callback; onSuccess.value = callback;
}; };
// //
const handleDataSourceConfirm = () => { const handleDataSourceConfirm = () => {
if (!dataSource.value || dataSource.value.trim() === '') {
message.error('请输入数据来源');
return;
}
dataSourceVisible.value = false; dataSourceVisible.value = false;
confirmVisible.value = true; confirmVisible.value = true;
}; };
@ -72,8 +65,13 @@ const handleDataSourceConfirm = () => {
// //
const handleFinalDelete = async () => { const handleFinalDelete = async () => {
try { try {
const res = await deletePowerInfo({ stcd: deleteRecord.value.stcd }); const params = {
if (res?.code === 200 || res?.success) { ids: [deleteRecord.value.stcd],
source: dataSource.value
};
const res = await deletePowerInfo(params);
console.log(res);
if (res?.code == 0) {
message.success('删除成功'); message.success('删除成功');
confirmVisible.value = false; confirmVisible.value = false;
onSuccess.value(); onSuccess.value();

View File

@ -6,6 +6,7 @@
:hycdList="hycdList" :hycdList="hycdList"
:topHynmLoading="topHynmLoading" :topHynmLoading="topHynmLoading"
:hycdLoading="hycdLoading" :hycdLoading="hycdLoading"
:dvtpList="dvtpList"
@export-btn="exportBtn" @export-btn="exportBtn"
@custom-filter-btn="customFilterBtn" @custom-filter-btn="customFilterBtn"
@search-finish="onSearchFinish" @search-finish="onSearchFinish"
@ -16,9 +17,13 @@
<!-- 表格组件 --> <!-- 表格组件 -->
<BasicTable <BasicTable
ref="tableRef" ref="tableRef"
:enableEllipsis="true"
:scrollX="tableScrollX" :scrollX="tableScrollX"
:scrollY="tableScrollY" :scrollY="tableScrollY"
:columns="columns" :columns="columns"
:searchParams="{
sort: sort
}"
:list-url="getPowerTableList" :list-url="getPowerTableList"
> >
<template #action="{ record }"> <template #action="{ record }">
@ -51,6 +56,7 @@
<!-- 编辑电站 Modal --> <!-- 编辑电站 Modal -->
<EditPowerModal <EditPowerModal
v-model:open="editVisible" v-model:open="editVisible"
:dvtp-list="dvtpList"
:record="editRecord" :record="editRecord"
:top-hynm-list="topHynmList" :top-hynm-list="topHynmList"
:hycd-list="hycdList" :hycd-list="hycdList"
@ -75,12 +81,32 @@ import {
updatePowerInfo, updatePowerInfo,
deletePowerInfo deletePowerInfo
} from '@/api/DataQueryMenuModule'; } from '@/api/DataQueryMenuModule';
import { getEngInfoById } from '@/api/select';
import { calcTableScrollY } from '@/utils/index'; import { calcTableScrollY } from '@/utils/index';
import { useModelStore } from '@/store/modules/model'; import { useModelStore } from '@/store/modules/model';
import { BasicColumns } from '@/components/MapModal/column.config'; import { BasicColumns } from '@/components/MapModal/column.config';
const modelStore = useModelStore(); const modelStore = useModelStore();
const sort = ref<any>([
{
field: 'baseStepSort',
dir: 'asc'
},
{
field: 'rvcdStepSort',
dir: 'asc'
},
{
field: 'rstcdStepSort',
dir: 'asc'
},
{
field: 'ttpwr',
dir: 'asc'
}
]);
const tableRef = ref(); const tableRef = ref();
const searchRef = ref(); const searchRef = ref();
const tableScrollY = ref<string | number>(0); const tableScrollY = ref<string | number>(0);
@ -101,6 +127,11 @@ const hycdLoading = ref(false);
const isEdit = ref(true); const isEdit = ref(true);
const dvtpList = ref<any[]>([
{ label: '堤坝式', value: '0' },
{ label: '引水式', value: '1' },
{ label: '混合式', value: '2' }
]);
const columns = ref<any[]>([ const columns = ref<any[]>([
{ {
key: 'stnm', key: 'stnm',
@ -165,7 +196,7 @@ const columns = ref<any[]>([
title: '第一台机组投产时间', title: '第一台机组投产时间',
dataIndex: 'piodt', dataIndex: 'piodt',
visible: true, visible: true,
width: 150, width: 160,
sort: true, sort: true,
ellipsis: true, ellipsis: true,
customRender: ({ text }) => { customRender: ({ text }) => {
@ -221,8 +252,7 @@ const columns = ref<any[]>([
dataIndex: 'nrupar', dataIndex: 'nrupar',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dstcrvr', key: 'dstcrvr',
@ -230,26 +260,23 @@ const columns = ref<any[]>([
dataIndex: 'dstcrvr', dataIndex: 'dstcrvr',
visible: true, visible: true,
width: 150, width: 150,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avyrp', key: 'avyrp',
title: '多年平均降雨量(mm)', title: '多年平均降雨量(mm)',
dataIndex: 'avyrp', dataIndex: 'avyrp',
visible: true, visible: true,
width: 160, width: 170,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avw', key: 'avw',
title: '多年平均年径流量(亿m³)', title: '多年平均年径流量(亿m³)',
dataIndex: 'avw', dataIndex: 'avw',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq', key: 'avq',
@ -257,8 +284,7 @@ const columns = ref<any[]>([
dataIndex: 'avq', dataIndex: 'avq',
visible: true, visible: true,
width: 160, width: 160,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq01', key: 'avq01',
@ -266,8 +292,7 @@ const columns = ref<any[]>([
dataIndex: 'avq01', dataIndex: 'avq01',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq02', key: 'avq02',
@ -275,8 +300,7 @@ const columns = ref<any[]>([
dataIndex: 'avq02', dataIndex: 'avq02',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq03', key: 'avq03',
@ -284,8 +308,7 @@ const columns = ref<any[]>([
dataIndex: 'avq03', dataIndex: 'avq03',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq04', key: 'avq04',
@ -293,8 +316,7 @@ const columns = ref<any[]>([
dataIndex: 'avq04', dataIndex: 'avq04',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq05', key: 'avq05',
@ -302,8 +324,7 @@ const columns = ref<any[]>([
dataIndex: 'avq05', dataIndex: 'avq05',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq06', key: 'avq06',
@ -311,8 +332,7 @@ const columns = ref<any[]>([
dataIndex: 'avq06', dataIndex: 'avq06',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq07', key: 'avq07',
@ -320,8 +340,7 @@ const columns = ref<any[]>([
dataIndex: 'avq07', dataIndex: 'avq07',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq08', key: 'avq08',
@ -329,8 +348,7 @@ const columns = ref<any[]>([
dataIndex: 'avq08', dataIndex: 'avq08',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq09', key: 'avq09',
@ -338,35 +356,31 @@ const columns = ref<any[]>([
dataIndex: 'avq09', dataIndex: 'avq09',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq10', key: 'avq10',
title: '10月多年平均流量(m³/s)', title: '10月多年平均流量(m³/s)',
dataIndex: 'avq10', dataIndex: 'avq10',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq11', key: 'avq11',
title: '11月多年平均流量(m³/s)', title: '11月多年平均流量(m³/s)',
dataIndex: 'avq11', dataIndex: 'avq11',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avq12', key: 'avq12',
title: '12月多年平均流量(m³/s)', title: '12月多年平均流量(m³/s)',
dataIndex: 'avq12', dataIndex: 'avq12',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'obmxq', key: 'obmxq',
@ -374,8 +388,7 @@ const columns = ref<any[]>([
dataIndex: 'obmxq', dataIndex: 'obmxq',
visible: true, visible: true,
width: 170, width: 170,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'obmnq', key: 'obmnq',
@ -383,26 +396,23 @@ const columns = ref<any[]>([
dataIndex: 'obmnq', dataIndex: 'obmnq',
visible: true, visible: true,
width: 170, width: 170,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'hmxq', key: 'hmxq',
title: '调查历史最大流量(m³/s)', title: '调查历史最大流量(m³/s)',
dataIndex: 'hmxq', dataIndex: 'hmxq',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dsnfqfrq', key: 'dsnfqfrq',
title: '设计入库洪水流量(m³/s)', title: '设计入库洪水流量(m³/s)',
dataIndex: 'dsnfqfrq', dataIndex: 'dsnfqfrq',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dsrcin', key: 'dsrcin',
@ -410,17 +420,15 @@ const columns = ref<any[]>([
dataIndex: 'dsrcin', dataIndex: 'dsrcin',
visible: true, visible: true,
width: 160, width: 160,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ckfqfqr', key: 'ckfqfqr',
title: '校核入库洪水流量(m³/s)', title: '校核入库洪水流量(m³/s)',
dataIndex: 'ckfqfqr', dataIndex: 'ckfqfqr',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'chrcin', key: 'chrcin',
@ -428,61 +436,54 @@ const columns = ref<any[]>([
dataIndex: 'chrcin', dataIndex: 'chrcin',
visible: true, visible: true,
width: 160, width: 160,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'obmxw3', key: 'obmxw3',
title: '实测最大洪量(三天)(亿m³)', title: '实测最大洪量(三天)(亿m³)',
dataIndex: 'obmxw3', dataIndex: 'obmxw3',
visible: true, visible: true,
width: 200, width: 220,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dsw3', key: 'dsw3',
title: '设计洪量(三天)(亿m³)', title: '设计洪量(三天)(亿m³)',
dataIndex: 'dsw3', dataIndex: 'dsw3',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ckw3', key: 'ckw3',
title: '校核洪量(三天)(亿m³)', title: '校核洪量(三天)(亿m³)',
dataIndex: 'ckw3', dataIndex: 'ckw3',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'avsd', key: 'avsd',
title: '多年平均输沙量(万t)', title: '多年平均输沙量(万t)',
dataIndex: 'avsd', dataIndex: 'avsd',
visible: true, visible: true,
width: 170, width: 180
ellipsis: true
}, },
{ {
key: 'avs', key: 'avs',
title: '多年平均含沙量(kg/m³)', title: '多年平均含沙量(kg/m³)',
dataIndex: 'avs', dataIndex: 'avs',
visible: true, visible: true,
width: 170, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'obmxs', key: 'obmxs',
title: '实测最大含沙量(kg/m³)', title: '实测最大含沙量(kg/m³)',
dataIndex: 'obmxs', dataIndex: 'obmxs',
visible: true, visible: true,
width: 170, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ckflz', key: 'ckflz',
@ -490,8 +491,7 @@ const columns = ref<any[]>([
dataIndex: 'ckflz', dataIndex: 'ckflz',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dsflz', key: 'dsflz',
@ -499,8 +499,7 @@ const columns = ref<any[]>([
dataIndex: 'dsflz', dataIndex: 'dsflz',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'normz', key: 'normz',
@ -508,8 +507,7 @@ const columns = ref<any[]>([
dataIndex: 'normz', dataIndex: 'normz',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'uzfc', key: 'uzfc',
@ -517,8 +515,7 @@ const columns = ref<any[]>([
dataIndex: 'uzfc', dataIndex: 'uzfc',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'fsltdz', key: 'fsltdz',
@ -526,8 +523,7 @@ const columns = ref<any[]>([
dataIndex: 'fsltdz', dataIndex: 'fsltdz',
visible: true, visible: true,
width: 150, width: 150,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ydownz', key: 'ydownz',
@ -535,8 +531,7 @@ const columns = ref<any[]>([
dataIndex: 'ydownz', dataIndex: 'ydownz',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ddz', key: 'ddz',
@ -544,17 +539,15 @@ const columns = ref<any[]>([
dataIndex: 'ddz', dataIndex: 'ddz',
visible: true, visible: true,
width: 120, width: 120,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'nrzar', key: 'nrzar',
title: '正常蓄水位水库面积(km²)', title: '正常蓄水位水库面积(km²)',
dataIndex: 'nrzar', dataIndex: 'nrzar',
visible: true, visible: true,
width: 180, width: 200,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'bcklen', key: 'bcklen',
@ -562,8 +555,7 @@ const columns = ref<any[]>([
dataIndex: 'bcklen', dataIndex: 'bcklen',
visible: true, visible: true,
width: 130, width: 130,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ttcp', key: 'ttcp',
@ -571,17 +563,15 @@ const columns = ref<any[]>([
dataIndex: 'ttcp', dataIndex: 'ttcp',
visible: true, visible: true,
width: 130, width: 130,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'nmzcp', key: 'nmzcp',
title: '正常蓄水位以下库容(亿m³)', title: '正常蓄水位以下库容(亿m³)',
dataIndex: 'nmzcp', dataIndex: 'nmzcp',
visible: true, visible: true,
width: 190, width: 200,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'fldcpStr', key: 'fldcpStr',
@ -589,8 +579,7 @@ const columns = ref<any[]>([
dataIndex: 'fldcpStr', dataIndex: 'fldcpStr',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'actcp', key: 'actcp',
@ -598,8 +587,7 @@ const columns = ref<any[]>([
dataIndex: 'actcp', dataIndex: 'actcp',
visible: true, visible: true,
width: 140, width: 140,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ddcp', key: 'ddcp',
@ -607,8 +595,7 @@ const columns = ref<any[]>([
dataIndex: 'ddcp', dataIndex: 'ddcp',
visible: true, visible: true,
width: 130, width: 130,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'cpsc', key: 'cpsc',
@ -616,8 +603,7 @@ const columns = ref<any[]>([
dataIndex: 'cpsc', dataIndex: 'cpsc',
visible: true, visible: true,
width: 120, width: 120,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'rgcpName', key: 'rgcpName',
@ -634,17 +620,15 @@ const columns = ref<any[]>([
dataIndex: 'dsflzmxq', dataIndex: 'dsflzmxq',
visible: true, visible: true,
width: 250, width: 250,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dsflzxyz', key: 'dsflzxyz',
title: '设计洪水位时最大下泄流量相应下游水位(m)', title: '设计洪水位时最大下泄流量相应下游水位(m)',
dataIndex: 'dsflzxyz', dataIndex: 'dsflzxyz',
visible: true, visible: true,
width: 300, width: 320,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ckflzmxq', key: 'ckflzmxq',
@ -652,17 +636,15 @@ const columns = ref<any[]>([
dataIndex: 'ckflzmxq', dataIndex: 'ckflzmxq',
visible: true, visible: true,
width: 250, width: 250,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ckflzxyz', key: 'ckflzxyz',
title: '校核洪水位时最大下泄流量相应下游水位(m)', title: '校核洪水位时最大下泄流量相应下游水位(m)',
dataIndex: 'ckflzxyz', dataIndex: 'ckflzxyz',
visible: true, visible: true,
width: 300, width: 320,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ksqadjq', key: 'ksqadjq',
@ -670,8 +652,7 @@ const columns = ref<any[]>([
dataIndex: 'ksqadjq', dataIndex: 'ksqadjq',
visible: true, visible: true,
width: 170, width: 170,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ksqxyz', key: 'ksqxyz',
@ -679,17 +660,15 @@ const columns = ref<any[]>([
dataIndex: 'ksqxyz', dataIndex: 'ksqxyz',
visible: true, visible: true,
width: 250, width: 250,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'gemaxrq', key: 'gemaxrq',
title: '发电最大引用流量(m³/s)', title: '发电最大引用流量(m³/s)',
dataIndex: 'gemaxrq', dataIndex: 'gemaxrq',
visible: true, visible: true,
width: 180, width: 190,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'mxgeqxyz', key: 'mxgeqxyz',
@ -697,8 +676,7 @@ const columns = ref<any[]>([
dataIndex: 'mxgeqxyz', dataIndex: 'mxgeqxyz',
visible: true, visible: true,
width: 260, width: 260,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ttpwr', key: 'ttpwr',
@ -742,8 +720,7 @@ const columns = ref<any[]>([
dataIndex: 'yrge', dataIndex: 'yrge',
visible: true, visible: true,
width: 200, width: 200,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'ushr', key: 'ushr',
@ -751,15 +728,14 @@ const columns = ref<any[]>([
dataIndex: 'ushr', dataIndex: 'ushr',
visible: true, visible: true,
width: 150, width: 150,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'k', key: 'k',
title: '机组综合出力系数', title: '机组综合出力系数',
dataIndex: 'k', dataIndex: 'k',
visible: true, visible: true,
width: 140, width: 150,
sort: true, sort: true,
ellipsis: true ellipsis: true
}, },
@ -778,8 +754,7 @@ const columns = ref<any[]>([
dataIndex: 'dmcrel', dataIndex: 'dmcrel',
visible: true, visible: true,
width: 130, width: 130,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'mxdmhg', key: 'mxdmhg',
@ -787,8 +762,7 @@ const columns = ref<any[]>([
dataIndex: 'mxdmhg', dataIndex: 'mxdmhg',
visible: true, visible: true,
width: 120, width: 120,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dmlen', key: 'dmlen',
@ -796,8 +770,7 @@ const columns = ref<any[]>([
dataIndex: 'dmlen', dataIndex: 'dmlen',
visible: true, visible: true,
width: 130, width: 130,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'sgyge', key: 'sgyge',
@ -805,8 +778,7 @@ const columns = ref<any[]>([
dataIndex: 'sgyge', dataIndex: 'sgyge',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'unyge', key: 'unyge',
@ -814,8 +786,7 @@ const columns = ref<any[]>([
dataIndex: 'unyge', dataIndex: 'unyge',
visible: true, visible: true,
width: 180, width: 180,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'gap', key: 'gap',
@ -823,8 +794,7 @@ const columns = ref<any[]>([
dataIndex: 'gap', dataIndex: 'gap',
visible: true, visible: true,
width: 120, width: 120,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dvtpName', key: 'dvtpName',
@ -832,8 +802,7 @@ const columns = ref<any[]>([
dataIndex: 'dvtpName', dataIndex: 'dvtpName',
visible: true, visible: true,
width: 120, width: 120,
sort: true, sort: true
ellipsis: true
}, },
{ {
key: 'dtinName', key: 'dtinName',
@ -926,8 +895,8 @@ const buildSearchParams = (values: any) => {
values.rstcd values.rstcd
? { ? {
field: 'rstcd', field: 'stcd',
operator: 'contains', operator: 'eq',
dataType: 'string', dataType: 'string',
value: values.rstcd value: values.rstcd
} }
@ -1059,7 +1028,10 @@ const handleDetail = (record: any) => {
}; };
// //
const handleEdit = (record: any) => { const handleEdit = (record: any) => {
editRecord.value = { ...record }; getEngInfoById({ stcd: record.stcd }).then(res => {
console.log(res);
editRecord.value = { ...res.data };
});
editVisible.value = true; editVisible.value = true;
}; };

View File

@ -203,7 +203,7 @@ const initCrossSectionList = params => {
const onValuesChange = (changedValues: any, allValues: any) => { const onValuesChange = (changedValues: any, allValues: any) => {
// //
if (changedValues.rvcd || changedValues.rstcd !== undefined) { if ('rvcd' in changedValues || 'rstcd' in changedValues) {
allValues.stcd = null; allValues.stcd = null;
if (basicSearchRef.value?.formData) { if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null; basicSearchRef.value.formData.stcd = null;

View File

@ -226,7 +226,7 @@ const initCrossSectionList = params => {
const onValuesChange = (changedValues: any, allValues: any) => { const onValuesChange = (changedValues: any, allValues: any) => {
// //
if (changedValues.rvcd || changedValues.rstcd !== undefined) { if ('rvcd' in changedValues || 'rstcd' in changedValues) {
allValues.stcd = null; allValues.stcd = null;
if (basicSearchRef.value?.formData) { if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null; basicSearchRef.value.formData.stcd = null;

View File

@ -226,7 +226,7 @@ const initCrossSectionList = params => {
const onValuesChange = (changedValues: any, allValues: any) => { const onValuesChange = (changedValues: any, allValues: any) => {
// //
if (changedValues.rvcd || changedValues.rstcd !== undefined) { if ('rvcd' in changedValues || 'rstcd' in changedValues) {
allValues.stcd = null; allValues.stcd = null;
if (basicSearchRef.value?.formData) { if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null; basicSearchRef.value.formData.stcd = null;

View File

@ -232,7 +232,7 @@ const initCrossSectionList = params => {
const onValuesChange = (changedValues: any, allValues: any) => { const onValuesChange = (changedValues: any, allValues: any) => {
// //
if (changedValues.rvcd || changedValues.rstcd !== undefined) { if ('rvcd' in changedValues || 'rstcd' in changedValues) {
allValues.stcd = null; allValues.stcd = null;
if (basicSearchRef.value?.formData) { if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null; basicSearchRef.value.formData.stcd = null;

View File

@ -248,7 +248,7 @@ const initCrossSectionList = params => {
const onValuesChange = (changedValues: any, allValues: any) => { const onValuesChange = (changedValues: any, allValues: any) => {
// //
if (changedValues.rvcd || changedValues.rstcd !== undefined) { if ('rvcd' in changedValues || 'rstcd' in changedValues) {
allValues.stcd = null; allValues.stcd = null;
if (basicSearchRef.value?.formData) { if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null; basicSearchRef.value.formData.stcd = null;

View File

@ -1,5 +1,6 @@
<template> <template>
<div class="conventionalHydropower-page"> <div class="conventionalHydropower-page">
<!-- 1. 排序 -->
<a-tabs v-model:activeKey="activeTab" class="conventionalHydropower-tabs"> <a-tabs v-model:activeKey="activeTab" class="conventionalHydropower-tabs">
<a-tab-pane tab="电站信息" key="BasicData"> <a-tab-pane tab="电站信息" key="BasicData">
<BasicData /> <BasicData />

View File

@ -0,0 +1,225 @@
import Excel from 'exceljs';
import FileSaver from 'file-saver';
const exportExcel = function (univerData, fileName = 'data') {
// 参数为Univer工作簿数据对象
const workbook = new Excel.Workbook();
// 遍历工作簿中的所有工作表
const sheetOrder = univerData.sheetOrder || [];
sheetOrder.forEach(sheetId => {
const sheet = univerData.sheets[sheetId];
if (!sheet || !sheet.cellData) return;
const worksheet = workbook.addWorksheet(sheet.name || 'Sheet1');
// 处理单元格数据
setCellsData(sheet.cellData, worksheet, univerData.styles || {});
// 设置合并单元格
if (sheet.mergeData) {
setMerge(sheet.mergeData, worksheet);
}
// 设置行高
if (sheet.rowData) {
setRowHeight(sheet.rowData, worksheet);
}
// 设置列宽
if (sheet.columnData) {
setColumnWidth(sheet.columnData, worksheet);
}
// 设置冻结行列
if (sheet.freeze) {
setFreeze(sheet.freeze, worksheet);
}
});
// 写入 buffer
const buffer = workbook.xlsx.writeBuffer().then(data => {
const blob = new Blob([data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
});
console.log('导出成功!');
FileSaver.saveAs(blob, `${fileName}.xlsx`);
});
return buffer;
};
// 设置单元格数据
var setCellsData = function (cellData, worksheet, styles = {}) {
for (let row in cellData) {
const rowData = cellData[row];
for (let col in rowData) {
const cell = rowData[col];
if (!cell) continue;
const excelRow = parseInt(row) + 1;
const excelCol = parseInt(col) + 1;
const targetCell = worksheet.getCell(excelRow, excelCol);
// 设置值
if (cell.f) {
// 如果是公式
targetCell.value = { formula: cell.f, result: cell.v };
} else if (cell.v !== undefined) {
// 如果是普通值
targetCell.value = cell.v;
}
// 如果有样式ID应用样式
if (cell.s && styles[cell.s]) {
const cellStyle = styles[cell.s];
applyCellStyle(targetCell, cellStyle);
}
}
}
};
// 应用单元格样式
var applyCellStyle = function (targetCell, cellStyle) {
// 应用字体样式
if (cellStyle.ff) {
targetCell.font = targetCell.font || {};
targetCell.font.name = cellStyle.ff;
}
if (cellStyle.fs) {
targetCell.font = targetCell.font || {};
targetCell.font.size = cellStyle.fs;
}
if (cellStyle.bl === 1) {
targetCell.font = targetCell.font || {};
targetCell.font.bold = true;
}
if (cellStyle.it === 1) {
targetCell.font = targetCell.font || {};
targetCell.font.italic = true;
}
// 应用背景色
if (cellStyle.bg && cellStyle.bg.rgb) {
targetCell.fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: cellStyle.bg.rgb.replace('#', '') }
};
}
// 应用字体颜色
if (cellStyle.cl && cellStyle.cl.rgb) {
targetCell.font = targetCell.font || {};
targetCell.font.color = { argb: cellStyle.cl.rgb.replace('#', '') };
}
// 应用水平对齐
if (cellStyle.ht !== undefined) {
targetCell.alignment = targetCell.alignment || {};
if (cellStyle.ht === 1) targetCell.alignment.horizontal = 'left';
else if (cellStyle.ht === 2) targetCell.alignment.horizontal = 'center';
else if (cellStyle.ht === 3) targetCell.alignment.horizontal = 'right';
}
// 应用垂直对齐
if (cellStyle.vt !== undefined) {
targetCell.alignment = targetCell.alignment || {};
if (cellStyle.vt === 1) targetCell.alignment.vertical = 'top';
else if (cellStyle.vt === 2) targetCell.alignment.vertical = 'middle';
else if (cellStyle.vt === 3) targetCell.alignment.vertical = 'bottom';
}
// 应用文本换行
if (cellStyle.tb !== undefined) {
targetCell.alignment = targetCell.alignment || {};
targetCell.alignment.wrapText = cellStyle.tb === 1;
}
// 应用文本旋转
if (cellStyle.tr !== undefined) {
targetCell.alignment = targetCell.alignment || {};
targetCell.alignment.textRotation = cellStyle.tr;
}
// 应用边框(如果有的话)
if (cellStyle.bd) {
// 这里可以处理边框样式
// 具体实现根据实际边框数据结构
}
};
// 设置合并单元格
var setMerge = function (mergeData = [], worksheet) {
mergeData.forEach(function (merge) {
worksheet.mergeCells(
merge.startRow + 1, // Excel行号从1开始
merge.startColumn + 1, // Excel列号从1开始
merge.endRow + 1,
merge.endColumn + 1
);
});
};
// 设置行高
var setRowHeight = function (rowData = {}, worksheet) {
for (let rowIndex in rowData) {
const rowInfo = rowData[rowIndex];
if (rowInfo.h) {
const excelRowNum = parseInt(rowIndex) + 1;
// 转换像素到Excel行高单位 (1像素 ≈ 0.75 Excel行高单位)
const excelHeight = rowInfo.h * 0.75;
worksheet.getRow(excelRowNum).height = excelHeight;
}
}
};
// 设置列宽
var setColumnWidth = function (columnData = {}, worksheet) {
for (let colIndex in columnData) {
const colInfo = columnData[colIndex];
if (colInfo.w) {
const excelColNum = parseInt(colIndex) + 1;
// 转换像素到Excel列宽单位 (1像素 ≈ 0.14 Excel列宽单位粗略估算)
const excelWidth = colInfo.w * 0.14;
worksheet.getColumn(excelColNum).width = excelWidth;
}
}
};
// 设置冻结行列
var setFreeze = function (freeze, worksheet) {
if (freeze.startRow > 0 || freeze.startColumn > 0) {
// Excel中冻结窗格通过视图设置
worksheet.views = [
{
state: 'frozen',
xSplit: freeze.xSplit || freeze.startColumn,
ySplit: freeze.ySplit || freeze.startRow,
topLeftCell: `${getExcelColumnName(freeze.startColumn + 1)}${freeze.startRow + 1}`
}
];
}
};
// 将数字转换为Excel列名 (A, B, ..., Z, AA, AB, ...)
function getExcelColumnName(colNumber) {
let columnName = '';
let num = colNumber;
while (num > 0) {
num--;
const remainder = num % 26;
columnName = String.fromCharCode(65 + remainder) + columnName;
num = Math.floor(num / 26);
}
return columnName || 'A';
}
export {
exportExcel
};

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,381 @@
<template> <template>
<div> <div class="shuiWenShuJuFenXi-page">
<h2>水温数据分析</h2> <BasicSearch
ref="basicSearchRef"
:searchList="searchList"
:initial-values="initSearchData"
:zhujianfujian="'fu'"
@reset="handleReset"
@finish="onSearchFinish"
@values-change="onValuesChange"
>
<template #actions>
<a-button :loading="exportLoading" @click="exportBtn">导出</a-button>
<a-button @click="saveBtn">保存</a-button>
</template>
</BasicSearch>
<a-spin :spinning="loading">
<div
ref="containerRef"
id="x-spreadsheet-demo"
style="width: 100%; height: calc(100vh - 220px)"
></div>
</a-spin>
</div> </div>
</template> </template>
<script setup lang="ts">
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { message } from 'ant-design-vue';
import {
getSurfaceTempAnalysisList,
getSurfaceTempAnalysisExcel,
saveSurfaceTempAnalysisExcel
} from '@/api/DataQueryMenuModule';
import BasicSearch from '@/components/BasicSearch/index.vue';
import '@univerjs/preset-sheets-core/lib/index.css';
import { exportExcel } from './components/export';
import { createExcelInstance, renderDataToExcel } from './components/utils';
import dayjs from 'dayjs';
const basicSearchRef = ref();
const stcdData = ref([]);
const stcdLoading = ref(false);
const originalData = ref([]);
const initSearchData = {
rvcd: 'all',
rstcd: null,
stcd: '008660306300000079',
dt: dayjs().startOf('year').format('YYYY-MM-DD HH:mm:ss')
};
const searchFinishInfo = ref({});
//
const loading = ref(false);
const exportLoading = ref(false);
const saveLoading = ref(false);
// ref
const containerRef = ref();
const univerInstanceRef = ref();
const searchList: any = computed(() => [
{
type: 'waterStation',
name: 'rvcd',
label: '流域',
placeholder: '请输入流域',
fieldProps: {
allowClear: true
},
options: []
},
{
type: 'Select',
name: 'stcd',
label: '断面',
width: 160,
fieldProps: {
allowClear: false
},
loading: stcdLoading.value,
options: stcdData.value
},
{
type: 'DataPicker',
name: 'dt',
label: '时间',
width: 100,
picker: 'year',
fieldProps: {
format: 'YYYY',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
allowClear: false
}
}
]);
//
const exportBtn = () => {
exportLoading.value = true;
const { univer, univerAPI } = univerInstanceRef.value;
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
const snapshot = fWorkbook.save();
const titleRange = fWorksheet.getRange('A1');
exportExcel(snapshot, titleRange.getValue() || ' 水温站xxxx年监测数据');
setTimeout(() => {
message.success('导出成功');
exportLoading.value = false;
}, 500);
};
//
const saveBtn = async () => {
saveLoading.value = true;
if (univerInstanceRef.value) {
const { univerAPI } = univerInstanceRef.value;
const workbook = univerAPI.getActiveWorkbook();
const activeSheet = workbook.getActiveSheet();
//
const maxRow = activeSheet.getMaxRows();
const maxCol = activeSheet.getMaxColumns();
//
const currentData = [];
for (let row = 0; row < maxRow; row++) {
const rowData = [];
for (let col = 0; col < maxCol; col++) {
const cellValue = activeSheet.getRange(row, col).getValue();
rowData.push(cellValue);
}
currentData.push(rowData);
}
//
const resultData = [];
//
let year = '2025'; //
if (originalData.value && originalData.value.length > 0) {
year = originalData.value[0].dt.split('-')[0]; //
}
// (utils.tsxinitializeExcelWorksheet)
for (let month = 1; month <= 12; month++) {
const monthRow = (month - 1) * 2 + 3; //
const dataRow = monthRow + 1; //
if (dataRow >= maxRow) break; //
//
const monthValue = currentData[monthRow - 1][0]; // A0monthRow11
// "1"
let monthNum = null;
if (typeof monthValue === 'string' && monthValue.endsWith('月')) {
monthNum = parseInt(monthValue.replace('月', ''));
} else if (typeof monthValue === 'number') {
monthNum = monthValue;
}
if (monthNum !== null && monthNum >= 1 && monthNum <= 12) {
const monthStr = monthNum.toString().padStart(2, '0'); //
// (C2utils.tsx)
for (let day = 1; day <= 31; day++) {
const dayCol = day + 1; // day=1C(2)
if (dayCol >= maxCol) break; //
// monthRowwtdataRow
const wtValue = currentData[monthRow - 1][dayCol]; // wtmonthRow11
// wt
if (wtValue !== undefined && wtValue !== null && wtValue !== '') {
// 使wt使Excel
const newDataItem = {
dt: `${year}-${monthStr}-${day.toString().padStart(2, '0')}`, //
wt: wtValue, // 使Excelwt
stcd: originalData.value[0]?.stcd || '' // 使
};
resultData.push(newDataItem);
}
}
}
}
//
resultData.sort(
(a, b) => new Date(a.dt).getTime() - new Date(b.dt).getTime()
);
if (resultData.length > 0) {
let res = await saveSurfaceTempAnalysisExcel(resultData);
if (res.code == 0) {
message.success('保存成功');
} else {
message.error(res.data.msg);
}
saveLoading.value = false;
} else {
message.warning(`保存失败,数据为空`);
saveLoading.value = false;
}
}
};
//
const handleReset = (values: any) => {
initData(initSearchData);
};
//
const onSearchFinish = (values: any) => {
searchFinishInfo.value = values;
if (values.stcd == '' || values.stcd == null) {
message.warning('请选择断面');
return;
}
initData(values);
};
//
const onValuesChange = (changedValues: any, allValues: any) => {
if ('rvcd' in changedValues || 'rstcd' in changedValues) {
if (basicSearchRef.value?.formData) {
basicSearchRef.value.formData.stcd = null;
}
initStcd(allValues);
}
};
//
const initStcd = (values: any) => {
stcdLoading.value = true;
setTimeout(() => {
stcdLoading.value = false;
const params = {
filter: {
logic: 'and',
filters: [
values.rvcd &&
values.rvcd !== 'all' && {
field: 'rvcd',
operator: 'eq',
dataType: 'string',
value: values.rvcd
},
values.rstcd && {
field: 'rstcd',
operator: 'eq',
dataType: 'string',
value: values.rstcd
},
{
field: 'sttpFullPath',
operator: 'contains',
dataType: 'string',
value: 'ENV,ENVM,WT,WTRV'
}
].filter(Boolean)
},
select: ['stcd', 'stnm', 'wtDeviceType', 'dtinType', 'mway']
};
getSurfaceTempAnalysisList(params).then(res => {
stcdData.value = res.data?.data?.map(item => ({
label: item.stnm,
value: item.stcd
}));
stcdLoading.value = false;
});
}, 1000);
};
//
const initData = async (values: any) => {
loading.value = true;
const params = {
filter: {
logic: 'and',
filters: [
{
field: 'stcd',
operator: 'eq',
dataType: 'string',
value: values.stcd
},
{
field: 'dt',
operator: 'gte',
dataType: 'date',
value: dayjs(values.dt).startOf('year').format('YYYY-MM-DD HH:mm:ss')
},
{
field: 'dt',
operator: 'lte',
dataType: 'date',
value: dayjs(values.dt).endOf('year').format('YYYY-MM-DD HH:mm:ss')
}
]
},
sort: [
{
field: 'baseStepSort',
dir: 'asc'
},
{
field: 'rvcd',
dir: 'asc'
},
{
field: 'rstcdStepSort',
dir: 'asc'
},
{
field: 'stnm',
dir: 'asc'
},
{
field: 'dt',
dir: 'desc'
}
],
skip: 0,
take: 1000
};
getSurfaceTempAnalysisExcel(params).then(res => {
if (!univerInstanceRef.value) {
console.error('Univer 实例尚未初始化,请稍后再试');
loading.value = false;
return;
}
originalData.value = res.data?.data;
const label =
stcdData.value.find(item => item.value === values.stcd)?.label || '';
const year = dayjs(values.dt).year();
const { univerAPI } = univerInstanceRef.value;
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();
// 1AAEA1:AE1
const titleRange = fWorksheet.getRange('A1');
if (titleRange) {
titleRange.setValue(`${label}${year}年监测数据`);
}
if (res.data.data.length == 0) {
message.warning(`当前${label}${year}年暂无数据`);
loading.value = false;
}
univerAPI.year = year;
for (let i = 0; i < res.data.data.length; i++) {
res.data.data[i].wt = Number(res.data.data[i].wt).toFixed(1);
}
renderDataToExcel(res.data.data, univerAPI, year, loading);
loading.value = false;
});
};
onMounted(() => {
// Excel
const { univer, univerAPI } = createExcelInstance(containerRef.value);
// univer ref
univerInstanceRef.value = { univer, univerAPI };
initStcd(initSearchData);
initData(initSearchData);
});
onUnmounted(() => {
// Excel
const { univer, univerAPI } = univerInstanceRef.value;
univerAPI.dispose();
});
</script>
<style scoped lang="scss">
.shuiWenShuJuFenXi-page {
position: relative;
z-index: 900;
pointer-events: all;
width: 100%;
height: 100%;
background-color: #ffffff;
box-sizing: border-box;
overflow: hidden;
padding: 20px;
}
</style>