水质接口对接-部分

This commit is contained in:
王兴凯 2026-06-01 08:38:48 +08:00
commit 1fbc8ced7a
19 changed files with 3180 additions and 223 deletions

View File

@ -7,12 +7,12 @@ VITE_APP_TITLE = '水电水利建设项目全过程环境管理信息平台'
VITE_APP_PORT = 3000
VITE_APP_BASE_API = '/dev-api'
# 本地环境
# VITE_APP_BASE_URL = 'http://localhost:8093'
VITE_APP_BASE_URL = 'http://localhost:8093'
# 测试环境
# VITE_APP_BASE_URL = 'http://172.16.21.142:8093'
# VITE_APP_BASE_URL = 'http://172.16.21.142:8096'
# 汤伟
VITE_APP_BASE_URL = 'http://10.84.121.21:8093'
# VITE_APP_BASE_URL = 'http://10.84.121.21:8093'
# VITE_APP_BASE_URL = 'http://192.168.1.162:8093'
# 测试环境线上

View File

@ -0,0 +1,50 @@
import request from '@/utils/request';
//水质监测工作开展情况
export function msstbprptGetKendoList(data: any) {
return request({
url: '/api/dec-lygk-base-server/base/msstbprpt/GetKendoList',
method: 'post',
data
});
}
////水温监测工作开展情况弹框
export function vmsstbprptGetKendoList(data: any) {
return request({
url: '/wq/vmsstbprpt/GetKendoList',
method: 'post',
data
});
}
//地表水水质达标率
export function wqGetKendoListCust(data: any) {
return request({
url: '/api/wmp-env-server/env/wq/GetKendoListCust',
method: 'post',
data
});
}
//环境质量满足度 - 表格数据列表
export function wqGetKendoList(data: any) {
return request({
url: '/api/wmp-env-server/env/wq/GetKendoListCust',
method: 'post',
data
});
}
//沿程水质变化_ 图表数据
export function qgcGetKendoListCust(data: any) {
return request({
url: '/api/wmp-env-server/env/wq/along/qgc/GetKendoListCust',
method: 'post',
data
});
}
//沿程水质变化_ 根据流域获取河段 https://211.99.26.225:12122
export function wbsbGetKendoList(data: any) {
return request({
url: '/api/dec-lygk-base-server/base/wbsb/GetKendoList',
method: 'post',
data
});
}

View File

