[feat]:[FL-209][新建维度时维度类型改为下拉选择]
将新建维度表单中的维度类型字段从文本输入框改为下拉选择框,提升用户体验。 主要修改: 1. 将维度类型字段从 Input 改为 Select 组件 2. 使用 mode="tags" 支持选择现有类型或输入新类型 3. 支持搜索和清空功能 4. 修改 CreateDimensionValues 类型定义,支持字符串或数组 5. 修改 handleCreateDimension 函数,处理 tags 模式返回的数组 用户体验优化: - 可以从现有维度类型中快速选择 - 支持搜索过滤 - 也可以输入新的维度类型 - 避免输入错误或不一致的类型名称 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -36,7 +36,7 @@ import type { DimensionItem, DimensionItemListResponse } from "@/types/dimension
|
|||||||
const AntCard = Card as unknown as ComponentType<CardProps & RefAttributes<HTMLDivElement>>;
|
const AntCard = Card as unknown as ComponentType<CardProps & RefAttributes<HTMLDivElement>>;
|
||||||
|
|
||||||
type CreateDimensionValues = {
|
type CreateDimensionValues = {
|
||||||
dimension_type: string;
|
dimension_type: string | string[];
|
||||||
code: string;
|
code: string;
|
||||||
name: string;
|
name: string;
|
||||||
parent_id?: string;
|
parent_id?: string;
|
||||||
@@ -285,7 +285,16 @@ export default function AdminDimensionsPage() {
|
|||||||
const handleCreateDimension = async (values: CreateDimensionValues) => {
|
const handleCreateDimension = async (values: CreateDimensionValues) => {
|
||||||
setError("");
|
setError("");
|
||||||
setSuccess("");
|
setSuccess("");
|
||||||
createDimensionMutation.mutate(values);
|
|
||||||
|
// Handle dimension_type from tags mode Select (returns array)
|
||||||
|
const payload = {
|
||||||
|
...values,
|
||||||
|
dimension_type: Array.isArray(values.dimension_type)
|
||||||
|
? values.dimension_type[0]
|
||||||
|
: values.dimension_type
|
||||||
|
};
|
||||||
|
|
||||||
|
createDimensionMutation.mutate(payload);
|
||||||
};
|
};
|
||||||
|
|
||||||
const openEditModal = (item: DimensionItem) => {
|
const openEditModal = (item: DimensionItem) => {
|
||||||
@@ -794,9 +803,16 @@ export default function AdminDimensionsPage() {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
label="维度类型"
|
label="维度类型"
|
||||||
name="dimension_type"
|
name="dimension_type"
|
||||||
rules={[{ required: true, message: "请输入维度类型" }]}
|
rules={[{ required: true, message: "请选择或输入维度类型" }]}
|
||||||
>
|
>
|
||||||
<Input placeholder="例如 电压等级" />
|
<Select
|
||||||
|
placeholder="请选择或输入维度类型"
|
||||||
|
showSearch
|
||||||
|
allowClear
|
||||||
|
mode="tags"
|
||||||
|
maxCount={1}
|
||||||
|
options={uniqueDimensionTypes.map((type) => ({ value: type, label: type }))}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
|||||||
Reference in New Issue
Block a user