rule-enginee-infrastructure.ctrl.js 4.65 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
systemConfigurationModule
    .controller('ruleEngineeInfrastructureController', ['$scope', '$log', 'SweetAlert', 'organizationStructureService', '$translate', 'businessUnitService', 'customerService',
        function ($scope, $log, SweetAlert, organizationStructureService, $translate, businessUnitService, customerService) {
            'use strict';

            var successAddMessage = $translate.instant('OrganizationStructureAddSuccess');
            var successEditMessage = $translate.instant('OrganizationStructureEditSuccess');
            var successDeleteMessage = $translate.instant('OrganizationStructureDeleteSuccess');
            var operationDeleteMessage = $translate.instant('OrganizationStructureOperationSuccess');
            var notAllowDisableMessage = $translate.instant('notAllowDisableMessage');


            $scope.add = function (newrow) {

                organizationStructureService.addOrganizationStructure(newrow).success(function (guid) {
                    SweetAlert.success(successAddMessage);
                });
            };

            $scope.edit = function (newcontent) {
                organizationStructureService.updateOrganizationStructure(newcontent).success(function (guid) {
                    SweetAlert.success(successEditMessage);
                });
            };

            $scope.remove = function (id) {
                organizationStructureService.deleteOrganizationStructure(id).success(function (guid) {
                    SweetAlert.success(successDeleteMessage);
                });
            };

            $scope.stop = function (id) {
                organizationStructureService.updateOrganizationStructure(id).success(function (successFlag) {
                    $scope.updateflag = successFlag;
                    $scope.$broadcast('to-child', successFlag);
                    if (successFlag) {
                        SweetAlert.success(operationDeleteMessage);
                    } else {
                        SweetAlert.warning(notAllowDisableMessage);
                    }
                });
            };

            //BusinessUnit
            $scope.addbs = function (newrow) {

                businessUnitService.addBusinessUnit(newrow).success(function (guid) {
                    SweetAlert.success(successAddMessage);
                });
            };

            $scope.editbs = function (newcontent) {
                businessUnitService.updateBusinessUnit(newcontent).success(function (guid) {
                    SweetAlert.success(successEditMessage);
                });
            };

            $scope.removebs = function (id) {
                businessUnitService.deleteBusinessUnit(id).success(function (guid) {
                    SweetAlert.success(successDeleteMessage);
                });
            };

            $scope.stopbs = function (id) {
                businessUnitService.updateBusinessUnit(id).success(function (successFlag) {
                    $scope.updateflag = successFlag;
                    $scope.$broadcast('to-child', successFlag);
                    if (successFlag) {
                        SweetAlert.success(operationDeleteMessage);
                    } else {
                        SweetAlert.warning(notAllowDisableMessage);
                    }
                });
            };

            $scope.showOperateLogPop = function () {
                $scope.isShowLog = true;
                // $('#showOperatePop').modal('show');
            };

            var getUserPermission = function () {

                var list = [];

                var basicData = constant.adminPermission.basicData;
                list.push(basicData.orangizationStructure.queryCode);
                list.push(basicData.businessUnit.queryCode);
                list.push(basicData.areaManage.queryCode);
                list.push(basicData.enterpriseAccountSet.queryCode);
                list.push(basicData.customerList.queryCode);

                $scope.$root.checkUserPermissionList(list).success(function (data) {

                    $scope.orangizationStructureShow = data[basicData.orangizationStructure.queryCode];
                    $scope.businessUnitShow = data[basicData.businessUnit.queryCode];
                    $scope.areaManageShow = data[basicData.areaManage.queryCode];
                    $scope.enterpriseAccountSetShow = data[basicData.enterpriseAccountSet.queryCode];
                    $scope.customerListShow = data[basicData.customerList.queryCode];

                });
            };

            (function initialize() {
                $log.debug('ruleEngineInfrastructureController.ctor()...');

                //getUserPermission();

            })();
        }
    ]);