|
|
|
@ -14,9 +14,9 @@ class PageNavigation {
|
|
|
|
|
// 현재 데이타 위치
|
|
|
|
|
,gridDataPos: null
|
|
|
|
|
// 현재 page
|
|
|
|
|
,page: null
|
|
|
|
|
,pageNum: null
|
|
|
|
|
// 페이지당 갯수
|
|
|
|
|
,perPage: null
|
|
|
|
|
,fetchSize: null
|
|
|
|
|
// 전체 데이타 count
|
|
|
|
|
,totalCount: null
|
|
|
|
|
// 페이지 이동 구분
|
|
|
|
@ -31,32 +31,29 @@ class PageNavigation {
|
|
|
|
|
*/
|
|
|
|
|
constructor(GRID, gridDatas, gridDataPos) {
|
|
|
|
|
let pageInfo = {
|
|
|
|
|
page: 1,
|
|
|
|
|
perPage: null,
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
fetchSize: null,
|
|
|
|
|
totalCount: null
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// pageOptions type에 따라 paging 정보 위치가 달라 분기 처리
|
|
|
|
|
if(GRID.store.data.pageOptions.type === 'scroll'){
|
|
|
|
|
//const {page, perPage, totalCount} = GRID.store.data.pageOptions;
|
|
|
|
|
const {page, perPage, totalCount} = GRID.store.data.pageOptions;
|
|
|
|
|
pageInfo.page = page;
|
|
|
|
|
pageInfo.perPage = perPage;
|
|
|
|
|
if(GRID.paginationInfoRef.pagingYn === true){
|
|
|
|
|
const {pageNum, fetchSize, totalCount} = GRID.paginationInfoRef;
|
|
|
|
|
pageInfo.pageNum = pageNum;
|
|
|
|
|
pageInfo.fetchSize = fetchSize;
|
|
|
|
|
pageInfo.totalCount = totalCount;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
const {itemsPerPage, totalItems} = GRID.getPagination()._options;
|
|
|
|
|
pageInfo.page = GRID.getPagination()._currentPage;
|
|
|
|
|
pageInfo.perPage = itemsPerPage;
|
|
|
|
|
pageInfo.totalCount = totalItems;
|
|
|
|
|
pageInfo.fetchSize = GRID.paginationInfoRef.totalCount;
|
|
|
|
|
pageInfo.totalCount = GRID.paginationInfoRef.totalCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.gridInfo = {
|
|
|
|
|
|
|
|
|
|
gridDatas
|
|
|
|
|
,gridDataPos
|
|
|
|
|
,curRowData: gridDatas[gridDataPos]
|
|
|
|
|
,curRowPos: (pageInfo.page - 1) * pageInfo.perPage + gridDataPos + 1
|
|
|
|
|
,page: pageInfo.page
|
|
|
|
|
,perPage: pageInfo.perPage
|
|
|
|
|
,curRowPos: (pageInfo.pageNum - 1) * pageInfo.fetchSize + gridDataPos + 1
|
|
|
|
|
,pageNum: pageInfo.pageNum
|
|
|
|
|
,fetchSize: pageInfo.fetchSize
|
|
|
|
|
,totalCount: pageInfo.totalCount
|
|
|
|
|
,pageMove: null
|
|
|
|
|
,next: null
|
|
|
|
@ -74,7 +71,7 @@ class PageNavigation {
|
|
|
|
|
resetGrid(res, gridDatas, callback) {
|
|
|
|
|
this.grid.resetData(res.data?.contents);
|
|
|
|
|
if (this.gridInfo.next) this.pageNav = new PageNavigation(this.grid, gridDatas, 0);
|
|
|
|
|
else this.pageNav = new PageNavigation(this.grid, gridDatas, this.gridInfo.perPage - 1);
|
|
|
|
|
else this.pageNav = new PageNavigation(this.grid, gridDatas, this.gridInfo.fetchSize - 1);
|
|
|
|
|
|
|
|
|
|
callback(this.pageNav)
|
|
|
|
|
}
|
|
|
|
@ -105,15 +102,15 @@ class PageNavigation {
|
|
|
|
|
* @param {function} callback 페이지 이동시 호출할 callback
|
|
|
|
|
*/
|
|
|
|
|
onClickNavBtn(evDiv, callback) {
|
|
|
|
|
const isTypeScroll = this.grid.store?.data.pageOptions.type === 'scroll';
|
|
|
|
|
const isTypeScroll = this.grid.paginationInfoRef?.pagingType === 'scroll';
|
|
|
|
|
|
|
|
|
|
if (evDiv === 'next') {
|
|
|
|
|
if(this.gridInfo.gridDataPos + 1 === this.gridInfo.perPage){
|
|
|
|
|
if(this.gridInfo.gridDataPos + 1 === this.gridInfo.fetchSize){
|
|
|
|
|
this.gridInfo.pageMove = true;
|
|
|
|
|
this.gridInfo.next = true;
|
|
|
|
|
this.gridInfo.page++;
|
|
|
|
|
//isTypeScroll ? GRID.store.data.pageOptions.pageMove(this.gridInfo.page) :
|
|
|
|
|
if(!isTypeScroll) this.grid.getPagination()?.movePageTo(this.gridInfo.page);
|
|
|
|
|
this.gridInfo.pageNum++;
|
|
|
|
|
if(!isTypeScroll)
|
|
|
|
|
this.grid.getPagination()?.movePageTo(this.gridInfo.pageNum);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
this.gridInfo.curRowPos++;
|
|
|
|
@ -126,9 +123,9 @@ class PageNavigation {
|
|
|
|
|
if(this.gridInfo.gridDataPos === 0){
|
|
|
|
|
this.gridInfo.pageMove = true;
|
|
|
|
|
this.gridInfo.next = false;
|
|
|
|
|
this.gridInfo.page--;
|
|
|
|
|
//isTypeScroll ? GRID.store.data.pageOptions.pageMove?(this.gridInfo.page) :
|
|
|
|
|
if(!isTypeScroll) this.grid.getPagination()?.movePageTo(this.gridInfo.page);
|
|
|
|
|
this.gridInfo.pageNum--;
|
|
|
|
|
if(!isTypeScroll)
|
|
|
|
|
this.grid.getPagination()?.movePageTo(this.gridInfo.pageNum);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
this.gridInfo.curRowPos--;
|
|
|
|
|