shared-ritm 1.3.23 → 1.3.25

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.
@@ -264,8 +264,8 @@ export type Api_Task_Instrument_From_Warehouse = {
264
264
  id: string;
265
265
  name: string;
266
266
  warehouse_prepared_quantity: number;
267
+ instrument_type_plan_quantity: number;
267
268
  has_status: boolean;
268
- has_responsible: boolean;
269
269
  has_module: boolean;
270
270
  };
271
271
  export type Api_Task_Close_Reason = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.3.23",
3
+ "version": "1.3.25",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -290,8 +290,8 @@ export type Api_Task_Instrument_From_Warehouse = {
290
290
  id: string
291
291
  name: string
292
292
  warehouse_prepared_quantity: number
293
+ instrument_type_plan_quantity: number
293
294
  has_status: boolean
294
- has_responsible: boolean
295
295
  has_module: boolean
296
296
  }
297
297
 
@@ -2,6 +2,7 @@
2
2
  <q-select
3
3
  ref="select"
4
4
  v-model="selected"
5
+ :data-test="dataTest"
5
6
  :options="filteredOptions"
6
7
  :option-value="optionValue"
7
8
  :option-label="optionLabel"
@@ -61,6 +62,7 @@ interface AppQSelectProps {
61
62
  isDisabled?: boolean
62
63
  clearable?: boolean
63
64
  search?: boolean
65
+ dataTest?: string
64
66
  }
65
67
 
66
68
  const props = defineProps<AppQSelectProps>()
