|
@@ -0,0 +1,194 @@
|
|
|
+import { Form, Button, Switch, Input } from 'antd';
|
|
|
+import React from 'react';
|
|
|
+
|
|
|
+function ItemAttribute(props) {
|
|
|
+ const { item, onChange } = props;
|
|
|
+
|
|
|
+ const renderForm = () => {
|
|
|
+ let FormContent;
|
|
|
+ switch (item.componentName) {
|
|
|
+ case 'InnerContactField':
|
|
|
+ FormContent = <InnerContactField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'DepartmentField':
|
|
|
+ FormContent = <DepartmentField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'TextField':
|
|
|
+ FormContent = <TextField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'TextareaField':
|
|
|
+ FormContent = <TextareaField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'DDSelectField':
|
|
|
+ FormContent = <DDSelectField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'DDMultiSelectField':
|
|
|
+ FormContent = <DDMultiSelectField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ case 'NumberField':
|
|
|
+ FormContent = <NumberField item={item} onChange={onChange} />;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return FormContent;
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!item) return null;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ // position: 'absolute',
|
|
|
+ // top: 0,
|
|
|
+ // right: 0,
|
|
|
+ width: 300,
|
|
|
+ height: '100%',
|
|
|
+ overflowY: 'auto',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {renderForm()}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+export default ItemAttribute;
|
|
|
+
|
|
|
+function InnerContactField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function DepartmentField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function TextField(props) {
|
|
|
+ const { item, onChange } = props;
|
|
|
+ const [form] = Form.useForm();
|
|
|
+
|
|
|
+ const onReset = () => {
|
|
|
+ form.resetFields();
|
|
|
+ };
|
|
|
+ const onFinish = values => {
|
|
|
+ console.log(values);
|
|
|
+ onChange?.(values);
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <Form
|
|
|
+ form={form}
|
|
|
+ labelCol={{ span: 8 }}
|
|
|
+ wrapperCol={{ span: 16 }}
|
|
|
+ onFinish={onFinish}
|
|
|
+ autoComplete="off"
|
|
|
+ initialValues={item.props}
|
|
|
+ >
|
|
|
+ <Form.Item label="标题" name="label">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="默认值" name="defaultValue">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="必填" valuePropName="checked" name="require">
|
|
|
+ <Switch />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item>
|
|
|
+ <Button type="primary" htmlType="submit" style={{ marginRight: 20 }}>
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ <Button htmlType="button" onClick={onReset}>
|
|
|
+ 重置
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function TextareaField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function DDSelectField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function DDMultiSelectField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|
|
|
+function NumberField(props) {
|
|
|
+ const [form] = Form.useForm();
|
|
|
+ return (
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
+ <Form.Item label="标题">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="提示文字">
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ {/* <Form.Item label="默认值">
|
|
|
+ <Input />
|
|
|
+ </Form.Item> */}
|
|
|
+ </Form>
|
|
|
+ );
|
|
|
+}
|