280 lines
11 KiB
JavaScript
280 lines
11 KiB
JavaScript
define(["moment"], function (moment) {
|
||
return ["$scope", "$filter", "$stateParams", "$translate", "$mdDialog", "config", "$locale", "MMWService", 'RouterExtendProvider', "$rootScope",
|
||
function ($scope, $filter, $stateParams, $translate, $mdDialog, config, $locale, $MMWService, $RouterExtendProvider, $rootScope) {
|
||
|
||
$scope.parent = $stateParams.parent;
|
||
$scope.Page_from_login = false;
|
||
var defaultUse = $scope.currentUse = $translate.use(), defaultConfig;
|
||
var langList = [];
|
||
|
||
$rootScope.menu_hidden = true;
|
||
|
||
//20201023 雋辰,新增WS設定
|
||
$scope.showWS = false;
|
||
var showWSClickCount = 0;
|
||
|
||
//20201125 雋辰,新增選擇DNS/IP
|
||
$scope.DNSMode = config.setting.DNSMode ? config.setting.DNSMode : false;
|
||
$scope.DNS = config.server.DNS;
|
||
|
||
$scope.init = function () {
|
||
try {
|
||
$scope.$root.hideMenu();
|
||
//StatusBar.backgroundColorByHexString("#334199");
|
||
} catch (e) { }
|
||
$scope.clientIp = config.client.ip.split('.');
|
||
$scope.clientMask = config.client.mask.split('.');
|
||
$scope.clientGateway = config.client.gateway.split('.');
|
||
$scope.serverIp = config.server.ip.split('.');
|
||
//$scope.serverEAIIp = config.server.ip.split('.');
|
||
defaultConfig = angular.merge({}, config);//copy
|
||
$scope.config = angular.merge({}, config);//copy
|
||
|
||
//2019.07.11 By OwenLiu, 修正關閉KMI後無法將已儲存的設定值回存給控制項的問題
|
||
// 作業資料設定方式,報工模式
|
||
$scope.opdatasetting = config.setting.opdatasetting;
|
||
$scope.postingmode = config.setting.postingmode;
|
||
|
||
if (config.langList) {
|
||
|
||
} else {
|
||
langList = [
|
||
{ code: 'zh_TW', label: $filter('translate')('Setting.zh_TW') },
|
||
{ code: 'zh_CN', label: $filter('translate')('Setting.zh_CN') },
|
||
{ code: 'en_US', label: $filter('translate')('Setting.en_US') },
|
||
{ code: 'vi_VN', label: $filter('translate')('Setting.vi_VN') }
|
||
];
|
||
}
|
||
|
||
if ($scope.parent == 'login') {
|
||
$scope.Page_from_login = true;
|
||
}
|
||
|
||
}
|
||
|
||
$scope.back = function () {
|
||
if (defaultUse != $scope.currentUse) {
|
||
$scope.currentUse = defaultUse;
|
||
$translate.use(defaultUse);
|
||
}
|
||
if ($scope.parent == 'home') {
|
||
//當按下返回時候將cache回壓,cache才是真正使用的內容
|
||
config.setting.workStation = config.cache.workStation;
|
||
config.setting.equipment = config.cache.equipment;
|
||
}
|
||
$scope.$root.changeProgram($scope.parent, true);
|
||
|
||
}
|
||
|
||
$scope.confirm = function (feedback) {
|
||
if (config.setting.RefreshTime <= 0) {
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.RefreshTimeZero'));
|
||
return;
|
||
}
|
||
|
||
//config = $scope.config;
|
||
config.server = $scope.config.server;
|
||
config.server.ip = combineIP($scope.serverIp);
|
||
//20201125 雋辰,新增選擇DNS/IP
|
||
config.server.DNS = $scope.DNS;
|
||
//config.server.eaiip = combineIP($scope.serverIp);
|
||
|
||
config.client.ip = combineIP($scope.clientIp);
|
||
config.client.mask = combineIP($scope.clientMask);
|
||
config.client.gateway = combineIP($scope.clientGateway);
|
||
config.setting = $scope.config.setting;
|
||
config.setting.lang = $scope.currentUse;
|
||
//2019/06/25 Eric
|
||
config.setting.opdatasetting = $scope.opdatasetting;
|
||
config.cache.opdatasetting = $scope.opdatasetting;
|
||
config.setting.postingmode = $scope.postingmode;
|
||
config.cache.postingmode = $scope.postingmode;
|
||
|
||
//20200825 雋辰,新增裝置名稱
|
||
config.setting.deviceName = $scope.config.setting.deviceName;
|
||
|
||
//20201125 雋辰,新增選擇DNS/IP
|
||
config.setting.DNSMode = $scope.DNSMode;
|
||
|
||
//20201023 雋辰,新增WS設定
|
||
//20220419 13871,增加sc設定
|
||
config.serverList.Production.name = $scope.config.serverList.Production.name
|
||
config.serverList.Production.eainame = $scope.config.serverList.Production.eainame;
|
||
config.serverList.Production.scname = $scope.config.serverList.Production.scname;
|
||
config.serverList.Test.name = $scope.config.serverList.Test.name;
|
||
config.serverList.Test.eainame = $scope.config.serverList.Test.eainame;
|
||
config.serverList.Test.scname = $scope.config.serverList.Test.scname;
|
||
config.server.name = $scope.config.serverList[config.setting.environment].name;
|
||
config.server.eainame = $scope.config.serverList[config.setting.environment].eainame;
|
||
config.server.scname = $scope.config.serverList[config.setting.environment].scname;
|
||
|
||
//20170608 modify by Dustdusk for 將公司別放入environment,後台才能成功取到
|
||
//config.setting.environment = $scope.config.setting.companyId;
|
||
if (typeof (Storage) !== "undefined") {
|
||
//20201023 雋辰,新增WS設定
|
||
localStorage.setItem(config.appName + "_serverList", JSON.stringify(config.serverList));
|
||
|
||
localStorage.setItem(config.appName + "_server", JSON.stringify(config.server));
|
||
localStorage.setItem(config.appName + "_setting", JSON.stringify(config.setting));
|
||
//localStorage.setItem(config.appName + "_lang", $scope.currentUse);
|
||
}
|
||
|
||
fullScreen();
|
||
if (feedback) {
|
||
feedback();
|
||
} else {
|
||
|
||
|
||
if ($scope.parent !== 'login') {
|
||
if (config.cache.dashboard == "eqp") {
|
||
$RouterExtendProvider.goToProgram($rootScope.modules[1].childs[0]);
|
||
}
|
||
else {
|
||
$RouterExtendProvider.goToProgram($rootScope.modules[1].childs[1]);
|
||
}
|
||
|
||
}
|
||
else {
|
||
$scope.$root.changeProgram($scope.parent, true);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
//20201023 雋辰,顯示/隱藏WS設定
|
||
$scope.showWSClick = function () {
|
||
showWSClickCount++;
|
||
if (showWSClickCount >= 5) {
|
||
showWSClickCount = 0;
|
||
$scope.showWS = !$scope.showWS;
|
||
}
|
||
}
|
||
|
||
function combineIP(array) {
|
||
var totalip;
|
||
array.forEach(function (ipstring) {
|
||
if (!totalip)
|
||
totalip = ipstring;
|
||
else
|
||
totalip += "." + ipstring;
|
||
});
|
||
return totalip;
|
||
}
|
||
|
||
//載入語系清單
|
||
$scope.loadLoaclizationList = function () {
|
||
|
||
langList = [];
|
||
config.langList.forEach(function (lang) {
|
||
langList.push({ code: lang, label: $filter('translate')('Setting.' + lang) });
|
||
})
|
||
$scope.$root.showSelect({
|
||
title: $filter('translate')('Setting.localizationList'),
|
||
label: 'label',
|
||
code: 'code',
|
||
selectCode: $scope.currentUse,
|
||
list: langList,
|
||
confirm: function (item, dialog) {
|
||
$translate.use(item.code);
|
||
$locale.id = "en-US";
|
||
$scope.$root.lang = $scope.currentUse = item.code;
|
||
dialog.hide();
|
||
}
|
||
});
|
||
}
|
||
|
||
//TODO:調整URI及回傳後的內容
|
||
//20170221 add by Dustdusk for mantis#35545:
|
||
//2019.04.22 by owenliu, MESws_STD標準測試連線函式
|
||
$scope.connectionTest = function () {
|
||
$MMWService.sendToMESSrv_plain({
|
||
uri: 'iMESUserManager.clsUSRSecurity.Test_Connection',
|
||
content: {
|
||
userno: 'IMES'
|
||
},
|
||
success: function (data) {
|
||
//data = JSON.parse(data.ResultJson);
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.sucess') + "<br>" + data.message);
|
||
},
|
||
error: function (data) {
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.exception);
|
||
}
|
||
});
|
||
}
|
||
|
||
//2019.06.25 by owenliu, MESws_STD標準呼叫Load SingleTable函式
|
||
$scope.TestInvoke = function () {
|
||
$MMWService.sendToMESSrv({
|
||
uri: 'kcSYS.clsSYSParameter.LoadParameter',
|
||
content: {
|
||
userno: 'IMES'
|
||
},
|
||
//invoketype>> 0:Load, 1:Add, 2:Edit, 3:Delete, 4:Get
|
||
invoketype: 0,
|
||
success: function (data) {
|
||
//data = JSON.parse(data.ResultJson);
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.sucess') + "<br>" + data.Message);
|
||
},
|
||
error: function (data) {
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.connect.failure') + "<br>" + data.Exception);
|
||
}
|
||
});
|
||
}
|
||
//2019.04.22 by owenliu, MESws_STD 檢查KMI版本方式
|
||
$scope.checkUpdate = function () {
|
||
config.server = angular.merge({}, $scope.config.server);//copy
|
||
config.server.ip = combineIP($scope.serverIp);
|
||
//config.server.eaiip = combineIP($scope.serverEAIIp);
|
||
|
||
$MMWService.sendToMESSrv_plain({
|
||
uri: 'tcMES_LiveUpdate.clsLiveUpdate.LiveUpdate',
|
||
content: {
|
||
applicationId: config.applicationId
|
||
},
|
||
success: function (data) {
|
||
data = JSON.parse(data.ResultJson);
|
||
config.server = angular.merge({}, defaultConfig.server);//copy
|
||
if (data.Result != 'fail') {
|
||
if (data.version == config.appVersion || data.version == '0.0.0.0' || data.version == '') {
|
||
//不用更新
|
||
$scope.$root.showAlert($filter('translate')('Setting.msg.dont_need.update').replace('{0}', config.appVersion));
|
||
} else {
|
||
//需要更新
|
||
$scope.$root.showConfirm($filter('translate')('Setting.msg.need.update').replace('{0}', data.version), function () {
|
||
$scope.confirm(function () {
|
||
document.location.href = 'startup.html';
|
||
});
|
||
});
|
||
}
|
||
} else {
|
||
$rootScope.showAlert(data.SysMsg);
|
||
}
|
||
}
|
||
});
|
||
};
|
||
|
||
$scope.$on('$stateChangeStart', function (event) {
|
||
$rootScope.menu_hidden = false;
|
||
});
|
||
|
||
function fullScreen() {
|
||
if (window.nodeRequire) {
|
||
try {
|
||
const remote = nodeRequire('electron').remote;
|
||
var version = remote.app.getVersion();
|
||
if (version != '1.1.2') {
|
||
win = remote.getCurrentWindow();
|
||
if (config.setting.fullScreen == 'Y') {
|
||
win.setFullScreen(true);
|
||
} else {
|
||
win.width = 1024;
|
||
win.height = 600;
|
||
win.setFullScreen(false);
|
||
}
|
||
}
|
||
} catch (e) { }
|
||
}
|
||
}
|
||
}];
|
||
});
|