king
2021-11-17 c51f5e007a3e03c9d6731ab7f28f0080de009990
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -3,16 +3,17 @@
import moment from 'moment'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import { Button, Modal, notification, message } from 'antd'
import { Button, Modal, notification, message, Drawer, Icon } from 'antd'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import Utils, { getSysDefaultSql } from '@/utils/utils.js'
import options from '@/store/options.js'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import { updateForm } from '@/utils/utils-update.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
// import './index.scss'
const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform'))
const { confirm } = Modal
@@ -36,12 +37,32 @@
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    visible: false,
    formdata: null,
    tabledata: null,
    selines: null,
    confirmLoading: false,
    btnconfig: null,
    loading: false,
    loadingNumber: '',
    checkParam: null
    disabled: false,
    hidden: false,
    checkParam: null,
    autoMatic: false
  }
  moduleParams = null
  UNSAFE_componentWillMount () {
    const { btn, selectedData } = this.props
    let disabled = false
    if (btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制
      selectedData.forEach(item => {
        let s = item[btn.controlField] + ''
        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
          disabled = true
        }
      })
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -49,10 +70,34 @@
  }
  componentDidMount () {
    const { position } = this.props
    const { position, btn } = this.props
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    if (position === 'form') {
      MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
    }
    MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
    if (btn.autoMatic) {
      MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { btn, selectedData } = this.props
    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
      let disabled = false
      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制
        nextProps.selectedData.forEach(item => {
          let s = item[btn.controlField] + ''
          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
            disabled = true
          }
        })
      }
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -61,41 +106,71 @@
      return
    }
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
    MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit)
    MKEmitter.removeListener('returnModuleParam', this.resetModuleParam)
    MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
  }
  triggerBtnPopSubmit = (id) => {
    const { btn } = this.props
    if (btn.uuid !== id) return
    this.handleOk()
  }
  actionSubmit = (res) => {
    const { btn } = this.props
    if (btn.uuid !== res.menuId) return
    this.setState({ loading: true })
    this.execSubmit(this.state.selines, () => {}, res.form)
  }
  resetModuleParam = (menuId, btnId, param) => {
    const { btn } = this.props
    if (btn.$menuId !== menuId || btn.uuid !== btnId || !param) return
    this.moduleParams = param
  }
  /**
   * @description 按钮状态改变
   */
  updateStatus = (type) => {
    if (type === 'start') {
      this.setState({
        loading: true
      })
    } else if (type === 'over') {
      this.setState({
        loading: false,
        visible: false
      })
    }
  updateStatus = () => {
    this.setState({
      loading: false,
      visible: false,
      confirmLoading: false
    })
  }
  
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record) => {
    const { setting, Tab, BID, btn, selectedData } = this.props
    const { loading } = this.state
  actionTrigger = (triggerId, record, type) => {
    const { Tab, BID, btn, selectedData, setting } = this.props
    const { loading, disabled } = this.state
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return
    if (Tab && Tab.supMenu && !BID) {
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        duration: 5
      })
      return
    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
      if (record[0].$Index !== selectedData[0].$Index) {
        return
      }
    }
    this.setState({autoMatic: type === 'autoMatic'})
    let _this = this
    let data = record || selectedData || []
