shared-ritm 1.0.20 → 1.0.22

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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "private": false,
5
5
  "files": [
6
- "dist"
6
+ "dist",
7
+ "src"
7
8
  ],
8
9
  "main": "dist/shared-ritm.umd.js",
9
10
  "type": "module",
@@ -12,10 +13,10 @@
12
13
  "exports": {
13
14
  ".": {
14
15
  "import": "./dist/shared-ritm.es.js",
15
- "require": "./dist/shared-ritm.umd.js"
16
+ "require": "./dist/shared-ritm.umd.js",
17
+ "default": "./dist/shared-ritm.es.js"
16
18
  },
17
- "./styles.css": "./dist/styles.css",
18
- "./styles.scss": "./dist/styles.scss"
19
+ "./style": "./dist/index.css"
19
20
  },
20
21
  "scripts": {
21
22
  "dev": "vite",
package/src/App.vue ADDED
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <app-button label="asad" color="primary" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import AppButton from '@/common/app-button/AppButton.vue'
7
+ </script>
8
+ <style lang="scss"></style>
@@ -0,0 +1,17 @@
1
+ import ApiService from '@/api/settings/ApiService'
2
+
3
+ class GanttService extends ApiService {
4
+ public async fetchCriticalPathTasks(params: string): Promise<any> {
5
+ return await this.get(`gantt/get_list_task_on_critical_path?${params}`)
6
+ }
7
+ public async fetchGanttList(params: string): Promise<any> {
8
+ return await this.get(`/gantt/tasks?${params}`)
9
+ }
10
+ }
11
+
12
+ let api: GanttService
13
+
14
+ export default function useGanttService() {
15
+ if (!api) api = new GanttService()
16
+ return api
17
+ }
@@ -0,0 +1,74 @@
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+
3
+ class MetricsService extends ApiService {
4
+ public async fetchPieProjects(queryString: string): Promise<ResponseApi<any>> {
5
+ return await this.get('repairs/pie/projects' + '?' + queryString)
6
+ }
7
+
8
+ public async fetchPieTasks(queryString: string): Promise<ResponseApi<any>> {
9
+ return await this.get('repairs/pie/tasks' + '?' + queryString)
10
+ }
11
+
12
+ public async fetchPiePersonnel(queryString: string): Promise<ResponseApi<any>> {
13
+ return await this.get('repairs/metrics/get_list_position' + '?' + queryString)
14
+ }
15
+
16
+ public async fetchPiePersonnelInfo(params: string): Promise<any> {
17
+ return await this.get(`repairs/metrics/get_list_user_by_position?${params}`)
18
+ }
19
+
20
+ public async fetchPieWorkZone(queryString: string): Promise<ResponseApi<any>> {
21
+ return await this.get('repairs/metrics/get_list_work_zone_instrument' + '?' + queryString)
22
+ }
23
+
24
+ public async fetchPieCriticalPath(queryString: string): Promise<any[]> {
25
+ return await this.get('repairs/metrics/get_critical_path_group_by_status' + '?' + queryString)
26
+ }
27
+
28
+ public async fetchPieCriticalPathInfo(params: string): Promise<any> {
29
+ return await this.get(`repairs/metrics/get_list_task_critical_path_by_status?${params}`)
30
+ }
31
+
32
+ public async fetchPieTmc(queryString: string): Promise<ResponseApi<any>> {
33
+ return await this.get('repairs/metrics/get_list_instrument_type' + '?' + queryString)
34
+ }
35
+
36
+ public async fetchPieTmcInfo(params: string): Promise<any> {
37
+ return await this.get(`repairs/metrics/get_list_warehouse_by_instrument_type?${params}`)
38
+ }
39
+
40
+ public async fetchPieUntimelyClosedTask(queryString: string): Promise<any[]> {
41
+ return await this.get('repairs/metrics/get_list_comment_type' + '?' + queryString)
42
+ }
43
+
44
+ public async fetchPieUntimelyClosedTaskInfo(params: string): Promise<any> {
45
+ return await this.get(`repairs/metrics/get_list_task_by_comment_type?${params}`)
46
+ }
47
+
48
+ public async fetchPieAdditionalTasks(queryString: string): Promise<any[]> {
49
+ return await this.get('repairs/metrics/get_list_task_after_plan_fixate_group_by_status' + '?' + queryString)
50
+ }
51
+
52
+ public async fetchPieAdditionalTasksInfo(params: string): Promise<any> {
53
+ return await this.get(`repairs/metrics/get_list_task_after_plan_fixate_by_status?${params}`)
54
+ }
55
+
56
+ public async fetchPersonnel(queryString: string): Promise<any[]> {
57
+ return await this.get('repairs/statistic/personnel' + '?' + queryString)
58
+ }
59
+
60
+ public async fetchPieExpired(queryString: string): Promise<any[]> {
61
+ return await this.get('repairs/metrics/get_list_task_expired_group_by_status' + '?' + queryString)
62
+ }
63
+
64
+ public async fetchPieExpiredInfo(params: string): Promise<any> {
65
+ return await this.get(`repairs/metrics/get_list_task_expired?${params}`)
66
+ }
67
+ }
68
+
69
+ let api: MetricsService
70
+
71
+ export default function useMetricsService() {
72
+ if (!api) api = new MetricsService()
73
+ return api
74
+ }
@@ -0,0 +1,15 @@
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+ import { Api_Tasks_Task_Dto } from '@/api/types/Api_Tasks'
3
+
4
+ class ProjectsService extends ApiService {
5
+ public async fetchProjectById(id: string): Promise<ResponseApi<Api_Tasks_Task_Dto>> {
6
+ return await this.get(`/projects/${id}`)
7
+ }
8
+ }
9
+
10
+ let api: ProjectsService
11
+
12
+ export default function useProjectsService() {
13
+ if (!api) api = new ProjectsService()
14
+ return api
15
+ }
@@ -0,0 +1,76 @@
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+ import {
3
+ Api_Create_Repair_With_Equipments,
4
+ Api_Equipment_Full_Dto,
5
+ Api_Repair_Dto,
6
+ Api_Update_Repair,
7
+ OptionFilters,
8
+ } from '@/api/types/Api_Repairs'
9
+
10
+ class RepairsService extends ApiService {
11
+ public fetchFilters(fullParams: string): Promise<OptionFilters> {
12
+ return this.get(`repairs?smart=1&${fullParams}`)
13
+ }
14
+ public fetchRepairs(
15
+ isQuery: boolean,
16
+ queries?: string,
17
+ hasTeams?: boolean | string,
18
+ teamsFilter?: string,
19
+ typeFilter?: string,
20
+ ): Promise<ResponseApi<Api_Repair_Dto[]>> {
21
+ return this.get(
22
+ 'repairs' +
23
+ (isQuery
24
+ ? `${queries}&per_page=100000${typeFilter ? '&' + typeFilter : ''}&${!hasTeams ? teamsFilter : ''}`
25
+ : `?per_page=100000${typeFilter ? '&' + typeFilter : ''}&${teamsFilter}`),
26
+ )
27
+ }
28
+ public fetchEquipment(): Promise<ResponseApi<Api_Equipment_Full_Dto[]>> {
29
+ return this.get('repairs/equipment/list?per_page=100000')
30
+ }
31
+ public createRepair(payload: Api_Create_Repair_With_Equipments) {
32
+ return this.post<Api_Create_Repair_With_Equipments, any>('/repairs/equipments', payload)
33
+ }
34
+ public startRepair(id: string): Promise<void> {
35
+ return this.post<null, void>(`/repairs/${id}/start`, null)
36
+ }
37
+ public finishRepair(id: string) {
38
+ return this.post<null, void>(`/repairs/${id}/finish`, null)
39
+ }
40
+ public finishPreparationProject(id: string) {
41
+ return this.post<null, void>(`/repairs/${id}/finish_preparation`, null)
42
+ }
43
+ public moveRepairToCurrent(id: string) {
44
+ return this.post<any, void>(`/repairs/transfer_repair_plan_to_current`, {
45
+ repairs: [id],
46
+ })
47
+ }
48
+ public moveArchiveToCurrent(id: string) {
49
+ return this.post<any, void>(`/repairs/transfer_repair_archive_to_current`, {
50
+ repairs_ids: [id],
51
+ })
52
+ }
53
+ public moveRepairToApr(id: string) {
54
+ return this.post<any, void>(`/repairs/transfer_repair_current_to_plan`, {
55
+ repairs: [id],
56
+ })
57
+ }
58
+ public moveRepairToArchive(id: string) {
59
+ return this.post<any, void>(`/repairs/transfer_repair_current_to_archive`, {
60
+ repairs_ids: [id],
61
+ })
62
+ }
63
+ public updateRepair(payload: Api_Update_Repair, id: string) {
64
+ return this.put<Api_Update_Repair, void>(`/repairs/${id}`, payload)
65
+ }
66
+ public deleteRepair(id: string) {
67
+ return this.delete<any>(`/repairs/${id}`)
68
+ }
69
+ }
70
+
71
+ let api: RepairsService
72
+
73
+ export default function useRepairsService() {
74
+ if (!api) api = new RepairsService()
75
+ return api
76
+ }
@@ -0,0 +1,15 @@
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+ import { Api_Tasks_Task_Dto } from '@/api/types/Api_Tasks'
3
+
4
+ class TasksService extends ApiService {
5
+ public async fetchTaskById(id: string): Promise<ResponseApi<Api_Tasks_Task_Dto>> {
6
+ return await this.get(`/tasks/${id}`)
7
+ }
8
+ }
9
+
10
+ let api: TasksService
11
+
12
+ export default function useTasksService() {
13
+ if (!api) api = new TasksService()
14
+ return api
15
+ }
@@ -0,0 +1,124 @@
1
+ import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
2
+
3
+ export enum ApiServiceType {
4
+ SERVICE_AUTH = 'SERVICE_AUTH',
5
+ }
6
+
7
+ export type ResponseApi<T> = {
8
+ count: number
9
+ current_page: number
10
+ data: T
11
+ per_page: number
12
+ total: number
13
+ total_pages: number
14
+ }
15
+
16
+ export default class ApiService {
17
+ private axiosInstance: AxiosInstance
18
+
19
+ constructor() {
20
+ this.axiosInstance = axios.create({
21
+ baseURL: process.env.VUE_APP_BACKEND,
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ },
25
+ })
26
+
27
+ this.axiosInstance.interceptors.request.use(
28
+ (config: InternalAxiosRequestConfig) => {
29
+ const token = this.getToken()
30
+ if (token && config.headers) {
31
+ config.headers.Authorization = `Bearer ${token}`
32
+ }
33
+ return config
34
+ },
35
+ (error: AxiosError) => {
36
+ return Promise.reject(error)
37
+ },
38
+ )
39
+
40
+ this.axiosInstance.interceptors.response.use(
41
+ (response: AxiosResponse) => {
42
+ return response.data
43
+ },
44
+ (error: AxiosError) => {
45
+ if (error.response?.status === 401 || error.response?.status === 403) {
46
+ this.logout()
47
+ }
48
+ return Promise.reject(error)
49
+ },
50
+ )
51
+ }
52
+ private getToken() {
53
+ return localStorage.getItem('token')
54
+ }
55
+
56
+ private removeToken() {
57
+ localStorage.removeItem('token')
58
+ }
59
+
60
+ private logout(): void {
61
+ this.removeToken()
62
+ window.location.href = '/sign-in'
63
+ }
64
+
65
+ private handleError(error: AxiosError): void {
66
+ if (error.response) {
67
+ console.error('API Error:', error.response.status, error.response.data)
68
+ } else if (error.request) {
69
+ console.error('No response received:', error.request)
70
+ } else {
71
+ console.error('Error during request setup:', error.message)
72
+ }
73
+ }
74
+
75
+ protected async get<T>(url: string, options?: AxiosRequestConfig) {
76
+ try {
77
+ const response: AxiosResponse<T> = await this.axiosInstance.get<T>(url, options)
78
+ return response?.data ?? (response as unknown as T)
79
+ } catch (error) {
80
+ const axiosError = error as AxiosError
81
+ this.handleError(axiosError)
82
+ throw error
83
+ }
84
+ }
85
+
86
+ protected async delete<T>(url: string, options?: AxiosRequestConfig) {
87
+ try {
88
+ return await this.axiosInstance.delete<T>(url, options)
89
+ } catch (error) {
90
+ const axiosError = error as AxiosError
91
+ this.handleError(axiosError)
92
+ throw error
93
+ }
94
+ }
95
+
96
+ protected async post<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
97
+ try {
98
+ const response: AxiosResponse<T2> = await this.axiosInstance.post<T1, AxiosResponse<T2>>(url, payload, options)
99
+ return response.data
100
+ } catch (error) {
101
+ const axiosError = error as AxiosError
102
+ this.handleError(axiosError)
103
+ throw error
104
+ }
105
+ }
106
+
107
+ // protected patch<T1, T2>(url: string, payload: T1, type: ApiServiceType, options?: AxiosRequestConfig): Promise<T2> {
108
+ // return axios
109
+ // .patch<T1, AxiosResponse<T2>>(apiServiceUrls[type] + url, payload, options)
110
+ // .catch((err: AxiosError) => processError401<T2>(err))
111
+ // .then(extractData)
112
+ // }
113
+ //
114
+ protected async put<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
115
+ try {
116
+ const response: AxiosResponse<T2> = await this.axiosInstance.put<T1, AxiosResponse<T2>>(url, payload, options)
117
+ return response.data
118
+ } catch (error) {
119
+ const axiosError = error as AxiosError
120
+ this.handleError(axiosError)
121
+ throw error
122
+ }
123
+ }
124
+ }
File without changes
@@ -0,0 +1,57 @@
1
+ export type Api_Team = {
2
+ id: string
3
+ display_name: string
4
+ }
5
+
6
+ export type Api_Equipment_Short_Dto = {
7
+ id: string
8
+ name: string
9
+ }
10
+
11
+ export type Api_Repairs = {
12
+ id: string
13
+ name: string
14
+ }
15
+
16
+ export type Api_Projects = {
17
+ id: string
18
+ name: string
19
+ }
20
+
21
+ export type OptionFilters = {
22
+ teams?: Api_Team[]
23
+ equipments?: Api_Equipment_Short_Dto[]
24
+ }
25
+
26
+ export type Api_Equipment_Full_Dto = {
27
+ id: string
28
+ model: null | string
29
+ name: string
30
+ registration_number: string
31
+ repair_frequency: number
32
+ repair_range: number
33
+ }
34
+
35
+ export type Api_Create_Repair_With_Equipments = {
36
+ name: string
37
+ display_name: string
38
+ description: string
39
+ equipment_id: string
40
+ }
41
+
42
+ export type Api_Update_Repair = {
43
+ name?: string
44
+ display_name?: string
45
+ description: string
46
+ }
47
+
48
+ export type Api_Repair_Dto = {
49
+ id: string
50
+ name: string
51
+ display_name: string
52
+ description: string
53
+ start_date: string
54
+ end_date: string
55
+ projects: Api_Projects[]
56
+ equipments: Api_Equipment_Full_Dto[]
57
+ }
@@ -0,0 +1,99 @@
1
+ export type Api_Tasks_Responsible_Dto = {
2
+ id: string
3
+ first_name: string
4
+ last_name: string
5
+ patronymic: string
6
+ full_name: string
7
+ }
8
+
9
+ export type Api_Tasks_Assigned_Dto = {
10
+ id: string
11
+ first_name: string
12
+ last_name: string
13
+ patronymic: null | string
14
+ full_name: string
15
+ }
16
+
17
+ export type Api_Tasks_Status_Dto = {
18
+ id: string
19
+ name: string
20
+ title: string
21
+ }
22
+ export type Api_Tasks_Project_Dto = {
23
+ id: string
24
+ name: string
25
+ teams: string[]
26
+ }
27
+ export type Api_Tasks_Position_Dto = {
28
+ id: string
29
+ name: string
30
+ display_name: string
31
+ }
32
+
33
+ export type Api_Tasks_Position_Assigned_Dto = {
34
+ id: number
35
+ user: {
36
+ id: string
37
+ full_name: string
38
+ }
39
+ position: Api_Tasks_Position_Dto
40
+ }
41
+
42
+ export type Api_Tasks_Teams_Dto = {
43
+ id: string
44
+ name: string
45
+ display_name: string
46
+ }
47
+
48
+ export type Api_Tasks_Equipment_Dto = {
49
+ id: string
50
+ name: string
51
+ model: string
52
+ registration_number: string
53
+ created_at: string
54
+ updated_at: string
55
+ repair_frequency: number
56
+ repair_range: number
57
+ }
58
+
59
+ export type Api_Tasks_Task_Dto = {
60
+ id: string
61
+ name: string
62
+ type: string
63
+ project_id: string
64
+ description: string
65
+ subtask_counter: number
66
+ subtasks: Api_Tasks_Task_Dto[]
67
+ state_id: null | string
68
+ start_date: string
69
+ end_date: string
70
+ deadline: string
71
+ plan_date: string
72
+ time_to_complete: null | string | number
73
+ time_to_complete_sec: number
74
+ priority: number
75
+ work_zone_id: null | string
76
+ location_id: null | string
77
+ target: any
78
+ status: Api_Tasks_Status_Dto
79
+ project: Api_Tasks_Project_Dto
80
+ position: Api_Tasks_Position_Dto[]
81
+ assigned: Api_Tasks_Assigned_Dto[]
82
+ instruments: any[]
83
+ warehouse: any[]
84
+ responsible: Api_Tasks_Responsible_Dto[]
85
+ position_assigned: Api_Tasks_Position_Assigned_Dto[]
86
+ comments: any[]
87
+ files: any[]
88
+ teams: Api_Tasks_Teams_Dto[]
89
+ work_zone: string
90
+ planned_start: null | string
91
+ planned_end: null | string
92
+ fact_start_date: string
93
+ fact_end_date: null | string
94
+ work_sec: number
95
+ pause_sec: number
96
+ repair_object: null | string
97
+ isPause: boolean
98
+ equipment: Api_Tasks_Equipment_Dto[]
99
+ }
@@ -0,0 +1,156 @@
1
+ <template>
2
+ <q-btn
3
+ v-bind="$props"
4
+ :class="[$style.wrapper]"
5
+ :disable="isDisabled"
6
+ :no-caps="!uppercase"
7
+ :no-wrap="!wrap"
8
+ class="hover-bg-secondary hover-text-black"
9
+ @click="onClick"
10
+ >
11
+ <slot></slot>
12
+ <q-badge
13
+ v-if="badge"
14
+ style="padding: 6px; top: -10px; right: -10px; font-size: 12px"
15
+ :color="badgeColor"
16
+ :floating="!badgeInline"
17
+ :rounded="true"
18
+ >{{ badgeText }}</q-badge
19
+ >
20
+ <q-tooltip v-if="tooltip" class="text-body2" :delay="400">{{ tooltip }}</q-tooltip>
21
+ </q-btn>
22
+ </template>
23
+
24
+ <script lang="ts" setup>
25
+ import { computed, defineProps, defineEmits } from 'vue'
26
+
27
+ interface QBtnProps {
28
+ size?: string | undefined
29
+ type?: string | undefined
30
+ to?: string | any | undefined
31
+ replace?: boolean | undefined
32
+ href?: string | undefined
33
+ target?: string | undefined
34
+ label?: string | number | undefined
35
+ icon?: string | undefined
36
+ iconRight?: string | undefined
37
+ outline?: boolean | undefined
38
+ flat?: boolean | undefined
39
+ unelevated?: boolean | undefined
40
+ rounded?: boolean | undefined
41
+ push?: boolean | undefined
42
+ square?: boolean | undefined
43
+ glossy?: boolean | undefined
44
+ fab?: boolean | undefined
45
+ fabMini?: boolean | undefined
46
+ padding?: string | undefined
47
+ color?: string | undefined
48
+ textColor?: string | undefined
49
+ noCaps?: boolean | undefined
50
+ noWrap?: boolean | undefined
51
+ dense?: boolean | undefined
52
+ ripple?: boolean | any | undefined
53
+ tabindex?: number | string | undefined
54
+ align?: 'left' | 'right' | 'center' | 'around' | 'between' | 'evenly' | undefined
55
+ stack?: boolean | undefined
56
+ stretch?: boolean | undefined
57
+ loading?: boolean | undefined
58
+ round?: boolean | undefined
59
+ percentage?: number | undefined
60
+ darkPercentage?: boolean | undefined
61
+ }
62
+
63
+ interface Props extends QBtnProps {
64
+ disable?: boolean | ((...args: any[]) => boolean)
65
+ tooltip?: string
66
+ uppercase?: boolean
67
+ xSmall?: boolean
68
+ small?: boolean
69
+ large?: boolean
70
+ fullWidth?: boolean
71
+ wrap?: boolean
72
+ largeIcon?: boolean
73
+ modelValue?: boolean
74
+ badge?: string | boolean | number
75
+ badgeColor?: string
76
+ badgeInline?: boolean
77
+ link?: boolean
78
+ }
79
+
80
+ const props = defineProps<Props>()
81
+
82
+ const emit = defineEmits(['update:modelValue', 'click'])
83
+
84
+ function onClick(event: any) {
85
+ emit('click', event)
86
+ emit('update:modelValue', !props.modelValue)
87
+ }
88
+
89
+ const badgeText = computed(() => {
90
+ if (props.badge === undefined || props.badge === false) return ''
91
+ if (props.badge === true || props.badge === '') return ''
92
+ return props.badge
93
+ })
94
+
95
+ // const btnClasses = computed(() => {
96
+ // return {
97
+ // '--icon': props.icon && !props.label,
98
+ // '--width-left-icon': props.icon && props.label,
99
+ // '--width-right-icon': props.iconRight && props.label,
100
+ // '--default': !props.small && !props.large && !props.xSmall,
101
+ // '--x-small': props.xSmall,
102
+ // '--small': props.small,
103
+ // '--large': props.large,
104
+ // '--full-width': props.fullWidth,
105
+ // '--large-icon': props.largeIcon,
106
+ // '--is-active': props.modelValue,
107
+ // '--link': props.link,
108
+ // '--loading': props.loading,
109
+ // }
110
+ // })
111
+
112
+ const isDisabled = computed(() => {
113
+ return typeof props.disable === 'function' ? props.disable() : props.disable
114
+ })
115
+ </script>
116
+
117
+ <style lang="scss" module>
118
+ .wrapper {
119
+ flex: 0 0 auto;
120
+ &:global(.q-btn--rounded) {
121
+ border-radius: 14px !important;
122
+ }
123
+ &:global(.q-btn) {
124
+ color: #0a1629;
125
+ font-size: 16px;
126
+ font-style: normal;
127
+ font-weight: 700;
128
+ }
129
+
130
+ &:global(.--loading) {
131
+ span:has(> svg) {
132
+ overflow: hidden;
133
+ }
134
+ }
135
+
136
+ :global(.q-icon) {
137
+ font-size: 1.2em;
138
+ }
139
+
140
+ &:global(.--large-icon .q-icon) {
141
+ font-size: 1.715em;
142
+ }
143
+
144
+ &:global(.--full-width) {
145
+ width: 100%;
146
+ }
147
+
148
+ &:global(.--link) {
149
+ padding: 0 8px;
150
+ display: inline;
151
+ min-height: unset;
152
+ font-size: inherit;
153
+ text-decoration: underline;
154
+ }
155
+ }
156
+ </style>