@mythpe/quasar-ui-qui 0.4.26 → 0.4.28
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
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type { ApiInterface, GenericMDtBtn, MDatatableProps } from '../../types'
|
|
14
14
|
import type { InvalidSubmissionHandler, SubmissionHandler } from 'vee-validate'
|
|
15
15
|
import { useForm } from 'vee-validate'
|
|
16
|
-
import { computed, onMounted, ref, toValue, useAttrs, watch } from 'vue'
|
|
16
|
+
import { computed, nextTick, onMounted, ref, toValue, useAttrs, watch } from 'vue'
|
|
17
17
|
import { is as quasarHelpers, QCardSection, QTable, useQuasar } from 'quasar'
|
|
18
18
|
import { useDtHelpers, useMyth } from '../../composable'
|
|
19
19
|
import { useI18n } from 'vue-i18n'
|
|
@@ -52,11 +52,12 @@ type Props = {
|
|
|
52
52
|
hideShowBtn?: boolean;
|
|
53
53
|
hideDestroyBtn?: boolean;
|
|
54
54
|
storeRoute?: MDatatableProps['storeRoute'];
|
|
55
|
-
storeCallback?: MDatatableProps['storeCallback'];
|
|
56
55
|
storeQueryParams?: boolean;
|
|
56
|
+
noStoreClose?: boolean;
|
|
57
57
|
updateRoute?: MDatatableProps['updateRoute'];
|
|
58
|
-
updateCallback?: MDatatableProps['updateCallback'];
|
|
59
58
|
updateQueryParams?: boolean;
|
|
59
|
+
noUpdateClose?: boolean;
|
|
60
|
+
noAutoClose?: boolean;
|
|
60
61
|
showRoute?: MDatatableProps['showRoute'];
|
|
61
62
|
showQueryParams?: boolean;
|
|
62
63
|
noMouse?: MDatatableProps['noMouse'];
|
|
@@ -136,11 +137,12 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
136
137
|
hideShowBtn: !1,
|
|
137
138
|
hideDestroyBtn: !1,
|
|
138
139
|
storeRoute: undefined,
|
|
139
|
-
storeCallback: undefined,
|
|
140
140
|
storeQueryParams: !1,
|
|
141
|
+
noStoreClose: !1,
|
|
141
142
|
updateRoute: undefined,
|
|
142
|
-
updateCallback: undefined,
|
|
143
143
|
updateQueryParams: !1,
|
|
144
|
+
noUpdateClose: !1,
|
|
145
|
+
noAutoClose: !1,
|
|
144
146
|
showRoute: undefined,
|
|
145
147
|
showQueryParams: !1,
|
|
146
148
|
noMouse: !1,
|
|
@@ -192,7 +194,17 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
192
194
|
})
|
|
193
195
|
|
|
194
196
|
interface Emits {
|
|
195
|
-
(e: 'update:rows', value: any): void
|
|
197
|
+
(e: 'update:rows', value: any): void;
|
|
198
|
+
|
|
199
|
+
(e: 'store', value: ApiInterface): void;
|
|
200
|
+
|
|
201
|
+
(e: 'update', value: ApiInterface): void;
|
|
202
|
+
|
|
203
|
+
(e: 'save', value: ApiInterface): void;
|
|
204
|
+
|
|
205
|
+
(e: 'destroy', value: ApiInterface): void;
|
|
206
|
+
|
|
207
|
+
(e: 'clone', value: ApiInterface): void;
|
|
196
208
|
}
|
|
197
209
|
|
|
198
210
|
const emit = defineEmits<Emits>()
|
|
@@ -313,7 +325,7 @@ const {
|
|
|
313
325
|
onCloseImportDialog,
|
|
314
326
|
downloadingExample,
|
|
315
327
|
onDownloadExample
|
|
316
|
-
} = useDtHelpers(() => props)
|
|
328
|
+
} = useDtHelpers(() => props, emit)
|
|
317
329
|
|
|
318
330
|
// Prevent user from back
|
|
319
331
|
/* router.beforeResolve(() => {
|
|
@@ -373,7 +385,6 @@ const onSuccess: SubmissionHandler = async (form) => {
|
|
|
373
385
|
}
|
|
374
386
|
}
|
|
375
387
|
}
|
|
376
|
-
|
|
377
388
|
const ignoreKeys = [
|
|
378
389
|
'_to_string',
|
|
379
390
|
'_to_number_format',
|
|
@@ -382,7 +393,6 @@ const onSuccess: SubmissionHandler = async (form) => {
|
|
|
382
393
|
'toNumberFormat',
|
|
383
394
|
'toDateFormat'
|
|
384
395
|
]
|
|
385
|
-
|
|
386
396
|
for (const i in ignoreKeys) {
|
|
387
397
|
for (const k in form) {
|
|
388
398
|
if (ignoreKeys[i] && k.slice(-ignoreKeys[i]?.length) === ignoreKeys[i]) {
|
|
@@ -408,17 +418,26 @@ const onSuccess: SubmissionHandler = async (form) => {
|
|
|
408
418
|
if (_data) {
|
|
409
419
|
updateDatatableItem(_data as any, dialogItemIndex.value)
|
|
410
420
|
}
|
|
421
|
+
emit('update', response)
|
|
422
|
+
if (!props.noUpdateClose && !props.noAutoClose) {
|
|
423
|
+
closeFormDialog()
|
|
424
|
+
}
|
|
411
425
|
} else {
|
|
412
426
|
setTimeout(() => refresh(), openDialogTimeout)
|
|
427
|
+
emit('store', response)
|
|
428
|
+
if (props.noStoreClose || props.noAutoClose) {
|
|
429
|
+
getRows.value = [
|
|
430
|
+
_data as any,
|
|
431
|
+
...getRows.value
|
|
432
|
+
]
|
|
433
|
+
const index = 0
|
|
434
|
+
dialogItemIndex.value = index
|
|
435
|
+
nextTick(() => openUpdateDialog(_data as any, index))
|
|
436
|
+
} else {
|
|
437
|
+
closeFormDialog()
|
|
438
|
+
}
|
|
413
439
|
}
|
|
414
|
-
|
|
415
|
-
props.updateCallback(response)
|
|
416
|
-
} else if (!isUpdateMode.value && props.storeCallback) {
|
|
417
|
-
props.storeCallback(response)
|
|
418
|
-
} else {
|
|
419
|
-
// nextTick()
|
|
420
|
-
closeFormDialog()
|
|
421
|
-
}
|
|
440
|
+
emit('save', response)
|
|
422
441
|
}
|
|
423
442
|
} catch (e: any) {
|
|
424
443
|
const { _message, _errors } = e || {}
|
|
@@ -1721,8 +1740,8 @@ defineExpose({
|
|
|
1721
1740
|
md="6"
|
|
1722
1741
|
>
|
|
1723
1742
|
<q-skeleton
|
|
1724
|
-
type="QInput"
|
|
1725
1743
|
:key="`form-inp-skeleton-${ai}`"
|
|
1744
|
+
type="QInput"
|
|
1726
1745
|
/>
|
|
1727
1746
|
</MCol>
|
|
1728
1747
|
</template>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
lang="ts"
|
|
11
11
|
setup
|
|
12
12
|
>
|
|
13
|
-
import { useField } from 'vee-validate'
|
|
13
|
+
import { useField, useFieldValue } from 'vee-validate'
|
|
14
14
|
import { computed, reactive, toValue, useTemplateRef } from 'vue'
|
|
15
15
|
import { QField, QInput, type QInputSlots } from 'quasar'
|
|
16
16
|
import { useBindInput, useMyth } from '../../composable'
|
|
@@ -35,6 +35,7 @@ interface P {
|
|
|
35
35
|
rules?: Props['rules'];
|
|
36
36
|
viewMode?: Props['viewMode'];
|
|
37
37
|
viewModeValue?: Props['viewModeValue'];
|
|
38
|
+
viewModeKey?: Props['viewModeValue'];
|
|
38
39
|
autocomplete?: Props['autocomplete'];
|
|
39
40
|
topLabel?: Props['topLabel'];
|
|
40
41
|
fieldOptions?: Props['fieldOptions'];
|
|
@@ -91,7 +92,13 @@ const sarValue = computed<string | null>(() => {
|
|
|
91
92
|
return '0.00'
|
|
92
93
|
}
|
|
93
94
|
})
|
|
94
|
-
const
|
|
95
|
+
const viewModeAttribute = useFieldValue(() => props.viewModeKey || props.name)
|
|
96
|
+
const computedViewModeValue = computed<any>(() => {
|
|
97
|
+
if (props.viewModeKey) {
|
|
98
|
+
return viewModeAttribute.value
|
|
99
|
+
}
|
|
100
|
+
return props.viewModeValue ?? value.value
|
|
101
|
+
})
|
|
95
102
|
const computedInputClass = computed(() => {
|
|
96
103
|
const classes: any[] = [props.inputClass]
|
|
97
104
|
if (props.ltr) {
|
|
@@ -37,7 +37,7 @@ export const initMetaServer: MDatatableMetaServer = {
|
|
|
37
37
|
total: null
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps
|
|
40
|
+
export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>, emit?: any) => {
|
|
41
41
|
const slots = useSlots()
|
|
42
42
|
const $q = useQuasar()
|
|
43
43
|
const router = useRouter()
|
|
@@ -693,7 +693,8 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
|
|
|
693
693
|
confirmMessage(__('messages.confirm_delete')).onOk(async () => {
|
|
694
694
|
loading.value = !0
|
|
695
695
|
try {
|
|
696
|
-
const
|
|
696
|
+
const response = await getMythApiServicesSchema().destroy(item.value.id)
|
|
697
|
+
const { _message, _success } = response
|
|
697
698
|
if (!hideAutoMessage.value && _success && _message) {
|
|
698
699
|
_message && alertSuccess(_message)
|
|
699
700
|
}
|
|
@@ -703,6 +704,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
|
|
|
703
704
|
selected.value = []
|
|
704
705
|
}
|
|
705
706
|
removeDtItem(index)
|
|
707
|
+
emit('destroy', response)
|
|
706
708
|
}
|
|
707
709
|
} catch (e: any) {
|
|
708
710
|
e?._message && alertError(e._message)
|
|
@@ -730,15 +732,14 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
|
|
|
730
732
|
confirmMessage(__('messages.confirm_delete')).onOk(async () => {
|
|
731
733
|
loading.value = !0
|
|
732
734
|
try {
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
_success
|
|
736
|
-
} = await getMythApiServicesSchema().destroyAll(selected.value.map((e: MDtItem) => e.id))
|
|
735
|
+
const response = await getMythApiServicesSchema().destroyAll(selected.value.map((e: MDtItem) => e.id))
|
|
736
|
+
const { _message, _success } = response
|
|
737
737
|
if (!hideAutoMessage.value && _success && _message) {
|
|
738
738
|
_message && alertSuccess(_message)
|
|
739
739
|
}
|
|
740
740
|
if (_success) {
|
|
741
741
|
refresh()
|
|
742
|
+
emit('destroy', response)
|
|
742
743
|
}
|
|
743
744
|
} catch (e: any) {
|
|
744
745
|
e?._message && alertError(e._message)
|
|
@@ -822,9 +823,11 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
|
|
|
822
823
|
.onOk(() => {
|
|
823
824
|
$q.loading.show()
|
|
824
825
|
getMythApiServicesSchema().clone(item.id)
|
|
825
|
-
.then((
|
|
826
|
+
.then((response: ApiInterface) => {
|
|
827
|
+
const { _message } = response
|
|
826
828
|
_message && alertSuccess(_message)
|
|
827
829
|
refreshNoUpdate()
|
|
830
|
+
emit('clone', response)
|
|
828
831
|
})
|
|
829
832
|
.catch(({ _message }) => {
|
|
830
833
|
_message && alertError(_message)
|
|
@@ -264,11 +264,12 @@ export type MDatatableProps<I extends GenericFormValues = GenericFormValues> = O
|
|
|
264
264
|
hideShowBtn?: boolean;
|
|
265
265
|
hideDestroyBtn?: boolean;
|
|
266
266
|
storeRoute?: string | RouteLocationRaw;
|
|
267
|
-
storeCallback?: (response: ApiInterface) => void;
|
|
268
267
|
storeQueryParams?: boolean;
|
|
268
|
+
noStoreClose?: boolean;
|
|
269
269
|
updateRoute?: string | RouteLocationRaw;
|
|
270
|
-
updateCallback?: (response: ApiInterface) => void;
|
|
271
270
|
updateQueryParams?: boolean;
|
|
271
|
+
noUpdateClose?: boolean;
|
|
272
|
+
noAutoClose?: boolean;
|
|
272
273
|
showRoute?: string | RouteLocationRaw;
|
|
273
274
|
showQueryParams?: boolean;
|
|
274
275
|
noMouse?: boolean;
|