(function($) {
$.fn.review = async function(options) {
const opts = $.extend({}, $.fn.review.defaults, options)
this.append(html.call(this, opts, ''))
loadModule.call(this)
callApi.call(this)
};
function callApi(limit = 10, offset = 0, page = 1) {
const self = this
$.fn.dataLinker.api23Js('list-type1-page', {
"QueryVars": {
"QueryName": "setup-input",
},
"PageVars": {
"Limit": limit,
"Offset": offset
},
"ListType1Vars": {
"FilterDate": "",
"StartDate": moment(new Date($(self).find('.type1-start-date').val())).format('YYYYMMDD'),
"EndDate": moment(new Date($(self).find('.type1-end-date').val())).format('YYYYMMDD'),
"OrderBy": $(self).find('.dabory-table-order-by-select').val()
}
}, function (response) {
const reviewList = response.Page
if (reviewList) {
appendTable.call(self, reviewList)
$(self).find('.dabory-table-pagination').html($.fn.table.makePagination(limit, response.PageVars.QueryCnt, page))
}
})
}
function appendTable(reviewList) {
const html = reviewList.reduce((html, data) => {
return html + `
|
${data['C1']}
|
${data['C1']}
|
${data['C2']}
|
${data['C3']}
|
${data['C4']}
|
${data['C5']}
|
${data['C6']}
|
${data['C7']}
|
${data['C8']}
|
${data['C9']}
|
`
}, '')
$(this).find('tbody').html(html)
}
// TODO: dabory-table.css 안으로 tpye1 클래스이름 전역 통합시키기
function html(opts, langJson) {
return ``
}
function getLangText(langJson, key) {
if (! langJson) { return key }
return langJson[key]
}
function loadModule() {
$.fn.type1.first_date_rang.call(this)
const self = this
$(document).ready(function () {
// $(self).find('.dabory-review-popup').css('z-index', 9999)
// $(self).find('.dabory-review-popup').show()
$(self).find('.dabory-review-popup').draggable()
$(document).on('click', '.dabory-review-popup .dabory-table-pagination .page-link', function () {
const limit = Number($(self).find('.dabory-table-line-select').val())
const offset = Number($(this).data('offset'))
const page = Number($(this).data('page'))
$(self).find('.dabory-table-order-by-select').data('page', page)
$(self).find('.dabory-table-order-by-select').data('offset', offset)
callApi.call( self, limit, offset, page )
});
$(document).on('change', '.dabory-review-popup .dabory-table-order-by-select', function () {
const limit = Number($(self).find('.dabory-table-line-select').val())
const offset = Number($(this).data('offset') ?? 1)
const page = Number($(this).data('page') ?? 1)
callApi.call( self, limit, offset, page )
});
$(document).on('change', '.dabory-review-popup .dabory-table-line-select', function () {
const limit = Number($(this).val())
callApi.call( self, limit, 0 )
});
$(document).on('list.requery', '.dabory-review-popup', function () {
const limit = Number($(self).find('.dabory-table-line-select').val())
const offset = Number($(self).find('.dabory-table-order-by-select').data('offset') ?? 1)
const page = Number($(self).find('.dabory-table-order-by-select').data('page') ?? 1)
callApi.call( self, limit, offset, page )
});
});
}
$.fn.review.defaults = {
top: 0,
left: 0,
width: 1200,
langType: 'ko',
basePath: '/dabory/widget/review',
};
}(jQuery));