美文网首页
解决element-ui upload组件在选择文件前进行弹窗提

解决element-ui upload组件在选择文件前进行弹窗提

作者: 上海老宅男 | 来源:发表于2020-06-18 17:48 被阅读0次
    <el-button ref="updataButt" @click="clickSubmit">导入</el-button >
                    <el-upload
                            class="uploadExcel"
                            ref="upload"
                            accept=".xls, .xlsx"
                            :action="uploadFileURL"
                            :data="uploadParam"
                            name="file"
                            :headers="header"
                            :before-remove="beforeReExcel"
                            :on-success="successExcel"
                            :on-change="changeUpExcel"
                            :on-error="errorExcel"
                            :auto-upload="true"
                            :before-upload="beforeUpExcel"
                            :show-file-list="false"
                    >
    
                    </el-upload>
    
    methods: {
    //点击先弹窗在上传
        clickSubmit(){
          let self = this;
          //这个地方根据自己的业务续修进行判断和调整
          if(self.uploadParam.kmMc){
            //这个弹窗是我自己根据element 二次封装的一个弹窗
            self.$JcMsgBox(
              "此操作将导入"+self.uploadParam.kmMc+"科目的保密对应关系,是否继续",
              "warning",
              "温馨提示"
            )
              .then(() => {
                //这句话就是弹窗点击确定之后进行弹出选择文件
                //其中的upload对应着ref
                self.$refs['upload'].$refs['upload-inner'].handleClick()
              })
              .catch(() => {
                self.$message({
                  type: "info",
                  message: "已取消导入"+self.uploadParam.kmMc+"科目的保密对应关系"
                });
              });
          }else{
            self.$message({
              type: "danger",
              message: "请先选择科目"
            });
          }
    
        }
    }

    相关文章

      网友评论

          本文标题:解决element-ui upload组件在选择文件前进行弹窗提

          本文链接:https://www.haomeiwen.com/subject/lszuxktx.html