
@{
    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">
                        <button type="button" class="btn btn-primary" onclick="exportFile();">导出</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 css{
    <style>
        .mules {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
}
@section scripts{
    <script>
        var tb;
        $(document).ready(function () {
            var height = document.body.clientHeight;
            $("#roletable").attr("data-height", (height - 100));

            list();
        })

        function list() {
            var columns = [
                {
                    field: 'buyno', title: '其他采购单号', width: '150', sortable: true, iscount:true,formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.buyno + '">' + data.buyno + '</div>';
                    }
                },
                { field: 'pay_time', title: '出纳付款时间', width: '150', sortable: true },
                { field: 'skuname', title: '采购物品', width: '180', sortable: false },
                { field: 'amount', title: '本期借方发生额', width: '110', sortable: false, iscount:true },
                { field: 'creditamount', title: '本期贷方发生额', width: '100', sortable: true, iscount:true },
                { field: 'day', title: '统计日期', width: '90', sortable: true }
            ];

            var pvalue = $('#companyvalue').val();

            var url = '@Url.Content("~/Reports/Finance/ListFixedAssetsDetailsJson")' + '?date=@(ViewBag.date)&companyvalue=@(ViewBag.companyvalue)';

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "", {
                    showfooter: true, loadsuccess: function (d) {
                        //替换汇总行的相关列值
                        var tr = $('.fixed-table-footer').find('tr');
                        for (var c in columns) {
                            var key = columns[c].field;
                            if (columns[c].iscount) {
                                for (var v in d.count_row) {
                                    if (key == v) {
                                        tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                });
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

        function exportFile() {
            window.open('@Url.Content("~/Reports/Finance/ListFixedAssetsDetailsExport?date=")' + '@(ViewBag.date)&companyvalue=@(ViewBag.companyvalue)', "_blank");
        }
    </script>

}

