shared-ritm 1.2.44 → 1.2.46

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.
@@ -1,11 +1,12 @@
1
1
  import ApiService, { ResponseApi } from '@/api/settings/ApiService';
2
- import { Api_ControlZones_Dto } from '@/api/types/Api_Controls';
2
+ import { Api_ControlLogs_Dto, Api_ControlZones_Dto } from '@/api/types/Api_Controls';
3
3
  declare class ControlsService extends ApiService {
4
4
  fetchControlZones(params: Record<string, any>): Promise<ResponseApi<Api_ControlZones_Dto[]>>;
5
5
  fetchControlZone(id: string): Promise<ResponseApi<Api_ControlZones_Dto>>;
6
6
  createControlZone(params: any): Promise<ResponseApi<any>>;
7
7
  editControlZone(id: string, params: any): Promise<ResponseApi<any>>;
8
8
  deleteControlZone(id: string): Promise<any>;
9
+ fetchControlLogs(params: Record<string, any>): Promise<ResponseApi<Api_ControlLogs_Dto[]>>;
9
10
  }
10
11
  export default function useControlsService(): ControlsService;
11
12
  export {};
@@ -1,4 +1,4 @@
1
- export type Api_Controllers_Dto = {
1
+ export type Api_User_Dto = {
2
2
  id: string;
3
3
  full_name: string;
4
4
  };
@@ -8,5 +8,52 @@ export type Api_ControlZones_Dto = {
8
8
  inventory_number: string;
9
9
  uuid: string;
10
10
  controller_zone: string;
11
- users?: Api_Controllers_Dto[];
11
+ users?: Api_User_Dto[];
12
+ };
13
+ export type ControlsParams = {
14
+ search?: string;
15
+ page?: number;
16
+ filter?: Record<string, string[]>;
17
+ };
18
+ export interface ControlMeta {
19
+ total: number;
20
+ perPage: number;
21
+ totalPages: number;
22
+ currentPage: number;
23
+ }
24
+ export interface FiltersValue {
25
+ users?: {
26
+ users: Api_User_Dto[];
27
+ };
28
+ controller?: {
29
+ controller: Api_User_Dto[];
30
+ };
31
+ responsible?: {
32
+ responsible: Api_User_Dto[];
33
+ };
34
+ status?: {
35
+ status: Api_User_Dto[];
36
+ };
37
+ }
38
+ export interface Instrument_Dto {
39
+ id: string;
40
+ name: string;
41
+ storage_id: string;
42
+ }
43
+ export interface Warehouse_Dto {
44
+ id: string;
45
+ invoice_ref_key: string;
46
+ inventory_number: string;
47
+ instrument: Instrument_Dto[];
48
+ }
49
+ export type Api_ControlLogs_Dto = {
50
+ id: string;
51
+ automatically: string;
52
+ in_zone: string;
53
+ uuid: string;
54
+ controller_zone: string;
55
+ controller: Api_User_Dto[];
56
+ user: Api_User_Dto[];
57
+ frame: Api_ControlZones_Dto[];
58
+ warehouse: Warehouse_Dto[];
12
59
  };
@@ -0,0 +1,8 @@
1
+ export declare function useBaseTable(model: any): {
2
+ search: import("vue").Ref<string, string>;
3
+ currentPage: import("vue").Ref<number, number>;
4
+ loading: import("vue").Ref<boolean, boolean>;
5
+ handleSearch: (val: string) => Promise<void>;
6
+ handlePageChange: (page: number) => Promise<void>;
7
+ loadTable: (searchVal?: string, pageVal?: number) => Promise<void>;
8
+ };
@@ -0,0 +1,10 @@
1
+ export interface ColumnConfig {
2
+ name: string;
3
+ label: string;
4
+ [key: string]: any;
5
+ }
6
+ export declare function useColumnSelector(allColumns: ColumnConfig[], fixedColumnNames?: string[]): {
7
+ selectedColumnNames: import("vue").Ref<string[], string[]>;
8
+ visibleColumns: import("vue").ComputedRef<ColumnConfig[]>;
9
+ openColumnSelectorDialog: ($q: any) => void;
10
+ };
@@ -8,6 +8,14 @@ export interface TableColumn {
8
8
  sortable?: boolean;
9
9
  filterType: 'single' | 'multi' | null;
10
10
  align?: 'left' | 'center' | 'right';
11
+ badge?: {
12
+ true?: string;
13
+ false?: string;
14
+ colorTrue?: string;
15
+ colorFalse?: string;
16
+ };
17
+ format?: (val: any) => any;
18
+ html?: boolean;
11
19
  }
12
20
  export interface FilterOption {
13
21
  id: string;
@@ -19,6 +19,7 @@ import AppTablePagination from '@/common/app-table/components/TablePagination.vu
19
19
  import AppTableSearch from '@/common/app-table/components/TableSearch.vue';
20
20
  import AppTableModal from '@/common/app-table/components/TableModal.vue';
21
21
  import AppTable from '@/common/app-table/AppTable.vue';
22
+ import AppTableLayout from '@/common/app-table/AppTableLayout.vue';
22
23
  import useGanttService from '@/api/services/GanttService';
23
24
  import useMetricsService from '@/api/services/MetricsService';
24
25
  import useProjectsService from '@/api/services/ProjectsService';
@@ -28,9 +29,11 @@ import useAuthService from '@/api/services/AuthService';
28
29
  import useFileService from '@/api/services/FileService';
29
30
  import ApiService from '@/api/settings/ApiService';
30
31
  import useControlsService from '@/api/services/ControlsService';
31
- export { AppButton, AppCheckbox, AppDatePicker, AppInput, AppInputSearch, AppLayout, AppLayoutHeader, AppLayoutPage, AppLoader, AppSelect, AppSheet, AppSidebar, AppToggle, AppWrapper, AppConfirmDialog, AppDropdown, AppTablePagination, AppTableSearch, AppTableModal, AppTable, };
32
+ export { AppButton, AppCheckbox, AppDatePicker, AppInput, AppInputSearch, AppLayout, AppLayoutHeader, AppLayoutPage, AppLoader, AppSelect, AppSheet, AppSidebar, AppToggle, AppWrapper, AppConfirmDialog, AppDropdown, AppTablePagination, AppTableSearch, AppTableModal, AppTable, AppTableLayout, };
32
33
  export { ApiService, useAuthService, useGanttService, useMetricsService, useProjectsService, useRepairsService, useTasksService, useFileService, useControlsService, };
34
+ export { useBaseTable } from './common/app-table/controllers/useBaseTable';
33
35
  export { useTableModel } from './common/app-table/controllers/useTableModel';
36
+ export { useColumnSelector } from './common/app-table/controllers/useColumnSelector';
34
37
  export type { FilterOption, TableModel, TableColumn } from './common/app-table/controllers/useTableModel';
35
38
  export type { NotificationType } from './utils/notification';
36
39
  export { notificationSettings } from './utils/notification';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -37,7 +37,6 @@
37
37
  "quasar": "^2.18.1"
38
38
  },
39
39
  "devDependencies": {
40
- "quasar": "^2.18.1",
41
40
  "@quasar/vite-plugin": "^1.9.0",
42
41
  "@rollup/pluginutils": "^5.1.3",
43
42
  "@types/node": "^22.7.9",
@@ -51,6 +50,7 @@
51
50
  "eslint-plugin-prettier": "^3.4.0",
52
51
  "eslint-plugin-vue": "^7.10.0",
53
52
  "prettier": "^2.3.0",
53
+ "quasar": "^2.18.1",
54
54
  "sass": "^1.80.4",
55
55
  "typescript": "^5.6.3",
56
56
  "vite": "^5.4.9",
@@ -1,6 +1,6 @@
1
1
  import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
2
 
3
- import { Api_ControlZones_Dto } from '@/api/types/Api_Controls'
3
+ import { Api_ControlLogs_Dto, Api_ControlZones_Dto } from '@/api/types/Api_Controls'
4
4
 
5
5
  class ControlsService extends ApiService {
6
6
  public fetchControlZones(params: Record<string, any>): Promise<ResponseApi<Api_ControlZones_Dto[]>> {
@@ -22,6 +22,10 @@ class ControlsService extends ApiService {
22
22
  public deleteControlZone(id: string): Promise<any> {
23
23
  return this.delete<ResponseApi<any>>(`/frame/${id}`)
24
24
  }
25
+
26
+ public fetchControlLogs(params: Record<string, any>): Promise<ResponseApi<Api_ControlLogs_Dto[]>> {
27
+ return this.get('/exposed_equipment_zones/list', { params })
28
+ }
25
29
  }
26
30
 
27
31
  let api: ControlsService
@@ -1,4 +1,4 @@
1
- export type Api_Controllers_Dto = {
1
+ export type Api_User_Dto = {
2
2
  id: string
3
3
  full_name: string
4
4
  }
@@ -8,5 +8,55 @@ export type Api_ControlZones_Dto = {
8
8
  inventory_number: string
9
9
  uuid: string
10
10
  controller_zone: string
11
- users?: Api_Controllers_Dto[]
12
- }
11
+ users?: Api_User_Dto[]
12
+ }
13
+ export type ControlsParams = {
14
+ search?: string
15
+ page?: number
16
+ filter?: Record<string, string[]>
17
+ }
18
+
19
+ export interface ControlMeta {
20
+ total: number
21
+ perPage: number
22
+ totalPages: number
23
+ currentPage: number
24
+ }
25
+
26
+ export interface FiltersValue {
27
+ users?: {
28
+ users: Api_User_Dto[]
29
+ }
30
+ controller?: {
31
+ controller: Api_User_Dto[]
32
+ }
33
+ responsible?: {
34
+ responsible: Api_User_Dto[]
35
+ }
36
+ status?: {
37
+ status: Api_User_Dto[]
38
+ }
39
+ }
40
+ export interface Instrument_Dto {
41
+ id: string
42
+ name: string
43
+ storage_id: string
44
+ }
45
+ export interface Warehouse_Dto {
46
+ id: string
47
+ invoice_ref_key: string
48
+ inventory_number: string
49
+ instrument: Instrument_Dto[]
50
+ }
51
+
52
+ export type Api_ControlLogs_Dto = {
53
+ id: string
54
+ automatically: string
55
+ in_zone: string
56
+ uuid: string
57
+ controller_zone: string
58
+ controller: Api_User_Dto[]
59
+ user: Api_User_Dto[]
60
+ frame: Api_ControlZones_Dto[]
61
+ warehouse: Warehouse_Dto[]
62
+ }
@@ -4,6 +4,7 @@
4
4
  :model-value="isRouteActive(item) && expand"
5
5
  header-class="text-purple"
6
6
  :class="[$style['menu-item'], { 'expansion-item-active': isRouteActive(item) && minify }]"
7
+ :data-test="`sidebar-expansion-item-${(item.name || 'unnamed').toLowerCase().replace(/\s+/g, '-')}`"
7
8
  @update:model-value="expand = $event"
8
9
  >
9
10
  <template #header>
@@ -41,7 +42,7 @@
41
42
  active-class="menu-active"
42
43
  clickable
43
44
  :to="main ? item.to : ''"
44
- :data-test="`sidebar-item-${item.label.toLowerCase().replace(/\s+/g, '-')}`"
45
+ :data-test="`sidebar-item-${item.name.toLowerCase().replace(/\s+/g, '-')}`"
45
46
  @click="goToRoute(item.to)"
46
47
  >
47
48
  <q-item-section v-if="item.icon" avatar>
@@ -116,6 +116,29 @@ const filteredOptions = computed(() => {
116
116
  </q-menu>
117
117
  </q-th>
118
118
  </template>
119
+
120
+ <template #body-cell="props">
121
+ <q-td :props="props">
122
+ <q-badge
123
+ v-if="props.col.badge && typeof props.value === 'boolean'"
124
+ :color="
125
+ props.col.badge.colorTrue && props.value
126
+ ? props.col.badge.colorTrue
127
+ : props.col.badge.colorFalse && !props.value
128
+ ? props.col.badge.colorFalse
129
+ : props.value
130
+ ? 'green'
131
+ : 'red'
132
+ "
133
+ outline
134
+ class="text-bold"
135
+ >
136
+ {{ props.value ? props.col.badge.true ?? 'Да' : props.col.badge.false ?? 'Нет' }}
137
+ </q-badge>
138
+ <span v-else-if="props.col.html" v-html="props.value"></span>
139
+ <span v-else>{{ props.value }}</span>
140
+ </q-td>
141
+ </template>
119
142
  </q-table>
120
143
  </q-page>
121
144
  </template>
@@ -0,0 +1,93 @@
1
+ <script setup lang="ts">
2
+ import { AppTable, AppTablePagination, AppTableSearch } from 'shared-ritm'
3
+ import { defineProps } from 'vue'
4
+
5
+ const props = defineProps<{
6
+ search: string
7
+ loading: boolean
8
+ currentPage: number
9
+ totalPages: number
10
+ tableProps: any
11
+ tableEvents: any
12
+ onSearch: (val: string) => void
13
+ onPageChange: (page: number) => void
14
+ actionsSlot?: boolean
15
+ modalSlot?: boolean
16
+ }>()
17
+ </script>
18
+
19
+ <template>
20
+ <div class="table-layout">
21
+ <div class="table-controls">
22
+ <app-table-search
23
+ :model-value="props.search"
24
+ class="search-input"
25
+ placeholder="Введите наименование"
26
+ @search="props.onSearch"
27
+ />
28
+ <slot v-if="actionsSlot" name="actions" />
29
+ </div>
30
+
31
+ <div class="table-wrapper">
32
+ <app-table v-bind="props.tableProps" v-on="props.tableEvents" />
33
+ <div v-if="props.loading" class="loader-overlay">
34
+ <q-spinner-audio class="loader-spinner" size="md" :thickness="3" color="primary" />
35
+ </div>
36
+ </div>
37
+
38
+ <app-table-pagination
39
+ :model-value="props.currentPage"
40
+ :total-pages="props.totalPages"
41
+ @page-change="props.onPageChange"
42
+ />
43
+
44
+ <slot v-if="modalSlot" name="modal" />
45
+ </div>
46
+ </template>
47
+
48
+ <style scoped lang="scss">
49
+ .table-layout {
50
+ height: calc(100vh - 100px);
51
+ display: flex;
52
+ flex-direction: column;
53
+ box-sizing: border-box;
54
+ }
55
+ .table-controls {
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: space-between;
59
+ gap: 18px;
60
+ margin-bottom: 20px;
61
+
62
+ .search-input {
63
+ flex: 1;
64
+ }
65
+
66
+ ::v-deep(.q-btn) {
67
+ flex-shrink: 0;
68
+ border-radius: 2px;
69
+ background: #fff;
70
+ box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
71
+ color: #3f8cff;
72
+ height: 50px;
73
+ width: 50px;
74
+ }
75
+ }
76
+ .table-wrapper {
77
+ position: relative;
78
+ flex: 1;
79
+ overflow-y: auto;
80
+ }
81
+ .loader-overlay {
82
+ position: absolute;
83
+ inset: 0;
84
+ z-index: 10;
85
+ background: rgba(255, 255, 255, 0.8);
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ }
90
+ .loader-spinner {
91
+ z-index: 11;
92
+ }
93
+ </style>
@@ -0,0 +1,43 @@
1
+ import { ref, watch, onMounted } from 'vue'
2
+
3
+ export function useBaseTable(model: any) {
4
+ const search = ref('')
5
+ const currentPage = ref(1)
6
+ const loading = ref(false)
7
+
8
+ const loadTable = async (searchVal = '', pageVal = 1) => {
9
+ loading.value = true
10
+ try {
11
+ await model.initialize({ search: searchVal, page: pageVal })
12
+ } finally {
13
+ loading.value = false
14
+ }
15
+ }
16
+
17
+ const handleSearch = async (val: string) => {
18
+ currentPage.value = 1
19
+ await loadTable(val, currentPage.value)
20
+ }
21
+
22
+ const handlePageChange = async (page: number) => {
23
+ currentPage.value = page
24
+ await loadTable(search.value, page)
25
+ }
26
+
27
+ watch(
28
+ () => model.columnFilters.value,
29
+ () => loadTable(search.value, currentPage.value),
30
+ { deep: true },
31
+ )
32
+
33
+ onMounted(() => loadTable())
34
+
35
+ return {
36
+ search,
37
+ currentPage,
38
+ loading,
39
+ handleSearch,
40
+ handlePageChange,
41
+ loadTable,
42
+ }
43
+ }
@@ -0,0 +1,38 @@
1
+ import { computed, ref } from 'vue'
2
+
3
+ export interface ColumnConfig {
4
+ name: string
5
+ label: string
6
+ [key: string]: any
7
+ }
8
+
9
+ export function useColumnSelector(allColumns: ColumnConfig[], fixedColumnNames: string[] = []) {
10
+ const selectedColumnNames = ref<string[]>([...new Set([...fixedColumnNames, ...allColumns.map(col => col.name)])])
11
+
12
+ const visibleColumns = computed(() => allColumns.filter(col => selectedColumnNames.value.includes(col.name)))
13
+
14
+ function openColumnSelectorDialog($q: any) {
15
+ $q.dialog({
16
+ title: 'Выберите колонки',
17
+ options: {
18
+ type: 'checkbox',
19
+ model: [...selectedColumnNames.value],
20
+ items: allColumns.map(col => ({
21
+ label: col.label,
22
+ value: col.name,
23
+ disable: fixedColumnNames.includes(col.name),
24
+ })),
25
+ },
26
+ cancel: true,
27
+ persistent: true,
28
+ }).onOk((val: string[]) => {
29
+ selectedColumnNames.value = Array.from(new Set([...val, ...fixedColumnNames]))
30
+ })
31
+ }
32
+
33
+ return {
34
+ selectedColumnNames,
35
+ visibleColumns,
36
+ openColumnSelectorDialog,
37
+ }
38
+ }
@@ -9,6 +9,14 @@ export interface TableColumn {
9
9
  sortable?: boolean
10
10
  filterType: 'single' | 'multi' | null
11
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
12
20
  }
13
21
 
14
22
  export interface FilterOption {
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ import AppTablePagination from '@/common/app-table/components/TablePagination.vu
19
19
  import AppTableSearch from '@/common/app-table/components/TableSearch.vue'
20
20
  import AppTableModal from '@/common/app-table/components/TableModal.vue'
21
21
  import AppTable from '@/common/app-table/AppTable.vue'
22
+ import AppTableLayout from '@/common/app-table/AppTableLayout.vue'
22
23
 
23
24
  import useGanttService from '@/api/services/GanttService'
24
25
  import useMetricsService from '@/api/services/MetricsService'
@@ -51,6 +52,7 @@ export {
51
52
  AppTableSearch,
52
53
  AppTableModal,
53
54
  AppTable,
55
+ AppTableLayout,
54
56
  }
55
57
 
56
58
  export {
@@ -64,7 +66,10 @@ export {
64
66
  useFileService,
65
67
  useControlsService,
66
68
  }
69
+ export { useBaseTable } from './common/app-table/controllers/useBaseTable'
67
70
  export { useTableModel } from './common/app-table/controllers/useTableModel'
71
+ export { useColumnSelector } from './common/app-table/controllers/useColumnSelector'
72
+
68
73
  export type { FilterOption, TableModel, TableColumn } from './common/app-table/controllers/useTableModel'
69
74
 
70
75
  export type { NotificationType } from './utils/notification'