Vue$confirm+loading
生活随笔
收集整理的這篇文章主要介紹了
Vue$confirm+loading
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
//添加createData () {//開(kāi)啟按鈕無(wú)法點(diǎn)擊狀態(tài)this.isDisable = true;setTimeout(() => {//2000毫秒后關(guān)閉禁用屬性狀態(tài)this.isDisable = false;}, 2000);//表單驗(yàn)證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, "") //正則替換特殊符號(hào) | 存yyyymmdd格式//獲得類型值for (let i in this.typeOptions) {if (this.model.aor_type == this.typeOptions[i].key) {var typeName = this.typeOptions[i].display_namebreak}}// 構(gòu)造將要執(zhí)行的說(shuō)明const confirmText = [`加班類型:【` + typeName + `】`,`加班人員:【` + this.userList.length + `】位`,`加班日期:【` + this.ymdTime + `】`,`加班時(shí)間:【` + this.model.aor_begin_time + `至` + this.model.aor_end_time + `】`,`加班工時(shí):【` + this.model.aor_work_time + `】小時(shí)`]const newDatas = []const h = this.$createElementfor (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 = ctxif (this.userList.length > 0) {ctx.cancelButtonLoading = truectx.confirmButtonLoading = truectx.showCancelButton = falsectx.confirmButtonText = "處理中..."// //執(zhí)行批量添加this.batchCreateData()return} else {close();return;}}}).finally(() => {}).then(() => {if (this.userList.length > 0) {//執(zhí)行批量添加this.batchCreateData()return}})}});},closeBtnLoading () {this.tempElement.cancelButtonLoading = falsethis.tempElement.confirmButtonLoading = falsethis.tempElement.close();},//批量添加batchCreateData (index) {if (!index) {index = 0}//開(kāi)始處理if (index == 0) {//this.formLoading = true}//全部處理完畢if (index >= this.userList.length) {this.closeBtnLoading()this.$message.success('添加成功')//this.formLoading = falsethis.userList = []// this.BReflashClosetagView(); // 關(guān)閉return}//提取用戶IDthis.model.aor_userid = this.userList[index].id// this.model.aor_begin_time=this.begin_Date// this.model.aor_end_time=this.end_Dat//提交數(shù)據(jù)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)})},總結(jié)
以上是生活随笔為你收集整理的Vue$confirm+loading的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 利用手机绘制标准曲线并且计算相关系数
- 下一篇: vue使用layer弹窗实现自定义回调函