导入封装

 

 

 
// 导入
  importFiles(e, type) {
    if (e.target.files.length === 0) return
    const file = e.target.files[0]
    if (!/\.xlsx$/g.test(file.name)) {
      message.info('仅支持读取xlsx格式!')
    }
    const param = new FormData()
    // 通过append向form对象添加数据
    param.append('file', file)
    // FormData私有类对象,访问不到,可以通过get判断值是否传进去
    // console.log(param.get('file'), 'param.get(file)')
    return request({
      method: 'POST',
      url: '/excel/importExcel?type=' + type,
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      data: param
    })
  },
posted @ 2022-03-16 09:31  MonsterSATSUKI  阅读(44)  评论(0)    收藏  举报