evui 3.4.207 → 3.4.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +18 -33
  2. package/dist/404.html +44 -0
  3. package/dist/favicon.ico +0 -0
  4. package/dist/index.js +22738 -0
  5. package/dist/index.umd.cjs +28 -0
  6. package/dist/style.css +1 -0
  7. package/package.json +46 -43
  8. package/dist/evui.common.js +0 -63681
  9. package/dist/evui.common.js.map +0 -1
  10. package/dist/evui.umd.js +0 -63691
  11. package/dist/evui.umd.js.map +0 -1
  12. package/dist/evui.umd.min.js +0 -2
  13. package/dist/evui.umd.min.js.map +0 -1
  14. package/dist/img/EVUI.b82ee81a.svg +0 -293
  15. package/src/assets/logo.png +0 -0
  16. package/src/common/emitter.js +0 -20
  17. package/src/common/utils.bignumber.js +0 -67
  18. package/src/common/utils.debounce.js +0 -223
  19. package/src/common/utils.js +0 -151
  20. package/src/common/utils.table.js +0 -78
  21. package/src/common/utils.throttle.js +0 -83
  22. package/src/common/utils.tree.js +0 -18
  23. package/src/components/button/Button.vue +0 -195
  24. package/src/components/button/index.js +0 -7
  25. package/src/components/buttonGroup/ButtonGroup.vue +0 -11
  26. package/src/components/buttonGroup/index.js +0 -7
  27. package/src/components/calendar/Calendar.vue +0 -725
  28. package/src/components/calendar/index.js +0 -7
  29. package/src/components/calendar/uses.js +0 -1410
  30. package/src/components/chart/Chart.vue +0 -363
  31. package/src/components/chart/ChartToolbar.vue +0 -52
  32. package/src/components/chart/chart.core.js +0 -1170
  33. package/src/components/chart/chartZoom.core.js +0 -540
  34. package/src/components/chart/element/element.bar.js +0 -672
  35. package/src/components/chart/element/element.bar.time.js +0 -166
  36. package/src/components/chart/element/element.heatmap.js +0 -743
  37. package/src/components/chart/element/element.line.js +0 -611
  38. package/src/components/chart/element/element.pie.js +0 -197
  39. package/src/components/chart/element/element.scatter.js +0 -320
  40. package/src/components/chart/element/element.tip.js +0 -717
  41. package/src/components/chart/helpers/helpers.canvas.js +0 -265
  42. package/src/components/chart/helpers/helpers.constant.js +0 -235
  43. package/src/components/chart/helpers/helpers.util.js +0 -400
  44. package/src/components/chart/index.js +0 -9
  45. package/src/components/chart/model/index.js +0 -50
  46. package/src/components/chart/model/model.series.js +0 -125
  47. package/src/components/chart/model/model.store.js +0 -1427
  48. package/src/components/chart/plugins/plugins.interaction.js +0 -1659
  49. package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
  50. package/src/components/chart/plugins/plugins.legend.js +0 -1543
  51. package/src/components/chart/plugins/plugins.pie.js +0 -254
  52. package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
  53. package/src/components/chart/plugins/plugins.title.js +0 -61
  54. package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
  55. package/src/components/chart/scale/scale.js +0 -951
  56. package/src/components/chart/scale/scale.linear.js +0 -268
  57. package/src/components/chart/scale/scale.logarithmic.js +0 -135
  58. package/src/components/chart/scale/scale.step.js +0 -430
  59. package/src/components/chart/scale/scale.time.category.js +0 -338
  60. package/src/components/chart/scale/scale.time.js +0 -49
  61. package/src/components/chart/style/chart.scss +0 -405
  62. package/src/components/chart/uses.js +0 -721
  63. package/src/components/chartBrush/ChartBrush.vue +0 -323
  64. package/src/components/chartBrush/chartBrush.core.js +0 -691
  65. package/src/components/chartBrush/index.js +0 -9
  66. package/src/components/chartBrush/uses.js +0 -23
  67. package/src/components/chartGroup/ChartGroup.vue +0 -144
  68. package/src/components/chartGroup/index.js +0 -9
  69. package/src/components/chartGroup/style/chartGroup.scss +0 -5
  70. package/src/components/chartGroup/uses.js +0 -53
  71. package/src/components/checkbox/Checkbox.vue +0 -229
  72. package/src/components/checkbox/index.js +0 -7
  73. package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
  74. package/src/components/checkboxGroup/index.js +0 -7
  75. package/src/components/contextMenu/ContextMenu.vue +0 -95
  76. package/src/components/contextMenu/MenuList.vue +0 -182
  77. package/src/components/contextMenu/index.js +0 -7
  78. package/src/components/contextMenu/uses.js +0 -223
  79. package/src/components/datePicker/DatePicker.vue +0 -504
  80. package/src/components/datePicker/index.js +0 -7
  81. package/src/components/datePicker/uses.js +0 -460
  82. package/src/components/grid/Grid.vue +0 -1535
  83. package/src/components/grid/GridColumnSetting.vue +0 -358
  84. package/src/components/grid/GridFilterSetting.vue +0 -323
  85. package/src/components/grid/GridPagination.vue +0 -75
  86. package/src/components/grid/GridSummary.vue +0 -314
  87. package/src/components/grid/GridToolbar.vue +0 -35
  88. package/src/components/grid/icon/icon-option-button.vue +0 -17
  89. package/src/components/grid/icon/icon-sort-button.vue +0 -67
  90. package/src/components/grid/index.js +0 -11
  91. package/src/components/grid/style/grid.scss +0 -417
  92. package/src/components/grid/uses.js +0 -1629
  93. package/src/components/icon/Icon.vue +0 -53
  94. package/src/components/icon/index.js +0 -8
  95. package/src/components/inputNumber/InputNumber.vue +0 -212
  96. package/src/components/inputNumber/index.js +0 -7
  97. package/src/components/inputNumber/uses.js +0 -217
  98. package/src/components/loading/Loading.vue +0 -125
  99. package/src/components/loading/index.js +0 -7
  100. package/src/components/menu/Menu.vue +0 -79
  101. package/src/components/menu/MenuItem.vue +0 -201
  102. package/src/components/menu/index.js +0 -7
  103. package/src/components/message/Message.vue +0 -229
  104. package/src/components/message/index.js +0 -34
  105. package/src/components/messageBox/MessageBox.vue +0 -358
  106. package/src/components/messageBox/index.js +0 -22
  107. package/src/components/notification/Notification.vue +0 -316
  108. package/src/components/notification/index.js +0 -49
  109. package/src/components/pagination/Pagination.vue +0 -317
  110. package/src/components/pagination/index.js +0 -7
  111. package/src/components/pagination/pageButton.vue +0 -31
  112. package/src/components/progress/Progress.vue +0 -139
  113. package/src/components/progress/index.js +0 -7
  114. package/src/components/radio/Radio.vue +0 -159
  115. package/src/components/radio/index.js +0 -7
  116. package/src/components/radioGroup/RadioGroup.vue +0 -41
  117. package/src/components/radioGroup/index.js +0 -7
  118. package/src/components/scheduler/Scheduler.vue +0 -149
  119. package/src/components/scheduler/index.js +0 -7
  120. package/src/components/scheduler/uses.js +0 -183
  121. package/src/components/select/Select.vue +0 -556
  122. package/src/components/select/index.js +0 -7
  123. package/src/components/select/uses.js +0 -379
  124. package/src/components/slider/Slider.vue +0 -505
  125. package/src/components/slider/index.js +0 -7
  126. package/src/components/slider/uses.js +0 -391
  127. package/src/components/tabPanel/TabPanel.vue +0 -74
  128. package/src/components/tabPanel/index.js +0 -7
  129. package/src/components/tabs/Tabs.vue +0 -517
  130. package/src/components/tabs/index.js +0 -7
  131. package/src/components/textField/TextField.vue +0 -399
  132. package/src/components/textField/index.js +0 -7
  133. package/src/components/timePicker/TimePicker.vue +0 -364
  134. package/src/components/timePicker/index.js +0 -7
  135. package/src/components/toggle/Toggle.vue +0 -115
  136. package/src/components/toggle/index.js +0 -7
  137. package/src/components/tree/Tree.vue +0 -338
  138. package/src/components/tree/TreeNode.vue +0 -293
  139. package/src/components/tree/index.js +0 -7
  140. package/src/components/treeGrid/TreeGrid.vue +0 -1074
  141. package/src/components/treeGrid/TreeGridNode.vue +0 -349
  142. package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
  143. package/src/components/treeGrid/icon/icon-tree.png +0 -0
  144. package/src/components/treeGrid/index.js +0 -9
  145. package/src/components/treeGrid/style/treeGrid.scss +0 -277
  146. package/src/components/treeGrid/uses.js +0 -1178
  147. package/src/components/window/Window.vue +0 -329
  148. package/src/components/window/index.js +0 -7
  149. package/src/components/window/uses.js +0 -908
  150. package/src/directives/clickoutside.js +0 -90
  151. package/src/main.js +0 -120
  152. package/src/style/components/input.scss +0 -108
  153. package/src/style/functions.scss +0 -3
  154. package/src/style/index.scss +0 -6
  155. package/src/style/lib/fonts/EVUI.eot +0 -0
  156. package/src/style/lib/fonts/EVUI.svg +0 -293
  157. package/src/style/lib/fonts/EVUI.ttf +0 -0
  158. package/src/style/lib/fonts/EVUI.woff +0 -0
  159. package/src/style/lib/icon.css +0 -888
  160. package/src/style/mixins.scss +0 -94
  161. package/src/style/themes.scss +0 -69
  162. package/src/style/variables.scss +0 -22