@@ -113,14 +188,6 @@
      notification.warning({
        top: 92,
        message: this.state.dict['main.action.confirm.selectSingleLine'],
        duration: 5
      })
      return
    } else if (!setting.primaryKey) {
      // 需要选择行时,校验是否设置主键
      notification.warning({
        top: 92,
        message: '未设置主键!',
        duration: 5
      })
      return
@@ -178,8 +245,15 @@
      return
    }
    if (btn.OpenType === 'prompt') {
      this.updateStatus('start')
    this.setState({
      selines: data
    })
    if (btn.OpenType === 'formSubmit') {
      MKEmitter.emit('mkFormSubmit', btn.uuid)
      return
    } else if (btn.OpenType === 'prompt') {
      this.setState({loading: true})
      confirm({
        title: this.state.dict['main.action.confirm.tip'],
        onOk() {
@@ -188,18 +262,21 @@
          })
        },
        onCancel() {
          _this.updateStatus('over')
          _this.setState({loading: false})
        }
      })
    } else if (btn.OpenType === 'exec') {
      this.updateStatus('start')
      this.setState({loading: true})
      this.execSubmit(data, () => { this.setState({loading: false})})
    } else if (btn.OpenType === 'pop') {
      this.updateStatus('start')
      let modal = this.state.btnconfig
      if (!modal && btn.modal) {
        modal = this.handleModelConfig(btn.modal)
      }
      this.setState({
        tabledata: data,
        btnconfig: btn.modal ? btn.modal : this.state.btnconfig
        loading: true,
        btnconfig: modal
      }, () => {
        this.improveAction()
      })
@@ -231,7 +308,7 @@
      
      let primaryId = ''
      if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') {
      if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) {
        let ids = data.map(d => { return d[setting.primaryKey] || ''})
        ids = ids.filter(Boolean)
        primaryId = ids.join(',')
@@ -239,7 +316,17 @@
      if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行
        param.ID = primaryId
        param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 数据源
        if (retmsg) {
          const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
          param.LText = sql
          param.$callbacksql = callbacksql
        } else {
          param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
          if (btn.output) {
            param.key_back_type = 'Y'
          }
        }
        if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
          param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -262,7 +349,7 @@
        }
        param.LText = Utils.formatOptions(param.LText)
      } else if (btn.OpenType === 'pop') { // 表单
      } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 表单
        if (btn.sqlType === 'insert') { // 系统函数添加时,生成uuid
          primaryId = ''
@@ -274,7 +361,17 @@
          }
          param.ID = primaryId || Utils.getguid()
          param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源
          if (retmsg) {
            const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            param.LText = sql
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
          
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
            param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -299,7 +396,17 @@
          param.LText = Utils.formatOptions(param.LText)
        } else {
          param.ID = primaryId
          param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源
          if (retmsg) {
            const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            param.LText = sql
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
          
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
            param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -334,6 +441,10 @@
      param.menuname = btn.logLabel
      if (window.GLOB.probation) {
        param.s_debug_type = 'Y'
      }
      if (check_param) {
        check_param.menuname = btn.logLabel
        this.setState({checkParam: check_param})
@@ -354,7 +465,17 @@
        if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行
          param.ID = primaryId
          param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 数据源
          if (retmsg) {
            const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
            param.LText = sql
            param.$callbacksql = callbacksql
          } else {
            param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 数据源
            if (btn.output) {
              param.key_back_type = 'Y'
            }
          }
          
          if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
            param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -380,7 +501,17 @@
          if (btn.sqlType === 'insert') { // 系统函数添加时,生成uuid
            param.ID = Utils.getguid()
            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源
            if (retmsg) {
              const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              param.LText = sql
              param.$callbacksql = callbacksql
            } else {
              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              if (btn.output) {
                param.key_back_type = 'Y'
              }
            }
            
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
              param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -396,7 +527,17 @@
            param.LText = Utils.formatOptions(param.LText)
          } else {
            param.ID = primaryId
            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源
            if (retmsg) {
              const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              param.LText = sql
              param.$callbacksql = callbacksql
            } else {
              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 数据源
              if (btn.output) {
                param.key_back_type = 'Y'
              }
            }
            
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
              param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -419,6 +560,9 @@
        if (param.func === 'sPC_TableData_InUpDe') {
          param.menuname = btn.logLabel
          if (window.GLOB.probation) {
            param.s_debug_type = 'Y'
          }
        }
        return param
@@ -443,15 +587,17 @@
      
      let primaryId = ''
      if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') {
      if ((btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') && setting.primaryKey) {
        let ids = data.map(d => { return d[setting.primaryKey] || ''})
        ids = ids.filter(Boolean)
        primaryId = ids.join(',')
      }
      param[setting.primaryKey] = primaryId // 设置主键参数
      if (setting.primaryKey) {
        param[setting.primaryKey] = primaryId // 设置主键参数
      }
      if (btn.OpenType === 'pop') { // 表单
      if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 表单
        formdata.forEach(_data => {
          param[_data.key] = _data.value
        })
@@ -490,7 +636,9 @@
            param[_data.key] = _data.value
          })
        }
        param[setting.primaryKey] = primaryId
        if (setting.primaryKey) {
          param[setting.primaryKey] = primaryId
        }
        if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 函数 s_sDataDictb_TBBack 云端验证
          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -510,6 +658,41 @@
   */
  execSubmit = (data, _resolve, formdata) => {
    const { setting, btn } = this.props
    this.moduleParams = null
    if (
      (btn.intertype === 'system' || (btn.intertype === 'custom' && btn.procMode === 'system')) &&
      btn.sqlType !== 'insert' && btn.Ot !== 'notRequired' && btn.verify && btn.verify.invalid === 'true' &&
      setting.dataresource
    ) {
      MKEmitter.emit('queryModuleParam', btn.$menuId, btn.uuid)
      setTimeout(() => {
        if (this.moduleParams) {
          this.execRealSubmit(data, _resolve, formdata)
        } else {
          setTimeout(() => {
            this.execRealSubmit(data, _resolve, formdata)
          }, 100)
        }
      }, 50)
    } else {
      this.execRealSubmit(data, _resolve, formdata)
    }
  }
  execRealSubmit = (data, _resolve, formdata) => {
    const { setting, btn, Tab, BID } = this.props
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
        duration: 5
      })
      _resolve()
      return
    }
    if (btn.intertype === 'system' || btn.intertype === 'inner') { // 系统接口
      let params = []
@@ -520,14 +703,41 @@
      }
      if (params.length <= 20) {
        let deffers = params.map(param => {
        let deffers = params.map((param, i) => {
          return new Promise(resolve => {
            Api.genericInterface(param).then(res => {
              resolve(res)
            }, () => {
              this.updateStatus('over')
              _resolve()
            })
            setTimeout(() => {
              let _param = null
              if (btn.preFunc) {
                _param = fromJS(param).toJS()
                param.func = btn.preFunc
              }
              Api.genericInterface(param).then(res => {
                if (btn.preFunc && res.status && res.ErrCode !== '-1') {
                  _param = {..._param, ...res}
                  delete _param.status
                  delete _param.ErrCode
                  delete _param.ErrMesg
                  delete _param.message
                  setTimeout(() => {
                    Api.genericInterface(_param).then(result => {
                      if (!result.status) {
                        notification.warning({
                          top: 92,
                          message: result.message,
                          duration: 5
                        })
                      }
                    })
                  }, 600)
                }
                resolve(res)
              }, () => {
                this.updateStatus()
                _resolve()
              })
            }, 100 * i)
          })
        })
        Promise.all(deffers).then(result => {
@@ -562,7 +772,7 @@
          param.BID = this.props.BID
        }
        if (btn.OpenType === 'pop' && formdata) { // 表单
        if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 表单
          formdata.forEach(_data => {
            param[_data.key] = _data.value
          })
@@ -638,15 +848,23 @@
      loadingNumber: params.length || ''
    })
    let record = {
      BID: param.BID || '',
      ID: param.ID || '',
      callbacksql: param.$callbacksql || ''
    }
    delete param.$callbacksql
    Api.genericInterface(param).then(res => {
      if (res.status) {
        if (res.mk_ex_invoke === 'false' && params.length === 0) {
        if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length === 0) {
          this.execSuccess(res)
          _resolve()
        } else if (res.mk_ex_invoke === 'false' && params.length > 0) {
        } else if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length > 0) {
          this.customLoopRequest(params, _resolve)
        } else {
          this.customOuterRequest(params, res, _resolve)
          this.customOuterRequest(params, res, record, _resolve)
        }
      } else if (res.ErrCode === 'C' && this.state.checkParam) {
        const _this = this
@@ -657,13 +875,13 @@
            return new Promise(resolve => {
              Api.genericInterface(_this.state.checkParam).then((result) => {
                if (result.status) {
                  if (result.mk_ex_invoke === 'false' && params.length === 0) {
                  if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length === 0) {
                    _this.execSuccess(result)
                    _resolve()
                  } else if (result.mk_ex_invoke === 'false' && params.length > 0) {
                  } else if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length > 0) {
                    _this.customLoopRequest(params, _resolve)
                  } else {
                    _this.customOuterRequest(params, result, _resolve)
                    _this.customOuterRequest(params, result, record, _resolve)
                  }
                } else {
                  _this.execError(result)
@@ -671,7 +889,7 @@
                }
                resolve()
              }, () => {
                _this.updateStatus('over')
                _this.updateStatus()
                resolve()
                _resolve()
              })
@@ -688,7 +906,7 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _resolve()
    })
  }
@@ -696,7 +914,7 @@
  /**
   * @description 自定义请求循环执行
   */
  customOuterRequest = (params, result, _resolve) => {
  customOuterRequest = (params, result, record, _resolve) => {
    const { btn } = this.props
    let url = ''
@@ -722,8 +940,8 @@
      param[key] = result[key]
    })
    Api.directRequest(url, btn.method, param).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
    Api.directRequest(url, btn.method, param, btn.cross).then(res => {
      if (typeof(res) !== 'object') {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
@@ -736,21 +954,29 @@
          $ErrMesg: error
        }
        this.customCallbackRequest(params, result, _resolve)
        this.customCallbackRequest(params, result, record, _resolve)
      } else {
        if (Array.isArray(res)) {
          res = { data: res }
        }
        res.mk_api_key = mkey
        this.customCallbackRequest(params, res, _resolve)
        this.customCallbackRequest(params, res, record, _resolve)
      }
    }, () => {
      this.updateStatus('over')
      _resolve()
    }, (e) => {
      let result = {
        mk_api_key: mkey,
        $ErrCode: 'E',
        $ErrMesg: e && e.statusText ? e.statusText : ''
      }
      this.customCallbackRequest([], result, record, _resolve)
    })
  }
  /**
   * @description 回调请求循环执行
   */
  customCallbackRequest = (params, result, _resolve) => {
  customCallbackRequest = (params, result, record, _resolve) => {
    const { btn } = this.props
    let lines = []
    let pre = btn.callbackType === 'script' ? '@' : ''
@@ -790,6 +1016,9 @@
            subObjs.push(val)
          }
        } else {
          if (typeof(val) === 'string') {
            val = val.replace(/'/ig, '"')
          }
          keys.push(key)
          vals.push(`'${val}'`)
        }
@@ -828,12 +1057,14 @@
    if (btn.callbackType === 'script') { // 使用自定义脚本
      param.func = 'sPC_TableData_InUpDe'
      
      if (this.props.BID) {
      if (record.BID) {
        param.BID = this.props.BID
      }
      if (record.ID) {
        param.ID = record.ID
      }
      let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
        Select @ErrorCode='',@retmsg=''
      let _prevCustomScript = `${record.callbacksql}
        ${errSql}
      `
      let _backCustomScript = ''
@@ -855,7 +1086,7 @@
      })
      _backCustomScript += `
      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
      let sql = [...lineMap.values()].map(item => (`
        ${item.insert}
@@ -885,6 +1116,10 @@
      param.secretkey = Utils.encrypt('', param.timestamp)
      param.LText = Utils.formatOptions(param.LText)
      param.menuname = btn.logLabel
      if (window.GLOB.probation) {
        param.s_debug_type = 'Y'
      }
      if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -923,7 +1158,7 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _resolve()
    })
  }
