angular.module('nurseApp').controller('interfaceConfigCtrl',['$scope','$rootScope','$modal','balert','uploadService','ImageManageService','userService',function($scope,$rootScope,$modal,balert,uploadService,ImageManageService,userService){ //region 新界面设置 //author:xie //views:interfaceConfig.html //date:2021-12-2 $scope.userView = {} $scope.sysLogoSet = {} $scope.LoginLogoSet = {} userService.findInterfaceConfig().then(function (data) { $scope.userView = data; if($scope.userView.SystemLogoWidth && $scope.userView.SystemLogoHeight){ $scope.sysLogoSet.edit = true $scope.sysLogoSet.width = parseInt($scope.userView.SystemLogoWidth) $scope.sysLogoSet.height = parseInt($scope.userView.SystemLogoHeight) } if($scope.userView.LoginLogoWidth && $scope.userView.LoginLogoHeight){ $scope.LoginLogoSet.edit = true $scope.LoginLogoSet.width = parseInt($scope.userView.LoginLogoWidth) $scope.LoginLogoSet.height = parseInt($scope.userView.LoginLogoHeight) } }); $scope.setSysLogoSize = function(){ if(!$scope.sysLogoSet.edit) return if($scope.sysLogoSet.width && $scope.sysLogoSet.height) return var LogoSize = getImgSize($scope.userView.LogoImage) $scope.sysLogoSet.width = LogoSize.width $scope.sysLogoSet.height = LogoSize.height } $scope.setLoginLogoSize = function(){ if(!$scope.LoginLogoSet.edit) return if($scope.LoginLogoSet.width&& $scope.LoginLogoSet.height) return var LogoSize = getImgSize($scope.userView.LoginLogoImage) $scope.LoginLogoSet.width = LogoSize.width $scope.LoginLogoSet.height = LogoSize.height } function getImgSize(img){ var imgSize = { width:'', height:'' } var imgFile = new Image(); imgFile.src = img; imgSize.width = imgFile.width imgSize.height = imgFile.height return imgSize } var showImgFileDlg = $modal({ scope: $scope, templateUrl: 'partials/showImgFile.html', show: false }); $scope.$on("fileSelected", function (event, msg) { $scope.imgFile = msg; }); // 上传 - 上传图片 $scope.uploadImages = function () { $scope.loading=true; if ($scope.imgFile == undefined) { balert.show('danger', $scope.languageJson.Configuration.ImageControl.UploadError, 3000); return; } uploadService.uploadFile($scope.imgFile).then(function (data) { $scope.loading=false; balert.show('success', "上传成功", 3000); }); }; //选择图片 start $scope.showImgFile = function (index) { $scope.imgFiles = { catalog: "img/diagram", imageFile: undefined, index:index }; showImgFileDlg.$promise.then(showImgFileDlg.show); $scope.changeCatalog($scope.imgFiles.catalog); }; $scope.changeCatalog = function (catalog) { ImageManageService.LoadImagesByPath(catalog).then(function (data) { $scope.ImageFiles = data; }); }; $scope.clickImage = function (imageFile, $event) { $scope.imgFiles.imageFile = imageFile; $($event.currentTarget).parent().find('div').removeClass("select-image"); $($event.currentTarget).addClass("select-image"); }; $scope.selectImageFile = function () { if ($scope.imgFiles == undefined || $scope.imgFiles.imageFile == undefined) { balert.show('danger', $scope.languageJson.Configuration.LocalImage.SelectError, 3000);//'请选择图片。' return; } switch ($scope.imgFiles.index) { case 1: $scope.userView.LogoImage= $scope.imgFiles.imageFile; $scope.sysLogoSet = {} break; case 2: $scope.userView.LoginLogoImage = $scope.imgFiles.imageFile; $scope.LoginLogoSet = {} break; case 3: $scope.userView.LoginBG = $scope.imgFiles.imageFile; break; case 4: $scope.userView.SystemBG = $scope.imgFiles.imageFile; break; default: break; } showImgFileDlg.hide(); }; $scope.editInterfaceConfig = function () { var defaultLogoStyle = {} var version = localStorage.getItem("versions"); if(version == "IView"){ defaultLogoStyle = { "min-width": 'auto', "max-width": '400px', "min-height": 'auto', "max-height": '88px' } }else{ defaultLogoStyle = { "min-width": '80px', "max-width": '80%', "min-height": '100px', "max-height": '120px' } } if($scope.LoginLogoSet.edit){ if($scope.LoginLogoSet.width>0 && $scope.LoginLogoSet.height>0){ $scope.userView.LoginLogoStyle = angular.toJson({ width:$scope.LoginLogoSet.width+'px', height:$scope.LoginLogoSet.height+'px', "min-height": "auto", "max-height": "none", "max-width": "none", "min-width": "auto" }) }else{ balert.show("danger", $scope.languageJson.Header.User.Interface.editSizeErr, 3000);//自定义宽高应大于0! return } }else{ $scope.userView.LoginLogoStyle = angular.toJson(defaultLogoStyle) } if($scope.sysLogoSet.edit){ if($scope.sysLogoSet.width>0 && $scope.sysLogoSet.height>0){ $scope.userView.SystemLogoStyle= angular.toJson({ width:$scope.sysLogoSet.width+'px', height:$scope.sysLogoSet.height+'px', "min-height": "auto", "max-height": "none", "max-width": "none", "min-width": "auto" }) }else{ balert.show("danger", $scope.languageJson.Header.User.Interface.editSizeErr, 3000);//自定义宽高应大于0! return } }else{ $scope.userView.SystemLogoStyle = angular.toJson(defaultLogoStyle) } // $scope.loading=true userService.editInterfaceConfig($scope.userView).then(function (data) { if (data == "OK") { userService.findInterfaceConfig().then(function (data) { $rootScope.user = data; // $rootScope.initSysView() window.location.reload(true); }); $scope.loading=false; balert.show("success", $scope.languageJson.Header.User.Interface.Succeed, 3000);//设置成功 } else { balert.show("danger", $scope.languageJson.Header.User.Interface.Error, 3000);//设置失败 } }); }; //endregion // ********************** 新界面设置 end************************ }])