当前位置:网站首页>避免按钮重复点击的小工具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;
}
};
边栏推荐
猜你喜欢
What is the material of 15CrMoR, mechanical properties and chemical analysis of 15CrMoR
《MATLAB 神经网络43个案例分析》:第30章 基于随机森林思想的组合分类器设计——乳腺癌诊断
OJ input and output exercise
Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)
使用beef劫持用戶瀏覽器
MAVROS发送自定义话题消息给PX4
MATLAB【函数求导】
01 NumPy介绍
01 numpy introduction
随机推荐
Matlab [functions and images]
Huawei machine test questions column subscription Guide
串口转WIFI模块通信
SPL-介绍(一)
Analysis of slice capacity expansion mechanism
Tita OKR: a dashboard to master the big picture
Transaction method call @transactional
使用threejs简单Web3D效果
Provincial selection + noi Part II string
機動目標跟踪——當前統計模型(CS模型)擴展卡爾曼濾波/無迹卡爾曼濾波 matlab實現
01 NumPy介绍
谈谈数字化转型的几个关键问题
CPU設計實戰-第四章實踐任務一簡單CPU參考設計調試
String coordinates of number to excel
Leetcode t29: divide two numbers
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)
Leetcode t40: combined sum II
如何招到适合自己店铺的淘宝主播
Rumtime 1200 upgrade: London upgrade support, pledge function update and more
Codeforces Round #803 (Div. 2) VP补题