king
2020-09-14 76427d51a079a5fd1f45bf7188249e7a4647ae05
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -15,15 +15,12 @@
class ExcelInButton extends Component {
  static propTpyes = {
    show: PropTypes.any,              // 显示样式
    BID: PropTypes.string,            // 主表ID
    BData: PropTypes.any,             // 主表数据
    selectedData: PropTypes.any,      // 子表中选择数据
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    btn: PropTypes.object,            // 按钮
    columns: PropTypes.array,         // 字段列
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    updateStatus: PropTypes.func,     // 按钮状态更新
    triggerBtn: PropTypes.any,
  }
@@ -189,26 +186,26 @@
  /**
   * @description Excel 导入
   */
  getexceldata = (data, errors) => {
  getexceldata = (data, errors, sheetName) => {
    const { btn } = this.props
    if (errors) {
      if (errors === 'notexit') {
        notification.warning({
          top: 92,
          message: '工作表《' + btn.verify.sheet + '》不存在!',
          message: '工作表《' + sheetName + '》不存在!',
          duration: 5
        })
      } else if (errors === 'empty') {
        notification.warning({
          top: 92,
          message: '工作表《' + btn.verify.sheet + '》为空!',
          message: '工作表《' + sheetName + '》为空!',
          duration: 5
        })
      } else if (errors === 'headerError') {
        notification.warning({
          top: 92,
          message: '工作表《' + btn.verify.sheet + '》表头设置错误!',
          message: '工作表《' + sheetName + '》表头设置错误,请检查表头中的名称及顺序,与按钮Excel列信息是否一致!',
          duration: 5
        })
      }
@@ -220,14 +217,20 @@
    if (!data || data.length === 0) {
      notification.warning({
        top: 92,
        message: '未获取到工作表《' + btn.verify.sheet + '》数据!',
        message: '未获取到工作表《' + sheetName + '》数据!',
        duration: 5
      })
      this.updateStatus('over')
      return
    } else if (data.length * btn.verify.columns.length > 30000) {
      notification.warning({
        top: 92,
        message: '当前导入数据量过大,如遇错误提示,请分批导入!',
        duration: 5
      })
    }
    let result = Utils.getExcelInSql(btn, data, this.state.dict)
    let result = Utils.getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''))
    if (result.errors) {
      notification.warning({
@@ -248,7 +251,7 @@
      param.BID = this.props.BID
    }
    if (btn.intertype === 'inner' && !btn.innerFunc) { // 系统存储过程
    if (btn.intertype === 'system') { // 系统存储过程
      param.func = 'sPC_TableData_InUpDe'
      
      if (this.props.dataManager) { // 数据权限
@@ -261,14 +264,14 @@
        result.bottom = result.bottom.replace(/@\$|\$@/ig, '')
      }
      
      param.excel_in = 'true'
      param.LText_insert = Utils.formatOptions(result.insert)
      param.LText_bottom = Utils.formatOptions(result.bottom)
      param.excel_in_type = 'true'
      param.LText1 = Utils.formatOptions(result.insert)
      param.LText2 = Utils.formatOptions(result.bottom)
      param.LText = Utils.formatOptions(result.sql)
      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)
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
      }
      Api.genericInterface(param).then((res) => {
@@ -326,7 +329,7 @@
      }).then(res => {
        if (!res) return
        // 外部请求
        _outParam = JSON.parse(JSON.stringify(res))
        _outParam = fromJS(res).toJS()
        if (this.props.menuType === 'HS') {
          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
@@ -344,6 +347,13 @@
        if (btn.outerFunc) {
          res.func = btn.outerFunc
        }
        if (this.props.menuType === 'HS' && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 云端验证
          param.LText = Utils.formatOptions(result.sql)
          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
          param.secretkey = Utils.encrypt(param.LText, param.timestamp)
          param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
        }
        return Api.genericInterface(res)
@@ -379,18 +389,25 @@
  }
  render() {
    const { btn } = this.props
    const { btn, show } = this.props
    const { loading } = this.state
    return (
      <div className="mk-btn-wrap">
        <Button
        {!show ? <Button
          className={'mk-btn mk-' + btn.class}
          icon={btn.icon}
          onClick={() => {this.actionTrigger()}}
          loading={loading}
        >{btn.label}</Button>
        <ExcelIn MenuID={this.props.MenuID} btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
        >{btn.label}</Button> : null}
        {show === 'icon' ? <Button
          className="import-icon"
          icon="upload"
          onClick={() => {this.actionTrigger()}}
          loading={loading}
          title={btn.label}
        ></Button> : null}
        <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
      </div>
    )
  }