nav-bar.ctrl.js 15.9 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

vatDongfengModule.controller('navBarController', ['$scope', '$rootScope', '$log', '$timeout', '$state', '$translate', 'projectService', 'SweetAlert', 'loginContext', 'vatSessionService', 'vatCommonService', 'application', 'enums', '$uibModal',
    function ($scope, $rootScope, $log, $timeout, $state, $translate, projectService, SweetAlert, loginContext, vatSessionService, vatCommonService, application, enums, $uibModal) {
        'use strict';
        $log.debug('navBarController.ctor()...');
        var baseDFFilePath = '/app/df/code/pages/';

        $scope.dateFormat = $translate.instant('dateFormat4YearMonth');
        $scope.showSubMenu = true;
        if (vatSessionService.project.name) {
            $scope.projectName = vatSessionService.project.name;
        } else {
            $scope.projectName = "普华永道上海税务(a1700000)";
        }

        $('#year').datepicker({
            format: 'yyyy年',
            weekStart: 1,
            autoclose: true,
            startView: 2,
            maxViewMode: 2,
            minViewMode: 2,
            forceParse: false,
            language: 'zh-CN'
        });

        $scope.selectedDate = new Date(vatSessionService.project.year, vatSessionService.month - 1, 1);
        $scope.startDate = new Date(vatSessionService.project.year, 0, 1);
        $scope.endDate = new Date(vatSessionService.project.year, 11, 31, 23, 59, 59);

        var subStatusDto = {
            dispalyIndex: -1,
            name: '',
            isImported: false
        };

        var msgboxOptions = {
            title: $translate.instant('UnsavedChange'),
            text: $translate.instant('ComfirmIgnoreUnsavedChanges'),
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#e0301e",
            confirmButtonText: $translate.instant('ConfirmYes'),
            cancelButtonText: $translate.instant('ConfirmNo'),
            closeOnConfirm: true,
            closeOnCancel: true
        };

        $scope.changeDate = function () { };

        var dongfengGoUrl = function (src) {
            $log.debug('new page src:' + src);
            $('#dfiframe').attr("src", src);
        };

        $scope.uiHandling = function (menu) {

            $scope.selectedMenu = menu;
            $log.debug(menu);
            if ($scope.type === 1) {//递延所得税
                $scope.submenus = [
                    { text: '构成分析', title: "构成分析", src: '/app/df/code/pages/DFModleIndex.html' + '?_=' + Math.random(), icon: 'fa fa-bank' },
                    { text: '对未来现金流的影响分析', title: "对未来现金流的影响分析", src: '/app/df/code/pages/DFModleIndex2.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' },
                    { name: '变动分析', title: "变动分析", text: "变动分析", src: '/app/df/code/pages/DFModleIndex3.html' + '?_=' + Math.random(), icon: 'fa fa-list-ul' },
                    { name: '对当期利润的影响分析模型', title: "对当期利润的影响分析模型", permission: '02.001.009', text: "对当期利润的影响分析模型", icon: 'fa fa-file-text-o' }
                ];
                if (menu.fileName.indexOf('deferredTaxNEWWorkingPaper.html') > -1) {
                    $scope.setFrameHeight();
                }
                dongfengGoUrl(baseDFFilePath + menu.fileName);

                if (menu.num === 3) {
                    //选中submenu的第一个默认
                    $scope.dongfengGo($scope.submenus[0]);
                }
            } else if ($scope.type === 2) {//现金流
                $scope.hideSubMenu = false;

                if (menu.name == "税务预算") {
                    $scope.submenus = [
                        { text: '数据状态', src: baseDFFilePath + menu.fileName, icon: 'fa fa-bank' },
                        { text: '数据上传', src: baseDFFilePath + 'DFTaxBudgetUpload.htm' + '?_=' + Math.random(), icon: 'fa fa-upload', clickId: 'clickDataUpload' },
                        { text: '地产数据', src: baseDFFilePath + 'DFRealEstateData.html' + '?_=' + Math.random(), icon: 'fa fa-university', clickId: 'realEstateData' },
                        { text: '数据计算', src: baseDFFilePath + 'DFTaxBudgetCaculateSummary.htm' + '?_=' + Math.random(), icon: 'fa fa-calculator', clickId: 'clickDataCalculate' },
                        { text: '数据预览', src: baseDFFilePath + 'DFTaxBudgetView.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' }
                    ];
                } else if (menu.name == "实交税额") {
                    $scope.submenus = [
                        { text: '数据状态', src: baseDFFilePath + menu.fileName, icon: 'fa fa-bank' },
                        { text: '数据处理', src: baseDFFilePath + "DFTaxPaymentProcess.html", icon: 'fa fa-cogs', clickId: 'taxPaymentProcess'  },
                        { text: '数据分析', src: baseDFFilePath + 'actualPayDashboard.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' },
                        { text: '数据预览', src: baseDFFilePath + 'DFTaxPaymentView.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' },
                    ];
                } else if (menu.name == "预实对比") {
                    $scope.submenus = [
                        { text: '数据处理', src: baseDFFilePath + "DFPreRealContrastProcess.html", icon: 'fa fa-cogs', clickId: 'taxPaymentProcess' },
                        { text: '数据分析', src: baseDFFilePath + 'DFPreRealContrastDashboard.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' },
                    ];
                }else if (menu.name == "税收返还") {
                    $scope.submenus = [
                        { text: '数据状态', src: baseDFFilePath + menu.fileName, icon: 'fa fa-bank' },
                        { text: '数据处理', src: baseDFFilePath + "DFTaxReturnProcess.html", icon: 'fa fa-cogs' },
                        { text: '数据预览', src: baseDFFilePath + 'DFTaxReturnView.html' + '?_=' + Math.random(), icon: 'fa fa-align-left' }];
                } else {
                    $scope.submenus = [{ text: '数据导入', src: baseDFFilePath + menu.fileName, icon: 'fa fa-bank' }];
                    $scope.hideSubMenu = true;
                }

                //if (menu.fileName) {
                $scope.dongfengGo($scope.submenus[0]);
                //}
            } else if ($scope.type === 3) { //数据统计
                
            }

        };

        var initMenu = function () {
            if ($scope.type === 1) { //递延所得税
                $('.vat-import-menu').show();
                $scope.serviceTitle = $translate.instant('DeferrIncomeTitle');
neo's avatar
neo committed
122 123
                $scope.menus = [
//                { name: '数据导入', num: 1, permission: '02.001', url: '#/vat/importData/balanceSheet', fileName: 'deferredTaxNEW.html' + '?_=' + Math.random() },
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
                { name: '数据核算', num: 2, permission: '02.002', url: '#/vat/previewData/balanceSheet', fileName: 'deferredTaxNEWWorkingPaper.html' + '?_=' + Math.random() },
                { name: '数据分析', num: 3, permission: '02.003', url: '#/vat/previewData/balanceSheet', fileName: 'DFModleIndex.html' + '?_=' + Math.random() },
                //{ name: '变动分析', num: 4, permission: '02.003', url: '#/vat/previewData/balanceSheet', fileName: 'DFModleIndex3.html' + '?_=' + Math.random() }
                ];
                //默认选中第一个
            } else if ($scope.type === 2) { //现金流
                $('.vat-import-menu').show();
                $scope.menus = [
                    { name: '税务预算', num: 1, permission: '02.001', url: '#', fileName: 'DFTaxActualStatus.html' + '?_=' + Math.random() },
                    { name: '实交税额', num: 2, permission: '02.002', url: '#', fileName: 'DFTaxPaymentStatus.html' + '?_=' + Math.random() },
                    { name: '预实对比', num: 3, permission: '02.003', url: '#', fileName: 'DFPreRealContrast.html' + '?_=' + Math.random() },
                    //{ name: '税额模拟', num: 4, permission: '02.004', url: '#', fileName: 'DFTaxAmountSimulation.html' + '?_=' + Math.random() },
                    { name: '税收返还', num: 4, permission: '02.005', url: '#', fileName: 'DFTaxReturnStatus.html' + '?_=' + Math.random() }
                ];
            } else if ($scope.type === 3) { //现金流 
                $('.vat-import-menu').hide();
                setTimeout(function(){
                    dongfengGoUrl(baseDFFilePath + 'DataSummary.html');
                },1000);
                return false;
            } else if ($scope.type === 4) { //现金流 
                $('.vat-import-menu').hide();
                setTimeout(function(){
                    dongfengGoUrl(baseDFFilePath + 'GlobalSearchResult.html');
                },1000);
                return false;
            }

            $scope.selectedMenu = $scope.menus[0];
            $timeout(function () {
                $scope.uiHandling($scope.menus[0]);
            }, 100);

            initTreeDrop();
        };

        $scope.orglist = [
             { "ID": 1, "name": "东风汽车有限公司", "expanded": true, "status": "已核算" },
             { "ID": "1_1", "categoryId": 1, "name": "东风汽车零部件(集团)有限公司", "expanded": true, "status": "未开始" },
             { "ID": "1_1_1", "categoryId": '1_1', "name": "东风贝洱热系统有限公司", "expanded": true, "status": "已导入" },
             { "ID": "1_1_2", "categoryId": '1_1', "name": "东风汽车紧固件有限公司", "expanded": true, "status": "已核算" },
             { "ID": "1_1_3", "categoryId": '1_1', "name": "上海弗列加滤清器有限公司", "expanded": true, "status": "已提交" },
             { "ID": "1_1_4", "categoryId": '1_1', "name": "东风精密铸造有限公司", "expanded": true, "status": "已分析" },
             { "ID": "1_2", "categoryId": 1, "name": "东风日产乘用车公司", "expanded": true, "status": "未开始" },
             { "ID": "1_2_1", "categoryId": '1_2', "name": "东风风神汽车有限公司", "expanded": true, "status": "已导入" },
             { "ID": "1_2_2", "categoryId": '1_2', "name": "东风日产发动机分公司", "expanded": true, "status": "已提交" },
             { "ID": "1_3", "categoryId": 1, "name": "东风汽车有限公司装备公司", "expanded": true, "status": "未开始" },
             { "ID": "1_4", "categoryId": 1, "name": "东风英菲尼迪有限公司", "expanded": true, "status": "未开始" },
        ];

        var initTreeDrop = function () {
            var dropDownTree = $("#org-treebox").dxDropDownBox({
                value: [1],
                valueExpr: "ID",
                displayExpr: "name",
                placeholder: "组织单元",
                showClearButton: true,
                dataSource: $scope.orglist,
                contentTemplate: function (e) {
                    var value = e.component.option("value"),
                        $treeView = $("<div>").dxTreeView({
                            dataSource: e.component.option("dataSource"),
                            dataStructure: "plain",
                            keyExpr: "ID",
                            parentIdExpr: "categoryId",
                            selectionMode: "single",
                            displayExpr: "name",
                            selectByClick: true,
                            onContentReady: function (args) {
                                syncTreeViewSelection(args.component, value);
                            },
                            selectNodesRecursive: false,
                            onItemSelectionChanged: function (args) {
                                var value = args.component.getSelectedNodesKeys();

                                e.component.option("value", value);
                                
                            }
                        });

                    treeView = $treeView.dxTreeView("instance");

                    e.component.on("valueChanged", function (args) {
                        var value = args.value;
                        syncTreeViewSelection(treeView, value);
                        dropDownTree.dxDropDownBox("instance").close();
                    });

                    return $treeView;
                }
            });

        };

        var showAccountingStatusModal = function () {
            var dropDownTree = $("#accounting-status-org-treebox").dxDropDownBox({
                value: [1],
                valueExpr: "ID",
                displayExpr: "name",
                placeholder: "组织单元",
                showClearButton: true,
                dataSource: $scope.orglist,
                contentTemplate: function (e) {
                    var value = e.component.option("value"),
                        $treeView = $("<div>").dxTreeView({
                            dataSource: e.component.option("dataSource"),
                            dataStructure: "plain",
                            keyExpr: "ID",
                            parentIdExpr: "categoryId",
                            selectionMode: "single",
                            displayExpr: "name",
                            selectByClick: true,
                            onContentReady: function (args) {
                                syncTreeViewSelection(args.component, value);
                            },
                            selectNodesRecursive: false,
                            onItemSelectionChanged: function (args) {
                                var value = args.component.getSelectedNodesKeys();

                                e.component.option("value", value);
                            }
                        });

                    accountingStatusTreeView = $treeView.dxTreeView("instance");

                    e.component.on("valueChanged", function (args) {
                        var value = args.value;
                        syncTreeViewSelection(accountingStatusTreeView, value);
                        dropDownTree.dxDropDownBox("instance").close();
                    });

                    return $treeView;
                }
            });
            $("#accountingStatusModal").modal('show');
        };

        var treeView, accountingStatusTreeView, dataGrid;
        var syncTreeViewSelection = function (treeView, value) {
            if (!value) {
                treeView.unselectAll();
                return;
            }

            value.forEach(function (key) {
                treeView.selectItem(key);
            });
        };

        $scope.$on(application.events.showSubMenu, function (event, data) {
            if (data) {
                $scope.showSubMenu = data.show;
            }
        });

        $scope.dongfengGo = function (menu) {
            parent.PWC.simulateProgress();
            $log.debug('new page src:' + menu.src);
            $scope.selectedSubMenu = menu;
            $('#dfiframe').attr("src", menu.src);
        };

        (function initialize() {
            $log.debug("nav-bar-crtl.js initialize() ");
            $scope.displaySubStatus = false;//导入子状态是否显示

            $rootScope.$on('statusChanged', function (event, args) {
                $log.debug("receive statusChanged");
                $log.debug(args.status);
                setLayoutStatusTitle(args.status);
            });

            if ($scope.type !== 5) {
                initMenu();
            }
            else {
                $timeout(function () {
                    $('#dfiframe').attr("src", '/app/df/code/pages/ETaxAudit.html');
                }, 500);
               
            }
            $scope.hideSubMenu = false;

            $timeout(function () {
                $scope.setFrameHeight();
            }, 500);
            
            $log.debug('dongfeng Type:' + $scope.type);

            $scope.showAccountingStatusModal = showAccountingStatusModal;
        })();
    }]);