v-nuxt-ui 0.2.25 → 0.2.27

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.
Files changed (96) hide show
  1. package/README.md +6 -0
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/AsyncSelect.vue +16 -1
  4. package/dist/runtime/components/AsyncTreeSelect.vue +15 -9
  5. package/dist/runtime/components/DeleteModal.d.vue.ts +25 -22
  6. package/dist/runtime/components/DeleteModal.vue +39 -4
  7. package/dist/runtime/components/DeleteModal.vue.d.ts +25 -22
  8. package/dist/runtime/components/ScrollArea.vue +20 -9
  9. package/dist/runtime/components/form/save-modal-template/ConfirmUpdateModal.d.vue.ts +19 -0
  10. package/dist/runtime/components/form/save-modal-template/ConfirmUpdateModal.vue +111 -0
  11. package/dist/runtime/components/form/save-modal-template/ConfirmUpdateModal.vue.d.ts +19 -0
  12. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/WithApi.d.vue.ts +2 -2
  13. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/WithApi.vue +4 -3
  14. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/WithApi.vue.d.ts +2 -2
  15. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/index.d.vue.ts +2 -2
  16. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/index.vue +54 -7
  17. package/dist/runtime/components/form/{create-modal-template → save-modal-template}/index.vue.d.ts +2 -2
  18. package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.d.vue.ts +19 -0
  19. package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.vue +111 -0
  20. package/dist/runtime/components/form/save-model-template/ConfirmUpdateModal.vue.d.ts +19 -0
  21. package/dist/runtime/components/form/save-model-template/WithApi.d.vue.ts +19 -0
  22. package/dist/runtime/components/form/save-model-template/WithApi.vue +37 -0
  23. package/dist/runtime/components/form/save-model-template/WithApi.vue.d.ts +19 -0
  24. package/dist/runtime/components/form/save-model-template/index.d.vue.ts +21 -0
  25. package/dist/runtime/components/form/save-model-template/index.vue +123 -0
  26. package/dist/runtime/components/form/save-model-template/index.vue.d.ts +21 -0
  27. package/dist/runtime/components/layout/button/UserMenu.vue +1 -2
  28. package/dist/runtime/components/sys/company/{CreateModal.vue → SaveModal.vue} +2 -2
  29. package/dist/runtime/components/sys/company/Table.vue +5 -4
  30. package/dist/runtime/components/sys/department/{CreateModal.vue → SaveModal.vue} +3 -2
  31. package/dist/runtime/components/sys/department/Table.vue +6 -5
  32. package/dist/runtime/components/sys/flow/EditNodeModal.vue +4 -3
  33. package/dist/runtime/components/sys/flow/{CreateModal.vue → SaveModal.vue} +3 -2
  34. package/dist/runtime/components/sys/flow/Table.vue +5 -4
  35. package/dist/runtime/components/sys/issue-record/{CreateModal.vue → SaveModal.vue} +2 -2
  36. package/dist/runtime/components/sys/issue-record/Table.vue +5 -4
  37. package/dist/runtime/components/sys/job-title/{CreateModal.vue → SaveModal.vue} +2 -2
  38. package/dist/runtime/components/sys/job-title/Table.vue +5 -4
  39. package/dist/runtime/components/sys/menu/{CreateModal.vue → SaveModal.vue} +3 -2
  40. package/dist/runtime/components/sys/menu/Table.vue +6 -5
  41. package/dist/runtime/components/sys/role/{CreateModal.vue → SaveModal.vue} +8 -5
  42. package/dist/runtime/components/sys/role/Table.vue +5 -4
  43. package/dist/runtime/components/sys/table/{CreateModal.vue → SaveModal.vue} +4 -3
  44. package/dist/runtime/components/sys/table/Table.vue +4 -4
  45. package/dist/runtime/components/sys/table/TableColumnModal.vue +4 -3
  46. package/dist/runtime/components/sys/user/{CreateModal.vue → SaveModal.vue} +4 -3
  47. package/dist/runtime/components/sys/user/Table.vue +7 -6
  48. package/dist/runtime/components/table/Page.vue +2 -1
  49. package/dist/runtime/components/table/UpdateDiffModal.d.vue.ts +14 -0
  50. package/dist/runtime/components/table/UpdateDiffModal.vue +156 -0
  51. package/dist/runtime/components/table/UpdateDiffModal.vue.d.ts +14 -0
  52. package/dist/runtime/components/table/header/index.vue +181 -183
  53. package/dist/runtime/components/table/index.vue +2 -1
  54. package/dist/runtime/composables/form/index.d.ts +2 -0
  55. package/dist/runtime/composables/form/index.js +2 -0
  56. package/dist/runtime/composables/form/useForm.d.ts +21 -0
  57. package/dist/runtime/composables/{useForm.js → form/useForm.js} +23 -1
  58. package/dist/runtime/composables/form/useFormUpdate.d.ts +6 -0
  59. package/dist/runtime/composables/form/useFormUpdate.js +101 -0
  60. package/dist/runtime/composables/index.d.ts +1 -1
  61. package/dist/runtime/composables/index.js +1 -1
  62. package/dist/runtime/composables/table/useTable.js +10 -1
  63. package/dist/runtime/composables/table/useTableRowActions.d.ts +3 -0
  64. package/dist/runtime/composables/table/useTableRowActions.js +24 -0
  65. package/dist/runtime/composables/useDate.js +2 -0
  66. package/dist/runtime/types/components/form/field.d.ts +2 -0
  67. package/dist/runtime/types/components/form/index.d.ts +4 -3
  68. package/dist/runtime/types/components/table/header.d.ts +2 -0
  69. package/dist/runtime/types/components/table/index.d.ts +1 -0
  70. package/dist/runtime/types/time.d.ts +1 -1
  71. package/dist/runtime/utils/cron.d.ts +1 -0
  72. package/dist/runtime/utils/cron.js +182 -0
  73. package/dist/runtime/utils/index.d.ts +1 -0
  74. package/dist/runtime/utils/index.js +1 -0
  75. package/dist/runtime/utils/vueuse.d.ts +1 -1
  76. package/dist/runtime/utils/vueuse.js +1 -0
  77. package/package.json +16 -15
  78. package/dist/runtime/composables/useForm.d.ts +0 -9
  79. /package/dist/runtime/components/sys/company/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  80. /package/dist/runtime/components/sys/company/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  81. /package/dist/runtime/components/sys/department/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  82. /package/dist/runtime/components/sys/department/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  83. /package/dist/runtime/components/sys/flow/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  84. /package/dist/runtime/components/sys/flow/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  85. /package/dist/runtime/components/sys/issue-record/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  86. /package/dist/runtime/components/sys/issue-record/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  87. /package/dist/runtime/components/sys/job-title/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  88. /package/dist/runtime/components/sys/job-title/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  89. /package/dist/runtime/components/sys/menu/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  90. /package/dist/runtime/components/sys/menu/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  91. /package/dist/runtime/components/sys/role/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  92. /package/dist/runtime/components/sys/role/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  93. /package/dist/runtime/components/sys/table/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  94. /package/dist/runtime/components/sys/table/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
  95. /package/dist/runtime/components/sys/user/{CreateModal.d.vue.ts → SaveModal.d.vue.ts} +0 -0
  96. /package/dist/runtime/components/sys/user/{CreateModal.vue.d.ts → SaveModal.vue.d.ts} +0 -0
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,111 @@
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>
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,19 @@
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
+ }) & {};
@@ -0,0 +1,37 @@
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>
@@ -0,0 +1,19 @@
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
+ }) & {};
@@ -0,0 +1,21 @@
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
+ }) & {};
@@ -0,0 +1,123 @@
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>
@@ -0,0 +1,21 @@
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,5 +1,5 @@
1
1
  <script setup>
