
@{
    ViewData["Title"] = "应付账款";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
}

@*<div class="ibox-content m-b-sm border-bottom">
        <table id="tb" class="table table-hover table-bordered" style="width:100%;">
            <thead>
                <tr>
                    <th>供应商名称</th>
                    <th>是否成品</th>
                    <th>公司主体</th>
                    <th>期初金额</th>
                    <th>借方发生额</th>
                    <th>贷方发生额</th>
                    <th>期末金额</th>
                    <th>日期</th>
                </tr>
            </thead>

            @if (ViewBag.list.Count > 0)
            {
                foreach (var item in ViewBag.list)
                {
                    <tr>
                        <td>@item.supplier_name</td>
                        <td>@(item.is_finish == 0 ? "半成品" : "成品")</td>
                        <td>@item.pay_company_name</td>
                        <td>@item.start_amount</td>
                        <td>@(item.putting_amount + item.express_amount + item.adjust_amount - item.return_amount - item.return_express)</td>
                        <td>@(item.pay_amount - item.receive_amount)</td>
                        <td>@(item.end_amount.ToString("###,###.##"))</td>
                        <td>@item.day.ToString("yyyy-MM-dd")</td>
                    </tr>
                }
            }
        </table>
    </div>*@

<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: 'supplier_name', title: '供应商名称', width: '150', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.supplier_name + '">' + data.supplier_name + '</div>';
                    }
                },
                { field: 'is_finish', title: '是否成品', width: '100', sortable: true },
                {
                    field: 'pay_company_name', title: '公司主体', width: '180', sortable: true, formatter: function (idx, data) {
                        return '<div class="mules" title="' + data.pay_company_name + '">' + data.pay_company_name + '</div>';
                    }
                },
                {
                    field: 'start_amount', title: '期初金额', width: '100', sortable: true
                },
                { field: 'putting_amount', title: '借方发生额', width: '110', sortable: false },
                { field: 'pay_amount', title: '贷方发生额', width: '110', sortable: false },
                { field: 'end_amount', title: '期末金额', width: '100', sortable: true },
                { field: 'day', title: '统计日期', width: '90', sortable: true }
            ];

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

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "");
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }
        
        function exportFile() {
            window.open('@Url.Content("~/Reports/Finance/CopeWithExport?finish=")'+'@(ViewBag.finish)&date=@(ViewBag.date)&paycompanyid=@(ViewBag.paycompanyid)', "_blank");
        }
    </script>

}


