zoukankan      html  css  js  c++  java
  • 前端传递数据到后台的两种方式;创建一个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
          })
        },
  • 相关阅读:
    Finite Difference Method with Mathematica
    评论
    The Woman in Red Is Seen as a Threat by Other Wom
    Why Does Everyone Else Appear to Be Succeeding?
    The Sorrows of Young Werther
    【洛谷P5607】无力回天 NOI2017
    【YbtOJ#532】往事之树
    【YbtOJ#582】大收藏家
    【牛客Wannafly挑战赛23 F】计数
    【YbtOJ#573】后缀表达
  • 原文地址:https://www.cnblogs.com/zwh0910/p/13991463.html
Copyright © 2011-2022 走看看