2026-02-11 07:44:49 +00:00
|
|
|
|
import {
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Card,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
Drawer,
|
|
|
|
|
|
Form,
|
|
|
|
|
|
Input,
|
|
|
|
|
|
InputNumber,
|
|
|
|
|
|
message,
|
|
|
|
|
|
Popconfirm,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Select,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Tag,
|
2026-02-12 05:43:59 +00:00
|
|
|
|
Typography,
|
|
|
|
|
|
Empty
|
2026-02-11 07:44:49 +00:00
|
|
|
|
} from "antd";
|
|
|
|
|
|
import { useEffect, useState } from "react";
|
2026-02-25 01:44:43 +00:00
|
|
|
|
import { useTranslation } from "react-i18next";
|
2026-02-11 07:44:49 +00:00
|
|
|
|
import {
|
|
|
|
|
|
createDictItem,
|
|
|
|
|
|
createDictType,
|
|
|
|
|
|
deleteDictItem,
|
|
|
|
|
|
deleteDictType,
|
|
|
|
|
|
fetchDictItems,
|
|
|
|
|
|
fetchDictTypes,
|
|
|
|
|
|
updateDictItem,
|
|
|
|
|
|
updateDictType
|
|
|
|
|
|
} from "../api";
|
|
|
|
|
|
import { usePermission } from "../hooks/usePermission";
|
2026-02-12 05:43:59 +00:00
|
|
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined, BookOutlined, ProfileOutlined } from "@ant-design/icons";
|
2026-02-27 02:27:57 +00:00
|
|
|
|
import { useDict } from "../hooks/useDict";
|
2026-02-11 07:44:49 +00:00
|
|
|
|
import type { SysDictItem, SysDictType } from "../types";
|
2026-02-27 02:27:57 +00:00
|
|
|
|
import PageHeader from "../components/shared/PageHeader";
|
2026-02-12 05:43:59 +00:00
|
|
|
|
import "./Dictionaries.css";
|
2026-02-11 07:44:49 +00:00
|
|
|
|
|
2026-02-12 05:43:59 +00:00
|
|
|
|
const { Title, Text } = Typography;
|
2026-02-11 07:44:49 +00:00
|
|
|
|
|
|
|
|
|
|
export default function Dictionaries() {
|
2026-02-25 01:44:43 +00:00
|
|
|
|
const { t } = useTranslation();
|
2026-02-11 07:44:49 +00:00
|
|
|
|
const { can } = usePermission();
|
|
|
|
|
|
const [types, setTypes] = useState<SysDictType[]>([]);
|
|
|
|
|
|
const [items, setItems] = useState<SysDictItem[]>([]);
|
|
|
|
|
|
const [selectedType, setSelectedType] = useState<SysDictType | null>(null);
|
|
|
|
|
|
const [loadingTypes, setLoadingTypes] = useState(false);
|
|
|
|
|
|
const [loadingItems, setLoadingItems] = useState(false);
|
|
|
|
|
|
|
2026-02-27 02:27:57 +00:00
|
|
|
|
// Dictionaries
|
|
|
|
|
|
const { items: statusDict } = useDict("sys_common_status");
|
|
|
|
|
|
|
2026-02-11 07:44:49 +00:00
|
|
|
|
// Type Drawer
|
|
|
|
|
|
const [typeDrawerVisible, setTypeDrawerVisible] = useState(false);
|
|
|
|
|
|
const [editingType, setEditingType] = useState<SysDictType | null>(null);
|
|
|
|
|
|
const [typeForm] = Form.useForm();
|
|
|
|
|
|
|
|
|
|
|
|
// Item Drawer
|
|
|
|
|
|
const [itemDrawerVisible, setItemDrawerVisible] = useState(false);
|
|
|
|
|
|
const [editingItem, setEditingItem] = useState<SysDictItem | null>(null);
|
|
|
|
|
|
const [itemForm] = Form.useForm();
|
|
|
|
|
|
|
|
|
|
|
|
const loadTypes = async () => {
|
|
|
|
|
|
setLoadingTypes(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = await fetchDictTypes();
|
|
|
|
|
|
setTypes(data || []);
|
|
|
|
|
|
if (data && data.length > 0 && !selectedType) {
|
|
|
|
|
|
setSelectedType(data[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoadingTypes(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const loadItems = async (typeCode: string) => {
|
|
|
|
|
|
setLoadingItems(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = await fetchDictItems(typeCode);
|
|
|
|
|
|
setItems(data || []);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoadingItems(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
loadTypes();
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (selectedType) {
|
|
|
|
|
|
loadItems(selectedType.typeCode);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setItems([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [selectedType]);
|
|
|
|
|
|
|
|
|
|
|
|
// Type Actions
|
|
|
|
|
|
const handleAddType = () => {
|
|
|
|
|
|
setEditingType(null);
|
|
|
|
|
|
typeForm.resetFields();
|
|
|
|
|
|
setTypeDrawerVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleEditType = (record: SysDictType) => {
|
|
|
|
|
|
setEditingType(record);
|
|
|
|
|
|
typeForm.setFieldsValue(record);
|
|
|
|
|
|
setTypeDrawerVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleDeleteType = async (id: number) => {
|
|
|
|
|
|
await deleteDictType(id);
|
2026-02-25 01:44:43 +00:00
|
|
|
|
message.success(t('common.success'));
|
2026-02-11 07:44:49 +00:00
|
|
|
|
loadTypes();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleTypeSubmit = async () => {
|
|
|
|
|
|
const values = await typeForm.validateFields();
|
|
|
|
|
|
if (editingType) {
|
|
|
|
|
|
await updateDictType(editingType.dictTypeId, values);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await createDictType(values);
|
|
|
|
|
|
}
|
2026-02-25 01:44:43 +00:00
|
|
|
|
message.success(t('common.success'));
|
2026-02-11 07:44:49 +00:00
|
|
|
|
setTypeDrawerVisible(false);
|
|
|
|
|
|
loadTypes();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Item Actions
|
|
|
|
|
|
const handleAddItem = () => {
|
|
|
|
|
|
if (!selectedType) {
|
2026-02-25 01:44:43 +00:00
|
|
|
|
message.warning(t('dicts.selectType'));
|
2026-02-11 07:44:49 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setEditingItem(null);
|
|
|
|
|
|
itemForm.resetFields();
|
|
|
|
|
|
itemForm.setFieldsValue({ typeCode: selectedType.typeCode, sortOrder: 0, status: 1 });
|
|
|
|
|
|
setItemDrawerVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleEditItem = (record: SysDictItem) => {
|
|
|
|
|
|
setEditingItem(record);
|
|
|
|
|
|
itemForm.setFieldsValue(record);
|
|
|
|
|
|
setItemDrawerVisible(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleDeleteItem = async (id: number) => {
|
|
|
|
|
|
await deleteDictItem(id);
|
2026-02-25 01:44:43 +00:00
|
|
|
|
message.success(t('common.success'));
|
2026-02-11 07:44:49 +00:00
|
|
|
|
if (selectedType) loadItems(selectedType.typeCode);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleItemSubmit = async () => {
|
|
|
|
|
|
const values = await itemForm.validateFields();
|
|
|
|
|
|
if (editingItem) {
|
|
|
|
|
|
await updateDictItem(editingItem.dictItemId, values);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await createDictItem(values);
|
|
|
|
|
|
}
|
2026-02-25 01:44:43 +00:00
|
|
|
|
message.success(t('common.success'));
|
2026-02-11 07:44:49 +00:00
|
|
|
|
setItemDrawerVisible(false);
|
|
|
|
|
|
if (selectedType) loadItems(selectedType.typeCode);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="dictionaries-page p-6">
|
2026-02-27 02:27:57 +00:00
|
|
|
|
<PageHeader
|
|
|
|
|
|
title={t('dicts.title')}
|
|
|
|
|
|
subtitle={t('dicts.subtitle')}
|
|
|
|
|
|
extra={can("sys_dict:type:create") && (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
icon={<PlusOutlined aria-hidden="true" />}
|
|
|
|
|
|
onClick={handleAddType}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('common.create')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
/>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Row gutter={24} style={{ height: 'calc(100vh - 180px)' }}>
|
|
|
|
|
|
<Col span={8} style={{ height: '100%' }}>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
<Card
|
2026-02-12 05:43:59 +00:00
|
|
|
|
title={
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<BookOutlined aria-hidden="true" />
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<span>{t('dicts.dictType')}</span>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
|
|
|
|
|
className="full-height-card shadow-sm"
|
2026-02-11 07:44:49 +00:00
|
|
|
|
>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div style={{ height: 'calc(100% - 10px)', overflowY: 'auto' }}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Table
|
|
|
|
|
|
rowKey="dictTypeId"
|
|
|
|
|
|
loading={loadingTypes}
|
|
|
|
|
|
dataSource={types}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
showHeader={false}
|
|
|
|
|
|
onRow={(record) => ({
|
|
|
|
|
|
onClick: () => setSelectedType(record),
|
|
|
|
|
|
className: `cursor-pointer dict-type-row ${selectedType?.dictTypeId === record.dictTypeId ? "dict-type-row-selected" : ""}`
|
|
|
|
|
|
})}
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
{
|
|
|
|
|
|
render: (_, record) => (
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="dict-type-item flex justify-between items-center p-2">
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<div className="min-w-0 flex-1">
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="dict-type-name font-medium truncate">{record.typeName}</div>
|
|
|
|
|
|
<div className="dict-type-code text-xs text-gray-400 truncate tabular-nums">{record.typeCode}</div>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</div>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="dict-type-actions flex gap-1">
|
2026-02-12 05:43:59 +00:00
|
|
|
|
{can("sys_dict:type:update") && (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
icon={<EditOutlined aria-hidden="true" />}
|
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
handleEditType(record);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{can("sys_dict:type:delete") && (
|
|
|
|
|
|
<Popconfirm
|
|
|
|
|
|
title={`确定删除类型 "${record.typeName}" 吗?这会影响关联的字典项。`}
|
|
|
|
|
|
onConfirm={(e) => {
|
|
|
|
|
|
e?.stopPropagation();
|
|
|
|
|
|
handleDeleteType(record.dictTypeId);
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
danger
|
|
|
|
|
|
icon={<DeleteOutlined aria-hidden="true" />}
|
|
|
|
|
|
onClick={(e) => e.stopPropagation()}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Col span={16} style={{ height: '100%' }}>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
<Card
|
2026-02-12 05:43:59 +00:00
|
|
|
|
title={
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<ProfileOutlined aria-hidden="true" />
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<span>{t('dicts.dictItem')}{selectedType ? ` - ${selectedType.typeName}` : ""}</span>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
|
|
|
|
|
className="full-height-card shadow-sm"
|
2026-02-11 07:44:49 +00:00
|
|
|
|
extra={
|
|
|
|
|
|
can("sys_dict:item:create") && (
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
icon={<PlusOutlined aria-hidden="true" />}
|
|
|
|
|
|
onClick={handleAddItem}
|
|
|
|
|
|
disabled={!selectedType}
|
|
|
|
|
|
>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
{t('dicts.drawerTitleItemCreate')}
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Button>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
{selectedType ? (
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div style={{ height: 'calc(100% - 10px)', overflowY: 'auto' }}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Table
|
|
|
|
|
|
rowKey="dictItemId"
|
|
|
|
|
|
loading={loadingItems}
|
|
|
|
|
|
dataSource={items}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size="middle"
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
{
|
2026-02-25 01:44:43 +00:00
|
|
|
|
title: t('dicts.itemLabel'),
|
2026-02-12 05:43:59 +00:00
|
|
|
|
dataIndex: "itemLabel",
|
|
|
|
|
|
render: (text) => <Text strong>{text}</Text>
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-02-25 01:44:43 +00:00
|
|
|
|
title: t('dicts.itemValue'),
|
2026-02-12 05:43:59 +00:00
|
|
|
|
dataIndex: "itemValue",
|
|
|
|
|
|
className: "tabular-nums"
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-02-25 01:44:43 +00:00
|
|
|
|
title: t('dicts.sort'),
|
2026-02-12 05:43:59 +00:00
|
|
|
|
dataIndex: "sortOrder",
|
|
|
|
|
|
width: 80,
|
|
|
|
|
|
className: "tabular-nums"
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-02-25 01:44:43 +00:00
|
|
|
|
title: t('common.status'),
|
2026-02-12 05:43:59 +00:00
|
|
|
|
dataIndex: "status",
|
|
|
|
|
|
width: 100,
|
2026-02-27 02:27:57 +00:00
|
|
|
|
render: (v) => {
|
|
|
|
|
|
const item = statusDict.find(i => i.itemValue === String(v));
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Tag color={v === 1 ? "green" : "red"}>
|
|
|
|
|
|
{item ? item.itemLabel : (v === 1 ? "启用" : "禁用")}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-02-12 05:43:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-02-25 01:44:43 +00:00
|
|
|
|
title: t('common.action'),
|
2026-02-12 05:43:59 +00:00
|
|
|
|
width: 120,
|
|
|
|
|
|
fixed: "right" as const,
|
|
|
|
|
|
render: (_, record) => (
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
{can("sys_dict:item:update") && (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
icon={<EditOutlined aria-hidden="true" />}
|
|
|
|
|
|
onClick={() => handleEditItem(record)}
|
2026-02-25 01:44:43 +00:00
|
|
|
|
aria-label={t('common.edit')}
|
2026-02-12 05:43:59 +00:00
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{can("sys_dict:item:delete") && (
|
|
|
|
|
|
<Popconfirm title={`确定删除字典项 "${record.itemLabel}" 吗?`} onConfirm={() => handleDeleteItem(record.dictItemId)}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
danger
|
|
|
|
|
|
icon={<DeleteOutlined aria-hidden="true" />}
|
2026-02-25 01:44:43 +00:00
|
|
|
|
aria-label={t('common.delete')}
|
2026-02-12 05:43:59 +00:00
|
|
|
|
/>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="flex items-center justify-center h-full">
|
|
|
|
|
|
<Empty description={t('dicts.selectType')} />
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Type Drawer */}
|
|
|
|
|
|
<Drawer
|
2026-02-12 05:43:59 +00:00
|
|
|
|
title={
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<BookOutlined aria-hidden="true" />
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<span>{editingType ? t('dicts.drawerTitleTypeEdit') : t('dicts.drawerTitleTypeCreate')}</span>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
2026-02-11 07:44:49 +00:00
|
|
|
|
open={typeDrawerVisible}
|
|
|
|
|
|
onClose={() => setTypeDrawerVisible(false)}
|
|
|
|
|
|
width={400}
|
|
|
|
|
|
destroyOnClose
|
|
|
|
|
|
footer={
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="flex justify-end gap-2 p-2">
|
|
|
|
|
|
<Button onClick={() => setTypeDrawerVisible(false)}>{t('common.cancel')}</Button>
|
|
|
|
|
|
<Button type="primary" onClick={handleTypeSubmit}>{t('common.confirm')}</Button>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Form form={typeForm} layout="vertical">
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.typeCode')} name="typeCode" rules={[{ required: true, message: t('dicts.typeCode') }]}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input disabled={!!editingType} placeholder="例如:user_status…" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.typeName')} name="typeName" rules={[{ required: true, message: t('dicts.typeName') }]}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input placeholder="例如:用户状态…" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('common.remark')} name="remark">
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input.TextArea placeholder="该字典类型的用途描述…" rows={3} />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Drawer>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Item Drawer */}
|
|
|
|
|
|
<Drawer
|
2026-02-12 05:43:59 +00:00
|
|
|
|
title={
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<ProfileOutlined aria-hidden="true" />
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<span>{editingItem ? t('dicts.drawerTitleItemEdit') : t('dicts.drawerTitleItemCreate')}</span>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
</Space>
|
|
|
|
|
|
}
|
2026-02-11 07:44:49 +00:00
|
|
|
|
open={itemDrawerVisible}
|
|
|
|
|
|
onClose={() => setItemDrawerVisible(false)}
|
|
|
|
|
|
width={400}
|
|
|
|
|
|
destroyOnClose
|
|
|
|
|
|
footer={
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<div className="flex justify-end gap-2 p-2">
|
|
|
|
|
|
<Button onClick={() => setItemDrawerVisible(false)}>{t('common.cancel')}</Button>
|
|
|
|
|
|
<Button type="primary" onClick={handleItemSubmit}>{t('common.confirm')}</Button>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Form form={itemForm} layout="vertical">
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.typeCode')} name="typeCode">
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input disabled className="tabular-nums" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.itemLabel')} name="itemLabel" rules={[{ required: true, message: t('dicts.itemLabel') }]}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input placeholder="例如:正常、禁用…" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.itemValue')} name="itemValue" rules={[{ required: true, message: t('dicts.itemValue') }]}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input placeholder="例如:1、0…" className="tabular-nums" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('dicts.sort')} name="sortOrder" initialValue={0}>
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<InputNumber className="w-full tabular-nums" />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('common.status')} name="status" initialValue={1}>
|
2026-02-11 07:44:49 +00:00
|
|
|
|
<Select
|
2026-02-27 02:27:57 +00:00
|
|
|
|
options={statusDict.map(i => ({ label: i.itemLabel, value: Number(i.itemValue) }))}
|
2026-02-11 07:44:49 +00:00
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
2026-02-25 01:44:43 +00:00
|
|
|
|
<Form.Item label={t('common.remark')} name="remark">
|
2026-02-12 05:43:59 +00:00
|
|
|
|
<Input.TextArea placeholder="可选项,备注详细信息…" rows={3} />
|
2026-02-11 07:44:49 +00:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Drawer>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|