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)
|