当前位置:网站首页>避免按钮重复点击的小工具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;
}
};边栏推荐
- Provincial selection + noi Part II string
- 防“活化”照片蒙混过关,数据宝“活体检测+人脸识别”让刷脸更安全
- Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system
- Leetcode t39: combined sum
- [untitled]
- Intelligent water conservancy solution
- Provincial election + noi part I dynamic planning DP
- [deep analysis of C language] - data storage in memory
- Mavros sends a custom topic message to Px4
- Using settoolkit to forge sites to steal user information
猜你喜欢

When using charts to display data, the time field in the database is repeated. How to display the value at this time?

MAVROS发送自定义话题消息给PX4

Use threejs simple Web3D effect

Airsim radar camera fusion to generate color point cloud

CPU設計實戰-第四章實踐任務一簡單CPU參考設計調試

Audio-AudioRecord create(一)

There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way

《微机原理》——微处理器内部及外部结构

The use of word in graduation thesis

分享2022上半年我读过的7本书
随机推荐
[JS reverse] MD5 encryption parameter cracking
Share 7 books I read in the first half of 2022
Airsim radar camera fusion to generate color point cloud
Vscode customize the color of each area
There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way
Provincial election + noi Part III tree problems
AES简单介绍
The data analyst will be ruined without project experience. These 8 project resources will not be taken away
Anddroid 文本合成语音TTS实现
01 NumPy介绍
How can beginners correctly understand Google's official suggested architectural principles (questions?)
Codeworks round 803 (Div. 2) VP supplement
初学者如何正确理解google官方建议架构原则(疑问?)
机动目标跟踪——当前统计模型(CS模型)扩展卡尔曼滤波/无迹卡尔曼滤波 matlab实现
Leetcode t39: combined sum
Mavros sends a custom topic message to Px4
【面试必刷101】链表
DID的使用指南,原理
[question brushing] character statistics [0]
XX攻击——反射型 XSS 攻击劫持用户浏览器