Fork me on GitHub
.net求学者

弹出框公共页面调用通用方法(artDialog)记录

 

<!doctype html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title>
    <script src="/Scripts/jquery-1.9.0.min.js" type="text/javascript"></script>
    <link href="../skin/Dark/css/style.css" rel="stylesheet" />
    <script src="../Script/FunctionJS.js"></script>
    <script src="/UILib/artDialog/artDialog.source.js" type="text/javascript"></script>
    <script src="/UILib/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="../Script/jquery/jquery.nicescroll.js"></script>
    <script src="../Script/layout.js"></script>
    <script src="../Script/JValidator.js"></script>
    <script type="text/javascript">
        //滚动条设置
        $(document).ready(function () {
            $("#div_scrollbar").niceScroll({ touchbehavior: false, cursorcolor: "#7C7C7C", cursoropacitymax: 0.6, cursorwidth: 8 });
        });

        //返回选择的监测项目名称与LHCodeID
        var W = art.dialog.open.origin;
        var callBack = RequestFrom("callBack");
        var callLHCodeID = RequestFrom("callLHCodeID");
        var callParamName = RequestFrom("callParamName");
        function ReturnOk() {
            var tLHCodeID = document.getElementById("hidLHCodeIDList").value;
            var tParamName = document.getElementById("hidParamNameList").value;

            if (tLHCodeID.length > 0 && tLHCodeID.charAt(tLHCodeID.length - 1) == ',') {
                tLHCodeID = tLHCodeID.substring(0, tLHCodeID.length - 1);
                tParamName = tParamName.substring(0, tParamName.length - 1);
            }

            if (tParamName.length < 1 && tLHCodeID.length < 1) {
                showWarningMsg("请选择相关内容,再执行确定!");
                return;
            } else {
                if (callLHCodeID != "" && W.document.getElementById(callLHCodeID) != null) {
                    W.document.getElementById(callLHCodeID).value = tLHCodeID;
                }

                if (callParamName != "" && W.document.getElementById(callParamName) != null) {
                    W.document.getElementById(callParamName).value = tParamName;
                }

                if (typeof W[callBack] === 'function') {
                    W[callBack].call(this, tLHCodeID, tParamName);
                }
            }
            OpenClose();
        }

        $(function () {
            var hidWaterLHCodeID = document.getElementById("hidWaterParamList").value;
            if (hidWaterLHCodeID != "" && hidWaterLHCodeID.length > 0) {
                BindCheckBox(hidWaterLHCodeID);
            } else {
                loadBindData();
            }

            //选择tr选中checkbox
            $("#table1 tr").on('click', function () {
                $(this).find(":checkbox :first").click();
            });
            $('#table1 tr td :checkbox').on('click', function (event) {
                event.stopPropagation();
            });
        })

        //全选与取消监测项目
        function SelectAllParams(bl) {
            $('#table1 tbody').find(':checkbox').each(function () {
                var $this = $(this);
                if ($this.prop('checked') != bl) {
                    $this.click();
                }
            });
        }

        //回选时,已选择的保持默认选中状态
        function loadBindData() {
            if (callLHCodeID != "" && W.document.getElementById(callLHCodeID) != null) {
                var LHCodeIDList = W.document.getElementById(callLHCodeID).value;
                var ParamNameList = W.document.getElementById(callParamName).value;
                document.getElementById("hidLHCodeIDList").value = LHCodeIDList;
                document.getElementById("hidParamNameList").value = ParamNameList;
                if (LHCodeIDList.length > 0) {
                    $("#table1").find(":checkbox").each(function () {
                        var tLHCodeID = $(this).val();
                        if (LHCodeIDList.indexOf(tLHCodeID) >= 0) {
                            $(this).prop("checked", true);
                        }
                    })
                }
            }
        }

        //增加选择监测项目操作
        function checkboxClick(obj, val1, val2) {
            var tLHCodeID = document.getElementById("hidLHCodeIDList").value;
            var tParamName = document.getElementById("hidParamNameList").value;
            if (tLHCodeID.length > 0 && tLHCodeID.charAt(tLHCodeID.length - 1) != ',') {
                tLHCodeID = tLHCodeID + ",";
                tParamName = tParamName + "|";
            }
            if (obj.checked) {
                tLHCodeID += val1 + ",";
                tParamName += val2 + "|";
            } else {
                tLHCodeID = tLHCodeID.replace(val1 + ",", "");
                tParamName = tParamName.replace(val2 + "|", "");
            }
            document.getElementById("hidLHCodeIDList").value = tLHCodeID;
            document.getElementById("hidParamNameList").value = tParamName;
        }

        //根据下拉框内容绑定复选框
        function BindCheckBox(LHCodeIDList) {
            var tLHCodeIDList = "";
            var tParamNameList = "";
            $("#table1").find(":checkbox").each(function () {
                var tLHCodeID = $(this).val();
                if (LHCodeIDList.indexOf(tLHCodeID) >= 0) {
                    $(this).prop("checked", true);
                    tLHCodeIDList += $(this).val() + ",";
                    tParamNameList += this.name + "|";
                }
            })
            document.getElementById("hidLHCodeIDList").value = tLHCodeIDList;
            document.getElementById("hidParamNameList").value = tParamNameList;
        }

        //执行查询
        function ReturnSearch() {
            document.getElementById("lbtSearch").click();
        }
    </script>
    <style>
        .grid td {
            border: 1px solid #e8e8e8;
        }

        .grid .theader td {
            text-align: center;
            letter-spacing: 4px;
        }
    </style>
