mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-09-16 00:38:19 +08:00
update 修改 参数设置页面布局
This commit is contained in:
parent
9bcb8a9f27
commit
117bb0ef8c
48
src/pages/system/config/index.less
Normal file
48
src/pages/system/config/index.less
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
.system-config-page {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
border-top: 1px solid rgba(5, 5, 5, 0.06);
|
||||||
|
|
||||||
|
&__tabs {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding-top: 16px;
|
||||||
|
|
||||||
|
.ant-tabs-content-holder {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-tabs-nav {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-tabs-tab {
|
||||||
|
height: 36px;
|
||||||
|
padding: 0 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
padding-left: 16px;
|
||||||
|
border-left: 1px solid rgba(5, 5, 5, 0.06);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.system-config-page {
|
||||||
|
display: block;
|
||||||
|
border-top: 0;
|
||||||
|
|
||||||
|
&__tabs {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
padding-left: 0;
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,52 +10,63 @@ import {
|
|||||||
type ProColumns
|
type ProColumns
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { useBoolean } from 'ahooks';
|
import { useBoolean } from 'ahooks';
|
||||||
import { Button, Form, message, Popconfirm } from 'antd';
|
import { Button, Form, Input, message, Tabs } from 'antd';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import type { ConfigForm, ConfigQuery, ConfigVO } from '@/api/system/config/types';
|
import type { ConfigForm, ConfigQuery, ConfigVO } from '@/api/system/config/types';
|
||||||
import { addConfig, delConfig, getConfig, listConfig, refreshConfigCache, updateConfig } from '@/api/system/config';
|
import {
|
||||||
import DictTag from '@/components/common/DictTag';
|
addConfig,
|
||||||
import EllipsisText from '@/components/common/EllipsisText';
|
delConfig,
|
||||||
|
getConfig,
|
||||||
|
listConfig,
|
||||||
|
refreshConfigCache,
|
||||||
|
updateConfig,
|
||||||
|
updateConfigByKey
|
||||||
|
} from '@/api/system/config';
|
||||||
import RowActions from '@/components/common/RowActions';
|
import RowActions from '@/components/common/RowActions';
|
||||||
import { useDateRangeQuery } from '@/hooks/useDateRangeQuery';
|
|
||||||
import { useDict } from '@/hooks/useDict';
|
import { useDict } from '@/hooks/useDict';
|
||||||
import { useTableExport } from '@/hooks/useTableExport';
|
import { useTableExport } from '@/hooks/useTableExport';
|
||||||
import { useTableSelection } from '@/hooks/useTableSelection';
|
|
||||||
import { useUserStore } from '@/stores/userStore';
|
import { useUserStore } from '@/stores/userStore';
|
||||||
import { dictOptions } from '@/utils/dict';
|
import { dictOptions } from '@/utils/dict';
|
||||||
|
import { confirmTitleSafe } from '@/utils/modal';
|
||||||
import { hasPermi } from '@/utils/permission';
|
import { hasPermi } from '@/utils/permission';
|
||||||
import { toPageQuery, toTableData } from '@/utils/ruoyi';
|
import { toPageQuery, toTableData } from '@/utils/ruoyi';
|
||||||
|
import './index.less';
|
||||||
|
|
||||||
|
const configTypeTabs = [
|
||||||
|
{ key: '', label: '全部' },
|
||||||
|
{ key: 'Y', label: '系统内置' },
|
||||||
|
{ key: 'N', label: '自定义配置' }
|
||||||
|
];
|
||||||
|
|
||||||
export default function SystemConfigPage() {
|
export default function SystemConfigPage() {
|
||||||
const actionRef = useRef<ActionType | undefined>(undefined);
|
const actionRef = useRef<ActionType | undefined>(undefined);
|
||||||
const [form] = Form.useForm<ConfigForm>();
|
const [form] = Form.useForm<ConfigForm>();
|
||||||
const userInfo = useUserStore(state => state.userInfo);
|
const userInfo = useUserStore(state => state.userInfo);
|
||||||
const dicts = useDict('sys_yes_no');
|
const dicts = useDict('sys_yes_no');
|
||||||
const { ids, selectedOne, handleSelectionChange, clearSelection } = useTableSelection<ConfigVO>(row => row.configId);
|
|
||||||
const [modalOpen, { setTrue: openModal, setFalse: closeModal }] = useBoolean(false);
|
const [modalOpen, { setTrue: openModal, setFalse: closeModal }] = useBoolean(false);
|
||||||
const [modalTitle, setModalTitle] = useState('');
|
const [modalTitle, setModalTitle] = useState('');
|
||||||
|
const [activeConfigType, setActiveConfigType] = useState('');
|
||||||
const { updateExportParams, exportFile } = useTableExport();
|
const { updateExportParams, exportFile } = useTableExport();
|
||||||
const { applyDateRange: applyCreateTimeDateRange } = useDateRangeQuery();
|
|
||||||
const canAdd = hasPermi(userInfo, ['system:config:add']);
|
const canAdd = hasPermi(userInfo, ['system:config:add']);
|
||||||
const canEdit = hasPermi(userInfo, ['system:config:edit']);
|
const canEdit = hasPermi(userInfo, ['system:config:edit']);
|
||||||
const canRemove = hasPermi(userInfo, ['system:config:remove']);
|
const canRemove = hasPermi(userInfo, ['system:config:remove']);
|
||||||
const canExport = hasPermi(userInfo, ['system:config:export']);
|
const canExport = hasPermi(userInfo, ['system:config:export']);
|
||||||
|
|
||||||
const openAdd = () => {
|
const openAdd = () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
form.setFieldsValue({ configType: 'Y' });
|
form.setFieldsValue({ configType: 'Y' });
|
||||||
setModalTitle('添加参数');
|
setModalTitle('添加参数');
|
||||||
openModal();
|
openModal();
|
||||||
};
|
};
|
||||||
const openEdit = async (row?: ConfigVO) => {
|
|
||||||
const target = row || selectedOne;
|
const openEdit = async (row: ConfigVO) => {
|
||||||
if (!target) return;
|
const res = await getConfig(row.configId);
|
||||||
const res = await getConfig(target.configId);
|
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
form.setFieldsValue(res.data);
|
form.setFieldsValue(res.data);
|
||||||
setModalTitle('修改参数');
|
setModalTitle('修改参数');
|
||||||
openModal();
|
openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async (values: ConfigForm) => {
|
const submit = async (values: ConfigForm) => {
|
||||||
values.configId ? await updateConfig(values) : await addConfig(values);
|
values.configId ? await updateConfig(values) : await addConfig(values);
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
@ -63,44 +74,55 @@ export default function SystemConfigPage() {
|
|||||||
actionRef.current?.reload();
|
actionRef.current?.reload();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const remove = async (row?: ConfigVO) => {
|
|
||||||
await delConfig(row?.configId || ids);
|
const remove = async (row: ConfigVO) => {
|
||||||
|
await delConfig(row.configId);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
clearSelection();
|
actionRef.current?.reload();
|
||||||
actionRef.current?.reloadAndRest?.();
|
};
|
||||||
|
|
||||||
|
const changeConfigType = (key: string) => {
|
||||||
|
setActiveConfigType(key);
|
||||||
|
setTimeout(() => actionRef.current?.reloadAndRest?.(), 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveInlineValue = async (row: ConfigVO, value: string) => {
|
||||||
|
if (value === row.configValue) return;
|
||||||
|
if (!(await confirmTitleSafe(`确认要保存对参数"${row.configKey}"的修改吗?`))) return;
|
||||||
|
await updateConfigByKey(row.configKey, value);
|
||||||
|
message.success('修改成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns: ProColumns<ConfigVO>[] = [
|
const columns: ProColumns<ConfigVO>[] = [
|
||||||
{ title: '参数名称', dataIndex: 'configName', width: 160 },
|
{ title: '参数名称', dataIndex: 'configName', width: 180 },
|
||||||
{ title: '参数键名', dataIndex: 'configKey', width: 180 },
|
{ title: '参数键名', dataIndex: 'configKey', width: 200 },
|
||||||
{
|
{
|
||||||
title: '参数键值',
|
title: '参数键值',
|
||||||
dataIndex: 'configValue',
|
dataIndex: 'configValue',
|
||||||
search: false,
|
search: false,
|
||||||
width: 220,
|
width: 240,
|
||||||
render: (_, row) => <EllipsisText value={row.configValue} maxWidth={200} />
|
render: (_, row) => (
|
||||||
},
|
<Input
|
||||||
{
|
defaultValue={row.configValue}
|
||||||
title: '系统内置',
|
placeholder="请输入参数键值"
|
||||||
dataIndex: 'configType',
|
onBlur={event => saveInlineValue(row, event.target.value)}
|
||||||
valueType: 'select',
|
onPressEnter={event => event.currentTarget.blur()}
|
||||||
width: 120,
|
/>
|
||||||
fieldProps: { options: dictOptions(dicts.sys_yes_no) },
|
)
|
||||||
render: (_, row) => <DictTag options={dicts.sys_yes_no} value={row.configType} />
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '备注',
|
title: '备注',
|
||||||
dataIndex: 'remark',
|
dataIndex: 'remark',
|
||||||
search: false,
|
search: false,
|
||||||
width: 180,
|
width: 220,
|
||||||
render: (_, row) => <EllipsisText value={row.remark} maxWidth={160} />
|
ellipsis: true,
|
||||||
|
renderText: value => value || '-'
|
||||||
},
|
},
|
||||||
{ title: '创建时间', dataIndex: 'createTimeRange', valueType: 'dateTimeRange', hideInTable: true },
|
|
||||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', search: false, width: 170 },
|
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
valueType: 'option',
|
valueType: 'option',
|
||||||
width: 120,
|
width: 96,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<RowActions
|
<RowActions
|
||||||
@ -122,39 +144,40 @@ export default function SystemConfigPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer title="参数管理">
|
<PageContainer title="参数管理">
|
||||||
<ProTable<ConfigVO, ConfigQuery & { createTimeRange?: [string, string] }>
|
<ProTable<ConfigVO, ConfigQuery>
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
rowKey="configId"
|
rowKey="configId"
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: 1180 }}
|
scroll={{ x: 900 }}
|
||||||
search={{ labelWidth: 90 }}
|
search={{ labelWidth: 90 }}
|
||||||
rowSelection={{ selectedRowKeys: ids, onChange: handleSelectionChange }}
|
|
||||||
request={async params => {
|
request={async params => {
|
||||||
const { createTimeRange, ...tableParams } = params;
|
const query = {
|
||||||
const query = applyCreateTimeDateRange(toPageQuery(tableParams), createTimeRange);
|
...toPageQuery(params),
|
||||||
|
configType: activeConfigType
|
||||||
|
};
|
||||||
updateExportParams(query);
|
updateExportParams(query);
|
||||||
const res = await listConfig(query);
|
const res = await listConfig(query);
|
||||||
return toTableData(res);
|
return toTableData(res);
|
||||||
}}
|
}}
|
||||||
toolbar={{ title: '参数列表' }}
|
toolbar={{ title: '参数列表' }}
|
||||||
|
tableRender={(_, dom) => (
|
||||||
|
<div className="system-config-page">
|
||||||
|
<Tabs
|
||||||
|
activeKey={activeConfigType}
|
||||||
|
tabPosition="left"
|
||||||
|
className="system-config-page__tabs"
|
||||||
|
items={configTypeTabs}
|
||||||
|
onChange={changeConfigType}
|
||||||
|
/>
|
||||||
|
<div className="system-config-page__content">{dom}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
toolBarRender={() => [
|
toolBarRender={() => [
|
||||||
canAdd && (
|
canAdd && (
|
||||||
<Button key="add" type="primary" icon={<PlusOutlined />} onClick={openAdd}>
|
<Button key="add" type="primary" icon={<PlusOutlined />} onClick={openAdd}>
|
||||||
新增
|
新增
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
canEdit && (
|
|
||||||
<Button key="edit" disabled={!selectedOne} icon={<EditOutlined />} onClick={() => openEdit()}>
|
|
||||||
修改
|
|
||||||
</Button>
|
|
||||||
),
|
|
||||||
canRemove && (
|
|
||||||
<Popconfirm key="delete" title={`是否确认删除参数编号为"${ids}"的数据项?`} onConfirm={() => remove()}>
|
|
||||||
<Button danger disabled={!ids.length} icon={<DeleteOutlined />}>
|
|
||||||
删除
|
|
||||||
</Button>
|
|
||||||
</Popconfirm>
|
|
||||||
),
|
|
||||||
canExport && (
|
canExport && (
|
||||||
<Button
|
<Button
|
||||||
key="export"
|
key="export"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user