WholeProcessPlatform/frontend/src/modules/shuishengshengtaijiance/index.vue

402 lines
8.9 KiB
Vue
Raw Normal View History

2026-05-12 08:47:27 +08:00
<!-- SidePanelItem.vue -->
<template>
2026-06-26 17:52:57 +08:00
<SidePanelItem
title="水生生态调查情况"
:select="select"
:datetimePicker="datetimePicker"
@update-values="handlePanelChange"
>
<a-spin :spinning="dataLoading" tip="加载中...">
<div class="facility-grid">
<div
v-for="facility in facilities"
:key="facility.name"
class="facility-card"
@click="handleCardClick"
>
<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>
2026-05-12 08:47:27 +08:00
</div>
2026-06-26 17:52:57 +08:00
</div>
<div class="facility-info">
<div class="facility-name">{{ facility.name }}</div>
<div style="font-size: 16px">
<span class="facility-count">{{ facility.count }}</span>
<span>{{ facility.unit }}</span>
</div>
</div>
2026-05-12 08:47:27 +08:00
</div>
2026-06-26 17:52:57 +08:00
</div>
</a-spin>
</SidePanelItem>
<!-- 水生生态调查概况弹框 -->
<a-modal
v-model:open="modalVisible"
title="水生生态调查概况"
width="1536px"
:footer="null"
@cancel="handleModalClose"
>
<SsstdcgkTk
v-if="modalVisible"
:selectDateTime="datetimePicker.value"
:all="true"
/>
</a-modal>
2026-05-12 08:47:27 +08:00
</template>
<script lang="ts" setup>
2026-06-26 17:52:57 +08:00
import { ref, watch } from 'vue';
import { useJidiSelectEventStore } from '@/store/modules/jidiSelectEvent';
2026-05-12 08:47:27 +08:00
import SidePanelItem from '@/components/SidePanelItem/index.vue';
2026-06-26 17:52:57 +08:00
import SsstdcgkTk from './SsstdcgkTk.vue';
import { wbsbGetKendoList, getDftYear, getWeFisht } from '@/api/stdc';
import moment from 'moment';
import { Label } from 'cesium';
import { useDraggable } from '@/utils/drag';
2026-05-12 08:47:27 +08:00
// 定义组件名
defineOptions({
2026-06-26 17:52:57 +08:00
name: 'shuishengshengtaijiance'
2026-05-12 08:47:27 +08:00
});
2026-06-26 17:52:57 +08:00
const JidiSelectEventStore = useJidiSelectEventStore();
const baseid = ref('');
const dataLoading = ref(false);
// ==================== 弹框状态 ====================
const modalVisible = ref(false);
useDraggable(modalVisible, { boundary: true, resetOnOpen: true });
2026-06-26 17:52:57 +08:00
// ==================== 响应式变量定义 ====================
// 选择器配置
2026-05-12 08:47:27 +08:00
const select = ref({
2026-06-26 17:52:57 +08:00
show: true,
value: undefined,
options: [],
picker: undefined,
format: undefined,
width: '120px'
2026-05-12 08:47:27 +08:00
});
// 日期选择器配置
const datetimePicker = ref({
2026-06-26 17:52:57 +08:00
show: true,
value: '',
format: 'YYYY',
picker: 'year' as const,
options: []
2026-05-12 08:47:27 +08:00
});
const facilities = ref([
2026-06-26 17:52:57 +08:00
{
name: '水生态调查断面',
count: 0,
unit: '个',
icon: 'icon iconfont icon-liuliangjiancezhan'
},
{
name: '调查鱼类统计',
count: 0,
unit: '种',
icon: 'icon iconfont icon-yuleizengzhizhan'
}
]);
// ==================== 事件处理 ====================
const handlePanelChange = (data: any) => {
console.log('当前所有控件状态:', data);
if (data.select) {
select.value.value = data.select;
}
if (data.datetime) {
datetimePicker.value.value = data.datetime;
}
// 选择器或日期变化时,重新获取统计数据
getCardData();
};
const handleCardClick = () => {
console.log('卡片被点击,准备打开弹框');
console.log('modalVisible:', datetimePicker.value.value);
modalVisible.value = true;
console.log('modalVisible:', modalVisible.value);
};
const handleModalClose = () => {
modalVisible.value = false;
};
// ==================== 获取默认年份 ====================
const getDefaultYear = async () => {
if (!baseid.value) return;
try {
// const params = {
// filter: { baseId: baseid.value },
// group: [{ dir: 'des', field: 'yr' }]
// };
let params = {
filter: {
logic: 'and',
filters: [
baseid.value != 'all'
? {
field: 'baseId',
operator: 'eq',
dataType: 'string',
value: baseid.value
}
: null
].filter(Boolean)
},
group: [
{
dir: 'des',
field: 'yr'
}
]
};
const res = await getDftYear(params);
const data = res?.data?.data?.[0] || {};
const allYears = Object.values(data);
if (allYears?.length) {
const last = (allYears as any[]).flat().sort().pop();
datetimePicker.value.value = last;
} else {
datetimePicker.value.value = moment().format('YYYY');
}
// 获取统计数据
getCardData();
} catch (error) {
console.error('获取默认年份失败:', error);
datetimePicker.value.value = moment().format('YYYY');
getCardData();
}
};
// ==================== 获取卡片统计数据 ====================
const getCardData = async () => {
if (!datetimePicker.value.value) return;
dataLoading.value = true;
try {
const filters: any[] = [
{
field: 'yr',
operator: 'eq',
dataType: 'string',
value: moment(datetimePicker.value.value).format('YYYY')
}
];
if (baseid.value && baseid.value !== 'all') {
filters.push({
field: 'baseId',
operator: 'eq',
dataType: 'string',
value: baseid.value
});
}
if (select.value.value) {
filters.push({
field: 'hbrvcd',
operator: 'eq',
dataType: 'string',
value: select.value.value
});
}
const params = {
filter: {
logic: 'and',
filters
},
group: [],
groupResultFlat: true
};
const res = await getWeFisht(params);
const data = res?.data?.data?.[0];
facilities.value = [
{
2026-05-12 08:47:27 +08:00
name: '水生态调查断面',
2026-06-26 17:52:57 +08:00
count: data?.stcdCount ?? 0,
unit: '个',
2026-05-12 08:47:27 +08:00
icon: 'icon iconfont icon-liuliangjiancezhan'
2026-06-26 17:52:57 +08:00
},
{
2026-05-12 08:47:27 +08:00
name: '调查鱼类统计',
2026-06-26 17:52:57 +08:00
count: data?.ftpCount ?? 0,
unit: '种',
2026-05-12 08:47:27 +08:00
icon: 'icon iconfont icon-yuleizengzhizhan'
2026-06-26 17:52:57 +08:00
}
];
} catch (error) {
console.error('获取统计数据失败:', error);
facilities.value = [
{
name: '水生态调查断面',
count: 0,
unit: '个',
icon: 'icon iconfont icon-liuliangjiancezhan'
},
{
name: '调查鱼类统计',
count: 0,
unit: '种',
icon: 'icon iconfont icon-yuleizengzhizhan'
}
];
} finally {
dataLoading.value = false;
}
};
2026-05-12 08:47:27 +08:00
2026-06-26 17:52:57 +08:00
// ==================== 获取选择器数据 ====================
const getSelectData = async () => {
let params = {
filter: {
logic: 'and',
filters: [
{
field: 'wbsType',
operator: 'eq',
value: 'PSB_RVCD'
},
baseid.value != 'all'
? {
field: 'objId',
operator: 'eq',
value: '水生生态调查情况'
}
: null
].filter(Boolean)
},
group: [
{
dir: 'asc',
field: 'orderIndex'
},
{
dir: 'asc',
field: 'wbsCode'
},
{
dir: 'asc',
field: 'wbsName'
},
{
dir: 'asc',
field: 'objid'
}
],
groupResultFlat: true
};
const res = await wbsbGetKendoList(params);
let data = res?.data?.data;
select.value.options = data.map((item: any) => {
return {
value: item.wbsCode,
label: item.wbsName
};
});
};
2026-05-12 08:47:27 +08:00
2026-06-26 17:52:57 +08:00
// ==================== 监听基地变化 ====================
watch(
() => JidiSelectEventStore.selectedItem,
async newVal => {
if (newVal && newVal.wbsCode) {
baseid.value = newVal.wbsCode;
getSelectData();
getDefaultYear();
}
},
{ deep: true, immediate: true }
);
2026-05-12 08:47:27 +08:00
</script>
<style lang="scss" scoped>
.facility-grid {
2026-06-26 17:52:57 +08:00
width: 406px;
flex-flow: wrap;
display: flex;
justify-content: space-between;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji,
Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
2026-05-12 08:47:27 +08:00
}
.facility-card {
2026-06-26 17:52:57 +08:00
width: 200px;
height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
margin: 4px 0px;
background: #fff;
border: 1px solid rgb(229, 236, 245);
border-radius: 2px;
transition: all 0.3s;
cursor: pointer;
box-sizing: border-box;
2026-05-12 08:47:27 +08:00
}
.facility-icon {
2026-06-26 17:52:57 +08:00
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
// margin-right: 8px;
background: #2f6b98;
border-radius: 50%;
.anticon {
font-size: 24px;
color: #fff;
}
2026-05-12 08:47:27 +08:00
}
.facility-info {
2026-06-26 17:52:57 +08:00
flex: 1;
2026-05-12 08:47:27 +08:00
}
.facility-name {
2026-06-26 17:52:57 +08:00
font-size: 16px;
color: #333;
// margin-bottom: 4px;
// font-weight: 500;
2026-05-12 08:47:27 +08:00
}
.facility-count {
2026-06-26 17:52:57 +08:00
font-size: 18px;
color: #2f6b98;
// font-weight: 600;
}
:deep(.ant-spin-nested-loading) {
min-height: 72px;
2026-05-12 08:47:27 +08:00
}
2026-06-26 17:52:57 +08:00
</style>