AddModal.jsx 8.25 KB
Newer Older
mayongxin's avatar
mayongxin committed
1
import React, { useState, useEffect } from 'react'
2
import SiteModal from '@/components/Modal/SiteModa';
皮倩雯's avatar
皮倩雯 committed
3
import { Form, Input, notification, Select, Row, Col } from 'antd'
4 5

const { Item } = Form;
mayongxin's avatar
mayongxin committed
6
const { TextArea } = Input;
7

mayongxin's avatar
mayongxin committed
8

皮倩雯's avatar
皮倩雯 committed
9 10 11
const AddModal = props => {
    const { option } = props;
    
12 13
    const [form] = Form.useForm();
    const [loading, setLoading] = useState(false);
皮倩雯's avatar
皮倩雯 committed
14
    
mayongxin's avatar
mayongxin committed
15 16 17 18 19 20
    const onSubmit = () => {
        form.submit()
    }
    const onSubmitSuccess = () => {
        const result = form.getFieldValue()
        props.onSubmit & props.onSubmit({ Id: props.template.Id, ...result })
21
    }
皮倩雯's avatar
皮倩雯 committed
22 23 24 25 26 27 28 29 30
    const layout = {
        layout: 'horizontal',
        labelCol: {
            span: 10,
        },
        wrapperCol: {
            span: 19,
        },
    };
31
    // useEffect(()=>{
皮倩雯's avatar
皮倩雯 committed
32
   
33
    // },[props.template])
皮倩雯's avatar
皮倩雯 committed
34 35 36 37 38 39
    const onChange = value => {
        const { length } = value;
        form.setFieldsValue({
          dbName: value[length - 1],
        });
      };
40 41 42 43 44 45 46 47 48 49 50 51 52
    return (
        <SiteModal
            {...props}
            title="模板添加"
            bodyStyle={{ width: '100%', minHeight: '100px' }}
            style={{ top: 200, borderRadius: '20px' }}
            width="800px"
            destroyOnClose
            cancelText="取消"
            okText="确认"
            onOk={() => onSubmit()}
            confirmLoading={loading}
        >
皮倩雯's avatar
皮倩雯 committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
            <div style={{ width: "750px", height: "400px", overflowY: "scroll", overflowX: "hidden" }}>
                <Form form={form}  {...layout} onFinish={onSubmitSuccess}>
                    <Row gutter={24}>
                        <Col span={11}>
                            <Item
                                label="模板名称"
                                name="name"

                                rules={[
                                    {
                                        required: true,
                                        message: '请输入模板名称',
                                    },
                                ]}
                            >
                                <Input placeholder="请输入模板名称" width='100px' />
                            </Item>
                        </Col>
                        <Col span={11}>
                            <Item
                                label="模板类型"
                                name="type"
                                rules={[
                                    {
                                        required: true,
                                        message: '请选择模板类型',
                                    },
                                ]}
                            >
                                <Select defaultValue={"公众号"}>
                                    <Option value="公众号">公众号</Option>
                                    <Option value="短信">短信</Option>
                                </Select>
                            </Item>
                        </Col>
                    </Row>
                    <Row gutter={24}>
                        <Col span={11}>
                            <Item
                                label="第三方模板名称"
                                name="third_name"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入第三方模板名称',
                                    },
                                ]}
                            >
                                {/* <Input placeholder="请输入模板名称" /> */}
                                <Select
                                    placeholder="请选择模板名称"
                                    // onFocus={() => {
                                    //     selectFocus();
                                    // }}
                                    onChange={e => {
                                        onChange(e);
                                    }}
                                >
                                    {option &&
                                        option.length > 0 &&
                                        option.map((item, index) => (
                                            <Option value={item.Name} key={item.Name + index}>
                                                {item.Name}
                                            </Option>
                                        ))}
                                </Select>
                            </Item>
                        </Col>
                        <Col span={11}>
                            <Item
                                label="第三方模板编号"
                                name="third_id"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入第三方模板编号',
                                    },
                                ]}
                            >
                                <Input placeholder="请输入模板名称" />
                            </Item>
                        </Col>
                    </Row>
                    <Row gutter={24}>
                        <Col span={1}>
                            <Item>

                            </Item>
                        </Col>
                        <Col span={23}>
                            <Item
                                label="模板参数"
                                labelCol="{span:10}"
                                style={{ marginLeft: '1.4rem' }}
                                name="params"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入模板参数',
                                    },
                                ]}
                            >
                                <TextArea rows={4} placeholder="first|Second|Third|Four" />
                            </Item>
                        </Col>
                    </Row>
                    <Row gutter={24}>
                        <Col span={1}>
                            <Item>

                            </Item>
                        </Col>
                        <Col span={23}>
                            <Item
                                label="参数说明"
                                labelCol="{span:10}"
                                style={{ marginLeft: '1.4rem' }}
                                name="desc"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入参数说明',
                                    },
                                ]}
                            >
                                <TextArea rows={4} placeholder="first: 标题信息|Second: 展示内容|Third: 时间|Four: 备注信息" />
                            </Item>
                        </Col>
                    </Row>
                    <Row gutter={24}>
                        <Col span={1}>
                            <Item>
mayongxin's avatar
mayongxin committed
185

皮倩雯's avatar
皮倩雯 committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
                            </Item>
                        </Col>
                        <Col span={23}>
                            <Item
                                label="参数解析"
                                labelCol="{span:10}"
                                style={{ marginLeft: '1.4rem' }}
                                name="analysis_params"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入参数解析',
                                    },
                                ]}
                            >
                                <TextArea rows={4} placeholder="param1|param2|param3|param4" />
                            </Item>
                        </Col>
                    </Row>
mayongxin's avatar
mayongxin committed
205 206
                </Form>
            </div>
207 208 209 210 211

        </SiteModal>
    )
}
export default AddModal;