Commit e783181f by NGUYEN HOANG SON

fix space of operationList js

parent 6e811ad3
...@@ -11,600 +11,600 @@ ...@@ -11,600 +11,600 @@
OL.operationGroupMaster; //category(operationGroupMaster) json data OL.operationGroupMaster; //category(operationGroupMaster) json data
OL.isOperationGroupMaster = 0; //0: category(operationGroupMaster) not exist 1: category(operationGroupMaster) exist OL.isOperationGroupMaster = 0; //0: category(operationGroupMaster) not exist 1: category(operationGroupMaster) exist
OL.sortIndex; OL.sortIndex;
OL.operationGroupMasterId; OL.operationGroupMasterId;
OL.REPORT_TYPE = { OL.REPORT_TYPE = {
REPORTONLY: 0, //report only REPORTONLY: 0, //report only
INSPECT: 1, //rountine INSPECT: 1, //rountine
WITHREPLY: 2, // report answer WITHREPLY: 2, // report answer
WORKFLOW: 3 // continuous WORKFLOW: 3 // continuous
} }
/** /**
* process on page load. * process on page load.
* 1.get all data. * 1.get all data.
* 2.show operationList. * 2.show operationList.
* 3.show category(operationGroupMaster). * 3.show category(operationGroupMaster).
*/ */
OL.init = function () { OL.init = function () {
console.log('OperationList start'); console.log('OperationList start');
TEMPLATE.loadHearder("#includedHeader"); TEMPLATE.loadHearder("#includedHeader");
TEMPLATE.loadMainNavsTitle('#includedMainTitle', 'workList', null, null); TEMPLATE.loadMainNavsTitle('#includedMainTitle', 'workList', null, null);
TEMPLATE.loadConfirmModal("#includedConfirmModal"); TEMPLATE.loadConfirmModal("#includedConfirmModal");
TEMPLATE.loadCategoryModal("#includedCategoryModal"); TEMPLATE.loadCategoryModal("#includedCategoryModal");
//get all data of operation list scene //get all data of operation list scene
OL.getAllDataWeb(sessionStorage.OL_searchKeyWord, sessionStorage.OL_sortIndex, sessionStorage.OL_searchStartDate, sessionStorage.OL_searchEndDate, sessionStorage.OL_operationGroupMasterId); OL.getAllDataWeb(sessionStorage.OL_searchKeyWord, sessionStorage.OL_sortIndex, sessionStorage.OL_searchStartDate, sessionStorage.OL_searchEndDate, sessionStorage.OL_operationGroupMasterId);
//show operation list //show operation list
OL.createOperationList(OL.operationList); OL.createOperationList(OL.operationList);
//show category(operationGroupMaster) //show category(operationGroupMaster)
OL.createCategory(); OL.createCategory();
}; };
/** /**
* get operation list all data * get operation list all data
* 1.operation list * 1.operation list
* 2.category(operationGroupMaster) list * 2.category(operationGroupMaster) list
* *
* @param {String} searchKeyword * @param {String} searchKeyword
* @param {Number} sortIndex * @param {Number} sortIndex
* @param {String} searchStartDate * @param {String} searchStartDate
* @param {String} searchEndDate * @param {String} searchEndDate
* @param {Number} operationGroupMasterId * @param {Number} operationGroupMasterId
*/ */
OL.getAllDataWeb = function (searchKeyWord, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId) { OL.getAllDataWeb = function (searchKeyWord, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId) {
let param = {}; let param = {};
param.sid = COMMON.getSid(); param.sid = COMMON.getSid();
if (typeof searchKeyWord !== 'undefined') { if (typeof searchKeyWord !== 'undefined') {
param.operationName = searchKeyWord; param.operationName = searchKeyWord;
} }
if (typeof sortIndex !== 'undefined') { if (typeof sortIndex !== 'undefined') {
param.sort = sortIndex; param.sort = sortIndex;
} }
if (typeof searchStartDate !== 'undefined') { if (typeof searchStartDate !== 'undefined') {
param.startDate = searchStartDate; param.startDate = searchStartDate;
} }
if (typeof searchEndDate !== 'undefined') { if (typeof searchEndDate !== 'undefined') {
param.endDate = searchEndDate; param.endDate = searchEndDate;
} }
if (typeof operationGroupMasterId !== 'undefined') { if (typeof operationGroupMasterId !== 'undefined') {
param.operationGroupMasterId = operationGroupMasterId; param.operationGroupMasterId = operationGroupMasterId;
} }
const url = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + CONSTANT.URL.CMS.API.ALL_OPERATION_LIST; const url = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + CONSTANT.URL.CMS.API.ALL_OPERATION_LIST;
COMMON.cmsAjax(url, param, false, function (json) { COMMON.cmsAjax(url, param, false, function (json) {
OL.saveSearchKeyWord(searchKeyWord, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId); OL.saveSearchKeyWord(searchKeyWord, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId);
OL.setSearchInfoWeb(); OL.setSearchInfoWeb();
OL.operationList = json.operationList; OL.operationList = json.operationList;
OL.operationGroupMaster = json.operationGroupMasterList; OL.operationGroupMaster = json.operationGroupMasterList;
OL.isOperationGroupMaster = json.isOperationGroupMaster; OL.isOperationGroupMaster = json.isOperationGroupMaster;
}); });
}; };
/** /**
* Transfer search criteria to session. * Transfer search criteria to session.
* Keep value after page move. * Keep value after page move.
* *
* @param {String} searchKeyword * @param {String} searchKeyword
* @param {String} sortIndex * @param {String} sortIndex
* @param {String} searchStartDate * @param {String} searchStartDate
* @param {String} searchEndDate * @param {String} searchEndDate
* @param {String} operationGroupMasterId * @param {String} operationGroupMasterId
*/ */
OL.saveSearchKeyWord = function (searchKeyword, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId) { OL.saveSearchKeyWord = function (searchKeyword, sortIndex, searchStartDate, searchEndDate, operationGroupMasterId) {
if (typeof searchKeyword !== 'undefined') { if (typeof searchKeyword !== 'undefined') {
sessionStorage.OL_searchKeyWord = searchKeyword; sessionStorage.OL_searchKeyWord = searchKeyword;
} }
if (typeof sortIndex !== 'undefined') { if (typeof sortIndex !== 'undefined') {
sessionStorage.OL_sortIndex = sortIndex; sessionStorage.OL_sortIndex = sortIndex;
} }
if (typeof searchStartDate !== 'undefined') { if (typeof searchStartDate !== 'undefined') {
sessionStorage.OL_searchStartDate = searchStartDate; sessionStorage.OL_searchStartDate = searchStartDate;
} }
if (typeof searchEndDate !== 'undefined') { if (typeof searchEndDate !== 'undefined') {
sessionStorage.OL_searchEndDate = searchEndDate; sessionStorage.OL_searchEndDate = searchEndDate;
} }
if (typeof operationGroupMasterId !== 'undefined') { if (typeof operationGroupMasterId !== 'undefined') {
sessionStorage.OL_operationGroupMasterId = operationGroupMasterId; sessionStorage.OL_operationGroupMasterId = operationGroupMasterId;
} }
}; };
/** /**
* set search criteria when Initial display. * set search criteria when Initial display.
*/ */
OL.setSearchInfoWeb = function () { OL.setSearchInfoWeb = function () {
if (sessionStorage.OL_sortIndex) { if (sessionStorage.OL_sortIndex) {
OL.sortIndex = sessionStorage.OL_sortIndex; OL.sortIndex = sessionStorage.OL_sortIndex;
} }
if (sessionStorage.OL_searchKeyWord) { if (sessionStorage.OL_searchKeyWord) {
$('#searchTaskName').val(sessionStorage.OL_searchKeyWord); $('#searchTaskName').val(sessionStorage.OL_searchKeyWord);
} }
if (sessionStorage.OL_searchStartDate) { if (sessionStorage.OL_searchStartDate) {
$('#searchStartDate').val(sessionStorage.OL_searchStartDate); $('#searchStartDate').val(sessionStorage.OL_searchStartDate);
} }
if (sessionStorage.OL_searchEndDate) { if (sessionStorage.OL_searchEndDate) {
$('#searchEndDate').val(sessionStorage.OL_searchEndDate); $('#searchEndDate').val(sessionStorage.OL_searchEndDate);
} }
if (sessionStorage.OL_operationGroupMasterId) { if (sessionStorage.OL_operationGroupMasterId) {
OL.operationGroupMasterId = sessionStorage.OL_operationGroupMasterId; OL.operationGroupMasterId = sessionStorage.OL_operationGroupMasterId;
} }
}; };
/** /**
* create operation list * create operation list
*/ */
OL.createOperationList = function (operationList) { OL.createOperationList = function (operationList) {
//Initialization //Initialization
OL.initActiveSortIndex(); OL.initActiveSortIndex();
$('#operationTable').empty(); $('#operationTable').empty();
$('#operationCount').text(0); $('#operationCount').text(0);
if (!operationList) { if (!operationList) {
return; return;
} }
$('#operationCount').text(operationList.length); $('#operationCount').text(operationList.length);
//create & show //create & show
for (let i = 0; i < operationList.length; i++) { for (let i = 0; i < operationList.length; i++) {
let classIcon ; let classIcon ;
switch (operationList[i].reportType) switch (operationList[i].reportType)
{ {
case OL.REPORT_TYPE.REPORTONLY: case OL.REPORT_TYPE.REPORTONLY:
classIcon = "report"; classIcon = "report";
break; break;
case OL.REPORT_TYPE.INSPECT: case OL.REPORT_TYPE.INSPECT:
classIcon = "inspection"; classIcon = "inspection";
break; break;
case OL.REPORT_TYPE.WITHREPLY: case OL.REPORT_TYPE.WITHREPLY:
classIcon = "questionary"; classIcon = "questionary";
break; break;
case OL.REPORT_TYPE.WORKFLOW: case OL.REPORT_TYPE.WORKFLOW:
classIcon = "proccess"; classIcon = "proccess";
break; break;
} }
let messageli = $("<li class='card mb-2' name = 'operationId_" + operationList[i].operationId + "' ></li>"); let messageli = $("<li class='card mb-2' name = 'operationId_" + operationList[i].operationId + "' ></li>");
let ahrefRequiredFlg = $("<a href=\"javascript:OL.sendOperation('" let ahrefRequiredFlg = $("<a href=\"javascript:OL.sendOperation('"
+ operationList[i].operationId + operationList[i].operationId
+ "', '" + "', '"
+ operationList[i].operationType + operationList[i].operationType
+ "', '" + "', '"
+ operationList[i].reportType + operationList[i].reportType
+ "', '" + "', '"
+ operationList[i].enableAddReport + operationList[i].enableAddReport
+ "');\" class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'></a>"); + "');\" class='h-100 d-block px-3 py-2 text-decoration-none text-dark position-relative'></a>");
let divIcon = $("<div class='position-absolute translate-middle top-50 left-0 ml-3'>" let divIcon = $("<div class='position-absolute translate-middle top-50 left-0 ml-3'>"
+ "<div class='type-icon'>" + "<div class='type-icon'>"
+ "<span class='" + classIcon + "'></span>" + "<span class='" + classIcon + "'></span>"
+ "</div></div>") + "</div></div>")
let divDate = "<div class='fs-8 text-secondary text-truncate'>" let divDate = "<div class='fs-8 text-secondary text-truncate'>"
+ OL.setOperationDate(operationList[i].operationStartDate) + OL.setOperationDate(operationList[i].operationStartDate)
+ ' ~ ' + ' ~ '
+ OL.setOperationDate(operationList[i].operationEndDate) + OL.setOperationDate(operationList[i].operationEndDate)
+ "</div>"; + "</div>";
let divText = $("<div class='pl-5 h-100 d-flex align-items-center'>" let divText = $("<div class='pl-5 h-100 d-flex align-items-center'>"
+ "<div class='w-100'>" + "<div class='w-100'>"
+ "<div class='fs-12 text-truncate'>" + operationList[i].operationName + "</div>" + "<div class='fs-12 text-truncate'>" + operationList[i].operationName + "</div>"
+ divDate + divDate
+ "</div></div>"); + "</div></div>");
ahrefRequiredFlg.append(divIcon); ahrefRequiredFlg.append(divIcon);
ahrefRequiredFlg.append(divText); ahrefRequiredFlg.append(divText);
messageli.append(ahrefRequiredFlg); messageli.append(ahrefRequiredFlg);
$('#operationTable').append(messageli); $('#operationTable').append(messageli);
} }
}; };
/** /**
* add color to any sorting type when sortIndex exsist * add color to any sorting type when sortIndex exsist
* *
* @param {Number} sortIndex * @param {Number} sortIndex
*/ */
OL.initActiveSortIndex = function (sortIndex) { OL.initActiveSortIndex = function (sortIndex) {
if (!sortIndex && !OL.sortIndex) { if (!sortIndex && !OL.sortIndex) {
OL.sortIndex = CONSTANT.SORT_TYPE.START_DATE_DESC; OL.sortIndex = CONSTANT.SORT_TYPE.START_DATE_DESC;
} }
$('.sort-type').each(function () { $('.sort-type').each(function () {
const sortType = $(this).data('sort'); const sortType = $(this).data('sort');
if (sortType == OL.sortIndex) { if (sortType == OL.sortIndex) {
$('.sort-type').removeClass('active'); $('.sort-type').removeClass('active');
$(this).addClass('active'); $(this).addClass('active');
} }
}); });
}; };
/** /**
* set date for OperationList * set date for OperationList
* *
* @param {String} date * @param {String} date
* @returns operationDate * @returns operationDate
*/ */
OL.setOperationDate = function (date) { OL.setOperationDate = function (date) {
const operationDate = date.replace(/-/g, '/').substring(0, 10); const operationDate = date.replace(/-/g, '/').substring(0, 10);
return operationDate; return operationDate;
}; };
/** /**
* create category(operationGroupMaster). * create category(operationGroupMaster).
*/ */
OL.createCategory = function () { OL.createCategory = function () {
if (!OL.isOperationGroupMaster) { if (!OL.isOperationGroupMaster) {
return; return;
} }
OL.initCategory(); OL.initCategory();
OL.createBreadcrumbList(); OL.createBreadcrumbList();
OL.createCategoryList(); OL.createCategoryList();
OL.acdMenu(); OL.acdMenu();
}; };
/** /**
* Initial processing of category(operationGroupMaster). * Initial processing of category(operationGroupMaster).
*/ */
OL.initCategory = function () { OL.initCategory = function () {
if (!OL.isOperationGroupMaster) { if (!OL.isOperationGroupMaster) {
return; return;
} }
$('#operationGroupMasterButton').removeClass('d-none'); $('#operationGroupMasterButton').removeClass('d-none');
OL.setCategoryHeight(); OL.setCategoryHeight();
$(window).resize(function () { $(window).resize(function () {
OL.setCategoryHeight(); OL.setCategoryHeight();
}); });
}; };
/** /**
* change height category(operationGroupMaster) * change height category(operationGroupMaster)
*/ */
OL.setCategoryHeight = function () { OL.setCategoryHeight = function () {
const CATEGORY_HEIGHT = $('footer').offset().top - $('#category-menu').offset().top; const CATEGORY_HEIGHT = $('footer').offset().top - $('#category-menu').offset().top;
$('#category-menu').css('overflow', 'scroll'); $('#category-menu').css('overflow', 'scroll');
$('#category-menu').height(CATEGORY_HEIGHT); $('#category-menu').height(CATEGORY_HEIGHT);
$('#overlayDiv').height(CATEGORY_HEIGHT); $('#overlayDiv').height(CATEGORY_HEIGHT);
}; };
/** /**
* create Breadcrumb List * create Breadcrumb List
*/ */
OL.createBreadcrumbList = function () { OL.createBreadcrumbList = function () {
if (!OL.isOperationGroupMaster) { if (!OL.isOperationGroupMaster) {
return; return;
} }
$('#groupMasterPath').empty(); $('#groupMasterPath').empty();
if (typeof OL.operationGroupMasterId === 'undefined' || OL.operationGroupMasterId == 0) { if (typeof OL.operationGroupMasterId === 'undefined' || OL.operationGroupMasterId == 0) {
$('#groupMasterPath').append('<li class="breadcrumb-item"><a href="#" class="text-decoration-none text-dark">' + COMMON.getMsg('all') + '</a></li>'); $('#groupMasterPath').append('<li class="breadcrumb-item"><a href="#" class="text-decoration-none text-dark">' + COMMON.getMsg('all') + '</a></li>');
} else { } else {
let treeList = []; let treeList = [];
OL.createBreadcrumbTree(treeList, OL.operationGroupMasterId); OL.createBreadcrumbTree(treeList, OL.operationGroupMasterId);
treeList.forEach(function (operationGroupMaster) { treeList.forEach(function (operationGroupMaster) {
$('#groupMasterPath').append( $('#groupMasterPath').append(
'<li class="breadcrumb-item"><a onclick="OL.changeOperationGroupMaster(' + '<li class="breadcrumb-item"><a onclick="OL.changeOperationGroupMaster(' +
operationGroupMaster.operationGroupMasterId + operationGroupMaster.operationGroupMasterId +
');" class="text-decoration-none text-dark">' + ');" class="text-decoration-none text-dark">' +
operationGroupMaster.operationGroupMasterName + operationGroupMaster.operationGroupMasterName +
'</a></li>', '</a></li>',
); );
}); });
} }
}; };
/** /**
* create Breadcrumb tree List * create Breadcrumb tree List
* *
* @param {list} treeList * @param {list} treeList
* @param {string} operationGroupMasterId * @param {string} operationGroupMasterId
* @returns * @returns
*/ */
OL.createBreadcrumbTree = function (treeList, operationGroupMasterId) { OL.createBreadcrumbTree = function (treeList, operationGroupMasterId) {
if (operationGroupMasterId == 0) { if (operationGroupMasterId == 0) {
return treeList; return treeList;
} }
const groupMaster = OL.operationGroupMaster.filter(it => it.operationGroupMasterId == operationGroupMasterId)[0]; const groupMaster = OL.operationGroupMaster.filter(it => it.operationGroupMasterId == operationGroupMasterId)[0];
OL.createBreadcrumbTree(treeList, groupMaster.parentOperationGroupMasterId); OL.createBreadcrumbTree(treeList, groupMaster.parentOperationGroupMasterId);
treeList.push(groupMaster); treeList.push(groupMaster);
return treeList; return treeList;
}; };
/** /**
* create category(operationGroupMaster) structure * create category(operationGroupMaster) structure
*/ */
OL.createCategoryList = function () { OL.createCategoryList = function () {
if (!OL.isOperationGroupMaster) { if (!OL.isOperationGroupMaster) {
return; return;
} }
//Create a side menu category structure //Create a side menu category structure
$('.group-category-list').remove(); $('.group-category-list').remove();
OL.operationGroupMaster.sort(function (a, b) { OL.operationGroupMaster.sort(function (a, b) {
if (a.operationGroupMasterLevel < b.operationGroupMasterLevel) return -1; if (a.operationGroupMasterLevel < b.operationGroupMasterLevel) return -1;
if (a.operationGroupMasterLevel > b.operationGroupMasterLevel) return 1; if (a.operationGroupMasterLevel > b.operationGroupMasterLevel) return 1;
return 1; return 1;
}); });
//common //common
const noCategory = $("<dl id='groupMasterId_0' class='group-category-list'><dt><a onclick='OL.changeOperationGroupMaster(0);'>" + COMMON.getMsg('all') + '</a></dt></dl>'); const noCategory = $("<dl id='groupMasterId_0' class='group-category-list'><dt><a onclick='OL.changeOperationGroupMaster(0);'>" + COMMON.getMsg('all') + '</a></dt></dl>');
$('#category-menu').append(noCategory); $('#category-menu').append(noCategory);
//create category(operationGroupMaster) structure //create category(operationGroupMaster) structure
for (let i = 0; i < OL.operationGroupMaster.length; i++) { for (let i = 0; i < OL.operationGroupMaster.length; i++) {
if (OL.operationGroupMaster[i].operationGroupMasterLevel == 0) { if (OL.operationGroupMaster[i].operationGroupMasterLevel == 0) {
const categoryParent = $( const categoryParent = $(
'<dl id=groupMasterId_' + '<dl id=groupMasterId_' +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
" class='group-category-list' style='overflow-x:auto;'><dt class='menu-ttl'><a onclick='OL.changeOperationGroupMaster(" + " class='group-category-list' style='overflow-x:auto;'><dt class='menu-ttl'><a onclick='OL.changeOperationGroupMaster(" +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
");'>" + ");'>" +
OL.operationGroupMaster[i].operationGroupMasterName + OL.operationGroupMaster[i].operationGroupMasterName +
'</a></dt></dl>', '</a></dt></dl>',
); );
$('#category-menu').append(categoryParent); $('#category-menu').append(categoryParent);
} else { } else {
if ($('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId + '>ul').length > 0) { if ($('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId + '>ul').length > 0) {
const categoryChild = $( const categoryChild = $(
"<li id='groupMasterId_" + "<li id='groupMasterId_" +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
"' class=''><p class='category-li group-level-" + "' class=''><p class='category-li group-level-" +
OL.operationGroupMaster[i].operationGroupMasterLevel + OL.operationGroupMaster[i].operationGroupMasterLevel +
"'><a class='category-a' onclick='OL.changeOperationGroupMaster(" + "'><a class='category-a' onclick='OL.changeOperationGroupMaster(" +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
");'>" + ");'>" +
OL.operationGroupMaster[i].operationGroupMasterName + OL.operationGroupMaster[i].operationGroupMasterName +
'</a></p></li>', '</a></p></li>',
); );
$('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId + ' >ul').append(categoryChild); $('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId + ' >ul').append(categoryChild);
} else { } else {
const groupParents = '#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId; const groupParents = '#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId;
$(groupParents + ' > p').addClass('sub-menu-ttl'); $(groupParents + ' > p').addClass('sub-menu-ttl');
const categoryChild = $( const categoryChild = $(
"<ul style='display:none;' class=''><li class='' id='groupMasterId_" + "<ul style='display:none;' class=''><li class='' id='groupMasterId_" +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
"' class=''><p class='category-li group-level-" + "' class=''><p class='category-li group-level-" +
OL.operationGroupMaster[i].operationGroupMasterLevel + OL.operationGroupMaster[i].operationGroupMasterLevel +
"'><a class='category-a' onclick='OL.changeOperationGroupMaster(" + "'><a class='category-a' onclick='OL.changeOperationGroupMaster(" +
OL.operationGroupMaster[i].operationGroupMasterId + OL.operationGroupMaster[i].operationGroupMasterId +
");'>" + ");'>" +
OL.operationGroupMaster[i].operationGroupMasterName + OL.operationGroupMaster[i].operationGroupMasterName +
'</a></p></li></ul>', '</a></p></li></ul>',
); );
$('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId).append(categoryChild); $('#groupMasterId_' + OL.operationGroupMaster[i].parentOperationGroupMasterId).append(categoryChild);
} }
} }
} }
}; };
/** /**
* Open/close category(operationGroupMaster) drawer menu * Open/close category(operationGroupMaster) drawer menu
*/ */
OL.acdMenu = function () { OL.acdMenu = function () {
//Hide accordion contents by default //Hide accordion contents by default
$('.drawer-menu dd').css('display', 'none'); $('.drawer-menu dd').css('display', 'none');
$('.drawer-menu2 ul').css('display', 'none'); $('.drawer-menu2 ul').css('display', 'none');
//second accordion //second accordion
$('.drawer-menu dt').on('click', function () { $('.drawer-menu dt').on('click', function () {
$('.sub-menu-ttl').removeClass('openAcd').next().slideUp('fast'); $('.sub-menu-ttl').removeClass('openAcd').next().slideUp('fast');
$('.drawer-menu dt').not(this).removeClass('open').next().slideUp('fast'); $('.drawer-menu dt').not(this).removeClass('open').next().slideUp('fast');
$(this).toggleClass('open').next().slideToggle('fast'); $(this).toggleClass('open').next().slideToggle('fast');
}); });
//third accordion //third accordion
$('.sub-menu-ttl').on('click', function () { $('.sub-menu-ttl').on('click', function () {
$('.sub-menu-ttl').not($(this)).not($(this).parents().siblings('p')).removeClass('openAcd').next().slideUp('fast'); $('.sub-menu-ttl').not($(this)).not($(this).parents().siblings('p')).removeClass('openAcd').next().slideUp('fast');
$(this).toggleClass('openAcd').next().slideToggle('fast'); $(this).toggleClass('openAcd').next().slideToggle('fast');
}); });
}; };
/** /**
* Sort the operationList by screen operation * Sort the operationList by screen operation
* *
* @param {Object} sortType * @param {Object} sortType
*/ */
OL.changeSortType = function (sortType) { OL.changeSortType = function (sortType) {
$('.sort-type').removeClass('active'); $('.sort-type').removeClass('active');
$(sortType).addClass('active'); $(sortType).addClass('active');
OL.sortIndex = $(sortType).attr('data-sort'); OL.sortIndex = $(sortType).attr('data-sort');
const sortStr = sortType.dataset.sort; const sortStr = sortType.dataset.sort;
const sortNumber = parseFloat(sortStr); const sortNumber = parseFloat(sortStr);
OL.sortOperationList(sortNumber); OL.sortOperationList(sortNumber);
OL.createOperationList(OL.operationList); OL.createOperationList(OL.operationList);
}; };
/** /**
* sort the operationList * sort the operationList
* *
* @param {Number} sortNumber * @param {Number} sortNumber
*/ */
OL.sortOperationList = function (sortNumber) { OL.sortOperationList = function (sortNumber) {
if (!OL.operationList) { if (!OL.operationList) {
return; return;
} }
switch (sortNumber) { switch (sortNumber) {
case CONSTANT.SORT_TYPE.NAME: case CONSTANT.SORT_TYPE.NAME:
OL.operationList.sort(function (a, b) { OL.operationList.sort(function (a, b) {
if (a.operationName > b.operationName) return 1; if (a.operationName > b.operationName) return 1;
if (a.operationName < b.operationName) return -1; if (a.operationName < b.operationName) return -1;
return 0; return 0;
}); });
break; break;
case CONSTANT.SORT_TYPE.START_DATE_DESC: case CONSTANT.SORT_TYPE.START_DATE_DESC:
OL.operationList.sort(function (a, b) { OL.operationList.sort(function (a, b) {
if (OL.setOperationDate(a.operationStartDate) < OL.setOperationDate(b.operationStartDate)) return 1; if (OL.setOperationDate(a.operationStartDate) < OL.setOperationDate(b.operationStartDate)) return 1;
if (OL.setOperationDate(a.operationStartDate) > OL.setOperationDate(b.operationStartDate)) return -1; if (OL.setOperationDate(a.operationStartDate) > OL.setOperationDate(b.operationStartDate)) return -1;
return 0; return 0;
}); });
break; break;
case CONSTANT.SORT_TYPE.START_DATE_ASC: case CONSTANT.SORT_TYPE.START_DATE_ASC:
OL.operationList.sort(function (a, b) { OL.operationList.sort(function (a, b) {
if (OL.setOperationDate(a.operationStartDate) > OL.setOperationDate(b.operationStartDate)) return 1; if (OL.setOperationDate(a.operationStartDate) > OL.setOperationDate(b.operationStartDate)) return 1;
if (OL.setOperationDate(a.operationStartDate) < OL.setOperationDate(b.operationStartDate)) return -1; if (OL.setOperationDate(a.operationStartDate) < OL.setOperationDate(b.operationStartDate)) return -1;
return 0; return 0;
}); });
break; break;
case CONSTANT.SORT_TYPE.TYPE: case CONSTANT.SORT_TYPE.TYPE:
OL.operationList.sort(function (a, b) { OL.operationList.sort(function (a, b) {
if (a.operationType < b.operationType) return 1; if (a.operationType < b.operationType) return 1;
if (a.operationType > b.operationType) return -1; if (a.operationType > b.operationType) return -1;
return 0; return 0;
}); });
break; break;
case CONSTANT.SORT_TYPE.LAST_EDIT_DATE: case CONSTANT.SORT_TYPE.LAST_EDIT_DATE:
const defaultDate = '1900-01-01 09:00:00'; const defaultDate = '1900-01-01 09:00:00';
OL.operationList.sort(function (a, b) { OL.operationList.sort(function (a, b) {
if (!a.operationOpenDate) { if (!a.operationOpenDate) {
a.operationOpenDate = defaultDate; a.operationOpenDate = defaultDate;
} }
if (!b.operationOpenDate) { if (!b.operationOpenDate) {
b.operationOpenDate = defaultDate; b.operationOpenDate = defaultDate;
} }
if (a.operationOpenDate < b.operationOpenDate) return 1; if (a.operationOpenDate < b.operationOpenDate) return 1;
if (a.operationOpenDate > b.operationOpenDate) return -1; if (a.operationOpenDate > b.operationOpenDate) return -1;
return 0; return 0;
}); });
break; break;
} }
}; };
/** /**
* search operarionList * search operarionList
*/ */
OL.search = function () { OL.search = function () {
COMMON.showLoading(); COMMON.showLoading();
const searchKeyword = $('#searchTaskName').val(); const searchKeyword = $('#searchTaskName').val();
const searchStartDate = $('#searchStartDate').val(); const searchStartDate = $('#searchStartDate').val();
const searchEndDate = $('#searchEndDate').val(); const searchEndDate = $('#searchEndDate').val();
if (searchStartDate && searchEndDate && searchStartDate > searchEndDate) { if (searchStartDate && searchEndDate && searchStartDate > searchEndDate) {
COMMON.closeLoading(); COMMON.closeLoading();
COMMON.displayAlert('dateError'); COMMON.displayAlert('dateError');
return; return;
} }
OL.getAllDataWeb(searchKeyword, OL.sortIndex, searchStartDate, searchEndDate, OL.operationGroupMasterId); OL.getAllDataWeb(searchKeyword, OL.sortIndex, searchStartDate, searchEndDate, OL.operationGroupMasterId);
OL.createOperationList(OL.operationList); OL.createOperationList(OL.operationList);
OL.createCategory(); OL.createCategory();
COMMON.closeLoading(); COMMON.closeLoading();
}; };
/** /**
* change the operationList by select the category(OperationGroupMaster) * change the operationList by select the category(OperationGroupMaster)
* @param {Number} operationGroupMasterId * @param {Number} operationGroupMasterId
*/ */
OL.changeOperationGroupMaster = function (operationGroupMasterId) { OL.changeOperationGroupMaster = function (operationGroupMasterId) {
if ($('#category-menu').hasClass('open')) { if ($('#category-menu').hasClass('open')) {
$('#category-toggle-button').click(); $('#category-toggle-button').click();
$('body').css('overflow', 'visible'); $('body').css('overflow', 'visible');
} }
OL.operationGroupMasterId = operationGroupMasterId; OL.operationGroupMasterId = operationGroupMasterId;
OL.search(); OL.search();
}; };
/** /**
* open the category(OperationGroupMaster) * open the category(OperationGroupMaster)
*/ */
OL.openCategory = function () { OL.openCategory = function () {
window.scrollTo(0, 0); window.scrollTo(0, 0);
if ($('#category-menu').hasClass('open')) { if ($('#category-menu').hasClass('open')) {
$('body').css('overflow', 'visible'); $('body').css('overflow', 'visible');
} else { } else {
$('body').css('overflow', 'hidden'); $('body').css('overflow', 'hidden');
} }
}; };
/** /**
* reset search * reset search
*/ */
OL.resetSearch = function () { OL.resetSearch = function () {
$('#searchTaskName').val(''); $('#searchTaskName').val('');
$('#searchStartDate').val(''); $('#searchStartDate').val('');
$('#searchEndDate').val(''); $('#searchEndDate').val('');
OL.changeSortType($('#defaultSort')); OL.changeSortType($('#defaultSort'));
}; };
/** /**
* Transition to the report form or operation list screen * Transition to the report form or operation list screen
* *
* @param {String} operationId * @param {String} operationId
*/ */
OL.sendOperation = function (operationId, operationType, reportType, enableAddReport) { OL.sendOperation = function (operationId, operationType, reportType, enableAddReport) {
//save operation logs. needed for sorting //save operation logs. needed for sorting
OL.saveOperationReadingLog(operationId, operationType, reportType); OL.saveOperationReadingLog(operationId, operationType, reportType);
//Transition to the report form or operation list screen //Transition to the report form or operation list screen
let params = {}; let params = {};
params.sid = COMMON.getSid(); params.sid = COMMON.getSid();
params.operationId = operationId; params.operationId = operationId;
params.returnUrl = CONSTANT.URL.WEB.BASE + CONSTANT.URL.WEB.OPERATION_LIST; params.returnUrl = CONSTANT.URL.WEB.BASE + CONSTANT.URL.WEB.OPERATION_LIST;
const url = OL.createUrlOfOperation(enableAddReport, reportType); const url = OL.createUrlOfOperation(enableAddReport, reportType);
COMMON.postCommunication(url, params); COMMON.postCommunication(url, params);
}; };
/** /**
* save operation logs. needed for sorting * save operation logs. needed for sorting
* *
* @param {String} operationId * @param {String} operationId
* @param {String} operationType * @param {String} operationType
* @param {String} reportType * @param {String} reportType
*/ */
OL.saveOperationReadingLog = function (operationId, operationType, reportType) { OL.saveOperationReadingLog = function (operationId, operationType, reportType) {
let params = {}; let params = {};
params.sid = COMMON.getSid(); params.sid = COMMON.getSid();
params.operationId = operationId; params.operationId = operationId;
params.deviceType = CONSTANT.DEVICE_TYPE.WEB; params.deviceType = CONSTANT.DEVICE_TYPE.WEB;
params.operationType = operationType; params.operationType = operationType;
params.reportType = reportType; params.reportType = reportType;
params.viewingStartDate = COMMON.currentTime(); params.viewingStartDate = COMMON.currentTime();
const url = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + CONSTANT.URL.CMS.API.OPERATION_VIEW_LOG; const url = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + CONSTANT.URL.CMS.API.OPERATION_VIEW_LOG;
COMMON.cmsAjax(url, params, false); COMMON.cmsAjax(url, params, false);
}; };
/** /**
* return url of cms Operation Scene * return url of cms Operation Scene
* *
* @param {boolean} enableAddReport * @param {boolean} enableAddReport
* @param {Number} reportType * @param {Number} reportType
* @returns url * @returns url
*/ */
OL.createUrlOfOperation = function (enableAddReport, reportType) { OL.createUrlOfOperation = function (enableAddReport, reportType) {
let baseUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.HTML.BASE; let baseUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.HTML.BASE;
if (reportType == CONSTANT.REPORT_TYPE.ROUTINE || enableAddReport == '1') { if (reportType == CONSTANT.REPORT_TYPE.ROUTINE || enableAddReport == '1') {
return baseUrl + CONSTANT.URL.CMS.HTML.TASK_REPORT_LIST; return baseUrl + CONSTANT.URL.CMS.HTML.TASK_REPORT_LIST;
} else { } else {
return baseUrl + CONSTANT.URL.CMS.HTML.LIST_REPORT_FORM; return baseUrl + CONSTANT.URL.CMS.HTML.LIST_REPORT_FORM;
} }
}; };
/** /**
* switch operation List to view * switch operation List to view
*/ */
OL.switchToViewList = function () { OL.switchToViewList = function () {
$('.view-menu .view-list-btn').on("click", function() { $('.view-menu .view-list-btn').on("click", function() {
$('.view-block-btn').removeClass('active'); $('.view-block-btn').removeClass('active');
$('.view-list-btn').addClass('active'); $('.view-list-btn').addClass('active');
$('.view-content').removeClass('view-block'); $('.view-content').removeClass('view-block');
$('.view-content').addClass('view-list'); $('.view-content').addClass('view-list');
}); });
}; };
/** /**
* switch operation List to grid * switch operation List to grid
*/ */
OL.switchToGridList = function() { OL.switchToGridList = function() {
$('.view-menu .view-block-btn').on("click", function() { $('.view-menu .view-block-btn').on("click", function() {
$('.view-list-btn').removeClass('active'); $('.view-list-btn').removeClass('active');
$('.view-block-btn').addClass('active'); $('.view-block-btn').addClass('active');
$('.view-content').removeClass('view-list'); $('.view-content').removeClass('view-list');
$('.view-content').addClass('view-block'); $('.view-content').addClass('view-block');
}); });
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment