Vue$confirm+loading

20 篇文章 0 订阅

 



//添加
    createData () {
      //开启按钮无法点击状态
      this.isDisable = true;
      setTimeout(() => {
        //2000毫秒后关闭禁用属性状态
        this.isDisable = false;
      }, 2000);
      //表单验证
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          if (!this.checkPostData()) {
            return false
          }
          this.model.aor_date_no = this.ymdTime.replace(/[^\a-\z\A-\Z0-9_\u4E00-\u9FA5]/g, "") //正则替换特殊符号 | 存yyyymmdd格式
          //获得类型值
          for (let i in this.typeOptions) {
            if (this.model.aor_type == this.typeOptions[i].key) {
              var typeName = this.typeOptions[i].display_name
              break
            }
          }
          // 构造将要执行的说明
          const confirmText = [`
					加班类型:【` + typeName + `】`,
          `加班人员:【` + this.userList.length + `】位`,
          `加班日期:【` + this.ymdTime + `】`,
          `加班时间:【` + this.model.aor_begin_time + `至` + this.model.aor_end_time + `】`,
          `加班工时:【` + this.model.aor_work_time + `】小时`]
          const newDatas = []
          const h = this.$createElement
          for (const i in confirmText) {
            newDatas.push(h('p', null, confirmText[i]))
          }
          this.$confirm('提示',
            {
              title: '添加加班单信息提示',
              message: h('div', null, newDatas),
              showCancelButton: true,
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              showClose: false,
              closeOnClickModal: false,
              closeOnPressEscape: false,
              closeOnHashChange: false,
              loading: true,
              beforeClose: (action, ctx, close) => {
                if (action !== 'confirm') {
                  close();
                  return;
                }
                this.tempElement = ctx
                if (this.userList.length > 0) {
                  ctx.cancelButtonLoading = true
                  ctx.confirmButtonLoading = true
                  ctx.showCancelButton = false
                  ctx.confirmButtonText = "处理中..."
                  //   //执行批量添加
                  this.batchCreateData()
                  return
                } else {
                  close();
                  return;
                }

              }
            }).finally(() => {
            }).then(() => {
              if (this.userList.length > 0) {
                //执行批量添加
                this.batchCreateData()
                return
              }
            })

        }
      });
    },
    closeBtnLoading () {
      this.tempElement.cancelButtonLoading = false
      this.tempElement.confirmButtonLoading = false
      this.tempElement.close();
    },
    //批量添加
    batchCreateData (index) {
      if (!index) {
        index = 0
      }
      //开始处理
      if (index == 0) {
        //this.formLoading = true
      }
      //全部处理完毕
      if (index >= this.userList.length) {
        this.closeBtnLoading()
        this.$message.success('添加成功')
        //this.formLoading = false
        this.userList = []
        // this.BReflashClosetagView(); // 关闭
        return
      }
      //提取用户ID
      this.model.aor_userid = this.userList[index].id
      // this.model.aor_begin_time=this.begin_Date
      // this.model.aor_end_time=this.end_Dat
      //提交数据
      this.RequestPost("/attendanceovertimerecordinfo?type=30", this.model)
        .then(response => {
          if (response.data.status) {
            this.batchCreateData(index + 1)
          } else {
            this.closeBtnLoading()
            this.$message.error(response.data.msg)
            this.formLoading = false
          }
        }).catch(err => {
          this.$message.error(err)
        })
    },

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值