v-nuxt-ui 0.2.33 → 0.3.0
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/module.json +1 -1
- package/dist/runtime/components/AsyncSelect.vue +13 -2
- package/dist/runtime/components/ScrollArea.vue +2 -2
- package/dist/runtime/components/Select.vue +13 -2
- package/dist/runtime/components/Watermark.d.vue.ts +2 -2
- package/dist/runtime/components/Watermark.vue.d.ts +2 -2
- package/dist/runtime/components/button/Confirm.d.vue.ts +22 -0
- package/dist/runtime/components/button/Confirm.vue +47 -0
- package/dist/runtime/components/button/Confirm.vue.d.ts +22 -0
- package/dist/runtime/components/button/Theme.vue +7 -13
- package/dist/runtime/components/date-picker/Input.d.vue.ts +1 -0
- package/dist/runtime/components/date-picker/Input.vue +12 -3
- package/dist/runtime/components/date-picker/Input.vue.d.ts +1 -0
- package/dist/runtime/components/form/save-modal-template/WithApi.vue +1 -2
- package/dist/runtime/components/form/save-modal-template/index.vue +23 -23
- package/dist/runtime/components/layout/button/ThemePicker.vue +2 -2
- package/dist/runtime/components/layout/default.vue +10 -4
- package/dist/runtime/components/simple-table/index.d.vue.ts +1 -1
- package/dist/runtime/components/simple-table/index.vue +72 -1
- package/dist/runtime/components/simple-table/index.vue.d.ts +1 -1
- package/dist/runtime/components/sys/department/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/flow/EditNodeModal.vue +5 -4
- package/dist/runtime/components/sys/flow/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/menu/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/role/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/table/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/table/TableColumnModal.vue +5 -4
- package/dist/runtime/components/sys/user/SaveModal.vue +0 -1
- package/dist/runtime/components/sys/user/Table.vue +19 -29
- package/dist/runtime/components/table/Page.vue +23 -2
- package/dist/runtime/components/table/Pagination.vue +1 -1
- package/dist/runtime/components/table/header/index.vue +231 -84
- package/dist/runtime/components/table/header/settings/columns/DndList.d.vue.ts +1 -0
- package/dist/runtime/components/table/header/settings/columns/DndList.vue +3 -1
- package/dist/runtime/components/table/header/settings/columns/DndList.vue.d.ts +1 -0
- package/dist/runtime/components/table/header/settings/columns/Item.d.vue.ts +1 -0
- package/dist/runtime/components/table/header/settings/columns/Item.vue +7 -3
- package/dist/runtime/components/table/header/settings/columns/Item.vue.d.ts +1 -0
- package/dist/runtime/components/table/header/settings/columns/index.d.vue.ts +3 -3
- package/dist/runtime/components/table/header/settings/columns/index.vue +7 -5
- package/dist/runtime/components/table/header/settings/columns/index.vue.d.ts +3 -3
- package/dist/runtime/components/table/header/settings/index.d.vue.ts +3 -2
- package/dist/runtime/components/table/header/settings/index.vue +5 -4
- package/dist/runtime/components/table/header/settings/index.vue.d.ts +3 -2
- package/dist/runtime/components/table/query/order/Newer.d.vue.ts +1 -0
- package/dist/runtime/components/table/query/order/Newer.vue +9 -2
- package/dist/runtime/components/table/query/order/Newer.vue.d.ts +1 -0
- package/dist/runtime/components/table/query/order/index.vue +46 -54
- package/dist/runtime/components/table/query/order/{Item.d.vue.ts → item.d.vue.ts} +2 -0
- package/dist/runtime/components/table/query/order/{Item.vue → item.vue} +25 -17
- package/dist/runtime/components/table/query/order/{Item.vue.d.ts → item.vue.d.ts} +2 -0
- package/dist/runtime/components/table/query/where/Newer.vue +2 -2
- package/dist/runtime/components/table/query/where/index.vue +90 -77
- package/dist/runtime/components/table/query/where/simple/item/ColumnPicker.vue +8 -7
- package/dist/runtime/components/table/query/where/simple/item/OprPicker.d.vue.ts +1 -0
- package/dist/runtime/components/table/query/where/simple/item/OprPicker.vue +6 -1
- package/dist/runtime/components/table/query/where/simple/item/OprPicker.vue.d.ts +1 -0
- package/dist/runtime/components/table/query/where/simple/item/index.d.vue.ts +3 -1
- package/dist/runtime/components/table/query/where/simple/item/index.vue +84 -39
- package/dist/runtime/components/table/query/where/simple/item/index.vue.d.ts +3 -1
- package/dist/runtime/components/table/query/where/simple/item/opr/AsyncSelect.vue +0 -1
- package/dist/runtime/components/table/query/where/simple/item/opr/DatePicker.d.vue.ts +1 -0
- package/dist/runtime/components/table/query/where/simple/item/opr/DatePicker.vue +42 -40
- package/dist/runtime/components/table/query/where/simple/item/opr/DatePicker.vue.d.ts +1 -0
- package/dist/runtime/components/table/query/where/simple/item/opr/Input.vue +3 -0
- package/dist/runtime/components/table/query/where/simple/item/opr/InputNumber.vue +0 -1
- package/dist/runtime/components/table/query/where/simple/item/opr/Select.vue +0 -1
- package/dist/runtime/components/table/query/where/simple/item/opr/index.vue +3 -0
- package/dist/runtime/composables/api/useApi.js +1 -0
- package/dist/runtime/composables/form/useForm.d.ts +2 -2
- package/dist/runtime/composables/form/useForm.js +10 -9
- package/dist/runtime/composables/table/useTable.js +9 -1
- package/dist/runtime/composables/table/useTableColumns.d.ts +1 -1
- package/dist/runtime/composables/table/useTableColumns.js +2 -2
- package/dist/runtime/composables/table/useTableQuery.d.ts +1 -0
- package/dist/runtime/composables/table/useTableQuery.js +8 -3
- package/dist/runtime/composables/table/useTableView.js +209 -11
- package/dist/runtime/composables/useTheme.js +10 -3
- package/dist/runtime/constants/columns.js +6 -6
- package/dist/runtime/types/components/form/index.d.ts +1 -1
- package/dist/runtime/types/components/table/column.d.ts +3 -1
- package/dist/runtime/types/components/table/header.d.ts +3 -1
- package/dist/runtime/types/components/table/query/order.d.ts +2 -0
- package/dist/runtime/types/components/table/query/where.d.ts +0 -1
- package/dist/runtime/types/query.d.ts +1 -0
- package/dist/runtime/types/storage.d.ts +1 -0
- package/package.json +1 -1
- package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.d.vue.ts +0 -19
- package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.vue +0 -111
- package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.vue.d.ts +0 -19
- package/dist/runtime/components/form/save-model-template/WithApi.d.vue.ts +0 -19
- package/dist/runtime/components/form/save-model-template/WithApi.vue +0 -37
- package/dist/runtime/components/form/save-model-template/WithApi.vue.d.ts +0 -19
- package/dist/runtime/components/form/save-model-template/index.d.vue.ts +0 -21
- package/dist/runtime/components/form/save-model-template/index.vue +0 -123
- package/dist/runtime/components/form/save-model-template/index.vue.d.ts +0 -21
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ButtonProps } from '@nuxt/ui';
|
|
2
2
|
import type { ApiGroup, OrderQueryProps, VColumn, VTableExportExcelProps, WhereQueryProps } from '.';
|
|
3
3
|
import type { Size, WhereQuery } from '../../index.js';
|
|
4
|
+
import type { Column } from '../../storage.js';
|
|
4
5
|
export type TableHeaderOprType = 'create' | 'whereQuery' | 'orderQuery' | 'batchDelete' | 'refresh' | 'settings' | 'exportExcel';
|
|
5
6
|
export type TableHeaderProps<T> = {
|
|
6
7
|
name: string;
|
|
8
|
+
tblName?: string;
|
|
7
9
|
fetching?: boolean;
|
|
8
10
|
rawBizColumns: VColumn<T>[];
|
|
9
|
-
onUpdateBizColumns?: (columns: VColumn<T>[]) => void;
|
|
11
|
+
onUpdateBizColumns?: (columns: VColumn<T>[], storageColumns?: Column[]) => void;
|
|
10
12
|
oprOrder?: TableHeaderOprType[];
|
|
11
13
|
onNew?: () => T;
|
|
12
14
|
apiGroup?: () => ApiGroup<T>;
|
|
@@ -9,6 +9,8 @@ export type OrderQueryProps<T> = {
|
|
|
9
9
|
defaultOrderQuery?: OrderQuery<T>;
|
|
10
10
|
orderQuery: OrderQuery<T>;
|
|
11
11
|
onUpdateOrderQuery: (query: OrderQuery<T>) => void;
|
|
12
|
+
orderQueryOpen?: boolean;
|
|
13
|
+
onUpdateOrderQueryOpen?: (open: boolean) => void;
|
|
12
14
|
fetching?: boolean;
|
|
13
15
|
triggerFetching: () => Promise<void>;
|
|
14
16
|
bizColumns: VColumn<T>[];
|
|
@@ -2,7 +2,6 @@ import type { VColumn, WhereQuery, WhereQueryColumnOption, WhereQueryItemGroup }
|
|
|
2
2
|
export type WhereQueryOption<T> = {
|
|
3
3
|
field: string & keyof T | string;
|
|
4
4
|
label: string;
|
|
5
|
-
preferred?: boolean;
|
|
6
5
|
} & WhereQueryColumnOption<T>;
|
|
7
6
|
export type WhereQueryProps<T> = {
|
|
8
7
|
whereOptions: WhereQueryOption<T>[];
|
|
@@ -36,6 +36,7 @@ export interface WhereQueryItem<T> {
|
|
|
36
36
|
value?: any;
|
|
37
37
|
custom?: boolean;
|
|
38
38
|
extraData?: any;
|
|
39
|
+
whereQuerySection?: 'preferred' | 'other';
|
|
39
40
|
}
|
|
40
41
|
export type OrderQueryOpr = 'asc' | 'desc' | 'str_len_asc' | 'str_len_desc' | null;
|
|
41
42
|
export type OrderQuery<T> = OrderQueryItem<T>[];
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { VFormFieldProps } from '#v/types';
|
|
2
|
-
export interface ConfirmDiffItem {
|
|
3
|
-
fieldName: string;
|
|
4
|
-
oldValue: unknown;
|
|
5
|
-
newValue: unknown;
|
|
6
|
-
}
|
|
7
|
-
type __VLS_Props = {
|
|
8
|
-
fields: VFormFieldProps[];
|
|
9
|
-
diffItems: ConfirmDiffItem[];
|
|
10
|
-
oldModelValue: Record<string, unknown>;
|
|
11
|
-
newModelValue: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
-
close: (args_0: boolean) => any;
|
|
15
|
-
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
|
-
onClose?: ((args_0: boolean) => any) | undefined;
|
|
17
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
-
declare const _default: typeof __VLS_export;
|
|
19
|
-
export default _default;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { isEmptyString } from "#v/utils";
|
|
3
|
-
import { diffEligibleTypes, useConfirmDiff } from "#v/composables";
|
|
4
|
-
const props = defineProps({
|
|
5
|
-
fields: { type: Array, required: true },
|
|
6
|
-
diffItems: { type: Array, required: true },
|
|
7
|
-
oldModelValue: { type: Object, required: true },
|
|
8
|
-
newModelValue: { type: Object, required: true }
|
|
9
|
-
});
|
|
10
|
-
const emit = defineEmits(["close"]);
|
|
11
|
-
const { diffedItems } = useConfirmDiff(
|
|
12
|
-
() => props.fields,
|
|
13
|
-
() => props.diffItems,
|
|
14
|
-
() => props.oldModelValue,
|
|
15
|
-
() => props.newModelValue
|
|
16
|
-
);
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
<UModal
|
|
21
|
-
title="确认修改"
|
|
22
|
-
:close="{ onClick: () => emit('close', false) }"
|
|
23
|
-
:dismissible="false"
|
|
24
|
-
>
|
|
25
|
-
<template #description>
|
|
26
|
-
<div class="flex items-center gap-3 w-full">
|
|
27
|
-
<span>
|
|
28
|
-
请确认以下 {{ diffedItems.length }} 处修改内容
|
|
29
|
-
</span>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
<template #body>
|
|
33
|
-
<div class="overflow-y-auto max-h-96">
|
|
34
|
-
<div class="space-y-4">
|
|
35
|
-
<UFormField
|
|
36
|
-
v-for="item in diffedItems"
|
|
37
|
-
:key="item.fieldName"
|
|
38
|
-
:label="item.field.label || item.fieldName"
|
|
39
|
-
>
|
|
40
|
-
<!-- String types: word diff -->
|
|
41
|
-
<div v-if="item.field.diffable ?? diffEligibleTypes.has(item.field.type)" class="flex items-center flex-wrap gap-2">
|
|
42
|
-
<span
|
|
43
|
-
class="rounded-md bg-muted px-2 py-1 text-sm text-dimmed"
|
|
44
|
-
:title="item.oldDisplay"
|
|
45
|
-
>
|
|
46
|
-
<span v-if="!item.parts.filter((part2) => !part2.added).length">{{ "\xA0" }}</span>
|
|
47
|
-
<template v-for="(part, idx) in item.parts" :key="idx">
|
|
48
|
-
<span
|
|
49
|
-
v-if="!part.added"
|
|
50
|
-
:class="{ 'bg-red-200 text-red-800 dark:bg-red-800 dark:text-red-200 rounded-sm line-through px-0.5': part.removed }"
|
|
51
|
-
>{{ isEmptyString(part.value) ? "\xA0" : part.value }}</span>
|
|
52
|
-
</template>
|
|
53
|
-
</span>
|
|
54
|
-
<UIcon
|
|
55
|
-
name="i-lucide-arrow-right"
|
|
56
|
-
class="text-dimmed shrink-0 size-4"
|
|
57
|
-
/>
|
|
58
|
-
<span
|
|
59
|
-
class="rounded-md bg-elevated px-2 py-1 text-sm text-highlighted font-bold"
|
|
60
|
-
:title="item.newDisplay"
|
|
61
|
-
>
|
|
62
|
-
<span v-if="!item.parts.filter((part2) => !part2.removed).length">{{ "\xA0" }}</span>
|
|
63
|
-
<template v-for="(part, idx) in item.parts" :key="idx">
|
|
64
|
-
<span
|
|
65
|
-
v-if="!part.removed"
|
|
66
|
-
:class="{ 'bg-green-200 text-green-800 dark:bg-green-800 dark:text-green-200 rounded-sm px-0.5': part.added }"
|
|
67
|
-
>{{ isEmptyString(part.value) ? "\xA0" : part.value }}</span>
|
|
68
|
-
</template>
|
|
69
|
-
</span>
|
|
70
|
-
</div>
|
|
71
|
-
<!-- Other types: simple old -> new -->
|
|
72
|
-
<div v-else class="flex items-center flex-wrap gap-2">
|
|
73
|
-
<span
|
|
74
|
-
class="rounded-md bg-muted px-2 py-1 text-sm text-dimmed"
|
|
75
|
-
:title="item.oldDisplay"
|
|
76
|
-
>
|
|
77
|
-
{{ isEmptyString(item.oldDisplay) ? "\xA0" : item.oldDisplay }}
|
|
78
|
-
</span>
|
|
79
|
-
<UIcon
|
|
80
|
-
name="i-lucide-arrow-right"
|
|
81
|
-
class="text-dimmed shrink-0 size-4"
|
|
82
|
-
/>
|
|
83
|
-
<span
|
|
84
|
-
class="rounded-md bg-elevated px-2 py-1 text-sm text-highlighted font-medium"
|
|
85
|
-
:title="item.newDisplay"
|
|
86
|
-
>
|
|
87
|
-
{{ isEmptyString(item.newDisplay) ? "\xA0" : item.newDisplay }}
|
|
88
|
-
</span>
|
|
89
|
-
</div>
|
|
90
|
-
</UFormField>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</template>
|
|
94
|
-
<template #footer>
|
|
95
|
-
<UButton
|
|
96
|
-
label="取消"
|
|
97
|
-
color="neutral"
|
|
98
|
-
variant="subtle"
|
|
99
|
-
icon="i-lucide-x"
|
|
100
|
-
@click="emit('close', false)"
|
|
101
|
-
/>
|
|
102
|
-
<UButton
|
|
103
|
-
:label="`\u786E\u8BA4 ${diffedItems.length} \u5904\u4FEE\u6539`"
|
|
104
|
-
color="primary"
|
|
105
|
-
variant="solid"
|
|
106
|
-
icon="i-lucide-check"
|
|
107
|
-
@click="emit('close', true)"
|
|
108
|
-
/>
|
|
109
|
-
</template>
|
|
110
|
-
</UModal>
|
|
111
|
-
</template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { VFormFieldProps } from '#v/types';
|
|
2
|
-
export interface ConfirmDiffItem {
|
|
3
|
-
fieldName: string;
|
|
4
|
-
oldValue: unknown;
|
|
5
|
-
newValue: unknown;
|
|
6
|
-
}
|
|
7
|
-
type __VLS_Props = {
|
|
8
|
-
fields: VFormFieldProps[];
|
|
9
|
-
diffItems: ConfirmDiffItem[];
|
|
10
|
-
oldModelValue: Record<string, unknown>;
|
|
11
|
-
newModelValue: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
-
close: (args_0: boolean) => any;
|
|
15
|
-
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
|
-
onClose?: ((args_0: boolean) => any) | undefined;
|
|
17
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
-
declare const _default: typeof __VLS_export;
|
|
19
|
-
export default _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaseModel, SaveModalFormTemplatePropsWithApi } from '#v/types';
|
|
2
|
-
declare const __VLS_export: <T extends BaseModel>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<SaveModalFormTemplatePropsWithApi<T>> & (typeof globalThis extends {
|
|
4
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
5
|
-
} ? P : {});
|
|
6
|
-
expose: (exposed: {}) => void;
|
|
7
|
-
attrs: any;
|
|
8
|
-
slots: {};
|
|
9
|
-
emit: {};
|
|
10
|
-
}>) => import("vue").VNode & {
|
|
11
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
12
|
-
};
|
|
13
|
-
declare const _default: typeof __VLS_export;
|
|
14
|
-
export default _default;
|
|
15
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
16
|
-
[K in keyof T]: T[K];
|
|
17
|
-
} : {
|
|
18
|
-
[K in keyof T as K]: T[K];
|
|
19
|
-
}) & {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { toRef } from "vue";
|
|
3
|
-
import { useFormSubmission, useFormValues } from "#v/composables/form/useForm";
|
|
4
|
-
import FormSaveModalTemplate from "./index.vue";
|
|
5
|
-
const props = defineProps({
|
|
6
|
-
apiGroup: { type: Function, required: true },
|
|
7
|
-
valuePruneFn: { type: Function, required: false },
|
|
8
|
-
defaultModelValue: { type: Object, required: false },
|
|
9
|
-
onSave: { type: Function, required: true },
|
|
10
|
-
title: { type: String, required: true },
|
|
11
|
-
description: { type: String, required: false },
|
|
12
|
-
fields: { type: Array, required: true },
|
|
13
|
-
onClose: { type: Function, required: true },
|
|
14
|
-
modelValue: { type: Object, required: true },
|
|
15
|
-
onUpdateModelValue: { type: Function, required: false }
|
|
16
|
-
});
|
|
17
|
-
const { oldValues, newValues } = useFormValues(toRef(props.modelValue), props.defaultModelValue);
|
|
18
|
-
const { onSubmit } = useFormSubmission(
|
|
19
|
-
toRef(oldValues),
|
|
20
|
-
toRef(newValues),
|
|
21
|
-
props.onClose,
|
|
22
|
-
props.onSave,
|
|
23
|
-
props.apiGroup
|
|
24
|
-
);
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
<FormSaveModalTemplate
|
|
29
|
-
v-model:model-value="newValues"
|
|
30
|
-
:old-model-value="oldValues"
|
|
31
|
-
:title="title"
|
|
32
|
-
:description="description"
|
|
33
|
-
:on-close="onClose"
|
|
34
|
-
:on-submit="onSubmit"
|
|
35
|
-
:fields="fields"
|
|
36
|
-
/>
|
|
37
|
-
</template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaseModel, SaveModalFormTemplatePropsWithApi } from '#v/types';
|
|
2
|
-
declare const __VLS_export: <T extends BaseModel>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<SaveModalFormTemplatePropsWithApi<T>> & (typeof globalThis extends {
|
|
4
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
5
|
-
} ? P : {});
|
|
6
|
-
expose: (exposed: {}) => void;
|
|
7
|
-
attrs: any;
|
|
8
|
-
slots: {};
|
|
9
|
-
emit: {};
|
|
10
|
-
}>) => import("vue").VNode & {
|
|
11
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
12
|
-
};
|
|
13
|
-
declare const _default: typeof __VLS_export;
|
|
14
|
-
export default _default;
|
|
15
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
16
|
-
[K in keyof T]: T[K];
|
|
17
|
-
} : {
|
|
18
|
-
[K in keyof T as K]: T[K];
|
|
19
|
-
}) & {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { BaseModel, SaveModalFormTemplateProps } from '#v/types';
|
|
2
|
-
declare const __VLS_export: <T extends BaseModel>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<SaveModalFormTemplateProps<T>> & (typeof globalThis extends {
|
|
4
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
5
|
-
} ? P : {});
|
|
6
|
-
expose: (exposed: {}) => void;
|
|
7
|
-
attrs: any;
|
|
8
|
-
slots: {
|
|
9
|
-
'after-form'?: (props: {}) => any;
|
|
10
|
-
};
|
|
11
|
-
emit: {};
|
|
12
|
-
}>) => import("vue").VNode & {
|
|
13
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
14
|
-
};
|
|
15
|
-
declare const _default: typeof __VLS_export;
|
|
16
|
-
export default _default;
|
|
17
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
18
|
-
[K in keyof T]: T[K];
|
|
19
|
-
} : {
|
|
20
|
-
[K in keyof T as K]: T[K];
|
|
21
|
-
}) & {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { computed, ref, useTemplateRef } from "vue";
|
|
3
|
-
import { useOverlay } from "@nuxt/ui/composables";
|
|
4
|
-
import { useSubmitting } from "#v/composables";
|
|
5
|
-
import Form from "../index.vue";
|
|
6
|
-
import ConfirmUpdateModal from "./ConfirmUpdateModal.vue";
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
title: { type: String, required: true },
|
|
9
|
-
description: { type: String, required: false },
|
|
10
|
-
onClose: { type: Function, required: true },
|
|
11
|
-
onSubmit: { type: Function, required: true },
|
|
12
|
-
fields: { type: Array, required: true },
|
|
13
|
-
oldModelValue: { type: Object, required: true },
|
|
14
|
-
modelValue: { type: Object, required: true },
|
|
15
|
-
onUpdateModelValue: { type: Function, required: false },
|
|
16
|
-
rowKey: { type: null, required: false, default: "id" },
|
|
17
|
-
fullscreen: { type: Boolean, required: false }
|
|
18
|
-
});
|
|
19
|
-
const form = useTemplateRef("form");
|
|
20
|
-
const action = computed(() => props.modelValue[props.rowKey] === 0 ? "\u521B\u5EFA" : "\u66F4\u65B0");
|
|
21
|
-
const isUpdate = computed(() => props.modelValue[props.rowKey] !== 0);
|
|
22
|
-
const titleWithAction = computed(() => `${action.value}${props.title}`);
|
|
23
|
-
const descWithAction = computed(() => props.description ?? `\u8BF7${action.value}${props.title}`);
|
|
24
|
-
const submitIcon = computed(() => props.modelValue[props.rowKey] === 0 ? "i-lucide-clipboard-plus" : "i-lucide-clipboard-pen-line");
|
|
25
|
-
const initialModelValue = ref(JSON.parse(JSON.stringify(props.modelValue)));
|
|
26
|
-
const overlay = useOverlay();
|
|
27
|
-
const confirmModal = overlay.create(ConfirmUpdateModal);
|
|
28
|
-
function computeDiff() {
|
|
29
|
-
const items = [];
|
|
30
|
-
for (const field of props.fields) {
|
|
31
|
-
if (!field.name || field.hidden) continue;
|
|
32
|
-
const name = field.name;
|
|
33
|
-
const oldVal = initialModelValue.value[name];
|
|
34
|
-
const newVal = props.modelValue[name];
|
|
35
|
-
if ((oldVal === null || oldVal === void 0) && (newVal === null || newVal === void 0)) continue;
|
|
36
|
-
if (oldVal === newVal) continue;
|
|
37
|
-
if (typeof oldVal === "object" && typeof newVal === "object" && oldVal !== null && newVal !== null) {
|
|
38
|
-
if (JSON.stringify(oldVal) === JSON.stringify(newVal)) continue;
|
|
39
|
-
}
|
|
40
|
-
items.push({
|
|
41
|
-
fieldName: name,
|
|
42
|
-
oldValue: oldVal,
|
|
43
|
-
newValue: newVal
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return items;
|
|
47
|
-
}
|
|
48
|
-
const { submitting, startSubmitting, endSubmitting } = useSubmitting();
|
|
49
|
-
async function doSubmit() {
|
|
50
|
-
try {
|
|
51
|
-
startSubmitting();
|
|
52
|
-
await props.onSubmit();
|
|
53
|
-
} finally {
|
|
54
|
-
endSubmitting();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async function onSubmitWithValidation(e) {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
e.stopPropagation();
|
|
60
|
-
try {
|
|
61
|
-
await form.value?.validate?.();
|
|
62
|
-
} catch {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (isUpdate.value) {
|
|
66
|
-
const items = computeDiff();
|
|
67
|
-
if (items.length === 0) {
|
|
68
|
-
await doSubmit();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const confirmed = await confirmModal.open({
|
|
72
|
-
fields: props.fields,
|
|
73
|
-
diffItems: items,
|
|
74
|
-
oldModelValue: props.oldModelValue,
|
|
75
|
-
newModelValue: props.modelValue
|
|
76
|
-
}).result;
|
|
77
|
-
if (confirmed) {
|
|
78
|
-
await doSubmit();
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
await doSubmit();
|
|
83
|
-
}
|
|
84
|
-
</script>
|
|
85
|
-
|
|
86
|
-
<template>
|
|
87
|
-
<UModal
|
|
88
|
-
:title="titleWithAction"
|
|
89
|
-
:description="descWithAction"
|
|
90
|
-
:close="{ onClick: () => props.onClose(false) }"
|
|
91
|
-
:dismissible="false"
|
|
92
|
-
:fullscreen="fullscreen"
|
|
93
|
-
>
|
|
94
|
-
<template #body>
|
|
95
|
-
<Form
|
|
96
|
-
ref="form"
|
|
97
|
-
:fields="fields"
|
|
98
|
-
:loading="submitting"
|
|
99
|
-
:model-value="modelValue"
|
|
100
|
-
@trigger-submit="onSubmitWithValidation"
|
|
101
|
-
@update-model-value="onUpdateModelValue"
|
|
102
|
-
/>
|
|
103
|
-
<slot name="after-form" />
|
|
104
|
-
</template>
|
|
105
|
-
<template #footer>
|
|
106
|
-
<UButton
|
|
107
|
-
label="取消"
|
|
108
|
-
color="neutral"
|
|
109
|
-
variant="subtle"
|
|
110
|
-
icon="i-lucide-x"
|
|
111
|
-
@click="props.onClose(false)"
|
|
112
|
-
/>
|
|
113
|
-
<UButton
|
|
114
|
-
:label="action"
|
|
115
|
-
color="primary"
|
|
116
|
-
variant="solid"
|
|
117
|
-
:icon="submitIcon"
|
|
118
|
-
:loading="submitting"
|
|
119
|
-
@click="onSubmitWithValidation"
|
|
120
|
-
/>
|
|
121
|
-
</template>
|
|
122
|
-
</UModal>
|
|
123
|
-
</template>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { BaseModel, SaveModalFormTemplateProps } from '#v/types';
|
|
2
|
-
declare const __VLS_export: <T extends BaseModel>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
-
props: import("vue").PublicProps & __VLS_PrettifyLocal<SaveModalFormTemplateProps<T>> & (typeof globalThis extends {
|
|
4
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
5
|
-
} ? P : {});
|
|
6
|
-
expose: (exposed: {}) => void;
|
|
7
|
-
attrs: any;
|
|
8
|
-
slots: {
|
|
9
|
-
'after-form'?: (props: {}) => any;
|
|
10
|
-
};
|
|
11
|
-
emit: {};
|
|
12
|
-
}>) => import("vue").VNode & {
|
|
13
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
14
|
-
};
|
|
15
|
-
declare const _default: typeof __VLS_export;
|
|
16
|
-
export default _default;
|
|
17
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
18
|
-
[K in keyof T]: T[K];
|
|
19
|
-
} : {
|
|
20
|
-
[K in keyof T as K]: T[K];
|
|
21
|
-
}) & {};
|