
@{
    ViewData["Title"] = "管理成本明细";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox-content m-b-sm border-bottom">
            <form id="toolbar">
                <div class="form-inline" style="line-height:40px;">
                    <div class="form-group">
                        <label>付款时间</label>
                        <input class="form-control layer-date" id="start" style="width:120px;" placeholder="付款开始时间" value="@ViewBag.start.ToString("yyyy-MM-dd")" />
                        <input class="form-control layer-date" id="end" style="width:120px" placeholder="付款结束时间" value="@ViewBag.end.ToString("yyyy-MM-dd")" />
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
                        <button type="button" class="btn btn-success" onclick="ExportCSV()">导出</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="ibox-content m-b-sm border-bottom">
            <table id="roletable" style="table-layout:fixed;"></table>
        </div>

    </div>
</div>

@section scripts{ 
    <script type="text/javascript">
        var companyid = @ViewBag.paycompanyid;
        var headname = '@Html.Raw(ViewBag.headname)';
        var categoryname = '@Html.Raw(ViewBag.categoryname)';
        var type = @ViewBag.type;
        var issub = @ViewBag.isSub;

        var tb;
        $(document).ready(function () {
            list();
        })

        function list() {

            var start = $('#start').val();
            var end = $('#end').val();

            var columns = [
                {
                    field: 'no', title: '费用单号', formatter: function (idx, data) {
                        //return '<div class="mules" title="' + data.no + '">' + data.no + '</div>';
                        return '<a href="http://fee.bailuntec.com/#/manage_cost?manageCostType=' + data.manageCostType+'&no='+data.no+'" target="_blank">' + data.no + '</a>';
                    }
                },
                { field: 'departmentName', title: '部门名称' },
                { field: 'companyName', title: '付款主体名称', },
                { field: 'feeSuperType', title: '父级分类' },
                { field: 'feeSubType', title: '子分类' },
                { field: 'amount',title: '金额' },
                { field: 'currency', title: '币种' },
                { field: 'amountRmb', title: '人民币金额' },
                { field: 'receiveUnit', title: '收款单位' },
                { field: 'reason', title: '付款理由' },
                { field: 'payTime', title: '付款时间' },
            ];

            var url = '@Url.Content("~/Reports/Finance/ListAdministrativeCostJson")' + '?paycompanyid=' + companyid + '&headname=' + headname + '&categoryname=' + categoryname + '&start=' + start + '&end=' + end + '&type=' + type + '&issub=' + issub;

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "",);
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

        function ExportCSV() {
            var start = $('#start').val();
            var end = $('#end').val();

            window.open('@Url.Content("~/Reports/Finance/ExportListAdministrativeCost")' + '?paycompanyid=' + companyid + '&headname=' + headname + '&categoryname=' + categoryname + '&start=' + start + '&end=' + end + '&type=' + type + '&issub=' + issub, '_blank');

        }

    </script>
}