@@ -938,8 +1173,35 @@
      loadingNumber: params.length || ''
    })
    let _param = null
    if (btn.preFunc) {
      _param = fromJS(param).toJS()
      param.func = btn.preFunc
    }
    Api.genericInterface(param).then(res => {
      if (res.status) {
        if (btn.preFunc && res.ErrCode !== '-1') {
          _param = {..._param, ...res}
          delete _param.status
          delete _param.ErrCode
          delete _param.ErrMesg
          delete _param.message
          setTimeout(() => {
            Api.genericInterface(_param).then(result => {
              if (!result.status) {
                notification.warning({
                  top: 92,
                  message: result.message,
                  duration: 5
                })
              }
            })
          }, 600)
        }
        if (params.length === 0) {
          this.execSuccess(res)
          _resolve()
@@ -951,7 +1213,7 @@
        _resolve()
      }
    }, () => {
      this.updateStatus('over')
      this.updateStatus()
      _resolve()
    })
  }
@@ -1004,7 +1266,7 @@
            _resolve()
          }
        }, () => {
          this.updateStatus('over')
          this.updateStatus()
          _resolve()
        })
      } else {
@@ -1022,7 +1284,11 @@
        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
          res.rduri = options.cloudServiceApi
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            res.rduri = btn.proInterface
          } else {
            res.rduri = btn.interface
          }
        }
        // 函数 s_sDataDictb_TBBack 云端验证
