shared-ritm 1.2.55 → 1.2.57
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/index.css +1 -1
- package/dist/shared-ritm.es.js +3897 -3900
- package/dist/shared-ritm.umd.js +7 -7
- package/dist/types/api/types/Api_Controls.d.ts +6 -6
- package/dist/types/utils/helpers.d.ts +17 -0
- package/package.json +1 -1
- package/src/api/types/Api_Controls.ts +72 -72
- package/src/common/app-table/AppTable.vue +58 -61
- package/src/common/app-table/AppTableLayout.vue +22 -24
- package/src/common/app-table/components/TableModal.vue +123 -151
- package/src/common/app-table/components/TablePagination.vue +150 -151
- package/src/common/app-table/components/TableSearch.vue +76 -78
- package/src/common/app-table/controllers/useTableModel.ts +93 -93
- package/src/utils/helpers.ts +39 -0
|
@@ -1,151 +1,150 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
margin-
|
|
110
|
-
|
|
111
|
-
.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-pagination">
|
|
3
|
+
<button class="arrow-button" :disabled="modelValue <= 1" @click="prevPage">
|
|
4
|
+
<q-icon name="mdi-chevron-left" :color="modelValue <= 1 ? 'grey-4' : 'primary'" />
|
|
5
|
+
</button>
|
|
6
|
+
|
|
7
|
+
<div class="pages">
|
|
8
|
+
<button
|
|
9
|
+
v-for="page in pageArray"
|
|
10
|
+
:key="page"
|
|
11
|
+
class="page-button"
|
|
12
|
+
:class="{ selected: page === modelValue, ellipsis: page === '...' }"
|
|
13
|
+
:disabled="page === modelValue || page === '...'"
|
|
14
|
+
@click="changePage(page)"
|
|
15
|
+
>
|
|
16
|
+
{{ page }}
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<button class="arrow-button" :disabled="modelValue >= totalPages" @click="nextPage">
|
|
21
|
+
<q-icon name="mdi-chevron-right" :color="modelValue >= totalPages ? 'grey-4' : 'primary'" />
|
|
22
|
+
</button>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { computed } from 'vue'
|
|
27
|
+
import { defineProps, defineEmits } from 'vue'
|
|
28
|
+
|
|
29
|
+
const props = defineProps<{
|
|
30
|
+
modelValue: number
|
|
31
|
+
totalPages: number
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
(e: 'update:modelValue', value: number): void
|
|
36
|
+
(e: 'page-change', value: number): void
|
|
37
|
+
}>()
|
|
38
|
+
|
|
39
|
+
const currentPage = computed({
|
|
40
|
+
get: () => props.modelValue,
|
|
41
|
+
set: (val: number) => {
|
|
42
|
+
emit('update:modelValue', val)
|
|
43
|
+
emit('page-change', val)
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const pageArray = computed(() => {
|
|
48
|
+
const maxPagesToShow = 5
|
|
49
|
+
let startPage = 1
|
|
50
|
+
let endPage = props.totalPages
|
|
51
|
+
const pages: (number | string)[] = []
|
|
52
|
+
|
|
53
|
+
if (props.totalPages <= maxPagesToShow) {
|
|
54
|
+
for (let i = 1; i <= props.totalPages; i++) pages.push(i)
|
|
55
|
+
} else {
|
|
56
|
+
if (props.modelValue <= 3) {
|
|
57
|
+
startPage = 1
|
|
58
|
+
endPage = maxPagesToShow - 1
|
|
59
|
+
} else if (props.modelValue + 2 >= props.totalPages) {
|
|
60
|
+
startPage = props.totalPages - (maxPagesToShow - 2)
|
|
61
|
+
endPage = props.totalPages
|
|
62
|
+
} else {
|
|
63
|
+
startPage = props.modelValue - 2
|
|
64
|
+
endPage = props.modelValue + 2
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (let i = startPage; i <= endPage; i++) pages.push(i)
|
|
68
|
+
|
|
69
|
+
if (startPage > 1) {
|
|
70
|
+
pages.unshift('...')
|
|
71
|
+
pages.unshift(1)
|
|
72
|
+
}
|
|
73
|
+
if (endPage < props.totalPages) {
|
|
74
|
+
pages.push('...')
|
|
75
|
+
pages.push(props.totalPages)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return pages
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
function changePage(page: number | string) {
|
|
83
|
+
if (typeof page === 'number' && page !== props.modelValue) {
|
|
84
|
+
currentPage.value = page
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function prevPage() {
|
|
89
|
+
if (props.modelValue > 1) currentPage.value = props.modelValue - 1
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function nextPage() {
|
|
93
|
+
if (props.modelValue < props.totalPages) currentPage.value = props.modelValue + 1
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style scoped lang="scss">
|
|
98
|
+
.pages {
|
|
99
|
+
display: flex;
|
|
100
|
+
gap: 20px;
|
|
101
|
+
}
|
|
102
|
+
.table-pagination {
|
|
103
|
+
display: flex;
|
|
104
|
+
justify-content: start;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 20px;
|
|
107
|
+
flex-wrap: wrap;
|
|
108
|
+
margin-top: 17px;
|
|
109
|
+
margin-bottom: 15px;
|
|
110
|
+
.arrow-button,
|
|
111
|
+
.page-button {
|
|
112
|
+
width: 34px;
|
|
113
|
+
height: 34px;
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
background: white;
|
|
116
|
+
border: none;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
color: #3f8cff;
|
|
120
|
+
font-size: 16px;
|
|
121
|
+
transition: all 0.2s ease;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.page-button.selected {
|
|
125
|
+
background: #3f8cff;
|
|
126
|
+
color: white;
|
|
127
|
+
cursor: not-allowed;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.page-button.ellipsis {
|
|
131
|
+
cursor: default;
|
|
132
|
+
color: #aab2c8;
|
|
133
|
+
font-weight: 400;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.arrow-button:disabled {
|
|
137
|
+
cursor: not-allowed;
|
|
138
|
+
background: white;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@media (max-width: 768px) {
|
|
142
|
+
.arrow-button,
|
|
143
|
+
.page-button {
|
|
144
|
+
width: 32px;
|
|
145
|
+
height: 32px;
|
|
146
|
+
font-size: 14px;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -1,78 +1,76 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
border-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<q-input v-model="input" :placeholder="placeholder" dense outlined>
|
|
3
|
+
<template v-if="input" #append>
|
|
4
|
+
<q-icon name="✕" class="cursor-pointer" @click.stop="clearInput" />
|
|
5
|
+
</template>
|
|
6
|
+
</q-input>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { defineProps, defineEmits, ref, watch } from 'vue'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
modelValue: string
|
|
14
|
+
placeholder: string
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits<{
|
|
18
|
+
(e: 'update:modelValue', value: string): void
|
|
19
|
+
(e: 'search', value: string): void
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
const input = ref(props.modelValue)
|
|
23
|
+
let debounceTimer: ReturnType<typeof setTimeout>
|
|
24
|
+
const clearInput = () => {
|
|
25
|
+
input.value = ''
|
|
26
|
+
emit('search', '')
|
|
27
|
+
}
|
|
28
|
+
watch(
|
|
29
|
+
() => props.modelValue,
|
|
30
|
+
val => {
|
|
31
|
+
input.value = val
|
|
32
|
+
},
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
watch(input, val => {
|
|
36
|
+
emit('update:modelValue', val)
|
|
37
|
+
clearTimeout(debounceTimer)
|
|
38
|
+
debounceTimer = setTimeout(() => {
|
|
39
|
+
emit('search', val)
|
|
40
|
+
}, 400)
|
|
41
|
+
})
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style scoped lang="scss">
|
|
45
|
+
.q-field {
|
|
46
|
+
background: #fff;
|
|
47
|
+
border-radius: 4px;
|
|
48
|
+
outline: none;
|
|
49
|
+
border-color: #f2f7fb;
|
|
50
|
+
|
|
51
|
+
::v-deep(.q-field__control) {
|
|
52
|
+
height: 52px;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
::v-deep(.q-field__native) {
|
|
58
|
+
font-family: NunitoSansFont, sans-serif;
|
|
59
|
+
color: #1d425d;
|
|
60
|
+
padding-left: 8px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
::v-deep(.q-field__native::placeholder) {
|
|
64
|
+
color: rgba(184, 184, 184, 0.87);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
::v-deep(.q-icon.cursor-pointer) {
|
|
68
|
+
color: #1d425d;
|
|
69
|
+
font-size: 20px;
|
|
70
|
+
line-height: 15px;
|
|
71
|
+
}
|
|
72
|
+
::v-deep(.q-field__control:hover:before) {
|
|
73
|
+
border-color: #3f8cff;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { Ref, computed, ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
export interface TableColumn {
|
|
4
|
-
name: string
|
|
5
|
-
label: string
|
|
6
|
-
style?: string
|
|
7
|
-
headerStyle?: string
|
|
8
|
-
field: string | ((row: any) => any)
|
|
9
|
-
sortable?: boolean
|
|
10
|
-
filterType: 'single' | 'multi' | null
|
|
11
|
-
align?: 'left' | 'center' | 'right'
|
|
12
|
-
badge?: {
|
|
13
|
-
true?: string
|
|
14
|
-
false?: string
|
|
15
|
-
colorTrue?: string
|
|
16
|
-
colorFalse?: string
|
|
17
|
-
}
|
|
18
|
-
format?: (val: any) => any
|
|
19
|
-
html?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface FilterOption {
|
|
23
|
-
id: string
|
|
24
|
-
name: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface TableModel<T = any> {
|
|
28
|
-
columns: TableColumn[]
|
|
29
|
-
rows: T[] | Ref<T[]>
|
|
30
|
-
filtersOptions?: Ref<Record<string, FilterOption[]>>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const useTableModel = <T = any>(model: TableModel<T>) => {
|
|
34
|
-
const columnFilters = ref<Record<string, string | string[] | undefined>>({})
|
|
35
|
-
const filterMenus = ref<Record<string, boolean>>({})
|
|
36
|
-
|
|
37
|
-
model.columns.forEach(({ name, filterType }) => {
|
|
38
|
-
if (filterType) {
|
|
39
|
-
columnFilters.value[name] = filterType === 'multi' ? [] : undefined
|
|
40
|
-
filterMenus.value[name] = false
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const resolvedRows = computed(() => (Array.isArray(model.rows) ? model.rows : model.rows.value))
|
|
45
|
-
|
|
46
|
-
const toggleFilterValue = (colName: string, value: string) => {
|
|
47
|
-
const col = model.columns.find(c => c.name === colName)
|
|
48
|
-
if (col?.filterType === 'multi') {
|
|
49
|
-
const current = columnFilters.value[colName] as string[]
|
|
50
|
-
const index = current.indexOf(value)
|
|
51
|
-
index > -1 ? current.splice(index, 1) : current.push(value)
|
|
52
|
-
columnFilters.value[colName] = [...current]
|
|
53
|
-
} else {
|
|
54
|
-
columnFilters.value[colName] = value
|
|
55
|
-
filterMenus.value[colName] = false
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const selectedFilters = computed(() => {
|
|
60
|
-
const result: Record<string, string[]> = {}
|
|
61
|
-
for (const col of model.columns) {
|
|
62
|
-
const filter = columnFilters.value[col.name]
|
|
63
|
-
const options = model.filtersOptions?.value[col.name] || []
|
|
64
|
-
|
|
65
|
-
if (filter) {
|
|
66
|
-
result[col.name] = Array.isArray(filter)
|
|
67
|
-
? options.filter(opt => filter.includes(opt.name)).map(opt => opt.id)
|
|
68
|
-
: options.filter(opt => opt.name === filter).map(opt => opt.id)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return result
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
const clearFilter = (colName: string) => {
|
|
75
|
-
const col = model.columns.find(c => c.name === colName)
|
|
76
|
-
columnFilters.value[colName] = col?.filterType === 'multi' ? [] : undefined
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const openFilterMenu = (colName: string, isOpen: boolean) => {
|
|
80
|
-
filterMenus.value[colName] = isOpen
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
rows: resolvedRows,
|
|
85
|
-
columns: computed(() => model.columns),
|
|
86
|
-
columnFilters,
|
|
87
|
-
filterMenus,
|
|
88
|
-
toggleFilterValue,
|
|
89
|
-
clearFilter,
|
|
90
|
-
openFilterMenu,
|
|
91
|
-
selectedFilters,
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
import { Ref, computed, ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface TableColumn {
|
|
4
|
+
name: string
|
|
5
|
+
label: string
|
|
6
|
+
style?: string
|
|
7
|
+
headerStyle?: string
|
|
8
|
+
field: string | ((row: any) => any)
|
|
9
|
+
sortable?: boolean
|
|
10
|
+
filterType: 'single' | 'multi' | null
|
|
11
|
+
align?: 'left' | 'center' | 'right'
|
|
12
|
+
badge?: {
|
|
13
|
+
true?: string
|
|
14
|
+
false?: string
|
|
15
|
+
colorTrue?: string
|
|
16
|
+
colorFalse?: string
|
|
17
|
+
}
|
|
18
|
+
format?: (val: any) => any
|
|
19
|
+
html?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FilterOption {
|
|
23
|
+
id: string
|
|
24
|
+
name: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TableModel<T = any> {
|
|
28
|
+
columns: TableColumn[]
|
|
29
|
+
rows: T[] | Ref<T[]>
|
|
30
|
+
filtersOptions?: Ref<Record<string, FilterOption[]>>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const useTableModel = <T = any>(model: TableModel<T>) => {
|
|
34
|
+
const columnFilters = ref<Record<string, string | string[] | undefined>>({})
|
|
35
|
+
const filterMenus = ref<Record<string, boolean>>({})
|
|
36
|
+
|
|
37
|
+
model.columns.forEach(({ name, filterType }) => {
|
|
38
|
+
if (filterType) {
|
|
39
|
+
columnFilters.value[name] = filterType === 'multi' ? [] : undefined
|
|
40
|
+
filterMenus.value[name] = false
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const resolvedRows = computed(() => (Array.isArray(model.rows) ? model.rows : model.rows.value))
|
|
45
|
+
|
|
46
|
+
const toggleFilterValue = (colName: string, value: string) => {
|
|
47
|
+
const col = model.columns.find(c => c.name === colName)
|
|
48
|
+
if (col?.filterType === 'multi') {
|
|
49
|
+
const current = columnFilters.value[colName] as string[]
|
|
50
|
+
const index = current.indexOf(value)
|
|
51
|
+
index > -1 ? current.splice(index, 1) : current.push(value)
|
|
52
|
+
columnFilters.value[colName] = [...current]
|
|
53
|
+
} else {
|
|
54
|
+
columnFilters.value[colName] = value
|
|
55
|
+
filterMenus.value[colName] = false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const selectedFilters = computed(() => {
|
|
60
|
+
const result: Record<string, string[]> = {}
|
|
61
|
+
for (const col of model.columns) {
|
|
62
|
+
const filter = columnFilters.value[col.name]
|
|
63
|
+
const options = model.filtersOptions?.value[col.name] || []
|
|
64
|
+
|
|
65
|
+
if (filter) {
|
|
66
|
+
result[col.name] = Array.isArray(filter)
|
|
67
|
+
? options.filter(opt => filter.includes(opt.name)).map(opt => opt.id)
|
|
68
|
+
: options.filter(opt => opt.name === filter).map(opt => opt.id)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const clearFilter = (colName: string) => {
|
|
75
|
+
const col = model.columns.find(c => c.name === colName)
|
|
76
|
+
columnFilters.value[colName] = col?.filterType === 'multi' ? [] : undefined
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const openFilterMenu = (colName: string, isOpen: boolean) => {
|
|
80
|
+
filterMenus.value[colName] = isOpen
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
rows: resolvedRows,
|
|
85
|
+
columns: computed(() => model.columns),
|
|
86
|
+
columnFilters,
|
|
87
|
+
filterMenus,
|
|
88
|
+
toggleFilterValue,
|
|
89
|
+
clearFilter,
|
|
90
|
+
openFilterMenu,
|
|
91
|
+
selectedFilters,
|
|
92
|
+
}
|
|
93
|
+
}
|