king
2023-09-18 11b6387d74467f81e33eba8f882bff610f240115
src/menu/datasource/verifycard/index.jsx
@@ -22,6 +22,7 @@
const { TabPane } = Tabs
const { Paragraph } = Typography
const { Search } = Input
const { confirm } = Modal
const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror'))
const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
@@ -51,6 +52,7 @@
    reload: false,
    script: null,
    scriptValue: '',
    cols: null,
    colColumns: [
      {
        title: '名称',
@@ -383,7 +385,7 @@
    }
    return new Promise((resolve, reject) => {
      this.sqlverify(resolve, reject, false, scripts)
      this.sqlverify(resolve, reject, 'script', scripts)
    })
  }
@@ -447,7 +449,7 @@
              loading: false
            })
            this.getdefaultSql()
          }, true)
          }, 'change')
        })
      }, () => {
        this.setState({loading: false})
@@ -579,7 +581,7 @@
  submitDataSource = () => {
    const { config, mainSearch } = this.props
    const { activeKey, setting, columns, subColumns, scripts } = this.state
    const { activeKey, setting, columns, subColumns, scripts, cols } = this.state
    if (config.subtype === 'dualdatacard') {
      let arr = columns.map(col => col.field.toLowerCase())
@@ -620,7 +622,7 @@
            defaultSearch: _search,
            setting: res
          }, () => {
            this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts }) }, reject, false)
            this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols }) }, reject, 'submit')
          })
        }, () => {
          reject()
@@ -635,7 +637,7 @@
          reject()
          return
        }
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
      } else if (activeKey === 'subcolumns') {
        if (this.subdatasource && this.subdatasource.state.editingKey) {
          notification.warning({
@@ -646,7 +648,7 @@
          reject()
          return
        }
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
      } else if (activeKey === 'scripts') {
        let _loading = false
        if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -665,12 +667,12 @@
          return
        }
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
      }
    })
  }
  sqlverify = (resolve, reject, change = false, testScripts) => {
  sqlverify = (resolve, reject, type, testScripts) => {
    const { config } = this.props
    const { columns, setting, scripts, searches, defaultSearch, debugId } = this.state
@@ -679,7 +681,7 @@
    if (testScripts) {
      _scripts = testScripts.filter(item => item.status !== 'false')
    }
    if (!change && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) {
    if (type !== 'change' && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) {
      notification.warning({
        top: 92,
        message: '不执行默认sql时,请添加自定义脚本!',
@@ -689,14 +691,13 @@
      return
    }
    if (change && columns.length === 0) {
    if (type === 'change' && columns.length === 0) {
      reject()
      return
    }
    if ((setting.interType === 'system' && setting.execute !== 'false') || _scripts.length > 0) {
      let timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      let r = SettingUtils.getDebugSql(setting, _scripts, columns, searches, defaultSearch, config.type, '2023-04-20 15:29:37')
      let r = SettingUtils.getDebugSql(setting, _scripts, columns, searches, defaultSearch, config.type)
      let _debugId = md5(r.sql)
@@ -713,52 +714,31 @@
        })
      }
      let param = {
        func: 's_debug_sql',
        exec_type: 'y',
        LText: r.sql
      }
      param.LText = Utils.formatOptions(param.LText)
      param.timestamp = timestamp
      param.secretkey = Utils.encrypt('', timestamp)
      let sumParam = null
      if (r.sumSql) {
        sumParam = {
          func: 's_debug_sql',
          exec_type: 'y',
          LText: r.sumSql
        }
        sumParam.LText = Utils.formatOptions(sumParam.LText)
        sumParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        sumParam.secretkey = Utils.encrypt('', sumParam.timestamp)
      }
      Api.genericInterface(param).then(result => {
        if (result.status) {
          if (sumParam) {
            Api.genericInterface(sumParam).then(res => {
              if (res.status) {
      Api.sDebug(r.sql).then(result => {
        if (result.status || result.ErrCode === '-2') {
                this.setState({debugId: _debugId}, () => {
                  resolve()
                })
              } else {
          if (type === 'submit') {
            Modal.confirm({
              title: result.message,
              okText: '知道了',
              cancelText: '强制保存',
              onOk: () => {
                reject()
                Modal.error({
                  title: res.message
                })
              }
            })
          } else {
            this.setState({debugId: _debugId}, () => {
              },
              onCancel() {
              resolve()
            })
          }
            })
        } else {
          reject()
          Modal.error({
            title: result.message
              title: result.message,
              okText: '知道了'
          })
          }
        }
      })
    } else {
@@ -799,7 +779,7 @@
    this.setState({loading: true})
    this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, false, _scripts)
    this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts)
  }
  updatefields = (columns) => {
@@ -965,6 +945,49 @@
    message.success('复制成功。')
  }
  addProcess = () => {
    const { config } = this.props
    const { columns } = this.state
    if (config.subtype === 'dualdatacard') return
    let fields = []
    let cols = []
    let _cols = columns.map(item => item.field.toLowerCase())
    if (!_cols.includes('remark_w')) {
      fields.push({ uuid: Utils.getuuid(), label: '备注', field: 'remark_w', datatype: 'Nvarchar(50)', fieldlength: 50, type: 'text' })
      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '备注', field: 'remark_w', type: 'text', Hide: 'false', IsSort: 'false', fieldlength: 50 })
    }
    if (!_cols.includes('statusname_w')) {
      fields.push({ uuid: Utils.getuuid(), label: '状态', field: 'statusname_w', datatype: 'Nvarchar(50)', fieldlength: 50, type: 'text' })
      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '状态', field: 'statusname_w', type: 'text', Hide: 'false', IsSort: 'false', fieldlength: 50 })
    }
    if (!_cols.includes('works_flow_param')) {
      fields.push({ uuid: Utils.getuuid(), label: '流程参数', field: 'works_flow_param', datatype: 'Nvarchar(512)', fieldlength: 512, type: 'text' })
      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '流程参数', field: 'works_flow_param', type: 'text', Hide: 'true', IsSort: 'false', fieldlength: 512 })
    }
    if (fields.length === 0) return
    const that = this
    if (config.subtype !== 'basetable') {
      cols = null
    }
    confirm({
      content: cols ? '显示列中是否添加工作流字段?' : '字段集中是否添加工作流字段?',
      onOk() {
        that.setState({
          cols: cols,
          columns: [...fields, ...columns]
        })
      },
      onCancel() {}
    })
  }
  /**
   * @description 组件销毁,清除state更新
   */
@@ -995,6 +1018,7 @@
              setting={setting}
              scripts={scripts}
              updateStatus={this.updateStatus}
              addProcess={this.addProcess}
              wrappedComponentRef={(inst) => this.settingForm = inst}
            /> : null}
          </TabPane>
@@ -1058,6 +1082,7 @@
              systemScripts={this.state.systemScripts}
              scriptsChange={this.scriptsChange}
              scriptSubmit={this.scriptSubmit}
              addProcess={this.addProcess}
              wrappedComponentRef={(inst) => this.scriptsForm = inst}
            />
            <EditTable actions={['move']} data={scripts} columns={scriptsColumns} onChange={this.changeScripts}/>