@@ -1,1178 +0,0 @@
1
- import { getCurrentInstance, nextTick } from 'vue';
2
- import { numberWithComma } from '@/common/utils';
3
-
4
- export const commonFunctions = (params) => {
5
- const { props } = getCurrentInstance();
6
- const { checkInfo } = params;
7
- /**
8
- * 해당 컬럼이 사용자 지정 컬럼인지 확인한다.
9
- *
10
- * @param {object} column - 컬럼 정보
11
- * @returns {boolean} 사용자 지정 컬럼 유무
12
- */
13
- const isRenderer = (column = {}) => !!column?.render?.use;
14
- const getComponentName = (type = '') => {
15
- const setUpperCaseFirstStr = str => str.charAt(0).toUpperCase() + str.slice(1);
16
- const rendererStr = 'Renderer';
17
- let typeStr = '';
18
- if (type.indexOf('_') !== -1) {
19
- const typeStrArray = type.split('_');
20
- for (let ix = 0; ix < typeStrArray.length; ix++) {
21
- typeStr += setUpperCaseFirstStr(typeStrArray[ix]);
22
- }
23
- } else {
24
- typeStr = setUpperCaseFirstStr(type);
25
- }
26
- return typeStr + rendererStr;
27
- };
28
- /**
29
- * 데이터 타입에 따라 변환된 데이터을 반환한다.
30
- *
31
- * @param {object} column - 컬럼 정보
32
- * @param {number|string} value - 데이터
33
- * @returns {number|string} 변환된 데이터
34
- */
35
- const getConvertValue = (column, value) => {
36
- let convertValue = column.type === 'number' || column.type === 'float' ? Number(value) : value;
37
-
38
- if (column.type === 'number') {
39
- convertValue = numberWithComma(value);
40
- convertValue = convertValue === false ? value : convertValue;
41
- } else if (column.type === 'float') {
42
- const floatValue = convertValue.toFixed(column.decimal ?? 3);
43
- convertValue = floatValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
44
- }
45
-
46
- return convertValue;
47
- };
48
- /**
49
- * 전달받은 필드명과 일치하는 컬럼 인덱스를 반환한다.
50
- *
51
- * @param {string} field - 컬럼 필드명
52
- * @returns {number} 일치한다면 컬럼 인덱스, 일치하지 않는다면 -1
53
- */
54
- const getColumnIndex = field => props.columns.findIndex(column => column.field === field);
55
- const setPixelUnit = (value) => {
56
- let size = value;
57
- const hasPx = size.toString().indexOf('px') >= 0;
58
- const hasPct = size.toString().indexOf('%') >= 0;
59
- if (!hasPx && !hasPct) {
60
- size = `${size}px`;
61
- }
62
- return size;
63
- };
64
- const checkHeader = (rows) => {
65
- checkInfo.isHeaderChecked = !!rows.length && rows.every(row => row.checked);
66
- const uncheckableList = rows.filter(row => row.uncheckable);
67
- if (uncheckableList.length) {
68
- const checkedList = rows.filter(row => row.checked);
69
- const isAllUncheckable = rows.every(row => uncheckableList.includes(row));
70
-
71
- checkInfo.isHeaderChecked = !isAllUncheckable
72
- && (uncheckableList.length + checkedList.length === rows.length);
73
- checkInfo.isHeaderUncheckable = isAllUncheckable;
74
- }
75
- checkInfo.isHeaderIndeterminate = !!rows.length
76
- && rows.some(row => row.checked || row.indeterminate)
77
- && !checkInfo.isHeaderChecked;
78
- };
79
- return {
80
- isRenderer,
81
- getComponentName,
82
- getConvertValue,
83
- getColumnIndex,
84
- setPixelUnit,
85
- checkHeader,
86
- };
87
- };
88
-
89
- export const getUpdatedColumns = (stores) => {
90
- const { originColumns, filteredColumns } = stores;
91
- return originColumns.map((col) => {
92
- const changedCol = filteredColumns.find(fcol => fcol.index === col.index) ?? {};
93
- return {
94
- ...col,
95
- ...changedCol,
96
- };
97
- });
98
- };
99
-
100
- export const scrollEvent = (params) => {
101
- const {
102
- scrollInfo,
103
- stores,
104
- elementInfo,
105
- resizeInfo,
106
- pageInfo,
107
- summaryScroll,
108
- getPagingData,
109
- updatePagingInfo,
110
- } = params;
111
- /**
112
- * 수직 스크롤의 위치 계산 후 적용한다.
113
- */
114
- const updateVScroll = (isScroll) => {
115
- let store = stores.showTreeStore;
116
- if (pageInfo.isClientPaging) {
117
- store = getPagingData();
118
- }
119
- const bodyEl = elementInfo.body;
120
- if (bodyEl) {
121
- const rowHeight = resizeInfo.rowHeight;
122
- const rowCount = bodyEl.clientHeight > rowHeight
123
- ? Math.ceil(bodyEl.clientHeight / rowHeight) : store.length;
124
- const totalScrollHeight = store.length * rowHeight;
125
- let firstVisibleIndex = Math.floor(bodyEl.scrollTop / rowHeight);
126
- if (firstVisibleIndex > store.length - 1) {
127
- firstVisibleIndex = 0;
128
- }
129
-
130
- const lastVisibleIndex = firstVisibleIndex + rowCount + 1;
131
- const firstIndex = Math.max(firstVisibleIndex, 0);
132
- const lastIndex = lastVisibleIndex;
133
- const tableEl = elementInfo.table;
134
-
135
- stores.viewStore = store.slice(firstIndex, lastIndex);
136
- scrollInfo.hasVerticalScrollBar = rowCount < store.length
137
- || bodyEl.clientHeight < tableEl.clientHeight;
138
- scrollInfo.vScrollTopHeight = firstIndex * rowHeight;
139
- scrollInfo.vScrollBottomHeight = totalScrollHeight - (stores.viewStore.length * rowHeight)
140
- - scrollInfo.vScrollTopHeight;
141
- if (isScroll && pageInfo.isInfinite && scrollInfo.vScrollBottomHeight === 0) {
142
- pageInfo.prevPage = pageInfo.currentPage;
143
- pageInfo.currentPage = Math.ceil(lastIndex / pageInfo.perPage) + 1;
144
- pageInfo.startIndex = lastIndex;
145
- updatePagingInfo({ onScrollEnd: true });
146
- }
147
- }
148
- };
149
- /**
150
- * 수평 스크롤의 위치 계산 후 적용한다.
151
- */
152
- const updateHScroll = () => {
153
- const headerEl = elementInfo.header;
154
- const bodyEl = elementInfo.body;
155
- const tableEl = elementInfo.table;
156
-
157
- headerEl.scrollLeft = bodyEl.scrollLeft;
158
- summaryScroll.value = bodyEl.scrollLeft;
159
- scrollInfo.hasHorizontalScrollBar = bodyEl.clientWidth < tableEl.clientWidth;
160
- };
161
- /**
162
- * scroll 이벤트를 처리한다.
163
- */
164
- const onScroll = () => {
165
- const bodyEl = elementInfo.body;
166
- const scrollTop = bodyEl.scrollTop;
167
- const scrollLeft = bodyEl.scrollLeft;
168
- const lastTop = scrollInfo.lastScroll.top;
169
- const lastLeft = scrollInfo.lastScroll.left;
170
- const isHorizontal = !(scrollLeft === lastLeft);
171
- const isVertical = !(scrollTop === lastTop);
172
-
173
- if (isVertical && bodyEl.clientHeight) {
174
- updateVScroll(true);
175
- }
176
-
177
- if (isHorizontal) {
178
- updateHScroll();
179
- }
180
-
181
- scrollInfo.lastScroll.top = scrollTop;
182
- scrollInfo.lastScroll.left = scrollLeft;
183
- };
184
- return { updateVScroll, updateHScroll, onScroll };
185
- };
186
-
187
- export const resizeEvent = (params) => {
188
- const { props, emit } = getCurrentInstance();
189
- const {
190
- resizeInfo,
191
- elementInfo,
192
- checkInfo,
193
- stores,
194
- isRenderer,
195
- updateVScroll,
196
- updateHScroll,
197
- contextInfo,
198
- } = params;
199
- /**
200
- * 고정 너비, 스크롤 유무 등에 따른 컬럼 너비를 계산한다.
201
- */
202
- const calculatedColumn = () => {
203
- stores.viewStore = stores.showTreeStore;
204
- const store = stores.viewStore;
205
- let columnWidth = resizeInfo.columnWidth;
206
- if (resizeInfo.columnWidth > 0) {
207
- columnWidth = resizeInfo.columnWidth;
208
- }
209
- columnWidth = resizeInfo.columnWidth;
210
- let remainWidth = 0;
211
- if (resizeInfo.adjust && elementInfo.body) {
212
- const bodyEl = elementInfo.body;
213
- let elWidth = bodyEl.offsetWidth;
214
- const elHeight = bodyEl.offsetHeight;
215
- const result = stores.orderedColumns.reduce((acc, column) => {
216
- if (column.hide || column.hiddenDisplay) {
217
- return acc;
218
- }
219
-
220
- if (column.width) {
221
- acc.totalWidth += column.width;
222
- } else {
223
- acc.emptyCount++;
224
- }
225
-
226
- return acc;
227
- }, { totalWidth: contextInfo.customContextMenu.length ? 30 : 0, emptyCount: 0 });
228
-
229
- if (resizeInfo.rowHeight * store.length > elHeight - resizeInfo.scrollWidth) {
230
- elWidth -= resizeInfo.scrollWidth;
231
- }
232
-
233
- if (checkInfo.useCheckbox.use) {
234
- elWidth -= resizeInfo.minWidth;
235
- }
236
-
237
- columnWidth = elWidth - result.totalWidth;
238
- if (columnWidth > 0) {
239
- const sharePerEmptyCount = result.emptyCount === 0
240
- ? 0
241
- : Math.floor(columnWidth / result.emptyCount);
242
-
243
- remainWidth = columnWidth - (sharePerEmptyCount * result.emptyCount);
244
- columnWidth = result.emptyCount !== 0
245
- ? sharePerEmptyCount
246
- : columnWidth;
247
- } else {
248
- columnWidth = resizeInfo.columnWidth;
249
- }
250
-
251
- columnWidth = columnWidth < resizeInfo.minWidth ? resizeInfo.minWidth : columnWidth;
252
- resizeInfo.columnWidth = columnWidth;
253
- }
254
-
255
- stores.orderedColumns.forEach((col) => {
256
- const minWidth = isRenderer(col) ? resizeInfo.rendererMinWidth : resizeInfo.minWidth;
257
- if (col.width && col.width < minWidth) {
258
- col.width = minWidth;
259
- }
260
- if (!col.width && !col.hide) {
261
- col.width = columnWidth;
262
- }
263
- });
264
-
265
- if (remainWidth && stores.orderedColumns.length) {
266
- let index = stores.orderedColumns.length - 1;
267
- let lastColumn = stores.orderedColumns[index];
268
-
269
- // orderedColumns에 hiddenDisplay === true 컬럼은 포함되어 있지 않다.
270
- // 하지만 hide === true 컬럼은 포함되어 있다. 그래서 hiddenDisplay 조건은 필요없지만 조건을 추가해서 코드 가독성과 안정성을 높였다.
271
- while (index > 0 && lastColumn && (lastColumn.hide || lastColumn.hiddenDisplay)) {
272
- index -= 1;
273
- lastColumn = stores.orderedColumns[index];
274
- }
275
- if (lastColumn) {
276
- lastColumn.width += remainWidth;
277
- }
278
- }
279
- resizeInfo.isResize = !resizeInfo.isResize;
280
- };
281
- /**
282
- * grid resize 이벤트를 처리한다.
283
- */
284
- const onResize = () => {
285
- nextTick(() => {
286
- if (resizeInfo.adjust) {
287
- stores.orderedColumns.forEach((column) => {
288
- const item = column;
289
-
290
- if (!props.columns[column.index]?.width && !item.resized) {
291
- item.width = 0;
292
- }
293
-
294
- return item;
295
- }, this);
296
- }
297
-
298
- calculatedColumn();
299
- if (elementInfo.body?.clientHeight) {
300
- updateVScroll();
301
- }
302
- if (elementInfo.body?.clientWidth) {
303
- updateHScroll();
304
- }
305
- });
306
- };
307
- const onShow = (isVisible) => {
308
- if (isVisible) {
309
- onResize();
310
- }
311
- };
312
- /**
313
- * column resize 이벤트를 처리한다.
314
- *
315
- * @param {number} columnIndex - 컬럼 인덱스
316
- * @param {object} event - 이벤트 객체
317
- */
318
- const onColumnResize = (columnIndex, event) => {
319
- const headerEl = elementInfo.header;
320
- const bodyEl = elementInfo.body;
321
- const headerLeft = headerEl.getBoundingClientRect().left;
322
- const columnEl = headerEl.querySelector(`li[data-index="${columnIndex}"]`);
323
- const minWidth = isRenderer(stores.orderedColumns[columnIndex])
324
- ? resizeInfo.rendererMinWidth : resizeInfo.minWidth;
325
- const columnRect = columnEl.getBoundingClientRect();
326
- const maxRight = bodyEl.getBoundingClientRect().right - headerLeft;
327
- const resizeLineEl = elementInfo.resizeLine;
328
- const minLeft = columnRect.left - headerLeft + minWidth;
329
- const startLeft = columnRect.right - headerLeft;
330
- const startMouseLeft = event.clientX;
331
- const startColumnLeft = columnRect.left - headerLeft;
332
-
333
- bodyEl.style.overflow = 'auto';
334
- resizeLineEl.style.left = `${startLeft}px`;
335
-
336
- resizeInfo.showResizeLine = true;
337
-
338
- const handleMouseMove = (evt) => {
339
- const deltaLeft = evt.clientX - startMouseLeft;
340
- const proxyLeft = startLeft + deltaLeft;
341
- let resizeWidth = Math.max(minLeft, proxyLeft);
342
-
343
- resizeWidth = Math.min(maxRight, resizeWidth);
344
-
345
- resizeLineEl.style.left = `${resizeWidth}px`;
346
- };
347
-
348
- const handleMouseUp = () => {
349
- const destLeft = parseInt(resizeLineEl.style.left, 10);
350
- const changedWidth = destLeft - startColumnLeft;
351
-
352
- if (stores.orderedColumns[columnIndex]) {
353
- stores.orderedColumns[columnIndex].width = changedWidth;
354
- stores.orderedColumns[columnIndex].resized = true;
355
- }
356
-
357
- resizeInfo.showResizeLine = false;
358
- document.removeEventListener('mousemove', handleMouseMove);
359
- onResize();
360
-
361
- const updatedColumns = getUpdatedColumns(stores);
362
- emit('resize-column', {
363
- column: stores.orderedColumns[columnIndex],
364
- columns: updatedColumns,
365
- });
366
- emit('change-column-info', {
367
- type: 'resize',
368
- columns: updatedColumns,
369
- });
370
- };
371
-
372
- document.addEventListener('mousemove', handleMouseMove);
373
- document.addEventListener('mouseup', handleMouseUp, { once: true });
374
- };
375
- return { calculatedColumn, onResize, onShow, onColumnResize };
376
- };
377
-
378
- export const clickEvent = (params) => {
379
- const { emit } = getCurrentInstance();
380
- const selectInfo = params;
381
- const getClickedRowData = (event, row) => {
382
- const tagName = event.target.tagName.toLowerCase();
383
- let cellInfo = {};
384
- if (event.target.offsetParent) {
385
- if (tagName === 'td') {
386
- cellInfo = event.target.dataset;
387
- } else {
388
- cellInfo = event.target.closest('td')?.dataset ?? {};
389
- }
390
- }
391
- return {
392
- event,
393
- rowData: row,
394
- rowIndex: row.index,
395
- cellName: cellInfo.name,
396
- cellIndex: cellInfo.index,
397
- };
398
- };
399
- /**
400
- * row click 이벤트를 처리한다.
401
- *
402
- * @param {object} event - 이벤트 객체
403
- * @param {array} row - row 데이터
404
- */
405
- let timer = null;
406
- const onRowClick = (event, row) => {
407
- if (event.target && event.target.parentElement
408
- && (event.target.parentElement.classList.contains('row-checkbox-input')
409
- || event.target.closest('td')?.classList?.contains('row-contextmenu'))) {
410
- return false;
411
- }
412
- clearTimeout(timer);
413
- timer = setTimeout(() => {
414
- if (selectInfo.useSelect) {
415
- if (row.selected) {
416
- row.selected = false;
417
- if (selectInfo.multiple) {
418
- if (event.ctrlKey) {
419
- selectInfo.selectedRow = selectInfo.selectedRow.filter(s => s.index !== row.index);
420
- } else {
421
- selectInfo.selectedRow = [row];
422
- }
423
- } else {
424
- selectInfo.selectedRow = [];
425
- }
426
- } else {
427
- row.selected = true;
428
- if (event.ctrlKey
429
- && selectInfo.multiple
430
- && (!selectInfo.limitCount || selectInfo.limitCount > selectInfo.selectedRow.length)) {
431
- selectInfo.selectedRow.push(row);
432
- } else {
433
- selectInfo.selectedRow = [row];
434
- }
435
- }
436
- emit('update:selected', selectInfo.selectedRow);
437
- emit('click-row', getClickedRowData(event, row));
438
- }
439
- }, 100);
440
- return true;
441
- };
442
- /**
443
- * row dblclick 이벤트를 처리한다.
444
- *
445
- * @param {object} event - 이벤트 객체
446
- * @param {array} row - row 데이터
447
- */
448
- const onRowDblClick = (event, row) => {
449
- clearTimeout(timer);
450
- emit('dblclick-row', getClickedRowData(event, row));
451
- };
452
- return { onRowClick, onRowDblClick };
453
- };
454
-
455
- export const checkEvent = (params) => {
456
- const {
457
- checkInfo,
458
- stores,
459
- checkHeader,
460
- pageInfo,
461
- getPagingData,
462
- } = params;
463
- const { emit } = getCurrentInstance();
464
-
465
- /**
466
- * row에 대한 체크 상태를 해제한다.
467
- *
468
- * @param {array} row - row 데이터
469
- */
470
- const isEachMode = () => checkInfo.useCheckbox.mode === 'each';
471
-
472
- const unCheckedRow = (row) => {
473
- const index = stores.treeStore.findIndex(
474
- item => item.index === row.index);
475
-
476
- if (index !== -1) {
477
- stores.treeStore[index].checked = row.checked;
478
- }
479
- };
480
- const onCheckChildren = (node) => {
481
- if (isEachMode()) {
482
- return;
483
- }
484
-
485
- if (node.hasChild) {
486
- node.children.forEach((children) => {
487
- const childNode = children;
488
- if (node.checked && !childNode.checked && !childNode.uncheckable) {
489
- checkInfo.checkedRows.push(childNode);
490
- }
491
- if (!node.checked) {
492
- checkInfo.checkedRows = checkInfo.checkedRows
493
- .filter(checked => checked.index !== childNode.index);
494
- }
495
- childNode.checked = node.checked && !childNode.uncheckable;
496
-
497
- if (childNode.hasChild) {
498
- onCheckChildren(childNode);
499
- }
500
- });
501
- }
502
- };
503
- const onCheckParent = (node) => {
504
- if (isEachMode()) {
505
- return;
506
- }
507
-
508
- const parentNode = node.parent;
509
- if (parentNode) {
510
- const isCheck = parentNode.children.every(n => n.checked);
511
- parentNode.checked = isCheck && !parentNode.uncheckable;
512
- const uncheckableList = parentNode.children.filter(n => n.uncheckable);
513
- if (uncheckableList.length) {
514
- const checkedList = parentNode.children.filter(n => n.checked);
515
- if (uncheckableList.length + checkedList.length === parentNode.children.length) {
516
- parentNode.checked = true;
517
- }
518
- }
519
-
520
- parentNode.indeterminate = !isCheck
521
- && parentNode.children.some(n => n.checked || n.indeterminate);
522
-
523
- if (!parentNode.checked) {
524
- checkInfo.checkedRows = checkInfo.checkedRows
525
- .filter(checked => checked.index !== parentNode.index);
526
- } else {
527
- checkInfo.checkedRows.push(parentNode);
528
- }
529
- if (parentNode.parent) {
530
- onCheckParent(parentNode);
531
- }
532
- }
533
- };
534
- /**
535
- * checkbox click 이벤트를 처리한다.
536
- *
537
- * @param {object} event - 이벤트 객체
538
- * @param {array} rowData - row 데이터
539
- */
540
- const onCheck = (event, rowData) => {
541
- let store = stores.store;
542
- if (pageInfo.isClientPaging) {
543
- store = getPagingData();
544
- }
545
- const isSingleMode = () => checkInfo.useCheckbox.mode === 'single';
546
- const unCheckHeader = () => {
547
- if (checkInfo.isHeaderChecked) {
548
- checkInfo.isHeaderChecked = false;
549
- }
550
- };
551
- const onSingleMode = () => {
552
- if (isSingleMode() && checkInfo.checkedRows.length > 0) {
553
- checkInfo.prevCheckedRow.checked = false;
554
- unCheckedRow(checkInfo.prevCheckedRow);
555
- }
556
- };
557
- const addCheckedRow = (row) => {
558
- if (isSingleMode()) {
559
- checkInfo.checkedRows = [row];
560
- return;
561
- }
562
- onCheckChildren(row);
563
- onCheckParent(row);
564
- checkInfo.checkedRows.push(row);
565
- row.indeterminate = false;
566
- };
567
- const removeCheckedRow = (row) => {
568
- if (isSingleMode()) {
569
- checkInfo.checkedRows = [];
570
- return;
571
- }
572
- checkInfo.checkedRows = checkInfo.checkedRows.filter(it => it.index !== row.index);
573
- };
574
-
575
- onSingleMode();
576
- if (rowData.checked) {
577
- addCheckedRow(rowData);
578
- checkHeader(store);
579
- } else {
580
- unCheckHeader();
581
- removeCheckedRow(rowData);
582
- onCheckChildren(rowData);
583
- onCheckParent(rowData);
584
- }
585
- checkInfo.prevCheckedRow = rowData;
586
- emit('update:checked', checkInfo.checkedRows);
587
- emit('check-row', event, rowData.index, rowData);
588
- };
589
- /**
590
- * all checkbox click 이벤트를 처리한다.
591
- *
592
- * @param {object} event - 이벤트 객체
593
- */
594
- const onCheckAll = (event) => {
595
- const status = checkInfo.isHeaderChecked;
596
- let store = stores.store?.filter(row => row.isFilter);
597
- if (pageInfo.isClientPaging) {
598
- store = getPagingData();
599
- }
600
- store.forEach((row) => {
601
- row.checked = status && !row.uncheckable;
602
- if (row.checked) {
603
- if (!checkInfo.checkedRows.find(checked => checked.index === row.index)) {
604
- checkInfo.checkedRows.push(row);
605
- }
606
- } else {
607
- checkInfo.checkedRows = checkInfo.checkedRows
608
- .filter(checked => checked.index !== row.index);
609
- }
610
- row.indeterminate = false;
611
- });
612
- checkInfo.isHeaderIndeterminate = false;
613
- emit('update:checked', checkInfo.checkedRows);
614
- emit('check-all', event, checkInfo.checkedRows);
615
- };
616
- return { onCheck, onCheckAll };
617
- };
618
-
619
- export const contextMenuEvent = (params) => {
620
- const { emit } = getCurrentInstance();
621
- const {
622
- contextInfo,
623
- stores,
624
- selectInfo,
625
- useGridSetting,
626
- columnSettingInfo,
627
- setColumnHidden,
628
- onSort,
629
- } = params;
630
- /**
631
- * 컨텍스트 메뉴를 설정한다.
632
- *
633
- * @param {boolean} useCustom - 사용자 지정 메뉴 사용 유무
634
- */
635
- const setContextMenu = (useCustom = true) => {
636
- const menuItems = [];
637
-
638
- if (useCustom && contextInfo.customContextMenu.length) {
639
- const row = selectInfo.selectedRow;
640
- const customItems = contextInfo.customContextMenu.map(
641
- (item) => {
642
- const menuItem = item;
643
- if (menuItem.validate) {
644
- menuItem.disabled = !menuItem.validate(menuItem.itemId, row);
645
- }
646
-
647
- menuItem.selectedRow = row ?? [];
648
-
649
- return menuItem;
650
- });
651
-
652
- menuItems.push(...customItems);
653
- }
654
- contextInfo.contextMenuItems = menuItems;
655
- };
656
- const onColumnContextMenu = (event, column) => {
657
- if (event.target.className.includes('column-name')) {
658
- const sortable = !!column.sortable;
659
- contextInfo.columnMenuItems = [
660
- {
661
- text: contextInfo.columnMenuTextInfo?.hide ?? 'Hide',
662
- iconClass: 'ev-icon-visibility-off',
663
- disabled: !useGridSetting.value || stores.orderedColumns.length === 1 || !!column.fixed,
664
- hidden: contextInfo.hiddenColumnMenuItem?.hide || !useGridSetting.value,
665
- click: () => {
666
- setColumnHidden(column.field);
667
- emit('change-column-status', {
668
- columns: stores.updatedColumns,
669
- });
670
- emit('change-column-info', {
671
- type: 'display',
672
- columns: stores.updatedColumns,
673
- });
674
- },
675
- },
676
- {
677
- text: contextInfo.columnMenuTextInfo?.ascending ?? 'Ascending',
678
- iconClass: 'ev-icon-allow2-up',
679
- disabled: !sortable,
680
- hidden: contextInfo.hiddenColumnMenuItem?.ascending,
681
- click: () => onSort(column, 'asc'),
682
- },
683
- {
684
- text: contextInfo.columnMenuTextInfo?.descending ?? 'Descending',
685
- iconClass: 'ev-icon-allow2-down',
686
- disabled: !sortable,
687
- hidden: contextInfo.hiddenColumnMenuItem?.descending,
688
- click: () => onSort(column, 'desc'),
689
- },
690
- ];
691
- } else {
692
- contextInfo.columnMenuItems.length = 0;
693
- }
694
- };
695
- /**
696
- * 마우스 우클릭 이벤트를 처리한다.
697
- *
698
- * @param {object} event - 이벤트 객체
699
- */
700
- const onContextMenu = (event) => {
701
- const target = event.target;
702
- const rowIndex = target.closest('.row')?.dataset?.index;
703
-
704
- if (rowIndex) {
705
- const index = stores.viewStore.findIndex(v => v.index === Number(rowIndex));
706
- const rowData = stores.viewStore[index];
707
- selectInfo.selectedRow = [rowData];
708
- setContextMenu();
709
- emit('update:selected', selectInfo.selectedRow);
710
- } else {
711
- selectInfo.selectedRow = [];
712
- setContextMenu(false);
713
- emit('update:selected', []);
714
- }
715
- };
716
- /**
717
- * 상단 우측의 Grid 옵션에 대한 Contextmenu 를 생성한다.
718
- *
719
- * @param {object} e - 이벤트 객체
720
- */
721
- const onGridSettingContextMenu = (e) => {
722
- const { useDefaultColumnSetting, columnSettingTextInfo } = columnSettingInfo;
723
- const columnListMenu = {
724
- text: columnSettingTextInfo?.title ?? 'Column List',
725
- isShowMenu: true,
726
- click: () => {
727
- columnSettingInfo.isShowColumnSetting = true;
728
- contextInfo.isShowMenuOnClick = true;
729
- },
730
- };
731
-
732
- if (contextInfo.customGridSettingContextMenu.length) {
733
- contextInfo.gridSettingContextMenuItems = [
734
- ...contextInfo.customGridSettingContextMenu,
735
- ];
736
- }
737
-
738
- if (useDefaultColumnSetting) {
739
- contextInfo.gridSettingContextMenuItems.push(columnListMenu);
740
- }
741
- contextInfo.gridSettingMenu.show(e);
742
- };
743
- return {
744
- setContextMenu,
745
- onContextMenu,
746
- onColumnContextMenu,
747
- onGridSettingContextMenu,
748
- };
749
- };
750
-
751
- export const treeEvent = (params) => {
752
- const { emit } = getCurrentInstance();
753
- const { stores, onResize } = params;
754
- const setTreeNodeStore = () => {
755
- let nodeIndex = 0;
756
- const nodeList = [];
757
-
758
- function getDataObj(nodeObj) {
759
- const newObj = {};
760
- Object.keys(nodeObj).forEach((key) => {
761
- if (key !== 'children') {
762
- newObj[key] = nodeObj[key];
763
- }
764
- });
765
- return newObj;
766
- }
767
-
768
- function setNodeData(nodeInfo) {
769
- const { node, level, isShow, parent, uncheckable } = nodeInfo;
770
- if (node !== null && typeof node === 'object') {
771
- node.index = nodeIndex++;
772
- node.level = level;
773
-
774
- if (!Object.hasOwnProperty.call(node, 'checked')) {
775
- node.checked = false;
776
- }
777
-
778
- if (!Object.hasOwnProperty.call(node, 'selected')) {
779
- node.selected = false;
780
- }
781
-
782
- if (!Object.hasOwnProperty.call(node, 'show')) {
783
- node.show = isShow;
784
- }
785
-
786
- if (!Object.hasOwnProperty.call(node, 'expand')) {
787
- node.expand = true;
788
- }
789
-
790
- if (!Object.hasOwnProperty.call(node, 'isFilter')) {
791
- node.isFilter = false;
792
- }
793
-
794
- if (!Object.hasOwnProperty.call(node, 'uncheckable')) {
795
- node.uncheckable = uncheckable;
796
- }
797
-
798
- if (!Object.hasOwnProperty.call(node, 'indeterminate')) {
799
- node.indeterminate = false;
800
- }
801
-
802
- if (!Object.hasOwnProperty.call(node, 'data')) {
803
- node.data = getDataObj(node);
804
- }
805
-
806
- nodeList.push(node);
807
-
808
- if (!Object.hasOwnProperty.call(node, 'parent')) {
809
- node.parent = parent;
810
- }
811
- if (node.children) {
812
- node.hasChild = true;
813
- node.children.forEach(child =>
814
- setNodeData({
815
- node: child,
816
- level: level + 1,
817
- isShow: node.show && node.expand,
818
- parent: node,
819
- uncheckable: node.uncheckable,
820
- }),
821
- );
822
- }
823
- }
824
- }
825
- stores.treeRows.forEach((root) => {
826
- setNodeData({
827
- node: root,
828
- level: 0,
829
- isShow: true,
830
- parent: undefined,
831
- uncheckable: false,
832
- });
833
- });
834
- return nodeList;
835
- };
836
- const setExpandNode = (children, isShow, isFilter) => {
837
- children.forEach((nodeObj) => {
838
- const node = nodeObj;
839
- node.show = isFilter && isShow ? node.isFilter : isShow;
840
- if (node.hasChild) {
841
- setExpandNode(node.children, node.show && node.expand, node.isFilter);
842
- }
843
- });
844
- };
845
- const handleExpand = (node) => {
846
- const isExpand = !node.expand;
847
- const data = node;
848
- data.expand = !data.expand;
849
- setExpandNode(data.children, data.expand, data.isFilter);
850
- emit('toggle-row', { row: data, isExpand });
851
- onResize();
852
- };
853
- return { setTreeNodeStore, handleExpand };
854
- };
855
-
856
- export const filterEvent = (params) => {
857
- const {
858
- stores,
859
- filterInfo,
860
- pageInfo,
861
- getConvertValue,
862
- onResize,
863
- checkHeader,
864
- getPagingData,
865
- updatePagingInfo,
866
- } = params;
867
- const makeParentShow = (data) => {
868
- if (!data?.parent) {
869
- return;
870
- }
871
- const { parent } = data;
872
- parent.show = true;
873
- parent.isFilter = true;
874
- makeParentShow(parent);
875
- };
876
- const makeChildShow = (data) => {
877
- if (!data?.children) {
878
- return;
879
- }
880
- const { children } = data;
881
- children.forEach((node) => {
882
- const childNode = node;
883
- if (childNode.parent.show && childNode.parent.expand) {
884
- childNode.show = true;
885
- } else {
886
- childNode.show = false;
887
- }
888
- childNode.isFilter = true;
889
- if (childNode.hasChild) {
890
- makeChildShow(childNode);
891
- }
892
- });
893
- };
894
- let timer = null;
895
- const onSearch = (searchWord) => {
896
- if (timer) {
897
- clearTimeout(timer);
898
- }
899
- timer = setTimeout(() => {
900
- filterInfo.isSearch = false;
901
- filterInfo.searchWord = searchWord;
902
- const store = stores.treeStore;
903
- store.forEach((row) => {
904
- row.show = false;
905
- row.isFilter = false;
906
- });
907
- if (searchWord) {
908
- const filterStores = store.filter((row) => {
909
- let isSameWord = false;
910
- for (let ix = 0; ix < stores.orderedColumns.length; ix++) {
911
- const column = stores.orderedColumns[ix] || {};
912
- let columnValue = row[column.field] ?? null;
913
- column.type = column.type || 'string';
914
- if (columnValue !== null) {
915
- if (!column.hide && (column?.searchable === undefined || column?.searchable)) {
916
- columnValue = getConvertValue(column, columnValue).toString();
917
- isSameWord = columnValue.toLowerCase()
918
- .includes(searchWord.toString().toLowerCase());
919
- if (isSameWord) {
920
- break;
921
- }
922
- }
923
- }
924
- }
925
- return isSameWord;
926
- });
927
- filterStores.forEach((row) => {
928
- row.show = true;
929
- if (row.parent && !row.parent.expand) {
930
- row.show = false;
931
- }
932
- row.isFilter = true;
933
- makeParentShow(row);
934
- makeChildShow(row);
935
- });
936
- filterInfo.isSearch = true;
937
- } else {
938
- store.forEach((row) => {
939
- row.show = true;
940
- row.isFilter = false;
941
- });
942
- store.forEach((row) => {
943
- makeParentShow(row);
944
- makeChildShow(row);
945
- });
946
- }
947
- if (!searchWord && pageInfo.isClientPaging && pageInfo.prevPage) {
948
- pageInfo.currentPage = 1;
949
- stores.pagingStore = getPagingData();
950
- }
951
- updatePagingInfo({ onSearch: true });
952
- checkHeader(stores.store);
953
- onResize();
954
- }, 500);
955
- };
956
- return { onSearch };
957
- };
958
-
959
- export const pagingEvent = (params) => {
960
- const { emit } = getCurrentInstance();
961
- const {
962
- stores,
963
- pageInfo,
964
- sortInfo,
965
- filterInfo,
966
- elementInfo,
967
- clearCheckInfo,
968
- } = params;
969
- const getPagingData = () => {
970
- const start = (pageInfo.currentPage - 1) * pageInfo.perPage;
971
- const end = parseInt(start, 10) + parseInt(pageInfo.perPage, 10);
972
- return stores.showTreeStore.slice(start, end);
973
- };
974
- const updatePagingInfo = (eventName) => {
975
- emit('page-change', {
976
- eventName,
977
- pageInfo: {
978
- currentPage: pageInfo.currentPage,
979
- prevPage: pageInfo.prevPage,
980
- startIndex: pageInfo.startIndex,
981
- total: pageInfo.pageTotal,
982
- perPage: pageInfo.perPage,
983
- },
984
- sortInfo: {
985
- field: sortInfo.sortField,
986
- order: sortInfo.sortOrder,
987
- },
988
- searchInfo: {
989
- searchWord: filterInfo.searchWord,
990
- searchColumns: stores.orderedColumns
991
- .filter(c => !c.hide && (c?.searchable === undefined || c?.searchable))
992
- .map(d => d.field),
993
- },
994
- });
995
- if (pageInfo.isInfinite && (eventName?.onSearch || eventName?.onSort)) {
996
- pageInfo.currentPage = 1;
997
- elementInfo.body.scrollTop = 0;
998
- clearCheckInfo();
999
- }
1000
- };
1001
- const changePage = (beforeVal) => {
1002
- if (pageInfo.isClientPaging) {
1003
- pageInfo.prevPage = beforeVal;
1004
- if (stores.showTreeStore.length <= pageInfo.perPage) {
1005
- stores.pagingStore = stores.showTreeStore;
1006
- } else {
1007
- const start = (pageInfo.currentPage - 1) * pageInfo.perPage;
1008
- const end = parseInt(start, 10) + parseInt(pageInfo.perPage, 10);
1009
- stores.pagingStore = stores.showTreeStore.slice(start, end);
1010
- elementInfo.body.scrollTop = 0;
1011
- pageInfo.startIndex = start;
1012
- }
1013
- }
1014
- updatePagingInfo({ onChangePage: true });
1015
- };
1016
- return { getPagingData, updatePagingInfo, changePage };
1017
- };
1018
-
1019
- export const sortEvent = ({ sortInfo, stores }) => {
1020
- const { emit } = getCurrentInstance();
1021
-
1022
- const getDefaultSortType = (includeInit = true) => (includeInit ? ['asc', 'desc', 'init'] : ['asc', 'desc']);
1023
-
1024
- function OrderQueue() {
1025
- this.orders = getDefaultSortType();
1026
- this.dequeue = () => this.orders.shift();
1027
- this.enqueue = o => this.orders.push(o);
1028
- }
1029
-
1030
- const setSortOptionToOrderedColumns = (column, sortType = 'init') => {
1031
- stores.orderedColumns.forEach((orderedColumn) => {
1032
- if (orderedColumn.index === column?.index && sortType) {
1033
- orderedColumn.sortOption = { sortType };
1034
- } else {
1035
- orderedColumn.sortOption = { sortType: 'init' };
1036
- }
1037
- });
1038
- };
1039
-
1040
- const initializeHiddenColumnsSortType = () => {
1041
- const hiddenColumns = stores.originColumns.filter(col => col.hiddenDisplay || col.hide);
1042
- if (hiddenColumns.length) {
1043
- hiddenColumns.forEach((col) => {
1044
- col.sortOption = { sortType: 'init' };
1045
- });
1046
- }
1047
- };
1048
-
1049
- const order = new OrderQueue();
1050
-
1051
- const initSortInfo = (columns) => {
1052
- sortInfo.isSorting = false;
1053
- sortInfo.sortOrder = 'init';
1054
- columns.forEach((col) => {
1055
- if (col?.sortOption?.sortType && col.sortOption.sortType !== 'init') {
1056
- col.sortOption.sortType = 'init';
1057
- }
1058
- });
1059
- };
1060
-
1061
- const setSortInfo = (columns, emitTriggered = true) => {
1062
- const sortByColumnIndex = columns?.findIndex(col => col?.sortable && col?.sortOption?.sortType && col.sortOption.sortType !== 'init');
1063
- const sortByColumn = columns[sortByColumnIndex];
1064
- if (sortByColumnIndex > -1) {
1065
- sortByColumn.index = sortByColumnIndex;
1066
- }
1067
- const { sortType } = sortByColumn?.sortOption || {};
1068
-
1069
- sortInfo.sortColumn = sortByColumn;
1070
- sortInfo.sortField = sortByColumn?.field;
1071
- sortInfo.isSorting = !!(sortType);
1072
- sortInfo.sortOrder = sortType;
1073
-
1074
- setSortOptionToOrderedColumns(sortByColumn, sortType);
1075
-
1076
- if (emitTriggered) {
1077
- emit('change-column-info', {
1078
- type: 'sort',
1079
- columns: getUpdatedColumns(stores),
1080
- });
1081
- }
1082
- };
1083
-
1084
- /* 24.11.09 Tree Grid Sort 로직 임시 제거 */
1085
- // const compareValues = (nodeA, nodeB) => {
1086
- // const valueA = nodeA.data[sortInfo.sortField];
1087
- // const valueB = nodeB.data[sortInfo.sortField];
1088
- //
1089
- // if (valueA === valueB) return 0;
1090
- //
1091
- // const isAscending = sortInfo.sortOrder === 'asc';
1092
- //
1093
- // if (isAscending) return valueA > valueB ? 1 : -1;
1094
- //
1095
- // return valueA < valueB ? 1 : -1;
1096
- // };
1097
- //
1098
- // const sortTree = (nodes, depth = 0) => {
1099
- // const groupedNodes = {};
1100
- //
1101
- // nodes.forEach((node) => {
1102
- // const nodeDepth = node.level || depth;
1103
- // if (!groupedNodes[nodeDepth]) {
1104
- // groupedNodes[nodeDepth] = [];
1105
- // }
1106
- // groupedNodes[nodeDepth].push(node);
1107
- // });
1108
- //
1109
- // Object.keys(groupedNodes).forEach((key) => {
1110
- // groupedNodes[key].sort(compareValues);
1111
- // });
1112
- //
1113
- // nodes.length = 0;
1114
- // Object.values(groupedNodes).forEach((group) => {
1115
- // group.forEach((node) => {
1116
- // nodes.push(node);
1117
- // if (node.hasChild) {
1118
- // sortTree(node.children, node.level + 1);
1119
- // }
1120
- // });
1121
- // });
1122
- // };
1123
-
1124
- const onSort = (column, sortOrder) => {
1125
- const isSortableColumn = column.sortable === undefined ? true : column.sortable;
1126
- if (isSortableColumn) {
1127
- sortInfo.sortColumn = column;
1128
-
1129
- if (sortInfo.sortField !== column?.field) {
1130
- order.orders = getDefaultSortType();
1131
- sortInfo.sortField = column?.field;
1132
- }
1133
-
1134
- if (sortOrder) {
1135
- order.orders = getDefaultSortType();
1136
- if (sortOrder === 'desc') {
1137
- sortInfo.sortOrder = order.dequeue();
1138
- order.enqueue(sortInfo.sortOrder);
1139
- }
1140
- }
1141
-
1142
- sortInfo.sortOrder = order.dequeue();
1143
- order.enqueue(sortInfo.sortOrder);
1144
-
1145
- initializeHiddenColumnsSortType();
1146
- setSortOptionToOrderedColumns(column, sortInfo.sortOrder);
1147
-
1148
- const updatedColumInfo = getUpdatedColumns(stores);
1149
-
1150
- emit('sort-column', {
1151
- field: sortInfo.sortField,
1152
- order: sortInfo.sortOrder,
1153
- column: sortInfo.sortColumn,
1154
- columns: updatedColumInfo,
1155
- });
1156
-
1157
- emit('change-column-info', {
1158
- type: 'sort',
1159
- columns: updatedColumInfo,
1160
- });
1161
-
1162
- /* 24.11.09 Tree Grid Sort 로직 임시 제거 */
1163
- // if (sortInfo.sortOrder === 'init') {
1164
- // stores.treeStore = cloneDeep(stores.originStore);
1165
- // stores.viewStore = stores.treeStore;
1166
- // onResize();
1167
- // sortInfo.isSorting = false;
1168
- // } else {
1169
- // sortTree(stores.treeRows);
1170
- // sortInfo.isSorting = true;
1171
- // }
1172
- //
1173
- // updatePagingInfo({ onSort: true });
1174
- }
1175
- };
1176
-
1177
- return { onSort, setSortInfo, initSortInfo };
1178
- };