生态流量接口校准和表格组件排序方式的更改

This commit is contained in:
王兴凯 2026-06-22 10:00:26 +08:00
parent 19d16a962b
commit 8fba065bc4
13 changed files with 419 additions and 504 deletions

View File

@ -34,7 +34,7 @@ export function evnmAutoMonitorGetKendoListCust(queryParams: any) {
//获取电站 //获取电站
export function vmsstbprptGetKendoList(queryParams: any) { export function vmsstbprptGetKendoList(queryParams: any) {
return request({ return request({
url: '/eq/vmsstbprpt/GetKendoList', url: '/eq/base/vmsstbprpt/GetKendoList',
method: 'post', method: 'post',
data: queryParams data: queryParams
}); });
@ -58,7 +58,7 @@ export function intervalGetKendoListCust(queryParams: any) {
// 获取生态流量达标率按性能 // 获取生态流量达标率按性能
export function eqGetKendoListCust(queryParams: any) { export function eqGetKendoListCust(queryParams: any) {
return request({ return request({
url: '/api/wmp-eng-server/eng/to/eq/GetKendoListCust', url: '/eq/to/eq/GetKendoListCust',
method: 'post', method: 'post',
data: queryParams data: queryParams
}); });
@ -82,7 +82,7 @@ export function wbsbGetKendoList(queryParams: any) {
//生态流量泄放方式 //生态流量泄放方式
export function msstbprptGetKendoList(queryParams: any) { export function msstbprptGetKendoList(queryParams: any) {
return request({ return request({
url: '/eq/msstbprpt/GetKendoList', url: '/eq/base/msstbprpt/GetKendoList',
method: 'post', method: 'post',
data: queryParams data: queryParams
}); });
@ -90,7 +90,7 @@ export function msstbprptGetKendoList(queryParams: any) {
//根据流域获取电站 //根据流域获取电站
export function qgcgetEngLimit(queryParams: any) { export function qgcgetEngLimit(queryParams: any) {
return request({ return request({
url: '/api/wmp-eng-server/eng/engalong/statistics/qgc/getEngLimit', url: '/eq/engalong/statistics/qgc/getEngLimit',
method: 'post', method: 'post',
data: queryParams data: queryParams
}); });

View File

@ -101,6 +101,12 @@ const lastFilter = ref<Record<string, any> | undefined>(undefined);
const tableContainerRef = ref<any>(null); const tableContainerRef = ref<any>(null);
const tableScrollY = ref<number>(0); // const tableScrollY = ref<number>(0); //
// --- ---
const internalSort = ref<{
field: string;
order: 'ascend' | 'descend' | null;
}>({ field: '', order: null });
// --- Computed Scroll Config --- // --- Computed Scroll Config ---
const scrollConfig = computed(() => { const scrollConfig = computed(() => {
const config: any = { const config: any = {
@ -177,10 +183,23 @@ const getList = async (filter?: Record<string, any>) => {
if (filter !== undefined) { if (filter !== undefined) {
lastFilter.value = filter; lastFilter.value = filter;
} }
console.log(props.searchParams);
try { try {
// 使使 searchParams
let sort = undefined;
if (internalSort.value.field && internalSort.value.order) {
sort = [
{
field: internalSort.value.field,
dir: internalSort.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else if (props.searchParams?.sort) {
sort = props.searchParams.sort;
}
const params = { const params = {
...props.searchParams, ...props.searchParams,
...(sort !== undefined ? { sort } : {}),
skip: page.value, skip: page.value,
take: size.value, take: size.value,
filter: lastFilter.value filter: lastFilter.value
@ -219,14 +238,17 @@ const getList = async (filter?: Record<string, any>) => {
const handleTableChange = (pag: any, filters: any, sorter: any) => { const handleTableChange = (pag: any, filters: any, sorter: any) => {
page.value = pag.current; page.value = pag.current;
size.value = pag.pageSize; size.value = pag.pageSize;
if (props.enableSort) {
if (sorter && sorter.field) { if (sorter && sorter.field) {
internalSort.value = { field: sorter.field, order: sorter.order };
page.value = 1; //
getList();
emit('sort-change', { field: sorter.field, order: sorter.order }); emit('sort-change', { field: sorter.field, order: sorter.order });
} else { } else {
emit('sort-change', { field: '', order: null }); //
} internalSort.value = { field: '', order: null };
} else { page.value = 1;
getList(); getList();
emit('sort-change', { field: '', order: null });
} }
}; };
const handleRowClick = (record: any) => { const handleRowClick = (record: any) => {
@ -264,6 +286,9 @@ defineExpose({
refresh, refresh,
tableData, tableData,
clearSelection, clearSelection,
clearSort: () => {
internalSort.value = { field: '', order: null };
},
getSelected: () => ({ getSelected: () => ({
keys: selectedRowKeys.value, keys: selectedRowKeys.value,
rows: selectedRows.value rows: selectedRows.value
@ -351,19 +376,28 @@ const createMergeCellHandler = (dataIndex: string) => {
}; };
}; };
// --- + Tooltip + + --- // --- + Tooltip + + + ---
const enhancedColumns = computed(() => { const enhancedColumns = computed(() => {
return props.columns.map(col => { return props.columns.map(col => {
const enhancedCol: any = { ...col };
// sort sorter: true sorter sortOrder
const isSortable = enhancedCol.sort === true || enhancedCol.sorter === true;
if (isSortable) {
enhancedCol.sorter = true;
enhancedCol.sortOrder =
internalSort.value.field === enhancedCol.dataIndex
? internalSort.value.order
: false;
}
// merge // merge
if (col.merge && col.dataIndex) { if (enhancedCol.merge && enhancedCol.dataIndex) {
const baseCol = { enhancedCol.customCell = createMergeCellHandler(enhancedCol.dataIndex);
...col,
customCell: createMergeCellHandler(col.dataIndex)
};
// slots.customRender slots // slots.customRender slots
if (baseCol.slots?.customRender) { if (enhancedCol.slots?.customRender) {
const { slots, ...restCol } = baseCol; const { slots, ...restCol } = enhancedCol;
return { return {
...restCol, ...restCol,
_slotName: slots.customRender, _slotName: slots.customRender,
@ -371,12 +405,12 @@ const enhancedColumns = computed(() => {
}; };
} }
return baseCol; return enhancedCol;
} }
// slots.customRender slots bodyCell dataIndex // slots.customRender slots bodyCell dataIndex
if (col.slots?.customRender) { if (enhancedCol.slots?.customRender) {
const { slots, ...restCol } = col; const { slots, ...restCol } = enhancedCol;
return { return {
...restCol, ...restCol,
// slotName bodyCell 使 // slotName bodyCell 使
@ -386,18 +420,18 @@ const enhancedColumns = computed(() => {
} }
// customRender // customRender
if (col.customRender) { if (enhancedCol.customRender) {
return { return {
...col, ...enhancedCol,
...(props.enableEllipsis && !col.ellipsis ? { ellipsis: true } : {}) ...(props.enableEllipsis && !enhancedCol.ellipsis ? { ellipsis: true } : {})
}; };
} }
// ellipsis // ellipsis
if (!props.enableEllipsis) return col; if (!props.enableEllipsis) return enhancedCol;
return { return {
...col, ...enhancedCol,
ellipsis: true ellipsis: true
}; };
}); });

View File

@ -8,7 +8,6 @@
:columns="currentColumns" :columns="currentColumns"
:list-url="fetchTableData" :list-url="fetchTableData"
:search-params="searchParams" :search-params="searchParams"
:enable-sort="true"
/> />
</div> </div>
</a-tab-pane> </a-tab-pane>

View File

@ -55,8 +55,6 @@
:list-url="sdFprdRGetKendoListCust" :list-url="sdFprdRGetKendoListCust"
:search-params="tableSearchParams" :search-params="tableSearchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #fid="{ column, record }"> <template #fid="{ column, record }">
<a-button <a-button
@ -108,13 +106,6 @@ const searchForm = reactive({
name: undefined, name: undefined,
year: props.currentYear ? dayjs().year(parseInt(props.currentYear)) : dayjs() year: props.currentYear ? dayjs().year(parseInt(props.currentYear)) : dayjs()
}); });
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: 'tm',
order: 'descend'
});
// //
const deviceOptions = ref<any[]>([]); const deviceOptions = ref<any[]>([]);
// //
@ -234,7 +225,7 @@ const columns = [
key: 'tm', key: 'tm',
dataIndex: 'tm', dataIndex: 'tm',
width: '120px', width: '120px',
sorter: true, // sort: true, //
customRender: ({ text }: any) => { customRender: ({ text }: any) => {
if (!text) return '-'; if (!text) return '-';
return dayjs(text).format('YYYY'); return dayjs(text).format('YYYY');
@ -269,16 +260,7 @@ const columns = [
// //
const tableSearchParams = computed(() => { const tableSearchParams = computed(() => {
const baseSort = const baseSort =[]
sortInfo.value.field && sortInfo.value.order
? [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
]
: [];
return { return {
sort: baseSort, sort: baseSort,
group: [], group: [],
@ -287,19 +269,6 @@ const tableSearchParams = computed(() => {
}; };
}); });
//
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
// DOM
nextTick(() => {
handleSearch();
});
};
// //
const customTransform = (res: any) => { const customTransform = (res: any) => {

View File

@ -58,10 +58,8 @@
:scroll-y="400" :scroll-y="400"
:columns="columns" :columns="columns"
:list-url="fpVmsstbprptGetKendoList" :list-url="fpVmsstbprptGetKendoList"
:enable-sort="true"
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
@sort-change="handleSortChange"
> >
<template #ennm="{ record }"> <template #ennm="{ record }">
<a @click="handleViewDetail(record, 'dz')" class="text-link"> <a @click="handleViewDetail(record, 'dz')" class="text-link">
@ -151,7 +149,7 @@ const columns = [
title: '设施名称', title: '设施名称',
dataIndex: 'stnm', dataIndex: 'stnm',
width: 200, width: 200,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -159,7 +157,7 @@ const columns = [
title: '所在基地名称', title: '所在基地名称',
dataIndex: 'baseName', dataIndex: 'baseName',
width: 150, width: 150,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -167,7 +165,7 @@ const columns = [
title: '所属电站名称', title: '所属电站名称',
dataIndex: 'ennm', dataIndex: 'ennm',
width: 150, width: 150,
sorter: true, sort: true,
ellipsis: true, ellipsis: true,
slots: { customRender: 'ennm' } slots: { customRender: 'ennm' }
}, },
@ -176,7 +174,7 @@ const columns = [
title: '开工日期', title: '开工日期',
dataIndex: 'ststdt', dataIndex: 'ststdt',
width: 120, width: 120,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -184,7 +182,7 @@ const columns = [
title: '建成日期', title: '建成日期',
dataIndex: 'jcdt', dataIndex: 'jcdt',
width: 120, width: 120,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -192,7 +190,7 @@ const columns = [
title: '建设状态', title: '建设状态',
dataIndex: 'bldsttCcodeName', dataIndex: 'bldsttCcodeName',
width: 100, width: 100,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -200,7 +198,7 @@ const columns = [
title: '接入状态', title: '接入状态',
dataIndex: 'dtinName', dataIndex: 'dtinName',
width: 100, width: 100,
sorter: true, sort: true,
ellipsis: true ellipsis: true
}, },
{ {
@ -221,19 +219,8 @@ const searchParams = computed(() => {
groupResultFlat: false, groupResultFlat: false,
select: [] select: []
}; };
if (sortState.value) {
//
params.sort = [
{
field: sortState.value.field,
dir: sortState.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
// //
params.sort = null; params.sort = null;
}
return params; return params;
}); });
@ -306,18 +293,6 @@ const buildFilter = () => {
}; };
}; };
//
const handleSortChange = (info: { field: string; order: string | null }) => {
//
if (info.field && info.order) {
sortState.value = info;
} else {
sortState.value = null; //
}
nextTick(() => {
handleSearch();
});
};
// //
const handleSearch = () => { const handleSearch = () => {
@ -350,10 +325,12 @@ const handleViewDetail = (record: any, type: string) => {
} else { } else {
// const sttpFullPath = 'ENV,ENVP,FP,FP_2,'; // const sttpFullPath = 'ENV,ENVP,FP,FP_2,';
// 使 filter // 使 filter
const parts = record.sttpFullPath.split(',').filter(item => item.trim() !== ''); const parts = record.sttpFullPath
.split(',')
.filter(item => item.trim() !== '');
const lastValue = parts[parts.length - 1]; const lastValue = parts[parts.length - 1];
modelStore.modalVisible = true; modelStore.modalVisible = true;
modelStore.params.sttp = lastValue modelStore.params.sttp = lastValue;
modelStore.title = record.stnm; modelStore.title = record.stnm;
modelStore.params.stcd = record.stcd; modelStore.params.stcd = record.stcd;
modelStore.params.bldsttCcode = record.bldsttCcode; modelStore.params.bldsttCcode = record.bldsttCcode;

View File

@ -45,8 +45,6 @@
:scrollY="360" :scrollY="360"
:columns="columns" :columns="columns"
:list-url="fhGetKendoListCust" :list-url="fhGetKendoListCust"
:enable-sort="true"
@sort-change="handleSortChange"
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
> >
@ -69,7 +67,7 @@ import { ref, computed, watch, onMounted, nextTick } from 'vue';
import { msstbprptGetKendoList, fhGetKendoListCust } from '@/api/qxd'; import { msstbprptGetKendoList, fhGetKendoListCust } from '@/api/qxd';
import BasicTable from '@/components/BasicTable/index.vue'; import BasicTable from '@/components/BasicTable/index.vue';
import { useModelStore } from '@/store/modules/model'; import { useModelStore } from '@/store/modules/model';
import { useJidiSelectEventStore } from "@/store/modules/jidiSelectEvent"; import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent';
const JidiSelectEventStore = useJidiSelectEventStore(); const JidiSelectEventStore = useJidiSelectEventStore();
// ==================== Props ==================== // ==================== Props ====================
const props = defineProps<{ const props = defineProps<{
@ -98,21 +96,21 @@ const columns = [
title: '设施名称', title: '设施名称',
dataIndex: 'stnm', dataIndex: 'stnm',
width: '176px', width: '176px',
sorter: true sort: true
}, },
{ {
key: 'baseName', key: 'baseName',
title: '所在基地', title: '所在基地',
dataIndex: 'baseName', dataIndex: 'baseName',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
title: '所属电站', title: '所属电站',
dataIndex: 'ennm', dataIndex: 'ennm',
width: '150px', width: '150px',
sorter: true, sort: true,
slots: { customRender: 'ennm' } slots: { customRender: 'ennm' }
}, },
{ {
@ -120,56 +118,56 @@ const columns = [
title: '所属栖息地', title: '所属栖息地',
dataIndex: 'fhstnm', dataIndex: 'fhstnm',
width: '176px', width: '176px',
sorter: true sort: true
}, },
{ {
key: 'ststdt', key: 'ststdt',
title: '开工日期', title: '开工日期',
dataIndex: 'ststdt', dataIndex: 'ststdt',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'esstdt', key: 'esstdt',
title: '建成日期', title: '建成日期',
dataIndex: 'esstdt', dataIndex: 'esstdt',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'mway', key: 'mway',
title: '监测方式', title: '监测方式',
dataIndex: 'mway', dataIndex: 'mway',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'vlsr', key: 'vlsr',
title: '数据接入来源', title: '数据接入来源',
dataIndex: 'vlsr', dataIndex: 'vlsr',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'hydrodtin_type', key: 'hydrodtin_type',
title: '数据接入类型', title: '数据接入类型',
dataIndex: 'hydrodtinType', dataIndex: 'hydrodtinType',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'enable', key: 'enable',
title: '是否启用', title: '是否启用',
dataIndex: 'enable', dataIndex: 'enable',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
key: 'dtin', key: 'dtin',
title: '是否接入', title: '是否接入',
dataIndex: 'dtin', dataIndex: 'dtin',
width: '150px', width: '150px',
sorter: true sort: true
}, },
{ {
title: '操作', title: '操作',
@ -180,30 +178,9 @@ const columns = [
slots: { customRender: 'action' } slots: { customRender: 'action' }
} }
]; ];
// 1.
const sortState = ref<{ field: string; order: string } | null>(null);
// 2.
const handleSortChange = (info: { field: string; order: string | null }) => {
if (info.field) {
sortState.value = info;
} else {
sortState.value = null; //
}
nextTick(() => {
handleSearch();
});
};
const searchParams = computed(() => { const searchParams = computed(() => {
const params: any = { group: [], groupResultFlat: false, select: [] }; const params: any = { group: [], groupResultFlat: false, select: [] };
if (sortState.value) {
// [{ field: 'name', dir: 'asc' }]
params.sort = [
{
field: sortState.value.field,
dir: sortState.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
params.sort = [ params.sort = [
{ {
field: 'baseStepSort', field: 'baseStepSort',
@ -218,7 +195,6 @@ const searchParams = computed(() => {
dir: 'asc' dir: 'asc'
} }
]; ];
}
return params; return params;
}); });
@ -384,7 +360,7 @@ onMounted(() => {
jiDiList.value.push({ jiDiList.value.push({
label: element.wbsName, label: element.wbsName,
value: element.wbsCode value: element.wbsCode
}) });
}); });
}); });
</script> </script>

View File

@ -57,8 +57,6 @@
:list-url="vmsstbprptGetKendoList" :list-url="vmsstbprptGetKendoList"
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #stnm="{ record }"> <template #stnm="{ record }">
<a-button <a-button
@ -116,7 +114,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -125,21 +123,21 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ttpwr', key: 'ttpwr',
title: '装机容量', title: '装机容量',
dataIndex: 'ttpwr', dataIndex: 'ttpwr',
width: '160px', width: '160px',
sorter: true sort: true
}, },
{ {
key: 'stjzysq', key: 'stjzysq',
title: '生态机组额定流量(m³/s)', title: '生态机组额定流量(m³/s)',
dataIndex: 'stjzysq', dataIndex: 'stjzysq',
width: '200px', width: '200px',
sorter: true sort: true
} }
], ],
EQ_5: [ EQ_5: [
@ -150,7 +148,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -159,28 +157,28 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'jhfdgk', key: 'jhfdgk',
title: '基荷发电工况', title: '基荷发电工况',
dataIndex: 'jhfdgk', dataIndex: 'jhfdgk',
width: '100px', width: '100px',
sorter: true sort: true
}, },
{ {
key: 'fdll', key: 'fdll',
title: '发电量(MKW)', title: '发电量(MKW)',
dataIndex: 'fdll', dataIndex: 'fdll',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'blprdName', key: 'blprdName',
title: '所属建设阶段', title: '所属建设阶段',
dataIndex: 'blprdName', dataIndex: 'blprdName',
width: '160px', width: '160px',
sorter: true sort: true
} }
], ],
default: [ default: [
@ -191,7 +189,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -200,55 +198,55 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ddzgq', key: 'ddzgq',
title: '死水位时保证流量(m³/s)', title: '死水位时保证流量(m³/s)',
dataIndex: 'ddzgq', dataIndex: 'ddzgq',
width: '190px', width: '190px',
sorter: true sort: true
}, },
{ {
key: 'flkq', key: 'flkq',
title: '最大泄放流量(m³/s)', title: '最大泄放流量(m³/s)',
dataIndex: 'flkq', dataIndex: 'flkq',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'jskgc', key: 'jskgc',
title: '进水口底版高程(m)', title: '进水口底版高程(m)',
dataIndex: 'jskgc', dataIndex: 'jskgc',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'outflrelev', key: 'outflrelev',
title: '出水口底版高程(m)', title: '出水口底版高程(m)',
dataIndex: 'outflrelev', dataIndex: 'outflrelev',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'flksz', key: 'flksz',
title: '孔口尺寸(m)', title: '孔口尺寸(m)',
dataIndex: 'flksz', dataIndex: 'flksz',
sorter: true, sort: true,
width: '120px' width: '120px'
}, },
{ {
key: 'frntwlltyp', key: 'frntwlltyp',
title: '结构形式', title: '结构形式',
dataIndex: 'frntwlltyp', dataIndex: 'frntwlltyp',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'blprdName', key: 'blprdName',
title: '所属建设阶段', title: '所属建设阶段',
dataIndex: 'blprdName', dataIndex: 'blprdName',
sorter: true, sort: true,
width: '160px' width: '160px'
} }
] ]
@ -263,12 +261,6 @@ const columns = computed(() => {
}); });
const tableRef = ref(); const tableRef = ref();
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: '',
order: null
});
const sort2 = ref([ const sort2 = ref([
{ {
field: 'baseStepSort', field: 'baseStepSort',
@ -291,19 +283,8 @@ const sort2 = ref([
// //
const searchParams = computed(() => { const searchParams = computed(() => {
let baseSort; let baseSort;
//
if (sortInfo.value.field && sortInfo.value.order) {
baseSort = [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
// 使 // 使
baseSort = sort2.value; baseSort = sort2.value;
}
return { return {
sort: baseSort, sort: baseSort,
@ -313,19 +294,7 @@ const searchParams = computed(() => {
}; };
}); });
// ;
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
// DOM
nextTick(() => {
fetchTableData();
});
};
const params = ref({ const params = ref({
qid: props.basicId || 'all', qid: props.basicId || 'all',
@ -635,16 +604,10 @@ const fetchTabList = async () => {
} }
: null, : null,
{ {
field: 'sttpFullPath', field: 'sttp',
operator: 'contains', operator: 'contains',
dataType: 'string', dataType: 'string',
value: 'ENV,ENVP,EQ,' value: 'EQ_'
},
{
field: 'sttpFullPath',
operator: 'neq',
dataType: 'string',
value: 'ENV,ENVP,EQ,'
}, },
{ {
field: 'baseName', field: 'baseName',

View File

@ -3,10 +3,31 @@
<div class="xie-fang-fang-shi-container"> <div class="xie-fang-fang-shi-container">
<SidePanelItem title="生态流量泄放方式"> <SidePanelItem title="生态流量泄放方式">
<!-- Loading 状态 --> <!-- Loading 状态 -->
<a-spin v-if="loading" :spinning="true" style="width: 100%; height: 350px; display: flex; justify-content: center; align-items: center;" /> <a-spin
v-if="loading"
:spinning="true"
style="
width: 100%;
height: 350px;
display: flex;
justify-content: center;
align-items: center;
"
/>
<!-- 空状态提示 --> <!-- 空状态提示 -->
<a-empty v-else-if="!loading && pieData.length === 0" description="暂无数据" style="height: 350px; display: flex; justify-content: center; align-items: center;flex-direction: column;text-indent:0em" /> <a-empty
v-else-if="!loading && pieData.length === 0"
description="暂无数据"
style="
height: 350px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-indent: 0em;
"
/>
<!-- 图表容器 --> <!-- 图表容器 -->
<div v-else ref="chartRef" class="pie-chart"></div> <div v-else ref="chartRef" class="pie-chart"></div>
@ -35,7 +56,7 @@ import * as echarts from 'echarts';
import type { ECharts } from 'echarts'; import type { ECharts } from 'echarts';
import { msstbprptGetKendoList } from '@/api/stll'; import { msstbprptGetKendoList } from '@/api/stll';
import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent'; import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent';
import STLLXFFS from './TwoLayer/STLLXFFS.vue' import STLLXFFS from './TwoLayer/STLLXFFS.vue';
// 便 // 便
defineOptions({ defineOptions({
name: 'xieFangFangShi' name: 'xieFangFangShi'
@ -263,16 +284,10 @@ const getecharts = async () => {
} }
: null, : null,
{ {
field: 'sttpFullPath', field: 'sttp',
operator: 'contains', operator: 'contains',
dataType: 'string', dataType: 'string',
value: 'ENV,ENVP,EQ,' value: 'EQ_'
},
{
field: 'sttpFullPath',
operator: 'neq',
dataType: 'string',
value: 'ENV,ENVP,EQ,'
}, },
{ {
field: 'baseName', field: 'baseName',

View File

@ -63,8 +63,6 @@
:list-url="vmsstbprptGetKendoList" :list-url="vmsstbprptGetKendoList"
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #stnm="{ record }"> <template #stnm="{ record }">
<a-button <a-button
@ -121,7 +119,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -130,21 +128,21 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ttpwr', key: 'ttpwr',
title: '装机容量', title: '装机容量',
dataIndex: 'ttpwr', dataIndex: 'ttpwr',
width: '160px', width: '160px',
sorter: true sort: true
}, },
{ {
key: 'stjzysq', key: 'stjzysq',
title: '生态机组额定流量(m³/s)', title: '生态机组额定流量(m³/s)',
dataIndex: 'stjzysq', dataIndex: 'stjzysq',
width: '200px', width: '200px',
sorter: true sort: true
} }
], ],
EQ_5: [ EQ_5: [
@ -155,7 +153,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -164,28 +162,28 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'jhfdgk', key: 'jhfdgk',
title: '基荷发电工况', title: '基荷发电工况',
dataIndex: 'jhfdgk', dataIndex: 'jhfdgk',
width: '100px', width: '100px',
sorter: true sort: true
}, },
{ {
key: 'fdll', key: 'fdll',
title: '发电量(MKW)', title: '发电量(MKW)',
dataIndex: 'fdll', dataIndex: 'fdll',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'blprdName', key: 'blprdName',
title: '所属建设阶段', title: '所属建设阶段',
dataIndex: 'blprdName', dataIndex: 'blprdName',
width: '160px', width: '160px',
sorter: true sort: true
} }
], ],
default: [ default: [
@ -196,7 +194,7 @@ const columnsConfig = {
slots: { customRender: 'stnm' }, slots: { customRender: 'stnm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ennm', key: 'ennm',
@ -205,55 +203,55 @@ const columnsConfig = {
slots: { customRender: 'ennm' }, slots: { customRender: 'ennm' },
fixed: 'left', fixed: 'left',
width: '120px', width: '120px',
sorter: true sort: true
}, },
{ {
key: 'ddzgq', key: 'ddzgq',
title: '死水位时保证流量(m³/s)', title: '死水位时保证流量(m³/s)',
dataIndex: 'ddzgq', dataIndex: 'ddzgq',
width: '190px', width: '190px',
sorter: true sort: true
}, },
{ {
key: 'flkq', key: 'flkq',
title: '最大泄放流量(m³/s)', title: '最大泄放流量(m³/s)',
dataIndex: 'flkq', dataIndex: 'flkq',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'jskgc', key: 'jskgc',
title: '进水口底版高程(m)', title: '进水口底版高程(m)',
dataIndex: 'jskgc', dataIndex: 'jskgc',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'outflrelev', key: 'outflrelev',
title: '出水口底版高程(m)', title: '出水口底版高程(m)',
dataIndex: 'outflrelev', dataIndex: 'outflrelev',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'flksz', key: 'flksz',
title: '孔口尺寸(m)', title: '孔口尺寸(m)',
dataIndex: 'flksz', dataIndex: 'flksz',
sorter: true, sort: true,
width: '120px' width: '120px'
}, },
{ {
key: 'frntwlltyp', key: 'frntwlltyp',
title: '结构形式', title: '结构形式',
dataIndex: 'frntwlltyp', dataIndex: 'frntwlltyp',
sorter: true, sort: true,
width: '160px' width: '160px'
}, },
{ {
key: 'blprdName', key: 'blprdName',
title: '所属建设阶段', title: '所属建设阶段',
dataIndex: 'blprdName', dataIndex: 'blprdName',
sorter: true, sort: true,
width: '160px' width: '160px'
} }
] ]
@ -269,12 +267,6 @@ const columns = computed(() => {
const tableRef = ref(); const tableRef = ref();
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: '',
order: null
});
const sort2 = ref([ const sort2 = ref([
{ {
field: 'rvcdStepSort', field: 'rvcdStepSort',
@ -289,18 +281,7 @@ const sort2 = ref([
// //
const searchParams = computed(() => { const searchParams = computed(() => {
let baseSort; let baseSort;
if (sortInfo.value.field && sortInfo.value.order) {
baseSort = [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
baseSort = sort2.value; baseSort = sort2.value;
}
return { return {
sort: baseSort, sort: baseSort,
group: [], group: [],
@ -309,19 +290,6 @@ const searchParams = computed(() => {
}; };
}); });
//
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
nextTick(() => {
fetchTableData();
});
};
// ==================== ==================== // ==================== ====================
const params = ref({ const params = ref({
JiDi: props.jidiName || '', JiDi: props.jidiName || '',
@ -670,7 +638,7 @@ const handleResize = () => {
onMounted(() => { onMounted(() => {
fetchPieData(); fetchPieData();
fetchTableData() fetchTableData();
window.addEventListener('resize', handleResize); window.addEventListener('resize', handleResize);
}); });

View File

@ -32,8 +32,6 @@
:list-url="vmsstbprptGetKendoList" :list-url="vmsstbprptGetKendoList"
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #dvtp="{ record }"> <template #dvtp="{ record }">
{{ {{
@ -104,7 +102,7 @@ const columns = ref([
key: 'jcdt', key: 'jcdt',
dataIndex: 'jcdt', dataIndex: 'jcdt',
visible: true, visible: true,
sorter: true, sort: true,
customRender: ({ record }: any) => { customRender: ({ record }: any) => {
const date = record.jcdt; const date = record.jcdt;
if (!date) return '-'; if (!date) return '-';
@ -181,33 +179,16 @@ const from = ref({
baseId: props.baseId || 'all', baseId: props.baseId || 'all',
stcd: '' stcd: ''
}); });
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: '',
order: null
});
// //
const searchParams = computed(() => { const searchParams = computed(() => {
let baseSort; let baseSort;
// //
if (sortInfo.value.field && sortInfo.value.order) {
baseSort = [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
baseSort = [ baseSort = [
{ field: 'baseStepSort', dir: 'asc' }, { field: 'baseStepSort', dir: 'asc' },
{ field: 'hbrvcd', dir: 'asc' }, { field: 'hbrvcd', dir: 'asc' },
{ field: 'rstcdStepSort', dir: 'asc' }, { field: 'rstcdStepSort', dir: 'asc' },
{ field: 'siteStepSort', dir: 'asc' } { field: 'siteStepSort', dir: 'asc' }
]; ];
}
return { return {
sort: baseSort, sort: baseSort,
@ -356,19 +337,7 @@ const Search = () => {
tableRef.value?.getList(filter); tableRef.value?.getList(filter);
}; };
//
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
// DOM BasicTable searchParams
nextTick(() => {
Search();
});
};
const resetSearch = () => { const resetSearch = () => {
from.value = { from.value = {

View File

@ -59,9 +59,11 @@
</a-tabs> </a-tabs>
<!-- 空状态 --> <!-- 空状态 -->
<a-empty v-if="!loading && tabList.length === 0" description="暂无数据" /> <div v-if="!loading && tabList.length === 0" class="empty-state">
<a-empty description="暂无数据" />
</div>
<div class="body_zhengti"> <div v-show="tabList.length > 0" class="body_zhengti">
<div class="echarts"> <div class="echarts">
<a-spin :spinning="dataLoading"> <a-spin :spinning="dataLoading">
<div v-if="pieData.length > 0" ref="chartRef" class="pie-chart"></div> <div v-if="pieData.length > 0" ref="chartRef" class="pie-chart"></div>
@ -81,8 +83,6 @@
" "
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #ennm="{ column, record }"> <template #ennm="{ column, record }">
<a-button type="link" size="small" @click="handleView(record)">{{ <a-button type="link" size="small" @click="handleView(record)">{{
@ -141,7 +141,7 @@ const columns = [
key: 'qecRate', key: 'qecRate',
title: `生态流量达标率(%)`, title: `生态流量达标率(%)`,
dataIndex: 'qecRate', dataIndex: 'qecRate',
sorter: true, // sort: true, //
width: '160px', width: '160px',
customRender: ({ text }: any) => { customRender: ({ text }: any) => {
if (text === null || text === undefined || text === '' || text === '-') if (text === null || text === undefined || text === '' || text === '-')
@ -152,12 +152,6 @@ const columns = [
]; ];
const tableRef = ref(); const tableRef = ref();
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: '',
order: null
});
const sort1 = ref([ const sort1 = ref([
{ {
field: 'baseStepSort', field: 'baseStepSort',
@ -194,39 +188,11 @@ const sort2 = ref([
// //
const searchParams = computed(() => { const searchParams = computed(() => {
let baseSort; let baseSort;
//
if (sortInfo.value.field && sortInfo.value.order) {
baseSort = [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
// 使
baseSort = params.value.key ? sort1.value : sort2.value; baseSort = params.value.key ? sort1.value : sort2.value;
}
return { return {
sort: baseSort sort: baseSort
}; };
}); });
//
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
// DOM
nextTick(() => {
fetchTableData();
});
};
// //
const initDateRange = () => { const initDateRange = () => {
const today = dayjs(); const today = dayjs();
@ -958,4 +924,12 @@ const handleResize = () => {
height: 482px; height: 482px;
} }
} }
.empty-state {
width: 100%;
height: 582px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style> </style>

View File

@ -82,8 +82,6 @@
" "
:search-params="searchParams" :search-params="searchParams"
:transform-data="customTransform" :transform-data="customTransform"
:enable-sort="true"
@sort-change="handleSortChange"
> >
<template #ennm="{ column, record }"> <template #ennm="{ column, record }">
<a-button type="link" size="small" @click="handleView(record)">{{ <a-button type="link" size="small" @click="handleView(record)">{{
@ -98,7 +96,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'; import { ref, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import type { EChartsOption } from 'echarts'; import type { EChartsOption } from 'echarts';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@ -117,6 +115,7 @@ const props = defineProps<{
type?: string; type?: string;
basicId?: string; basicId?: string;
qecPerformance?: any; qecPerformance?: any;
dateArr?: string[];
}>(); }>();
const JidiSelectEventStore = useJidiSelectEventStore(); const JidiSelectEventStore = useJidiSelectEventStore();
@ -126,7 +125,7 @@ const columns = [
key: 'baseName', key: 'baseName',
title: '所属基地', title: '所属基地',
dataIndex: 'baseName', dataIndex: 'baseName',
sorter: true // sort: true //
} }
: null, : null,
{ {
@ -134,13 +133,13 @@ const columns = [
title: '电站名称', title: '电站名称',
dataIndex: 'ennm', dataIndex: 'ennm',
slots: { customRender: 'action' }, slots: { customRender: 'action' },
sorter: true // sort: true //
}, },
{ {
key: 'addvcdName', key: 'addvcdName',
title: '行政区', title: '行政区',
dataIndex: 'addvcdName', dataIndex: 'addvcdName',
sorter: true // sort: true //
}, },
{ {
key: 'hbrvcdName', key: 'hbrvcdName',
@ -152,7 +151,7 @@ const columns = [
key: 'qecRate', key: 'qecRate',
title: `生态流量达标率(%)`, title: `生态流量达标率(%)`,
dataIndex: 'qecRate', dataIndex: 'qecRate',
sorter: true, // sort: true, //
width: '160px', width: '160px',
customRender: ({ text }: any) => { customRender: ({ text }: any) => {
if (text === null || text === undefined || text === '' || text === '-') if (text === null || text === undefined || text === '' || text === '-')
@ -165,7 +164,7 @@ const columns = [
title: '去年同期达标率(%)', title: '去年同期达标率(%)',
dataIndex: 'beforeQecRate', dataIndex: 'beforeQecRate',
width: '160px', width: '160px',
sorter: true, // sort: true, //
customRender: ({ text }: any) => { customRender: ({ text }: any) => {
if (text === null || text === undefined || text === '' || text === '-') if (text === null || text === undefined || text === '' || text === '-')
return '-'; return '-';
@ -175,12 +174,6 @@ const columns = [
].filter(Boolean); ].filter(Boolean);
const tableRef = ref(); const tableRef = ref();
//
const sortInfo = ref<{ field: string; order: string | null }>({
field: '',
order: null
});
const defaultSort = ref([ const defaultSort = ref([
{ {
field: 'baseId', field: 'baseId',
@ -205,39 +198,22 @@ const searchParams = computed(() => {
let baseSort; let baseSort;
// //
if (sortInfo.value.field && sortInfo.value.order) {
baseSort = [
{
field: sortInfo.value.field,
dir: sortInfo.value.order === 'ascend' ? 'asc' : 'desc'
}
];
} else {
// 使 // 使
baseSort = defaultSort.value; baseSort = defaultSort.value;
}
return { return {
sort: baseSort sort: baseSort
}; };
}); });
// // dateArr
const handleSortChange = (info: {
field: string;
order: 'ascend' | 'descend' | null;
}) => {
sortInfo.value.field = info.field || '';
sortInfo.value.order = info.order || null;
// DOM
nextTick(() => {
fetchTableData();
});
};
//
const initDateRange = () => { const initDateRange = () => {
// dateArr使
if (props.dateArr && props.dateArr.length === 2) {
return [dayjs(props.dateArr[0]), dayjs(props.dateArr[1])];
}
// 使""
const today = dayjs(); const today = dayjs();
const lastMonthSameDay = today.subtract(1, 'month'); const lastMonthSameDay = today.subtract(1, 'month');
return [lastMonthSameDay, today]; return [lastMonthSameDay, today];
@ -245,6 +221,17 @@ const initDateRange = () => {
const dateRange = ref(initDateRange()); const dateRange = ref(initDateRange());
// dateArr
watch(
() => props.dateArr,
newVal => {
if (newVal && newVal.length === 2) {
dateRange.value = [dayjs(newVal[0]), dayjs(newVal[1])];
}
},
{ deep: true }
);
const params = ref({ const params = ref({
qid: props.basicId || 'all', qid: props.basicId || 'all',
ennm: '', ennm: '',
@ -387,6 +374,8 @@ const jdColor = [
const fetchPieData = async () => { const fetchPieData = async () => {
if (!params.value.sTime || !params.value.eTime) return; if (!params.value.sTime || !params.value.eTime) return;
const isAllBase = params.value.qid === 'all';
dataLoading.value = true; dataLoading.value = true;
try { try {
const { sTime, eTime, qid, ennm } = params.value; const { sTime, eTime, qid, ennm } = params.value;
@ -437,17 +426,16 @@ const fetchPieData = async () => {
].filter(Boolean) ].filter(Boolean)
}, },
group: [ group: [
isAllBase
? { dir: 'asc', field: 'baseStepSort' }
: { dir: 'asc', field: 'rvcdStepSort' },
{ {
dir: 'asc', dir: 'asc',
field: 'rvcdStepSort' field: isAllBase ? 'baseId' : 'hbrvcd'
}, },
{ {
dir: 'asc', dir: 'asc',
field: 'hbrvcd' field: isAllBase ? 'baseName' : 'hbrvcdName'
},
{
dir: 'asc',
field: 'hbrvcdName'
} }
], ],
groupResultFlat: true groupResultFlat: true
@ -457,10 +445,10 @@ const fetchPieData = async () => {
const res = await vmsstbprptGetKendoList(obj); const res = await vmsstbprptGetKendoList(obj);
if (res?.data?.data) { if (res?.data?.data) {
const dataSource = res.data.data.map((el: any) => ({ const dataSource = res.data.data.map((el: any) => ({
id: el.hbrvcd, id: isAllBase ? el.baseId : el.hbrvcd,
name: el.hbrvcdName, name: isAllBase ? el.baseName : el.hbrvcdName,
value: el.count_hbrvcd, value: isAllBase ? el.count_baseId : el.count_hbrvcd,
key: el.hbrvcd key: isAllBase ? el.baseId : el.hbrvcd
})); }));
pieData.value = dataSource; pieData.value = dataSource;

View File

@ -53,7 +53,8 @@
v-if="detailModalVisible" v-if="detailModalVisible"
:type="mode" :type="mode"
:basicId="detailData[0]?.baseId" :basicId="detailData[0]?.baseId"
:qecPerformance=detailData[0].qecPerformance :qecPerformance="detailData[0].qecPerformance"
:date-arr="dateArr"
/> />
</a-modal> </a-modal>
</template> </template>
@ -65,6 +66,7 @@ import * as echarts from 'echarts';
import { eqqecRateCount, evnmAutoMonitorGetKendoListCust } from '@/api/stll'; import { eqqecRateCount, evnmAutoMonitorGetKendoListCust } from '@/api/stll';
import ModalYkzhbzdjcgz from '../shengtaidabiaoMod/TwoLayer/ModalYkzhbzdjcgz.vue'; import ModalYkzhbzdjcgz from '../shengtaidabiaoMod/TwoLayer/ModalYkzhbzdjcgz.vue';
import STLLXFFS from './TwoLayer/STLLXFFS.vue' import STLLXFFS from './TwoLayer/STLLXFFS.vue'
import { useMapViewStore } from '@/modules/map/stores/map-view.store';
// 便 // 便
defineOptions({ defineOptions({
name: 'shengtaidabiaoMod' name: 'shengtaidabiaoMod'
@ -73,8 +75,9 @@ const mode = ref('top');
const spinning = ref(false); const spinning = ref(false);
const chartRef = ref<HTMLElement | null>(null); const chartRef = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null; let chartInstance: echarts.ECharts | null = null;
const mapViewStore = useMapViewStore();
// //
let dateArr = ref<any[]>([]);
const chartData = ref<{ const chartData = ref<{
categories: string[]; categories: string[];
currentData: number[]; currentData: number[];
@ -333,12 +336,7 @@ const handleChartClick = (params: any) => {
detailModalVisible.value = true; detailModalVisible.value = true;
}; };
const getdate = () => { const getdate = (offsetYears = 0) => {
const now = new Date();
const oneMonthAgo = new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
// YYYY-MM-DD
const formatDate = (date: Date) => { const formatDate = (date: Date) => {
const year = date.getFullYear(); const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); const month = String(date.getMonth() + 1).padStart(2, '0');
@ -346,15 +344,57 @@ const getdate = () => {
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
}; };
const startDate = `${formatDate(oneMonthAgo)} 00:00:00`; let startDate: string;
const endDate = `${formatDate(now)} 23:59:59`; let endDate: string;
const startDate1 = `${formatDate(oneMonthAgo)}`; let startDate1: string;
const endDate1 = `${formatDate(now)}`; let endDate1: string;
// dateArr.value 使
if (dateArr.value && dateArr.value.length === 2) {
const start = new Date(dateArr.value[0]);
const end = new Date(dateArr.value[1]);
// offsetYears 0
if (offsetYears !== 0) {
start.setFullYear(start.getFullYear() + offsetYears);
end.setFullYear(end.getFullYear() + offsetYears);
}
startDate = `${formatDate(start)} 00:00:00`;
endDate = `${formatDate(end)} 23:59:59`;
//
startDate1 = formatDate(start);
endDate1 = formatDate(end);
// debugger
} else {
// 使""
const now = new Date();
const oneMonthAgo = new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
// offsetYears 0
if (offsetYears !== 0) {
now.setFullYear(now.getFullYear() + offsetYears);
oneMonthAgo.setFullYear(oneMonthAgo.getFullYear() + offsetYears);
}
startDate = `${formatDate(oneMonthAgo)} 00:00:00`;
endDate = `${formatDate(now)} 23:59:59`;
startDate1 = formatDate(oneMonthAgo);
endDate1 = formatDate(now);
}
return { startDate, endDate, startDate1, endDate1 }; return { startDate, endDate, startDate1, endDate1 };
}; };
const getEcharts = async () => { const getEcharts = async () => {
let params = { //
filter: { const currentDateRange = getdate(0);
//
const lastYearDateRange = getdate(-1);
// filter
const baseFilter = {
logic: 'and', logic: 'and',
filters: [ filters: [
mode.value == 'top' mode.value == 'top'
@ -369,57 +409,80 @@ const getEcharts = async () => {
operator: 'eq', operator: 'eq',
dataType: 'string', dataType: 'string',
value: 'DAY' value: 'DAY'
}, }
]
};
// params
const currentParams = {
filter: {
...baseFilter,
filters: [
...baseFilter.filters,
{ {
field: 'tm', field: 'tm',
operator: 'gte', operator: 'gte',
dataType: 'date', dataType: 'date',
value: getdate().startDate value: currentDateRange.startDate
}, },
{ {
field: 'tm', field: 'tm',
operator: 'lte', operator: 'lte',
dataType: 'date', dataType: 'date',
value: getdate().endDate value: currentDateRange.endDate
} }
] ]
}, },
group: group:
mode.value == 'top' mode.value == 'top'
? [ ? [
{ dir: 'asc', field: 'basestepsort' },
{ dir: 'asc', field: 'baseId' },
{ dir: 'asc', field: 'baseName' }
]
: [{ dir: 'asc', field: 'qecPerformance' }]
};
// params
const lastYearParams = {
filter: {
...baseFilter,
filters: [
...baseFilter.filters,
{ {
dir: 'asc', field: 'tm',
field: 'basestepsort' operator: 'gte',
dataType: 'date',
value: lastYearDateRange.startDate
}, },
{ {
dir: 'asc', field: 'tm',
field: 'baseId' operator: 'lte',
dataType: 'date',
value: lastYearDateRange.endDate
}
]
}, },
{ group: currentParams.group
dir: 'asc',
field: 'baseName'
}
]
: [
{
dir: 'asc',
field: 'qecPerformance'
}
]
}; };
try { try {
const res: any = await eqqecRateCount(params); // API
const [currentRes, lastYearRes]: [any, any] = await Promise.all([
eqqecRateCount(currentParams),
eqqecRateCount(lastYearParams)
]);
// //
if (res && res.success && res.data && res.data.data) { const currentApiData = (currentRes && currentRes.data && currentRes.data.data) ? currentRes.data.data : [];
const apiData = res.data.data; //
const lastYearApiData = (lastYearRes && lastYearRes.data && lastYearRes.data) ? lastYearRes.data.data : [];
// mode // mode
if (mode.value === 'top') { if (mode.value === 'top') {
// baseId // baseId
const uniqueMap = new Map(); const uniqueMap = new Map();
apiData.forEach((item: any) => { currentApiData.forEach((item: any) => {
if (!uniqueMap.has(item.baseId)) { if (!uniqueMap.has(item.baseId)) {
uniqueMap.set(item.baseId, item); uniqueMap.set(item.baseId, item);
} }
@ -427,40 +490,48 @@ const getEcharts = async () => {
const uniqueData = Array.from(uniqueMap.values()); const uniqueData = Array.from(uniqueMap.values());
// baseId
const lastYearMap = new Map();
lastYearApiData.forEach((item: any) => {
if (!lastYearMap.has(item.baseId)) {
lastYearMap.set(item.baseId, item.qecRate);
}
});
chartData.value = { chartData.value = {
categories: uniqueData.map((item: any) => item.baseName || ''), categories: uniqueData.map((item: any) => item.baseName || ''),
currentData: uniqueData.map((item: any) => currentData: uniqueData.map((item: any) =>
item.qecRate != null ? Number(item.qecRate) : 0 item.qecRate != null ? Number(item.qecRate) : 0
), ),
lastYearData: uniqueData.map((item: any) => lastYearData: uniqueData.map((item: any) => {
item.beforeQecRate != null ? Number(item.beforeQecRate) : 0 const lastYearRate = lastYearMap.get(item.baseId);
), return lastYearRate != null ? Number(lastYearRate) : 0;
}),
baseIds: uniqueData.map((item: any) => item.baseId), baseIds: uniqueData.map((item: any) => item.baseId),
qecPerformances: [] qecPerformances: []
}; };
} else { } else {
// //
// qecPerformance
const lastYearMap = new Map();
lastYearApiData.forEach((item: any) => {
if (!lastYearMap.has(item.qecPerformance)) {
lastYearMap.set(item.qecPerformance, item.qecRate);
}
});
chartData.value = { chartData.value = {
categories: apiData.map((item: any) => item.qecPerformanceName || ''), categories: currentApiData.map((item: any) => item.qecPerformanceName || ''),
currentData: apiData.map((item: any) => currentData: currentApiData.map((item: any) =>
item.qecRate != null ? Number(item.qecRate) : 0 item.qecRate != null ? Number(item.qecRate) : 0
), ),
lastYearData: apiData.map((item: any) => lastYearData: currentApiData.map((item: any) => {
item.beforeQecRate != null ? Number(item.beforeQecRate) : 0 const lastYearRate = lastYearMap.get(item.qecPerformance);
), return lastYearRate != null ? Number(lastYearRate) : 0;
}),
baseIds: [], baseIds: [],
qecPerformances: apiData.map((item: any) => item.qecPerformance || '') qecPerformances: currentApiData.map((item: any) => item.qecPerformance || '')
};
}
} else {
console.warn('API 返回数据格式异常');
// 使
chartData.value = {
categories: [],
currentData: [],
lastYearData: [],
baseIds: [],
qecPerformances: []
}; };
} }
} catch (error) { } catch (error) {
@ -517,6 +588,18 @@ onMounted(() => {
}); });
}); });
watch(
() => mapViewStore.searchTimeRange,
(newVal, oldVal) => {
console.log('时间范围变化:', oldVal, '->', newVal);
dateArr.value = newVal
// debugger
loadData();
//
},
{ deep: true }
);
// //
const detailModalVisible = ref(false); const detailModalVisible = ref(false);
const detailModalTitle = ref(''); const detailModalTitle = ref('');