vue+element UI文件导入 带参数

页面代码

                <!--导入-->
                <el-upload
                        style="display: inline-flex"
                        :show-file-list="false"
                        :before-upload="beforeUpload"
                        :on-success="onSuccess"
                        :on-error="onError"
                        :disbaled="importDataDisable"
                        :data={buildingId:this.dorRadio}
                        action="/dormitry/info/excel/upload">
                    <el-button size="small" type="success" style="margin-left: 10px" :icon="importDataBtnIcon"
                               :disabled="importDataDisable">
                        {
   
   {importDataBtnText}}
                    </el-button>
                </el-upload>

data数据:

                importDataDisable: false,
                importDataBtnText: '导入数据',
                importDataBtnIcon: 'el-icon-upload2',

js代码

            //导入
            beforeUpload() {
    
    
                this.importDataBtnIcon = 'el-icon-loading';
                this.importDataBtnText = '上传中...';
                this.importDataDisable = true;
            },
            onSuccess(resp, file, fileList) {
    
    
                this.importDataBtnIcon = 'el-icon-upload2';
                this.importDataBtnText = '导入数据';
                this.importDataDisable = false;
                if(resp.status == 500){
    
    
                    this.$message.error({
    
    message:resp.msg});
                }else{
    
    
                    this.$message.success({
    
    message:resp.msg});
                    this.initDormitoryInfo();
                }
            },
            onError() {
    
    
                this.importDataBtnIcon = 'el-icon-upload2';
                this.importDataBtnText = '导入数据';
                this.importDataDisable = false;
                this.$message.error('导入失败');
            },

猜你喜欢

转载自blog.csdn.net/weixin_55806809/article/details/121633951