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


<!DOCTYPE html>
<html>
<head>
    <title>冲销报表</title>
    <script type="text/javascript" src="../jscript/jquery-1.11.3.min.js"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <script src="../jscript/format.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>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script type="text/javascript" src="../jscript/export.js"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        #SearchDlg {
            padding: 10px;
            width: 700px;
            height: 230px;
        }

        .SearchTable {
            width: 700px;
            height: auto;
        }

            .SearchTable .TdTitle {
                width: 15%;
            }

            .SearchTable .TdContent {
                width: 35%;
            }

        #CostNames {
            width: 91.7%;
            height: 60px;
            border: 1px solid #cccccc;
            font-size: 12px;
            padding: 2px;
            resize: none;
        }

        #CommNames {
            width: 91.7%;
            height: 60px;
            border: 1px solid #cccccc;
            font-size: 12px;
            padding: 2px;
            resize: none;
        }
    </style>
</head>
<body>
    <form id="frmForm">
        <input id="Attribute" name="Attribute" value="" type="hidden" />
        <input id="CorpCostIDs" name="CorpCostIDs" value="" type="hidden" />
        <input id="CommIDs" name="CommIDs" value="" type="hidden" runat="server" />
        <input id="hCommID" name="hCommID" value="" type="hidden" runat="server" />
        <input id="hOrganCode" name="hOrganCode" value="" type="hidden" runat="server" />
        <div class="datagrid-mask" style="height: 100%; width: 100%;"></div>
        <div class="datagrid-mask-msg" style='font-size: 12px; height: 55px; border: 1px solid #cccccc; z-index: 999999;'>
            <div id='DivProgressBar' class='easyui-progressbar' style='width: 200px; border: 1px solid #cccccc; margin-top: 10px;'></div>
            <div id='DivMsg' style='width: 200px; text-align: center; margin-top: 5px;'></div>
        </div>

        <div id="TableContainer" style="width: 100%;"></div>
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" style="overflow: hidden;" data-options="iconCls:'icon-search',closed: true,modal:true">
            <table class="SearchTable">
                <tr>
                    <td class="TdTitle">项目名称
                    </td>
                    <td class="TdContent" colspan="3">
                        <textarea id="CommNames" name="CommNames" onclick="SelComm();" runat="server" ru="server" readonly></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">费用项目
                    </td>
                    <td class="TdContent" colspan="3">
                        <textarea id="CostNames" name="CostNames" runat="server" onclick="SelCost();"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">开始时间
                    </td>
                    <td class="TdContent">
                        <input id="StartDate" name="StartDate" class="Wdate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })"  runat="server" />
                    </td>
                    <td class="TdTitle">结束时间
                    </td>
                    <td class="TdContent">
                        <input id="EndDate" name="EndDate" class="Wdate"  onclick=" WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" runat="server"/>                        
                    </td>
                </tr>               
                <tr>
                    <td colspan="4" style="text-align: center; padding-top: 5px;">
                        
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="Search();">查询</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="SearchData();">统计</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="Clear();">清空</a>
                    </td>
                </tr>
            </table>
        </div>
        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

            $(function () {

                //获取进度
                $.tool.DataPostNoLoading('WriteOffOrganReport', 'TakeProgress', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        var Obj = JSON.parse(_Data);
                        if (_Data == '[]') {
                            LoadData();
                        }
                        else {
                            SetProgress(Obj);
                            if (Obj[0].Curr == '100') {
                                LoadData();
                            }
                            else {
                                LoadData();
                                //展示进度
                                ShowProgress();
                                //获取执行情况进度
                                ProgressInterval = setInterval("TakeProgress()", 1000);
                            }
                        }
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });

            });

            function SelComm() {

                if ($('#hCommID').val() == '') {
                    var w = $(window).width() * 0.7;
                    HDialog.Open(w, 500, '../DialogNew/SelComm.aspx?IsCheck=1', "选择管理项目", false, function callback(_Data) {
                        var arrRet = JSON.parse(_Data);
                        $("#CommIDs").val(arrRet.id);
                        $("#CommNames").val(arrRet.name);
                    });
                }
            }

            function Clear() {
                $("#CostIDs").val("");
                $("#CostNames").val("");
            }

            function SelCost() {
                if ($('#hCommID').val() == '') {
                    HDialog.Open('700', '450', "../dialogNew/MultiCorpCostDlg.aspx" + "?Ram=" + Math.random(), '收费项目选择', false, function (_data) {
                        var varReturn = _data;
                        if (varReturn != "") {//**获得返回 刷新
                            var varObjects = varReturn.split("\t");
                            $('#CorpCostIDs').val(varObjects[0]);
                            $('#CostNames').val(varObjects[1]);
                        }

                    });
                }
                else {
                    HDialog.Open('700', '450', "../dialogNew/MultiCorpCommCostDlg.aspx" + "?Ram=" + Math.random(), '收费项目选择', false, function (_data) {
                        var varReturn = _data;
                        if (varReturn != "") {//**获得返回 刷新
                            var varObjects = varReturn.split("\t");
                            $("#CorpCostIDs").val(varObjects[0]);
                            $("#CostNames").val(varObjects[1]);
                        }
                    });
                }
            }

            function InitFunction() {
                var h = $(window).height();
                var w = $(window).width();

                $("#CorpCostIDs").val('0')

                $("#TableContainer").css("height", h + "px");
                $("#TableContainer").css("width", w + "px");
                if ($('#hCommID').val() != '') {
                    $('#ViewType').val('Comm');
                    $('#ViewType').prop('disabled', 'disabled');
                }
            }
            InitFunction();

            var frozenColumns = [[          
                { field: '区域', title: '区域', align: 'center', sortable: true, width: 100 },
                { field: '项目', title: '项目', align: 'center', sortable: true, width: 100 },
                { field: '收费模式', title: '收费模式', align: 'center', sortable: true, width: 100 },
            ]]

            var column;
            column = [
                [
                     { colspan: 1, rowspan: 2, width: 150, align: 'center', field: '往年本年', title: '往年/本年' },
                    { colspan: 1, rowspan: 2, width: 150, align: 'center', field: '费用名称', title: '费用名称' },
                    { colspan: 1, rowspan: 2, width: 150, align: 'center', field: '客户类别', title: '客户类别' },
                    { colspan: 1, rowspan: 2, width: 150, align: 'center', field: '冲销方式', title: '冲销方式' },
                    { colspan: 1, rowspan: 2, width: 150, align: 'center', field: '考核条件', title: '考核条件' },
                    { colspan: 3, align: 'center', title: '冲销金额合计' },
                    { colspan: 3, align: 'center', title: '冲销合同违约金' }
                   
                ],
                [
                        //冲销金额
                    { field: '冲销金额', title: '含税金额', align: 'left', sortable: true, width: 100 },
                    { field: '冲销金额税费', title: '税费', align: 'left', sortable: true, width: 100 },
                    { field: '冲销金额不含税金额', title: '不含税金额', align: 'left', sortable: true, width: 100 },

                    //冲销合同违约金
                    { field: '冲销合同违约金', title: '含税金额', align: 'left', sortable: true, width: 100 },
                    { field: '冲销合同违约金税费', title: '税费', align: 'left', sortable: true, width: 100 },
                    { field: '冲销合同违约金不含税金额', title: '不含税金额', align: 'left', sortable: true, width: 100 }
                ]
            ];

            var toolbar = [
                {
                    text: '筛选',
                    iconCls: 'icon-search',
                    handler: function () {

                        $('#SearchDlg').parent().appendTo($("form:first"));
                        $('#SearchDlg').dialog('open');
                    }
                }, '-',
                {
                    text: 'Excel导出',
                    iconCls: 'icon-page_white_excel',
                    handler: function () {

                        var rowData = $('#TableContainer').datagrid('getData');
                        if (rowData == '') {
                            HDialog.Info('请先生成报表');
                        }
                        else {
                            window.location.href = "WriteOff_OrganToExcel.aspx";
                        }
                    }


                }
            ];

            var ProgressInterval;

            function Search() {
                LoadData();
            }

            function SearchData() {

                if ($("#LastStaticYearMonth").val() == "" || $("#ThisStaticYearMonth").val() == "") {
                    HDialog.Info("日期不能为空");
                    return;
                }

                if ($("#OrganCode").val() != "01") {
                    if ($("#CommIDs").val() == "") {
                        HDialog.Info("请选择需要统计的小区");
                        return;
                    }
                }

                if ($("#CorpCostIDs").val() == "") {

                    HDialog.Info("请选择需要统计的费用项目");
                    return;

                }
                $("#SearchDlg").dialog("close");
                //启动任务
                StartTask();
                //展示进度
                ShowProgress();
                //获取执行情况进度
                ProgressInterval = setInterval("TakeProgress()", 1000);
            }

            function StartTask() {
                //启动一个任务
                $.tool.DataPostNoLoading('WriteOffOrganReport', 'StartTask', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }

            //加载数据
            function LoadData() {
                //加载已经统计了的数据
                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    frozenColumns: frozenColumns,
                    fitColumns: false,
                    singleSelect: true,
                    pagination: true,
                    remoteSort: false,
                    rownumbers: true,
                    toolbar: toolbar,
                    border: false,
                    sortOrder: "asc",
                    showFooter: true,
                    onLoadSuccess: function (data) {
                        $("#SearchDlg").dialog("close");
                        CloseProgress();
                    },
                    onBeforeLoad: function (param) {
                        param = $.JQForm.GetParam("WriteOffOrganReport", "LoadData", "TableContainer", param);
                    },
                    rowStyler: function (index, row) {
                        if (row.FeesID == 'footer') {
                            return 'background-color:#F4F4F4;border:none;'; // return inline style
                        }
                        return 'height:20px;';
                    }

                });


            }

            //获取进度
            function TakeProgress() {
                $.tool.DataPostNoLoading('WriteOffOrganReport', 'TakeProgress', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        var Obj = JSON.parse(_Data);
                        if (_Data == '[]') {
                            LoadData();
                            CloseProgress();
                        }
                        else {
                            SetProgress(Obj);
                            if (Obj[0].Curr == '100') {
                                $('#hiIsSQLData').val('1');
                                LoadData();
                                CloseProgress();
                            }
                            else {
                            }
                        }
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }

            //显示进度
            function ShowProgress() {
                var h = parseInt($(window).height()) + parseInt($(window).scrollTop());
                var ht = parseInt($(window).scrollTop());
                $(".datagrid-mask").css({ display: "block", width: "100%", height: h });
                $(".datagrid-mask-msg").css({ display: "block", left: ($(document.body).outerWidth(true) - 350) / 2, top: ht + 240 });
            }
            //关闭进度
            function CloseProgress() {
                clearInterval(ProgressInterval);
                $(".datagrid-mask").hide();
                $(".datagrid-mask-msg").hide();
            }
            //设置进度
            function SetProgress(Obj) {
                $('#DivProgressBar').progressbar('setValue', Obj[0].Curr);
                $('#DivMsg').html(Obj[0].MessageInfo);
            }
        </script>
    </form>
</body>
</html>



