king
2020-11-03 37a134bd23ec4b227a0e010b08a1a89c2bbaaa0d
src/templates/zshare/editcomponent/index.jsx
@@ -4,6 +4,7 @@
import { Menu, Dropdown, Icon, Modal, Spin, notification } from 'antd'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import PasteForm from '@/templates/zshare/pasteform'
import ReplaceForm from '@/templates/zshare/replaceform'
import TransferForm from '@/templates/zshare/basetransferform'
@@ -136,14 +137,8 @@
    this.pasteFormRef.handleConfirm().then(res => {
      if (['maintable', 'subtable'].includes(type) && res.copyType === 'action') {
        if (this.props.type === 'subtable' && !['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'popview'].includes(res.OpenType)) {
          notification.warning({
            top: 92,
            message: '不支持此打开方式!',
            duration: 5
          })
          return
        }
        res.uuid = Utils.getuuid()
        this.setState({
          pasteVisible: false
        }, () => {
@@ -152,7 +147,24 @@
            content: res
          })
        })
      } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'search') {
      } else if (['maintable', 'subtable', 'calendar'].includes(type) && (res.copyType === 'search' || res.copyType === 'form')) {
        res.uuid = Utils.getuuid()
        // search: text select multiselect link date dateweek datemonth daterange group
        // form: text number select multiselect link switch checkbox radio checkcard
        //       fileupload date datemonth datetime textarea hint color funcvar
        if (res.copyType === 'form') {
          if (['number', 'switch', 'textarea', 'checkcard', 'fileupload', 'hint', 'color', 'funcvar'].includes(res.type)) {
            res.type = 'text'
          } else if (res.type === 'radio') {
            res.type = 'select'
          } else if (res.type === 'checkbox') {
            res.type = 'multiselect'
          } else if (res.type === 'datetime') {
            res.type = 'date'
          }
        }
        this.setState({
          pasteVisible: false
        }, () => {
@@ -180,68 +192,54 @@
            content: res
          })
        })
      } else if (['form'].includes(type) && res.copyType === 'form') {
        if (res.type === 'linkMain') {
          notification.warning({
            top: 92,
            message: '不支持此表单类型!',
            duration: 10
          })
          return
        }
      } else if (['form'].includes(type) && (res.copyType === 'form' || res.copyType === 'search')) {
        let _config = fromJS(config).toJS()
        let fieldrepet = false
        let labelrepet = false
        let fields = []
        let labels = []
        res.uuid = Utils.getuuid()
        // search: text select multiselect link date dateweek datemonth daterange group
        // form: text number select multiselect link switch checkbox radio checkcard
        //       fileupload date datemonth datetime textarea hint color funcvar
        if (res.copyType === 'search') {
          if (res.type === 'dateweek' || res.type === 'daterange' || res.type === 'group') {
            res.type = 'date'
          }
        }
        if (_config.groups.length > 0) {
          _config.groups.forEach(group => {
            group.sublist.forEach(item => {
              if (item.uuid === res.uuid) {
                fieldrepet = true
              } else if (item.field === res.field) {
                fieldrepet = true
              } else if (item.label === res.label) {
                labelrepet = true
              }
              fields.push(item.field)
              labels.push(item.label)
            })
            if (group.default) {
              group.sublist.push(res)
            }
          })
        } else {
          _config.fields.forEach(item => {
            if (item.uuid === res.uuid) {
              fieldrepet = true
            } else if (item.field === res.field) {
              fieldrepet = true
            } else if (item.label === res.label) {
              labelrepet = true
            }
            fields.push(item.field)
            labels.push(item.label)
          })
          _config.fields.push(res)
        }
        if (fieldrepet) {
        if (fields.includes(res.field)) {
          notification.warning({
            top: 92,
            message: '字段已存在!',
            duration: 10
          })
          return
        } else if (labelrepet) {
        } else if (labels.includes(res.label)) {
          notification.warning({
            top: 92,
            message: '名称已存在!',
            duration: 10
          })
          return
        }
        if (_config.groups.length > 0) {
          _config.groups.forEach(group => {
            if (group.default) {
              group.sublist.push(res)
            }
          })
        } else {
          _config.fields.push(res)
        }
        
        this.setState({
@@ -280,7 +278,7 @@
    const menu = (
      <Menu onClick={this.handleMenuClick}>
        {['maintable', 'subtable'].includes(type) ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null}
        {['maintable', 'subtable', 'form'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null}
        {['maintable', 'subtable', 'form', 'calendar'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null}
        {/* <Menu.Item key="replace"><Icon type="retweet" />替换</Menu.Item> */}
      </Menu>
    )