2
- import { useAuth, useApp } from "#v/composables";
2
+ import { useAuth } from "#v/composables";
3
3
  import { useRoute } from "nuxt/app";
4
4
  import { getEmojiFlag } from "#v/utils";
5
5
  import { computed } from "vue";
@@ -8,7 +8,6 @@ defineProps({
8
8
  headerMode: { type: Boolean, required: false }
9
9
  });
10
10
  const auth = useAuth();
11
- const app = useApp();
12
11
  const route = useRoute();
13
12
  const items = computed(() => [
14
13
  [
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import * as z from "zod";
3
- import FormCreateModalTemplateWithApi from "#v/components/form/create-modal-template/WithApi.vue";
3
+ import FormSaveModalTemplateWithApi from "#v/components/form/save-modal-template/WithApi.vue";
4
4
  import { useCompanyApi } from "#v/composables";
5
5
  defineProps({
6
6
  model: { type: Object, required: true }
@@ -9,7 +9,7 @@ const emit = defineEmits(["close", "save"]);
9
9
  </script>
10
10
 
11
11
  <template>
12
- <FormCreateModalTemplateWithApi
12
+ <FormSaveModalTemplateWithApi
13
13
  title="公司信息"
14
14
  :on-close="(ok) => emit('close', ok)"
15
15
  :on-save="(model) => emit('save', model)"
@@ -1,11 +1,11 @@
1
1
  <script setup>
2
2
  import { useOverlay } from "@nuxt/ui/composables";
3
3
  import { useCompanyApi } from "#v/composables";
4
- import SysCompaniesCreateModal from "./CreateModal.vue";
4
+ import SysCompaniesSaveModal from "./SaveModal.vue";
5
5
  import { getOprColumns } from "#v/constants";
6
6
  import TablePage from "#v/components/table/Page.vue";
7
7
  const overlay = useOverlay();
8
- const createModal = overlay.create(SysCompaniesCreateModal);
8
+ const saveModal = overlay.create(SysCompaniesSaveModal);
9
9
  const columns = [
10
10
  {
11
11
  accessorKey: "fullname",
@@ -41,13 +41,14 @@ const columns = [
41
41
 
42
42
  <template>
43
43
  <TablePage
44
- name="sys-company"
44
+ name="companies"
45
45
  cn-name="公司信息"
46
46
  :use-api-group="useCompanyApi"
47
47
  :biz-columns="columns"
48
48
  :extra-order-query-options="[
49
49
  { field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
50
50
  ]"
51
- @edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
51
+ :display-fn-in-delete-modal="(model) => model.fullname"
52
+ @edit-row-from-modal="async (row) => await saveModal.open({ model: row }).result"
52
53
  />
53
54
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import * as z from "zod";
3
- import FormCreateModalTemplate from "#v/components/form/create-modal-template/index.vue";
3
+ import FormSaveModalTemplate from "#v/components/form/save-modal-template/index.vue";
4
4
  import { useCompanyApi, useDepartmentApi, useFormSubmission, useFormValues, useUserApi } from "#v/composables";
5
5
  import { toRef, watch } from "vue";
6
6
  const props = defineProps({
@@ -27,7 +27,7 @@ const { onSubmit } = useFormSubmission(
27
27
  </script>
28
28
 
29
29
  <template>
30
- <FormCreateModalTemplate
30
+ <FormSaveModalTemplate
31
31
  title="部门信息"
32
32
  :on-close="(ok) => emit('close', ok)"
33
33
  :fields="[
@@ -74,6 +74,7 @@ const { onSubmit } = useFormSubmission(
74
74
  }
75
75
  ]"
76
76
  :model-value="newValues"
77
+ :old-model-value="oldValues"
77
78
  @update-model-value="(newVal) => newValues = { id: 0, ...newVal }"
78
79
  @submit="onSubmit"
79
80
  />
@@ -1,11 +1,11 @@
1
1
  <script setup>
2
2
  import { useOverlay } from "@nuxt/ui/composables";
3
3
  import { useDepartmentApi } from "#v/composables";
4
- import SysDepartmentsCreateModal from "./CreateModal.vue";
4
+ import SysDepartmentsSaveModal from "./SaveModal.vue";
5
5
  import { getOprColumns } from "#v/constants";
6
6
  import TablePage from "#v/components/table/Page.vue";
7
7
  const overlay = useOverlay();
8
- const createModal = overlay.create(SysDepartmentsCreateModal);
8
+ const saveModal = overlay.create(SysDepartmentsSaveModal);
9
9
  const columns = [
10
10
  {
11
11
  accessorKey: "name",
@@ -40,7 +40,7 @@ const columns = [
40
40
 
41
41
  <template>
42
42
  <TablePage
43
- name="sys-department"
43
+ name="departments"
44
44
  cn-name="部门信息"
45
45
  :use-api-group="useDepartmentApi"
46
46
  :biz-columns="columns"
@@ -53,9 +53,10 @@ const columns = [
53
53
  icon: 'i-lucide-clipboard-plus',
54
54
  label: '\u4EE5\u6B64\u4F5C\u4E3A\u7236\u90E8\u95E8\u590D\u5236',
55
55
  asyncFn: async (raw) => {
56
- await createModal.open({ model: useDepartmentApi().copyAsParent?.(raw) ?? { id: 0 } });
56
+ await saveModal.open({ model: useDepartmentApi().copyAsParent?.(raw) ?? { id: 0 } });
57
57
  }
58
58
  }]"
59
- @edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
59
+ :display-fn-in-delete-modal="(model) => model.name"
60
+ @edit-row-from-modal="async (row) => await saveModal.open({ model: row }).result"
60
61
  />
61
62
  </template>
@@ -1,26 +1,27 @@
1
1
  <script setup>
2
2
  import * as z from "zod";
3
- import FormCreateModalTemplate from "#v/components/form/create-modal-template/index.vue";
3
+ import FormSaveModalTemplate from "#v/components/form/save-modal-template/index.vue";
4
4
  import { useFormValues } from "#v/composables";
5
5
  import { toRef } from "vue";
6
6
  const props = defineProps({
7
7
  model: { type: Object, required: true }
8
8
  });
9
9
  const emit = defineEmits(["close", "save"]);
10
- const { newValues } = useFormValues(toRef(props.model), {
10
+ const { oldValues, newValues } = useFormValues(toRef(props.model), {
11
11
  id: 0,
12
12
  name: ""
13
13
  });
14
14
  </script>
15
15
 
16
16
  <template>
17
- <FormCreateModalTemplate
17
+ <FormSaveModalTemplate
18
18
  title="编辑节点"
19
19
  :on-close="(ok) => emit('close', ok)"
20
20
  :fields="[
21
21
  { name: 'name', type: 'input', label: '\u8282\u70B9\u540D\u79F0', colSpan: '24', zodType: z.string().min(1, '\u8BF7\u8F93\u5165\u8282\u70B9\u540D\u79F0') }
22
22
  ]"
23
23
  :model-value="newValues"
24
+ :old-model-value="oldValues"
24
25
  @update-model-value="(newVal) => newValues = { ...props.model, ...newVal }"
25
26
  @submit="async () => {
26
27
  emit('save', newValues);
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import * as z from "zod";
3
- import FormCreateModalTemplate from "#v/components/form/create-modal-template/index.vue";
3
+ import FormSaveModalTemplate from "#v/components/form/save-modal-template/index.vue";
4
4
  import { useFlowApi, useFormSubmission, useFormValues } from "#v/composables";
5
5
  import { toRef } from "vue";
6
6
  const props = defineProps({
@@ -18,7 +18,7 @@ const { onSubmit } = useFormSubmission(
18
18
  </script>
19
19
 
20
20
  <template>
21
- <FormCreateModalTemplate
21
+ <FormSaveModalTemplate
22
22
  title="流程信息"
23
23
  :on-close="(ok) => emit('close', ok)"
24
24
  :fields="[
@@ -26,6 +26,7 @@ const { onSubmit } = useFormSubmission(
26
26
  { name: 'description', type: 'textarea', label: '\u6D41\u7A0B\u63CF\u8FF0', colSpan: '24' }
27
27
  ]"
28
28
  :model-value="newValues"
29
+ :old-model-value="oldValues"
29
30
  @update-model-value="(newVal) => newValues = { ...newValues, ...newVal }"
30
31
  @submit="onSubmit"
31
32
  />
@@ -5,10 +5,10 @@ import { getCreateAtColumn } from "#v/constants";
5
5
  import { useFlowApi, useFlowNodeApi, useFlowEdgeApi } from "#v/composables";
6
6
  import TablePage from "#v/components/table/Page.vue";
7
7
  import FlowEditor from "#v/components/flow/FlowEditor.client.vue";
8
- import CreateModal from "./CreateModal.vue";
8
+ import SaveModal from "./SaveModal.vue";
9
9
  import EditNodeModal from "./EditNodeModal.vue";
10
10
  const overlay = useOverlay();
11
- const createModal = overlay.create(CreateModal);
11
+ const saveModal = overlay.create(SaveModal);
12
12
  const editNodeModal = overlay.create(EditNodeModal);
13
13
  const tablePageRef = ref(null);
14
14
  const columns = [
@@ -87,12 +87,13 @@ function getExpandVNode(row) {
87
87
  <template>
88
88
  <TablePage
89
89
  ref="tablePageRef"
90
- name="sys-flow"
90
+ name="flows"
91
91
  cn-name="流程列表"
92
92
  :use-api-group="useFlowApi"
93
93
  :biz-columns="columns"
94
94
  expandable
95
95
  :expand-v-node="getExpandVNode"
96
- @edit-row-from-modal="async (row) => Boolean(await createModal.open({ model: { ...row } }).result)"
96
+ :display-fn-in-delete-modal="(model) => model.name"
97
+ @edit-row-from-modal="async (row) => Boolean(await saveModal.open({ model: { ...row } }).result)"
97
98
  />
98
99
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import * as z from "zod";
3
- import FormCreateModalTemplateWithApi from "#v/components/form/create-modal-template/WithApi.vue";
3
+ import FormSaveModalTemplateWithApi from "#v/components/form/save-modal-template/WithApi.vue";
4
4
  import { useIssueRecordApi } from "#v/composables";
5
5
  defineProps({
6
6
  model: { type: Object, required: true }
@@ -9,7 +9,7 @@ const emit = defineEmits(["close", "save"]);
9
9
  </script>
10
10
 
11
11
  <template>
12
- <FormCreateModalTemplateWithApi
12
+ <FormSaveModalTemplateWithApi
13
13
  title="改进建议"
14
14
  description="您可以针对该网页提出任何改进建议或直接联系chenrn@mail.veken.com"
15
15
  :on-close="(ok) => emit('close', ok)"
@@ -2,10 +2,10 @@
2
2
  import { getOprColumns } from "#v/constants";
3
3
  import { useOverlay } from "@nuxt/ui/composables";
4
4
  import { useIssueRecordApi } from "#v/composables";
5
- import SysIssueRecordsCreateModal from "./CreateModal.vue";
5
+ import SysIssueRecordsSaveModal from "./SaveModal.vue";
6
6
  import TablePage from "#v/components/table/Page.vue";
7
7
  const overlay = useOverlay();
8
- const createModal = overlay.create(SysIssueRecordsCreateModal);
8
+ const saveModal = overlay.create(SysIssueRecordsSaveModal);
9
9
  const columns = [
10
10
  {
11
11
  accessorKey: "description",
@@ -20,13 +20,14 @@ const columns = [
20
20
 
21
21
  <template>
22
22
  <TablePage
23
- name="sys-issue-record"
23
+ name="issue_records"
24
24
  cn-name="改进建议"
25
25
  :use-api-group="useIssueRecordApi"
26
26
  :biz-columns="columns"
27
27
  :extra-order-query-options="[
28
28
  { field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
29
29
  ]"
30
- @edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
30
+ :display-fn-in-delete-modal="(model) => model.description"
31
+ @edit-row-from-modal="async (row) => await saveModal.open({ model: row }).result"
31
32
  />
32
33
  </template>