vue elementui 弹框确定后加上loading提示

this.$confirm("确认取消关联该园所?", "提示", {
    confirmButtonText: "确定",//必填
    cancelButtonText: "取消",//必填
    type: "warning",//必填
    beforeClose: (action, instance, done) => {
      if (action === "confirm") {//必填
        instance.confirmButtonLoading = true;
        instance.confirmButtonText = "执行中...";
        this.postRequest("/api/admin/agency/associateXXX", { //请求路径 postRequest post请求的方式可以超考原生的写法
          schoolId:'',
          relateSchoolId: id,
        }).then(              
          (data) => {
            if (data.status == "200") {
              //业务代码
              this.$message({
                type: "success",
                message: "取消关联成功!",
              });
              this.search();
              //业务代码-End
              
              //必要部分
              done(); 
              setTimeout(() => {
                instance.confirmButtonLoading = false;
              }, 300);
              //必要部分-End
              
              this.changeDialog = false; //业务代码
            } else {
              //必要部分
              done();
              setTimeout(() => {
                instance.confirmButtonLoading = false;
              }, 300);
              //必要部分-End
    
              this.changeDialog = false; //业务代码
            }
          }
        );
      } else {
        done();
      }
    },
  })
  .then(() => {})
  .catch(() => {});

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