当前位置:网站首页>避免按钮重复点击的小工具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;
}
};边栏推荐
- Leetcode t31: next spread
- 量化交易之读书篇 - 《征服市场的人》读书笔记
- On June 30, 2022, the record of provincial competition + national competition of Bluebridge
- Download jackson codehaus. org jar - downloading jackson. codehaus. org jar
- Provincial election + noi Part VI skills and ideas
- 串口转WIFI模块通信
- Intelligent constant pressure irrigation system
- Maneuvering target tracking -- current statistical model (CS model) extended Kalman filter / unscented Kalman filter matlab implementation
- [untitled]
- Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates
猜你喜欢
![[question brushing] character statistics [0]](/img/cc/f5aaecd920c502180303d92447e54f.png)
[question brushing] character statistics [0]

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

Huawei machine test questions column subscription Guide

Airsim雷达相机融合生成彩色点云

MATLAB小技巧(23)矩阵分析--模拟退火

使用beef劫持用戶瀏覽器
![[detailed explanation of Huawei machine test] judgment string subsequence [2022 Q1 Q2 | 200 points]](/img/0f/972cde8c749e7b53159c9d9975c9f5.png)
[detailed explanation of Huawei machine test] judgment string subsequence [2022 Q1 Q2 | 200 points]

MATLAB【函数和图像】
![Matlab [function derivation]](/img/ba/9fb9da8a458d0c74b29b21a17328fc.png)
Matlab [function derivation]

Qt的模型与视图
随机推荐
Model and view of QT
[no title] free test questions for constructor municipal direction general foundation (constructor) and theoretical test for constructor municipal direction general foundation (constructor) in 2022
Hijacking a user's browser with beef
[deep analysis of C language] - data storage in memory
《单片机原理及应用》—定时器、串行通信和中断系统
【C】 Summary of wrong questions in winter vacation
《微机原理》—总线及其形成
栈实现计算器
串口转WIFI模块通信
Vscode customize the color of each area
Burpsuite -- brute force cracking of intruder
Leetcode t29: divide two numbers
The difference between interceptors and filters
Advanced API
SPL-安装与基本使用(二)
What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
Koltin35, headline Android interview algorithm
Download jackson codehaus. org jar - downloading jackson. codehaus. org jar
《单片机原理与应用》——并行IO口原理
vscode自定义各个区域的颜色