|
@@ -1,32 +1,44 @@
|
|
-import { Form, Button, Switch, Input } from 'antd';
|
|
|
|
|
|
+import { Form, Button, Switch, Input, Radio, Space } from 'antd';
|
|
import React from 'react';
|
|
import React from 'react';
|
|
-
|
|
|
|
|
|
+import { DeleteOutlined } from '@ant-design/icons';
|
|
function ItemAttribute(props) {
|
|
function ItemAttribute(props) {
|
|
const { item, onChange } = props;
|
|
const { item, onChange } = props;
|
|
|
|
|
|
const renderForm = () => {
|
|
const renderForm = () => {
|
|
let FormContent;
|
|
let FormContent;
|
|
|
|
+ const formProps = {
|
|
|
|
+ btns: <Form.Item>
|
|
|
|
+ <Button type="primary" htmlType="submit" style={{ marginRight: 20 }}>
|
|
|
|
+ 保存
|
|
|
|
+ </Button>
|
|
|
|
+ </Form.Item>,
|
|
|
|
+ item,
|
|
|
|
+ onFinish: values => {
|
|
|
|
+ console.log(values);
|
|
|
|
+ onChange?.(values);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
switch (item.componentName) {
|
|
switch (item.componentName) {
|
|
case 'InnerContactField':
|
|
case 'InnerContactField':
|
|
- FormContent = <InnerContactField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <InnerContactField {...formProps} />;
|
|
break;
|
|
break;
|
|
case 'DepartmentField':
|
|
case 'DepartmentField':
|
|
- FormContent = <DepartmentField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <DepartmentField {...formProps} />;
|
|
break;
|
|
break;
|
|
case 'TextField':
|
|
case 'TextField':
|
|
- FormContent = <TextField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <TextField {...formProps} />;
|
|
break;
|
|
break;
|
|
case 'TextareaField':
|
|
case 'TextareaField':
|
|
- FormContent = <TextareaField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <TextareaField {...formProps} />;
|
|
break;
|
|
break;
|
|
case 'DDSelectField':
|
|
case 'DDSelectField':
|
|
- FormContent = <DDSelectField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <DDSelectField {...formProps} />;
|
|
break;
|
|
break;
|
|
case 'DDMultiSelectField':
|
|
case 'DDMultiSelectField':
|
|
FormContent = <DDMultiSelectField item={item} onChange={onChange} />;
|
|
FormContent = <DDMultiSelectField item={item} onChange={onChange} />;
|
|
break;
|
|
break;
|
|
case 'NumberField':
|
|
case 'NumberField':
|
|
- FormContent = <NumberField item={item} onChange={onChange} />;
|
|
|
|
|
|
+ FormContent = <NumberField {...formProps} />;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,48 +66,67 @@ function ItemAttribute(props) {
|
|
export default ItemAttribute;
|
|
export default ItemAttribute;
|
|
|
|
|
|
function InnerContactField(props) {
|
|
function InnerContactField(props) {
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
|
+ const onSwitchChange = checked => {
|
|
|
|
+ form.setFieldValue("choice", checked ? 1 : 0);
|
|
|
|
+ }
|
|
return (
|
|
return (
|
|
- <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
|
- <Form.Item label="标题">
|
|
|
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off" initialValues={item.props} onFinish={onFinish}>
|
|
|
|
+ <Form.Item label="标题" name="label">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="提示文字">
|
|
|
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- {/* <Form.Item label="默认值">
|
|
|
|
- <Input />
|
|
|
|
- </Form.Item> */}
|
|
|
|
|
|
+ <Form.Item label="选项" name="choice">
|
|
|
|
+ <Radio.Group>
|
|
|
|
+ <Space direction="vertical">
|
|
|
|
+ <Radio value={'0'}>只能选择一人</Radio>
|
|
|
|
+ <Radio value={'1'}>可同时选择多人</Radio>
|
|
|
|
+ </Space>
|
|
|
|
+ </Radio.Group>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label="必填" name="required" valuePropName="checked">
|
|
|
|
+ <Switch />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
function DepartmentField(props) {
|
|
function DepartmentField(props) {
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
return (
|
|
return (
|
|
- <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
|
- <Form.Item label="标题">
|
|
|
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off" initialValues={item.props} onFinish={onFinish}>
|
|
|
|
+ <Form.Item label="标题" name="label">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="提示文字">
|
|
|
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- {/* <Form.Item label="默认值">
|
|
|
|
- <Input />
|
|
|
|
- </Form.Item> */}
|
|
|
|
|
|
+ <Form.Item label="选项" name="choice">
|
|
|
|
+ <Radio.Group>
|
|
|
|
+ <Space direction="vertical">
|
|
|
|
+ <Radio value={'0'}>只能选择一人</Radio>
|
|
|
|
+ <Radio value={'1'}>可同时选择多人</Radio>
|
|
|
|
+ </Space>
|
|
|
|
+ </Radio.Group>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label="必填" name="required" valuePropName="checked">
|
|
|
|
+ <Switch />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
function TextField(props) {
|
|
function TextField(props) {
|
|
- const { item, onChange } = props;
|
|
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
|
|
|
const onReset = () => {
|
|
const onReset = () => {
|
|
form.resetFields();
|
|
form.resetFields();
|
|
};
|
|
};
|
|
- const onFinish = values => {
|
|
|
|
- console.log(values);
|
|
|
|
- onChange?.(values);
|
|
|
|
- };
|
|
|
|
return (
|
|
return (
|
|
<Form
|
|
<Form
|
|
form={form}
|
|
form={form}
|
|
@@ -111,52 +142,49 @@ function TextField(props) {
|
|
<Form.Item label="提示文字" name="placeholder">
|
|
<Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="默认值" name="defaultValue">
|
|
|
|
- <Input />
|
|
|
|
- </Form.Item>
|
|
|
|
- <Form.Item label="必填" valuePropName="checked" name="require">
|
|
|
|
|
|
+ <Form.Item label="必填" valuePropName="checked" name="required">
|
|
<Switch />
|
|
<Switch />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item>
|
|
|
|
- <Button type="primary" htmlType="submit" style={{ marginRight: 20 }}>
|
|
|
|
- 保存
|
|
|
|
- </Button>
|
|
|
|
- <Button htmlType="button" onClick={onReset}>
|
|
|
|
- 重置
|
|
|
|
- </Button>
|
|
|
|
- </Form.Item>
|
|
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
function TextareaField(props) {
|
|
function TextareaField(props) {
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
return (
|
|
return (
|
|
- <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
|
- <Form.Item label="标题">
|
|
|
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off" initialValues={item.props} onFinish={onFinish}>
|
|
|
|
+ <Form.Item label="标题" name="label">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="提示文字">
|
|
|
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- {/* <Form.Item label="默认值">
|
|
|
|
- <Input />
|
|
|
|
- </Form.Item> */}
|
|
|
|
|
|
+ <Form.Item label="必填" valuePropName="checked" name="required">
|
|
|
|
+ <Switch />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
function DDSelectField(props) {
|
|
function DDSelectField(props) {
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
return (
|
|
return (
|
|
- <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
|
- <Form.Item label="标题">
|
|
|
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off" initialValues={item.props} onFinish={onFinish}>
|
|
|
|
+ <Form.Item label="标题" name="label">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="提示文字">
|
|
|
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- {/* <Form.Item label="默认值">
|
|
|
|
- <Input />
|
|
|
|
- </Form.Item> */}
|
|
|
|
|
|
+ <Form.Item label="选项" name="options">
|
|
|
|
+ {/* <SelectItem /> */}
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label="必填" valuePropName="checked" name="required">
|
|
|
|
+ <Switch />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -176,19 +204,56 @@ function DDMultiSelectField(props) {
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function SelectItem(props) {
|
|
|
|
+ const { value, onChange } = props;
|
|
|
|
+ console.log(value);
|
|
|
|
+ const pushItem = item => {
|
|
|
|
+ let tempValue = [...value, item];
|
|
|
|
+ onChange(tempValue);
|
|
|
|
+ }
|
|
|
|
+ const handleDelete = index => {
|
|
|
|
+ value.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ const handleInputOnchange = value => {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return (
|
|
|
|
+ <div>
|
|
|
|
+ <div>
|
|
|
|
+ {
|
|
|
|
+ value.map((item, index) =>
|
|
|
|
+ <div>
|
|
|
|
+ <Input />
|
|
|
|
+ <DeleteOutlined
|
|
|
|
+ onClick={() => handleDelete(index)}
|
|
|
|
+ />
|
|
|
|
+ </div>)
|
|
|
|
+ }
|
|
|
|
+ </div>
|
|
|
|
+ <div onClick={() => { pushItem('') }}>添加选项</div>
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+
|
|
function NumberField(props) {
|
|
function NumberField(props) {
|
|
|
|
+ const { item, btns, onFinish } = props;
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
return (
|
|
return (
|
|
- <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off">
|
|
|
|
- <Form.Item label="标题">
|
|
|
|
|
|
+ <Form form={form} labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} autoComplete="off" initialValues={item.props} onFinish={onFinish}>
|
|
|
|
+ <Form.Item label="标题" name="label">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- <Form.Item label="提示文字">
|
|
|
|
|
|
+ <Form.Item label="提示文字" name="placeholder">
|
|
<Input />
|
|
<Input />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
- {/* <Form.Item label="默认值">
|
|
|
|
|
|
+ <Form.Item label="单位" name="unit">
|
|
<Input />
|
|
<Input />
|
|
- </Form.Item> */}
|
|
|
|
|
|
+ </Form.Item>
|
|
|
|
+ <Form.Item label="必填" valuePropName="checked" name="required">
|
|
|
|
+ <Switch />
|
|
|
|
+ </Form.Item>
|
|
|
|
+ {btns}
|
|
</Form>
|
|
</Form>
|
|
);
|
|
);
|
|
}
|
|
}
|