• 避免按钮重复点击的小工具bimianchongfu.queren()


    按钮后台可能执行很长时间,这期间如果客户等不及再次点了按钮,可能会重复触发。

    比如资产折旧,运行很长时间。

    所以可以做一个hf_running的hiddenfield对象,设置值1表示正在运行,0表示没有。为兼容性用的纯js。

    封装好了:

    1. //避免重复运行,需要加一个hf_running的控件。用法:
    2. //if (!bimianchongfu.queren('确认继续吗?')) return;
    3. //执行具体业务代码
    4. //执行完后,清空hf_running的值或者改成0
    5. var bimianchongfu = {
    6. kongjian: { objRunning: "hf_running" },
    7. //检查是否正在运行,并提示,并设置值
    8. queren: function (AConfirmMsg, lShowAlert, strShowAlert, lMarkIsRunning) {
    9. var rt = this.zhengzaiyunxing(lShowAlert, strShowAlert, false);//检查正在运行
    10. if (rt) return false; //正在运行,返回
    11. //确认
    12. var s = AConfirmMsg;
    13. if (AConfirmMsg == undefined || AConfirmMsg == null) s = "";
    14. if (s != "") if (!(rt = confirm(s))) return false;
    15. //
    16. if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
    17. this.set("1");
    18. //
    19. return true;
    20. },
    21. //读取是否正在运行
    22. zhengzaiyunxing: function (lShowAlert, strShowAlert, lMarkIsRunning) {
    23. var obj = this.kongjian.objRunning, v = "", l = false, s = strShowAlert, lAlert = lShowAlert;
    24. if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
    25. else if (typeof (obj) == "string") obj = document.getElementById(obj);
    26. if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
    27. if (obj != null && this.kongjian.objRunning == null) this.kongjian.objRunning = obj;//记下来
    28. v = obj.value; //取值
    29. l = !(v == undefined || v == null || v == "" || v == "0" || v == "false");
    30. //提示信息
    31. if (l) { //正在运行
    32. if (lShowAlert == undefined || lShowAlert == null) lAlert = true;
    33. if (strShowAlert == undefined || strShowAlert == null) s = "正在运行,请稍候";
    34. if (lAlert && s != "") alert(s);
    35. } else { //没有运行,标记为正在运行
    36. if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
    37. this.set("1");
    38. }
    39. //完成返回
    40. return l;
    41. },
    42. //设置值
    43. set: function (val) {
    44. var obj = this.kongjian.objRunning, tp = typeof (obj);
    45. if (tp == "object") obj.value = val;
    46. else if (tp == "string") document.getElementById(obj).value = val;
    47. else document.getElementById("hf_running").value = val;
    48. }
    49. };

  • 相关阅读:
    DHCP服务的八种报文(消息)作用
    大数据必看:大厂十年架构师职业生涯实战经验总结,《大规模分布式系统架构与设计实战》
    【SI好文翻译】铜箔表面纹理对损耗的影响:一个有效的模型(四)
    QtC++与QCheckBox详解
    JSP学生寝室管理系统myeclipse开发sql数据库BS模式java编程struts2框架网页结构
    wx.request请求eggjs报invalid csrf token
    配置文件config
    新公司第一次上架新APP需要提前准备哪些材料?
    Spring的注解开发-Spring配置其它注解
    SwiftUI Bluetooth 使用
  • 原文地址:https://blog.csdn.net/gssystems/article/details/125537427