AddViewModal.jsx 6.22 KB
Newer Older
皮倩雯's avatar
皮倩雯 committed
1
import React, { useEffect, useState } from 'react';
皮倩雯's avatar
皮倩雯 committed
2
import { Drawer, Form, Input, notification, Row, Col, Button, Space} from 'antd';
皮倩雯's avatar
皮倩雯 committed
3 4 5
import { CM_Event_OperateEventExtendPage, GetEventExtendPage} from '@/services/standingBook/api';
import { IdcardTwoTone } from '@ant-design/icons';
const AddViewModal = props => {
皮倩雯's avatar
皮倩雯 committed
6
    const { callBackSubmit = () => { }, visible, onClose, maxLength, title2, obj, type } = props;
皮倩雯's avatar
皮倩雯 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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
    const [id, setId]= useState('')

    const [form] = Form.useForm();
    const { Item } = Form;
    const { TextArea } = Input;

    const onSubmit = () => {
        let aa = title2;
        let bb = form.getFieldsValue().WebLabel;
        let cc = form.getFieldsValue().WebPage;
        let dd = form.getFieldsValue().WebParam;
        let ee = form.getFieldsValue().MobileLabel;
        let ff = form.getFieldsValue().MobilePage;
        let gg = form.getFieldsValue().MobileParam;
        if(type=='edit'){
            CM_Event_OperateEventExtendPage({
                ID: id,
                EventName: aa,
                WebLabel: bb,
                WebPage: cc,
                WebParam: dd,
                MobileLabel: ee,
                MobilePage: ff,
                MobileParam: gg,
            }).then(res => {
                if (res.msg === '') {
                    form.resetFields();
                    callBackSubmit();
                    notification.success({
                        message: '提示',
                        duration: 3,
                        description: '编辑成功',
                    });
                } else {
                    notification.error({
                        message: '提示',
                        duration: 3,
                        description: res.msg,
                    });
                }
            })
        }else{
            CM_Event_OperateEventExtendPage({
                ID: 0,
                EventName: aa,
                WebLabel: bb,
                WebPage: cc,
                WebParam: dd,
                MobileLabel: ee,
                MobilePage: ff,
                MobileParam: gg,
            }).then(res => {
                if (res.msg === '') {
                    form.resetFields();
                    callBackSubmit();
                    notification.success({
                        message: '提示',
                        duration: 3,
                        description: '添加成功',
                    });
                } else {
                    notification.error({
                        message: '提示',
                        duration: 3,
                        description: res.msg,
                    });
                }
            })
        }
        
        
    }
    useEffect(() => {
        console.log(type)
        if(type==='edit'){
            GetEventExtendPage({eventExtendPageId:obj}).then(res=>{
                console.log(res.data)
                form.setFieldsValue({...res.data})
                setId(res.data.ID)
            })
        }else if(type==='add'){
            form.resetFields();
        }
    }, [visible])
    return (
皮倩雯's avatar
皮倩雯 committed
92
        <Drawer
皮倩雯's avatar
皮倩雯 committed
93
            visible={visible}
皮倩雯's avatar
皮倩雯 committed
94 95
            onClose={onClose}
            width="500px"
皮倩雯's avatar
皮倩雯 committed
96
            title={type=='edit' ? '编辑事件辅助视图配置':'添加事件辅助视图配置'}
皮倩雯's avatar
皮倩雯 committed
97 98 99 100 101 102 103
            footer={
                <Space>
                  <Button onClick={onSubmit} type="primary" >
                    确定
                  </Button>
                </Space>
              } 
皮倩雯's avatar
皮倩雯 committed
104
        >
皮倩雯's avatar
皮倩雯 committed
105
            <Form form={form} labelCol={{ span: 7 }} style={{ height: '24rem', overflowY: 'scroll' }}>
皮倩雯's avatar
皮倩雯 committed
106 107 108 109 110
                <Row>
                    <Col span={23}>
                        <Item
                            label="前端标签"
                            name="WebLabel"
皮倩雯's avatar
皮倩雯 committed
111 112 113 114 115 116
                            rules={[
                                {
                                    required: true,
                                    message: '请输入前端标签',
                                },
                            ]}
皮倩雯's avatar
皮倩雯 committed
117 118 119 120 121 122 123 124
                        >
                            <Input style={{ width: '17rem' }} placeholder="请输入前端标签" />
                        </Item>
                    </Col>
                    <Col span={23}>
                        <Item
                            label="前端视图"
                            name="WebPage"
皮倩雯's avatar
皮倩雯 committed
125 126 127 128 129 130
                            rules={[
                                {
                                    required: true,
                                    message: '请输入前端视图',
                                },
                            ]}
皮倩雯's avatar
皮倩雯 committed
131 132 133 134 135 136 137 138 139
                        >
                            <Input style={{ width: '17rem' }} placeholder="请输入前端视图" />
                        </Item>
                    </Col>
                    <Col span={23}>
                        <Item
                            label="视图参数"
                            name="WebParam"
                        >
皮倩雯's avatar
皮倩雯 committed
140
                            <TextArea style={{ width: '17rem' }} placeholder="请输入视图参数" />
皮倩雯's avatar
皮倩雯 committed
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
                        </Item>
                    </Col>
                    <Col span={23}>
                        <Item
                            label="手持标签"
                            name="MobileLabel"
                        >
                            <Input style={{ width: '17rem' }} placeholder="请输入手持标签" />
                        </Item>
                    </Col>
                    <Col span={23}>
                        <Item
                            label="手持视图"
                            name="MobilePage"
                        >
                            <Input style={{ width: '17rem' }} placeholder="请输入手持视图" />
                        </Item>
                    </Col>
                    <Col span={23}>
                        <Item
                            label="手持参数"
                            name="MobileParam"
                        >
                            <TextArea style={{ width: '17rem' }} placeholder="请输入手持参数" />
                        </Item>
                    </Col>
                </Row>

            </Form>
皮倩雯's avatar
皮倩雯 committed
170
        </Drawer>
皮倩雯's avatar
皮倩雯 committed
171 172 173
    )
}
export default AddViewModal;