emsApplication/applications/WebConfigure/web/js/script/intervalClearDataCtrl.js

174 lines
8.2 KiB
JavaScript
Raw Permalink Normal View History

2024-05-24 12:19:45 +08:00
angular.module('nurseApp').controller('intervalClearDataCtrl',['$scope', '$modal', 'balert', 'HistoryDataClear',
function($scope, $modal, balert, HistoryDataClear){
(function(){
HistoryDataClear.GetAllIntervalClearData().then(function (data) {
$scope.ClearTasks = parseClearData(data);
});
})();
function parseClearData(data) {
var miss = $scope.languageJson.MissionName.Mission;
data.forEach(function (item) {
if (item.status == 0)
item.statusName = miss.Close;/*"关闭"*/
else
item.statusName = miss.Start;/*"启动"*/
if (item.type == "DB") item.typeName = miss.DB;
else if (item.type == "LOG") item.typeName = miss.Log;
else if (item.type == "FILE_SIZE") item.typeName = miss.FileSize;
else if (item.type == "FILE_PERIOD") item.typeName = miss.FilePeriod;
});
return data;
};
//#region 新增/修改 定时任务
var historyDataInfoDlg = $modal({
scope: $scope,
templateUrl: 'partials/historyDataInfo.html',
show: false
});
$scope.addClearTasksClk = function () {
$scope.ClearTaskTitle = $scope.languageJson.MissionName.Add;
$scope.ClearTask = {
name: "", type: "DB", clearObject: "", delay: 86400,
period: 86400, storageDays: 30, storageCols: "",
storagePath: "", storagePers: "", storageSize: "",
status: 1, otherParam: ""
};/*'新增'*/
historyDataInfoDlg.$promise.then(historyDataInfoDlg.show);
};
$scope.updClearTasksClk = function (data) {
$scope.ClearTaskTitle = $scope.languageJson.MissionName.Modify;
$scope.ClearTask = data;
historyDataInfoDlg.$promise.then(historyDataInfoDlg.show);
};
$scope.saveClearTaskClk = function () {
if(!inputValidation($scope.ClearTask)) return;
/*"新增"*/
if ($scope.ClearTaskTitle == $scope.languageJson.MissionName.Add) {
HistoryDataClear.InsertIntervalClearData($scope.ClearTask).then(function (data) {
if (data == "OK") {
balert.show('success', $scope.languageJson.Task.New.Newly, 3000);/*'新增成功,生效需要重启系统!'*/
historyDataInfoDlg.hide();
HistoryDataClear.GetAllIntervalClearData().then(function (data) {
$scope.ClearTasks = parseClearData(data);
});
} else
balert.show('danger', $scope.languageJson.Task.New.Title, 3000);/*'新增失败!'*/
});
} else {
HistoryDataClear.UpdateIntervalClearData($scope.ClearTask).then(function (data) {
if (data == "OK") {
balert.show('success', $scope.languageJson.Task.New.Modification, 3000);/*'修改成功,生效需要重启系统!'*/
historyDataInfoDlg.hide();
HistoryDataClear.GetAllIntervalClearData().then(function (data) {
$scope.ClearTasks = parseClearData(data);
});
} else
balert.show('danger', $scope.languageJson.Task.New.Fail, 3000);/*'修改失败!'*/
});
}
};
function inputValidation(item){
if (item.name == undefined || item.name == "") {
balert.show('danger', $scope.languageJson.Task.Title, 3000);/*'任务名称不能为空,请重新输入!'*/
return false;
}
if (item.clearObject == undefined || item.clearObject == "") {
balert.show('danger', $scope.languageJson.Task.Cleanup, 3000);/*'清理对象不能为空,请重新输入!'*/
return false;
}
if (item.delay == undefined || item.delay == "") {
balert.show('danger', $scope.languageJson.Task.Empty, 3000);/*'任务延时不能为空,请重新输入!'*/
return false;
}
if (item.period == undefined || item.period == "") {
balert.show('danger', $scope.languageJson.Task.Period, 3000);/*'定时周期不能为空,请重新输入!'*/
return false;
}
if(item.type == "DB" || item.type == "FILE_PERIOD"){
if ($scope.ClearTask.storageDays == undefined || $scope.ClearTask.storageDays == "") {
balert.show('danger', $scope.languageJson.Task.Storage, 3000);/*'存储天数不能为空,请重新输入!'*/
return false;
}
}
if(item.type == "DB"){
if ($scope.ClearTask.storageCols == undefined || $scope.ClearTask.storageCols == "") {
balert.show('danger', $scope.languageJson.Task.Associated, 3000);/*'关联列不能为空,请重新输入!'*/
return false;
}
}
if(item.type != "DB"){
if ($scope.ClearTask.storagePath == undefined || $scope.ClearTask.storagePath == "") {
balert.show('danger', $scope.languageJson.Task.NotStoragePath, 3000);/*'存储目录不能为空,请重新输入!'*/
return false;
}
}
if(item.type == "FILE_SIZE"){
if ($scope.ClearTask.storagePers == undefined || $scope.ClearTask.storagePers == "") {
balert.show('danger', $scope.languageJson.Task.NotStoragePers, 3000);/*'存储百分比不能为空,请重新输入!'*/
return false;
}
if ($scope.ClearTask.storageSize == undefined || $scope.ClearTask.storageSize == "") {
balert.show('danger', $scope.languageJson.Task.NotStorageSize, 3000);/*'存储大小不能为空,请重新输入!'*/
return false;
}
}
return true;
}
//#endregion
//#region 删除
var confirmBoxDlg = $modal({
scope: $scope,
templateUrl: 'partials/confirmBox.html',
show: false
});
$scope.delClearTasksClk = function (id) {
$scope.message = $scope.languageJson.Task.Confirm;/*"确定删除吗?"*/
confirmBoxDlg.$promise.then(confirmBoxDlg.show);
$scope.ok = function () {
HistoryDataClear.DeleteIntervalClearData(id).then(function (data) {
if (data == "OK") {
balert.show('success', $scope.languageJson.Task.New.System, 3000);/*'删除成功,生效需要重启系统!'*/
confirmBoxDlg.hide();
HistoryDataClear.GetAllIntervalClearData().then(function (data) {
$scope.ClearTasks = parseClearData(data);
});
} else
balert.show('danger', $scope.languageJson.Task.New.Delete, 3000);/*'删除失败!'*/
});
}
$scope.cancel = function () {
confirmBoxDlg.hide();
}
};
//#endregion
//#region 清空
$scope.emptyClearTasksClk = function(id){
$scope.message = $scope.languageJson.Task.Empty2;/*"确定清空数据吗?"*/
confirmBoxDlg.$promise.then(confirmBoxDlg.show);
$scope.ok = function () {
HistoryDataClear.EmptyIntervalClearData(id).then(function (data) {
if (data == "OK") {
balert.show('success', $scope.languageJson.Task.New.System2, 3000);/*'清空成功!'*/
confirmBoxDlg.hide();
} else
balert.show('danger', $scope.languageJson.Task.New.Delete2, 3000);/*'清空失败!'*/
});
}
$scope.cancel = function () {
confirmBoxDlg.hide();
}
};
//#endregion
}
]);