</head>
<body>
  
        <input type="hidden" id="hidParamNameList" />
        <input type="hidden" id="hidLHCodeIDList" />
        <input type="hidden" name="hidWaterParamList" id="hidWaterParamList" />
        <!--工具栏-->
        <div class="toolbar-wrap">
            <div id="floatHead" class="toolbar" style="padding: 0px;">
                <div style="float: left; width: 60px; padding-left: 10px;">
                    <span id="Label1" class="LabText">参数名称:</span>
                </div>
                <div style="float: left; width: 160px;">
                    <input name="txtParamName" type="text" id="txtParamName" class="KeyWord" />
                </div>
                <div style="float: left; width: 60px; padding-left: 10px;">
                    <span id="Label2" class="LabText">水体参数:</span>
                </div>
                <div style="float: left; width: 100px;" class="rule-single-select">
                    <select name="ddl_watertype" onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;ddl_watertype\&#39;,\&#39;\&#39;)&#39;, 0)" id="ddl_watertype">
    <option selected="selected" value="">选择</option>
    <option value="0">河流</option>
    <option value="1">湖泊</option>
    <option value="11">近岸海域</option>
    <option value="3">地下水</option>

</select>
                </div>
                <div style="float: left;">
                    <div style="display: none;">
                        <input type="submit" name="lbtSearch" value="查  询" id="lbtSearch" class="btngreen" />
                    </div>
                    <input id="lbtSearchInput" type="button" value="查&nbsp;&nbsp;询" class="btngreen" onclick="ReturnSearch()" />
                    <input id="lbtOK" type="button" value="确&nbsp;&nbsp;定" class="btnyellow" onclick="ReturnOk()" />
                </div>
            </div>
        </div>
        <!--end工具栏-->
        <div class="div-body" style="margin-top: -25px;">
            <table class="grid">
                <thead>
                    <tr>
                        <td style="width: 10%;">
                            <input type="checkbox" id="chkItemAll" onclick="SelectAllParams(this.checked)" /><label for="chkItemAll">全选</label>
                        </td>
                        <td style="width: 20%;">参数名称</td>
                        <td style="width: 20%;">参数代码</td>
                        <td>单位</td>
                        <td>排序</td>
                    </tr>
                </thead>
            </table>
        </div>
        <div class="div-body" id="div_scrollbar" style="height: 465px; overflow: auto; margin-top: 1px;">
            <table id="table1" class="grid">
                <tbody>
                    
                            <tr>
                                <td style="width: 10%;">
                                    <input id="CheckBoxNoC99" type="checkbox" name="取水量" value="C99" onclick="checkboxClick(this, value, name)">
                                    1
                                </td>
                                <td style="width: 20%;">取水量</td>
                                <td style="width: 20%;">C99</td>
                                <td>万吨</td>
                                <td>0</td>
                            </tr>
                        
                            <tr>
                                <td style="width: 10%;">
                                    <input id="CheckBoxNoZ63" type="checkbox" name="水温" value="Z63" onclick="checkboxClick(this, value, name)">
                                    2
                                </td>
                                <td style="width: 20%;">水温</td>
                                <td style="width: 20%;">Z63</td>
                                <td></td>
                                <td>1</td>
                            </tr>
                        
                            <tr>
                                <td style="width: 10%;">
                                    <input id="CheckBoxNoZ60" type="checkbox" name="pH" value="Z60" onclick="checkboxClick(this, value, name)">
                                    3
                                </td>
                                <td style="width: 20%;">pH</td>
                                <td style="width: 20%;">Z60</td>
                                <td>无量纲</td>
                                <td>2</td>
                            </tr>
                        
                            <tr>
                                <td style="width: 10%;">
                                    <input id="CheckBoxNoZ64" type="checkbox" name="溶解氧" value="Z64" onclick="checkboxClick(this, value, name)">
                                    4
                                </td>
                                <td style="width: 20%;">溶解氧</td>
                                <td style="width: 20%;">Z64</td>
                                <td>mg/L</td>
                                <td>3</td>
                            </tr>
                </tbody>
            </table>
        </div>
