king
2023-04-06 0eacb2fbcaa01060f81219d1ce5b406ae50f0c80
src/templates/comtableconfig/updatetable/index.jsx
@@ -264,7 +264,6 @@
                      uuid: btn.uuid,
                      MenuID: btn.uuid,
                      ParentId: tab.components[0].uuid,
                      enabled: false,
                      MenuName: btn.label,
                      tables: _config.tables || [],
                      Template: 'BaseTable',
@@ -272,6 +271,8 @@
                      viewType: 'popview',
                      style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                    }
                    btn.config.enabled = this.setEnabled(btn.config)
                  } else {
                    errors.push(tab.label + '中按钮《' + btn.label + '》配置信息丢失')
                  }
@@ -288,7 +289,6 @@
                        uuid: btn.uuid,
                        MenuID: btn.uuid,
                        ParentId: tab.components[0].uuid,
                        enabled: false,
                        MenuName: btn.label,
                        tables: _config.tables || [],
                        Template: 'BaseTable',
@@ -296,6 +296,8 @@
                        viewType: 'popview',
                        style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                      }
                      btn.config.enabled = this.setEnabled(btn.config)
                    } else {
                      errors.push(tab.label + '中按钮《' + btn.label + '》配置信息丢失')
                    }
@@ -313,7 +315,6 @@
                    uuid: btn.uuid,
                    MenuID: btn.uuid,
                    ParentId: item.uuid,
                    enabled: false,
                    MenuName: btn.label,
                    tables: _config.tables || [],
                    Template: 'BaseTable',
@@ -321,6 +322,8 @@
                    viewType: 'popview',
                    style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                  }
                  btn.config.enabled = this.setEnabled(btn.config)
                } else {
                  errors.push('主表中按钮《' + btn.label + '》配置信息丢失')
                }
@@ -337,7 +340,6 @@
                      uuid: btn.uuid,
                      MenuID: btn.uuid,
                      ParentId: item.uuid,
                      enabled: false,
                      MenuName: btn.label,
                      tables: _config.tables || [],
                      Template: 'BaseTable',
@@ -345,6 +347,8 @@
                      viewType: 'popview',
                      style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
                    }
                    btn.config.enabled = this.setEnabled(btn.config)
                  } else {
                    errors.push('主表中按钮《' + btn.label + '》配置信息丢失')
                  }
@@ -359,6 +363,25 @@
    } else {
      this.setPopForm(_resolve, _config, formActions, formTabs, errors)
    }
  }
  setEnabled = (config) => {
    let enabled = true
    config.components.forEach(item => {
      if (item.type === 'tabs') {
        item.subtabs.forEach(tab => {
          if (tab.components[0].errors.length > 0) {
            enabled = false
          }
        })
      } else {
        if (item.errors.length > 0) {
          enabled = false
        }
      }
    })
    return enabled
  }
  setPopForm = (_resolve, _config, formActions, formTabs, errors) => {
@@ -566,20 +589,6 @@
          })
          tab.components[0].$tables = getTables(tab.components[0])
          tab.components[0].errors = []
          let columns = tab.components[0].columns.map(c => c.field)
          if (tab.components[0].setting.interType === 'system' && tab.components[0].setting.execute !== 'false' && !tab.components[0].setting.dataresource) {
            tab.components[0].errors.push({ level: 0, detail: '未设置数据源!'})
          } else if (tab.components[0].setting.interType === 'system' && tab.components[0].setting.execute === 'false' && tab.components[0].scripts.filter(script => script.status !== 'false').length === 0) {
            tab.components[0].errors.push({ level: 0, detail: '数据源中无可用脚本!'})
          } else if (!tab.components[0].setting.primaryKey) {
            tab.components[0].errors.push({ level: 0, detail: '未设置主键!'})
          } else if (!columns.includes(tab.components[0].setting.primaryKey)) {
            tab.components[0].errors.push({ level: 0, detail: '主键已失效!'})
          } else if (!tab.components[0].setting.supModule) {
            tab.components[0].errors.push({ level: 0, detail: '未设置上级组件!'})
          }
        })
      } else {
        item.action.forEach(btn => {
@@ -597,20 +606,6 @@
        })
        item.$tables = getTables(item)
        item.errors = []
        let columns = item.columns.map(c => c.field)
        if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) {
          item.errors.push({ level: 0, detail: '未设置数据源!'})
        } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.filter(script => script.status !== 'false').length === 0) {
          item.errors.push({ level: 0, detail: '数据源中无可用脚本!'})
        } else if (!item.setting.primaryKey) {
          item.errors.push({ level: 0, detail: '未设置主键!'})
        } else if (!columns.includes(item.setting.primaryKey)) {
          item.errors.push({ level: 0, detail: '主键已失效!'})
        } else if (!item.setting.supModule) {
          item.errors.push({ level: 0, detail: '未设置上级组件!'})
        }
      }
    })
@@ -1214,6 +1209,50 @@
      _card.wrap.doubleClick = ''
    }
    _card.errors = []
    let columns = _card.columns.map(c => c.field)
    if (_card.setting.interType === 'system' && _card.setting.execute !== 'false' && !_card.setting.dataresource) {
      _card.errors.push({ level: 0, detail: '未设置数据源!'})
    } else if (_card.setting.interType === 'system' && _card.setting.execute === 'false' && _card.scripts.filter(script => script.status !== 'false').length === 0) {
      _card.errors.push({ level: 0, detail: '数据源中无可用脚本!'})
    } else if (!_card.setting.primaryKey) {
      _card.errors.push({ level: 0, detail: '未设置主键!'})
    } else if (!columns.includes(_card.setting.primaryKey)) {
      _card.errors.push({ level: 0, detail: '主键已失效!'})
    } else if (!_card.setting.supModule) {
      _card.errors.push({ level: 0, detail: '未设置上级组件!'})
    }
    _card.action.forEach(cell => {
      if (cell.hidden === 'true') return
      if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
        if (!cell.modal || cell.modal.fields.length === 0) {
          _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中表单尚未添加`})
        }
      } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
        _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中导入列未设置!`})
      } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
        _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中导出列未设置!`})
      }
    })
    _card.cols.forEach(col => {
      if (col.type !== 'action') return
      col.elements.forEach(cell => {
        if (cell.hidden === 'true') return
        if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
          if (!cell.modal || cell.modal.fields.length === 0) {
            _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中表单尚未添加`})
          }
        } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) {
          _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中导入列未设置!`})
        } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) {
          _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中导出列未设置!`})
        }
      })
    })
    return _card
  }