• 前端传递数据到后台的两种方式;创建一个map或者创建一个FormData对象


    一、构建一个map

    getAllDeptAllUsers(){
              const modleCode = {'auditMenuId': this.auditMenuId,
                'enterpriseId': this.$store.getters.enterpriseId};
              deptJs.getAllDeptAllUsers(modleCode).then(res=>{
                this.departmentList = res.data;
              })
            },

    二、通过const data = new FormData()创建一个FormData对象

    handleUploadChange(file, fileList) {
          if(this.auditors == ''||this.auditors == null){
            this.$message.error('上传前请先选择审核人')
            return
          }
          if (file.name.lastIndexOf('.') < 0) {
            this.$message.error('上传文件只能是xls、xlsx格式!')
            return
          }
          const testMsg = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase()
          const extensionXLS = testMsg == 'xls'
          const extensionXLSX = testMsg == 'xlsx'
          if (!extensionXLS && !extensionXLSX) {
            this.$message.error('上传文件只能是xls、xlsx格式!')
            return
          }
          const isLt2M = file.size / 1024 / 1024 < 2
          if (!isLt2M) {
            this.$message.error('上传文件不能超过 2MB!')
            return
          }
          console.log('import continue')
          this.importLoading = true
          this.importDisabled = true
          const data = new FormData()
          data.append('file', file.raw)
          data.append('ids',this.auditors)
          data.append('mesNodeNo',this.dataObj.mesNodeNo)
          Node.importExcel(data).then(response => {
            if (response.success == true) {
              this.open2(response.msg)
              this.importLoading = false
              this.importDisabled = false
              this.getList()
            } else {
              this.open2(response.msg)
              this.importLoading = false
              this.importDisabled = false
            }
          }).catch(() => {
            this.open2('抱歉,导入失败')
            this.importLoading = false
            this.importDisabled = false
          })
        },
  • 相关阅读:
    ffmpeg使用中文使用+解释
    CentOS GCC升级到4.6.1(转)
    C#委托与直接调用方法区别
    微软面试题,倒置数组
    MSDN中介绍的图片格式
    你们的学校是几流
    VS代码模版
    正则表达式
    Visual Studio 2010中添加项目模板
    泛型详解
  • 原文地址:https://www.cnblogs.com/zwh0910/p/13991463.html
Copyright © 2020-2023  润新知