king
2020-02-28 888095418c902cc94693cba8b45f31bb79cdf818
src/templates/modalconfig/index.jsx
@@ -48,6 +48,7 @@
    dict: CommonDict,      // 字典
    config: null,          // 页面配置,包括模板类型、模态框设置、添加表名、表单列表
    visible: false,        // 表单编辑模态框,显示控制
    modalType: null,       // 表单编辑类型,编辑或复制
    tableVisible: false,   // 数据表字段列表模态框,显示控制
    tableColumns: [],      // 表格字段名列表
    fields: null,          // 表单,可选字段(去重后)
@@ -372,8 +373,15 @@
   * 2、保存编辑项-card
   * 3、设置编辑参数项-formlist
   */
  handleForm = (card) => {
  handleForm = (_card, type) => {
    const {menu, tabConfig, subTabConfig} = this.props
    let card = JSON.parse(JSON.stringify(_card))
    if (type === 'copy') {
      card.originUuid = card.uuid
      card.uuid = Utils.getuuid()
      card.focus = true
    }
    const { config } = this.state
    let _inputfields = []
@@ -449,6 +457,7 @@
    this.setState({
      visible: true,
      modalType: type,
      card: card,
      formlist: getModalForm(card, _inputfields, _linkableFields, !!this.props.editTab)
    })
@@ -462,6 +471,8 @@
   */
  handleSubmit = () => {
    const {editAction, optionLibs} = this.props
    const { card, modalType } = this.state
    this.formRef.handleConfirm().then(res => {
      let _config = JSON.parse(JSON.stringify(this.state.config))
@@ -479,30 +490,60 @@
        })
      }
      if (_config.groups.length > 0) {
        _config.groups.forEach(group => {
          group.sublist = group.sublist.map(item => {
      if (modalType === 'copy' && card.originUuid) {
        if (_config.groups.length > 0) {
          _config.groups = _config.groups.map(group => {
            let _index = null
            group.sublist.forEach((item, index) => {
              if (item.uuid === card.originUuid) {
                _index = index
              }
            })
            if (_index !== null) {
              group.sublist.splice(_index + 1, 0, res)
            }
            return group
          })
        } else {
          let _index = null
          _config.fields.forEach((item, index) => {
            if (item.uuid === card.originUuid) {
              _index = index
            }
          })
          _config.fields.splice(_index + 1, 0, res)
        }
      } else {
        if (_config.groups.length > 0) {
          _config.groups.forEach(group => {
            group.sublist = group.sublist.map(item => {
              if (item.uuid === res.uuid) {
                return res
              } else {
                return item
              }
            })
          })
        } else {
          _config.fields = _config.fields.map(item => {
            if (item.uuid === res.uuid) {
              return res
            } else {
              return item
            }
          })
        })
      } else {
        _config.fields = _config.fields.map(item => {
          if (item.uuid === res.uuid) {
            return res
          } else {
            return item
          }
        })
        }
      }
      
      _config.fields = _config.fields.filter(item => !item.origin)
      this.setState({
        config: _config,
        modalType: null,
        card: null,
        optionLibs: optionLibs,
        visible: false
      })
@@ -551,27 +592,6 @@
      return
    }
    // if (config.setting.display === 'prompt') { // 有需要置空的场景
    //   let _fields = []
    //   if (config.groups.length > 0) {
    //     config.groups.forEach(group => {
    //       _fields = [..._fields, ...group.sublist]
    //     })
    //   } else {
    //     _fields = config.fields
    //   }
    //   let readfields = _fields.filter(item => item.initval || item.initval === 0)
    //   if (readfields.length < _fields.length) {
    //     notification.warning({
    //       top: 92,
    //       message: '以《是否框》显示的弹框,所有表单必须含有默认值!',
    //       duration: 10
    //     })
    //     return
    //   }
    // }
    let _LongParam = ''
    let _config = {...config, tables: this.state.selectedTables}
@@ -612,6 +632,7 @@
        this.setState({
          menuloading: false,
          closeloading: false,
          closeVisible: false,
          originConfig: _config,
          config: _config
        })
@@ -1181,7 +1202,7 @@
          </div>
        </DndProvider>
        <Modal
          title={this.state.dict['header.edit']}
          title={this.state.modalType !== 'copy' ? this.state.dict['header.edit'] : this.state.dict['header.modal.form.copy']}
          visible={this.state.visible}
          width={700}
          onCancel={this.editModalCancel}