后台请求得参数问题

 post请求(body)

// 风险清单管理-分页查询
const riskList = (data: any) => {
  return axios({
    method: 'post',
    url: SERVICE_BASIC + '/Risk/RiskListManagementController/riskList',
    data: JSON.stringify(data),
  });
};
普通键值对
key:value
list传值
['1','2','3']
map类型或实体类型,json格式
[{
    a:'1',
    b:''
}]

post请求(query得形式)

// 隐患排查--导入接口
export const importTemplate = (data: any) => {
  return axios({
    method: 'post',
    url:
      SERVICE_BASIC +
      '/knowledge/hiddenDanger/importTemplate?enterpriseType=' +
      data.enterpriseType +
      '&' +
      'troubleshootingName=' +
      data.troubleshootingName +
      '&' +
      'troubleshootingType=' +
      data.troubleshootingType,
    data: data.xlsFile,
  });
};

post请求(formdata得形式)

// 附件----附件上传-新增页面
export const baseFileSave = (data: any) => {
  return axios({
    method: 'post',
    url: SERVICE_ENCLOSURE + '/knoFilepath/baseFileSave',
    data,
  });
};
 // 附件上传
  private submitEnclosure(file: any) {
    // formdata 格式得传参
    const myFormData: any = new FormData();
    myFormData.set('file', file.file);
    myFormData.set('fileType', this.fileType);
    
    this.myFileList = (this.$refs.upload as any).uploadFiles;
    let serviceStr: any = '';
    if (this.type === 'add') {
      myFormData.set('moduleId', this.moduleId);
      serviceStr = 'baseFileSave';
    } else if (this.type === 'edit') {
      myFormData.set('id', this.dataId);
      myFormData.set('moduleId', this.moduleId);
      serviceStr = 'baseUpload';
    }
    this.serviceobj[serviceStr](myFormData)
      .then((res: any) => {
        console.log('$refs.upload');
        console.log((this.$refs.upload as any).fileList);
        // let temFileList = (this.$refs.upload as any).fileList;
        this.fullscreenLoading = false;
        if (res.data.msg === '成功') {
          this.$message.success('上传成功!');
          const newName = res.data.data.fileName;
          this.myFileList.forEach((item: any) => {
            if (item.name === newName) {
              item.id = res.data.data.id;
            }
          });
          this.watchMyFileList(this.myFileList);
          this.$emit('onUploadSuccess', file, this.myFileList);
        }
      })
      .catch((err: any) => {
        this.fullscreenLoading = false;
        return false;
      });
  }

get请求

  // 导出
  private exportFun() {
    let idArr: any = '';
    if (this.$store.state.commonModule.dataCheckedArr.length > 0) {
      this.$store.state.commonModule.dataCheckedArr.forEach((i: any) => {
        idArr += 'idList=' + i.id + '&';
      });
    } else {
      idArr = 'idList=';
    }
    // 直接在url后面拼接参数
    window.location.href =
      (this as any).$SERVICE_BASIC +
      '/knowledge/discretion/discretionKnoExport?' +
      idArr;
  }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值