附件上传和下载

jquery

//文件上传
				$.ajaxFileUpload({
	                url:yxUrl.upFileUrl+"?tableName=K_IM_CHECK_DEAL&aboutRecordId="+data.data.dealDetID, //用于文件上传的服务器端请求地址
	                secureuri: false, //一般设置为false
	                fileElementId: 'file-ipt', //文件上传空间的id属性  <input type="file" id="file" name="file" />
	                dataType: 'json', //返回值类型 一般设置为json
	                success: function (data, status){  //服务器成功响应处理函数
//	                    console.log(data);
//	                    console.log(status);
	                },
	                error: function (data, status, e){//服务器响应失败处理函数
//	                    console.log(e);
	                }
	            });
	            

el-upload

1、上传

自动上传:
	
 let formData = new FormData();
        formData.append("files",file.file);
        formData.append('supTaskNo',this.superviseList.supTaskNo)
		formData.append('fedTaskNo',this.fedTaskNo)
        this.$http.post(this.$urls.supervise.files("upload"),formData,
            { 'Content-Type':'multipart/form-data' },{
                // onUploadProgress: progress =>{
                //         //上传过程
                //         for (let i = 0; i < this.newFilesList.length; i++){
                //             if(this.newFilesList[i].uid === file.uid){
                //                 this.newFilesList[i].percentage = progress.loaded * 100 / progress.total
                //                 break;
                //             }
                //         }
                //     }
            }).then(xhr=>{
                // 上传完成
                if(xhr && xhr.data){
                    if(xhr.data.code == '10000'){
                        this.$message.success(xhr.data.msg);
                    }else{
                        this.$message.error(xhr.data.msg);
                    }
                }
            }).catch(e=>{
                //  上传异常
            })
	非自动上传
	 _this.noFileUrl = Lvm.$api.upFileUrl + "?tableName=K_AC_WHITE_REC&aboutRecordId=" + str;
      setTimeout(function() {
           _this.$refs.upload2.submit();
       }, 1);

2、下载or 预览
法一:

this.$http.post(this.$urls.supervise.files("download"),
           { id :file.id},null,{responseType:'blob'}).then(xhr=>{
     // new Blob([data])用来创建URL的file对象或者blob对象
     let url = window.URL.createObjectURL(new Blob([xhr.data]));
     // 生成一个a标签
     let link = document.createElement("a");
     link.style.display = "none";
     link.href = url;
     // 生成时间戳
     link.download = file.fileName
     document.body.appendChild(link);
     link.click();
})
handlePreview (file) {
     var urls = Lvm.$api.upFileUrlDown + '?id=' + file.num;
     	window.open(urls, '_self');
 },

3、删除
调用删除接口
4、查看
直接调用接口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值