king
2021-06-10 5cfe6db94c1449810a44660b299dba8e7e98e5c5
src/templates/sharecomponent/settingcomponent/settingform/index.jsx
@@ -85,12 +85,41 @@
    status.requestMode = status.requestMode || 'system'
    status.procMode = status.procMode || 'script'
    status.callbackType = status.callbackType || 'script'
    let regoptions = Utils.getRegOptions(search)
    if (config.urlFields && config.urlFields.length > 0) {
      config.urlFields.forEach(field => {
        regoptions.push({
          key: field,
          value: '0',
          type: 'url'
        })
      })
    }
    if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
      window.GLOB.funcs.forEach(m => {
        let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig')
        _scripts.forEach(item => {
          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
        })
        _preScripts.forEach(item => {
          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
        })
        _cbScripts.forEach(item => {
          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
        })
        if (_setting.dataresource) {
          _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`)
        }
      })
    }
    this.setState({
      setting: _setting,
      search: _search,
      arr_field: arr_field.join(','),
      regoptions: Utils.getRegOptions(search), // 搜索条件,正则替换
      regoptions: regoptions, // 搜索条件,正则替换
      columns: columns,
      scripts: _scripts,
      preScripts: _preScripts,
@@ -157,11 +186,11 @@
    const { activeKey, setting, scripts, preScripts, cbScripts } = this.state
    let _loading = false
    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) {
    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.preScriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) {
    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.cbScriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    }
@@ -171,14 +200,12 @@
        message: '存在未保存脚本,请点击确定保存,或点击取消放弃修改!',
        duration: 5
      })
      return
      return Promise.reject()
    }
    if (trigger) {
      this.setState({loading: true})
    }
    let _scripts = scripts.filter(script => script.status !== 'false')
    // 表单提交时检查输入值是否正确
    if (activeKey === 'setting') {
@@ -200,14 +227,6 @@
              duration: 5
            })
            this.setState({loading: false})
            reject()
            return
          } else if ((res.interType === 'system' || res.requestMode === 'system') && res.default === 'false' && _scripts.length === 0) {
            notification.warning({
              top: 92,
              message: '不执行默认sql时,请添加自定义脚本!',
              duration: 5
            })
            reject()
            return
          }
@@ -234,14 +253,6 @@
          notification.warning({
            top: 92,
            message: '使用内部接口,才可以创建存储过程!',
            duration: 5
          })
          this.setState({loading: false})
          reject()
        } else if ((setting.interType === 'system' || setting.requestMode === 'system') && setting.default === 'false' && _scripts.length === 0) {
          notification.warning({
            top: 92,
            message: '不执行默认sql时,请添加自定义脚本!',
            duration: 5
          })
          this.setState({loading: false})
@@ -311,11 +322,11 @@
    const { activeKey, search, arr_field, setting } = this.state
    let _loading = false
    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) {
    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.preScriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) {
    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.cbScriptsForm.props.form.getFieldValue('sql'))) {
      _loading = true
    }
@@ -470,6 +481,7 @@
              setting={setting}
              scripts={scripts}
              defaultSql={defaultSql}
              urlFields={config.urlFields}
              searches={this.props.search}
              scriptsChange={this.scriptsChange}
              scriptsUpdate={this.scriptsUpdate}
@@ -487,6 +499,7 @@
              setting={setting}
              scripts={preScripts}
              regoptions={regoptions}
              urlFields={config.urlFields}
              searches={this.props.search}
              scriptsUpdate={this.preScriptsUpdate}
              wrappedComponentRef={(inst) => this.preScriptsForm = inst}