| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Button, Input, Select, Cascader } from 'antd' |
| | | import { Form, Row, Col, Button, Input, Select, Cascader, notification } from 'antd' |
| | | import './index.scss' |
| | | |
| | | class ExcelOutColumn extends Component { |
| | | class MenusColumn extends Component { |
| | | static propTpyes = { |
| | | menus: PropTypes.array, |
| | | appType: PropTypes.string, |
| | | menulist: PropTypes.array, |
| | | columnChange: PropTypes.func // 修改函数 |
| | | columnChange: PropTypes.func |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { appType, menus, menulist } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | if (menus.filter(item => item.sign === values.sign).length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '标识已存在!', |
| | | duration: 2 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!appType) { |
| | | let fId = values.menu[0] || '' |
| | | let sId = values.menu[1] || '' |
| | | let tId = values.menu[2] || '' |
| | | let label = '' |
| | | |
| | | menulist.forEach(f => { |
| | | if (!fId || fId !== f.value) return |
| | | label = f.label |
| | | |
| | | f.children.forEach(s => { |
| | | if (!sId || sId !== s.value) return |
| | | label += ' / ' + s.label |
| | | |
| | | s.children.forEach(t => { |
| | | if (!tId || tId !== t.value) return |
| | | label += ' / ' + t.label |
| | | |
| | | values.MenuID = t.MenuID |
| | | values.MenuName = t.MenuName |
| | | values.MenuNo = t.MenuNo |
| | | values.tabType = t.type |
| | | values.label = label |
| | | }) |
| | | }) |
| | | }) |
| | | } else { |
| | | menulist.forEach(f => { |
| | | if (values.menu !== f.value) return |
| | | values.label = f.label |
| | | }) |
| | | } |
| | | |
| | | this.props.columnChange(values) |
| | | this.props.form.setFieldsValue({ |
| | | Column: '', |
| | | Text: '', |
| | | Width: 20 |
| | | sign: '', |
| | | menu: appType ? '' : [] |
| | | }) |
| | | } |
| | | }) |
| | |
| | | <Row gutter={24}> |
| | | <Col span={10}> |
| | | <Form.Item label="标识"> |
| | | {getFieldDecorator('name', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入标识!' |
| | | } |
| | | ] |
| | | {getFieldDecorator('sign', { |
| | | initialValue: '' |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(ExcelOutColumn) |
| | | export default Form.create()(MenusColumn) |