invoiceModule.directive('gdInvoicePrint', ['$log', function ($log) {
    'use strict';

    console.log('gdInvoicePrint.ctor()...');
    $log.debug('gdInvoicePrint.ctor()...');
    return {
        restrict: 'E',
        templateUrl: '/app/vat/output-invoice/gd-invoice-print/gd-invoice-print.html' + '?_=' + Math.random(),
        scope:
        {

        },
        controller: 'gdInvoicePrintController',
        link: function (scope, element) {
                //计算datagrid的高度
                scope.setInvoiceGridHeight = function () {
                   var contentbody = '.gdprint-grid-container';
                    var pageHeight = $(document).height();// 810; // parseInt($(pageWrapSelector).css('height').replace('px', ''));
                    var contentbodyHeight = pageHeight -520;
                     
                    var height = contentbodyHeight;

                    // if (scope.gridHeight < contentbodyHeight - 34){
                    //     height = scope.gridHeight + 34;
                    // } 

                    $(contentbody).css('height', height);
                    // $(dxGridSelector).css('height', height);
                    //$(invoiceDataGridSelector).css('max-height', '100%');

                    try {
                        var option = $('#invoiceGdPrintGridContainer').dxDataGrid('option');
                        option.height = height - 34;
                        // option.height = 400;
                        $('#invoiceGdPrintGridContainer').dxDataGrid('option', option);
                        // $('#invoiceGdPrintGridContainer').dxDataGrid('instance').repaint();
                    }
                    catch (e) {
                        console.log(e);
                    }
                };


                $(window).on('resize', function () {
                    scope.setInvoiceGridHeight();
                });
        }
    };
}]);