</body>
</html>

 

/*Dialog回调方法*/
var _stimeDialog;
var _stimeDialogBack;
var _stimeDialogVal;

function stimeShowDialog(callBack, val) {
    _stimeDialogBack = callBack;
    _stimeDialogVal = val;
    _stimeDialog = art.dialog({
        left: '50%',
        top: '50%',
        width: 380,
        height: 160,
        fixed: true,
        resize: false,
        lock: true,
        padding: 0,
        title: "选择时间",
        content: '<table border="1" cellspacing="0" cellpadding="0" class="jqGridBian ui-jqgrid-btable ui-common-table" style="margin:10px 5px;text-align:center;">' +
                '<tr class="jqgrow ui-row-ltr ui-widget-content">' +
                    '<td class="jqgrid-rownum ui-state-default" width="145px"><span class="sp_bz">*</span>开始时间:</td>' +
                    '<td width="180px">' +
                        '<input id="txt_TimeS" name="txt_TimeS" type="text" class="Wdate" onfocus="WdatePicker()" style="width: 98%;" /></td>' +
                '</tr>' +
                '<tr class="jqgrow ui-row-ltr ui-widget-content">' +
                    '<td class="jqgrid-rownum ui-state-default"><span class="sp_bz">*</span>结束时间:</td>' +
                    '<td>' +
                        '<input id="txt_TimeE" name="txt_TimeE" type="text" class="Wdate" onfocus="WdatePicker()" style="width: 98%;" /></td>' +
                '</tr>' +
    '</table>' +
    '<p style="margin-top: 30px; text-align: right;">' +
   '<input type="button" value="保存" class="btnSave" onclick="callbackFun(_stimeDialogBack,_stimeDialogVal);_stimeDialog.close();">' +
       '&emsp;<input type="button" value="关闭" class="btnQuit" onclick="_stimeDialog.close()">' +
   '</p>',


        //content: '<div class="grid_5">开始时间:</div>' +
        //            '<div class="grid_8">' +
        //                '<input id="txt_TimeS" name="txt_TimeS" type="text" class="Wdate" onfocus="WdatePicker()" style="width: 80px;">' +
        //            '</div>' +
        //            '<div class="grid_5">结束时间:</div>' +
        //            '<div class="grid_8">' +
        //                '<input id="txt_TimeS" name="txt_TimeE" type="text" class="Wdate" onfocus="WdatePicker()" style="width: 80px;">' +
        //           ' </div>',
        //ok: function () {
        //    $("#txt_TimeS").val()
        //    callBack.apply(null, val);[1,2,3]
        //    //stimeDialog.close();
        //},

        //init: function () {
        //    loadStatus();
        //},
        close: function (e) {
            art.dialog.close();
        },

    });
}

function callbackFun(callBack, val) {
    callBack.apply(null, val);
}

 

posted @ 2018-05-21 21:21  hy31337  阅读(690)  评论(0)    收藏  举报
.net求学者