117 lines
3.4 KiB
Plaintext
117 lines
3.4 KiB
Plaintext
function ENDR900Controller($scope, $log, $location, commonFactory) {
|
|
|
|
init();
|
|
|
|
function init() {
|
|
$scope.onSearch = false;
|
|
$scope.searchFlag = '0';
|
|
|
|
//for pagination
|
|
$scope.perPages = 20;
|
|
$scope.maxSize = 10;
|
|
|
|
$scope.schForm = {};
|
|
$scope.resultList = [];
|
|
|
|
|
|
clearRequired();
|
|
}
|
|
|
|
$scope.doSearch = function () {
|
|
if (dateRequired()) {
|
|
// alert("dateRequired");
|
|
return;
|
|
}
|
|
|
|
$scope.searchFlag = '1';
|
|
$scope.onSearch = true;
|
|
try {
|
|
var actLoadData = $.ajax(doGetPath('/json/ENDR900SchData.json'),
|
|
{
|
|
ajax: true,
|
|
dataType: 'json',
|
|
type: "POST",
|
|
data: {
|
|
schFormParam: JSON.stringify($scope.schForm)
|
|
}
|
|
}).error(
|
|
function (data) {
|
|
alert("Session Time Out!!!");
|
|
// $location.path("/");
|
|
$scope.$apply();
|
|
});
|
|
|
|
actLoadData.success(
|
|
function (data) {
|
|
// console.log(JSON.stringify(data));
|
|
var dbError = data[0];
|
|
if (dbError.errorFlag == 1) {
|
|
$scope.onSearch = false;
|
|
var retDialog1 = commonFactory.doOpenMsg(dbError);
|
|
retDialog1.then((function (returnData) {
|
|
//alert("1");
|
|
}), function () {
|
|
//dismissed
|
|
});
|
|
} else {
|
|
angular.copy(data[1], $scope.resultList);
|
|
// console.log(JSON.stringify( $scope.resultList));
|
|
// page
|
|
setPaging($scope.resultList);
|
|
$scope.onSearch = false;
|
|
}
|
|
$scope.$apply();
|
|
}
|
|
);
|
|
} catch (e) {
|
|
//
|
|
}
|
|
};
|
|
|
|
|
|
function setPaging(dataLst) {
|
|
$scope.totalItems1 = dataLst.length;
|
|
$scope.currentPage1 = 1;
|
|
$scope.numPages1 = Math.ceil($scope.totalItems1 / $scope.perPages);
|
|
$scope.$apply();
|
|
}
|
|
|
|
|
|
function dateRequired() {
|
|
clearRequired();
|
|
var isRequired = false;
|
|
if (!isEmpty($scope.schForm.createddateFrom) && isEmpty($scope.schForm.createddateTo)) {
|
|
$scope.createdDateToRequired = true;
|
|
isRequired = true;
|
|
}
|
|
|
|
if (isEmpty($scope.schForm.createddateFrom) && !isEmpty($scope.schForm.createddateTo)) {
|
|
$scope.createdDateFromRequired = true;
|
|
isRequired = true;
|
|
}
|
|
|
|
if (!isEmpty($scope.schForm.enddateFrom) && isEmpty($scope.schForm.enddateTo)) {
|
|
$scope.enddateToRequired = true;
|
|
isRequired = true;
|
|
}
|
|
|
|
if (isEmpty($scope.schForm.enddateFrom) && !isEmpty($scope.schForm.enddateTo)) {
|
|
$scope.enddateFromRequired = true;
|
|
isRequired = true;
|
|
}
|
|
return isRequired;
|
|
}
|
|
|
|
function isEmpty(value) {
|
|
return (value == null || value.length === 0);
|
|
}
|
|
|
|
function clearRequired() {
|
|
$scope.createdDateFromRequired = false;
|
|
$scope.createdDateToRequired = false;
|
|
$scope.enddateFromRequired = false;
|
|
$scope.enddateToRequired = false;
|
|
}
|
|
|
|
|
|
} |