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

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/jquery.tool.js" type="text/javascript"></script>
    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css">
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/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/Dialog.js" type="text/javascript"></script>
    <link href="../css/button.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/hplus/js/plugins/layer/layer.min.js"></script>

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

    <script type="text/javascript" src="../jscript/jquery.ztree.core-3.5.js"></script>
    <link href="../css/style.css" type="text/css" rel="stylesheet" />
    <link href="../css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet" />
    <link href="../css/workflow.css" type="text/css" rel="stylesheet" />
    <script src="../jscript/DateFormat.js" type="text/javascript"></script>
    <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
    <style type="text/css">
        body {
            margin: 0px;
            margin-top: 0px;
            overflow: hidden;
            font-family: 微软雅黑;
            background-color: #ffffff;
        }

        .Container {
            width: 100%;
            height: auto;
            font-size: 12px;
            font-family: 微软雅黑;
        }

        .ContainerLeft {
            float: left;
            width: 25%;
            padding-right: 5px;
            overflow-y: auto;
            border-right: 1px solid #cccccc;
        }

        .ContainerRight {
            float: left;
            width: 73.5%;
        }

        textarea {
            height: 22px;
            resize: none;
            border: 1px solid #cccccc;
            width: 200px;
        }
    </style>
</head>
<body>
    <form id="frmForm" runat="server">

        <div class="Container">
            <div id="ContainerLeft" class="ContainerLeft" style="height: 500px;">
                <div id="TableContainerTree">
                </div>
            </div>
            <div id="ContainerRight" class="ContainerRight">
                <div style="background-color: #cccccc;" id="TableContainer">
                </div>
            </div>
        </div>

        <input id="hidID" type="hidden" size="2" name="hidID" runat="server" />
        <input id="OrganCode" type="hidden" size="2" name="OrganCode" runat="server" />
        <input id="OrganName" type="hidden" size="2" name="OrganName" runat="server" />
        <input id="InPopedom" type="hidden" name="InPopedom" runat="server" />
        <script type="text/javascript">

            var column;
            column = [[
                {
                    field: 'text', title: '项目列表', align: 'left', sortable: true,
                    formatter: function (value, row, index) {
                        var str = "<a class=\"HrefStyle\" href=\"#\">" + row.text + "</a>";
                        return str;
                    }
                },
                {
                    field: 'InPopedom', title: '项目ID', align: 'left', formatter: function (value, row, index) {
                        var str = row.attributes.InPopedom;
                        if (str == 0) str = '';
                        return str;
                    }
                }
            ]];

            var IsCollapseAll = false;
            var toolbar = [
                {
                    text: '展开/折叠',
                    iconCls: 'icon-redo',
                    handler: function () {
                        if (IsCollapseAll == true) {
                            $('#TableContainerTree').treegrid('expandAll');
                            IsCollapseAll = false;
                        }
                        else {
                            $('#TableContainerTree').treegrid('collapseAll');
                            IsCollapseAll = true;
                        }
                    }
                }
            ];

            function LoadListTree() {
                $("#TableContainerTree").treegrid({
                    url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=Organ&Command=GetOrganTreeGridList&' + $('#frmForm').serialize(),
                    treeField: 'text',
                    idField: 'id',
                    method: "get",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    fitColumns: true,
                    singleSelect: true,
                    remoteSort: false,
                    pagination: false,
                    rownumbers: true,
                    IsCustomHead: false,
                    cascadeCheck: false,
                    width: "100%",
                    toolbar: toolbar,
                    border: false,
                    sortOrder: "asc",
                    onClickRow: function (node) {
                        if (parseInt(node.attributes.InPopedom) > 0) {
                            $("#InPopedom").val(node.attributes.InPopedom);
                            $("#OrganName").val(node.text);
                        } else {
                            $("#InPopedom").val('');
                            $("#OrganName").val('');
                        }
                        LoadList();
                    }
                });
            }
            LoadListTree();

            function InitFunction() {
                var h = $(window).height();
                $("#ContainerLeft").css("height", h + "px");
                $("#ContainerRight").css("height", h + "px");
                $("#TableContainer").css("height", h + "px");
            }
            InitFunction();

            var toolbar = [
                {
                    text: '新增',
                    iconCls: 'icon-add',
                    handler: function () {
                        if ($("#InPopedom").val() == "" || $("#InPopedom").val() == null || $("#InPopedom").val() == undefined || $("#InPopedom").val() == 0) {
                            HDialog.Info("请选择要设置的项目");
                        } else {
                            HDialog.Open('700', '280', '../ChargesNew/PreCostSettingManage.aspx?OpType=insert&CommID=' + $("#InPopedom").val() + '&CommName=' + encodeURI($("#OrganName").val()), '新增费用预存统计设置', true,
                                function callback(_Data) {
                                    if (_Data == "true") {
                                        LoadList();
                                    }

                                });
                        }
                    }
                }, '-',
                {
                    text: '删除',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        var row = $("#TableContainer").datagrid("getSelected");
                        if (row != null && row != undefined && row != "") {
                            DelRecord(row.ID);
                        } else {
                            HDialog.Info("请选择一行数据进行删除！");
                        }
                    }
                }, '-',
                {
                    text: '修改',
                    iconCls: 'icon-edit',
                    handler: function () {
                        var row = $("#TableContainer").datagrid("getSelected");
                        if (row != "" && row != null && row != undefined) {
                            HDialog.Open('700', '280', '../ChargesNew/PreCostSettingManage.aspx?OpType=edit&ID=' + row.ID + '&CommID=' + $("#InPopedom").val() + '&CommName=' + encodeURI($("#OrganName").val()), '修改费用预存统计设置', true,
                                function callback(_Data) {
                                    if (_Data == "true") {
                                        LoadList();
                                    }
                                });
                        }
                        else {
                            HDialog.Info("请选择一行数据进行修改！");
                        }
                    }
                }, '-',
                {
                    text: 'Excel导入',
                    iconCls: 'icon-page_white_excel',
                    handler: function () {
                        HDialog.Open(770, 270, '../ChargesNew/BatchImportPreCostSetting.aspx', '批量导入设置信息', false, function callback(_Data) {
                            if (_Data == "true") {
                                LoadList();
                            }
                        });
                    }
                }

            ];

            function DelRecord(ID) {
                $.messager.confirm('确定', '是否删除该项', function (r) {
                    if (r) {
                        $.tool.DataGet('PreCostSetting', 'DeLPreCostSettingList', 'ID=' + ID,
                            function Init() {
                            },
                            function callback(_Data) {
                                if (_Data == "false") {
                                    HDialog.Info("操作成功！");
                                } else {
                                    LoadList();
                                }
                            },
                            function completeCallback() {
                            },
                            function errorCallback() {
                            });
                    }
                });
            }

            var column = [[
                { field: 'ID', title: 'ID', width: 25, align: 'left', sortable: true, hidden: true },
                { field: 'CommName', title: '项目名称', width: 150, align: 'left', sortable: true },
                {
                    field: 'StartTime', title: '预算费用起算日期', width: 200, align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = formatDate(row.StartTime, "yyyy-MM-dd");
                        return str;
                    }
                },
                { field: 'Amount', title: '目标金额（元）', width: 150, align: 'left', sortable: true }
            ]];

            function LoadList() {
                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    remoteSort: false,
                    fitColumns: false,
                    rownumbers: true,
                    singleSelect: true,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    pagination: true,
                    width: "100%",
                    border: false,
                    toolbar: toolbar,
                    border: false,
                    sortOrder: "asc",
                    onBeforeLoad: function (param) {
                        param = $.JQForm.GetParam("PreCostSetting", "GetPreCostSettingList", "TableContainer", param);
                    },
                });
            }
            LoadList();


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

