Files
xian_vue_new/src/hooks/earthquake/useEarthquakeDisasterChain.ts
T

83 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-04-14 08:08:01 +08:00
import { ref } from 'vue';
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
import type { PaginationType } from '@/types/common/PaginationType';
import { PointType } from '@/types/common/DisasterType';
/**
* 暴雨灾害链影响点列表钩子函数
* @returns 搜索条件、表格数据、分页配置及相关方法
*/
export const useEarthquakeDisasterChain = () => {
/**
* 搜索条件
*/
const conditions = ref({
tableData: '',
hiddenPoint: PointType.LANDSLIDE,
});
/**
* 下拉选项
*/
const selectOptions = [
{ value: PointType.LANDSLIDE, label: '滑坡' },
{ value: PointType.DEBRIS_FLOW, label: '泥石流' },
{ value: PointType.RISK_AREA, label: '风险区' },
];
/**
* 表格数据
*/
const tableDatas = ref<XianHiddenDangerSpots[]>([]);
/**
* 表头配置
*/
const tableColumns = [
{ title: '名称', key: 'disasterName' },
{ title: '位置', key: 'position' },
{ title: '规模等级', key: 'scaleGrade' },
{ title: '险情等级', key: 'riskGrade' },
];
/**
* 分页配置
*/
const paginationConfig = ref<PaginationType>({
currentPage: 1,
pageSize: 10,
total: 10,
totalPage: 1,
});
/**
* 修改搜索条件
* @param value - 新的搜索条件
*/
function changeConditions(value: {
tableData: string;
hiddenPoint: PointType;
}): void {
conditions.value = value;
}
/**
* 修改页码
* @param value - 新的页码
*/
function changeCurrentPage(value: number) {
paginationConfig.value.currentPage = value;
}
// 把所有需要用到的数据/方法 return 出去
return {
conditions,
selectOptions,
tableDatas,
tableColumns,
paginationConfig,
changeConditions,
changeCurrentPage,
};
};