view+vue上传文件

view+vue上传文件

<Upload ref= "upload"
	align="left"
	name= "file"
	:data="setValidates"
	action= '/mysens/sensitiveInformat/ionScan'
	:format="['xlsx']"
	:before-upload="handleUpload"
	:on-success="uploadSuccess"
	:on-format-error= "handleFormatError"
	:on-error=" uploadError"
	:show-upload-list= "false"
	v-model="setValidates. plugin_ name"
>
	<Button type=" primary" >导入问题列表</Button> 
</Upload>

export default {
	data (){
		return{
			setValidates:{
				plugin_ name:'',
			}
		}
	},
	methods (){
		//上传
		TaskAdd : function (name){
			let_ this = this;
			this . $refs['setValidates ' ].validate((valid)=>{
				if(valid){
					//console. log("正在提交--------",this. setValidates )
					this. isLoadingConfirm-true;
					//console. log(this. file)
					this . $refs . upload . post(this. file);
					//console . log(_ this . setValidates . department )
				}else{
					//console . log( "出现了错误-------")
					this. $Message . error( "表单验证失败" ) 
				}
				//console. log(”222222222222-------49999",this. file);
			})
		}//excel上传验证失败
		handleFormatError: function(file){
			this . $Message. error(file.name + '文件格式不正确,请上传正确的格式文件!');
		}
		//上传之前的方法
		handleUpload: function(file){
			//console. log("fil11111111111" ,file);
			let_ this = this;
			this.setValidates.plugin_name = file.name;
			this.file = file;
		},
		//excel上传成功
		uploadSuccess : function(res,file) {
			let_ this = this;
			console. log("上传成功" ,res, file) 
			this.isLoadingConfirm = false;
			if(res.result == "fail"){
				this.$Message.info(res.err_desc);
			}else if(res.msg ==成功"){
				this.$Message. info( "文件,上传成功")
				this.isLoadingConfirm = false,
				this.file = nullthis.loading=false ;
			}else{
				this .$Message.info("文件.上传失败")
			}
		},
		//excel上传失败
		uploadError: function(res, file){
			let_ this = this;
			console. log(".上传失败”,res, file);
			_this.isLoadingList=false;
			this.$Message. error("文件上传失败,请重新上传! ")
		}
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值