output-invoice-edit.js 2.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
invoiceModule.directive('outputInvoiceEdit', ['$log', 'SweetAlert', '$translate',
    function ($log, SweetAlert, $translate) {
        'use strict';
        $log.debug('outputInvoiceEdit.ctor()...');

        return {
            restrict: 'E',
            templateUrl: '/app/vat/output-invoice/output-invoice-edit/output-invoice-edit.html' + '?_=' + Math.random(),
            scope:
            {

            },
            controller: 'outputInvoiceEditController',
            link: function (scope, element) {
                //计算datagrid的高度
                scope.setInvoiceGridHeight = function () {
                    var invoiceDataGridSelector = '#invoiceEditGridContainer';
                    var pageWrapSelector = ".output-invoice-edit-wrapper";
                    var menuSelector = ".output-invoice-edit-wrapper .header-title";
                    var contentHeader = '.edit-content-container .header';
                    var contentbody = '.edit-content-container .body';
                    var buttonRow = '.edit-content-container .buttom-row';
                    var pageFooter = '.output-invoice-edit-wrapper .page-footer';
                    var dxGridSelector = ".edit-grid-container";

                    var pageHeight = $(document).height();// 810; // parseInt($(pageWrapSelector).css('height').replace('px', ''));
                    
                    var menuHeight = $(menuSelector).outerHeight(); //parseInt($(menuSelector).css('height').replace('px', ''));

                    var contentHeaderHeight = $(contentHeader).outerHeight(); //parseInt($(contentHeader).css('height').replace('px', ''));
                    var buttonRowHeight = $(buttonRow).outerHeight();  //parseInt($(buttonRow).css('height').replace('px', ''));
                    // var pageFooterHeight = $(pageFooter).outerHeight(); //parseInt($(pageFooter).css('height').replace('px', ''));

                    var pageFooterHeight = 0;
                    var contentbodyHeight = pageHeight - menuHeight - contentHeaderHeight;
                    var height = contentbodyHeight - buttonRowHeight - pageFooterHeight - 40 + 'px';
                    $(contentbody).css('height', contentbodyHeight);
                    // $(dxGridSelector).css('height', height);
                    //$(invoiceDataGridSelector).css('max-height', '100%');

                    try {

                        var option = $('#invoiceEditGridContainer').dxDataGrid('option');
                        option.height = height;
                        $('#invoiceEditGridContainer').dxDataGrid('option', option);
                        $(invoiceDataGridSelector).dxDataGrid('instance').repaint();
                    }
                    catch (e) {
                        console.log(e);
                    }
                };


                $(window).on('resize', function () {
                    scope.setInvoiceGridHeight();
                });
            }//# end of link
        };
    }
]);