cosey 0.4.11 → 0.4.13
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/components/form-dialog/form-dialog.d.ts +4 -8
- package/components/form-dialog/form-dialog.js +4 -0
- package/components/table/table-export/table-export.d.ts +4 -8
- package/components/table/table-export/table-export.vue.d.ts +8 -16
- package/hooks/useUpsert.d.ts +8 -7
- package/hooks/useUpsert.js +18 -16
- package/package.json +1 -1
|
@@ -40,6 +40,10 @@ export declare const formDialogProps: {
|
|
|
40
40
|
type: BooleanConstructor;
|
|
41
41
|
default: boolean;
|
|
42
42
|
};
|
|
43
|
+
closeOnPressEscape: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
43
47
|
confirmText: {
|
|
44
48
|
type: StringConstructor;
|
|
45
49
|
default: string;
|
|
@@ -76,14 +80,6 @@ export declare const formDialogProps: {
|
|
|
76
80
|
__epPropKey: true;
|
|
77
81
|
};
|
|
78
82
|
destroyOnClose: BooleanConstructor;
|
|
79
|
-
closeOnPressEscape: {
|
|
80
|
-
readonly type: PropType<boolean>;
|
|
81
|
-
readonly required: false;
|
|
82
|
-
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
83
|
-
__epPropKey: true;
|
|
84
|
-
} & {
|
|
85
|
-
readonly default: true;
|
|
86
|
-
};
|
|
87
83
|
lockScroll: {
|
|
88
84
|
readonly type: PropType<boolean>;
|
|
89
85
|
readonly required: false;
|
|
@@ -27,6 +27,10 @@ export declare const tableExportProps: {
|
|
|
27
27
|
type: BooleanConstructor;
|
|
28
28
|
default: boolean;
|
|
29
29
|
};
|
|
30
|
+
closeOnPressEscape: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
30
34
|
confirmText: {
|
|
31
35
|
type: StringConstructor;
|
|
32
36
|
default: string;
|
|
@@ -63,14 +67,6 @@ export declare const tableExportProps: {
|
|
|
63
67
|
__epPropKey: true;
|
|
64
68
|
};
|
|
65
69
|
destroyOnClose: BooleanConstructor;
|
|
66
|
-
closeOnPressEscape: {
|
|
67
|
-
readonly type: PropType<boolean>;
|
|
68
|
-
readonly required: false;
|
|
69
|
-
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
70
|
-
__epPropKey: true;
|
|
71
|
-
} & {
|
|
72
|
-
readonly default: true;
|
|
73
|
-
};
|
|
74
70
|
lockScroll: {
|
|
75
71
|
readonly type: PropType<boolean>;
|
|
76
72
|
readonly required: false;
|
|
@@ -25,6 +25,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
25
25
|
type: BooleanConstructor;
|
|
26
26
|
default: boolean;
|
|
27
27
|
};
|
|
28
|
+
closeOnPressEscape: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
28
32
|
confirmText: {
|
|
29
33
|
type: StringConstructor;
|
|
30
34
|
default: string;
|
|
@@ -61,14 +65,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
61
65
|
__epPropKey: true;
|
|
62
66
|
};
|
|
63
67
|
destroyOnClose: BooleanConstructor;
|
|
64
|
-
closeOnPressEscape: {
|
|
65
|
-
readonly type: import("vue").PropType<boolean>;
|
|
66
|
-
readonly required: false;
|
|
67
|
-
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
68
|
-
__epPropKey: true;
|
|
69
|
-
} & {
|
|
70
|
-
readonly default: true;
|
|
71
|
-
};
|
|
72
68
|
lockScroll: {
|
|
73
69
|
readonly type: import("vue").PropType<boolean>;
|
|
74
70
|
readonly required: false;
|
|
@@ -196,6 +192,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
196
192
|
type: BooleanConstructor;
|
|
197
193
|
default: boolean;
|
|
198
194
|
};
|
|
195
|
+
closeOnPressEscape: {
|
|
196
|
+
type: BooleanConstructor;
|
|
197
|
+
default: boolean;
|
|
198
|
+
};
|
|
199
199
|
confirmText: {
|
|
200
200
|
type: StringConstructor;
|
|
201
201
|
default: string;
|
|
@@ -232,14 +232,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
232
232
|
__epPropKey: true;
|
|
233
233
|
};
|
|
234
234
|
destroyOnClose: BooleanConstructor;
|
|
235
|
-
closeOnPressEscape: {
|
|
236
|
-
readonly type: import("vue").PropType<boolean>;
|
|
237
|
-
readonly required: false;
|
|
238
|
-
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
239
|
-
__epPropKey: true;
|
|
240
|
-
} & {
|
|
241
|
-
readonly default: true;
|
|
242
|
-
};
|
|
243
235
|
lockScroll: {
|
|
244
236
|
readonly type: import("vue").PropType<boolean>;
|
|
245
237
|
readonly required: false;
|
package/hooks/useUpsert.d.ts
CHANGED
|
@@ -9,16 +9,17 @@ export interface UseUpsertExpose<Row extends Record<string, any>, Data = any> {
|
|
|
9
9
|
setOptions: (options: UseUpsertExposeOptions) => any;
|
|
10
10
|
}
|
|
11
11
|
export type UpsertType = 'edit' | 'add';
|
|
12
|
-
export interface UseUpsertOptions<Model, Row = Model
|
|
12
|
+
export interface UseUpsertOptions<Model, Row = Model> {
|
|
13
13
|
title?: string;
|
|
14
14
|
stuffTitle?: string;
|
|
15
15
|
model: Model;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
onAdd?: (...args: any[]) => void;
|
|
17
|
+
onEdit?: (row: Row, ...args: any[]) => void;
|
|
18
|
+
onShow?: () => void;
|
|
19
|
+
detailsFetch?: (row: Row) => any;
|
|
18
20
|
beforeFill?: (row: Row) => any;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
edit?: (data: Data) => any;
|
|
21
|
+
addFetch?: () => any;
|
|
22
|
+
editFetch?: () => any;
|
|
22
23
|
success?: (res: any) => any;
|
|
23
24
|
addSuccessText?: string;
|
|
24
25
|
editSuccessText?: string;
|
|
@@ -42,7 +43,7 @@ export interface UseUpsertReturn<Model extends Record<string, any>, Row extends
|
|
|
42
43
|
isEdit: ComputedRef<boolean>;
|
|
43
44
|
isAdd: ComputedRef<boolean>;
|
|
44
45
|
}
|
|
45
|
-
export declare function useUpsert<Model extends Record<string, any>, Row extends Record<string, any> = Model, Data = any>(options: MaybeRef<UseUpsertOptions<Model, Row
|
|
46
|
+
export declare function useUpsert<Model extends Record<string, any>, Row extends Record<string, any> = Model, Data = any>(options: MaybeRef<UseUpsertOptions<Model, Row>>): UseUpsertReturn<Model, Row, Data>;
|
|
46
47
|
export interface UseExternalUpsertOptions {
|
|
47
48
|
success?: () => any;
|
|
48
49
|
}
|
package/hooks/useUpsert.js
CHANGED
|
@@ -17,12 +17,13 @@ function useUpsert(options) {
|
|
|
17
17
|
title,
|
|
18
18
|
addSuccessText,
|
|
19
19
|
editSuccessText,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
onAdd,
|
|
21
|
+
onEdit,
|
|
22
|
+
onShow,
|
|
23
|
+
detailsFetch,
|
|
22
24
|
beforeFill,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
edit,
|
|
25
|
+
addFetch,
|
|
26
|
+
editFetch,
|
|
26
27
|
success
|
|
27
28
|
} = toRefs(computed(() => unref(options)));
|
|
28
29
|
const { t, lang } = useLocale();
|
|
@@ -45,13 +46,12 @@ function useUpsert(options) {
|
|
|
45
46
|
const formRefKey = uuid();
|
|
46
47
|
const formRef = useTemplateRef(formRefKey);
|
|
47
48
|
const onSubmit = async () => {
|
|
48
|
-
const data2 = await unref(beforeSubmit)?.(unref(model)) || unref(model);
|
|
49
49
|
let res;
|
|
50
50
|
if (type.value === "add") {
|
|
51
|
-
res = await unref(
|
|
51
|
+
res = await unref(addFetch)?.();
|
|
52
52
|
ElMessage.success(unref(addSuccessText) || t("co.common.addSuccess"));
|
|
53
53
|
} else {
|
|
54
|
-
res = await unref(
|
|
54
|
+
res = await unref(editFetch)?.();
|
|
55
55
|
ElMessage.success(unref(editSuccessText) || t("co.common.editSuccess"));
|
|
56
56
|
}
|
|
57
57
|
unref(success)?.(res);
|
|
@@ -66,26 +66,28 @@ function useUpsert(options) {
|
|
|
66
66
|
const row = shallowRef();
|
|
67
67
|
let exposeOptions;
|
|
68
68
|
const expose = {
|
|
69
|
-
edit: async (
|
|
69
|
+
edit: async (...args) => {
|
|
70
70
|
type.value = "edit";
|
|
71
|
-
row.value =
|
|
71
|
+
row.value = args[0];
|
|
72
72
|
deepAssign(unref(model), initialModel);
|
|
73
|
+
unref(onEdit)?.(...args);
|
|
73
74
|
visible.value = true;
|
|
74
|
-
unref(
|
|
75
|
-
let filledRow =
|
|
76
|
-
if (unref(
|
|
77
|
-
filledRow = await unref(
|
|
75
|
+
unref(onShow)?.();
|
|
76
|
+
let filledRow = row.value;
|
|
77
|
+
if (unref(detailsFetch)) {
|
|
78
|
+
filledRow = await unref(detailsFetch)(row.value);
|
|
78
79
|
}
|
|
79
80
|
filledRow = { ...filledRow };
|
|
80
81
|
filledRow = unref(beforeFill)?.(filledRow) || filledRow;
|
|
81
82
|
Object.assign(unref(model), pick(filledRow, modelKeys));
|
|
82
83
|
},
|
|
83
|
-
add: () => {
|
|
84
|
+
add: (...args) => {
|
|
84
85
|
type.value = "add";
|
|
85
86
|
row.value = void 0;
|
|
86
87
|
deepAssign(unref(model), initialModel);
|
|
88
|
+
unref(onAdd)?.(...args);
|
|
87
89
|
visible.value = true;
|
|
88
|
-
unref(
|
|
90
|
+
unref(onShow)?.();
|
|
89
91
|
},
|
|
90
92
|
setData: (_data) => {
|
|
91
93
|
data.value = _data;
|