king
2019-12-31 f9697383bc9097be8a444558e09ae21b27f1e831
src/templates/comtableconfig/actionform/index.jsx
@@ -2,65 +2,67 @@
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Button, Modal, message } from 'antd'
import { btnIcons, btnClasses } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
import './index.scss'
const { TextArea } = Input
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object, // 字典项
    formlist: PropTypes.any,
    card: PropTypes.any
    dict: PropTypes.object,  // 字典项
    formlist: PropTypes.any, // 表单信息
    card: PropTypes.any,     // 按钮信息
    tabs: PropTypes.array    // 所有标签页
  }
  state = {
    formlist: null,
    openType: null,
    errorType: 'E',
    interType: null,
    position: null,
    formlist: null,  // 表单信息
    openType: null,  // 打开方式
    errorType: 'E',  // 报错类型
    interType: null, // 接口类型:内部、外部
    position: null,  // 按钮位置
    reqOptionSgl: [{
      MenuID: 'requiredSgl',
      value: 'requiredSgl',
      text: this.props.dict['header.form.requiredSgl']
    }],
    reqOptions: [{
      MenuID: 'notRequired',
      value: 'notRequired',
      text: this.props.dict['header.form.notRequired']
    }, {
      MenuID: 'requiredSgl',
      value: 'requiredSgl',
      text: this.props.dict['header.form.requiredSgl']
    }],
    reqOptionsMutil: [{
      MenuID: 'notRequired',
      value: 'notRequired',
      text: this.props.dict['header.form.notRequired']
    }, {
      MenuID: 'requiredSgl',
      value: 'requiredSgl',
      text: this.props.dict['header.form.requiredSgl']
    }, {
      MenuID: 'required',
      value: 'required',
      text: this.props.dict['header.form.required']
    }, {
      MenuID: 'requiredOnce',
      value: 'requiredOnce',
      text: this.props.dict['header.form.requiredOnce']
    }],
    insertUpdateOptions: [{
      MenuID: '',
      value: '',
      text: this.props.dict['header.form.empty']
    }, {
      MenuID: 'insert',
      value: 'insert',
      text: this.props.dict['header.form.action.insert']
    }, {
      MenuID: 'update',
      value: 'update',
      text: this.props.dict['header.form.action.update']
    }],
    deleteOptions: [{
      MenuID: '',
      value: '',
      text: this.props.dict['header.form.empty']
    }, {
      MenuID: 'LogicDelete',
      value: 'LogicDelete',
      text: this.props.dict['header.form.action.LogicDelete']
    }, {
      MenuID: 'delete',
      value: 'delete',
      text: this.props.dict['header.form.action.delete']
    }]
  }
@@ -71,6 +73,8 @@
    let _intertype = ''
    let _position = ''
    let _errorType = ''
    let _tabType = ''
    let _linkTab = ''
    let _options = null
    this.props.formlist.forEach(form => {
@@ -82,16 +86,25 @@
        _position = form.initVal
      } else if (form.key === 'errorTip') {
        _errorType = form.initVal
      } else if (form.key === 'tabType') {
        _tabType = form.initVal
      } else if (form.key === 'linkTab') {
        _linkTab = form.initVal
      }
    })
    if (_opentype === 'innerpage') { // 新页面(内部),可选模板
    let _tabs = this.props.tabs.filter(tab => tab.type === _tabType)
    let initTab = _tabs.filter(tab => tab.uuid === _linkTab)[0]
    if (_opentype === 'innerpage') {                                     // 新页面(内部),可选模板
      _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position']
    } else if (_opentype === 'outerpage') { // 新页面(外部),需要页面地址
    } else if (_opentype === 'outerpage') {                              // 新页面(外部),需要页面地址
      _options = ['label', 'Ot', 'OpenType', 'url', 'icon', 'class', 'position']
    } else if (_opentype === 'blank' || _opentype === 'tab' || _opentype === 'popview') {
    } else if (_opentype === 'blank' || _opentype === 'tab') {           // 新标签或当前页面替换
      _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position']
    } else if (_opentype === 'excelIn' || _opentype === 'excelOut') {
    } else if (_opentype === 'popview') {                                // 模态框标签页
      _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose']
    } else if (_opentype === 'excelIn' || _opentype === 'excelOut') {    // 导入导出
      if (_intertype === 'outer') {
        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method']
      } else {
@@ -128,6 +141,17 @@
          } else {
            item.options = this.state.insertUpdateOptions
          }
        } else if (item.key === 'linkTab') {
          item.options = [
            {
              value: '',
              text: '新建'
            },
            ..._tabs
          ]
          if (!initTab) {
            item.initVal = ''
          }
        }
        item.hidden = !_options.includes(item.key)
        return item
@@ -143,8 +167,10 @@
        _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position']
      } else if (value === 'outerpage') {
        _options = ['label', 'Ot', 'OpenType', 'url', 'icon', 'class', 'position']
      } else if (value === 'blank' || value === 'tab' || value === 'popview') {
      } else if (value === 'blank' || value === 'tab') {
        _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position']
      } else if (value === 'popview') {
        _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose']
      } else if (value === 'excelIn' || value === 'excelOut') {
        if (this.state.interType === 'outer') {
          _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method']
@@ -236,6 +262,34 @@
      this.setState({
        errorType: value
      })
    } else if (key === 'tabType') {
      let _tabs = this.props.tabs.filter(tab => tab.type === value)
      this.setState({
        formlist: this.state.formlist.map(item => {
          if (item.key === 'linkTab') {
            item.options = [
              {
                value: '',
                text: '新建'
              },
              ..._tabs
            ]
            item.initVal = ''
            item.hidden = true
          }
          return item
        })
      }, () => {
        this.setState({
          formlist: this.state.formlist.map(item => {
            if (item.key === 'linkTab') {
              item.hidden = false
            }
            return item
          })
        })
      })
    }
  }
@@ -295,6 +349,7 @@
  getFields() {
    const { getFieldDecorator } = this.props.form
    const fields = []
    this.state.formlist.forEach((item, index) => {
      if (item.hidden) return
@@ -371,9 +426,9 @@
                  onChange={(value) => {this.openTypeChange(item.key, value)}}
                  getPopupContainer={() => document.getElementById('winter')}
                >
                  {item.options.map(option =>
                    <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>
                      {item.key === 'icon' && option.MenuID && <Icon type={option.MenuID} />} {option.text}
                  {item.options.map((option, index) =>
                    <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value}>
                      {item.key === 'icon' && option.value && <Icon type={option.value} />} {option.text}
                    </Select.Option>
                  )}
                </Select>
@@ -399,7 +454,7 @@
                  {
                    item.options.map(option => {
                      return (
                        <Radio key={option.MenuID} value={option.MenuID}>{option.text}</Radio>
                        <Radio key={option.value} value={option.value}>{option.text}</Radio>
                      )
                    })
                  }
@@ -434,6 +489,8 @@
          if (values.OpenType === 'excelIn' || values.OpenType === 'excelOut') {
            values.position = 'toolbar'
            values.Ot = 'notRequired'
          } else if (values.OpenType === 'popview' && !values.linkTab) { // 没有关联标签(新建时),创建新标签Id
            values.linkTab = Utils.getuuid()
          }
          if (values.innerFunc === '' && values.sql === '') {