@@ -1,296 +1,298 @@
1
- <template>
2
- <label v-if="label" class="field-label">
3
- {{ label }}
4
- <span v-if="rules?.length && isShowRequired" class="required">*</span>
5
- </label>
6
-
7
- <q-select
8
- ref="select"
9
- v-model="selected"
10
- :options="filteredOptions"
11
- :disable="isDisabled"
12
- :multiple="multiple"
13
- :popup-content-class="'custom-select-menu'"
14
- :hide-selected="!showChip && !simple"
15
- :placeholder="isEmpty || (multiple && !showChip) ? placeholder : null"
16
- :loading="loading"
17
- :option-value="optionValue || 'value'"
18
- :option-label="optionLabel || 'label'"
19
- emit-value
20
- filled
21
- map-options
22
- stack-label
23
- :use-input="!hideSearch"
24
- :use-chips="!simple"
25
- :hide-bottom-space="hideBottomSpace"
26
- input-debounce="100"
27
- autocomplete=""
28
- :rules="rules"
29
- :popup-content-style="popupContentStyle"
30
- @virtual-scroll="onScroll"
31
- @filter="filterFn"
32
- @add="clearInputAfterFilterSelection"
33
- >
34
- <template v-if="multiple || showChip || 'selected' in slots" #selected-item="scope">
35
- <slot v-if="'selected' in slots && scope.opt" name="selected" :opt="scope.opt" />
36
- <q-chip
37
- v-else-if="scope.opt"
38
- removable
39
- :tabindex="scope.tabindex"
40
- :style="{ backgroundColor: chipColor }"
41
- icon-remove="close"
42
- text-color="secondary"
43
- @remove="scope.removeAtIndex(scope.index)"
44
- >
45
- {{ scope.opt[optionLabel || 'label'] }}
46
- </q-chip>
47
- </template>
48
-
49
- <template #append>
50
- <q-icon
51
- v-if="!isDisabled && !isEmpty"
52
- name="close"
53
- class="cursor-pointer clear-input"
54
- @click.stop="handleClear"
55
- />
56
- </template>
57
-
58
- <template #no-option>
59
- <div class="q-pa-sm">
60
- <q-item>
61
- <q-item-section class="wrapper-empty-text">
62
- {{ emptyText || 'Ничего не найдено' }}
63
- <button
64
- v-if="allowCreate && internalSearch && internalSearch.trim()"
65
- class="add-new-items"
66
- @click="handleCreateFromSearch"
67
- >
68
- Добавить
69
- </button>
70
- </q-item-section>
71
- </q-item>
72
- </div>
73
- </template>
74
-
75
- <template #option="scope">
76
- <q-item v-if="scope.opt.__loading" class="q-py-md q-ml-md">
77
- <q-spinner-dots size="24px" color="primary" />
78
- </q-item>
79
- <q-item v-else-if="'option' in slots" v-bind="scope.itemProps">
80
- <slot name="option" :opt="scope.opt" />
81
- </q-item>
82
- <q-item v-else v-bind="scope.itemProps">
83
- <q-item-section>{{ scope.opt[optionLabel || 'label'] }}</q-item-section>
84
- </q-item>
85
- </template>
86
- </q-select>
87
- </template>
88
-
89
- <script setup lang="ts">
90
- import { computed, defineEmits, defineProps, ref, Ref, useSlots } from 'vue'
91
- import { QSelect } from 'quasar'
92
- type Option = Record<string, any>
93
-
94
- interface AppQSelectProps {
95
- modelValue: any
96
- options: Option[]
97
- placeholder?: string | undefined
98
- emptyText?: string
99
- optionLabel?: string
100
- optionValue?: string
101
- label?: string
102
- multiple?: boolean
103
- loading?: boolean
104
- isShowRequired?: boolean
105
- isDisabled?: boolean
106
- allowCreate?: boolean
107
- isSearch?: boolean
108
- hideSearch?: boolean
109
- showChip?: boolean
110
- simple?: boolean
111
- hideBottomSpace?: boolean
112
- chipColor?: string
113
- height?: string
114
- borderColor?: string
115
- borderRadius?: string
116
- menuWidth?: string
117
- rules?: ((val: any) => boolean | string)[]
118
- popupContentStyle?: string
119
- }
120
-
121
- const props = defineProps<AppQSelectProps>()
122
- const emit = defineEmits(['update:modelValue', 'update:scroll', 'update:search', 'clear', 'create'])
123
-
124
- const slots = useSlots()
125
-
126
- const select = ref<QSelect | null>(null)
127
- const lcText: Ref<string> = ref('')
128
- const internalSearch = ref('')
129
-
130
- const selected = computed({
131
- get() {
132
- return props.modelValue
133
- },
134
- set(value) {
135
- emit('update:modelValue', value)
136
- },
137
- })
138
-
139
- const isEmpty = computed(() => {
140
- if (!props.modelValue && props.modelValue !== 0) return true
141
-
142
- return Array.isArray(props.modelValue) && !props.modelValue.length
143
- })
144
-
145
- function handleClear() {
146
- const emptyValue = props.multiple ? [] : null
147
- selected.value = emptyValue
148
- lcText.value = ''
149
- emit('update:modelValue', emptyValue)
150
- emit('clear')
151
- }
152
-
153
- const filteredOptions = computed(() => {
154
- const labelKey = props.optionLabel || 'label'
155
-
156
- const baseOptions =
157
- 'option' in slots
158
- ? props.options
159
- : props.options.filter(x => {
160
- const label = x[labelKey]
161
- return typeof label === 'string' && label.toLowerCase().includes(lcText.value)
162
- })
163
-
164
- if (props.loading) {
165
- return [
166
- ...baseOptions,
167
- {
168
- __loading: true,
169
- label: '__loading__',
170
- value: '__loading__',
171
- },
172
- ]
173
- }
174
-
175
- return baseOptions
176
- })
177
-
178
- function handleCreateFromSearch() {
179
- const labelKey = props.optionLabel || 'label'
180
- const valueKey = props.optionValue || 'value'
181
-
182
- const trimmed = internalSearch.value?.trim()
183
- if (!trimmed) return
184
-
185
- const newOption = {
186
- [labelKey]: trimmed,
187
- [valueKey]: trimmed,
188
- }
189
- emit('create', newOption)
190
- handleClear()
191
- }
192
-
193
- function filterFn(val: string, update: (cb: () => void) => void) {
194
- debouncedFilter(val, update)
195
- }
196
-
197
- const debouncedFilter = debounce((val: string, update: (cb: () => void) => void) => {
198
- internalSearch.value = val
199
- emit('update:search', val)
200
- update(() => {
201
- lcText.value = val.toLowerCase()
202
- })
203
- }, 500)
204
-
205
- function onScroll({ to, ref: qSelectRef }) {
206
- const totalOptions = qSelectRef.options.length
207
- if (to >= totalOptions - 1 && !lcText.value) {
208
- emit('update:scroll')
209
- }
210
- }
211
-
212
- function clearInputAfterFilterSelection() {
213
- if (!props.hideSearch && select.value) {
214
- select.value.updateInputValue('')
215
- }
216
- }
217
-
218
- function debounce<T>(fn: T, ms) {
219
- let timeoutId
220
- return function (...args) {
221
- clearTimeout(timeoutId)
222
- return new Promise(resolve => {
223
- timeoutId = setTimeout(() => {
224
- resolve(fn(...args))
225
- }, ms)
226
- })
227
- }
228
- }
229
- </script>
230
-
231
- <style lang="scss" scoped>
232
- .wrapper-empty-text {
233
- display: flex;
234
- align-items: center;
235
- justify-content: space-between;
236
- flex-direction: row;
237
- .add-new-items {
238
- background: #3f8cff;
239
- color: #fff;
240
- outline: none;
241
- border: none;
242
- border-radius: 4px;
243
- padding: 5px 10px;
244
- cursor: pointer;
245
- }
246
- }
247
- .field-label {
248
- font-size: 14px;
249
- font-weight: 700;
250
- color: #7d8592;
251
- }
252
- .required {
253
- color: #f65160;
254
- font-weight: bold;
255
- }
256
-
257
- ::v-deep(.q-placeholder) {
258
- color: #7d8592;
259
- }
260
- ::v-deep(.q-field__control) {
261
- border-radius: 8px;
262
- border: 1px solid #d8e0f0;
263
- background: #fff;
264
- box-shadow: 0 1px 2px 0 rgba(184, 200, 224, 0.22);
265
- }
266
- :deep(.q-field__control:before) {
267
- display: none;
268
- }
269
- :global(.q-field--filled.q-field--highlighted .q-field__control:before) {
270
- background: #fff !important;
271
- border: none;
272
- }
273
- ::v-deep(.q-field--with-bottom) {
274
- padding-bottom: 0;
275
- }
276
- ::v-deep(.q-field__bottom) {
277
- padding: 0;
278
- }
279
- .clear-input {
280
- color: #d8e0f0;
281
- }
282
- ::v-deep(.q-chip) {
283
- border-radius: 4px;
284
- background: #e9eff9;
285
- color: #1d425d;
286
- font-family: NunitoSansFont, sans-serif;
287
- font-size: 14px;
288
- height: 30px;
289
- line-height: 30px;
290
- padding: 0 15px;
291
- .q-chip__icon {
292
- color: #3f8cff;
293
- margin-left: 5px;
294
- }
295
- }
296
- </style>
1
+ <template>
2
+ <label v-if="label" class="field-label" :data-test="`${dataTest}-label`">
3
+ {{ label }}
4
+ <span v-if="rules?.length && isShowRequired" class="required">*</span>
5
+ </label>
6
+
7
+ <q-select
8
+ ref="select"
9
+ v-model="selected"
10
+ :data-test="dataTest"
11
+ :options="filteredOptions"
12
+ :disable="isDisabled"
13
+ :multiple="multiple"
14
+ :popup-content-class="'custom-select-menu'"
15
+ :hide-selected="!showChip && !simple"
16
+ :placeholder="isEmpty || (multiple && !showChip) ? placeholder : null"
17
+ :loading="loading"
18
+ :option-value="optionValue || 'value'"
19
+ :option-label="optionLabel || 'label'"
20
+ emit-value
21
+ filled
22
+ map-options
23
+ stack-label
24
+ :use-input="!hideSearch"
25
+ :use-chips="!simple"
26
+ :hide-bottom-space="hideBottomSpace"
27
+ input-debounce="100"
28
+ autocomplete=""
29
+ :rules="rules"
30
+ :popup-content-style="popupContentStyle"
31
+ @virtual-scroll="onScroll"
32
+ @filter="filterFn"
33
+ @add="clearInputAfterFilterSelection"
34
+ >
35
+ <template v-if="multiple || showChip || 'selected' in slots" #selected-item="scope">
36
+ <slot v-if="'selected' in slots && scope.opt" name="selected" :opt="scope.opt" />
37
+ <q-chip
38
+ v-else-if="scope.opt"
39
+ removable
40
+ :tabindex="scope.tabindex"
41
+ :style="{ backgroundColor: chipColor }"
42
+ icon-remove="close"
43
+ text-color="secondary"
44
+ @remove="scope.removeAtIndex(scope.index)"
45
+ >
46
+ {{ scope.opt[optionLabel || 'label'] }}
47
+ </q-chip>
48
+ </template>
49
+
50
+ <template #append>
51
+ <q-icon
52
+ v-if="!isDisabled && !isEmpty"
53
+ name="close"
54
+ class="cursor-pointer clear-input"
55
+ @click.stop="handleClear"
56
+ />
57
+ </template>
58
+
59
+ <template #no-option>
60
+ <div class="q-pa-sm">
61
+ <q-item>
62
+ <q-item-section class="wrapper-empty-text">
63
+ {{ emptyText || 'Ничего не найдено' }}
64
+ <button
65
+ v-if="allowCreate && internalSearch && internalSearch.trim()"
66
+ class="add-new-items"
67
+ @click="handleCreateFromSearch"
68
+ >
69
+ Добавить
70
+ </button>
71
+ </q-item-section>
72
+ </q-item>
73
+ </div>
74
+ </template>
75
+
76
+ <template #option="scope">
77
+ <q-item v-if="scope.opt.__loading" class="q-py-md q-ml-md">
78
+ <q-spinner-dots size="24px" color="primary" />
79
+ </q-item>
80
+ <q-item v-else-if="'option' in slots" v-bind="scope.itemProps">
81
+ <slot name="option" :opt="scope.opt" />
82
+ </q-item>
83
+ <q-item v-else v-bind="scope.itemProps">
84
+ <q-item-section>{{ scope.opt[optionLabel || 'label'] }}</q-item-section>
85
+ </q-item>
86
+ </template>
87
+ </q-select>
88
+ </template>
89
+
90
+ <script setup lang="ts">
91
+ import { computed, defineEmits, defineProps, ref, Ref, useSlots } from 'vue'
92
+ import { QSelect } from 'quasar'
93
+ type Option = Record<string, any>
94
+
95
+ interface AppQSelectProps {
96
+ modelValue: any
97
+ options: Option[]
98
+ placeholder?: string | undefined
99
+ emptyText?: string
100
+ optionLabel?: string
101
+ optionValue?: string
102
+ label?: string
103
+ multiple?: boolean
104
+ loading?: boolean
105
+ isShowRequired?: boolean
106
+ isDisabled?: boolean
107
+ allowCreate?: boolean
108
+ isSearch?: boolean
109
+ hideSearch?: boolean
110
+ showChip?: boolean
111
+ simple?: boolean
112
+ hideBottomSpace?: boolean
113
+ chipColor?: string
114
+ height?: string
115
+ borderColor?: string
116
+ borderRadius?: string
117
+ menuWidth?: string
118
+ rules?: ((val: any) => boolean | string)[]
119
+ popupContentStyle?: string
120
+ dataTest?: string
121
+ }
122
+
123
+ const props = defineProps<AppQSelectProps>()
124
+ const emit = defineEmits(['update:modelValue', 'update:scroll', 'update:search', 'clear', 'create'])
125
+
126
+ const slots = useSlots()
127
+
128
+ const select = ref<QSelect | null>(null)
129
+ const lcText: Ref<string> = ref('')
130
+ const internalSearch = ref('')
131
+
132
+ const selected = computed({
133
+ get() {
134
+ return props.modelValue
135
+ },
136
+ set(value) {
137
+ emit('update:modelValue', value)
138
+ },
139
+ })
140
+
141
+ const isEmpty = computed(() => {
142
+ if (!props.modelValue && props.modelValue !== 0) return true
143
+
144
+ return Array.isArray(props.modelValue) && !props.modelValue.length
145
+ })
146
+
147
+ function handleClear() {
148
+ const emptyValue = props.multiple ? [] : null
149
+ selected.value = emptyValue
150
+ lcText.value = ''
151
+ emit('update:modelValue', emptyValue)
152
+ emit('clear')
153
+ }
154
+
155
+ const filteredOptions = computed(() => {
156
+ const labelKey = props.optionLabel || 'label'
157
+
158
+ const baseOptions =
159
+ 'option' in slots
160
+ ? props.options
161
+ : props.options.filter(x => {
162
+ const label = x[labelKey]
163
+ return typeof label === 'string' && label.toLowerCase().includes(lcText.value)
164
+ })
165
+
166
+ if (props.loading) {
167
+ return [
168
+ ...baseOptions,
169
+ {
170
+ __loading: true,
171
+ label: '__loading__',
172
+ value: '__loading__',
173
+ },
174
+ ]
175
+ }
176
+
177
+ return baseOptions
178
+ })
179
+
180
+ function handleCreateFromSearch() {
181
+ const labelKey = props.optionLabel || 'label'
182
+ const valueKey = props.optionValue || 'value'
183
+
184
+ const trimmed = internalSearch.value?.trim()
185
+ if (!trimmed) return
186
+
187
+ const newOption = {
188
+ [labelKey]: trimmed,
189
+ [valueKey]: trimmed,
190
+ }
191
+ emit('create', newOption)
192
+ handleClear()
193
+ }
194
+
195
+ function filterFn(val: string, update: (cb: () => void) => void) {
196
+ debouncedFilter(val, update)
197
+ }
198
+
199
+ const debouncedFilter = debounce((val: string, update: (cb: () => void) => void) => {
200
+ internalSearch.value = val
201
+ emit('update:search', val)
202
+ update(() => {
203
+ lcText.value = val.toLowerCase()
204
+ })
205
+ }, 500)
206
+
207
+ function onScroll({ to, ref: qSelectRef }) {
208
+ const totalOptions = qSelectRef.options.length
209
+ if (to >= totalOptions - 1 && !lcText.value) {
210
+ emit('update:scroll')
211
+ }
212
+ }
213
+
214
+ function clearInputAfterFilterSelection() {
215
+ if (!props.hideSearch && select.value) {
216
+ select.value.updateInputValue('')
217
+ }
218
+ }
219
+
220
+ function debounce<T>(fn: T, ms) {
221
+ let timeoutId
222
+ return function (...args) {
223
+ clearTimeout(timeoutId)
224
+ return new Promise(resolve => {
225
+ timeoutId = setTimeout(() => {
226
+ resolve(fn(...args))
227
+ }, ms)
228
+ })
229
+ }
230
+ }
231
+ </script>
232
+
233
+ <style lang="scss" scoped>
234
+ .wrapper-empty-text {
235
+ display: flex;
236
+ align-items: center;
237
+ justify-content: space-between;
238
+ flex-direction: row;
239
+ .add-new-items {
240
+ background: #3f8cff;
241
+ color: #fff;
242
+ outline: none;
243
+ border: none;
244
+ border-radius: 4px;
245
+ padding: 5px 10px;
246
+ cursor: pointer;
247
+ }
248
+ }
249
+ .field-label {
250
+ font-size: 14px;
251
+ font-weight: 700;
252
+ color: #7d8592;
253
+ }
254
+ .required {
255
+ color: #f65160;
256
+ font-weight: bold;
257
+ }
258
+
259
+ ::v-deep(.q-placeholder) {
260
+ color: #7d8592;
261
+ }
262
+ ::v-deep(.q-field__control) {
263
+ border-radius: 8px;
264
+ border: 1px solid #d8e0f0;
265
+ background: #fff;
266
+ box-shadow: 0 1px 2px 0 rgba(184, 200, 224, 0.22);
267
+ }
268
+ :deep(.q-field__control:before) {
269
+ display: none;
270
+ }
271
+ :global(.q-field--filled.q-field--highlighted .q-field__control:before) {
272
+ background: #fff !important;
273
+ border: none;
274
+ }
275
+ ::v-deep(.q-field--with-bottom) {
276
+ padding-bottom: 0;
277
+ }
278
+ ::v-deep(.q-field__bottom) {
279
+ padding: 0;
280
+ }
281
+ .clear-input {
282
+ color: #d8e0f0;
283
+ }
284
+ ::v-deep(.q-chip) {
285
+ border-radius: 4px;
286
+ background: #e9eff9;
287
+ color: #1d425d;
288
+ font-family: NunitoSansFont, sans-serif;
289
+ font-size: 14px;
290
+ height: 30px;
291
+ line-height: 30px;
292
+ padding: 0 15px;
293
+ .q-chip__icon {
294
+ color: #3f8cff;
295
+ margin-left: 5px;
296
+ }
297
+ }
298
+ </style>