@@ -1035,7 +1301,11 @@
        if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
          res.rduri = window.GLOB.mainSystemApi
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
          if (window.GLOB.systemType === 'production' && btn.proInterface) {
            res.rduri = btn.proInterface
          } else {
            res.rduri = btn.interface
          }
        }
      }
@@ -1102,9 +1372,9 @@
   */
  execSuccess = (res) => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (res && res.ErrCode === 'S') { // 执行成功
    if ((res && res.ErrCode === 'S') || autoMatic) { // 执行成功
      notification.success({
        top: 92,
        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
@@ -1118,7 +1388,14 @@
    }
    
    if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
    if (autoMatic) {
      this.setState({
        loading: false,
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'success')
      return
    } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
      this.setState({
        loading: false,
        visible: false
@@ -1129,8 +1406,42 @@
      this.sendMessage()
    }
    if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn)
    let id = ''
    if (btn.output) {
      id = res.mk_b_id || res[btn.output] || ''
    }
    if (btn.execSuccess === 'closetab') {
      MKEmitter.emit('closeTabView', btn.$MenuID)
    } else if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
    }
    if (btn.refreshTab && btn.refreshTab.length > 0) {
      MKEmitter.emit('reloadMenuView', btn.refreshTab[btn.refreshTab.length - 1], 'table')
    }
    if (btn.switchTab && btn.switchTab.length > 0) {
      let id = btn.switchTab[btn.switchTab.length - 1]
      let node = document.getElementById('tab' + id)
      node && node.click()
    }
    if (btn.openmenu && btn.openmenu.length > 0 && btn.MenuID) {
      let newtab = {
        MenuID: btn.MenuID,
        MenuName: btn.MenuName,
        MenuNo: btn.MenuNo,
        type: btn.tabType,
        param: {
          $BID: id
        }
      }
      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
        MKEmitter.emit('modifyTabs', newtab, 'replace')
      } else {
        MKEmitter.emit('modifyTabs', newtab, 'plus', true)
      }
    }
  }
@@ -1160,6 +1471,7 @@
      let _param = {
        templatecode: verify.noteCode, // 模板编码
        TypeCharOne: verify.noteTemp,  // N不同内容,Y相同内容
        ID: verify.noteId || ''        // 模板Id,暂时未使用
      }
      _param.submitdate = res.submitdate
@@ -1224,10 +1536,12 @@
      _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
      _param.rduri = 'http://sso.mk9h.cn/webapi/dostar'
      _param.appkey = window.GLOB.appkey || ''
      _param.rduri = 'http://sso.mk9h.cn/webapi/dostars'
      Api.dostarInterface(_param).then(result => {
      _param.userid = 'bh0bapabtd45epsgra79segbch6c1ibk'
      _param.LoginUID = 'bh0bapabtd45epsgra79segbch6c1ibk'
      Api.getLocalConfig(_param).then(result => {
        if (!result.status) {
          notification.warning({
            top: 92,
@@ -1247,12 +1561,13 @@
   */
  execError = (res) => {
    const { btn } = this.props
    const { btnconfig, autoMatic } = this.state
    if (res.ErrCode === 'E') {
    if (res.ErrCode === 'E' && !autoMatic) {
      Modal.error({
        title: res.message || res.ErrMesg,
      })
    } else if (res.ErrCode === 'N') {
    } else if (res.ErrCode === 'N' || autoMatic) {
      notification.error({
        top: 92,
        message: res.message || res.ErrMesg,
@@ -1267,6 +1582,16 @@
      })
    } else if (res.ErrCode === 'NM') {
      message.error(res.message || res.ErrMesg)
    }
    if (autoMatic) {
      this.setState({
        loading: false,
        loadingNumber: '',
        visible: false
      })
      MKEmitter.emit('autoExecOver', btn.uuid, 'error')
      return
    }
    
    this.setState({
@@ -1303,7 +1628,7 @@
              visible: false
            })
            if (btn.execError !== 'never') {
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
              MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
            }
          }
        })
@@ -1316,8 +1641,12 @@
      }
    }
    if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) {
      MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus)
    }
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    }
  }
@@ -1332,15 +1661,38 @@
    })
  }
  handleModelConfig = (config) => {
    let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
    config.fields = config.fields.map(cell => {
      // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
      if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
        let _option = Utils.getSelectQueryOptions(cell)
        cell.data_sql = Utils.formatOptions(_option.sql)
        cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
        cell.arr_field = _option.field
      }
      // 字段权限黑名单
      if (!cell.blacklist || cell.blacklist.length === 0) return cell
      if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
        cell.hidden = 'true'
      }
      return cell
    })
    return config
  }
  /**
   * @description 获取按钮配置信息
   */
  improveAction = () => {
    const { btn } = this.props
    const { btnconfig } = this.state
    const { btnconfig, autoMatic } = this.state
    if (btnconfig) {
      if (btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示
      if (!autoMatic && btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示
        this.modelconfirm()
      } else {
        this.setState({
@@ -1369,80 +1721,22 @@
            message: res.message,
            duration: 5
          })
          this.updateStatus('over')
          this.setState({ loading: false })
        } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) {
          notification.warning({
            top: 92,
            message: '未获取到按钮配置信息!',
            duration: 5
          })
          this.updateStatus('over')
          this.setState({ loading: false })
        } else {
          let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
          if (_LongParam.groups.length > 0) {
            _LongParam.groups.forEach(group => {
              group.sublist = group.sublist.map(cell => {
                // 数据源sql语句,预处理, 权限黑名单字段设置为隐藏表单
                if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                  let _option = Utils.getSelectQueryOptions(cell)
                  if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                    _option.sql = _option.sql.replace(/\$@/ig, '/*')
                    _option.sql = _option.sql.replace(/@\$/ig, '*/')
                  } else {
                    _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
                  }
                  // 外联数据库替换
                  if (window.GLOB.externalDatabase !== null) {
                    _option.sql = _option.sql.replace(/@db@/ig, window.GLOB.externalDatabase)
                  }
                  cell.data_sql = Utils.formatOptions(_option.sql)
                  cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
                  cell.arr_field = _option.field
                }
                // 字段权限黑名单
                if (!cell.blacklist || cell.blacklist.length === 0) return cell
                if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                  cell.hidden = 'true'
                }
                return cell
              })
            })
          } else {
            _LongParam.fields = _LongParam.fields.map(cell => {
              // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
              if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(cell)
                if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                  _option.sql = _option.sql.replace(/\$@/ig, '/*')
                  _option.sql = _option.sql.replace(/@\$/ig, '*/')
                } else {
                  _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
                }
                cell.data_sql = Utils.formatOptions(_option.sql)
                cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
                cell.arr_field = _option.field
              }
              // 字段权限黑名单
              if (!cell.blacklist || cell.blacklist.length === 0) return cell
              if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                cell.hidden = 'true'
              }
              return cell
            })
          }
          _LongParam = updateForm(_LongParam)
          _LongParam = this.handleModelConfig(_LongParam)
          this.setState({
            btnconfig: _LongParam
          }, () => {
            if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
            if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示
              this.modelconfirm()
            } else {
              this.setState({
@@ -1459,16 +1753,11 @@
   * @description 模态框(表单),确认
   */
  handleOk = () => {
    if (!this.formRef) return
    this.formRef.handleConfirm().then(res => {
      this.setState({
        confirmLoading: true
      })
      this.setState({ confirmLoading: true })
      this.execSubmit(this.state.tabledata, () => {
        this.setState({
          confirmLoading: false
        })
      }, res)
      this.execSubmit(this.state.selines, () => { this.setState({ confirmLoading: false }) }, res)
    })
  }
@@ -1477,27 +1766,20 @@
   */
  handleCancel = () => {
    this.setState({
      loading: false,
      visible: false,
      confirmLoading: false
    })
    this.updateStatus('over')
  }
  modelconfirm = () => {
    const { BData } = this.props
    const { btnconfig, tabledata } = this.state
    const { btnconfig, selines } = this.state
    let _this = this
    let _fields = []
    if (btnconfig.groups.length > 0) {
      btnconfig.groups.forEach(group => {
        _fields = [..._fields, ...group.sublist]
      })
    } else {
      _fields = btnconfig.fields
    }
    let result = _fields.map(item => {
    let result = []
    btnconfig.fields.forEach(item => {
      if (!item.field) return
      let _readin = item.readin !== 'false'
      let _initval = item.initval
@@ -1507,8 +1789,8 @@
      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
        _initval = BData[item.field]
      } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) {
        _initval = tabledata[0][item.field]
      } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) {
        _initval = selines[0][item.field]
      } else if (item.type === 'date' && _initval) {
        _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD')
      } else if (item.type === 'datemonth' && _initval) {
@@ -1524,25 +1806,36 @@
        _fieldlen = item.decimal ? item.decimal : 0
      }
      return {
      if (_initval === undefined) {
        _initval = ''
      }
      let _type = item.type
      if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') {
        _type = 'text'
      }
      result.push({
        key: item.field,
        readonly: item.readonly === 'true',
        readin: _readin,
        readin: item.readin !== 'false' && item.readin !== 'top',
        fieldlen: _fieldlen,
        type: item.type,
        writein: item.writein !== 'false',
        type: _type,
        value: _initval
      }
      })
    })
    confirm({
      title: this.state.dict['main.action.confirm.tip'],
      onOk() {
        return new Promise(resolve => {
          _this.execSubmit(tabledata, resolve, result)
          _this.execSubmit(selines, resolve, result)
        })
      },
      onCancel() {
        _this.updateStatus('over')
        _this.setState({ loading: false })
      }
    })
  }
@@ -1551,58 +1844,96 @@
   * @description 显示模态框
   */
  getModels = () => {
    const { setting, BID, btn } = this.props
    const { setting, BID, btn, BData } = this.props
    const { btnconfig, visible } = this.state
    if (!btnconfig || !btnconfig.setting) return null
    let title = btnconfig.setting.title
    let width = btnconfig.setting.width + 'vw'
    let clickouter = false
    let container = document.body
    let clickouter = btnconfig.setting.clickouter === 'close'
    if (
      (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
      (btnconfig.setting.container === 'tab' && btn.ContainerId)
    ) {
      width = btnconfig.setting.width + '%'
      container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
    if (btnconfig.setting.display === 'drawer') {
      let height = '100vh'
      if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') {
        width = '100vw'
        height = btnconfig.setting.width + 'vh'
      }
      return (
        <Drawer
          title={title}
          width={width}
          height={height}
          maskClosable={clickouter}
          onClose={this.handleCancel}
          visible={visible}
          placement={btnconfig.setting.placement || 'right'}
          bodyStyle={{ paddingBottom: 80 }}
          destroyOnClose
        >
          <MutilForm
            BID={BID}
            dict={this.state.dict}
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
          <div style={{ position: 'absolute', zIndex: 1, right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right'}}>
            <Button onClick={this.handleCancel} style={{ marginRight: 8 }}>
              {btnconfig.setting.formType !== 'check' ? '取消' : '关闭'}
            </Button>
            {btnconfig.setting.formType !== 'check' ? <Button onClick={this.handleOk} loading={this.state.confirmLoading} type="primary">
              确定
            </Button> : null}
          </div>
        </Drawer>
      )
    } else {
      let container = document.body
      if (
        (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) ||
        (btnconfig.setting.container === 'tab' && btn.ContainerId)
      ) {
        width = btnconfig.setting.width + '%'
        container = () => document.getElementById(this.props.ContainerId || btn.ContainerId)
      }
      return (
        <Modal
          title={title}
          maskClosable={clickouter}
          getContainer={container}
          wrapClassName='action-modal'
          visible={visible}
          width={width}
          onOk={this.handleOk}
          confirmLoading={this.state.confirmLoading}
          onCancel={this.handleCancel}
          destroyOnClose
        >
          <MutilForm
            BID={BID}
            dict={this.state.dict}
            menuType={this.props.menuType}
            action={btnconfig}
            inputSubmit={this.handleOk}
            data={this.state.selines[0]}
            BData={BData}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />
        </Modal>
      )
    }
    if (btnconfig.setting.clickouter === 'close') {
      clickouter = true
    }
    return (
      <Modal
        title={title}
        maskClosable={clickouter}
        getContainer={container}
        wrapClassName='action-modal'
        visible={visible}
        width={width}
        onOk={this.handleOk}
        confirmLoading={this.state.confirmLoading}
        onCancel={this.handleCancel}
        destroyOnClose
      >
        <MutilForm
          BID={BID}
          dict={this.state.dict}
          menuType={this.props.menuType}
          action={btnconfig}
          inputSubmit={this.handleOk}
          data={this.state.tabledata[0]}
          BData={this.props.BData}
          wrappedComponentRef={(inst) => this.formRef = inst}
        />
      </Modal>
    )
  }
  render() {
    const { btn, show, style } = this.props
    const { loadingNumber, loading, visible } = this.state
    const { loadingNumber, loading, disabled, hidden } = this.state
    if (hidden) return null
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
@@ -1610,13 +1941,14 @@
          style={style}
          icon={btn.icon}
          loading={loading}
          disabled={disabled}
          className={'mk-btn mk-' + btn.class}
          onClick={() => {this.actionTrigger()}}
        >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button>
        {visible ? this.getModels() : null}
        {this.getModels()}
      </div>
    } else if (show && show.indexOf('plus') > -1) {
      return <div className="mk-btn-wrap">
      return <div style={{display: 'inline-block'}}>
        <Button
          type="link"
          loading={loading}
@@ -1624,19 +1956,36 @@
          style={{fontSize: show.substring(4) + 'px'}}
          onClick={() => {this.actionTrigger()}}
        ></Button>
        {visible ? this.getModels() : null}
        {this.getModels()}
      </div>
    } else { // icon、text、 all 卡片
      let label = ''
      let icon = ''
      if (show === 'button') {
        label = btn.label
        icon = btn.icon || ''
      } else if (show === 'link') {
        label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
        icon = ''
      } else if (show === 'icon') {
        icon = btn.icon || ''
      // } else if (show === 'text') {
      } else {
        label = btn.label
      }
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        <Button
          type="link"
          title={show === 'icon' ? btn.label : ''}
          loading={loading}
          style={btn.btnstyle || style}
          icon={show === 'text' ? '' : (btn.icon || '')}
          disabled={disabled}
          style={btn.style || style}
          icon={icon}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
        {visible ? this.getModels() : null}
        >{label}</Button>
        {this.getModels()}
      </div>
    }
  }
@@ -1644,7 +1993,6 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    menuType: state.editLevel
  }
}