PlatformTest.jsx 2.38 KB
Newer Older
邓超's avatar
邓超 committed
1 2 3 4 5 6 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
import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
import { Form, Input, Select, Divider, TreeSelect, Empty, Switch, Button, message } from 'antd';

const PlatformTest = (props, ref) => {
  const { menuWebList, menuMoblieList, formValue } = props;
  const [form] = Form.useForm();
  const [parmarForm] = Form.useForm();
  useEffect(() => {
    if (!formValue) {
      return;
    }
  }, [formValue]);
  useImperativeHandle(ref, () => ({
    getParmar,
  }));
  const getParmar = () => {
    let obj = form.getFieldsValue(true);
    let platform = {};
    let allFields = parmarForm.getFieldsValue(true);
    Object.keys(allFields).map(item => {
      platform[formValue.lines.find(ele => ele.Description == item).Name] = allFields[item];
    });
    obj = { ...obj, platform };
    return obj;
  };

  return (
    <div>
      <Divider
        orientation="left"
        style={{
          borderTopColor: '#99bbe8',
          color: '#15428b',
          fontWeight: 700,
          marginTop: '0px',
        }}
      >
        基础配置
      </Divider>
      <Form form={form} labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} labelAlign="left">
        <Form.Item label="网页跳转路径" name="PlatformWebUrl">
          <Input placeholder="请填写网页跳转路径" />
        </Form.Item>
        <Form.Item label="APP跳转路径" name="PlatformAppUrl">
          <Input placeholder="请填写APP跳转路径" />
        </Form.Item>
        <Form.Item label="视频地址" name="PlatformVideoUrl">
          <Input placeholder="请填写视频地址" />
        </Form.Item>
      </Form>
      <Divider
        orientation="left"
        style={{
          borderTopColor: '#99bbe8',
          color: '#15428b',
          fontWeight: 700,
          marginTop: '0px',
          display: formValue.lines?.length > 0 ? 'flex' : 'none',
        }}
      >
        参数配置
      </Divider>
      <Form form={parmarForm} labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} labelAlign="left">
        {formValue.lines?.map(item => (
65 66 67 68 69 70
          <Form.Item
            label={item.Description}
            name={item.Description}
            key={item.Name}
            initialValue={item.DefaultValue}
          >
邓超's avatar
邓超 committed
71 72 73 74 75 76 77 78 79
            <Input placeholder={`请填写${item.Description}`} />
          </Form.Item>
        ))}
      </Form>
    </div>
  );
};

export default forwardRef(PlatformTest);