king
2024-05-16 b69b5f6329ca5f87932436b7a6c1ddfc3377e10f
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -106,12 +106,15 @@
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record, type) => {
    const { setting, BID, btn, selectedData } = this.props
  actionTrigger = (triggerId, record, type, lid) => {
    const { setting, BID, btn, selectedData, LID } = this.props
    const { loading, disabled } = this.state
    if (loading || disabled) return
    if (triggerId && btn.uuid !== triggerId) return
    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
    let data = record || selectedData || []
    if (setting.supModule && !BID) {
      notification.warning({
@@ -119,44 +122,35 @@
        message: '需要上级主键值!',
        duration: 5
      })
      return
    } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) {
      return
    }
    let data = record || selectedData || []
    if (btn.Ot === 'requiredSgl' && data.length !== 1) {
    } else if (btn.Ot === 'requiredSgl' && data.length !== 1) {
      // 需要选择单行时,校验数据
      notification.warning({
        top: 92,
        message: '请选择单行数据!',
        duration: 5
      })
      return
    } else if (!btn.verify || !btn.verify.sheet || !btn.verify.columns || btn.verify.columns.length === 0) {
      notification.warning({
        top: 92,
        message: 'excel导入验证信息未设置!',
        duration: 5
      })
      return
    }
    let primaryId = '' // 导入时行Id
    if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
      primaryId = data[0][setting.primaryKey] || ''
    }
    this.setState({
      selines: data,
      primaryId: primaryId
    }, () => {
      this.refs.excelIn.exceltrigger()
    })
    if (window.GLOB.systemType === 'production') {
      MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '导入Excel'})
    } else {
      let primaryId = '' // 导入时行Id
      if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
        primaryId = data[0][setting.primaryKey] || ''
      }
      this.setState({
        selines: data,
        primaryId: primaryId
      }, () => {
        this.refs.excelIn.exceltrigger()
      })
      if (window.GLOB.systemType === 'production') {
        MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: '导入Excel'})
      }
    }
  }
@@ -199,9 +193,15 @@
      if (btn.syncComponentId === 'multiComponent') {
        btn.syncComponentIds.forEach((id, i) => {
          setTimeout(() => {
            MKEmitter.emit('reloadData', id)
            if (/\$focus/.test(id)) {
              MKEmitter.emit('reloadData', id.split('$')[0], id.split('$')[1])
            } else {
              MKEmitter.emit('reloadData', id)
            }
          }, 20 * i)
        })
      } else if (/\$focus/.test(btn.syncComponentId)) {
        MKEmitter.emit('reloadData', btn.syncComponentId.split('$')[0], btn.syncComponentId.split('$')[1])
      } else {
        MKEmitter.emit('reloadData', btn.syncComponentId)
      }
@@ -270,43 +270,21 @@
  /**
   * @description Excel 导入
   */
  getexceldata = (data, errors, sheetName, errDetail) => {
  getexceldata = (data, error) => {
    const { btn, BID } = this.props
    if (errors) {
      if (errors === 'notexit') {
        notification.warning({
          top: 92,
          message: '工作表《' + sheetName + '》不存在!',
          duration: 5
        })
      } else if (errors === 'empty') {
        notification.warning({
          top: 92,
          message: '工作表《' + sheetName + '》为空!',
          duration: 5
        })
      } else if (errors === 'headerError') {
        notification.warning({
          top: 92,
          message: `工作表《${sheetName}》表头错误,${errDetail}`,
          duration: 5
        })
      }
    if (error) {
      notification.warning({
        top: 92,
        message: error,
        duration: 5
      })
      this.setState({ loading: false })
      return
    }
    if (!data || data.length === 0) {
      notification.warning({
        top: 92,
        message: '未获取到工作表《' + sheetName + '》数据!',
        duration: 5
      })
      this.setState({ loading: false })
      return
    } else if (data.length * btn.verify.columns.length > 30000) {
    if (data.length * btn.verify.columns.length > 30000) {
      notification.warning({
        top: 92,
        message: '当前导入数据量过大,如遇错误提示,请分批导入!',
@@ -341,7 +319,7 @@
      delete param.excel_in
      // param.excel_in_type = 'true'
      param.exec_type = 'y'
      param.exec_type = window.GLOB.execType || 'y'
      param.LText = result.sql
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -352,7 +330,7 @@
        param.LText = param.LText.replace(/\$check@|@check\$/ig, '')
      }
      param.LText = Utils.formatOptions(param.LText)
      param.LText = Utils.formatOptions(param.LText, param.exec_type)
      param.secretkey = Utils.encrypt('', param.timestamp)
      if (window.GLOB.mkHS) { // 云端验证
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -366,7 +344,7 @@
      if (unCheckParam) {
        unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/')
        unCheckParam.LText = Utils.formatOptions(unCheckParam.LText)
        unCheckParam.LText = Utils.formatOptions(unCheckParam.LText, unCheckParam.exec_type)
        unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp)
        unCheckParam.menuname = btn.logLabel
@@ -423,6 +401,9 @@
      if (btn.recordUser === 'true') {
        param.username = sessionStorage.getItem('User_Name') || ''
        param.fullname = sessionStorage.getItem('Full_Name') || ''
      }
      if (btn.dataM === 'true') {
        param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
      }
      Api.genericInterface(param).then((res) => {
@@ -550,38 +531,24 @@
    if (hidden) return null
    let label = ''
    let icon = ''
    let type = 'link'
    let className = ''
    if (btn.show === 'button') {
      label = btn.label
      icon = btn.icon || ''
    } else if (btn.show === 'link') {
      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
      icon = ''
    if (btn.show === 'link') {
      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
    } else if (btn.show === 'icon') {
      icon = btn.icon || 'upload'
    } else if (!btn.$toolbtn) {
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
      label = !loading ? <MkIcon type={btn.icon} /> : null
    } else {
      type = ''
      icon = btn.icon || ''
      label = btn.label
      className = 'mk-btn mk-' + btn.class
      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span>
    }
    return <>
      <Button
        type={type}
        type="link"
        id={'button' + btn.uuid}
        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
        loading={loading}
        disabled={disabled}
        style={btn.style}
        icon={icon}
        className={className}
        className={btn.hover || ''}
        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
      >{label}</Button>
      <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" />