
@{
    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 id="month" name="month" class="form-control" style="width:130px;" placeholder="年.月" value="@(ViewBag.month)" />
                    </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 id="btnexport" style="display:none;" 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 tb;
        $(document).ready(function () {
            laydate.render({ elem: '#month', type: 'month' });
            list();

        })

        function list() {

            var month = $('#month').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>' + (data.no==""?"":'<a style="margin-left:5px;color:#aaa;" onclick="showAttachment(\''+data.no+'\');">出纳凭证</a>');
                    }
                },
                { field: 'departmentName', title: '部门名称' },
                { field: 'companyName', title: '付款主体名称', },
                { field: 'type_name', title: '费用类别' },
                { field: 'accounting_subject_name', 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/MonthSaleProfitNew_FeeOrderDetailJson")' + '?month=' + month +'&col=@(ViewBag.col)';

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "", {
                    loadsuccess: function (d) {
                        if (d.isexport == 1) {
                            $('#btnexport').show();
                        }
                    }
                });
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

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

            window.open('@Url.Content("~/Reports/Finance/ExportMonthSaleProfitNewFeeOrderDetail")' + '?month=' + month + '&col=@(ViewBag.col)', '_blank');

        }

        function showAttachment(no) {
            $.submit({
                type:'POST',
                url: '@Url.Content("~/Reports/Finance/GetFeeCashAttachment")',
                paramData: 'no='+no,
                func: function (result) {
                    if (result.success) {
                        //alert(result.data);

                        if (result.data.indexOf('.png') > 0 || result.data.indexOf('.jpg') > 0 || result.data.indexOf('.gif') > 0) {
                            layer.open({
                                type: 1,
                                title: false,
                                closeBtn: 1,
                                area: ['auto'],
                                skin: 'layui-layer-nobg', //没有背景色
                                shadeClose: true,
                                content: '<img src="' + result.data + '" style="width:800px;height:540px;" />'
                            });
                        }
                        else {
                            layer.open({
                                type: 1,
                                title: false,
                                closeBtn: 0,
                                shadeClose: true,
                                skin: 'yourclass',
                                content: '<div style="padding:30px 60px;"><a href="'+result.data+'" target="_blank" >'+下载附件+'</a><div>'
                            });
                        }
                    }
                    else {
                        alert(result.msg);
                    }
                }
            })
        }

    </script>
}