@ -1455,7 +1455,7 @@ const FPPointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{
@ -1629,7 +1629,7 @@ const FBPointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{
@ -1760,7 +1760,7 @@ const VaPointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{
@ -2149,6 +2149,7 @@ const DwPointColumns: Array<any> = [
filed: 'nrmxavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2156,6 +2157,7 @@ const DwPointColumns: Array<any> = [
filed: 'nrmnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2163,6 +2165,7 @@ const DwPointColumns: Array<any> = [
filed: 'dnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2170,6 +2173,7 @@ const DwPointColumns: Array<any> = [
filed: 'dnmxavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2177,6 +2181,7 @@ const DwPointColumns: Array<any> = [
filed: 'dnwnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2200,7 +2205,7 @@ const DwPointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{
@ -2336,6 +2341,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'nrmxavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2343,6 +2349,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'nrmnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2350,6 +2357,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'dnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2357,6 +2365,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'dnmxavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
{
@ -2364,6 +2373,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'dnwnavwt',
visible: true,
type: 'number',
toFixed: 1,
url: '',
},
@ -2372,7 +2382,7 @@ const DwFivePointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{
@ -2627,7 +2637,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'nrmxavwt',
visible: true,
type: 'number',
toFixed: 2,
toFixed: 1,
url: '',
},
{
@ -2635,7 +2645,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'nrmnavwt',
visible: true,
type: 'number',
toFixed: 2,
toFixed: 1,
url: '',
},
{
@ -2643,7 +2653,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'dnavwt',
visible: true,
type: 'number',
toFixed: 2,
toFixed: 1,
url: '',
},
{
@ -2651,7 +2661,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'dnmxavwt',
visible: true,
type: 'number',
toFixed: 2,
toFixed: 1,
url: '',
},
{
@ -2659,7 +2669,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'dnmnavwt',
visible: true,
type: 'number',
toFixed: 2,
toFixed: 1,
url: '',
},
{
@ -2667,7 +2677,7 @@ const DwOnePointColumns: Array<any> = [
filed: 'inv',
visible: true,
type: 'number',
toFixed: 4,
toFixed: 6,
url: '',
},
{

View File

@ -392,11 +392,12 @@ const getChartOption = computed(() => {
params.forEach((param: any) => {
const dataIndex = param.dataIndex;
const record = data[dataIndex];
const value = param.value != null ? param.value : '-';
html += `
<div style="display:flex;align-items:center;margin:4px 0;">
<span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${param.color};margin-right:8px;"></span>
<span>${param.seriesName}: ${param.value}°C</span>
<span>${param.seriesName}: ${value}°C</span>
</div>
`;
@ -433,7 +434,19 @@ const getChartOption = computed(() => {
show: false
},
axisLabel: {
interval: xAxisData.length > 7 ? Math.floor((xAxisData.length - 1) / 7) : 0,
interval: (() => {
const dataLen = xAxisData.length;
if (dataLen <= 8) return 0; //
//
// 2 + 6 = 8
const maxLabels = 8;
const minInterval = Math.ceil((dataLen - 1) / (maxLabels - 1));
// 使使
const calculatedInterval = Math.floor((dataLen - 1) / 7);
return Math.max(calculatedInterval, minInterval);
})(),
fontSize: 12,
rotate: 0,
margin: 10

View File

@ -661,7 +661,7 @@ const WQFBTabs: Array<any> = [
name: '基础信息',
key: 'basicInfo',
type: 'basic',
url: '/bbi/siteBipc/getSiteBasicInfo'
url: '/api/dec-lygk-base-server/base/msstbprpt/getStcdInfo'
},
{
name: '监测数据',

View File

@ -71,7 +71,7 @@
</template>
<script lang="ts" setup>
import { ref, onMounted, watch, computed, nextTick } from 'vue';
import { ref, onMounted, onUnmounted, watch, computed, nextTick } from 'vue';
import {
QuestionCircleOutlined,
InfoCircleOutlined
@ -186,6 +186,9 @@ const scopeDateValue = ref<[Dayjs, Dayjs] | undefined>(
);
const tabsValue = ref(props.tabs.value)
// yearmonth
const lastMonthValue = ref<string | null>(null);
//
const treeExpandedKeys = ref<string[]>([])
const nodeMap = new Map<string, { node: any; parentKey: string | null }>()
@ -229,15 +232,19 @@ const createDisabledDateFn = (pickerType: string) => {
/**
* 单日期选择器的时间禁用函数针对 show-time
* 精确限制到当前时刻的时分秒
* @param current - 用户当前悬停或选择的日期 Ant Design Vue 自动传入
*/
const disabledTimeForSinglePicker = () => {
const disabledTimeForSinglePicker = (current?: Dayjs) => {
// datetimePicker date
if (!props.datetimePicker.show || props.datetimePicker.picker !== 'date') {
return undefined
}
const now = dayjs()
const selectedDate = datetimeValue.value
// 使 current datetimeValue.value
// current
const selectedDate = current || datetimeValue.value
//
if (!selectedDate || !selectedDate.isSame(now, 'day')) {
@ -531,7 +538,10 @@ const getPopupContainer = (trigger: HTMLElement) => {
//
const handleDateTimeChange = (date: any | null, dateString: string) => {
// Handle date time change
// month
if (props.datetimePicker.picker === 'month' && date) {
lastMonthValue.value = dayjs(date).format('YYYY-MM');
}
};
const handleTabClick = (value: string) => {
@ -654,6 +664,31 @@ watch(
}
);
// datetimePicker.picker year month
watch(
() => props.datetimePicker.picker,
(newPicker, oldPicker) => {
// year month
if (oldPicker === 'year' && newPicker === 'month' && lastMonthValue.value && datetimeValue.value) {
const currentYear = datetimeValue.value.year(); //
const lastMonth = dayjs(lastMonthValue.value); //
const lastMonthNum = lastMonth.month(); // 0-11
// +
let newValue = dayjs().year(currentYear).month(lastMonthNum);
//
const now = dayjs();
if (newValue.isAfter(now, 'month')) {
//
newValue = now.startOf('month');
}
datetimeValue.value = newValue;
}
}
);
// moreSelectValue
watch(() => moreSelectValue.value, (newValue) => {
console.log('moreSelectValue 变化:', newValue)
@ -691,9 +726,20 @@ watch(() => processedMoreSelectOptions.value, (newData) => {
//
onMounted(() => {
// picker month
if (props.datetimePicker.picker === 'month' && datetimeValue.value) {
lastMonthValue.value = datetimeValue.value.format('YYYY-MM');
}
//
emitAllValues();
});
//
onUnmounted(() => {
//
lastMonthValue.value = null;
});
</script>
<style lang="scss">

View File

@ -0,0 +1,844 @@
<template>
<div class="environmental-quality-container">
<!-- 搜索区域 -->
<a-form ref="formRef" :model="formState" layout="inline" class="search-form">
<a-space wrap>
<a-form-item label="所属基地" name="dataDimensionVal">
<a-select
v-model:value="formState.dataDimensionVal"
placeholder="请选择"
style="width: 120px"
show-search
:filter-option="filterBaseOption"
option-filter-prop="label"
@change="handleBaseChange"
>
<a-select-option
v-for="item in baseList"
:key="item.baseid"
:value="item.baseid"
:label="item.basename"
>
{{ item.basename }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-if="formState.dataDimensionVal === 'all'" label="测站类型" name="dtinType">
<a-select
v-model:value="formState.dtinType"
placeholder="请选择"
style="width: 100px"
show-search
:filter-option="filterOption"
option-filter-prop="label"
>
<a-select-option value="" label="全部">全部</a-select-option>
<a-select-option value="0" label="自建水质站">自建水质站</a-select-option>
<a-select-option value="1" label="国家水质站">国家水质站</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="时间维度" name="types">
<a-select
v-model:value="formState.types"
placeholder="请选择"
style="width: 80px"
show-search
:filter-option="filterOption"
option-filter-prop="label"
>
<a-select-option value="year" label="年度">年度</a-select-option>
<a-select-option value="month" label="月度">月度</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="达标状态" name="sfdb">
<a-select
v-model:value="formState.sfdb"
placeholder="请选择"
style="width: 100px"
show-search
:filter-option="filterOption"
option-filter-prop="label"
>
<a-select-option value="" label="全部">全部</a-select-option>
<a-select-option value="0" label="不达标">不达标</a-select-option>
<a-select-option value="1" label="达标">达标</a-select-option>
<a-select-option value="2" label="无目标等级/无数据">无目标等级/无数据</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="时间" name="dateValues">
<a-month-picker
v-if="formState.types === 'month'"
v-model:value="formState.dateValues"
format="YYYY-MM"
placeholder="请选择月份"
style="width: 160px"
:disabled-date="disabledMonthDate"
/>
<a-year-picker
v-else
v-model:value="formState.dateValues"
format="YYYY"
placeholder="请选择年份"
style="width: 160px"
:disabled-date="disabledYearDate"
/>
</a-form-item>
<a-form-item label="断面名称" name="stnm">
<a-input
v-model:value="formState.stnm"
placeholder="请输入断面名称"
style="width: 200px"
allow-clear
/>
</a-form-item>
<a-form-item>
<a-space>
<a-button type="primary" @click="handleSearch">查询</a-button>
<a-button @click="handleReset">重置</a-button>
</a-space>
</a-form-item>
</a-space>
</a-form>
<!-- 图表和表格布局区域 -->
<div class="content-layout">
<!-- 左侧饼图区域 -->
<div class="chart-section">
<a-spin :spinning="pieLoading" tip="加载中...">
<div ref="pieChartRef" class="pie-chart-container"></div>
<div v-if="!showPieChart && !pieLoading" class="empty-overlay">
<a-empty description="暂无数据" />
</div>
</a-spin>
</div>
<!-- 右侧表格区域 -->
<div class="table-section">
<BasicTable
ref="tableRef"
:scrollY="360"
:columns="columns"
:list-url="wqGetKendoList"
:search-params="{ sort: sortConfig }"
:transform-data="customTransform"
>
<template #bodyCell="{ column, record }">
<!-- 断面名称列 - 可点击 -->
<template v-if="column.key === 'stnm'">
<a @click="handleViewStnmDetail(record)" class="text-link">
{{ record.stnm }}
</a>
</template>
<!-- 操作列 -->
<template v-if="column.key === 'action'">
<a @click="handleViewDetail(record)" class="text-link">
查看详情
</a>
</template>
</template>
</BasicTable>
</div>
</div>
<!-- 详情弹窗 -->
<a-modal
v-model:open="detailModalVisible"
:title="`${detailData.stnm || ''} 详细信息`"
width="80%"
:footer="null"
@cancel="handleDetailModalClose"
>
<div class="modal-content">
<!-- TODO: 这里放置详情组件待后续实现 -->
<p>详情内容待实现...</p>
<pre>{{ detailData }}</pre>
</div>
</a-modal>
<!-- 地图弹窗断面名称点击 -->
<a-modal
v-model:open="mapModalVisible"
:title="`${mapModalData.titleName || ''} 详情信息`"
width="80%"
:footer="null"
@cancel="handleMapModalClose"
>
<div class="modal-content">
<!-- TODO: 这里放置地图标签页组件待后续实现 -->
<p>地图详情内容待实现...</p>
<pre>{{ mapModalData }}</pre>
</div>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'
import { message } from 'ant-design-vue'
import * as echarts from 'echarts'
import dayjs, { Dayjs } from 'dayjs'
import BasicTable from '@/components/BasicTable/index.vue'
import { wqGetKendoList } from '@/api/sz'
// Props
const props = defineProps<{
datas?: Array<{ baseid: string; basename: string }> //
type?: 'month' | 'year' //
modalData?: string //
dateValue?: string | Dayjs //
dataDimensionVal?: string //
buildType?: string | number //
}>()
// Refs
const formRef = ref()
const tableRef = ref()
const pieChartRef = ref<HTMLElement | null>(null)
let pieChartInstance: echarts.ECharts | null = null
// State
const formState = reactive({
dataDimensionVal: props.dataDimensionVal || '',
dtinType: '',
types: props.type || 'month',
sfdb: '',
dateValues: props.dateValue ? (typeof props.dateValue === 'string' ? dayjs(props.dateValue, props.type === 'month' ? 'YYYY-MM' : 'YYYY') : props.dateValue) : dayjs(),
stnm: ''
})
const baseList = computed(() => props.datas || [])
const pieLoading = ref(false)
const showPieChart = ref(true)
const pieCode = ref<string[]>([]) //
//
const detailModalVisible = ref(false)
const detailData = ref<any>({})
const mapModalVisible = ref(false)
const mapModalData = ref<any>({})
//
const sortConfig = computed(() => [
{ field: 'rstcdStepSort', dir: 'asc' },
{ field: 'stnm', dir: 'asc' },
{ field: 'tm', dir: 'desc' }
])
// URL
const getListUrl = async (params: any) => {
try {
const res = await wqGetKendoList(params)
return res
} catch (error) {
console.error('获取表格数据失败:', error)
message.error('获取表格数据失败')
return { data: { data: [], total: 0 } }
}
}
//
const customTransform = (res: any) => {
return {
records: res?.data?.data || [],
total: res?.data?.total || 0
}
}
//
const columns = [
{
title: '日期',
dataIndex: 'tm',
key: 'tm',
width: 120,
customRender: ({ record }: any) => {
const date = record.tm
if (!date) return '-'
if (typeof date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(date)) {
return date
}
if (typeof date === 'string' && date.includes(' ')) {
return date.split(' ')[0]
}
return date
}
},
{
title: '断面名称',
dataIndex: 'stnm',
key: 'stnm',
width: 150,
ellipsis: true
},
{
title: '断面编码',
dataIndex: 'stcd',
key: 'stcd',
width: 120,
visible: false
},
{
title: '测站类型',
dataIndex: 'sttypeName',
key: 'sttypeName',
width: 120
},
{
title: '达标状态',
dataIndex: 'sfdbName',
key: 'sfdbName',
width: 120
},
{
title: '水质要求',
dataIndex: 'wwqtgName',
key: 'wwqtgName',
width: 120
},
{
title: '当前水质',
dataIndex: 'wqGrdName',
key: 'wqGrdName',
width: 120
},
{
title: '去年同期水质',
dataIndex: 'beforeWqGrdName',
key: 'beforeWqGrdName',
width: 150
},
{
title: '操作',
key: 'action',
width: 100,
fixed: 'right'
}
]
//
const disabledMonthDate = (current: Dayjs) => {
if (!current) return false
const now = dayjs()
return current.isAfter(now, 'month')
}
//
const disabledYearDate = (current: Dayjs) => {
if (!current) return false
const now = dayjs()
return current.year() > now.year()
}
//
const filterBaseOption = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
//
const filterOption = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
//
const fetchPieData = async () => {
pieLoading.value = true
try {
//
const timeFormat = formState.types === 'month' ? 'YYYY-MM' : 'YYYY'
const startTime = formState.dateValues ? formState.dateValues.format(timeFormat) : ''
if (!startTime || !formState.dataDimensionVal) {
showPieChart.value = false
return
}
//
const filters: any[] = [
{
field: 'baseId',
operator: 'eq',
dataType: 'string',
value: formState.dataDimensionVal
},
{
field: 'type',
operator: 'eq',
dataType: 'string',
value: 'DAY'
},
formState.types === 'month' ? {
field: 'drMonth',
operator: 'eq',
dataType: 'string',
value: startTime
} : {
field: 'drYear',
operator: 'eq',
dataType: 'string',
value: startTime
},
formState.dataDimensionVal !== 'all' ? {
field: 'rstcd',
operator: 'eq',
dataType: 'string',
value: formState.dataDimensionVal
} : null,
formState.sfdb ? {
field: 'sfdb',
operator: 'eq',
dataType: 'string',
value: formState.sfdb
} : null,
formState.stnm ? {
field: 'stnm',
operator: 'contains',
dataType: 'string',
value: formState.stnm
} : null,
formState.dataDimensionVal == 'all' && formState.dtinType ? {
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: formState.dtinType
} : null
].filter(Boolean)
const params = {
filter: {
logic: 'and',
filters
}
}
// API
const res = await wqGetKendoList(params)
let data = res?.data?.data || res?.data || []
if (data.length === 0) {
showPieChart.value = false
return
}
//
const dataSource = data.map((item: any) => ({
name: item.keyName || 'null',
value: item.count,
key: item.keyName === '达标' ? 'DB_STATUS_1' : item.keyName === '不达标' ? 'DB_STATUS_0' : 'CURNODATA',
keyData: item?.key
}))
// ""
const filteredDataSource = dataSource.filter(item => item.name !== '无数据')
if (filteredDataSource.length === 0) {
showPieChart.value = false
return
}
showPieChart.value = true
//
await nextTick()
initPieChart(filteredDataSource)
} catch (error) {
console.error('获取饼图数据失败:', error)
message.error('获取饼图数据失败')
showPieChart.value = false
} finally {
pieLoading.value = false
}
}
//
const initPieChart = (data: any[]) => {
if (!pieChartRef.value) return
//
if (pieChartInstance) {
pieChartInstance.dispose()
pieChartInstance = null
}
pieChartInstance = echarts.init(pieChartRef.value)
//
const total = data.reduce((sum, item) => sum + item.value, 0)
const option = {
tooltip: {
trigger: 'item',
formatter: '{b}: {c} 次 ({d}%)'
},
legend: {
orient: 'vertical',
right: '10%',
top: '10%',
data: data.map(item => item.name)
},
title: [
{
text: total.toString(),
left: '45%',
top: '50%',
textAlign: 'center',
textStyle: {
fontSize: 20,
fontWeight: 'bold',
color: '#333'
}
},
{
text: '监测总次数',
left: '45%',
top: '56%',
textAlign: 'center',
textStyle: {
fontSize: 12,
color: '#666'
}
},
{
text: '(次)',
left: '45%',
top: '61%',
textAlign: 'center',
textStyle: {
fontSize: 10,
color: '#999'
}
}
],
series: [
{
name: '断面总数量',
type: 'pie',
radius: ['20%', '35%'],
center: ['45%', '55%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: true,
formatter: '{b}: {c} ({d}%)'
},
emphasis: {
label: {
show: true,
fontSize: 14,
fontWeight: 'bold'
}
},
data: data
}
]
}
//
const colorConfig: any = {
color: ['#52c41a', '#ff4d4f', '#d9d9d9']
}
pieChartInstance.setOption({ ...option, ...colorConfig })
// -
pieChartInstance.on('legendselectchanged', (params: any) => {
const selectedKeys = Object.keys(params.selected).filter(key => params.selected[key])
const allFalse = Object.values(params.selected).every(value => value === false)
// keyData
const dataMap: Record<string, string> = {
'达标': 'DB_STATUS_1',
'不达标': 'DB_STATUS_0',
'无数据': 'CURNODATA'
}
const selectedCodes = data
.filter(item => selectedKeys.includes(item.name))
.map(item => item.keyData)
pieCode.value = allFalse ? ['5'] : selectedCodes
//
handleSearch()
})
}
//
const handleBaseChange = () => {
formState.stnm = ''
fetchPieData()
handleSearch()
}
//
const handleSearch = () => {
const timeFormat = formState.types === 'month' ? 'YYYY-MM' : 'YYYY'
const startTime = formState.dateValues ? formState.dateValues.format(timeFormat) : ''
const filters: any[] = [
{
field: 'baseId',
operator: 'eq',
dataType: 'string',
value: formState.dataDimensionVal
},
formState.types === 'month' ? {
field: 'drMonth',
operator: 'eq',
dataType: 'string',
value: startTime
} : {
field: 'drYear',
operator: 'eq',
dataType: 'string',
value: startTime
},
{
field: 'type',
operator: 'eq',
dataType: 'string',
value: 'DAY'
},
formState.dataDimensionVal !== 'all' ? {
field: 'rstcd',
operator: 'eq',
dataType: 'string',
value: formState.dataDimensionVal
} : null,
pieCode.value.length > 0 ? {
field: 'sfdb',
operator: 'in',
dataType: 'string',
value: pieCode.value
} : (formState.sfdb ? {
field: 'sfdb',
operator: 'eq',
dataType: 'string',
value: formState.sfdb
} : null),
formState.stnm ? {
field: 'stnm',
operator: 'contains',
dataType: 'string',
value: formState.stnm
} : null,
formState.dataDimensionVal === 'all' && formState.dtinType ? {
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: formState.dtinType
} : null
].filter(Boolean)
const filter = {
logic: 'and',
filters
}
//
tableRef.value?.getList(filter)
}
//
const handleReset = () => {
formState.dataDimensionVal = props.dataDimensionVal || ''
formState.dtinType = ''
formState.types = props.type || 'month'
formState.sfdb = ''
formState.dateValues = dayjs()
formState.stnm = ''
pieCode.value = []
fetchPieData()
handleSearch()
}
//
const handleViewDetail = (record: any) => {
detailData.value = { ...record }
detailModalVisible.value = true
}
//
const handleDetailModalClose = () => {
detailModalVisible.value = false
detailData.value = {}
}
//
const handleViewStnmDetail = (record: any) => {
const timeRange = formState.dateValues
? [dayjs(formState.dateValues).startOf(formState.types === 'month' ? 'month' : 'year'),
dayjs(formState.dateValues).endOf(formState.types === 'month' ? 'month' : 'year')]
: []
mapModalData.value = {
sttp: 'wq',
stcd: record.stcd,
titleName: record.stnm,
timeRange,
calculateFlag: null // TODO:
}
mapModalVisible.value = true
}
//
const handleMapModalClose = () => {
mapModalVisible.value = false
mapModalData.value = {}
}
//
watch(
() => [formState.dataDimensionVal, formState.types, formState.sfdb, formState.stnm, formState.dtinType],
() => {
fetchPieData()
handleSearch()
},
{ deep: true }
)
//
watch(
() => formState.dateValues,
() => {
fetchPieData()
handleSearch()
}
)
//
onMounted(async () => {
await nextTick()
fetchPieData()
handleSearch()
// resize
window.addEventListener('resize', () => {
pieChartInstance?.resize()
})
})
//
onBeforeUnmount(() => {
pieChartInstance?.dispose()
pieChartInstance = null
window.removeEventListener('resize', () => {
pieChartInstance?.resize()
})
})
//
defineExpose({
handleSearch
})
</script>
<style scoped lang="scss">
.environmental-quality-container {
height: 100%;
display: flex;
flex-direction: column;
.search-form {
background: #fff;
border-radius: 4px;
padding: 16px;
:deep(.ant-space) {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
:deep(.ant-form-item) {
margin-bottom: 0;
}
}
.content-layout {
flex: 1;
display: flex;
gap: 16px;
overflow: hidden;
.chart-section {
width: 35%;
min-width: 300px;
background: #fff;
border-radius: 4px;
padding: 16px;
position: relative;
.pie-chart-container {
width: 100%;
height: 482px;
}
.empty-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.9);
z-index: 10;
}
}
.table-section {
flex: 1;
background: #fff;
border-radius: 4px;
padding: 16px;
overflow: hidden;
}
}
.text-link {
color: #2f6b98;
&:hover {
color: #40a9ff;
}
}
.modal-content {
padding: 20px;
max-height: 600px;
overflow-y: auto;
pre {
background: #f5f5f5;
padding: 12px;
border-radius: 4px;
font-size: 12px;
margin-top: 16px;
}
}
}
:deep(.ant-spin-nested-loading) {
height: 100%;
}
:deep(.ant-spin-container) {
height: 100%;
}
</style>

View File

@ -1,80 +1,573 @@
<!-- SidePanelItem.vue -->
<template>
<SidePanelItem title="地表水水质达标率">
<SidePanelItem title="地表水水质达标率" :select="select" :datetimePicker="datetimePicker"
@update-values="handlePanelChange1" style="height: 650px;">
<div class="body_item">
<div class="tabs_all">
<div :class="tabs == 1 ? 'zhong_tabs' : 'no_tabs'" @click="handleTabChange(1)">自建水质站</div>
<div :class="tabs == 2 ? 'zhong_tabs' : 'no_tabs'" @click="handleTabChange(2)">国家水质站</div>
<div v-if="baseid == 'all'" class="tabs_all">
<div :class="tabs == 0 ? 'zhong_tabs' : 'no_tabs'" @click="handleTabChange(0)">自建水质站</div>
<div :class="tabs == 1 ? 'zhong_tabs' : 'no_tabs'" @click="handleTabChange(1)">国家水质站</div>
</div>
<div v-show="tabs == 1 || tabs == 2" class="tabs_body">
<div v-show="tabs == 0 || tabs == 1" class="tabs_body">
<a-spin :spinning="loading">
<!-- 始终渲染图表容器确保有固定宽高 -->
<div ref="chartRef" class="chart-container"></div>
<!-- 无数据时显示Empty但不影响容器尺寸 -->
<div v-if="chartData.length === 0 && !loading" class="empty-overlay">
<a-empty description="暂无数据" />
</div>
</a-spin>
</div>
</div>
</SidePanelItem>
<!-- 环境质量满足度弹框 -->
<a-modal
v-model:open="modalVisible"
title="环境质量满足度"
width="1536px"
:footer="null"
centered
>
<EnvironmentalQualityTwoLayers
:datas="jiDiList"
:type="select.value "
:dateValue="datetimePicker.value"
:dataDimensionVal="baseid"
:buildType="tabs"
/>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { ref, onMounted, onUnmounted, watch, nextTick, computed } from 'vue';
import * as echarts from 'echarts';
import SidePanelItem from '@/components/SidePanelItem/index.vue';
import { wqGetKendoListCust } from '@/api/sz'
import { useJidiSelectEventStore } from "@/store/modules/jidiSelectEvent";
import EnvironmentalQualityTwoLayers from "./TwoLayers/EnvironmentalQualityTwoLayers.vue"
// 便
defineOptions({
name: 'EnvironmentalQuality'
});
const tabs = ref(1);
const JidiSelectEventStore = useJidiSelectEventStore();
const tabs = ref(0);
const chartRef = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const loading = ref(false);
// - 1
const selfBuiltData = [
{ name: '雅砻江\n干流', current: 99, lastYear: 100 },
{ name: '大渡河\n干流', current: 99, lastYear: 100 },
{ name: '黄河上游\n干流', current: 99, lastYear: 100 }
];
//
const chartData = ref<Array<{ name: string; current: number | null; lastYear: number | null }>>([]);
// - 2
const nationalData = [
{ name: '长江\n干流', current: 98, lastYear: 99 },
{ name: '珠江\n干流', current: 97, lastYear: 98 },
{ name: '淮河\n干流', current: 96, lastYear: 97 }
];
const select = ref({
show: true,
value: 'month',
options: [
{ value: 'month', label: '月度' },
{ value: 'year', label: '年度' }
],
picker: undefined,
format: undefined,
});
// tab
const getCurrentData = () => {
return tabs.value === 1 ? selfBuiltData : nationalData;
//
const datetimePicker = ref({
show: true,
value: (() => {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
return `${year}-${month}`;
})(),
format: "YYYY-MM",
picker: "month" as const,
options: [],
});
const baseid = ref("")
const jiDiList: any = ref([
{
"baseid": "all",
"basename": "当前全部",
"id": "9BFEC848-83EA-AD22-6DE2-10E969476693"
},
{
"baseid": "01",
"basename": "金沙江干流",
"id": "A33040B7-8977-D9F1-5E02-D7F0241AB8AA"
},
{
"baseid": "02",
"basename": "雅砻江干流",
"id": "C63D6020-995D-FE97-2F4A-F619A7142C79"
},
{
"baseid": "03",
"basename": "大渡河干流",
"id": "CCB0766B-F1D4-7DD6-650F-5C556B7231B3"
},
{
"baseid": "04",
"basename": "乌江干流",
"id": "E8A66641-B4F4-CC85-0815-38C5B2F93DBD"
},
{
"baseid": "05",
"basename": "长江上游干流",
"id": "E02C11E9-CEA5-A030-202F-3BFE84465D03"
},
{
"baseid": "10",
"basename": "湘西",
"id": "B1D1D52D-CEEF-6DC4-27DF-9990EB572F8D"
},
{
"baseid": "08",
"basename": "黄河上游干流",
"id": "BC6AF135-263D-09A9-D5CA-C99B2598FE6E"
},
{
"baseid": "09",
"basename": "黄河中游干流",
"id": "60EEEC28-128F-A2A8-44F3-6EAAC8FD8BB6"
},
{
"baseid": "06",
"basename": "南盘江-红水河",
"id": "7BB9A8F4-34B5-42B4-A7FC-CE910AD7F203"
},
{
"baseid": "12",
"basename": "东北",
"id": "47F8EF06-924E-E161-FCAF-62A66BBF252D"
},
{
"baseid": "07",
"basename": "澜沧江干流",
"id": "A966A4C9-278C-B0DA-2B97-2D10B7A6E96A"
},
{
"baseid": "13",
"basename": "怒江干流",
"id": "FA89E8CB-67A8-76DA-DC1E-23AE4C54F9E4"
},
{
"baseid": "11",
"basename": "闽浙赣",
"id": "CD98F995-EEB2-1021-D807-DA1B1AD9E49A"
},
{
"baseid": "other",
"basename": "其他",
"id": "AFBDFC67-B955-4EFD-959A-014CFB59EBFC"
}
])
// Store
const baseList = computed(() => {
// TODO:
// Store API
//
// return [
// { baseid: 'all', basename: '' },
// { baseid: '01', basename: '' },
// ...
// ]
//
return []
})
// API
const parseApiResponse = (items: any[], currentValueForApi: string, lastYearValue: string) => {
const result: Array<{ name: string; current: number | null; lastYear: number | null }> = [];
console.log('=== parseApiResponse 开始解析 ===');
console.log('currentValueForApi:', currentValueForApi);
console.log('lastYearValue:', lastYearValue);
console.log('items数量:', items?.length);
items.forEach((group, groupIndex) => {
console.log(`\n--- 处理第${groupIndex + 1}个group ---`);
console.log('group.key:', group.key);
console.log('group.items数量:', group.items?.length);
group.items?.forEach((mainGroup, mainIndex) => {
console.log(` → 第${mainIndex + 1}个mainGroup:`);
console.log(' field:', mainGroup.field);
console.log(' key:', mainGroup.key);
// field
const field = mainGroup.field;
if (field === 'ennm' || field === 'baseId') {
// mainGroup.keyID
let displayName = '';
// mainGroup.key ""ID"02"
if (mainGroup.key && typeof mainGroup.key === 'string') {
displayName = mainGroup.key;
console.log(' 从mainGroup.key获取名称:', displayName);
}
// mainGroup.keysubGroup.key
if (!displayName || !/[\u4e00-\u9fa5]/.test(displayName)) {
const subGroup = mainGroup.items?.[0];
console.log(' subGroup.key:', subGroup?.key);
if (subGroup && subGroup.key && typeof subGroup.key === 'string') {
displayName = subGroup.key; // ""
console.log(' 从subGroup.key获取名称:', displayName);
}
}
//
if (!displayName) {
const subGroup = mainGroup.items?.[0];
const firstMonthGroup = subGroup?.items?.[0];
const dataItem = firstMonthGroup?.items?.[0];
if (dataItem) {
if (field === 'ennm') {
displayName = dataItem.ENNM || '';
} else if (field === 'baseId') {
displayName = dataItem.BASENAME || '';
}
console.log(' 从最内层数据获取名称:', displayName);
}
}
if (!displayName) {
console.log(' ⚠️ 跳过:没有名称');
return; //
}
let currentPeriodValue: number | null = null;
let lastYearPeriodValue: number | null = null;
// 3
const subGroup = mainGroup.items?.[0];
console.log(' subGroup.items数量:', subGroup?.items?.length);
subGroup?.items?.forEach(monthGroup => {
const periodKey = monthGroup.key; // "2026-05" "2025-05"
const dataItem = monthGroup.items?.[0];
if (dataItem) {
const value = dataItem.COUNT_DRMONTH ?? dataItem.wqRate;
console.log(` 时间:${periodKey}, 值:${value}`);
//
if (periodKey === currentValueForApi) {
currentPeriodValue = value != null ? Number(value) : null;
console.log(` ✓ 当前期值: ${currentPeriodValue}`);
} else if (periodKey === lastYearValue) {
lastYearPeriodValue = value != null ? Number(value) : null;
console.log(` ✓ 去年同期值: ${lastYearPeriodValue}`);
}
}
});
// ""\n
const finalDisplayName = displayName.replace(/干流$/, '\n干流');
console.log(` → 最终数据: {name: "${finalDisplayName}", current: ${currentPeriodValue}, lastYear: ${lastYearPeriodValue}}`);
result.push({
name: finalDisplayName,
current: currentPeriodValue,
lastYear: lastYearPeriodValue
});
}
});
});
console.log('\n=== parseApiResponse 解析完成 ===');
console.log('result数量:', result.length);
console.log('result:', result);
return result;
};
// tab
const handleTabChange = (tab: number) => {
tabs.value = tab;
getEchartsData()
};
// tabs
//tabs
watch(tabs, (newVal) => {
if (newVal === 1 || newVal === 2) {
if (newVal === 0 || newVal === 1) {
nextTick(() => {
setTimeout(() => {
if (!chartInstance) {
initChart();
} else {
//
updateChartData();
}
getEchartsData();
}, 50);
});
}
});
watch(
() => JidiSelectEventStore.selectedItem,
(newVal) => {
if (newVal && newVal.wbsCode) {
baseid.value = newVal.wbsCode;
getEchartsData();
}
},
{ deep: true }
);
//
const initChart = () => {
if (!chartRef.value) return;
// option
const initChart = (): Promise<void> => {
return new Promise((resolve, reject) => {
if (!chartRef.value) {
console.error('图表容器ref不存在');
reject(new Error('图表容器不存在'));
return;
}
chartInstance = echarts.init(chartRef.value);
if (chartInstance) {
resolve();
return;
}
const currentData = getCurrentData();
const domElement = chartRef.value;
// DOM
if (domElement.clientWidth === 0 || domElement.clientHeight === 0) {
console.warn('图表容器尺寸为0等待DOM布局完成...', {
clientWidth: domElement.clientWidth,
clientHeight: domElement.clientHeight,
offsetWidth: domElement.offsetWidth,
offsetHeight: domElement.offsetHeight
});
// 使
let retryCount = 0;
const maxRetries = 10;
const tryInit = () => {
retryCount++;
if (domElement.clientWidth > 0 && domElement.clientHeight > 0) {
chartInstance = echarts.init(domElement);
console.log('图表实例已创建(第' + retryCount + '次尝试)');
resolve();
} else if (retryCount < maxRetries) {
console.log(`${retryCount}次尝试容器尺寸仍为0继续等待...`);
requestAnimationFrame(tryInit);
} else {
console.error('图表容器尺寸仍为0已达到最大重试次数', {
clientWidth: domElement.clientWidth,
clientHeight: domElement.clientHeight
});
reject(new Error('图表容器尺寸为0'));
}
};
//
requestAnimationFrame(tryInit);
} else {
//
chartInstance = echarts.init(domElement);
console.log('图表实例已创建');
resolve();
}
});
};
//
const getEchartsData = async () => {
// 1.
const currentValue = datetimePicker.value.value;
// debugger
if (select.value.value === 'year') {
// YYYY 4
if (!/^\d{4}$/.test(currentValue)) {
console.warn('年度模式下日期格式不正确,应为 YYYY 格式');
return;
}
} else if (select.value.value === 'month') {
// YYYY-MM
if (!/^\d{4}-\d{2}$/.test(currentValue)) {
console.warn('月度模式下日期格式不正确,应为 YYYY-MM 格式');
return;
}
} else {
console.warn('未知的选择器类型');
return;
}
// 2.
let currentValueForApi: string; //
let lastYearValue: string; //
if (select.value.value === 'year') {
//
currentValueForApi = currentValue; // "2025"
lastYearValue = String(Number(currentValue) - 1); // "2024"
} else {
//
currentValueForApi = currentValue; // "2025-03"
//
const [year, month] = currentValue.split('-');
// 1
const lastYear = String(Number(year) - 1);
lastYearValue = `${lastYear}-${month}`; // "2024-03"
}
// 3.
let params = {
"filter": {
"logic": "and",
"filters": [
baseid.value != 'all' ? {
"field": "baseId",
"operator": "eq",
"value": baseid.value
} : null,
{
"field": "type",
"operator": "eq",
"value": select.value.value == "year" ? "YEAR" : "MON"
},
{
"field": "dtinType",
"operator": "eq",
"value": tabs.value
},
{
"logic": "or",
"filters": [
{
"field": select.value.value == "year" ? "drYear" : "drMonth",
"operator": "eq",
"value": currentValueForApi, //
"dataType": "string"
},
{
"field": select.value.value == "year" ? "drYear" : "drMonth",
"operator": "eq",
"value": lastYearValue, //
"dataType": "string"
}
]
}
].filter(Boolean)
},
"group": [
{
"dir": "des",
"field": "baseStepSort"
},
baseid.value == 'all' ? {
"dir": "des",
"field": "baseId"
} : {
"dir": "asc",
"field": "ennm"
},
baseid.value == 'all' ? {
"dir": "des",
"field": "baseName"
} : {
"dir": "des",
"field": "rstcd"
},
{
"dir": "desc",
"field": select.value.value == "year" ? "drYear" : "drMonth"
}
],
"groupResultFlat": false,
"aggregate": [
{
"aggregate": "sum",
"field": "wqRate"
}
]
};
// 4. API
loading.value = true;
try {
const res = await wqGetKendoListCust(params);
console.log('=== API返回数据调试 ===');
console.log('res:', res);
console.log('res.data:', res?.data);
console.log('res.data.data:', res?.data?.data);
console.log('currentValueForApi:', currentValueForApi);
console.log('lastYearValue:', lastYearValue);
if (!res?.data?.data) {
console.warn('数据获取失败或数据为空');
chartData.value = [];
//
if (chartInstance) {
chartInstance.clear();
console.log('图表已清空(数据获取失败)');
}
return;
}
//
const parsedData = parseApiResponse(res.data.data, currentValueForApi, lastYearValue);
console.log('解析后的数据 parsedData:', parsedData);
//
if (parsedData.length > 0) {
chartData.value = parsedData;
console.log('chartData.value:', chartData.value);
// DOM
await nextTick();
try {
//
if (!chartInstance) {
await initChart();
}
//
if (chartInstance) {
updateChartData(currentValueForApi, lastYearValue);
console.log('图表已更新');
} else {
console.error('图表实例创建失败');
}
} catch (error) {
console.error('图表初始化失败:', error);
}
} else {
chartData.value = [];
console.warn('解析后数据为空');
//
if (chartInstance) {
chartInstance.clear();
console.log('图表已清空(解析后数据为空)');
}
}
} catch (error) {
console.error('获取图表数据失败:', error);
chartData.value = [];
//
if (chartInstance) {
chartInstance.clear();
console.log('图表已清空(发生错误)');
}
} finally {
loading.value = false;
}
};
//
const updateChartData = (currentLabel: string, lastYearLabel: string) => {
if (!chartInstance) return;
//
const modeText = select.value.value === 'year' ? '' : ' 月度';
const legendCurrentLabel = currentLabel + modeText;
const legendLastYearLabel = ' 去年同期';
const option = {
//
@ -85,8 +578,8 @@ const initChart = () => {
itemGap: 20,
icon: 'roundRect',
data: [
{ name: '2026-04 月度', itemStyle: { color: '#4A8BC2' } },
{ name: '去年同期', itemStyle: { color: '#9B59B6' } }
{ name: legendCurrentLabel, itemStyle: { color: '#4A8BC2' } },
{ name: legendLastYearLabel, itemStyle: { color: '#9B59B6' } }
],
textStyle: {
fontSize: 12,
@ -118,10 +611,11 @@ const initChart = () => {
const name = params[0].name.replace('\n', '');
let result = `<div style="font-weight: bold; margin-bottom: 8px;">${name}</div>`;
params.forEach((item: any) => {
const value = item.value != null ? Number(item.value).toFixed(1) : '-';
result += `<div style="display: flex; align-items: center; margin-bottom: 4px;">
<span style="display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: ${item.color}; margin-right: 8px;"></span>
<span>${item.seriesName}:</span>
<span style="margin-left: auto; font-weight: bold;">${item.value} %</span>
<span style="margin-left: auto; font-weight: bold;">${value}%</span>
</div>`;
});
return result;
@ -133,7 +627,7 @@ const initChart = () => {
left: 60,
right: 10,
top: 60,
bottom: 50
bottom: 60
},
// X
@ -163,7 +657,7 @@ const initChart = () => {
// Y
yAxis: {
type: 'category',
data: currentData.map(item => item.name),
data: chartData.value.map(item => item.name),
inverse: true,
axisLine: {
show: true,
@ -199,29 +693,20 @@ const initChart = () => {
//
series: [
{
name: '2026-04 月度',
name: legendCurrentLabel,
type: 'bar',
data: currentData.map(item => item.current),
data: chartData.value.map(item => item.current != null ? Number(item.current).toFixed(1) : null),
barWidth: 10,
barGap: '20%',
itemStyle: {
color: '#4A8BC2',
borderRadius: [0, 3, 3, 0]
},
markArea: {
silent: true,
itemStyle: {
color: 'rgba(240, 245, 250, 0.5)'
},
data: [
[{ yAxis: 1 }, { yAxis: 2 }]
]
}
},
{
name: '去年同期',
name: legendLastYearLabel,
type: 'bar',
data: currentData.map(item => item.lastYear),
data: chartData.value.map(item => item.lastYear != null ? Number(item.lastYear).toFixed(1) : null),
barWidth: 10,
barGap: '20%',
itemStyle: {
@ -232,38 +717,69 @@ const initChart = () => {
]
};
chartInstance.setOption(option);
};
chartInstance.setOption(option, { notMerge: true });
//
const updateChartData = () => {
if (!chartInstance) return;
//
chartInstance.off('click');
const currentData = getCurrentData();
//
chartInstance.on('click', (params: any) => {
if (params.componentType === 'series' && params.seriesType === 'bar') {
//
const dataIndex = params.dataIndex;
const barData = chartData.value[dataIndex];
chartInstance.setOption({
yAxis: {
data: currentData.map(item => item.name)
},
series: [
{
data: currentData.map(item => item.current)
},
{
data: currentData.map(item => item.lastYear)
if (barData) {
clickedBarData.value = {
name: barData.name.replace('\n', ''), //
current: barData.current,
lastYear: barData.lastYear
};
modalVisible.value = true;
}
}
]
});
//
chartInstance.resize();
};
// datetimePicker.value.value
watch(
() => datetimePicker.value.value,
async (newValue, oldValue) => {
//
if (newValue !== oldValue && chartInstance) {
await nextTick();
getEchartsData();
}
}
);
//
const handlePanelChange1 = async (data) => {
console.log('当前所有控件状态:', data);
// debugger
//
if (data.select || data.datetime) {
await (select.value.value = data.select)
await (datetimePicker.value.value = data.datetime)
await (datetimePicker.value.picker = data.select)
await (datetimePicker.value.format = data.select == 'month' ? 'YYYY-MM' : 'YYYY')
getEchartsData()
}
}
//
//
onMounted(() => {
//
setTimeout(() => {
initChart();
// selectedItem
if (JidiSelectEventStore.selectedItem?.wbsCode) {
baseid.value = JidiSelectEventStore.selectedItem.wbsCode;
getEchartsData();
}
}, 100);
// resize
@ -275,10 +791,55 @@ onMounted(() => {
//
onUnmounted(() => {
chartInstance?.dispose();
chartInstance = null;
chartData.value = [];
window.removeEventListener('resize', () => {
chartInstance?.resize();
});
});
//
const modalVisible = ref(false);
const clickedBarData = ref<{ name: string; current: number | null; lastYear: number | null } | null>(null);
//
const modalTimeInfo = computed(() => {
if (!datetimePicker.value.value) return '';
const currentValue = datetimePicker.value.value;
const modeText = select.value.value === 'year' ? '年度' : '月度';
if (select.value.value === 'year') {
return `${currentValue}${modeText}`;
} else {
const [year, month] = currentValue.split('-');
return `${year}${month}${modeText}`;
}
});
//
const getChangeValue = () => {
if (!clickedBarData.value || clickedBarData.value.current == null || clickedBarData.value.lastYear == null) {
return '-';
}
const change = Number(clickedBarData.value.current) - Number(clickedBarData.value.lastYear);
const symbol = change > 0 ? '+' : '';
return `${symbol}${change.toFixed(1)}%`;
};
//
const getChangeClass = () => {
if (!clickedBarData.value || clickedBarData.value.current == null || clickedBarData.value.lastYear == null) {
return '';
}
const change = Number(clickedBarData.value.current) - Number(clickedBarData.value.lastYear);
if (change > 0) return 'positive';
if (change < 0) return 'negative';
return 'neutral';
};
</script>
<style lang="scss" scoped>
@ -291,7 +852,7 @@ onUnmounted(() => {
.tabs_all {
width: 28px;
height: 600px;
height: 500px;
box-sizing: border-box;
border: 2px solid #2f6b98;
border-radius: 5px;
@ -322,6 +883,7 @@ onUnmounted(() => {
box-sizing: border-box;
cursor: pointer;
}
.no_tabs:hover {
color: #40a9ff;
}
@ -333,10 +895,119 @@ onUnmounted(() => {
display: flex;
align-items: center;
justify-content: center;
position: relative;
/* 为empty-overlay提供定位上下文 */
.chart-container {
width: 100% !important;
height: 100% !important;
min-width: 368px;
/* 强制最小宽度 */
min-height: 600px;
/* 强制最小高度 */
}
.empty-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.9);
z-index: 10;
}
}
}
.modal-content {
padding: 20px;
.detail-info {
.info-header {
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 2px solid #e8e8e8;
h3 {
margin: 0 0 8px 0;
font-size: 20px;
color: #333;
font-weight: bold;
}
.time-info {
margin: 0;
font-size: 14px;
color: #666;
}
}
.info-body {
.info-item {
display: flex;
align-items: center;
margin-bottom: 16px;
padding: 12px 16px;
background: #f5f7fa;
border-radius: 4px;
.label {
font-size: 14px;
color: #666;
min-width: 140px;
}
.value {
font-size: 16px;
font-weight: bold;
&.current {
color: #4A8BC2;
}
&.last-year {
color: #9B59B6;
}
&.change {
&.positive {
color: #52c41a;
}
&.negative {
color: #ff4d4f;
}
&.neutral {
color: #666;
}
}
}
}
.custom-section {
margin-top: 24px;
padding: 16px;
background: #fafafa;
border-radius: 4px;
border: 1px solid #e8e8e8;
h4 {
margin: 0 0 12px 0;
font-size: 16px;
color: #333;
}
p {
margin: 0;
font-size: 14px;
color: #666;
line-height: 1.6;
}
}
}
}
}

View File

@ -473,8 +473,8 @@ const handleViewDetail = (record: any, type: string) => {
watch(
() => [formState.dataDimensionVal, formState.hydrodtin, formState.bldstt],
async () => {
// await fetchFacilityStats()
// handleSearch()
await fetchFacilityStats()
handleSearch()
}
)
@ -512,9 +512,25 @@ onMounted(async () => {
handleSearch()
})
//
const resetSearchState = () => {
//
formState.dataDimensionVal = props.BID || ''
formState.hydrodtin = props.res?.hydrodtin || ''
formState.bldstt = props.res?.bldstt || ''
formState.stnm = ''
// activeTabkey
activeTab.value = currentDwtp.value
//
tableRefs.value = {}
}
//
defineExpose({
handleSearch
handleSearch,
resetSearchState
})
</script>

View File

@ -20,10 +20,10 @@
</SidePanelItem>
<!-- 自定义弹框 -->
<a-modal v-model:open="modalVisible" title="设施类型及接入情况" width="1536px" :footer="null">
<a-modal v-model:open="modalVisible" title="设施类型及接入情况" width="1536px" :footer="null" @cancel="handleModalClose">
<div class="modal-content">
<DiwenshuijianhuansheshileixingzuchengjijieruqingkuangTwoLayers :datas="jiDiList" :BID="baseid"
<DiwenshuijianhuansheshileixingzuchengjijieruqingkuangTwoLayers ref="twoLayersRef" :datas="jiDiList" :BID="baseid"
:data="selectedItem" :res="res">
</DiwenshuijianhuansheshileixingzuchengjijieruqingkuangTwoLayers>
</div>
@ -149,6 +149,7 @@ const baseid = ref('')
//
const modalVisible = ref(false);
const selectedItem: any = ref<DataString | null>(null);
const twoLayersRef = ref();
const getListData = async () => {
@ -211,6 +212,14 @@ const imgclick = (item: DataString) => {
modalVisible.value = true;
}
//
const handleModalClose = () => {
//
if (twoLayersRef.value && twoLayersRef.value.resetSearchState) {
twoLayersRef.value.resetSearchState()
}
}
//
onMounted(() => {
//

View File

@ -58,6 +58,9 @@ const baseid: any = ref(null);
const loading = ref(false);
const showemit = ref(true);
// Xformatter
const xData = ref<any[]>([]);
//
const modalVisible = ref(false);
const modalData = ref<any>(null);
@ -359,12 +362,15 @@ const getEchartsData = async () => {
// sttp === "1" X
const stationData = data.filter((item: any) => item.sttp === "1")
const xData = stationData.map((item: any) => ({
const newXData = stationData.map((item: any) => ({
value: item.stnm,
stnm: item.stnm,
stcd: item.stcd //
}))
// xData
xData.value = newXData;
// sttp === "2"
const tempData = data.filter((item: any) => item.sttp === "2")
@ -393,19 +399,12 @@ const getEchartsData = async () => {
//
setTimeout(() => {
if (!chartInstance) {
initChart(xData, actualData, lastData, naturalData)
initChart(newXData, actualData, lastData, naturalData)
} else {
//
chartInstance.setOption({
xAxis: {
data: xData
},
series: [
{ data: actualData },
{ data: lastData },
{ data: naturalData }
]
})
// formatter 使
chartInstance.dispose()
chartInstance = null
initChart(newXData, actualData, lastData, naturalData)
}
//
setTimeout(() => {
@ -420,7 +419,7 @@ const getEchartsData = async () => {
}
}
const initChart = (xData: any[], actualData: any[], lastData: any[], naturalData: any[]) => {
const initChart = (newXData: any[], actualData: any[], lastData: any[], naturalData: any[]) => {
if (!chartRef.value) return
chartInstance = echarts.init(chartRef.value)
@ -438,7 +437,7 @@ const initChart = (xData: any[], actualData: any[], lastData: any[], naturalData
const options: any = {
noShowToolbox: true,
yAxisSplit: 5,
xData,
xData: newXData,
dataZoom: [
{
type: 'inside',
@ -454,7 +453,8 @@ const initChart = (xData: any[], actualData: any[], lastData: any[], naturalData
trigger: 'axis',
confine: true,
formatter: (params: any) => {
const label = xData.filter((item: any) => item.value === params[0].axisValueLabel)?.[0]?.stnm
// 使 xData.value
const label = xData.value.filter((item: any) => item.value === params[0].axisValueLabel)?.[0]?.stnm
let elm = ``
for (const item of params) {
const value = item.data?.value ?? item.value;
@ -498,10 +498,13 @@ const initChart = (xData: any[], actualData: any[], lastData: any[], naturalData
axisLabel: {
color: '#000000',
fontSize: 12,
interval: xData.length < 5 ? 0 : 2,
interval: xData.value.length < 5 ? 0 : 2,
rotate: 0,
formatter: (value: any) => {
const label = xData.filter((item: any) => item.value === value)?.[0]?.stnm
// 使 xData.value
const label = xData.value.filter((item: any) => item.value === value)?.[0]?.stnm
// undefined
if (!label) return '-'
return `{a|${label.substring(0, 6)}}` + (label.length > 6 ? '...\n{b|}' : '\n{b|}')
},
rich: {
@ -515,7 +518,7 @@ const initChart = (xData: any[], actualData: any[], lastData: any[], naturalData
}
}
},
data: xData,
data: xData.value,
splitLine: {
show: false
}

View File

@ -390,7 +390,7 @@ const getChartOption = () => {
params.forEach((item: any) => {
result += `<div style="display: flex; align-items: center; margin: 4px 0;">`;
result += `<span style="display: inline-block; width: 10px; height: 10px; border-radius: 50%; background-color: ${item.color}; margin-right: 8px;"></span>`;
const displayValue = item.value !== null && item.value !== undefined ? item.value : '-';
const displayValue = item.value !== null && item.value !== undefined ? item.value: '-';
result += `<span>${item.seriesName} ${displayValue}${unit}</span>`;
result += `</div>`;
});

View File

@ -9,20 +9,25 @@
<div class="search-form">
<a-space size="middle">
<div>选择水电站:</div>
<a-select v-model:value="searchData.stcd.dataDimensionData" placeholder="请选择水电站" style="width: 200px"
@change="handleHydropowerStationChange">
<a-select-option v-for="station in hydropowerStationList" :key="station.wbsCode"
:value="station.wbsCode">
{{ station.wbsName }}
</a-select-option>
</a-select>
<a-select v-model:value="searchData.stnm" placeholder=" " style="width: 200px" allow-clear
@change="handleStationChange">
<a-select-option v-for="station in stationDataList" :key="station.wbsCode" :value="station.stcd">
{{ station.stnm }}
</a-select-option>
</a-select>
<!-- <a-input v-model:value="searchData.stnm" placeholder="请输入测站名称" style="width: 200px" allow-clear /> -->
<a-select
v-model:value="searchData.stcd.dataDimensionData"
placeholder="请选择水电站"
style="width: 200px"
show-search
:filter-option="filterOption"
:options="hydropowerStationOptions"
@change="handleHydropowerStationChange"
/>
<a-select
v-model:value="searchData.stnm"
placeholder=" "
style="width: 200px"
allow-clear
show-search
:filter-option="filterOption"
:options="stationOptions"
@change="handleStationChange"
/>
<a-button type="primary" @click="handleSearch">查询</a-button>
<a-tooltip title="重置">
@ -90,6 +95,22 @@ const tableHeight = 'calc(48vh)'
//
const hydropowerStationList = ref<any[]>([])
const stationDataList: any = ref([])
// a-select options
const hydropowerStationOptions = computed(() => {
return hydropowerStationList.value.map(station => ({
label: station.wbsName,
value: station.wbsCode
}))
})
const stationOptions = computed(() => {
return stationDataList.value.map(station => ({
label: station.stnm,
value: station.stcd
}))
})
const searchData = ref<any>({
stcd: {
dataDimensionType: 'hyBase',
@ -227,14 +248,14 @@ const buildSearchFilter = () => {
})
}
// ID
if (searchData.value?.stcd?.stcdId) {
filters.push({
field: 'rstcd',
operator: 'eq',
value: searchData.value.stcd.stcdId
})
}
// // ID
// if (searchData.value?.stcd?.stcdId) {
// filters.push({
// field: 'rstcd',
// operator: 'eq',
// value: searchData.value.stcd.stcdId
// })
// }
//
if (searchData.value?.stnm) {
@ -293,6 +314,8 @@ const fetchData = async () => {
try {
const filter = buildSearchFilter()
const params = {
take: pagination.value.pageSize,
skip: pagination.value.current,
filter: filter,
select: [
'baseName',
@ -445,6 +468,11 @@ const getselectTwo = async (code: any) => {
}
// ==================== ====================
const filterOption = (input: string, option: any) => {
// 使 options option { label, value }
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
const handleHydropowerStationChange = (value: string) => {
console.log('【水电站选择变化】', value)
//

View File

@ -1,8 +1,10 @@
<!-- SidePanelItem.vue -->
<template>
<SidePanelItem title="水质监测工作开展情况">
<div class="facility-grid" >
<div v-for="facility in facilities" :key="facility.name" class="facility-card">
<a-spin :spinning="loading" tip="加载中...">
<div class="facility-grid">
<div v-for="facility in facilities" :key="facility.name" class="facility-card"
@click="handleFacilityClick(facility)">
<div style="width: 60px;height: 62px;display: flex;align-items: center;justify-content: center;">
<div class="facility-icon">
<i style="color: #fff;" :class="facility.icon" type="icon-shengtailiuliang2"></i>
@ -11,42 +13,249 @@
<div class="facility-info">
<div class="facility-name">{{ facility.name }}</div>
<div style="font-size: 16px;"> <span class="facility-count">{{ facility.count }}</span><span></span></div>
<div style="font-size: 16px;"> <span class="facility-count">{{ facility.count
}}</span><span></span></div>
</div>
</div>
</div>
</a-spin>
</SidePanelItem>
<!-- 弹框 -->
<a-modal v-model:open="modalVisible" :title="'水质监测工作开展情况'" :footer="null" width="1536px" @cancel="handleCloseModal">
<ShuiwenjiancegongzuoEJ v-if="currentFacility" :activeKey="currentFacility.key" :tabs="facilities"
:baseId="baseid" />
</a-modal>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { ref, onMounted, watch } from 'vue';
import SidePanelItem from '@/components/SidePanelItem/index.vue';
import { useJidiSelectEventStore } from "@/store/modules/jidiSelectEvent";
import { msstbprptGetKendoList } from '@/api/sz'
import ShuiwenjiancegongzuoEJ from "./shuiwenjiancegongzuoEJ.vue"
// 便
defineOptions({
name: 'shuizhijiancegongzuoQK'
});
const JidiSelectEventStore = useJidiSelectEventStore();
// loading
const loading = ref(false);
//
const facilities = ref([
{
name: '自建水质站',
count: 56,
icon: 'icon iconfont icon-qixidi'
name: '河道水质站',
count: 0,
icon: 'icon iconfont icon-qixidi',
key: '0'
},
{
icon: 'icon iconfont icon-yuleizengzhizhan',
name: '增殖站水质站',
count: '0',
key: '3'
},
{
name: '国家水质站',
count: 1722,
icon: 'icon iconfont icon-diwenshuijianhuan'
count: 0,
icon: 'icon iconfont icon-diwenshuijianhuan',
key: '1'
},
{
name: '人工水质监测断面',
count: 135,
icon: 'icon iconfont icon-shuiwen-line'
count: 0,
icon: 'icon iconfont icon-shuiwen-line',
key: '2'
},
]);
//
const modalVisible = ref(false);
const currentFacility = ref<any>(null);
const baseid = ref("")
//
const getDataList = async () => {
loading.value = true;
try {
let data1 = {
"filter": {
"logic": "and",
"filters": [
baseid.value != "all" ? {
"field": "baseId",
"operator": "eq",
"dataType": "string",
"value": "01"
} : null,
{
"field": "isDeleted",
"operator": "eq",
"value": 0
},
{
"field": "sttpCode",
"operator": "eq",
"value": "WQ"
},
{
"logic": "or",
"filters": [
{
"logic": "and",
"filters": [
{
"field": "mway",
"operator": "eq",
"value": 2
},
{
"field": "dtinType",
"operator": "eq",
"value": 0
}
]
},
{
"logic": "and",
"filters": [
{
"field": "mway",
"operator": "eq",
"value": 1
},
{
"field": "dtinType",
"operator": "eq",
"value": 2
}
]
},
{
"logic": "and",
"filters": [
{
"field": "mway",
"operator": "eq",
"value": 2
},
{
"field": "dtinType",
"operator": "eq",
"value": 1
}
]
}
]
}
].filter(Boolean)
},
"group": [
{
"dir": "asc",
"field": "dtinType"
}
]
}
let data2 = {
"filter": {
"logic": "and",
"filters": [
baseid.value != "all" ? {
"field": "baseId",
"operator": "eq",
"dataType": "string",
"value": "01"
} : null,
{
"field": "isDeleted",
"operator": "eq",
"value": 0
},
{
"field": "sttpCode",
"operator": "eq",
"value": "WQFB"
},
{
"filters": [
{
"logic": "and",
"filters": [
{
"field": "mway",
"operator": "eq",
"value": 2
},
{
"field": "dtinType",
"operator": "eq",
"value": 0
}
]
}
]
}
].filter(Boolean)
},
"group": [
{
"dir": "asc",
"field": "dtinType"
}
]
}
// const params = [data1, data2]
const res1 = await msstbprptGetKendoList(data1);
let finalData = facilities.value.map((item) => ({ ...item, count: 0 }))
if (res1.data) {
const { data } = res1
data.data.forEach((item: any, index: number) => {
const target = finalData.find((n) => n.key == item.key)
if (target) {
target.count = item.count
}
})
}
const res2 = await msstbprptGetKendoList(data2);
if (res2.data) {
const responseData = res2?.data?.data
const target1 = finalData.find((n) => n.key == '3')
if (target1) {
target1.count = responseData[0].count || 0
}
}
facilities.value = finalData
} catch (error) {
console.error('获取数据失败:', error);
} finally {
loading.value = false;
}
}
watch(
() => JidiSelectEventStore.selectedItem,
(newVal) => {
baseid.value = newVal.wbsCode;
getDataList()
},
{ deep: true, immediate: true }
);
//
const handleFacilityClick = (facility: any) => {
// console.log(facility);
currentFacility.value = facility;
modalVisible.value = true;
};
//
const handleCloseModal = () => {
modalVisible.value = false;
currentFacility.value = null;
};
//
onMounted(() => {

View File

@ -0,0 +1,636 @@
<template>
<div class="shuiwenjiancegongzwo-ej-container">
<!-- Tab切换 -->
<a-tabs v-model:activeKey="tabIndex" @change="handleTabChange">
<a-tab-pane v-for="tab in tabs" :key="tab.key" :tab="tab.name" />
</a-tabs>
<!-- 搜索表单 -->
<div class="search-form">
<a-space size="middle">
<div>选择水电站:</div>
<a-select
v-model:value="searchData.stcd.dataDimensionData"
placeholder="请选择水电站"
style="width: 200px"
show-search
:filter-option="filterOption"
:options="hydropowerStationOptions"
@change="handleHydropowerStationChange"
/>
<a-select
v-model:value="searchData.stnm"
placeholder=" "
style="width: 200px"
allow-clear
show-search
:filter-option="filterOption"
:options="stationOptions"
@change="handleStationChange"
/>
<!-- <a-input v-model:value="searchData.stnm" placeholder="请输入测站名称" style="width: 200px" allow-clear /> -->
<a-button type="primary" @click="handleSearch">查询</a-button>
<a-tooltip title="重置">
<a-button @click="handleReset">重置</a-button>
</a-tooltip>
</a-space>
</div>
<!-- 数据表格 -->
<a-table :columns="columns" :data-source="tableData" :loading="loading" :pagination="pagination"
:scroll="{ y: tableHeight }" row-key="stcd" @change="handleTableChange">
<template #bodyCell="{ column, record }">
<!-- 监测状态 -->
<template v-if="column.key === 'coenvwState'">
<a-tooltip placement="top">
<template #title>
<ol>
<li>最近1天有监测数据为在线否则为离线</li>
</ol>
</template>
<a-tag :color="record.coenvwState > 0 ? 'green' : '#999'">
{{ record.coenvwState > 0 ? '在线' : '离线' }}
</a-tag>
</a-tooltip>
</template>
<!-- 操作 -->
<template v-else-if="column.key === 'action'">
<a @click="handleViewDetail(record)" class="text_hocer">查看详情</a>
</template>
</template>
</a-table>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, watch, onMounted } from 'vue'
import { wbsbGetKendoList, getVmsstbprpt } from '@/api/sw'
import { vmsstbprptGetKendoList } from '@/api/sz'
import { useModelStore } from "@/store/modules/model";
const modelStore = useModelStore();
// ==================== Props ====================
const props = defineProps<{
baseId?: string
tabs?: any[]
activeKey?: string
}>()
// ==================== ====================
const tabIndex = ref(props.activeKey || '0')
const loading = ref(false)
const tableData = ref<any[]>([])
const pagination = ref({
current: 1,
pageSize: 20,
total: 0,
size: 'small',
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total: number) => `${total}`,
pageSizeOptions: ['10', '20', '50', '100']
})
const tableHeight = 'calc(48vh)'
//
const hydropowerStationList = ref<any[]>([])
const stationDataList: any = ref([])
// a-select options
const hydropowerStationOptions = computed(() => {
return hydropowerStationList.value.map(station => ({
label: station.wbsName,
value: station.wbsCode
}))
})
const stationOptions = computed(() => {
return stationDataList.value.map(station => ({
label: station.stnm,
value: station.stcd
}))
})
const searchData = ref<any>({
stcd: {
dataDimensionType: 'hyBase',
stcdId: '',
dataDimensionData: props.baseId || 'all'
},
stnm: null
})
// ==================== ====================
const getRowSpanInfo = (dataIndex: string) => {
const spanMap = new Map()
if (!tableData.value || tableData.value.length === 0) {
return spanMap
}
let currentGroupStart = 0
let currentValue = tableData.value[0][dataIndex]
for (let i = 0; i < tableData.value.length; i++) {
const value = tableData.value[i][dataIndex]
if (value !== currentValue) {
//
spanMap.set(currentGroupStart, i - currentGroupStart)
currentGroupStart = i
currentValue = value
}
}
//
spanMap.set(currentGroupStart, tableData.value.length - currentGroupStart)
return spanMap
}
// ==================== Props ====================
// const baseId = ref('')
watch(
() => props.baseId,
(newVal) => {
if (newVal && newVal !== searchData.value.stcd.dataDimensionData) {
searchData.value.stcd.dataDimensionData = newVal
fetchData()
}
}
)
watch(
() => props.activeKey,
(newVal) => {
if (newVal && newVal !== tabIndex.value) {
tabIndex.value = newVal
fetchData()
}
}
)
// ==================== ====================
const columns = computed(() => {
const baseColumns = [
{
title: '所属基地',
dataIndex: 'baseName',
key: 'baseName',
width: 150,
customCell: (record: any, index: number) => {
const spanMap = getRowSpanInfo('baseName')
const rowSpan = spanMap.get(index)
if (rowSpan === undefined) {
//
return { rowSpan: 0 }
}
//
return { rowSpan }
}
},
{
title: '测站名称',
dataIndex: 'stnm',
key: 'stnm',
width: 150
},
{
title: '电站',
dataIndex: 'ennm',
key: 'ennm',
width: 150
},
// {
// title: '',
// dataIndex: 'jcdt',
// key: 'jcdt',
// width: 120
// },
{
title: '监测指标',
dataIndex: 'stindx',
key: 'stindx',
width: 150
},
// {
// title: '',
// key: 'coenvwState',
// dataIndex: 'coenvwState',
// width: 100,
// align: 'center' as const
// },
{
title: '操作',
key: 'action',
width: 100,
align: 'center' as const,
fixed: 'right' as const
}
]
return baseColumns.filter(Boolean)
})
// ==================== ====================
const buildSearchFilter = () => {
const filters: any[] = []
// ID
if (searchData.value?.stcd?.dataDimensionData && searchData.value.stcd.dataDimensionData !== 'all') {
filters.push({
field: 'baseId',
operator: 'eq',
value: searchData.value.stcd.dataDimensionData
})
}
// ID
if (searchData.value?.stcd?.stcdId) {
filters.push({
field: 'rstcd',
operator: 'eq',
value: searchData.value.stcd.stcdId
})
}
//
if (searchData.value?.stnm) {
filters.push({
field: 'rstcd',
operator: 'eq',
value: searchData.value.stnm
})
}
// tabIndex
if (tabIndex.value === '3') {
filters.push({
field: 'sttpCode',
operator: 'eq',
dataType: 'string',
value: 'WQFB'
})
} else {
filters.push({
field: 'sttpCode',
operator: 'eq',
dataType: 'string',
value: 'WQ'
})
}
// Tab - React
switch (tabIndex.value) {
case '0': // -
filters.push(
{
field: 'mway',
operator: 'eq',
dataType: 'string',
value: 2
},
{
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: 0
}
)
break
case '1': // -
filters.push(
{
field: 'mway',
operator: 'eq',
dataType: 'string',
value: 2
},
{
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: 1
}
)
break
case '2': //
filters.push(
{
field: 'mway',
operator: 'eq',
dataType: 'string',
value: 1
},
{
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: 2
}
)
break
case '3': //
filters.push(
{
field: 'mway',
operator: 'eq',
dataType: 'string',
value: 2
},
{
field: 'dtinType',
operator: 'eq',
dataType: 'string',
value: 0
}
)
break
}
return {
logic: 'and',
filters: filters.filter((f) => f.value !== undefined && f.value !== null && f.value !== '')
}
}
// ==================== API ====================
const fetchData = async () => {
loading.value = true
try {
const filter = buildSearchFilter()
const params = {
take: pagination.value.pageSize,
skip: pagination.value.current,
filter: filter,
select: [
'baseName',
'stnm',
'ennm',
'jcdt',
'stindx',
'coenvwState',
'sttpCode',
'stcd',
'rstcd',
'stCode',
'stName',
'dvtp'
],
sort: [
{ field: 'baseStepSort', dir: 'asc' },
{ field: 'hbrvcd', dir: 'asc' },
{ field: 'rstcdStepSort', dir: 'asc' },
{ field: 'siteStepSort', dir: 'asc' }
],
groupResultFlat:false
}
console.log('【请求参数】', params)
const res = await vmsstbprptGetKendoList(params)
console.log('【响应数据】', res)
//
let total = res.data.total
let records = res?.data?.data || res?.data
// if (Array.isArray(res?.data?.data)) {
// records = res.data.data
// total = res.data.data.length
// }
tableData.value = records || []
pagination.value.total = total
loading.value = false
} catch (error) {
console.error('获取水文监测数据失败:', error)
tableData.value = []
pagination.value.total = 0
} finally {
loading.value = false
}
}
const getselect = async () => {
try {
const params = {
"filter": {
"logic": "and",
"filters": [
{
"field": "wbsType",
"operator": "eq",
"dataType": "string",
"value": "PSB"
},
{
"field": "treeLevel",
"operator": "eq",
"dataType": "string",
"value": "1"
}
]
},
"sort": [
{
"field": "orderIndex",
"dir": "asc"
}
]
}
const res = await wbsbGetKendoList(params)
console.log('【水电站列表】', res)
//
if (res?.data?.data && Array.isArray(res.data.data)) {
hydropowerStationList.value = res.data.data
console.log('站点数据列表', stationDataList.value)
getselectTwo(searchData.value.stcd.dataDimensionData)
console.log('【水电站数量】', hydropowerStationList.value.length)
} else {
console.warn('【警告】未获取到有效的水电站数据')
hydropowerStationList.value = []
}
} catch (error) {
console.error('【错误】获取水电站列表失败:', error)
hydropowerStationList.value = []
}
}
const getselectTwo = async (code: any) => {
console.log('站点数据列表')
// Tab
// const sttpCodeValue = tabIndex.value === '3' ? 'WQFB' : 'WQ'
const params = {
"filter": {
"logic": "and",
"filters": [
code != 'all' ? {
"field": "baseId",
"operator": "contains",
"dataType": "string",
"value": code
} : null,
{
"field": "sttpCode",
"operator": "eq",
"dataType": "string",
"value": "ENG"
}
].filter(Boolean)
},
"sort": code !== 'all'
? [
{
"field": "baseId",
"dir": "asc"
},
{
"field": "rvcdStepSort",
"dir": "asc"
},
{
"field": "rstcdStepSort",
"dir": "asc"
},
{
"field": "siteStepSort",
"dir": "asc"
}
]
: [
{
"field": "ttpwr",
"dir": "desc"
}
],
"select": [
"stcd",
"stnm"
]
}
const res = await getVmsstbprpt(params)
// console.log('', res)
console.log('站点数据列表', res?.data?.data)
stationDataList.value = res?.data?.data || res?.data
}
// ==================== ====================
const filterOption = (input: string, option: any) => {
// 使 options option { label, value }
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
const handleHydropowerStationChange = (value: string) => {
console.log('【水电站选择变化】', value)
//
searchData.value.stnm = null
searchData.value.stcd.stcdId = ''
//
getselectTwo(value)
//
// pagination.value.current = 1
// fetchData()
}
const handleStationChange = (value: string | undefined) => {
console.log('【测站选择变化】', value)
// ID
if (value) {
searchData.value.stcd.stcdId = value
} else {
searchData.value.stcd.stcdId = ''
}
}
const handleSearch = () => {
console.log('【搜索】', searchData.value)
pagination.value.current = 1
fetchData()
}
const handleReset = () => {
console.log('【重置】')
searchData.value = {
stcd: {
dataDimensionType: 'hyBase',
stcdId: '',
dataDimensionData: props.baseId || 'all'
},
stnm: null
}
pagination.value.current = 1
fetchData()
}
const handleTabChange = (key: string) => {
console.log('【Tab切换】', key)
tabIndex.value = key
pagination.value.current = 1
fetchData()
}
const handleTableChange = (pag: any) => {
pagination.value.current = pag.current
pagination.value.pageSize = pag.pageSize
fetchData()
}
const handleViewDetail = (record: any) => {
if (record) {
modelStore.modalVisible = true;
modelStore.params.sttp = "fh_wq_point";
modelStore.title = record.stnm + "详情信息";
// modelStore.isBasicEdit = true;
modelStore.params.stcd = record.stcd;
modelStore.modalVisible = true;
}
// TODO:
}
// ==================== ====================
onMounted(() => {
console.log('【组件挂载】水文监测工作二级页面已加载')
fetchData()
getselect()
})
</script>
<style scoped lang="scss">
.shuiwenjiancegongzwo-ej-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
background-color: #ffffff;
box-sizing: border-box;
.search-form {
margin-bottom: 16px;
border-radius: 4px;
}
:deep(.ant-table-wrapper) {
flex: 1;
overflow: hidden;
}
}
.text_hocer {
color: #2f6b98;
}
.text_hocer:hover {
color: #40a9ff;
}
</style>

View File

@ -1,22 +1,37 @@
<!-- SidePanelItem.vue -->
<template>
<SidePanelItem title="沿程水质变化" :iconmap="iconmap" :datetimePicker="datetimePicker">
<div class="chart-container" ref="chartRef"></div>
<SidePanelItem title="沿程水质变化" :iconmap="iconmap" :select="select" :datetimePicker="datetimePicker"
@update-values="handlePanelChange1">
<div class="chart-wrapper">
<a-spin :spinning="loading">
<!-- 始终渲染图表容器确保有固定宽高 -->
<div ref="chartRef" class="chart-container"></div>
<!-- 无数据时显示Empty但不影响容器尺寸 -->
<div v-if="!loading && !hasData" class="empty-overlay">
<a-empty description="暂无数据" />
</div>
</a-spin>
</div>
</SidePanelItem>
</template>
<script lang="ts" setup>
import { ref, onMounted, onBeforeUnmount, nextTick } from 'vue';
import { ref, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
import * as echarts from 'echarts';
import type { EChartsOption } from 'echarts';
import SidePanelItem from '@/components/SidePanelItem/index.vue';
import { qgcGetKendoListCust, wbsbGetKendoList } from '@/api/sz'
import { useJidiSelectEventStore } from "@/store/modules/jidiSelectEvent";
import { useModelStore } from "@/store/modules/model";
// 便
defineOptions({
name: 'waterQuality'
});
const modelStore = useModelStore();
const JidiSelectEventStore = useJidiSelectEventStore();
const iconmap = ref({
show: true,
value: '注最新数据时间为2026-05-14 2300',
@ -26,6 +41,10 @@ const iconmap = ref({
const chartRef = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
// Loading
const loading = ref(false);
const hasData = ref(true); // true initChart 使 mockData
// 8:00
const now = new Date();
const todayAtEightAM = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 8, 0, 0);
@ -38,6 +57,13 @@ const datetimePicker = ref({
picker: 'date',
options: []
});
const select = ref({
show: true,
value: '',
options: [],
picker: undefined,
format: undefined,
});
// ==================== 2====================
const visibleSeriesQueue = ref<string[]>([]);
@ -90,12 +116,22 @@ const getChartOption = (): EChartsOption => {
}
// X
const xData = data.map((item, index) => ({
value: item.stnm,
const xData = data.map((item, index) => {
// """"
let stnm = item.stnm || '-';
if (stnm.includes('出库水质监测站')) {
stnm = stnm.replace('出库水质监测站', '');
} else if (stnm.includes('坝上水质监测站')) {
stnm = stnm.replace('坝上水质监测站', '');
}
return {
value: stnm,
textStyle: {
padding: index % 2 !== 0 ? [16, 0, 0, 0] : 0
}
}));
};
});
// 线
const markLineData: any[] = [];
@ -144,16 +180,43 @@ const getChartOption = (): EChartsOption => {
};
});
// Y使
const calculateYAxisRange = (configIndex: number) => {
if (!selectedState[indicatorConfig[configIndex].name]) {
return null;
}
const values = data
.map(item => item[indicatorConfig[configIndex].key as keyof typeof item])
.filter((val): val is number => typeof val === 'number' && !isNaN(val));
if (values.length === 0) {
return { min: 0, max: 10 };
}
const min = Math.min(...values);
const max = Math.max(...values);
// Y使-1+1
return {
min: Math.floor(min) - 1,
max: Math.ceil(max) + 1
};
};
// Y1N
const yAxisData = indicatorConfig.map((config, index) => {
const isLeft = index === 0;
const offset = index < 2 ? 0 : (index - 1) * 60;
const range = calculateYAxisRange(index);
return {
type: 'value' as const,
name: config.name,
position: isLeft ? ('left' as const) : ('right' as const),
offset,
min: range ? range.min : undefined,
max: range ? range.max : undefined,
axisLine: {
show: true,
lineStyle: {
@ -163,8 +226,8 @@ const getChartOption = (): EChartsOption => {
axisLabel: {
color: config.color,
formatter: (value: number) => {
const decimalCount = (value.toString().split('.')[1] || '').length;
return decimalCount >= 2 ? value.toFixed(1) : value;
// Y使
return Math.round(value).toString();
}
},
splitLine: {
@ -190,8 +253,10 @@ const getChartOption = (): EChartsOption => {
formatter: (params: any) => {
if (!params || params.length === 0) return '';
//
let result = `<div style="font-weight: bold; margin-bottom: 8px;">${datetimePicker.value.value}</div>`;
const tm = data.find(item => item.stnm === params[0].name)?.tm;
let result = tm ? `${new Date(tm).toLocaleString('zh-CN')}<br/>` : '';
result += `${params[0].name}<br/>`;
params.forEach((param: any) => {
@ -199,16 +264,12 @@ const getChartOption = (): EChartsOption => {
const unit = config?.unit || '';
if (param.value !== null && param.value !== undefined) {
//
// 线
const numValue = Number(param.value);
let displayValue = param.value;
// 2
if (!isNaN(numValue)) {
const decimalPart = param.value.toString().split('.')[1];
if (decimalPart && decimalPart.length > 2) {
displayValue = numValue.toFixed(2);
}
displayValue = numValue.toFixed(1);
}
result += `${param.marker}${param.seriesName}${displayValue}${unit}<br/>`;
@ -231,6 +292,18 @@ const getChartOption = (): EChartsOption => {
fontSize: 14
}
},
// dataZoom X
dataZoom: [
{
type: 'inside', //
xAxisIndex: 0, // X
start: 0, //
end: 100,
zoomOnMouseWheel: true, //
moveOnMouseMove: true, //
filterMode: 'filter' //
}
],
grid: {
top: 60,
bottom: 50,
@ -337,6 +410,24 @@ const handleLegendSelectChanged = (params: any) => {
}
};
// ==================== ====================
const handleDataPointClick = (params: any) => {
if (!params || !params.dataIndex) return;
//
const dataIndex = params.dataIndex;
const stationData = mockData.value[dataIndex];
if (stationData && stationData.stcd) {
modelStore.modalVisible = true;
modelStore.params.sttp = "fh_wq_point";
modelStore.title = stationData.stnm + "详情信息";
// modelStore.isBasicEdit = true;
modelStore.params.stcd = stationData.stcd;
}
};
// ==================== Y ====================
const yAxisShowDynamic = (selected: Record<string, boolean>, options: any) => {
const allShow = options.yAxis?.filter((item: any) => item.show);
@ -421,8 +512,20 @@ const initChart = async () => {
const rect = chartRef.value.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) {
console.warn('图表容器尺寸为0等待渲染...');
await new Promise(resolve => setTimeout(resolve, 50));
return initChart();
// 使 requestAnimationFrame
return new Promise((resolve) => {
requestAnimationFrame(() => {
setTimeout(() => {
initChart().then(resolve);
}, 50);
});
});
}
//
if (chartInstance) {
chartInstance.dispose();
chartInstance = null;
}
//
@ -439,6 +542,9 @@ const initChart = async () => {
//
chartInstance.on('legendselectchanged', handleLegendSelectChanged);
//
chartInstance.on('click', handleDataPointClick);
// resize
setTimeout(() => {
chartInstance?.resize();
@ -468,16 +574,328 @@ onBeforeUnmount(() => {
if (chartInstance) {
chartInstance.off('legendselectchanged', handleLegendSelectChanged);
chartInstance.off('click', handleDataPointClick);
chartInstance.dispose();
chartInstance = null;
}
});
//
const getecharts = async () => {
if (!select.value.value) {
console.warn('选择器值为空,无法获取图表数据');
loading.value = false;
hasData.value = false;
chartInstance?.clear();
return;
}
console.log('开始获取图表数据select.value:', select.value.value);
// loading
loading.value = true;
hasData.value = false;
//
if (!chartInstance) {
console.log('图表实例不存在,重新初始化...');
await nextTick();
await initChart();
//
await new Promise(resolve => setTimeout(resolve, 100));
}
let params = {
"filter": {
"logic": "and",
"filters": [
{
"field": "baseId",
"operator": "eq",
"dataType": "string",
"value": wbsCode.value
},
{
"field": "rvcd",
"operator": "eq",
"dataType": "string",
"value": select.value.value
},
{
"field": "tm",
"operator": "gte",
"dataType": "date",
"value": getStartTime()
},
{
"field": "tm",
"operator": "lte",
"dataType": "date",
"value": getEndTime()
}
]
},
"sort": [
{
"field": "sort",
"dir": "asc"
}
]
}
try {
console.log('请求参数:', params);
let res = await qgcGetKendoListCust(params);
console.log('接口返回数据:', res);
// -
let apiData: any[] = [];
if (res && res.data) {
// 1: res.data.data
if (Array.isArray(res.data.data)) {
apiData = res.data.data;
}
// 2: res.data.data.data
else if (res.data.data && Array.isArray(res.data.data.data)) {
apiData = res.data.data.data;
}
// 3: res.data
else if (Array.isArray(res.data)) {
apiData = res.data;
}
}
console.log('原始数据条数:', apiData.length);
// sttp === 'WQ'sort
const filteredData = apiData
.filter((item: any) => item.sttp === 'WQ')
.sort((a: any, b: any) => {
// sort使
return (a.sort || 0) - (b.sort || 0);
});
console.log('过滤后水质数据条数:', filteredData.length);
//
const chartData = filteredData.map((item: any, index: number) => {
// ""
let stnm = item.stnm || '-';
if (stnm.includes('出库水质站')) {
stnm = stnm.replace('出库水质站', '');
}
return {
stnm: stnm,
stcd: item.stcd || '',
type: item.rstcd ? '1' : '0', // rstcd
tm: item.tm || '',
SORT: index + 1,
ph: item.ph != null ? Number(item.ph) : null,
dox: item.dox != null ? Number(item.dox) : null,
codmn: item.codmn != null ? Number(item.codmn) : null,
nh3n: item.nh3n != null ? Number(item.nh3n) : null,
tp: item.tp != null ? Number(item.tp) : null,
tn: item.tn != null ? Number(item.tn) : null
};
});
//
mockData.value = chartData;
//
hasData.value = chartData.length > 0;
console.log('hasData 设置为:', hasData.value);
// - 使 nextTick DOM
await nextTick();
if (chartInstance && hasData.value) {
// 使 requestAnimationFrame
requestAnimationFrame(() => {
const option = getChartOption();
chartInstance?.setOption(option, true);
chartInstance?.resize();
console.log('图表数据已更新,共', chartData.length, '个站点');
});
} else if (!hasData.value) {
//
console.log('无数据,清空图表');
chartInstance?.clear();
}
} catch (error) {
console.error('获取图表数据失败:', error);
hasData.value = false;
} finally {
// loading - 使 nextTick tick
await nextTick();
console.log('关闭 loading 状态');
loading.value = false;
}
}
//
const getStartTime = () => {
const currentDate = new Date(datetimePicker.value.value);
const oneMonthAgo = new Date(currentDate);
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
const year = oneMonthAgo.getFullYear();
const month = String(oneMonthAgo.getMonth() + 1).padStart(2, '0');
const day = String(oneMonthAgo.getDate()).padStart(2, '0');
const hours = String(oneMonthAgo.getHours()).padStart(2, '0');
const minutes = String(oneMonthAgo.getMinutes()).padStart(2, '0');
const seconds = String(oneMonthAgo.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
// 23:59:59
const getEndTime = () => {
const currentDate = new Date(datetimePicker.value.value);
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
const day = String(currentDate.getDate()).padStart(2, '0');
return `${year}-${month}-${day} 23:59:59`;
};
//
const getSelect = async () => {
if (!wbsCode.value) {
console.warn('wbsCode 为空,无法获取河段数据');
return;
}
let params = {
"filter": {
"logic": "and",
"filters": [
{
"field": "objId",
"operator": "eq",
"dataType": "string",
"value": wbsCode.value
},
{
"field": "wbsType",
"operator": "eq",
"dataType": "string",
"value": "PSB_RVCD"
}
]
},
"group": [
{
"dir": "asc",
"field": "orderIndex"
},
{
"dir": "des",
"field": "wbsCode"
},
{
"dir": "des",
"field": "wbsName"
}
],
"groupResultFlat": "true"
}
try {
let res = await wbsbGetKendoList(params);
// -
let data;
if (res && res.data && res.data.data) {
// res.data.data 使
if (Array.isArray(res.data.data)) {
data = res.data.data;
}
// res.data.data data 使 res.data.data.data
else if (res.data.data.data && Array.isArray(res.data.data.data)) {
data = res.data.data.data;
} else {
console.warn('无法解析河段数据:', res);
return;
}
} else {
console.warn('未获取到河段数据');
return;
}
if (data && data.length > 0) {
select.value.value = data[0].wbsCode;
select.value.options = data.map(item => {
return {
value: item.wbsCode,
label: item.wbsName
};
});
//
await nextTick();
getecharts();
} else {
console.warn('河段数据为空');
select.value.value = '';
select.value.options = [];
hasData.value = false;
}
} catch (error) {
console.error('获取河段数据失败:', error);
}
}
//
const handlePanelChange1 = async (data) => {
console.log('当前所有控件状态:', data);
//
if (data.datetime || data.select) {
getecharts()
}
}
const wbsCode = ref('');
watch(
() => JidiSelectEventStore.selectedItem,
(newVal) => {
console.log(newVal);
wbsCode.value = newVal.wbsCode;
getSelect()
},
{ deep: true, immediate: true }
);
</script>
<style lang="scss" scoped>
.chart-container {
.chart-wrapper {
width: 100%;
height: 280px;
min-height: 231px;
position: relative;
/* 为empty-overlay提供定位上下文 */
.chart-container {
width: 100% !important;
height: 100% !important;
min-width: 100%;
min-height: 280px;
}
.empty-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.9);
z-index: 10;
}
}
</style>

View File

@ -199,9 +199,11 @@ const initChart = () => {
formatter: (params: any) => {
if (params && params.length > 0) {
const data = params[0];
// null
if (data.value !== null && data.value !== undefined) {
// 线 `-`
if (data.value != null) {
return `${currentTime.value}<br/>${data.name}${data.value}°C`;
} else {
return `${currentTime.value}<br/>${data.name}-`;
}
}
return "";
@ -288,6 +290,7 @@ const initChart = () => {
smooth: true,
symbol: "circle",
symbolSize: 6,
connectNulls: true, // 线线
lineStyle: {
color: "#6ca4f7",
width: 2,
@ -347,8 +350,8 @@ const init = async () => {
logic: "and",
filters: [
{ field: "rvcd", operator: "eq", dataType: "string", value: paramsOne.rvcd },
{ field: "tm", operator: "gte", dataType: "date", value: paramsOne.tm[0] },
{ field: "tm", operator: "lte", dataType: "date", value: paramsOne.tm[1] },
{ field: "tm", operator: "gte", dataType: "date", value: paramsOne.tm[1] },
{ field: "tm", operator: "lte", dataType: "date", value: paramsOne.tm[0] },
],
},
sort: [{ field: "sort", dir: "asc" }],

View File

@ -31,7 +31,7 @@ service.interceptors.request.use(
config.headers._sysid = '10EC2E0B-AEA9-4757-83A2-201BA1BC54E9';
config.headers.authorization =
'bearer a385ef90-a17d-429f-817f-7d961594020c';
'bearer 3f010383-deb5-464c-9198-b42af9c5c839';
config.baseURL = '/';
} else {
const user = useUserStoreHook();

View File

@ -12,9 +12,10 @@ watch(
() => JidiSelectEventStore.selectedItem,
(newVal) => {
console.log(newVal);
// debugger
wbsCode.value = newVal.wbsCode;
},
{ deep: true }
{ deep: true, immediate: true }
);
</script>