king
2020-09-14 76427d51a079a5fd1f45bf7188249e7a4647ae05
src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -25,7 +25,7 @@
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    btn: PropTypes.object,            // 按钮
    columns: PropTypes.array,         // 字段列
    columns: PropTypes.any,           // 字段列
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    updateStatus: PropTypes.func,     // 按钮状态更新
@@ -126,12 +126,12 @@
      // 数据选择类型校验
      this.actionSettingError()
      return
    } else if (btn.intertype === 'inner') {
      // 使用内部接口时,内部函数和数据源不可同时为空, 使用系统函数时,类型不可为空
      if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) {
    } else if (btn.intertype === 'system') {
      // 使用内部接口时,操作类型和数据源不可为空
      if (!btn.sql || !btn.sqlType) {
        this.actionSettingError()
        return
      } else if (data.length === 0 && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) {
      } else if (data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) {
        notification.warning({
          top: 92,
          message: '使用创建凭证函数,需要选择行!',
@@ -139,13 +139,19 @@
        })
        return
      }
    } else if (btn.intertype === 'outer') {
      // 接口地址不存在时报错
      if (!btn.interface) {
    } else if (btn.intertype === 'inner') {
      // 使用内部接口时,内部函数不可为空
      if (!btn.innerFunc) {
        this.actionSettingError()
        return
      }
    } else if (!['inner', 'outer'].includes(btn.intertype)) {
    } else if (btn.intertype === 'outer') {
      // 接口地址不存在时报错
      if (!btn.interface && btn.sysInterface !== 'true') {
        this.actionSettingError()
        return
      }
    } else if (!['inner', 'outer', 'system'].includes(btn.intertype)) {
      // 接口类型错误
      this.actionSettingError()
      return
@@ -182,7 +188,7 @@
   */
  execSubmit = (data, _resolve, formdata) => {
    const { setting, columns, btn } = this.props
    if (btn.intertype === 'inner') {
    if (btn.intertype === 'inner' || btn.intertype === 'system') {
      // 执行方式为多行拼接,且打开方式为表单时,会转为循环发送请求
      // 打开方式为模态框,使用内部函数添加(有批量添加场景,已去除)
      if (
@@ -223,8 +229,13 @@
              param.LText = param.LText.replace(/@\$|\$@/ig, '')
            }
            param.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
            param.LText2 = LText2
            param.LText1 = LText1
            param.LText = LText
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
          }
        } else if (btn.OpenType === 'pop') { // 表单
@@ -259,8 +270,13 @@
              param.LText = param.LText.replace(/@\$|\$@/ig, '')
            }
            param.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
            let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
            param.LText2 = LText2
            param.LText1 = LText1
            param.LText = LText
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
          } else if (btn.sql) {
            param.ID = primaryId
@@ -272,15 +288,24 @@
            } 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.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
          }
        }
        if (this.props.menuType === 'HS' && param.timestamp) { // 云端验证
          param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
        if (this.props.menuType === 'HS' && param.timestamp) { // 函数 sPC_TableData_InUpDe 云端验证
          param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
        } else 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')
          param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
          param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
        }
        Api.genericInterface(param).then((res) => {
@@ -332,8 +357,12 @@
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              param.LText = Utils.formatOptions(param.LText)
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            }
          } else if (btn.OpenType === 'pop') { // 表单
@@ -367,8 +396,13 @@
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              param.LText = Utils.formatOptions(param.LText)
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            } else if (btn.sql) {
              param.ID = primaryId
@@ -381,14 +415,23 @@
                param.LText = param.LText.replace(/@\$|\$@/ig, '')
              }
              param.LText = Utils.formatOptions(param.LText)
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
              let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
              param.LText2 = LText2
              param.LText1 = LText1
              param.LText = LText
              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            }
          }
          if (this.props.menuType === 'HS' && param.timestamp) { // 云端验证
            param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
          if (this.props.menuType === 'HS' && param.timestamp) { // 函数 sPC_TableData_InUpDe 云端验证
            param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
          } else 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')
            param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp)
            param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
          }
          return param
@@ -539,6 +582,14 @@
      // 内部请求
      if (btn.innerFunc) {
        param.func = btn.innerFunc
        // 函数 s_sDataDictb_TBBack 云端验证
        if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) {
          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)
        }
        // 存在内部函数时,数据预处理
        Api.genericInterface(param).then(res => {
          if (res.status) {
@@ -571,11 +622,21 @@
      // 外部请求
      _outParam = JSON.parse(JSON.stringify(res))
      if (btn.outerFunc) {
        res.func = btn.outerFunc
      }
      if (this.props.menuType === 'HS') {
        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
          res.rduri = options.cloudServiceApi
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
        }
        // 函数 s_sDataDictb_TBBack 云端验证
        if (res.func === 's_sDataDictb_TBBack' && res.LTextOut) {
          res.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
          res.secretkey = Utils.encrypt(res.LTextOut, res.timestamp)
          res.open_key = Utils.encryptOpenKey(res.secretkey, res.timestamp)
        }
      } else {
        if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) {
@@ -583,10 +644,6 @@
        } else if (btn.sysInterface !== 'true') {
          res.rduri = btn.interface
        }
      }
      if (btn.outerFunc) {
        res.func = btn.outerFunc
      }
      return Api.genericInterface(res)
@@ -601,6 +658,14 @@
        response.func = btn.callbackFunc
        let _callbackparam = {..._outParam, ...response}
        // 函数 s_sDataDictb_TBBack 云端验证
        if (this.props.menuType === 'HS' && _callbackparam.func === 's_sDataDictb_TBBack' && _callbackparam.LTextOut) {
          _callbackparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
          _callbackparam.secretkey = Utils.encrypt(_callbackparam.LTextOut, _callbackparam.timestamp)
          _callbackparam.open_key = Utils.encryptOpenKey(_callbackparam.secretkey, _callbackparam.timestamp)
        }
        return Api.genericInterface(_callbackparam)
      } else {
        if (response.status) {
@@ -743,7 +808,7 @@
        })
      }
    } else {
      Api.getSystemCacheConfig({
      Api.getCacheConfig({
        func: 'sPC_Get_LongParam',
        MenuID: btn.uuid
      }).then(res => {
@@ -775,8 +840,8 @@
        } else {
          if (_LongParam.groups.length > 0) {
            _LongParam.groups.forEach(group => {
              group.sublist = group.sublist.filter(cell => {
                // 数据源sql语句,预处理
              group.sublist = group.sublist.map(cell => {
                // 数据源sql语句,预处理, 权限黑名单字段设置为隐藏表单
                if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') {
                  let _option = Utils.getSelectQueryOptions(cell)
@@ -788,26 +853,27 @@
                  }
                  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 true
                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) {
                  return false
                } else {
                  return true
                  cell.hidden = 'true'
                }
                return cell
              })
            })
          } else {
            _LongParam.fields = _LongParam.fields.filter(cell => {
              // 数据源sql语句,预处理
            _LongParam.fields = _LongParam.fields.map(cell => {
              // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
              if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') {
                let _option = Utils.getSelectQueryOptions(cell)
@@ -819,21 +885,22 @@
                }
                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 true
              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) {
                return false
              } else {
                return true
                cell.hidden = 'true'
              }
              return cell
            })
          }
@@ -1010,6 +1077,7 @@
        {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null}
        {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
        {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null}
        {show && show.indexOf('plus') > -1 ? <Button className="action-cell" style={{fontSize: show.substring(4) + 'px'}} icon={btn.icon || 'plus'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null}
        {this.getModels()}
      </div>
    )