import React, { useState, useRef } from 'react'; import { Card, Space, Divider, Typography, message } from 'antd'; import XinForm, { type XinFormRef } from '@/components/XinForm'; import type { FormColumn } from '@/components/XinFormField/FieldRender/typings'; import IconSelect from '@/components/XinFormField/IconSelector'; const { Title, Paragraph, Text } = Typography; /** * 图标选择器组件使用示例页面 */ const IconSelectExample: React.FC = () => { const [icon, setIcon] = useState(''); const formRef = useRef(undefined); // 表单列配置 const columns: FormColumn[] = [ { dataIndex: 'systemName', title: '系统名称', valueType: 'text', rules: [{ required: true, message: '请输入系统名称' }], fieldProps: { placeholder: '请输入系统名称', }, }, { dataIndex: 'systemIcon', title: '系统图标', rules: [{ required: true, message: '请选择系统图标' }], fieldRender: () => , }, { dataIndex: 'description', title: '系统描述', valueType: 'textarea', fieldProps: { placeholder: '请输入系统描述', rows: 4, }, }, ]; return (
图标选择器组件示例 基于 Ant Design Select + Modal + Tabs 封装的图标选择器组件,支持多分类图标选择。 基础用法:
{ setIcon(value || ''); if (value) { message.success(`选中图标: ${value}`); } else { message.info('已清空图标'); } }} placeholder="请选择图标" />
禁用状态:
只读状态:
只读模式下不能打开选择弹窗,但可以清空
{ console.log('XinForm 提交:', values); message.success('提交成功!'); message.info(`系统图标: ${values.systemIcon}`); return true; }} submitter={{ submitText: '提交表单', render: (dom) => dom.submit, }} />
); }; export default IconSelectExample;