WholeProcessPlatform/frontend/src/views/system/map/components/ConfigManagement/index.vue

201 lines
4.7 KiB
Vue
Raw Normal View History

<!-- d:\wordpack\WholeProcessPlatform\frontend\src\views\system\map\components\ConfigManagement\index.vue -->
<template>
<div class="config-management">
<ConfigManagementSearch
ref="configManagementSearch"
:handle-add="handleAdd"
@reset="handleReset"
@search-finish="onSearchFinish"
/>
<BasicTable
:columns="columns"
:data="dataSource"
:list-url="fetchConfigData"
:search-params="searchParams"
:enable-row-selection="true"
@selection-change="handleSelectionChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-button type="link" size="small" @click="handleEdit(record)"
>编辑</a-button
>
<a-button
type="link"
size="small"
danger
@click="handleDelete(record)"
>删除</a-button
>
</a-space>
</template>
<template v-if="column.key === 'configType'">
<a-tag :color="getConfigTypeColor(record.configType)">
{{ record.configType }}
</a-tag>
</template>
</template>
</BasicTable>
<ConfigManagementForm
ref="configManagementForm"
v-model:visible="editModalVisible"
:initial-values="currentRecord"
@cancel="editModalCancel"
@ok="handleEditSubmit"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import BasicTable from '@/components/BasicTable/index.vue';
import ConfigManagementSearch from './ConfigManagementSearch.vue';
import ConfigManagementForm from './ConfigManagementForm.vue';
import { message } from 'ant-design-vue';
// 表格列配置
const columns = [
{
title: '配置项名称',
dataIndex: 'configName',
key: 'configName',
width: 150
},
{
title: '配置类型',
key: 'configType',
dataIndex: 'configType',
width: 120
},
{
title: '配置值',
dataIndex: 'configValue',
key: 'configValue',
ellipsis: true
},
{
title: '描述',
dataIndex: 'description',
key: 'description',
ellipsis: true
},
{
title: '更新时间',
dataIndex: 'updateTime',
key: 'updateTime',
width: 180
},
{
title: '操作',
key: 'action',
width: 150,
fixed: 'right'
}
];
// 搜索参数
const searchParams = ref({});
// 编辑弹窗数据
const currentRecord = ref<any | null>(null);
const editModalVisible = ref(false);
// 数据源
const dataSource = ref([]);
// 获取配置类型标签颜色
const getConfigTypeColor = (type: string) => {
const colorMap: Record<string, string> = {
系统配置: 'blue',
显示配置: 'green',
业务配置: 'orange'
};
return colorMap[type] || 'default';
};
// 模拟数据获取函数
const fetchConfigData = (params: any) => {
return new Promise(resolve => {
setTimeout(() => {
resolve({
data: {
records: [
{
id: 1,
configName: '默认缩放级别',
configType: '显示配置',
configValue: '10',
description: '地图默认显示的缩放级别',
updateTime: '2023-05-15 10:30:00'
},
{
id: 2,
configName: '数据刷新间隔',
configType: '系统配置',
configValue: '300',
description: '数据自动刷新的时间间隔(秒)',
updateTime: '2023-06-20 14:45:00'
},
{
id: 3,
configName: '预警阈值',
configType: '业务配置',
configValue: '85%',
description: '触发预警的阈值百分比',
updateTime: '2023-07-10 09:15:00'
}
],
total: 3
}
});
}, 500);
});
};
const handleAdd = () => {
currentRecord.value = null;
editModalVisible.value = true;
};
// 编辑处理
const handleEdit = (record: any) => {
currentRecord.value = { ...record };
editModalVisible.value = true;
};
// 删除处理
const handleDelete = (record: any) => {
message.warning(`删除配置: ${record.configName}`);
};
// 搜索完成处理
const onSearchFinish = (values: any) => {
console.log(values);
};
// 重置
const handleReset = (params: any) => {};
// 选择变化处理
const handleSelectionChange = (selectedRows: any[]) => {
console.log('选中的行:', selectedRows);
};
// 表单取消
const editModalCancel = () => {
editModalVisible.value = false;
};
// 表单提交
const handleEditSubmit = (values: any) => {
console.log(values);
};
</script>
<style scoped lang="scss">
.config-management {
height: 100%;
padding: 16px;
}
</style>