|
@@ -29,45 +29,54 @@
|
|
|
<template #warningIcon="scope">
|
|
<template #warningIcon="scope">
|
|
|
<img :src="getWarningIcon(scope.row.disasterType)" alt="预警图标" class="weather-warning-icon" />
|
|
<img :src="getWarningIcon(scope.row.disasterType)" alt="预警图标" class="weather-warning-icon" />
|
|
|
</template>
|
|
</template>
|
|
|
- <template #activeStatus="scope">
|
|
|
|
|
|
|
+ <template #disasterType="scope">
|
|
|
|
|
+ <span>{{ formatDisasterType(scope.row.disasterType) }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template #disasterLevel="scope">
|
|
|
|
|
+ <span>{{ formatDisasterLevel(scope.row.disasterLevel) }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template #effectState="scope">
|
|
|
<div class="active-status--div">
|
|
<div class="active-status--div">
|
|
|
<div
|
|
<div
|
|
|
class="dot"
|
|
class="dot"
|
|
|
- :style="{ backgroundColor: ACTIVE_STATUS_COLOR[scope.row.activeStatus as ACTIVE_STATUS] }"
|
|
|
|
|
|
|
+ :style="{ backgroundColor: ACTIVE_STATUS_COLOR[scope.row.effectState as ACTIVE_STATUS] }"
|
|
|
/>
|
|
/>
|
|
|
- <span>{{ ACTIVE_STATUS_MAP[scope.row.activeStatus] }}</span>
|
|
|
|
|
|
|
+ <span>{{ ACTIVE_STATUS_MAP[scope.row.effectState] }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
- <template #pushStatus="scope">
|
|
|
|
|
- <span :style="{ color: scope.row.pushStatus === PUSH_STATUS.PUSHED ? '' : '#ff4d4f' }">
|
|
|
|
|
- {{ PUSH_STATUS_MAP[scope.row.pushStatus as PUSH_STATUS] }}
|
|
|
|
|
|
|
+ <template #isPush="scope">
|
|
|
|
|
+ <span :style="{ color: scope.row.isPush === PUSH_STATUS.PUSHED ? '' : '#ff4d4f' }">
|
|
|
|
|
+ {{ PUSH_STATUS_MAP[scope.row.isPush as PUSH_STATUS] }}
|
|
|
</span>
|
|
</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template #action="scope">
|
|
<template #action="scope">
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="编辑"
|
|
text="编辑"
|
|
|
@click="handleEditWarningInfo(scope.row.id)"
|
|
@click="handleEditWarningInfo(scope.row.id)"
|
|
|
- v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
|
|
+ v-if="scope.row.effectState === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="发布"
|
|
text="发布"
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要发布?',
|
|
title: '确定要发布?',
|
|
|
}"
|
|
}"
|
|
|
- v-if="scope.row.activeStatus === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
|
|
+ v-if="scope.row.effectState === ACTIVE_STATUS.NOT_EFFECTIVE"
|
|
|
|
|
+ @confirm="handlePublishWarningInfo(scope.row.id, scope.row.effectState)"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="撤回"
|
|
text="撤回"
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要撤回?',
|
|
title: '确定要撤回?',
|
|
|
}"
|
|
}"
|
|
|
- v-else-if="scope.row.activeStatus === ACTIVE_STATUS.ACTIVE"
|
|
|
|
|
|
|
+ v-else-if="scope.row.effectState === ACTIVE_STATUS.ACTIVE"
|
|
|
|
|
+ @confirm="handlePublishWarningInfo(scope.row.id, scope.row.effectState)"
|
|
|
/>
|
|
/>
|
|
|
<ActionButton
|
|
<ActionButton
|
|
|
text="删除"
|
|
text="删除"
|
|
|
:popconfirm="{
|
|
:popconfirm="{
|
|
|
title: '确定要删除?',
|
|
title: '确定要删除?',
|
|
|
}"
|
|
}"
|
|
|
|
|
+ @confirm="handleDeleteWarningInfo(scope.row.id)"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
</BasicTable>
|
|
</BasicTable>
|
|
@@ -90,15 +99,18 @@
|
|
|
import { PUSH_STATUS_MAP, PUSH_STATUS, WEATHER_DISASTER_ALERT_TYPE } from './src/constant';
|
|
import { PUSH_STATUS_MAP, PUSH_STATUS, WEATHER_DISASTER_ALERT_TYPE } from './src/constant';
|
|
|
import { WARNING_INFO_SEARCH_CONFIG, TABLE_OPTIONS, WARNING_INFO_TABLE_COLUMNS } from './src/config';
|
|
import { WARNING_INFO_SEARCH_CONFIG, TABLE_OPTIONS, WARNING_INFO_TABLE_COLUMNS } from './src/config';
|
|
|
import { useRouter } from 'vue-router';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
+ import type { QueryPageRequest } from '@/types/disaster';
|
|
|
|
|
+ import type { WarningInfoListQuery } from '@/types/disaster-warning';
|
|
|
|
|
+ import { formatDisasterLevel } from '@/views/disaster/utils/formatTable';
|
|
|
|
|
+ import { formatDisasterType } from './src/util';
|
|
|
|
|
+ import { deleteWarningInfoItem, publishWarningInfoItem } from '@/api/disaster-warning';
|
|
|
|
|
+ import { ElMessage } from 'element-plus';
|
|
|
|
|
+
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const searchData = reactive({
|
|
const searchData = reactive({
|
|
|
disasterType: '',
|
|
disasterType: '',
|
|
|
disasterLevel: '',
|
|
disasterLevel: '',
|
|
|
});
|
|
});
|
|
|
- const handleSearch = (data: any) => {
|
|
|
|
|
- console.log(data);
|
|
|
|
|
- getTableData();
|
|
|
|
|
- };
|
|
|
|
|
const getWarningIcon = (disasterType: string) => {
|
|
const getWarningIcon = (disasterType: string) => {
|
|
|
const icon = WEATHER_DISASTER_ALERT_TYPE.find((item) => item.label === disasterType)?.icon;
|
|
const icon = WEATHER_DISASTER_ALERT_TYPE.find((item) => item.label === disasterType)?.icon;
|
|
|
return icon ?? PlaceHolderWeather;
|
|
return icon ?? PlaceHolderWeather;
|
|
@@ -121,8 +133,35 @@
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
+ const handlePublishWarningInfo = async (id: number, effectState: number) => {
|
|
|
|
|
+ const message = effectState === ACTIVE_STATUS.ACTIVE ? '撤回成功' : '发布成功';
|
|
|
|
|
+ const effectStateStatus = effectState === ACTIVE_STATUS.ACTIVE ? ACTIVE_STATUS.NOT_EFFECTIVE : ACTIVE_STATUS.ACTIVE;
|
|
|
|
|
+ await publishWarningInfoItem({ id, effectState: effectStateStatus });
|
|
|
|
|
+ await getTableData();
|
|
|
|
|
+ ElMessage.success(message);
|
|
|
|
|
+ };
|
|
|
|
|
+ const handleDeleteWarningInfo = async (id: number) => {
|
|
|
|
|
+ await deleteWarningInfoItem(id);
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ ElMessage.success('删除成功');
|
|
|
|
|
+ };
|
|
|
const tableData = ref<WarningInfoListResponse[]>([]);
|
|
const tableData = ref<WarningInfoListResponse[]>([]);
|
|
|
const { tableConfig, pagination } = useTableConfig(WARNING_INFO_TABLE_COLUMNS, TABLE_OPTIONS);
|
|
const { tableConfig, pagination } = useTableConfig(WARNING_INFO_TABLE_COLUMNS, TABLE_OPTIONS);
|
|
|
|
|
+ let wanrningInfoListQuery: QueryPageRequest<WarningInfoListQuery> = {
|
|
|
|
|
+ pageNumber: pagination.pageNumber,
|
|
|
|
|
+ pageSize: pagination.pageSize,
|
|
|
|
|
+ queryParam: {},
|
|
|
|
|
+ };
|
|
|
|
|
+ const handleSearch = () => {
|
|
|
|
|
+ wanrningInfoListQuery.queryParam = {};
|
|
|
|
|
+ if (searchData.disasterLevel !== '') {
|
|
|
|
|
+ wanrningInfoListQuery.queryParam.disasterLevel = searchData.disasterLevel;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (searchData.disasterType !== '') {
|
|
|
|
|
+ wanrningInfoListQuery.queryParam.disasterType = searchData.disasterType;
|
|
|
|
|
+ }
|
|
|
|
|
+ getTableData();
|
|
|
|
|
+ };
|
|
|
const handleSizeChange = (value: number) => {
|
|
const handleSizeChange = (value: number) => {
|
|
|
pagination.pageSize = value;
|
|
pagination.pageSize = value;
|
|
|
getTableData();
|
|
getTableData();
|
|
@@ -133,9 +172,9 @@
|
|
|
};
|
|
};
|
|
|
const getTableData = async () => {
|
|
const getTableData = async () => {
|
|
|
tableConfig.loading = true;
|
|
tableConfig.loading = true;
|
|
|
- const res = await getWarningInfoList();
|
|
|
|
|
- tableData.value = res;
|
|
|
|
|
- pagination.total = tableData.value.length;
|
|
|
|
|
|
|
+ const res = await getWarningInfoList(wanrningInfoListQuery);
|
|
|
|
|
+ tableData.value = res.records;
|
|
|
|
|
+ pagination.total = res.totalRow;
|
|
|
tableConfig.loading = false;
|
|
tableConfig.loading = false;
|
|
|
};
|
|
};
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|