king
2020-12-16 06404e701a89955958cbf56213e2eec618d8644d
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -20,11 +20,12 @@
class NormalButton extends Component {
  static propTpyes = {
    show: PropTypes.any,              // 按钮显示样式控制
    position: PropTypes.any,          // 按钮位置,工具栏为toolbar
    BID: PropTypes.string,            // 主表ID
    BData: PropTypes.any,             // 主表数据
    style: PropTypes.any,             // 按钮样式
    selectedData: PropTypes.any,      // 子表中选择数据
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    btn: PropTypes.object,            // 按钮
    columns: PropTypes.any,           // 字段列
    setting: PropTypes.any,           // 页面通用设置
@@ -48,9 +49,9 @@
  }
  componentDidMount () {
    const { show } = this.props
    const { position } = this.props
    if (show === 'actionList') {
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
  }
@@ -81,7 +82,7 @@
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId) => {
  actionTrigger = (triggerId, record) => {
    const { setting, Tab, BID, btn, selectedData } = this.props
    const { loading } = this.state
@@ -97,7 +98,7 @@
    }
    let _this = this
    let data = selectedData || []
    let data = record || selectedData || []
    if (btn.Ot !== 'notRequired' && data.length === 0) {
      // 需要选择行时,校验数据
@@ -176,8 +177,10 @@
      this.execSubmit(data, () => { this.setState({loading: false})})
    } else if (btn.OpenType === 'pop') {
      this.updateStatus('start')
      this.setState({
        tabledata: data
        tabledata: data,
        btnconfig: btn.modal ? btn.modal : this.state.btnconfig
      }, () => {
        this.improveAction()
      })
@@ -223,21 +226,17 @@
            param.ID = primaryId
            param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 数据源
            if (this.props.dataManager) { // 数据权限
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
              param.LText = param.LText.replace(/\$@/ig, '/*')
              param.LText = param.LText.replace(/@\$/ig, '*/')
            } else {
              param.LText = param.LText.replace(/@\$|\$@/ig, '')
            }
            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
            param.LText2 = LText2
            param.LText1 = LText1
            param.LText = LText
            param.exec_type = 'y' // 后台解码
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            param.secretkey = Utils.encrypt('', param.timestamp)
            param.LText = Utils.formatOptions(param.LText)
          }
        } else if (btn.OpenType === 'pop') { // 表单
          if (btn.innerFunc) {
@@ -264,40 +263,32 @@
            param.ID = primaryId || Utils.getguid()
            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 数据源
            
            if (this.props.dataManager) { // 数据权限
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
              param.LText = param.LText.replace(/\$@/ig, '/*')
              param.LText = param.LText.replace(/@\$/ig, '*/')
            } else {
              param.LText = param.LText.replace(/@\$|\$@/ig, '')
            }
            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
            param.LText2 = LText2
            param.LText1 = LText1
            param.LText = LText
            param.exec_type = 'y' // 后台解码
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            param.secretkey = Utils.encrypt('', param.timestamp)
            param.LText = Utils.formatOptions(param.LText)
          } else if (btn.sql) {
            param.ID = primaryId
            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 数据源
            
            if (this.props.dataManager) { // 数据权限
            if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
              param.LText = param.LText.replace(/\$@/ig, '/*')
              param.LText = param.LText.replace(/@\$/ig, '*/')
            } else {
              param.LText = param.LText.replace(/@\$|\$@/ig, '')
            }
            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
            param.LText2 = LText2
            param.LText1 = LText1
            param.LText = LText
            param.exec_type = 'y' // 后台解码
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            param.secretkey = Utils.encrypt('', param.timestamp)
            param.LText = Utils.formatOptions(param.LText)
          }
        }
@@ -307,6 +298,10 @@
          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
          param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
          param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
        }
        if (param.func === 'sPC_TableData_InUpDe') {
          param.menuname = btn.logLabel
        }
        Api.genericInterface(param).then((res) => {
@@ -351,20 +346,17 @@
              param.ID = primaryId
              param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 数据源
              
              if (this.props.dataManager) { // 数据权限
              if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                param.LText = param.LText.replace(/\$@/ig, '/*')
                param.LText = param.LText.replace(/@\$/ig, '*/')
              } else {
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.exec_type = 'y' // 后台解码
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
              param.secretkey = Utils.encrypt('', param.timestamp)
              param.LText = Utils.formatOptions(param.LText)
            }
          } else if (btn.OpenType === 'pop') { // 表单
            if (index !== 0) {
@@ -390,40 +382,32 @@
              param.ID = _formPrimaryId || Utils.getguid()
              param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 数据源
              
              if (this.props.dataManager) { // 数据权限
              if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                param.LText = param.LText.replace(/\$@/ig, '/*')
                param.LText = param.LText.replace(/@\$/ig, '*/')
              } else {
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.exec_type = 'y' // 后台解码
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
              param.secretkey = Utils.encrypt('', param.timestamp)
              param.LText = Utils.formatOptions(param.LText)
            } else if (btn.sql) {
              param.ID = primaryId
              param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 数据源
              
              if (this.props.dataManager) { // 数据权限
              if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                param.LText = param.LText.replace(/\$@/ig, '/*')
                param.LText = param.LText.replace(/@\$/ig, '*/')
              } else {
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.exec_type = 'y' // 后台解码
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
              param.secretkey = Utils.encrypt('', param.timestamp)
              param.LText = Utils.formatOptions(param.LText)
            }
          }
@@ -433,6 +417,10 @@
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
            param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
          }
          if (param.func === 'sPC_TableData_InUpDe') {
            param.menuname = btn.logLabel
          }
          return param
@@ -737,7 +725,7 @@
      this.sendMessage()
    }
    this.props.updateStatus('refresh', btn.execSuccess)
    this.props.updateStatus('refresh', btn.execSuccess, btn)
  }
  sendMessage = () => {
@@ -879,7 +867,7 @@
      loading: false
    })
    this.props.updateStatus('refresh', btn.execError)
    this.props.updateStatus('refresh', btn.execError, btn)
  }
  /**
@@ -939,6 +927,7 @@
          })
          this.updateStatus('over')
        } else {
          let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
          if (_LongParam.groups.length > 0) {
            _LongParam.groups.forEach(group => {
              group.sublist = group.sublist.map(cell => {
@@ -946,11 +935,15 @@
                if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                  let _option = Utils.getSelectQueryOptions(cell)
                  if (this.props.dataManager) { // 数据权限
                  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)
@@ -960,12 +953,7 @@
                // 字段权限黑名单
                if (!cell.blacklist || cell.blacklist.length === 0) return cell
                let _black = cell.blacklist.filter(v => {
                  return this.props.permRoles.indexOf(v) !== -1
                })
                if (_black.length > 0) {
                if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                  cell.hidden = 'true'
                }
@@ -978,7 +966,7 @@
              if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(cell)
                if (this.props.dataManager) { // 数据权限
                if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
                  _option.sql = _option.sql.replace(/\$@/ig, '/*')
                  _option.sql = _option.sql.replace(/@\$/ig, '*/')
                } else {
@@ -992,12 +980,7 @@
              // 字段权限黑名单
              if (!cell.blacklist || cell.blacklist.length === 0) return cell
              let _black = cell.blacklist.filter(v => {
                return this.props.permRoles.indexOf(v) !== -1
              })
              if (_black.length > 0) {
              if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
                cell.hidden = 'true'
              }
@@ -1164,12 +1147,13 @@
  }
  render() {
    const { btn, show } = this.props
    const { btn, show, style } = this.props
    const { loadingNumber, loading } = this.state
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        <Button
          style={style}
          icon={btn.icon}
          loading={loading}
          className={'mk-btn mk-' + btn.class}
@@ -1193,6 +1177,7 @@
        <Button
          type="link"
          loading={loading}
          style={btn.btnstyle || style}
          icon={show === 'text' ? '' : (btn.icon || '')}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' && btn.icon ? '' : btn.label}</Button>
@@ -1205,9 +1190,7 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    menuType: state.editLevel,
    permRoles: state.permRoles,
    dataManager: state.dataManager
    menuType: state.editLevel
  }
}