第一步:将列表数据全部显示
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<div class="table-box">
|
<div class="table-box">
|
||||||
<el-table
|
<el-table
|
||||||
:data="tableDataList"
|
:data="paginatedData"
|
||||||
border
|
border
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
empty-text="暂无数据"
|
empty-text="暂无数据"
|
||||||
@@ -111,6 +111,13 @@
|
|||||||
|
|
||||||
// ==================== 计算属性 ====================
|
// ==================== 计算属性 ====================
|
||||||
|
|
||||||
|
// 分页后的数据
|
||||||
|
const paginatedData = computed(() => {
|
||||||
|
const start = (props.pageOption.currentPage - 1) * props.pageOption.pageSize;
|
||||||
|
const end = start + props.pageOption.pageSize;
|
||||||
|
return props.tableDataList.slice(start, end);
|
||||||
|
});
|
||||||
|
|
||||||
// 是否显示分页
|
// 是否显示分页
|
||||||
const showPagination = computed(() => props.pageOption.totalPage !== 0);
|
const showPagination = computed(() => props.pageOption.totalPage !== 0);
|
||||||
|
|
||||||
@@ -216,7 +223,10 @@
|
|||||||
:deep(.el-select__selected-item) {
|
:deep(.el-select__selected-item) {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
/* 减小表格行的上下间距 */
|
||||||
|
:deep(.el-table .el-table__cell) {
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
:deep(.el-table--border th) {
|
:deep(.el-table--border th) {
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
180deg,
|
180deg,
|
||||||
@@ -227,7 +237,7 @@
|
|||||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 14px;
|
font-size: 15px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
:deep(.el-table tr),
|
:deep(.el-table tr),
|
||||||
@@ -267,4 +277,19 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
/* 名称列样式:一行显示,超出隐藏 */
|
||||||
|
:deep(.el-table .el-table__row td:first-child .cell) {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 鼠标悬浮时显示完整名称 */
|
||||||
|
:deep(.el-table .el-table__row td:first-child:hover .cell) {
|
||||||
|
white-space: normal;
|
||||||
|
overflow: visible;
|
||||||
|
text-overflow: unset;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -34,20 +34,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { provide } from 'vue';
|
import { inject } from 'vue';
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
import { useStatusStore } from '@/stores/useStatusStore';
|
||||||
import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis';
|
|
||||||
import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType';
|
import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType';
|
||||||
import ButtonComponent from './around-analysis/ButtonComponent.vue';
|
import ButtonComponent from './around-analysis/ButtonComponent.vue';
|
||||||
import SearchComponent from './around-analysis/SearchComponent.vue';
|
import SearchComponent from './around-analysis/SearchComponent.vue';
|
||||||
|
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
|
||||||
// 在父组件中创建唯一的 Hook 实例
|
// 通过 inject 获取父组件(RainstormView.vue)提供的实例
|
||||||
const aroundAnalysisState = useAroundAnalysis();
|
const aroundAnalysisState = inject<AroundAnalysisState>('aroundAnalysisState')!;
|
||||||
|
|
||||||
// 通过 provide 共享给所有子组件
|
|
||||||
provide<AroundAnalysisState>('aroundAnalysisState', aroundAnalysisState);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -119,6 +119,17 @@ export const useDisasterChainTable = () => {
|
|||||||
tableColumns.value = columns;
|
tableColumns.value = columns;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置表格数据
|
||||||
|
* @param datas - 表格数据数组
|
||||||
|
*/
|
||||||
|
const setTableDatas = (datas: XianHiddenDangerSpots[]) => {
|
||||||
|
tableDatas.value = datas;
|
||||||
|
paginationConfig.value.total = datas.length;
|
||||||
|
paginationConfig.value.totalPage = Math.ceil(datas.length / paginationConfig.value.pageSize);
|
||||||
|
paginationConfig.value.currentPage = 1;
|
||||||
|
};
|
||||||
|
|
||||||
// ==================== 返回 ====================
|
// ==================== 返回 ====================
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -135,5 +146,6 @@ export const useDisasterChainTable = () => {
|
|||||||
changeCurrentPage,
|
changeCurrentPage,
|
||||||
setSelectOptions,
|
setSelectOptions,
|
||||||
setTableColumns,
|
setTableColumns,
|
||||||
|
setTableDatas,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const usePointsHandle = () => {
|
|||||||
|
|
||||||
const id = `${prefix}${point.id}`;
|
const id = `${prefix}${point.id}`;
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
info.push({ id, name: point.name!, lon: point.lon, lat: point.lat });
|
info.push({ id, name: point.name!, lon: point.lon, lat: point.lat, scale_grade: point.scale_grade, risk_grade: point.risk_grade });
|
||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
@@ -16,4 +16,8 @@ export interface Point {
|
|||||||
name?: string;
|
name?: string;
|
||||||
/** 预测概率 */
|
/** 预测概率 */
|
||||||
probability?: string;
|
probability?: string;
|
||||||
|
/** 规模等级(隐患点专用) */
|
||||||
|
scale_grade?: string;
|
||||||
|
/** 险情等级(隐患点专用) */
|
||||||
|
risk_grade?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,13 +71,17 @@
|
|||||||
import RightButtonComponent from '@/component/rain-earthquake/RightButtonComponent.vue';
|
import RightButtonComponent from '@/component/rain-earthquake/RightButtonComponent.vue';
|
||||||
import StepComponent from '@/component/rain-earthquake/StepComponent.vue';
|
import StepComponent from '@/component/rain-earthquake/StepComponent.vue';
|
||||||
import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain';
|
import { useRainDisasterChain } from '@/hooks/rainstorm/useRainDisasterChain';
|
||||||
|
import { useAroundAnalysis } from '@/hooks/rain-earthquake/useAroundAnalysis';
|
||||||
|
import type { AroundAnalysisState } from '@/types/common/useAroundAnalysisType';
|
||||||
|
import type { PointResource } from '@/types/common/useAroundAnalysisType';
|
||||||
|
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
|
||||||
import {
|
import {
|
||||||
useDisasterChainTable,
|
useDisasterChainTable,
|
||||||
type SearchConditions,
|
type SearchConditions,
|
||||||
} from '@/hooks/useDisasterChainTable';
|
} from '@/hooks/useDisasterChainTable';
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
import { useStatusStore } from '@/stores/useStatusStore';
|
||||||
import { DisasterType, PointType } from '@/types/common/DisasterType.ts';
|
import { DisasterType, PointType } from '@/types/common/DisasterType.ts';
|
||||||
import { onBeforeMount } from 'vue';
|
import { onBeforeMount, watch, provide } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -87,6 +91,10 @@
|
|||||||
|
|
||||||
const statusStore = useStatusStore();
|
const statusStore = useStatusStore();
|
||||||
|
|
||||||
|
// 在父组件中创建 useAroundAnalysis 实例,并通过 provide 提供给子组件
|
||||||
|
const aroundAnalysisState = useAroundAnalysis();
|
||||||
|
provide<AroundAnalysisState>('aroundAnalysisState', aroundAnalysisState);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
selectOptions,
|
selectOptions,
|
||||||
tableColumns,
|
tableColumns,
|
||||||
@@ -97,6 +105,7 @@
|
|||||||
changeCurrentPage,
|
changeCurrentPage,
|
||||||
setSelectOptions,
|
setSelectOptions,
|
||||||
setTableColumns,
|
setTableColumns,
|
||||||
|
setTableDatas,
|
||||||
} = useDisasterChainTable();
|
} = useDisasterChainTable();
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
@@ -104,8 +113,9 @@
|
|||||||
setSelectOptions([
|
setSelectOptions([
|
||||||
{ value: PointType.LANDSLIDE, label: '滑坡' },
|
{ value: PointType.LANDSLIDE, label: '滑坡' },
|
||||||
{ value: PointType.DEBRIS_FLOW, label: '泥石流' },
|
{ value: PointType.DEBRIS_FLOW, label: '泥石流' },
|
||||||
{ value: PointType.FLASH_FLOOD, label: '山洪' },
|
|
||||||
{ value: PointType.WATER_LOGGING, label: '内涝' },
|
{ value: PointType.WATER_LOGGING, label: '内涝' },
|
||||||
|
{ value: PointType.FLASH_FLOOD, label: '山洪' },
|
||||||
|
{ value: PointType.COLLAPSE, label: '崩塌' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 设置表格列配置
|
// 设置表格列配置
|
||||||
@@ -124,6 +134,46 @@
|
|||||||
setConditions(value);
|
setConditions(value);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 监听脉冲点变化并更新表格数据
|
||||||
|
watch(
|
||||||
|
() => aroundAnalysisState.pulsePoints.value,
|
||||||
|
(newPulsePoints: PointResource[]) => {
|
||||||
|
console.log('=== 脉冲点变化 ===');
|
||||||
|
console.log('newPulsePoints:', newPulsePoints);
|
||||||
|
console.log('newPulsePoints.length:', newPulsePoints?.length);
|
||||||
|
|
||||||
|
if (newPulsePoints && newPulsePoints.length > 0) {
|
||||||
|
// 将 PointResource 转换为 XianHiddenDangerSpots 格式
|
||||||
|
const convertedData: XianHiddenDangerSpots[] = newPulsePoints.map(point => ({
|
||||||
|
id: typeof point.id === 'number' ? point.id : parseInt(String(point.id), 10),
|
||||||
|
name: point.value,
|
||||||
|
disasterName: point.value,
|
||||||
|
position: point.lon !== undefined && point.lat !== undefined
|
||||||
|
? `${point.lon.toFixed(4)}, ${point.lat.toFixed(4)}`
|
||||||
|
: '未知位置',
|
||||||
|
scaleGrade: String(point.scale_grade || '未知'),
|
||||||
|
riskGrade: String(point.risk_grade || '一般'),
|
||||||
|
lon: point.lon,
|
||||||
|
lat: point.lat,
|
||||||
|
fieldCode: String(point.id),
|
||||||
|
province: '陕西省',
|
||||||
|
city: '西安市',
|
||||||
|
county: '',
|
||||||
|
village: '',
|
||||||
|
isDelete: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.log('convertedData:', convertedData);
|
||||||
|
setTableDatas(convertedData);
|
||||||
|
} else {
|
||||||
|
// 如果没有脉冲点,则清空表格数据
|
||||||
|
console.log('清空表格数据');
|
||||||
|
setTableDatas([]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true, deep: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
Reference in New Issue
Block a user