king
2024-05-07 2aa5ab63b4bbce5c36dbb3511b205b3b5f6af9bd
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
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Tooltip, Cascader } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
 
import MenuUtils from '@/utils/utils-custom.js'
// import './index.scss'
const { TextArea } = Input
 
class BaseForm extends Component {
  static propTpyes = {
    verify: PropTypes.object,
    onChange: PropTypes.func
  }
 
  state = {
    modules: [],
    menulist: [],
    appType: sessionStorage.getItem('appType')
  }
 
  UNSAFE_componentWillMount() {
    const { verify } = this.props
    let menu = window.GLOB.customMenu
 
    let modules = MenuUtils.getSubModules(menu.components, verify.parId, '', menu.interfaces || null)
 
    let menulist = sessionStorage.getItem('fstMenuList')
    if (menulist) {
      try {
        menulist = JSON.parse(menulist)
      } catch (e) {
        menulist = []
      }
    } else {
      menulist = []
    }
 
    this.setState({modules, menulist})
  }
 
  handleConfirm = () => {
    const { verify } = this.props
    
    if (verify.type === 'billout') {
      return new Promise((resolve, reject) => {
        this.props.form.validateFieldsAndScroll((err, values) => {
          if (!err) {
            resolve(values)
          }
        })
      })
    } else {
      return Promise.resolve()
    }
  }
 
  // onOptionChange = (value, key) => {
  //   const { verify } = this.props
 
  //   let _verify = {...verify, [key]: value}
 
  //   this.props.onChange(_verify)
  // }
 
  render() {
    const { getFieldDecorator } = this.props.form
    const { verify } = this.props
    const { modules, menulist, appType } = this.state
 
    return (
      <Form className="base-form">
        <Row gutter={24}>
          <Col span={8}>
            <Form.Item label="按钮名称">
              <Input value={verify.label} disabled={true}/>
            </Form.Item>
          </Col>
          <Col span={8}>
            <Form.Item label={
              <Tooltip placement="bottomLeft" title="执行成功后需要刷新的组件。">
                <QuestionCircleOutlined className="mk-form-tip" />
                刷新组件
              </Tooltip>
            }>
              {getFieldDecorator('syncComponent', {
                initialValue: verify.syncComponent || []
              })(
                <Cascader allowClear={true} options={modules} expandTrigger="hover"/>
              )}
            </Form.Item>
          </Col>
          {!appType ? <Col span={8}>
            <Form.Item label={
              <Tooltip placement="bottomLeft" title="执行成功后需要刷新的菜单。">
                <QuestionCircleOutlined className="mk-form-tip" />
                刷新菜单
              </Tooltip>
            }>
              {getFieldDecorator('refreshTab', {
                initialValue: verify.refreshTab || []
              })(
                <Cascader allowClear={true} options={menulist} expandTrigger="hover"/>
              )}
            </Form.Item>
          </Col> : null}
          {/* <Col span={8}>
            <Form.Item label={
              <Tooltip placement="bottomLeft" title="">
                <QuestionCircleOutlined className="mk-form-tip" />
                接口类型
              </Tooltip>
            }>
              <Radio.Group value={verify.intertype} disabled={true}>
                <Radio value="system">系统</Radio>
                <Radio value="custom">自定义</Radio>
              </Radio.Group>
            </Form.Item>
          </Col> */}
          {/* {verify.type === 'billout' ? <Col span={8}>
            <Form.Item label={
              <Tooltip placement="bottomLeft" title="">
                <QuestionCircleOutlined className="mk-form-tip" />
                参数处理
              </Tooltip>
            }>
              {getFieldDecorator('procMode', {
                initialValue: verify.procMode || 'system',
              })(
                <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'procMode')}}>
                  <Radio value="system">系统函数</Radio>
                  <Radio value="none">无</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null} */}
          {verify.type === 'billout' ? <Col span={24}>
            <Form.Item label="测试地址">
              {getFieldDecorator('interface', {
                initialValue: verify.interface || '',
                rules: [
                  { required: true, message: '请输入测试地址!' }
                ]
              })(
                <TextArea rows={2}/>
              )}
            </Form.Item>
          </Col> : null}
          {verify.type === 'billout' ? <Col span={24}>
            <Form.Item label="正式地址">
              {getFieldDecorator('proInterface', {
                initialValue: verify.proInterface || '',
              })(
                <TextArea rows={2}/>
              )}
            </Form.Item>
          </Col> : null}
          {verify.type === 'billout' ? <Col span={8}>
            <Form.Item label="回调表名">
              {getFieldDecorator('cbTable', {
                initialValue: verify.cbTable || '',
                rules: [
                  { required: true, message: '请输入表名!' }
                ]
              })(
                <Input autoComplete="off"/>
              )}
            </Form.Item>
          </Col> : null}
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(BaseForm)