|
@@ -0,0 +1,208 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * 新建检查 - 工作流检查设置组件
|
|
|
|
|
+ */
|
|
|
|
|
+import React, { useState } from 'react';
|
|
|
|
|
+import { Form, Card, Switch, Input, Select, Table, Button, Space, Checkbox } from 'antd';
|
|
|
|
|
+import { SPACING } from '../../constants';
|
|
|
|
|
+
|
|
|
|
|
+const { Option } = Select;
|
|
|
|
|
+
|
|
|
|
|
+// 字段配置数据类型
|
|
|
|
|
+interface FieldConfig {
|
|
|
|
|
+ key: string;
|
|
|
|
|
+ field: string;
|
|
|
|
|
+ visible: boolean;
|
|
|
|
|
+ required: boolean;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 新建检查组件
|
|
|
|
|
+ * 实现自动生成动物ID设置和输入字段配置功能
|
|
|
|
|
+ */
|
|
|
|
|
+const NewInspection: React.FC = () => {
|
|
|
|
|
+ const [form] = Form.useForm();
|
|
|
|
|
+
|
|
|
|
|
+ // 字段配置数据
|
|
|
|
|
+ const [fieldConfigs, setFieldConfigs] = useState<FieldConfig[]>([
|
|
|
|
|
+ { key: '1', field: '主人', visible: true, required: true },
|
|
|
|
|
+ { key: '2', field: '动物名称', visible: true, required: true },
|
|
|
|
|
+ { key: '3', field: '动物ID', visible: true, required: false },
|
|
|
|
|
+ { key: '4', field: '芯片号', visible: true, required: false },
|
|
|
|
|
+ { key: '5', field: '动物类型', visible: true, required: false },
|
|
|
|
|
+ { key: '6', field: '出生日期', visible: true, required: true },
|
|
|
|
|
+ { key: '7', field: '年龄', visible: true, required: false },
|
|
|
|
|
+ { key: '8', field: '动物体型', visible: true, required: false },
|
|
|
|
|
+ { key: '9', field: '性别', visible: true, required: false },
|
|
|
|
|
+ { key: '10', field: '体重/体长', visible: true, required: false },
|
|
|
|
|
+ { key: '11', field: '登记号', visible: true, required: true },
|
|
|
|
|
+ { key: '12', field: '兽医师', visible: true, required: false },
|
|
|
|
|
+ { key: '13', field: '操作技师', visible: true, required: false },
|
|
|
|
|
+ { key: '14', field: '动物注意', visible: true, required: false },
|
|
|
|
|
+ { key: '15', field: '麻醉', visible: true, required: false },
|
|
|
|
|
+ { key: '16', field: '镇定', visible: true, required: false },
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ // 表格列配置
|
|
|
|
|
+ const columns = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '可见',
|
|
|
|
|
+ dataIndex: 'visible',
|
|
|
|
|
+ key: 'visible',
|
|
|
|
|
+ width: 80,
|
|
|
|
|
+ render: (visible: boolean, record: FieldConfig) => (
|
|
|
|
|
+ <Checkbox
|
|
|
|
|
+ checked={visible}
|
|
|
|
|
+ onChange={(e) => handleFieldConfigChange(record.key, 'visible', e.target.checked)}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '必填',
|
|
|
|
|
+ dataIndex: 'required',
|
|
|
|
|
+ key: 'required',
|
|
|
|
|
+ width: 80,
|
|
|
|
|
+ render: (required: boolean, record: FieldConfig) => (
|
|
|
|
|
+ <Checkbox
|
|
|
|
|
+ checked={required}
|
|
|
|
|
+ onChange={(e) => handleFieldConfigChange(record.key, 'required', e.target.checked)}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '输入字段列表',
|
|
|
|
|
+ dataIndex: 'field',
|
|
|
|
|
+ key: 'field',
|
|
|
|
|
+ },
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ // 处理字段配置变更
|
|
|
|
|
+ const handleFieldConfigChange = (key: string, field: 'visible' | 'required', value: boolean) => {
|
|
|
|
|
+ setFieldConfigs(prev =>
|
|
|
|
|
+ prev.map(config =>
|
|
|
|
|
+ config.key === key ? { ...config, [field]: value } : config
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 处理保存
|
|
|
|
|
+ const handleSave = () => {
|
|
|
|
|
+ form.validateFields().then(values => {
|
|
|
|
|
+ console.log('保存设置:', { ...values, fieldConfigs });
|
|
|
|
|
+ // TODO: 调用API保存设置
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 处理取消
|
|
|
|
|
+ const handleCancel = () => {
|
|
|
|
|
+ form.resetFields();
|
|
|
|
|
+ // 重置字段配置到初始状态
|
|
|
|
|
+ setFieldConfigs([
|
|
|
|
|
+ { key: '1', field: '主人', visible: true, required: true },
|
|
|
|
|
+ { key: '2', field: '动物名称', visible: true, required: true },
|
|
|
|
|
+ { key: '3', field: '动物ID', visible: true, required: false },
|
|
|
|
|
+ { key: '4', field: '芯片号', visible: true, required: false },
|
|
|
|
|
+ { key: '5', field: '动物类型', visible: true, required: false },
|
|
|
|
|
+ { key: '6', field: '出生日期', visible: true, required: true },
|
|
|
|
|
+ { key: '7', field: '年龄', visible: true, required: false },
|
|
|
|
|
+ { key: '8', field: '动物体型', visible: true, required: false },
|
|
|
|
|
+ { key: '9', field: '性别', visible: true, required: false },
|
|
|
|
|
+ { key: '10', field: '体重/体长', visible: true, required: false },
|
|
|
|
|
+ { key: '11', field: '登记号', visible: true, required: true },
|
|
|
|
|
+ { key: '12', field: '兽医师', visible: true, required: false },
|
|
|
|
|
+ { key: '13', field: '操作技师', visible: true, required: false },
|
|
|
|
|
+ { key: '14', field: '动物注意', visible: true, required: false },
|
|
|
|
|
+ { key: '15', field: '麻醉', visible: true, required: false },
|
|
|
|
|
+ { key: '16', field: '镇定', visible: true, required: false },
|
|
|
|
|
+ ]);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
+ {/* 主内容区 - 分割视图 */}
|
|
|
|
|
+ <div style={{ flex: 1, display: 'flex', gap: SPACING.LG, padding: SPACING.LG }}>
|
|
|
|
|
+ {/* 左侧面板 - 表单设置 */}
|
|
|
|
|
+ <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: SPACING.MD }}>
|
|
|
|
|
+ <Form
|
|
|
|
|
+ form={form}
|
|
|
|
|
+ layout="vertical"
|
|
|
|
|
+ initialValues={{
|
|
|
|
|
+ autoGenerateAnimalId: false,
|
|
|
|
|
+ autoGeneratePrefix: false,
|
|
|
|
|
+ detailedInput: '',
|
|
|
|
|
+ defaultAnimalType: 'Cat',
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {/* 自动生成动物ID的设置 */}
|
|
|
|
|
+ <Card title="自动生成动物ID的设置" size="small">
|
|
|
|
|
+ <Space direction="vertical" style={{ width: '100%' }}>
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label="自动生成动物ID"
|
|
|
|
|
+ name="autoGenerateAnimalId"
|
|
|
|
|
+ valuePropName="checked"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Switch />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label="自动生成动物ID的前缀"
|
|
|
|
|
+ name="autoGeneratePrefix"
|
|
|
|
|
+ valuePropName="checked"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Switch />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label="详细输入内容"
|
|
|
|
|
+ name="detailedInput"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Input placeholder="请输入详细规则" />
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 默认动物类型 */}
|
|
|
|
|
+ <Card title="默认动物类型" size="small">
|
|
|
|
|
+ <Form.Item
|
|
|
|
|
+ label="默认连中的动物类型"
|
|
|
|
|
+ name="defaultAnimalType"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Select style={{ width: '100%' }}>
|
|
|
|
|
+ <Option value="Cat">Cat</Option>
|
|
|
|
|
+ <Option value="Dog">Dog</Option>
|
|
|
|
|
+ <Option value="Other">Other</Option>
|
|
|
|
|
+ </Select>
|
|
|
|
|
+ </Form.Item>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ </Form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 右侧面板 - 字段配置表格 */}
|
|
|
|
|
+ <div style={{ flex: 1 }}>
|
|
|
|
|
+ <Card title="输入字段配置" size="small">
|
|
|
|
|
+ <Table
|
|
|
|
|
+ columns={columns}
|
|
|
|
|
+ dataSource={fieldConfigs}
|
|
|
|
|
+ pagination={false}
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ scroll={{ y: 400 }}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 底部操作区 */}
|
|
|
|
|
+ <div style={{
|
|
|
|
|
+ padding: SPACING.LG,
|
|
|
|
|
+ borderTop: '1px solid #f0f0f0',
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ justifyContent: 'flex-end',
|
|
|
|
|
+ gap: SPACING.MD
|
|
|
|
|
+ }}>
|
|
|
|
|
+ <Button onClick={handleCancel}>取消</Button>
|
|
|
|
|
+ <Button type="primary" onClick={handleSave}>保存</Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+export default NewInspection;
|