dabory-review.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. (function($) {
  2. $.fn.review = async function(options) {
  3. const opts = $.extend({}, $.fn.review.defaults, options)
  4. this.append(html.call(this, opts, ''))
  5. loadModule.call(this)
  6. callApi.call(this)
  7. };
  8. function callApi(limit = 10, offset = 0, page = 1) {
  9. const self = this
  10. $.fn.dataLinker.api23Js('list-type1-page', {
  11. "QueryVars": {
  12. "QueryName": "setup-input",
  13. },
  14. "PageVars": {
  15. "Limit": limit,
  16. "Offset": offset
  17. },
  18. "ListType1Vars": {
  19. "FilterDate": "",
  20. "StartDate": moment(new Date($(self).find('.type1-start-date').val())).format('YYYYMMDD'),
  21. "EndDate": moment(new Date($(self).find('.type1-end-date').val())).format('YYYYMMDD'),
  22. "OrderBy": $(self).find('.dabory-table-order-by-select').val()
  23. }
  24. }, function (response) {
  25. const reviewList = response.Page
  26. if (reviewList) {
  27. appendTable.call(self, reviewList)
  28. $(self).find('.dabory-table-pagination').html($.fn.table.makePagination(limit, response.PageVars.QueryCnt, page))
  29. }
  30. })
  31. }
  32. function appendTable(reviewList) {
  33. const html = reviewList.reduce((html, data) => {
  34. return html + `<tr>
  35. <td style="text-align: center !important;">
  36. <input name="cursor-state" type="radio" value="1" tabindex="-1">
  37. </td>
  38. <td style="text-align: center !important;">
  39. ${data['C1']}
  40. </td>
  41. <td style="text-align: left !important;">
  42. ${data['C1']}
  43. </td>
  44. <td style="text-align: center !important;">
  45. ${data['C2']}
  46. </td>
  47. <td style="text-align: left !important;">
  48. ${data['C3']}
  49. </td>
  50. <td style="text-align: right !important;">
  51. ${data['C4']}
  52. </td>
  53. <td style="text-align: right !important;">
  54. ${data['C5']}
  55. </td>
  56. <td style="text-align: right !important;">
  57. ${data['C6']}
  58. </td>
  59. <td style="text-align: right !important;">
  60. ${data['C7']}
  61. </td>
  62. <td style="text-align: right !important;">
  63. ${data['C8']}
  64. </td>
  65. <td style="text-align: right !important;">
  66. ${data['C9']}
  67. </td>
  68. </tr>`
  69. }, '')
  70. $(this).find('tbody').html(html)
  71. }
  72. // TODO: dabory-table.css 안으로 tpye1 클래스이름 전역 통합시키기
  73. function html(opts, langJson) {
  74. return `<div class="dabory-review-popup review type1" style="top: ${opts['top']}px; left: ${opts['left']}px; width: ${opts['width']}px; display: none;">
  75. <button type="button" class="tab-close" data-widget="review">
  76. <img src="/dabory/common/image/close-button.svg" alt="close-butto">
  77. </button>
  78. ${$.fn.type1.html.call(this)}
  79. </div>`
  80. }
  81. function getLangText(langJson, key) {
  82. if (! langJson) { return key }
  83. return langJson[key]
  84. }
  85. function loadModule() {
  86. $.fn.type1.first_date_rang.call(this)
  87. const self = this
  88. $(document).ready(function () {
  89. // $(self).find('.dabory-review-popup').css('z-index', 9999)
  90. // $(self).find('.dabory-review-popup').show()
  91. $(self).find('.dabory-review-popup').draggable()
  92. $(document).on('click', '.dabory-review-popup .dabory-table-pagination .page-link', function () {
  93. const limit = Number($(self).find('.dabory-table-line-select').val())
  94. const offset = Number($(this).data('offset'))
  95. const page = Number($(this).data('page'))
  96. $(self).find('.dabory-table-order-by-select').data('page', page)
  97. $(self).find('.dabory-table-order-by-select').data('offset', offset)
  98. callApi.call( self, limit, offset, page )
  99. });
  100. $(document).on('change', '.dabory-review-popup .dabory-table-order-by-select', function () {
  101. const limit = Number($(self).find('.dabory-table-line-select').val())
  102. const offset = Number($(this).data('offset') ?? 1)
  103. const page = Number($(this).data('page') ?? 1)
  104. callApi.call( self, limit, offset, page )
  105. });
  106. $(document).on('change', '.dabory-review-popup .dabory-table-line-select', function () {
  107. const limit = Number($(this).val())
  108. callApi.call( self, limit, 0 )
  109. });
  110. $(document).on('list.requery', '.dabory-review-popup', function () {
  111. const limit = Number($(self).find('.dabory-table-line-select').val())
  112. const offset = Number($(self).find('.dabory-table-order-by-select').data('offset') ?? 1)
  113. const page = Number($(self).find('.dabory-table-order-by-select').data('page') ?? 1)
  114. callApi.call( self, limit, offset, page )
  115. });
  116. });
  117. }
  118. $.fn.review.defaults = {
  119. top: 0,
  120. left: 0,
  121. width: 1200,
  122. langType: 'ko',
  123. basePath: '/dabory/widget/review',
  124. };
  125. }(jQuery));