当前位置:网站首页>避免按钮重复点击的小工具bimianchongfu.queren()
避免按钮重复点击的小工具bimianchongfu.queren()
2022-07-01 08:26:00 【海宏AA】
按钮后台可能执行很长时间,这期间如果客户等不及再次点了按钮,可能会重复触发。
比如资产折旧,运行很长时间。
所以可以做一个hf_running的hiddenfield对象,设置值1表示正在运行,0表示没有。为兼容性用的纯js。
封装好了:
//避免重复运行,需要加一个hf_running的控件。用法:
//if (!bimianchongfu.queren('确认继续吗?')) return;
//执行具体业务代码
//执行完后,清空hf_running的值或者改成0
var bimianchongfu = {
kongjian: { objRunning: "hf_running" },
//检查是否正在运行,并提示,并设置值
queren: function (AConfirmMsg, lShowAlert, strShowAlert, lMarkIsRunning) {
var rt = this.zhengzaiyunxing(lShowAlert, strShowAlert, false);//检查正在运行
if (rt) return false; //正在运行,返回
//确认
var s = AConfirmMsg;
if (AConfirmMsg == undefined || AConfirmMsg == null) s = "";
if (s != "") if (!(rt = confirm(s))) return false;
//
if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
this.set("1");
//
return true;
},
//读取是否正在运行
zhengzaiyunxing: function (lShowAlert, strShowAlert, lMarkIsRunning) {
var obj = this.kongjian.objRunning, v = "", l = false, s = strShowAlert, lAlert = lShowAlert;
if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
else if (typeof (obj) == "string") obj = document.getElementById(obj);
if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
if (obj != null && this.kongjian.objRunning == null) this.kongjian.objRunning = obj;//记下来
v = obj.value; //取值
l = !(v == undefined || v == null || v == "" || v == "0" || v == "false");
//提示信息
if (l) { //正在运行
if (lShowAlert == undefined || lShowAlert == null) lAlert = true;
if (strShowAlert == undefined || strShowAlert == null) s = "正在运行,请稍候";
if (lAlert && s != "") alert(s);
} else { //没有运行,标记为正在运行
if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
this.set("1");
}
//完成返回
return l;
},
//设置值
set: function (val) {
var obj = this.kongjian.objRunning, tp = typeof (obj);
if (tp == "object") obj.value = val;
else if (tp == "string") document.getElementById(obj).value = val;
else document.getElementById("hf_running").value = val;
}
};
边栏推荐
- Precautions and skills in using regular expressions in golang
- Provincial election + noi Part VII computational geometry
- 毕业论文中word的使用1-代码域标公式
- Provincial election + noi Part III tree problems
- 谈谈数字化转型的几个关键问题
- MATLAB小技巧(16)矩阵特征向量特征值求解一致性验证--层次分析
- XX attack - reflective XSS attack hijacking user browser
- MATLAB【函数和图像】
- SPL installation and basic use (II)
- String coordinates of number to excel
猜你喜欢
一套十万级TPS的IM综合消息系统的架构实践与思考
Learn reptiles for a month and earn 6000 a month? Tell you the truth about the reptile, netizen: I wish I had known it earlier
Matlab [functions and images]
《单片机原理与应用》——并行IO口原理
Principle and application of single chip microcomputer - off chip development
Conception et mise en service du processeur - chapitre 4 tâches pratiques
MATLAB小技巧(16)矩阵特征向量特征值求解一致性验证--层次分析
Use threejs simple Web3D effect
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)
Internet of things technology is widely used to promote intelligent water automation management
随机推荐
【无标题】
【js逆向】md5加密参数破解
Anddroid 文本合成语音TTS实现
Download jackson codehaus. org jar - downloading jackson. codehaus. org jar
View drawing process analysis
MATLAB【函数求导】
Pipeline detection of UAV Based on gazebo
Qt的模型与视图
OJ input and output exercise
Intelligent water conservancy solution
Intelligent constant pressure irrigation system
Anddroid text to speech TTS implementation
leetcode T31:下一排列
[staff] high and low octave mark (the notes in the high octave mark | mark range are increased by one octave as a whole | low octave mark | mark range are decreased by one octave as a whole)
[Yu Yue education] Shandong Vocational College talking about railway reference materials
shardingSphere
CPU设计实战-第四章实践任务一简单CPU参考设计调试
Tita OKR: a dashboard to master the big picture
网关gateway-88
Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates