quasar-factory-lib 0.1.17 → 0.1.19
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.
- package/dist/components/Table/DraggableQTable.vue.d.ts +1521 -0
- package/dist/components/Table/Table.vue.d.ts +3 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/plugins.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/layouts/PdaLayout.vue.d.ts +3 -0
- package/dist/pages/TablePage.vue.d.ts +3 -0
- package/dist/quasar-factory-lib.js +1707 -1706
- package/dist/quasar-factory-lib.umd.cjs +12 -12
- package/package.json +1 -1
- package/src/components/Table/DraggableQTable.vue +565 -0
- package/src/components/Table/Table.vue +21 -22
- package/src/components/Table/components/TableSlotBody.vue +1 -0
- package/src/components/Table/components/TableSlotGrid.vue +1 -1
- package/src/components/Table/index.ts +3 -0
- package/src/components/plugins.ts +2 -1
- package/src/index.ts +3 -2
- package/src/layouts/PdaLayout.vue +318 -8
package/package.json
CHANGED
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
<template lang="">
|
|
2
|
+
<div>
|
|
3
|
+
<q-table
|
|
4
|
+
v-show="!showSkeleton"
|
|
5
|
+
ref="myTable"
|
|
6
|
+
v-model:selected="selected"
|
|
7
|
+
class="my-table"
|
|
8
|
+
:grid="smallDevice"
|
|
9
|
+
:style="tableStyle"
|
|
10
|
+
flat
|
|
11
|
+
:filter-method="customFilter"
|
|
12
|
+
bordered
|
|
13
|
+
:rows="rowsData"
|
|
14
|
+
:columns="columns"
|
|
15
|
+
:row-key="rowKey"
|
|
16
|
+
:rows-per-page-options="rowsPerPageOptions"
|
|
17
|
+
:selection="selectionType"
|
|
18
|
+
:visible-columns="visibleColumns"
|
|
19
|
+
table-class="text-grey-9"
|
|
20
|
+
table-header-class="main-color"
|
|
21
|
+
:filter="filterComputed"
|
|
22
|
+
:sort-method="customSortMethod"
|
|
23
|
+
separator="horizontal"
|
|
24
|
+
binary-state-sort
|
|
25
|
+
:selected-rows-label="getSelectedString"
|
|
26
|
+
:loading="loading"
|
|
27
|
+
pagination.sync="0"
|
|
28
|
+
:grid-header="showGridHeader"
|
|
29
|
+
@update:selected="(details) => {
|
|
30
|
+
$emit('onUpdateSelected', details)
|
|
31
|
+
}"
|
|
32
|
+
>
|
|
33
|
+
<template #top-right="props">
|
|
34
|
+
<q-separator />
|
|
35
|
+
<div
|
|
36
|
+
v-if="showIconAdvancedFilter"
|
|
37
|
+
class="q-pr-lg float-left cursor-pointer no-wrap row items-center"
|
|
38
|
+
data-cy="advanced-filters-button"
|
|
39
|
+
@click="() => {
|
|
40
|
+
showAdvancedFilter = !showAdvancedFilter
|
|
41
|
+
}"
|
|
42
|
+
>
|
|
43
|
+
<q-icon
|
|
44
|
+
:name="showAdvancedFilter ? 'filter_alt_off' : 'filter_alt'"
|
|
45
|
+
size="md"
|
|
46
|
+
class="cursor-pointer items-center"
|
|
47
|
+
/>
|
|
48
|
+
<span v-if="!smallDevice">
|
|
49
|
+
{{ $t('table.advancedFilters') }}
|
|
50
|
+
</span>
|
|
51
|
+
</div>
|
|
52
|
+
<TableFilter
|
|
53
|
+
v-if="getTableInputSearchVisibility && !hideFilter"
|
|
54
|
+
ref="filterInput"
|
|
55
|
+
class="q-pl-xs"
|
|
56
|
+
:table-props="props"
|
|
57
|
+
:store="store"
|
|
58
|
+
@input-focus="filterInputFocus"
|
|
59
|
+
/>
|
|
60
|
+
<TableColumnsSelector
|
|
61
|
+
v-if="getColumnsSelectorVisibility && !hideColumnsSelector "
|
|
62
|
+
class="q-pl-xs"
|
|
63
|
+
:table-props="props"
|
|
64
|
+
:columns="columns"
|
|
65
|
+
:visible-columns="visibleColumns"
|
|
66
|
+
@on-select-visible-columns="onSelectVisibleColumns"
|
|
67
|
+
/>
|
|
68
|
+
</template>
|
|
69
|
+
<template #header="props">
|
|
70
|
+
<TableSlotHeader
|
|
71
|
+
:table-props="props"
|
|
72
|
+
:selection-type="selectionType"
|
|
73
|
+
:small-device="smallDevice"
|
|
74
|
+
:show-advanced-filter="showAdvancedFilter"
|
|
75
|
+
:advancedFilters="advancedFiltersData"
|
|
76
|
+
:filteredRowsLength="filteredRows.length"
|
|
77
|
+
/>
|
|
78
|
+
</template>
|
|
79
|
+
<template #body="props">
|
|
80
|
+
<TableSlotBody
|
|
81
|
+
v-if="!showSkeleton"
|
|
82
|
+
:table-props="props"
|
|
83
|
+
:selection-type="selectionType"
|
|
84
|
+
:getCellClass="getCellClass"
|
|
85
|
+
@on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
|
|
86
|
+
@on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
|
|
87
|
+
@on-save-value-popup-edit="onSaveValuePopupEdit"
|
|
88
|
+
@on-click-button="onClickButton"
|
|
89
|
+
@on-click-icon-tool-tip="onClickIconToolTip"
|
|
90
|
+
@click="onRowClick(props.row)"
|
|
91
|
+
/>
|
|
92
|
+
</template>
|
|
93
|
+
<template #item="props">
|
|
94
|
+
<TableSlotGrid
|
|
95
|
+
v-if="!showSkeleton"
|
|
96
|
+
:table-props="props"
|
|
97
|
+
:selection-type="selectionType"
|
|
98
|
+
:popup-edit-number-options="popupEditNumberOptions"
|
|
99
|
+
:getCellClass="getCellClass"
|
|
100
|
+
@on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
|
|
101
|
+
@on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
|
|
102
|
+
@on-save-value-popup-edit="onSaveValuePopupEdit"
|
|
103
|
+
@on-click-button="onClickButton"
|
|
104
|
+
@on-click-icon-tool-tip="onClickIconToolTip"
|
|
105
|
+
@click="onRowClick(props.row)"
|
|
106
|
+
/>
|
|
107
|
+
</template>
|
|
108
|
+
</q-table>
|
|
109
|
+
<TableSkeleton
|
|
110
|
+
v-show="getTableSkeletonVisibility"
|
|
111
|
+
id="tableSkeleton"
|
|
112
|
+
/>
|
|
113
|
+
<CardListSkeleton
|
|
114
|
+
v-show="getGridSkeletonVisibility"
|
|
115
|
+
id="cardListSkeleton"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
<script lang="ts">
|
|
120
|
+
import { defineComponent } from 'vue'
|
|
121
|
+
import TableSlotHeader from './components/TableSlotHeader.vue'
|
|
122
|
+
import TableColumnsSelector from './components/TableColumnsSelector.vue'
|
|
123
|
+
import TableSlotBody from './components/TableSlotBody.vue'
|
|
124
|
+
import TableSlotGrid from './components/TableSlotGrid.vue'
|
|
125
|
+
import TableFilter from './components/TableFilter.vue'
|
|
126
|
+
import TableSkeleton from './components/TableSkeleton.vue'
|
|
127
|
+
import CardListSkeleton from './components/CardListSkeleton.vue'
|
|
128
|
+
import {useDraggable} from 'vue-draggable-plus'
|
|
129
|
+
|
|
130
|
+
export default defineComponent({
|
|
131
|
+
components: {
|
|
132
|
+
TableSlotHeader,
|
|
133
|
+
TableColumnsSelector,
|
|
134
|
+
TableSlotBody,
|
|
135
|
+
TableSlotGrid,
|
|
136
|
+
TableFilter,
|
|
137
|
+
TableSkeleton,
|
|
138
|
+
CardListSkeleton
|
|
139
|
+
},
|
|
140
|
+
props: {
|
|
141
|
+
columns: {
|
|
142
|
+
type: Array as () => object[],
|
|
143
|
+
required: true
|
|
144
|
+
},
|
|
145
|
+
rows: {
|
|
146
|
+
type: Array as () => object[],
|
|
147
|
+
required: true
|
|
148
|
+
},
|
|
149
|
+
visibleColumns: {
|
|
150
|
+
type: Array as () => string[],
|
|
151
|
+
required: true
|
|
152
|
+
},
|
|
153
|
+
selectionType: {
|
|
154
|
+
type: String as () => 'none' | 'single' | 'multiple',
|
|
155
|
+
default: 'none'
|
|
156
|
+
},
|
|
157
|
+
rowKey: {
|
|
158
|
+
type: String,
|
|
159
|
+
default: 'id'
|
|
160
|
+
},
|
|
161
|
+
tableStyle: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: ''
|
|
164
|
+
},
|
|
165
|
+
popupEditNumberOptions: {
|
|
166
|
+
type: Array,
|
|
167
|
+
default: () => []
|
|
168
|
+
},
|
|
169
|
+
smallDevice: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
required: true
|
|
172
|
+
},
|
|
173
|
+
store: {
|
|
174
|
+
type: Object,
|
|
175
|
+
required: true
|
|
176
|
+
},
|
|
177
|
+
tableId: {
|
|
178
|
+
type: String,
|
|
179
|
+
default: ''
|
|
180
|
+
},
|
|
181
|
+
hideColumnsSelector: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
default: false
|
|
184
|
+
},
|
|
185
|
+
hideFilter: {
|
|
186
|
+
type: Boolean,
|
|
187
|
+
default: false
|
|
188
|
+
},
|
|
189
|
+
showSkeleton: {
|
|
190
|
+
type: Boolean
|
|
191
|
+
},
|
|
192
|
+
getCellClass: {
|
|
193
|
+
type: Function,
|
|
194
|
+
default: function () {}
|
|
195
|
+
},
|
|
196
|
+
// Needs to be used with additionalFilterConditions and additionalSortConditions
|
|
197
|
+
filterComputedOptions: {
|
|
198
|
+
type: Object,
|
|
199
|
+
default: {}
|
|
200
|
+
},
|
|
201
|
+
additionalFilterConditions: {
|
|
202
|
+
type: Function,
|
|
203
|
+
default: function () {}
|
|
204
|
+
},
|
|
205
|
+
additionalSortConditions: {
|
|
206
|
+
type: Function,
|
|
207
|
+
default: function () {}
|
|
208
|
+
},
|
|
209
|
+
showIconAdvancedFilter: {
|
|
210
|
+
type: Boolean,
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
rowsPerPageOptions: {
|
|
214
|
+
type: Array,
|
|
215
|
+
default: () => [0]
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
emits: [
|
|
220
|
+
'onSelectVisibleColumns',
|
|
221
|
+
'onUpdateBasicCheckboxValue',
|
|
222
|
+
'onUpdateCustomizedCheckboxValue',
|
|
223
|
+
'onSaveValuePopupEdit',
|
|
224
|
+
'onClickButton',
|
|
225
|
+
'storeUpdated',
|
|
226
|
+
'deleteItem',
|
|
227
|
+
'openModalWithTable',
|
|
228
|
+
'setItemNotFound',
|
|
229
|
+
'onClickSeeTaskDetails',
|
|
230
|
+
'startMaintenanceTicket',
|
|
231
|
+
'pauseMaintenanceTicket',
|
|
232
|
+
'finishMaintenanceTicket',
|
|
233
|
+
'onRowClick',
|
|
234
|
+
'onClickIconToolTip',
|
|
235
|
+
'onUpdateSelected',
|
|
236
|
+
'setLineRemainingQty',
|
|
237
|
+
'setLineNoStock',
|
|
238
|
+
'onDoneLineMaintenanceTasks',
|
|
239
|
+
'reprintSULabel',
|
|
240
|
+
'onDragStart',
|
|
241
|
+
'onDragUpdate',
|
|
242
|
+
'onDragEnd',
|
|
243
|
+
'modifyPriorityOrder',
|
|
244
|
+
'onClickRowBtnPrintOP',
|
|
245
|
+
'getPOFromWorkCenter',
|
|
246
|
+
'getProductionTimesMachineCenter',
|
|
247
|
+
'operatorMachineAssignmentAssignMachine',
|
|
248
|
+
'operatorMachineAssignmentSetDate',
|
|
249
|
+
'operatorMachineAssignmentSetPartialMachineCenter',
|
|
250
|
+
'operatorMachineAssignmentSeeDetail',
|
|
251
|
+
'onClickOpenDialogOperators'
|
|
252
|
+
|
|
253
|
+
],
|
|
254
|
+
data () {
|
|
255
|
+
return {
|
|
256
|
+
selected: [],
|
|
257
|
+
filter: '',
|
|
258
|
+
rowsData: [] as object[],
|
|
259
|
+
gridRowsSelected: false,
|
|
260
|
+
selectedRows: [] as number[],
|
|
261
|
+
showColumnsSelector: false,
|
|
262
|
+
showSearch: false,
|
|
263
|
+
loading: false,
|
|
264
|
+
forceRender: false,
|
|
265
|
+
totalPage: 0,
|
|
266
|
+
pageSize: 20,
|
|
267
|
+
filteredRows: [] as object [] | [],
|
|
268
|
+
showAdvancedFilter: false,
|
|
269
|
+
advancedFiltersData: {},
|
|
270
|
+
tableRef: null,
|
|
271
|
+
draggableInstance: null,
|
|
272
|
+
disabled: false,
|
|
273
|
+
enableDragAndDrop: false,
|
|
274
|
+
dragAndDropDelay: 0
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
computed: {
|
|
278
|
+
getColumnsSelectorVisibility () {
|
|
279
|
+
return !this.smallDevice || this.showColumnsSelector
|
|
280
|
+
},
|
|
281
|
+
getTableInputSearchVisibility () {
|
|
282
|
+
return !this.smallDevice || this.showSearch
|
|
283
|
+
},
|
|
284
|
+
showGridHeader () {
|
|
285
|
+
return this.selectionType === 'multiple' || this.showAdvancedFilter
|
|
286
|
+
},
|
|
287
|
+
getTableSkeletonVisibility () {
|
|
288
|
+
return !this.smallDevice && this.showSkeleton
|
|
289
|
+
},
|
|
290
|
+
getGridSkeletonVisibility () {
|
|
291
|
+
return this.smallDevice && this.showSkeleton
|
|
292
|
+
},
|
|
293
|
+
filterComputed ():object {
|
|
294
|
+
return {
|
|
295
|
+
search: this.store.filterValue,
|
|
296
|
+
forceRender: this.forceRender,
|
|
297
|
+
...this.filterComputedOptions
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
pageLength (): number {
|
|
301
|
+
return (this.totalPage + 1) * this.pageSize
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
watch: {
|
|
305
|
+
rows (val) {
|
|
306
|
+
this.rowsData = val
|
|
307
|
+
},
|
|
308
|
+
showAdvancedFilter (val: boolean): void {
|
|
309
|
+
if (!val) {
|
|
310
|
+
this.advancedFiltersData = {}
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
enableDragAndDrop (val): void {
|
|
314
|
+
if (val) {
|
|
315
|
+
this.enableDragAndDropFunc()
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
smallDevice (val): void {
|
|
319
|
+
if(val) {
|
|
320
|
+
this.dragAndDropDelay = 200
|
|
321
|
+
} else {
|
|
322
|
+
this.dragAndDropDelay = 0
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
/* showSkeleton (val: boolean): void {
|
|
326
|
+
if (!val) {
|
|
327
|
+
this.handleInfiniteScrollTableCompositionAPi()
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
'$q.screen.width' (): void {
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
this.handleInfiniteScrollTableCompositionAPi()
|
|
333
|
+
}, 500)
|
|
334
|
+
} */
|
|
335
|
+
},
|
|
336
|
+
mounted () {
|
|
337
|
+
this.getAdvancedFilterColumns()
|
|
338
|
+
},
|
|
339
|
+
methods: {
|
|
340
|
+
enableDragAndDropFunc (): void {
|
|
341
|
+
this.dragAndDropDelay = this.smallDevice ? 200: 0
|
|
342
|
+
if (this.smallDevice) {
|
|
343
|
+
this.tableRef = document.querySelector('.q-table__grid-content')
|
|
344
|
+
} else {
|
|
345
|
+
this.tableRef = document.querySelector('.q-table tbody')
|
|
346
|
+
}
|
|
347
|
+
const self = this
|
|
348
|
+
if (this.draggableInstance?.destroy) {
|
|
349
|
+
this.draggableInstance.destroy()
|
|
350
|
+
}
|
|
351
|
+
if (this.tableRef) {
|
|
352
|
+
this.draggableInstance = useDraggable(this.tableRef, this.rows, {
|
|
353
|
+
animation: 100,
|
|
354
|
+
delay: self.dragAndDropDelay,
|
|
355
|
+
|
|
356
|
+
onStart (e) {
|
|
357
|
+
self.$emit('onDragStart', e)
|
|
358
|
+
},
|
|
359
|
+
onUpdate (e) {
|
|
360
|
+
self.rowsData = [...self.rows]
|
|
361
|
+
self.$emit('onDragUpdate', e)
|
|
362
|
+
},
|
|
363
|
+
onEnd(e) {
|
|
364
|
+
self.$emit('onDragEnd', e)
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
getSelectedString (val: number): string {
|
|
370
|
+
const rowsSelectedLength = val
|
|
371
|
+
if (rowsSelectedLength === 0) {
|
|
372
|
+
return ''
|
|
373
|
+
}
|
|
374
|
+
const recordString = rowsSelectedLength > 1 ? 'records' : 'record'
|
|
375
|
+
return `${rowsSelectedLength} ${recordString} selected`
|
|
376
|
+
},
|
|
377
|
+
onSelectVisibleColumns (columns: string[]) {
|
|
378
|
+
this.$emit('onSelectVisibleColumns', columns)
|
|
379
|
+
},
|
|
380
|
+
onSaveValuePopupEdit (row: object) {
|
|
381
|
+
this.$emit('onSaveValuePopupEdit', row)
|
|
382
|
+
},
|
|
383
|
+
onUpdateBasicCheckboxValue (row: object) {
|
|
384
|
+
this.$emit('onUpdateBasicCheckboxValue', row)
|
|
385
|
+
},
|
|
386
|
+
onClickButton (emit: 'onClickButton', row: object) {
|
|
387
|
+
this.$emit(emit, row)
|
|
388
|
+
},
|
|
389
|
+
onClickIconToolTip (emit: 'onClickIconToolTip', row: object) {
|
|
390
|
+
this.$emit(emit, row)
|
|
391
|
+
},
|
|
392
|
+
onRowClick (row: object) {
|
|
393
|
+
this.$emit('onRowClick', row)
|
|
394
|
+
},
|
|
395
|
+
deleteItem (row: object) {
|
|
396
|
+
this.$emit('deleteItem', row)
|
|
397
|
+
},
|
|
398
|
+
onUpdateCustomizedCheckboxValue (row: object) {
|
|
399
|
+
this.$emit('onUpdateCustomizedCheckboxValue', row)
|
|
400
|
+
},
|
|
401
|
+
clearTableSelection () {
|
|
402
|
+
this.selected = []
|
|
403
|
+
},
|
|
404
|
+
toggleSearchVisibility (store: { lastFilterValue: string, valueInputFilterTable: string }) {
|
|
405
|
+
this.showSearch = !this.showSearch
|
|
406
|
+
store.lastFilterValue = ''
|
|
407
|
+
store.valueInputFilterTable = ''
|
|
408
|
+
},
|
|
409
|
+
toogleColumnsSelectorVisibility () {
|
|
410
|
+
this.showColumnsSelector = !this.showColumnsSelector
|
|
411
|
+
},
|
|
412
|
+
filterInputFocus () {
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
if (this.$refs.filterInput) {
|
|
415
|
+
this.$refs.filterInput.inputFocus()
|
|
416
|
+
}
|
|
417
|
+
}, 10)
|
|
418
|
+
},
|
|
419
|
+
toogleLoading () {
|
|
420
|
+
this.loading = !this.loading
|
|
421
|
+
},
|
|
422
|
+
customSortMethod(rows: object[] | [], sortBy: string, descending: boolean) {
|
|
423
|
+
let data = []
|
|
424
|
+
if (this.store.filterValue !== '') {
|
|
425
|
+
data = [...this.filteredRows];
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
data = [...this.rows];
|
|
429
|
+
}
|
|
430
|
+
if (this.additionalSortConditions && this.additionalSortConditions.toString().replace(/\s+/g, '') !== 'function(){}') {
|
|
431
|
+
data = this.additionalSortConditions(this.filteredRows, rows);
|
|
432
|
+
}
|
|
433
|
+
this.getSortedData(sortBy, data, descending)
|
|
434
|
+
return data.slice(0, this.pageLength);
|
|
435
|
+
},
|
|
436
|
+
getSortedData (sortBy: string, data: object[] | [], descending: boolean) {
|
|
437
|
+
if (sortBy) {
|
|
438
|
+
data.sort((a, b) => {
|
|
439
|
+
const x = descending ? b : a;
|
|
440
|
+
const y = descending ? a : b;
|
|
441
|
+
|
|
442
|
+
const xValue = x[sortBy];
|
|
443
|
+
const yValue = y[sortBy];
|
|
444
|
+
|
|
445
|
+
const parseDate = (dateString: string): Date => {
|
|
446
|
+
const [day, month, year] = dateString.split('/');
|
|
447
|
+
return new Date(`${year}-${month}-${day}`);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
const parseTime = (timeString: string): number => {
|
|
451
|
+
const [hours, minutes, seconds] = timeString.split(':').map(Number);
|
|
452
|
+
return (hours * 3600) + (minutes * 60) + seconds;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const parsePercentage = (percentageString: string): number => {
|
|
456
|
+
return parseFloat(percentageString.replace('%', '')) / 100;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
if (typeof xValue === 'string' && typeof yValue === 'string') {
|
|
460
|
+
const xDate = parseDate(xValue);
|
|
461
|
+
const yDate = parseDate(yValue);
|
|
462
|
+
|
|
463
|
+
if (!isNaN(xDate.getTime()) && !isNaN(yDate.getTime())) {
|
|
464
|
+
return xDate.getTime() - yDate.getTime();
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const xTime = parseTime(xValue);
|
|
468
|
+
const yTime = parseTime(yValue);
|
|
469
|
+
|
|
470
|
+
if (!isNaN(xTime) && !isNaN(yTime)) {
|
|
471
|
+
return xTime - yTime;
|
|
472
|
+
} else if (xValue.includes('%') && yValue.includes('%')) {
|
|
473
|
+
const xPercent = parsePercentage(xValue);
|
|
474
|
+
const yPercent = parsePercentage(yValue);
|
|
475
|
+
return xPercent - yPercent;
|
|
476
|
+
} else {
|
|
477
|
+
return xValue.localeCompare(yValue);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else if (typeof xValue === 'number' && typeof yValue === 'number') {
|
|
481
|
+
return xValue - yValue;
|
|
482
|
+
}
|
|
483
|
+
else if (typeof xValue === 'boolean' && typeof yValue === 'boolean') {
|
|
484
|
+
console.log(xValue, yValue)
|
|
485
|
+
return xValue === yValue ? 0 : xValue ? 1 : -1;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
return String(xValue) > String(yValue) ? 1 : String(xValue) < String(yValue) ? -1 : 0;
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
containsSearchTermInRow (row: object, lowerSearch: string): boolean {
|
|
494
|
+
if (lowerSearch !== '') {
|
|
495
|
+
const values = Object.values(row)
|
|
496
|
+
const valuesLowerCase = values.map((x) => (x + '').toLowerCase())
|
|
497
|
+
for (let val = 0; val < valuesLowerCase.length; val++) {
|
|
498
|
+
if (valuesLowerCase[val].includes(lowerSearch)) {
|
|
499
|
+
return true
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return false
|
|
504
|
+
},
|
|
505
|
+
customFilter(rows: object[] | [], terms: { search: string, prepared: boolean }) {
|
|
506
|
+
let filteredRows_ = []
|
|
507
|
+
if (terms.search !== '') {
|
|
508
|
+
const lowerSearch = terms.search ? terms.search.toLowerCase() : ''
|
|
509
|
+
for (let i = 0; i < this.rows.length; i++) {
|
|
510
|
+
if (this.containsSearchTermInRow(this.rows[i], lowerSearch)) {
|
|
511
|
+
filteredRows_.push(this.rows[i])
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
filteredRows_ = rows
|
|
517
|
+
}
|
|
518
|
+
if (this.additionalFilterConditions && this.additionalFilterConditions.toString().replace(/\s+/g, '') !== 'function(){}') {
|
|
519
|
+
filteredRows_ = this.additionalFilterConditions(this.rows, filteredRows_)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (this.advancedFiltersData && Object.keys(this.advancedFiltersData).length > 0) {
|
|
523
|
+
filteredRows_ = filteredRows_.filter(row => {
|
|
524
|
+
return Object.keys(this.advancedFiltersData).every(key => {
|
|
525
|
+
const filterValue = this.advancedFiltersData[key]
|
|
526
|
+
if (filterValue === '' || filterValue === null || filterValue === undefined) {
|
|
527
|
+
return true
|
|
528
|
+
}
|
|
529
|
+
return String(row[key]).toLowerCase().includes(String(filterValue).toLowerCase())
|
|
530
|
+
})
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
this.filteredRows = filteredRows_
|
|
535
|
+
return filteredRows_.slice(0, this.pageLength)
|
|
536
|
+
},
|
|
537
|
+
getAdvancedFilterColumns (): void {
|
|
538
|
+
this.advancedFiltersData = this.columns.reduce((acc, column) => {
|
|
539
|
+
acc[column.name] = ''
|
|
540
|
+
return acc
|
|
541
|
+
}, {} as Record<string, string>)
|
|
542
|
+
},
|
|
543
|
+
handleInfiniteScrollTableCompositionAPi () {
|
|
544
|
+
// const offSet = this.showIconAdvancedFilter && this.smallDevice ? document.getElementsByClassName('q-table__control')[0].offsetHeight : 0
|
|
545
|
+
this.$nextTick(() => {
|
|
546
|
+
const elemClass = this.smallDevice ? 'q-table__grid-content' : 'q-table__middle scroll'
|
|
547
|
+
const tableType = this.smallDevice ? 'Grid' : 'Table'
|
|
548
|
+
const qtableScrollElem = document.getElementsByClassName(elemClass) as HTMLCollectionOf<HTMLElement>
|
|
549
|
+
const elementToScroll =
|
|
550
|
+
qtableScrollElem.length > 0 ? qtableScrollElem[0] : window
|
|
551
|
+
const fnAddScroll = (event: Event) => {
|
|
552
|
+
const { scrollHeight, scrollTop, clientHeight } = event.target as HTMLElement
|
|
553
|
+
if (Math.abs(scrollHeight - clientHeight - scrollTop) <= 1) {
|
|
554
|
+
console.log(`[${tableType}] You are at the bottom!`, this.totalPage)
|
|
555
|
+
this.totalPage++
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
window.removeEventListener('scroll', fnAddScroll)
|
|
559
|
+
elementToScroll.removeEventListener('scroll', fnAddScroll)
|
|
560
|
+
elementToScroll.addEventListener('scroll', fnAddScroll)
|
|
561
|
+
})
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
})
|
|
565
|
+
</script>
|