admin-vben5/apps/web-antd/src/views/system/config/index.vue

133 lines
3.1 KiB
Vue
Raw Normal View History

2024-08-07 08:57:56 +08:00
<script setup lang="ts">
2024-09-11 21:32:30 +08:00
import type { Recordable } from '@vben/types';
import type { ColumnsType } from 'ant-design-vue/es/table';
import type { Config } from '#/api/system/config/model';
import { onMounted, ref } from 'vue';
2024-09-11 20:23:44 +08:00
import { Page, useVbenModal } from '@vben/common-ui';
2024-09-12 08:43:56 +08:00
import { DictEnum } from '@vben/constants';
2024-09-11 20:23:44 +08:00
2024-09-24 11:23:02 +08:00
import { Card, Space, Table } from 'ant-design-vue';
2024-09-11 21:32:30 +08:00
2024-09-24 11:23:02 +08:00
import { useVbenForm } from '#/adapter';
2024-09-13 09:56:05 +08:00
import { configExport, configList } from '#/api/system/config';
import { downloadExcel } from '#/utils/file/download';
2024-09-12 08:43:56 +08:00
import { renderDict } from '#/utils/render';
2024-09-11 20:23:44 +08:00
import configModal from './config-modal.vue';
2024-09-24 11:23:02 +08:00
import { querySchema } from './data';
2024-09-11 20:23:44 +08:00
const [ConfigModal, modalApi] = useVbenModal({
connectedComponent: configModal,
});
function handleAdd() {
2024-09-23 09:55:40 +08:00
modalApi.setData({});
2024-09-11 20:23:44 +08:00
modalApi.open();
}
2024-09-11 21:32:30 +08:00
async function handleEdit(record: Recordable<any>) {
2024-09-23 09:55:40 +08:00
modalApi.setData({ id: record.configId });
2024-09-11 21:32:30 +08:00
modalApi.open();
2024-09-11 20:23:44 +08:00
}
2024-09-11 21:32:30 +08:00
const configDataList = ref<Config[]>([]);
async function reload() {
const resp = await configList();
configDataList.value = resp.rows;
}
onMounted(reload);
const columns: ColumnsType = [
{
align: 'center',
dataIndex: 'configName',
title: '参数名称',
},
{
align: 'center',
dataIndex: 'configKey',
title: '参数KEY',
},
{
align: 'center',
dataIndex: 'configValue',
title: '参数Value',
},
2024-09-12 08:43:56 +08:00
{
align: 'center',
customRender: ({ value }) => {
return renderDict(value, DictEnum.SYS_YES_NO);
},
dataIndex: 'configType',
title: '系统内置',
},
2024-09-11 21:32:30 +08:00
{
align: 'center',
dataIndex: 'remark',
ellipsis: true,
title: '备注',
},
{
align: 'center',
dataIndex: 'createTime',
title: '创建时间',
},
{
align: 'center',
dataIndex: 'action',
title: '操作',
},
];
2024-09-24 11:23:02 +08:00
const [QueryForm] = useVbenForm({
// 默认展开
collapsed: false,
// 所有表单项共用,可单独在表单内覆盖
commonConfig: {
// 所有表单项
componentProps: {
class: 'w-full',
},
},
schema: querySchema(),
// 是否可展开
showCollapseButton: true,
submitButtonOptions: {
text: '查询',
},
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
});
2024-08-07 08:57:56 +08:00
</script>
<template>
2024-09-24 11:23:02 +08:00
<Page content-class="flex flex-col gap-3">
<Card>
<QueryForm />
</Card>
<div class="flex justify-end gap-[8px]">
2024-09-13 09:56:05 +08:00
<a-button @click="downloadExcel(configExport, '参数配置', {})">
{{ $t('pages.common.export') }}
</a-button>
2024-09-11 21:32:30 +08:00
<a-button type="primary" @click="handleAdd">
{{ $t('pages.common.add') }}
</a-button>
</div>
<Table :columns :data-source="configDataList" size="middle">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<Space>
<a-button size="small" type="primary" @click="handleEdit(record)">
{{ $t('pages.common.edit') }}
</a-button>
</Space>
</template>
</template>
</Table>
2024-09-11 20:23:44 +08:00
<ConfigModal @reload="reload" />
</Page>
2024-08-07 08:57:56 +08:00
</template>