invoice-manage-map.js 2.2 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
invoiceModule.directive('invoiceManageMap', ['$log', 'SweetAlert', '$translate',
    function ($log, SweetAlert, $translate) {
        'use strict';
        $log.debug('invoiceManageMap.ctor()...');

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

            },
            controller: 'invoiceManageMapController',
            link: function (scope, element) {
                //计算datagrid的高度
                scope.setInvoiceGridHeight = function () {
                    var invoiceDataGridSelector = '#invoiceManageMapList';
                    var pageWrapSelector = ".invoice-manage-map";
                    var queryCondition = '.invoice-manage-map .query-condition-wrapper';
                    var contentbody = '.invoice-manage-map .search-result-wrapper';
                    var buttonRow = '.invoice-manage-map .operation-btn-row';
                    var pageFooter = '.invoice-manage-map .page-footer';
                    var dxGridSelector = ".invoice-manage-map .gridContainer";

                    var pageHeight = $(document).height();
                    var queryConditionHeight = $(queryCondition).outerHeight();

                    var buttonRowHeight = $(buttonRow).outerHeight();
                    var pageFooterHeight = $(pageFooter).outerHeight();

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

                    try {
                        $(invoiceDataGridSelector).dxDataGrid('instance').repaint();
                    }
                    catch (e) {
                        console.log(e);
                    }
                };


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