<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WbPollingPlanList.aspx.cs" Inherits="M_Main.dialog.WbPollingPlanList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>巡检计划列表</title>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script src="../jscript/jquery.tool.js" type="text/javascript"></script>
    <script src="../jscript/Authority.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.1/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.1/themes/icon.css" />
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <script src="../jscript/QualityDictionaryCanNull.js" type="text/javascript"></script>
    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <script src="../jscript/Cache.js"></script>

    <link href="../css/editcss.css" type="text/css" rel="stylesheet" />


    <script type="text/javascript" src="../jscript/jquery.ztree.core-3.5.js"></script>
    <link href="../css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet" />

    <script src="../Jscript-Ui/hplus/js/plugins/layer/layer.min.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <style type="text/css">
        body {
            margin: 0px;
            margin-top: 0px;
            overflow: hidden;
            background-color: #ffffff;
        }
    </style>

</head>
<body>
    <form id="frmForm" runat="server">
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true" style="width: 850px; height: 150px; overflow: hidden; padding: 10px;">
            <table style="width: 100%; font-size: 12px; font-family: 微软雅黑;">
                <tr>

                    <td class="TdTitle">设备系统</td>
                    <td class="TdContent">
                        <input type="hidden" id="EqId" name="EqId" />
                        <input type="text" id="EqIdName" name="EqIdName" onclick="SelRankSys();" class="easyui-validatebox" />
                    </td>

                    <td class="TdTitle">机房名称</td>
                    <td class="TdContent">
                        <input type="hidden" id="SpaceId1" name="SpaceId1" />
                        <input type="text" id="SpaceIdName" name="SpaceIdName" onclick="SelSpace();" class="easyui-validatebox" />
                    </td>
                    <td class="TdTitle">计划名称</td>
                    <td class="TdContent">
                        <input type="text" id="PlanName" name="PlanName" class="easyui-validatebox" />
                    </td>
                    <td class="TdTitle">维保内容</td>
                    <td class="TdContent">
                        <input type="text" id="Content" name="Content" class="easyui-validatebox" />
                    </td>
                </tr>
                <tr>

                    <td class="TdTitle">责任岗位</td>
                    <td class="TdContent">
                        <input type="hidden" id="RoleCode" name="RoleCode" />
                        <input type="text" id="RoleName" name="RoleName" onclick="SelRole();" class="easyui-validatebox" />
                    </td>
                    <td class="TdTitle">任务状态</td>
                    <td class="TdContentSearch">
                        <select name="Statue" id="Statue">
                            <option value=""></option>
                            <option value="未完成">未完成</option>
                            <option value="已过期">已过期</option>
                            <option value="已完成">已完成</option>
                            <option value="已关闭">已关闭</option>
                        </select>
                    </td>
                    <td class="TdTitle"></td>
                    <td class="TdContentSearch"></td>
                    <td class="TdTitle">至</td>
                    <td class="TdContentSearch"></td>
                </tr>

                <tr>
                    <td colspan="8" align="center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="LoadBind();">确定筛选</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'"
                            onclick="btnClear();">清空</a>
                    </td>
                </tr>
            </table>

        </div>

        <input type="hidden" id="ReturnValue" name="ReturnValue" />
        <div style="width: 100%; background-color: #cccccc;" id="DivContainer">
        </div>
        <input type="hidden" id="CommId" name="CommId" />

        <input type="hidden" id="RankId" name="RankId" />
        <input type="hidden" id="SpaceId" name="SpaceId" />
        <input type="hidden" id="PlanId" name="PlanId" />
        <input type="hidden" id="HidStandardId" name="HidStandardId" />
        <input type="hidden" id="Standard" name="Standard" />


        <script type="text/javascript">
            //选择设备系统
            function SelRankSys() {
                HDialog.Open('600', '450', '../DialogNew/RankListSys.aspx', '选择设备系统', true, function callback(_Data) {
                    if (_Data != "") {//**获得返回的参数信息
                        var varObjects = JSON.parse(_Data);
                        $("#EqId").val(varObjects.RankId);
                        $("#EqIdName").val(varObjects.RankName);
                    }
                });
            }
            //设备空间名称
            function SelSpace() {
                var CommID = "";
                HDialog.Open('600', '450', '../DialogNew/RankSpace.aspx?CommId=' + CommID, '选择设备机房', true, function callback(_Data) {
                    if (_Data != "") {//**获得返回的参数信息
                        var varObjects = JSON.parse(_Data);
                        $("#SpaceId1").val(varObjects.SpaceId);
                        $("#SpaceIdName").val(varObjects.MacRoName);
                    }
                });
            }

            function btnClear() {
                $("#CommId").val("");
                $("#CommName").val("");
                $("#EqId").val("");
                $("#EqIdName").val("");
                $("#SpaceId").val("");
                $("#SpaceIdName").val("");
                $("#PlanId").val("");
                $("#PlanName").val("");
                $("#Content").val("");
                $("#RoleCode").val("");
                $("#RoleName").val("");
                $('#Statue').combobox('setValue', "");
            }

            function InitTableHeight() {
                var h = 450;
                $("#DivContainer").css("height", h + "px");
            }

            InitTableHeight();

            var column = [[
             { field: 'ck', checkbox: true },
             { field: 'Sort', title: '序号', width: 30, align: 'left', sortable: true },
             { field: 'CommName', title: '项目名称', width: 100, align: 'left', sortable: true },
             { field: 'PlanName', title: '计划名称', width: 180, align: 'left', sortable: true },
             { field: 'EqName', title: '设备系统', width: 80, align: 'left', sortable: true },
            { field: 'MacRoName', title: '机房名称', width: 80, align: 'left', sortable: true },
            {
                field: 'Content', title: '维保内容', width: 180, align: 'left', sortable: true, formatter: function (value, row, index) {
                    var str = value;
                    if (value.length > 10)
                        str = str.substr(0, 15) + '...';
                    return str;
                }
            },
            { field: 'FrequencyName', title: '维保频次', width: 100, align: 'left', sortable: true },
            { field: 'BeginTime', title: '有效时间起', width: 70, align: 'left', sortable: true },
            { field: 'EndTime', title: '有效时间止', width: 70, align: 'left', sortable: true },
            { field: 'WorkDayBegin', title: '有效星期天数', width: 80, align: 'left', sortable: true },
            { field: 'WorkTime', title: '额定工时', width: 60, align: 'left', sortable: true },
            { field: 'PerfNum', title: '绩效系数', width: 60, align: 'left', sortable: true },
            { field: 'RoleName', title: '责任岗位', width: 90, align: 'left', sortable: true },
            {
                field: 'IsEntrust', title: '是否外委', width: 60, align: 'left', sortable: true, formatter: function (value, row, index) {
                    var str = "是";
                    if (value == '0')
                        str = "否";
                    return str;
                }
            },
            { field: 'EntrustCompany', title: '外委单位', width: 60, align: 'left', sortable: true },
            { field: 'CheckRoleName', title: '验收岗位', width: 90, align: 'left', sortable: true },
             { field: 'Remark', title: '备注', width: 150, align: 'left', sortable: true }

            ]];

            var toolbar =
               [
                 {
                     text: '保存',
                     iconCls: 'icon-save',
                     handler: function () {
                         OnClickSave();
                     }
                 }
                 , '-', {
                     text: '筛选',
                     iconCls: 'icon-filter',
                     handler: function () {
                         $('#SearchDlg').parent().appendTo($("form:first"))
                         $('#SearchDlg').dialog('open');
                     }
                 }
               ];

            function OnClickSave() {
                var StandardId = document.getElementById("HidStandardId").value;
                if (StandardId != "") {
                    self.returnValue = StandardId;
                    self.close();
                    return;
                }
                var Standard = document.getElementById("Standard").value.split('|');
                var ss = "";
                for (var i = 0; i < Standard.length; i++) {
                    if (ss == "")
                        ss = Standard[i];
                    else
                        ss += "|" + Standard[i];
                }
                self.returnValue = ss;
                self.close();
            }

            //加载数据
            function LoadBind() {
                $("#DivContainer").datagrid({
                    url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=CsEquipment&Command=GetPollingPlanWb&' + $("#frmForm").serialize(),
                    method: "get",
                    loadMsg: '数据加载中,请稍候...',
                    nowrap: false,
                    rownumbers: true,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    fitColumns: false,
                    border: false,
                    pagination: true,
                    singleSelect: false,//注释了就可以批量删除 与 设置启用停用
                    width: "100%",
                    toolbar: toolbar,
                    sortOrder: "asc",
                    onDblClickRow: function (rowIndex, rowData) {
                        document.getElementById("HidStandardId").value = rowData.Id;
                        OnClickSave();
                    },
                    onCheck: function (rowIndex, rowData) {
                        document.getElementById("Standard").value = document.getElementById("Standard").value + "|" + rowData.Id;
                    },
                    onUncheck: function (rowIndex, rowData) {
                        var ss = document.getElementById("Standard").value.split('|');
                        for (var i = 0; i < ss.length; i++) {
                            if (ss[i].indexOf(rowData.Id) >= 0) {
                                ss.splice(i, 1);
                            }
                        }
                        valu = "";
                        for (var i = 0; i < ss.length; i++) {
                            valu += "|" + ss[i];
                        }
                        document.getElementById("Standard").value = valu.substr(1, valu.length);
                    },
                    onCheckAll: function (rows) {
                        document.getElementById("Standard").value = "";
                        for (var i = 0; i < rows.length; i++) {
                            document.getElementById("Standard").value = document.getElementById("Standard").value + "|" + rows[i].Id;
                        }
                    },
                    onUncheckAll: function (rows) {
                        document.getElementById("Standard").value = "";
                    }
                });
                $("#SearchDlg").dialog("close");
            }
            LoadBind();

            //设置上下页改变之后选中的值还在
            //function SetCheckboxValue() {
            //    var trainValue = document.getElementById("Standard").value;
            //    if (trainValue.length > 0) {
            //        var rows = $('#DivContainer').datagrid("getRows");
            //        $.each(rows, function (index, item) {
            //            if (trainValue.indexOf(item.Id) > 0) {
            //                $('#DivContainer').datagrid("checkRow", index);
            //            }
            //        });
            //    }
            //}
            //$(document).ready(function () {
            //    //获取DataGrid分页组件对象
            //    var p = $("#DivContainer").datagrid('getPager');
            //    //设置分页组件参数
            //    $(p).pagination({
            //        onSelectPage: function (pageNumber, pageSize) {
            //            $.ajax({
            //                url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=CsQuality&Command=GetObjectStandardListDialog&page=' + pageNumber + '&rows=' + pageSize + '&' + $("#frmForm").serialize(),
            //                type: 'GET',
            //                dataType: 'JSON',
            //                cache: false,
            //                success: function (_Data) {
            //                    $("#DivContainer").datagrid('loadData', _Data);
            //                    SetCheckboxValue();
            //                },
            //                complete: function (XMLHttpRequest, textStatus, errorThrown) {

            //                },
            //                error: function (XMLHttpRequest, textStatus, errorThrown) {
            //                    $.messager.alert('错误', '数据读取错误', 'error');
            //                }
            //            });
            //        }
            //    });
            //});

        </script>
    </form>
</body>
</html>
