king
2020-09-09 2652a3c1485dbbf3b003e13e5c5d1c0205e7c324
src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx
@@ -312,29 +312,62 @@
  }
  changeTab = (val) => {
    const { activeKey } = this.state
    const { activeKey, setting } = this.state
    this.setState({loading: true})
    if (activeKey === 'setting') {
      this.settingForm.handleConfirm().then(res => {
        if (res.interType !== 'system' && val === 'scripts') {
          notification.warning({
            top: 92,
            message: '使用系统接口时,才可以设置自定义脚本!',
            duration: 5
          })
          this.setState({loading: false})
          return
        }
        this.setState({
          setting: res
        }, () => {
          this.sqlverify(() => { // 验证成功
          if (res.interType === 'system') { // 系统接口,sql验证
            this.sqlverify(() => { // 验证成功
              this.setState({
                activeKey: val,
                loading: false
              })
            }, () => {             // 验证失败
              this.setState({
                loading: false
              })
            }, activeKey)
          } else {
            this.setState({
              activeKey: val,
              loading: false
            })
          }, () => {             // 验证失败
            this.setState({
              loading: false
            })
          }, true)
          }
        })
      }, () => {
        this.setState({loading: false})
      })
    } else if (activeKey === 'columns') {
      if (setting.interType !== 'system' && val === 'scripts') {
        notification.warning({
          top: 92,
          message: '使用系统接口时,才可以设置自定义脚本!',
          duration: 5
        })
        this.setState({loading: false})
        return
      } else if (setting.interType !== 'system') {
        this.setState({
          activeKey: val,
          loading: false
        })
        return
      }
      this.sqlverify(() => { // 验证成功
        this.setState({
          activeKey: val,
@@ -344,7 +377,7 @@
        this.setState({
          loading: false
        })
      }, true)
      }, activeKey)
    } else if (activeKey === 'scripts') {
      let _loading = false
      if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -374,7 +407,7 @@
        this.setState({
          loading: false
        })
      }, true)
      }, activeKey)
    }
  }
@@ -387,13 +420,13 @@
          this.setState({
            setting: res
          }, () => {
            this.sqlverify(() => { resolve({setting: res, columns, scripts }) }, reject, false)
            this.sqlverify(() => { resolve({setting: res, columns, scripts }) }, reject, 'submit')
          })
        }, () => {
          reject()
        })
      } else if (activeKey === 'columns') {
        this.sqlverify(() => { resolve({setting, columns, scripts }) }, reject, false)
        this.sqlverify(() => { resolve({setting, columns, scripts }) }, reject, 'submit')
      } else if (activeKey === 'scripts') {
        let _loading = false
        if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -412,14 +445,14 @@
          return
        }
        this.sqlverify(() => { resolve({setting, columns, scripts }) }, reject, false)
        this.sqlverify(() => { resolve({setting, columns, scripts }) }, reject, 'submit')
      }
    })
  }
  sqlverify = (resolve, reject, change = false, testScripts) => {
  sqlverify = (resolve, reject, type, testScripts) => {
    const { searches } = this.props
    const { columns, setting, scripts, activeKey } = this.state
    const { columns, setting, scripts } = this.state
    let _scripts = []
    if (testScripts) {
@@ -428,7 +461,7 @@
      _scripts = scripts.filter(item => item.status !== 'false')
    }
    if (!change && setting.interType === 'system' && !setting.innerFunc && setting.execute === 'false' && _scripts.length === 0) {
    if (type === 'submit' && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) {
      notification.warning({
        top: 92,
        message: '不执行默认sql时,请添加自定义脚本!',
@@ -439,11 +472,11 @@
    }
    // 不使用默认sql切换
    if (change && activeKey === 'setting' && setting.interType === 'system' && setting.execute === 'false') {
    if (type === 'setting' && setting.interType === 'system' && setting.execute === 'false') {
      resolve()
    } else if (change && activeKey === 'scripts' && _scripts.length === 0) {
    } else if (type === 'scripts' && _scripts.length === 0) {
      resolve()
    } else if ((setting.interType === 'system' && setting.execute !== 'false') || _scripts.length > 0) {
    } else if (setting.interType === 'system' && (setting.execute !== 'false' || _scripts.length > 0)) {
      let param = {
        func: 's_debug_sql',
        LText: SettingUtils.getDebugSql(setting, _scripts, columns, searches)