shared-ritm 1.3.21 → 1.3.23
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 +4936 -4981
- package/dist/shared-ritm.umd.js +103 -103
- package/dist/types/api/services/ComentsServise.d.ts +10 -0
- package/dist/types/api/services/PhotoService.d.ts +51 -38
- package/dist/types/api/services/RepairsService.d.ts +1 -1
- package/dist/types/api/services/TasksService.d.ts +5 -0
- package/dist/types/api/settings/ApiService.d.ts +1 -1
- package/dist/types/api/types/Api_Tasks.d.ts +1 -0
- package/dist/types/api/types/Api_Users.d.ts +43 -0
- package/package.json +65 -65
- package/src/App.vue +2461 -2461
- package/src/api/services/BrigadesService.ts +32 -32
- package/src/api/services/ControlsService.ts +96 -96
- package/src/api/services/EquipmentService.ts +29 -29
- package/src/api/services/InstrumentsService.ts +68 -68
- package/src/api/services/MetricsService.ts +123 -123
- package/src/api/services/ModulesService.ts +27 -27
- package/src/api/services/ProjectsService.ts +83 -83
- package/src/api/services/RepairsService.ts +111 -111
- package/src/api/services/ScheduleService.ts +69 -69
- package/src/api/services/SearchService.ts +22 -22
- package/src/api/services/TasksService.ts +7 -0
- package/src/api/services/UserService.ts +119 -119
- package/src/api/services/VideoService.ts +108 -108
- package/src/api/settings/ApiService.ts +124 -124
- package/src/api/types/Api_Auth.ts +105 -105
- package/src/api/types/Api_Brigades.ts +36 -36
- package/src/api/types/Api_Controls.ts +111 -111
- package/src/api/types/Api_Equipment.ts +3 -3
- package/src/api/types/Api_Instruments.ts +156 -156
- package/src/api/types/Api_Metrics.ts +5 -5
- package/src/api/types/Api_Modules.ts +21 -21
- package/src/api/types/Api_Projects.ts +62 -62
- package/src/api/types/Api_Repairs.ts +140 -140
- package/src/api/types/Api_Schedule.ts +64 -64
- package/src/api/types/Api_Search.ts +80 -80
- package/src/api/types/Api_Tasks.ts +372 -371
- package/src/api/types/Api_User.ts +146 -146
- package/src/api/types/Api_Video.ts +198 -198
- package/src/common/app-datepicker/AppDatepicker.vue +218 -218
- package/src/common/app-dropdown/AppDropdown.vue +37 -37
- package/src/common/app-input-new/AppInputNew.vue +179 -179
- package/src/common/app-layout/AppLayout.vue +84 -84
- package/src/common/app-modal/index.vue +96 -96
- package/src/common/app-sheet-new/AppSheetNew.vue +244 -244
- package/src/common/app-sidebar/AppSidebar.vue +174 -174
- package/src/common/app-sidebar/components/SidebarMenuItem.vue +149 -149
- package/src/common/app-table/AppTable.vue +308 -308
- package/src/common/app-table/AppTableLayout.vue +137 -137
- package/src/common/app-table/components/ModalSelect.vue +296 -296
- package/src/common/app-table/components/TableModal.vue +356 -356
- package/src/common/app-table/controllers/useBaseTable.ts +45 -45
- package/src/common/app-table/controllers/useTableModel.ts +102 -102
- package/src/icons/dialogs/SafetyIcon.vue +12 -12
- package/src/index.ts +131 -131
- package/src/styles/variables.sass +12 -12
- package/src/utils/files.ts +19 -19
|
@@ -1,308 +1,308 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex flex-col" style="height: 100%; min-height: 100%">
|
|
3
|
-
<q-table
|
|
4
|
-
v-model:selected="selected"
|
|
5
|
-
:rows="rows.value"
|
|
6
|
-
:columns="columns"
|
|
7
|
-
row-key="id"
|
|
8
|
-
flat
|
|
9
|
-
bordered
|
|
10
|
-
hide-bottom
|
|
11
|
-
class="full-width"
|
|
12
|
-
:rows-per-page-options="[0]"
|
|
13
|
-
:selection="props.enableMultiSelect ? 'multiple' : 'none'"
|
|
14
|
-
style="height: 100%"
|
|
15
|
-
:table-row-style-fn="tableRowStyleFn"
|
|
16
|
-
@row-click="rowClick"
|
|
17
|
-
>
|
|
18
|
-
<template #header-selection="scope">
|
|
19
|
-
<q-toggle v-model="scope.selected" />
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<template #body-selection="scope">
|
|
23
|
-
<q-toggle v-model="scope.selected" />
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<template #body-cell-index="cellProps">
|
|
27
|
-
<q-td :props="cellProps" class="text-center" :class="{ 'q-td--no-hover': noHover }">
|
|
28
|
-
{{ getIndex(cellProps.rowIndex) }}
|
|
29
|
-
</q-td>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<template v-for="col in columns" :key="col.name" #[`header-cell-${col.name}`]="propsSlot">
|
|
33
|
-
<q-th
|
|
34
|
-
:props="propsSlot"
|
|
35
|
-
:class="{ 'cursor-pointer': col.filterType, fixed: col.name === 'fixed' }"
|
|
36
|
-
:style="col.style"
|
|
37
|
-
>
|
|
38
|
-
<div
|
|
39
|
-
v-if="col.filterType"
|
|
40
|
-
class="row items-center no-wrap"
|
|
41
|
-
@click.stop="emit('open-filter-menu', col.name, !filterMenus.value[col.name])"
|
|
42
|
-
>
|
|
43
|
-
<filter-icon class="q-mr-xs" />
|
|
44
|
-
<span>{{ col.label }}</span>
|
|
45
|
-
<div
|
|
46
|
-
v-if="['multi', 'single'].includes(col.filterType) && columnFilters.value[col.name]?.length"
|
|
47
|
-
class="label-length"
|
|
48
|
-
>
|
|
49
|
-
- {{ col.filterType === 'multi' ? columnFilters.value[col.name]?.length : 1 }}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<div v-else>{{ col.label }}</div>
|
|
53
|
-
|
|
54
|
-
<q-menu
|
|
55
|
-
v-if="col.filterType"
|
|
56
|
-
:model-value="filterMenus.value[col.name]"
|
|
57
|
-
fit
|
|
58
|
-
max-height="300px"
|
|
59
|
-
class="filter-menu"
|
|
60
|
-
@update:model-value="isOpen => emit('open-filter-menu', col.name, isOpen)"
|
|
61
|
-
>
|
|
62
|
-
<div class="filter-content">
|
|
63
|
-
<q-input v-model="localSearches[col.name]" dense outlined placeholder="Поиск" class="q-mb-sm" clearable />
|
|
64
|
-
<q-scroll-area style="height: 200px">
|
|
65
|
-
<q-list style="min-width: 200px">
|
|
66
|
-
<q-item v-for="option in filteredOptions[col.name]" :key="`${col.name}-${option.id}`" tag="label">
|
|
67
|
-
<q-item-section avatar>
|
|
68
|
-
<q-checkbox
|
|
69
|
-
v-if="col.filterType === 'multi'"
|
|
70
|
-
dense
|
|
71
|
-
:model-value="
|
|
72
|
-
Array.isArray(columnFilters.value[col.name]) &&
|
|
73
|
-
columnFilters.value[col.name]?.includes(option.name)
|
|
74
|
-
"
|
|
75
|
-
@update:model-value="() => emit('toggle-filter-value', col.name, option.name)"
|
|
76
|
-
/>
|
|
77
|
-
<q-radio
|
|
78
|
-
v-else
|
|
79
|
-
dense
|
|
80
|
-
:model-value="columnFilters.value[col.name]"
|
|
81
|
-
:val="option.name"
|
|
82
|
-
@update:model-value="emit('toggle-filter-value', col.name, $event)"
|
|
83
|
-
/>
|
|
84
|
-
</q-item-section>
|
|
85
|
-
<q-item-section>{{ option.name }}</q-item-section>
|
|
86
|
-
</q-item>
|
|
87
|
-
</q-list>
|
|
88
|
-
</q-scroll-area>
|
|
89
|
-
|
|
90
|
-
<div class="filter-footer">
|
|
91
|
-
<q-btn color="negative" flat dense label="Сбросить фильтр" @click="emit('clear-filter', col.name)" />
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
</q-menu>
|
|
95
|
-
</q-th>
|
|
96
|
-
</template>
|
|
97
|
-
|
|
98
|
-
<template #body-cell="cellProps">
|
|
99
|
-
<q-td
|
|
100
|
-
:props="cellProps"
|
|
101
|
-
:class="{
|
|
102
|
-
'q-td--no-hover': noHover || cellProps.col.name === 'fixed',
|
|
103
|
-
fixed: cellProps.col.name === 'fixed',
|
|
104
|
-
}"
|
|
105
|
-
>
|
|
106
|
-
<q-badge
|
|
107
|
-
v-if="cellProps.col.badge && typeof cellProps.value === 'boolean'"
|
|
108
|
-
:color="
|
|
109
|
-
cellProps.col.badge.colorTrue && cellProps.value
|
|
110
|
-
? cellProps.col.badge.colorTrue
|
|
111
|
-
: cellProps.col.badge.colorFalse && !cellProps.value
|
|
112
|
-
? cellProps.col.badge.colorFalse
|
|
113
|
-
: cellProps.value
|
|
114
|
-
? 'green'
|
|
115
|
-
: 'red'
|
|
116
|
-
"
|
|
117
|
-
outline
|
|
118
|
-
class="text-bold"
|
|
119
|
-
>
|
|
120
|
-
{{ cellProps.value ? cellProps.col.badge.true ?? 'Да' : cellProps.col.badge.false ?? 'Нет' }}
|
|
121
|
-
</q-badge>
|
|
122
|
-
<span v-else-if="cellProps.col.html" v-html="cellProps.value"></span>
|
|
123
|
-
<slot
|
|
124
|
-
v-else-if="hasSlot(cellProps.col.name)"
|
|
125
|
-
:name="cellProps.col.name"
|
|
126
|
-
:cellProps="cellProps"
|
|
127
|
-
:class="{ fixed__btns: cellProps.col.name === 'fixed' }"
|
|
128
|
-
/>
|
|
129
|
-
<span v-else :title="cellProps.value">{{ cellProps.value }}</span>
|
|
130
|
-
</q-td>
|
|
131
|
-
</template>
|
|
132
|
-
</q-table>
|
|
133
|
-
</div>
|
|
134
|
-
</template>
|
|
135
|
-
<script setup lang="ts">
|
|
136
|
-
import { defineProps, defineEmits, ref, computed, watch, Slots } from 'vue'
|
|
137
|
-
import type { Ref } from 'vue'
|
|
138
|
-
import FilterIcon from '@/icons/components/table-filter-icon.vue'
|
|
139
|
-
|
|
140
|
-
interface FilterOption {
|
|
141
|
-
id: string
|
|
142
|
-
name: string
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
interface TableEmits {
|
|
146
|
-
'toggle-filter-value': [colName: string, value: string]
|
|
147
|
-
'clear-filter': [colName: string]
|
|
148
|
-
'open-filter-menu': [colName: string, isOpen: boolean]
|
|
149
|
-
'row-click': [row: Record<string, any>]
|
|
150
|
-
'update:selectedRows': [rows: any[]] // синтаксис defineEmits для эмита с именованными параметрами
|
|
151
|
-
edit: [row: Record<string, any>]
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const props = defineProps<{
|
|
155
|
-
rows: Ref<any[]>
|
|
156
|
-
columns: any[]
|
|
157
|
-
columnFilters: Ref<Record<string, string | string[] | undefined>>
|
|
158
|
-
filterMenus: Ref<Record<string, boolean>>
|
|
159
|
-
filtersOptions: Record<string, FilterOption[]>
|
|
160
|
-
meta: Ref<{ currentPage: number; perPage: number }>
|
|
161
|
-
enableMultiSelect?: boolean
|
|
162
|
-
noHover?: boolean
|
|
163
|
-
hidePagination?: boolean
|
|
164
|
-
selectedRows: any[]
|
|
165
|
-
tableRowStyleFn?: (row: Record<string, any>) => string
|
|
166
|
-
slots?: Slots
|
|
167
|
-
}>()
|
|
168
|
-
const emit = defineEmits<TableEmits>()
|
|
169
|
-
|
|
170
|
-
const localSearches = ref<Record<string, string>>({})
|
|
171
|
-
const selected = ref<any[]>([])
|
|
172
|
-
|
|
173
|
-
const filteredOptions = computed(() => {
|
|
174
|
-
const result: Record<string, FilterOption[]> = {}
|
|
175
|
-
for (const col of props.columns) {
|
|
176
|
-
const search = localSearches.value[col.name]?.toLowerCase() || ''
|
|
177
|
-
const options = props.filtersOptions[col.name] || []
|
|
178
|
-
result[col.name] = options.filter(opt => opt.name.toLowerCase().includes(search))
|
|
179
|
-
}
|
|
180
|
-
return result
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
const hasSlot = (name: string) => props.slots && name in props.slots
|
|
184
|
-
|
|
185
|
-
const rowClick = (e: Event, row: Record<string, any>) => {
|
|
186
|
-
const target = e?.target
|
|
187
|
-
|
|
188
|
-
if (!(target instanceof HTMLElement) || target.closest('.fixed') || document.getSelection()?.toString()) return
|
|
189
|
-
|
|
190
|
-
emit('row-click', row)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const getIndex = (rowIndex: number) => {
|
|
194
|
-
if (props.hidePagination) return rowIndex + 1
|
|
195
|
-
|
|
196
|
-
return rowIndex + 1 + (props.meta.value.currentPage - 1) * props.meta.value.perPage
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
watch(
|
|
200
|
-
() => props.selectedRows,
|
|
201
|
-
val => {
|
|
202
|
-
selected.value = val
|
|
203
|
-
},
|
|
204
|
-
{ immediate: true },
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
watch(
|
|
208
|
-
selected,
|
|
209
|
-
val => {
|
|
210
|
-
emit('update:selectedRows', val)
|
|
211
|
-
},
|
|
212
|
-
{ deep: true },
|
|
213
|
-
)
|
|
214
|
-
</script>
|
|
215
|
-
<style scoped lang="scss">
|
|
216
|
-
.fixed {
|
|
217
|
-
background-color: #f2f7fb;
|
|
218
|
-
position: sticky;
|
|
219
|
-
right: 0;
|
|
220
|
-
z-index: 1;
|
|
221
|
-
border-left: 1px solid #d7e0ef;
|
|
222
|
-
|
|
223
|
-
&__btns {
|
|
224
|
-
display: flex;
|
|
225
|
-
justify-content: center;
|
|
226
|
-
gap: 0.5rem;
|
|
227
|
-
|
|
228
|
-
button {
|
|
229
|
-
background-color: #a4b4cf50;
|
|
230
|
-
width: 32px;
|
|
231
|
-
height: 32px;
|
|
232
|
-
border-radius: 8px;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.cursor-pointer {
|
|
238
|
-
cursor: pointer;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.filter-menu {
|
|
242
|
-
padding: 10px;
|
|
243
|
-
}
|
|
244
|
-
.label-length {
|
|
245
|
-
margin-left: 5px;
|
|
246
|
-
}
|
|
247
|
-
.filter-content {
|
|
248
|
-
display: flex;
|
|
249
|
-
flex-direction: column;
|
|
250
|
-
color: #1d425d;
|
|
251
|
-
.q-item {
|
|
252
|
-
padding: 0 5px;
|
|
253
|
-
min-height: 40px;
|
|
254
|
-
}
|
|
255
|
-
.q-item__section {
|
|
256
|
-
min-width: 30px;
|
|
257
|
-
padding: 0;
|
|
258
|
-
}
|
|
259
|
-
::v-deep(.q-radio__inner),
|
|
260
|
-
::v-deep(.q-checkbox__inner) {
|
|
261
|
-
color: #a4b4cf;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.filter-footer {
|
|
266
|
-
border-top: 1px solid #eee;
|
|
267
|
-
display: flex;
|
|
268
|
-
justify-content: center;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
::v-deep(.q-table thead) {
|
|
272
|
-
position: sticky;
|
|
273
|
-
top: 0;
|
|
274
|
-
background: #f2f7fb;
|
|
275
|
-
z-index: 2;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
::v-deep(.q-table th) {
|
|
279
|
-
font-family: NunitoSansFont, sans-serif;
|
|
280
|
-
color: #a4b4cf;
|
|
281
|
-
font-size: 15px;
|
|
282
|
-
font-style: normal;
|
|
283
|
-
font-weight: 700;
|
|
284
|
-
line-height: 20px;
|
|
285
|
-
height: 61px;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
::v-deep(.q-table tbody td) {
|
|
289
|
-
height: 61px;
|
|
290
|
-
font-size: 14px;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.q-td--no-hover {
|
|
294
|
-
cursor: default;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
::v-deep(.q-table tbody) {
|
|
298
|
-
font-family: NunitoSansFont, sans-serif;
|
|
299
|
-
border-color: #d7e0ef;
|
|
300
|
-
color: #1d425d;
|
|
301
|
-
line-height: 20px;
|
|
302
|
-
font-size: 14px;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
::v-deep(.q-table tbody tr:last-child td) {
|
|
306
|
-
border-bottom: 1px solid #d7e0ef;
|
|
307
|
-
}
|
|
308
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-col" style="height: 100%; min-height: 100%">
|
|
3
|
+
<q-table
|
|
4
|
+
v-model:selected="selected"
|
|
5
|
+
:rows="rows.value"
|
|
6
|
+
:columns="columns"
|
|
7
|
+
row-key="id"
|
|
8
|
+
flat
|
|
9
|
+
bordered
|
|
10
|
+
hide-bottom
|
|
11
|
+
class="full-width"
|
|
12
|
+
:rows-per-page-options="[0]"
|
|
13
|
+
:selection="props.enableMultiSelect ? 'multiple' : 'none'"
|
|
14
|
+
style="height: 100%"
|
|
15
|
+
:table-row-style-fn="tableRowStyleFn"
|
|
16
|
+
@row-click="rowClick"
|
|
17
|
+
>
|
|
18
|
+
<template #header-selection="scope">
|
|
19
|
+
<q-toggle v-model="scope.selected" />
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<template #body-selection="scope">
|
|
23
|
+
<q-toggle v-model="scope.selected" />
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<template #body-cell-index="cellProps">
|
|
27
|
+
<q-td :props="cellProps" class="text-center" :class="{ 'q-td--no-hover': noHover }">
|
|
28
|
+
{{ getIndex(cellProps.rowIndex) }}
|
|
29
|
+
</q-td>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<template v-for="col in columns" :key="col.name" #[`header-cell-${col.name}`]="propsSlot">
|
|
33
|
+
<q-th
|
|
34
|
+
:props="propsSlot"
|
|
35
|
+
:class="{ 'cursor-pointer': col.filterType, fixed: col.name === 'fixed' }"
|
|
36
|
+
:style="col.style"
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
v-if="col.filterType"
|
|
40
|
+
class="row items-center no-wrap"
|
|
41
|
+
@click.stop="emit('open-filter-menu', col.name, !filterMenus.value[col.name])"
|
|
42
|
+
>
|
|
43
|
+
<filter-icon class="q-mr-xs" />
|
|
44
|
+
<span>{{ col.label }}</span>
|
|
45
|
+
<div
|
|
46
|
+
v-if="['multi', 'single'].includes(col.filterType) && columnFilters.value[col.name]?.length"
|
|
47
|
+
class="label-length"
|
|
48
|
+
>
|
|
49
|
+
- {{ col.filterType === 'multi' ? columnFilters.value[col.name]?.length : 1 }}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
<div v-else>{{ col.label }}</div>
|
|
53
|
+
|
|
54
|
+
<q-menu
|
|
55
|
+
v-if="col.filterType"
|
|
56
|
+
:model-value="filterMenus.value[col.name]"
|
|
57
|
+
fit
|
|
58
|
+
max-height="300px"
|
|
59
|
+
class="filter-menu"
|
|
60
|
+
@update:model-value="isOpen => emit('open-filter-menu', col.name, isOpen)"
|
|
61
|
+
>
|
|
62
|
+
<div class="filter-content">
|
|
63
|
+
<q-input v-model="localSearches[col.name]" dense outlined placeholder="Поиск" class="q-mb-sm" clearable />
|
|
64
|
+
<q-scroll-area style="height: 200px">
|
|
65
|
+
<q-list style="min-width: 200px">
|
|
66
|
+
<q-item v-for="option in filteredOptions[col.name]" :key="`${col.name}-${option.id}`" tag="label">
|
|
67
|
+
<q-item-section avatar>
|
|
68
|
+
<q-checkbox
|
|
69
|
+
v-if="col.filterType === 'multi'"
|
|
70
|
+
dense
|
|
71
|
+
:model-value="
|
|
72
|
+
Array.isArray(columnFilters.value[col.name]) &&
|
|
73
|
+
columnFilters.value[col.name]?.includes(option.name)
|
|
74
|
+
"
|
|
75
|
+
@update:model-value="() => emit('toggle-filter-value', col.name, option.name)"
|
|
76
|
+
/>
|
|
77
|
+
<q-radio
|
|
78
|
+
v-else
|
|
79
|
+
dense
|
|
80
|
+
:model-value="columnFilters.value[col.name]"
|
|
81
|
+
:val="option.name"
|
|
82
|
+
@update:model-value="emit('toggle-filter-value', col.name, $event)"
|
|
83
|
+
/>
|
|
84
|
+
</q-item-section>
|
|
85
|
+
<q-item-section>{{ option.name }}</q-item-section>
|
|
86
|
+
</q-item>
|
|
87
|
+
</q-list>
|
|
88
|
+
</q-scroll-area>
|
|
89
|
+
|
|
90
|
+
<div class="filter-footer">
|
|
91
|
+
<q-btn color="negative" flat dense label="Сбросить фильтр" @click="emit('clear-filter', col.name)" />
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</q-menu>
|
|
95
|
+
</q-th>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<template #body-cell="cellProps">
|
|
99
|
+
<q-td
|
|
100
|
+
:props="cellProps"
|
|
101
|
+
:class="{
|
|
102
|
+
'q-td--no-hover': noHover || cellProps.col.name === 'fixed',
|
|
103
|
+
fixed: cellProps.col.name === 'fixed',
|
|
104
|
+
}"
|
|
105
|
+
>
|
|
106
|
+
<q-badge
|
|
107
|
+
v-if="cellProps.col.badge && typeof cellProps.value === 'boolean'"
|
|
108
|
+
:color="
|
|
109
|
+
cellProps.col.badge.colorTrue && cellProps.value
|
|
110
|
+
? cellProps.col.badge.colorTrue
|
|
111
|
+
: cellProps.col.badge.colorFalse && !cellProps.value
|
|
112
|
+
? cellProps.col.badge.colorFalse
|
|
113
|
+
: cellProps.value
|
|
114
|
+
? 'green'
|
|
115
|
+
: 'red'
|
|
116
|
+
"
|
|
117
|
+
outline
|
|
118
|
+
class="text-bold"
|
|
119
|
+
>
|
|
120
|
+
{{ cellProps.value ? cellProps.col.badge.true ?? 'Да' : cellProps.col.badge.false ?? 'Нет' }}
|
|
121
|
+
</q-badge>
|
|
122
|
+
<span v-else-if="cellProps.col.html" v-html="cellProps.value"></span>
|
|
123
|
+
<slot
|
|
124
|
+
v-else-if="hasSlot(cellProps.col.name)"
|
|
125
|
+
:name="cellProps.col.name"
|
|
126
|
+
:cellProps="cellProps"
|
|
127
|
+
:class="{ fixed__btns: cellProps.col.name === 'fixed' }"
|
|
128
|
+
/>
|
|
129
|
+
<span v-else :title="cellProps.value">{{ cellProps.value }}</span>
|
|
130
|
+
</q-td>
|
|
131
|
+
</template>
|
|
132
|
+
</q-table>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
<script setup lang="ts">
|
|
136
|
+
import { defineProps, defineEmits, ref, computed, watch, Slots } from 'vue'
|
|
137
|
+
import type { Ref } from 'vue'
|
|
138
|
+
import FilterIcon from '@/icons/components/table-filter-icon.vue'
|
|
139
|
+
|
|
140
|
+
interface FilterOption {
|
|
141
|
+
id: string
|
|
142
|
+
name: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface TableEmits {
|
|
146
|
+
'toggle-filter-value': [colName: string, value: string]
|
|
147
|
+
'clear-filter': [colName: string]
|
|
148
|
+
'open-filter-menu': [colName: string, isOpen: boolean]
|
|
149
|
+
'row-click': [row: Record<string, any>]
|
|
150
|
+
'update:selectedRows': [rows: any[]] // синтаксис defineEmits для эмита с именованными параметрами
|
|
151
|
+
edit: [row: Record<string, any>]
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const props = defineProps<{
|
|
155
|
+
rows: Ref<any[]>
|
|
156
|
+
columns: any[]
|
|
157
|
+
columnFilters: Ref<Record<string, string | string[] | undefined>>
|
|
158
|
+
filterMenus: Ref<Record<string, boolean>>
|
|
159
|
+
filtersOptions: Record<string, FilterOption[]>
|
|
160
|
+
meta: Ref<{ currentPage: number; perPage: number }>
|
|
161
|
+
enableMultiSelect?: boolean
|
|
162
|
+
noHover?: boolean
|
|
163
|
+
hidePagination?: boolean
|
|
164
|
+
selectedRows: any[]
|
|
165
|
+
tableRowStyleFn?: (row: Record<string, any>) => string
|
|
166
|
+
slots?: Slots
|
|
167
|
+
}>()
|
|
168
|
+
const emit = defineEmits<TableEmits>()
|
|
169
|
+
|
|
170
|
+
const localSearches = ref<Record<string, string>>({})
|
|
171
|
+
const selected = ref<any[]>([])
|
|
172
|
+
|
|
173
|
+
const filteredOptions = computed(() => {
|
|
174
|
+
const result: Record<string, FilterOption[]> = {}
|
|
175
|
+
for (const col of props.columns) {
|
|
176
|
+
const search = localSearches.value[col.name]?.toLowerCase() || ''
|
|
177
|
+
const options = props.filtersOptions[col.name] || []
|
|
178
|
+
result[col.name] = options.filter(opt => opt.name.toLowerCase().includes(search))
|
|
179
|
+
}
|
|
180
|
+
return result
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
const hasSlot = (name: string) => props.slots && name in props.slots
|
|
184
|
+
|
|
185
|
+
const rowClick = (e: Event, row: Record<string, any>) => {
|
|
186
|
+
const target = e?.target
|
|
187
|
+
|
|
188
|
+
if (!(target instanceof HTMLElement) || target.closest('.fixed') || document.getSelection()?.toString()) return
|
|
189
|
+
|
|
190
|
+
emit('row-click', row)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const getIndex = (rowIndex: number) => {
|
|
194
|
+
if (props.hidePagination) return rowIndex + 1
|
|
195
|
+
|
|
196
|
+
return rowIndex + 1 + (props.meta.value.currentPage - 1) * props.meta.value.perPage
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
watch(
|
|
200
|
+
() => props.selectedRows,
|
|
201
|
+
val => {
|
|
202
|
+
selected.value = val
|
|
203
|
+
},
|
|
204
|
+
{ immediate: true },
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
watch(
|
|
208
|
+
selected,
|
|
209
|
+
val => {
|
|
210
|
+
emit('update:selectedRows', val)
|
|
211
|
+
},
|
|
212
|
+
{ deep: true },
|
|
213
|
+
)
|
|
214
|
+
</script>
|
|
215
|
+
<style scoped lang="scss">
|
|
216
|
+
.fixed {
|
|
217
|
+
background-color: #f2f7fb;
|
|
218
|
+
position: sticky;
|
|
219
|
+
right: 0;
|
|
220
|
+
z-index: 1;
|
|
221
|
+
border-left: 1px solid #d7e0ef;
|
|
222
|
+
|
|
223
|
+
&__btns {
|
|
224
|
+
display: flex;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
gap: 0.5rem;
|
|
227
|
+
|
|
228
|
+
button {
|
|
229
|
+
background-color: #a4b4cf50;
|
|
230
|
+
width: 32px;
|
|
231
|
+
height: 32px;
|
|
232
|
+
border-radius: 8px;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.cursor-pointer {
|
|
238
|
+
cursor: pointer;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.filter-menu {
|
|
242
|
+
padding: 10px;
|
|
243
|
+
}
|
|
244
|
+
.label-length {
|
|
245
|
+
margin-left: 5px;
|
|
246
|
+
}
|
|
247
|
+
.filter-content {
|
|
248
|
+
display: flex;
|
|
249
|
+
flex-direction: column;
|
|
250
|
+
color: #1d425d;
|
|
251
|
+
.q-item {
|
|
252
|
+
padding: 0 5px;
|
|
253
|
+
min-height: 40px;
|
|
254
|
+
}
|
|
255
|
+
.q-item__section {
|
|
256
|
+
min-width: 30px;
|
|
257
|
+
padding: 0;
|
|
258
|
+
}
|
|
259
|
+
::v-deep(.q-radio__inner),
|
|
260
|
+
::v-deep(.q-checkbox__inner) {
|
|
261
|
+
color: #a4b4cf;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.filter-footer {
|
|
266
|
+
border-top: 1px solid #eee;
|
|
267
|
+
display: flex;
|
|
268
|
+
justify-content: center;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
::v-deep(.q-table thead) {
|
|
272
|
+
position: sticky;
|
|
273
|
+
top: 0;
|
|
274
|
+
background: #f2f7fb;
|
|
275
|
+
z-index: 2;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
::v-deep(.q-table th) {
|
|
279
|
+
font-family: NunitoSansFont, sans-serif;
|
|
280
|
+
color: #a4b4cf;
|
|
281
|
+
font-size: 15px;
|
|
282
|
+
font-style: normal;
|
|
283
|
+
font-weight: 700;
|
|
284
|
+
line-height: 20px;
|
|
285
|
+
height: 61px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
::v-deep(.q-table tbody td) {
|
|
289
|
+
height: 61px;
|
|
290
|
+
font-size: 14px;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.q-td--no-hover {
|
|
294
|
+
cursor: default;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
::v-deep(.q-table tbody) {
|
|
298
|
+
font-family: NunitoSansFont, sans-serif;
|
|
299
|
+
border-color: #d7e0ef;
|
|
300
|
+
color: #1d425d;
|
|
301
|
+
line-height: 20px;
|
|
302
|
+
font-size: 14px;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
::v-deep(.q-table tbody tr:last-child td) {
|
|
306
|
+
border-bottom: 1px solid #d7e0ef;
|
|
307
|
+
}
|
|
308
|
+
</style>
|