v-nuxt-ui 0.2.27 → 0.2.29
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/table/ExcelExportModal.d.vue.ts +1 -0
- package/dist/runtime/components/table/ExcelExportModal.vue +26 -9
- package/dist/runtime/components/table/ExcelExportModal.vue.d.ts +1 -0
- package/dist/runtime/components/table/Page.vue +1 -0
- package/dist/runtime/components/table/header/index.vue +2 -1
- package/dist/runtime/components/table/index.vue +1 -0
- package/dist/runtime/composables/table/useTable.d.ts +2 -0
- package/dist/runtime/composables/table/useTable.js +22 -2
- package/dist/runtime/composables/table/useTableRowActions.d.ts +3 -0
- package/dist/runtime/composables/table/useTableRowActions.js +28 -13
- package/dist/runtime/composables/table/useTableView.d.ts +2 -0
- package/dist/runtime/composables/table/useTableView.js +6 -2
- package/dist/runtime/types/components/table/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -7,6 +7,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
7
7
|
columns: VColumn<T>[];
|
|
8
8
|
whereQueryOptions: WhereQueryOption<T>[];
|
|
9
9
|
extraWhereQueryInitValues?: WhereQuery<T>;
|
|
10
|
+
initWhereQuery?: WhereQuery<T>;
|
|
10
11
|
listFn?(payload: Omit<QueryTemplate<T>, "selectQuery">, ...args: unknown[]): Promise<{
|
|
11
12
|
data: Ref<RequestResult<PageResult<T>>>;
|
|
12
13
|
}>;
|
|
@@ -5,7 +5,7 @@ import { defu } from "defu";
|
|
|
5
5
|
import { useExporting } from "#v/composables/useBoolean";
|
|
6
6
|
import { useDate } from "#v/composables/useDate";
|
|
7
7
|
import { dateFormat, TIME_ZONE } from "#v/constants";
|
|
8
|
-
import { genTableExcel } from "#v/utils";
|
|
8
|
+
import { cloneJson, genTableExcel } from "#v/utils";
|
|
9
9
|
import TableQueryWhere from "#v/components/table/query/where/index.vue";
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
filename: { type: String, required: false },
|
|
@@ -13,9 +13,10 @@ const props = defineProps({
|
|
|
13
13
|
columns: { type: Array, required: true },
|
|
14
14
|
whereQueryOptions: { type: Array, required: true },
|
|
15
15
|
extraWhereQueryInitValues: { type: Object, required: false },
|
|
16
|
+
initWhereQuery: { type: Object, required: false },
|
|
16
17
|
listFn: { type: Function, required: false }
|
|
17
18
|
});
|
|
18
|
-
const whereQuery = ref();
|
|
19
|
+
const whereQuery = ref(props.initWhereQuery);
|
|
19
20
|
const emit = defineEmits(["close"]);
|
|
20
21
|
const { exporting, startExporting, endExporting } = useExporting();
|
|
21
22
|
const exportExcel = async () => {
|
|
@@ -51,14 +52,30 @@ const exportExcel = async () => {
|
|
|
51
52
|
>
|
|
52
53
|
<template #body>
|
|
53
54
|
<UFormField label="筛选条件">
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
<template #label>
|
|
56
|
+
<div class="flex items-center gap-1">
|
|
57
|
+
<span>筛选条件</span>
|
|
58
|
+
<UTooltip text="同步查询条件" :delay="0" :content="{ side: 'top' }">
|
|
59
|
+
<UButton
|
|
60
|
+
variant="ghost"
|
|
61
|
+
color="neutral"
|
|
62
|
+
size="xs"
|
|
63
|
+
icon="i-lucide-refresh-ccw"
|
|
64
|
+
@click="whereQuery = cloneJson(initWhereQuery)"
|
|
65
|
+
/>
|
|
66
|
+
</UTooltip>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
<div class="ring ring-default rounded-md">
|
|
70
|
+
<TableQueryWhere
|
|
71
|
+
:where-query="whereQuery"
|
|
72
|
+
:where-options="whereQueryOptions"
|
|
73
|
+
:trigger-fetching="async () => {
|
|
58
74
|
}"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
hide-query-button
|
|
76
|
+
@update-where-query="(newWhereQuery) => whereQuery = newWhereQuery"
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
62
79
|
</UFormField>
|
|
63
80
|
</template>
|
|
64
81
|
<template #footer>
|
|
@@ -7,6 +7,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
7
7
|
columns: VColumn<T>[];
|
|
8
8
|
whereQueryOptions: WhereQueryOption<T>[];
|
|
9
9
|
extraWhereQueryInitValues?: WhereQuery<T>;
|
|
10
|
+
initWhereQuery?: WhereQuery<T>;
|
|
10
11
|
listFn?(payload: Omit<QueryTemplate<T>, "selectQuery">, ...args: unknown[]): Promise<{
|
|
11
12
|
data: Ref<RequestResult<PageResult<T>>>;
|
|
12
13
|
}>;
|
|
@@ -41,6 +41,7 @@ const props = defineProps({
|
|
|
41
41
|
disableRowCopy: { type: Boolean, required: false },
|
|
42
42
|
disableRowDeletion: { type: Boolean, required: false },
|
|
43
43
|
disableRowSelection: { type: Boolean, required: false },
|
|
44
|
+
disableRowDiff: { type: Boolean, required: false },
|
|
44
45
|
expandable: { type: Boolean, required: false },
|
|
45
46
|
expandVNode: { type: Function, required: false },
|
|
46
47
|
rowSpanColumns: { type: Array, required: false },
|
|
@@ -67,7 +67,8 @@ async function handleExportExcel() {
|
|
|
67
67
|
filenameWithDateTime: props.exportExcel.filenameWithDateTime,
|
|
68
68
|
listFn: props.apiGroup?.().countAndList,
|
|
69
69
|
whereQueryOptions: props.whereQueryProps.whereOptions,
|
|
70
|
-
extraWhereQueryInitValues: defu(props.extraWhereQueryInitValues, props.exportExcel.extraWhereQueryInitValues)
|
|
70
|
+
extraWhereQueryInitValues: defu(props.extraWhereQueryInitValues, props.exportExcel.extraWhereQueryInitValues),
|
|
71
|
+
initWhereQuery: props.whereQueryProps.whereQuery
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
async function handleBatchDelete() {
|
|
@@ -40,6 +40,7 @@ const props = defineProps({
|
|
|
40
40
|
disableRowCopy: { type: Boolean, required: false },
|
|
41
41
|
disableRowDeletion: { type: Boolean, required: false },
|
|
42
42
|
disableRowSelection: { type: Boolean, required: false },
|
|
43
|
+
disableRowDiff: { type: Boolean, required: false },
|
|
43
44
|
expandable: { type: Boolean, required: false },
|
|
44
45
|
expandVNode: { type: Function, required: false },
|
|
45
46
|
rowSpanColumns: { type: Array, required: false },
|
|
@@ -21,5 +21,7 @@ export interface UseTableReturn<T> {
|
|
|
21
21
|
tblHeaderProps: ComputedRef<TableHeaderProps<T>>;
|
|
22
22
|
tblPaginationProps: ComputedRef<TablePaginationProps<T>>;
|
|
23
23
|
tblContextMenuItems: Ref<ContextMenuItem[]>;
|
|
24
|
+
deletingRowKey: Ref<number | null>;
|
|
25
|
+
editingRowKey: Ref<number | null>;
|
|
24
26
|
}
|
|
25
27
|
export declare function useTable<T>(props: VTableProps<T>): UseTableReturn<T>;
|
|
@@ -42,6 +42,7 @@ export function useTable(props) {
|
|
|
42
42
|
disableRowCopy,
|
|
43
43
|
disableRowDeletion,
|
|
44
44
|
disableRowSelection,
|
|
45
|
+
disableRowDiff,
|
|
45
46
|
expandable,
|
|
46
47
|
rowSpanColumns,
|
|
47
48
|
customRowCopyFn,
|
|
@@ -159,6 +160,7 @@ export function useTable(props) {
|
|
|
159
160
|
disableRowUpdate,
|
|
160
161
|
disableRowCopy,
|
|
161
162
|
disableRowDeletion,
|
|
163
|
+
disableRowDiff,
|
|
162
164
|
onEditRowFromModal,
|
|
163
165
|
extraRowActions,
|
|
164
166
|
useApiGroup,
|
|
@@ -166,7 +168,7 @@ export function useTable(props) {
|
|
|
166
168
|
displayFnInDeleteModal,
|
|
167
169
|
fetchList
|
|
168
170
|
});
|
|
169
|
-
const { getRowActions, generateActionColumn } = rowActionsComposable;
|
|
171
|
+
const { getRowActions, generateActionColumn, deletingRowKey, editingRowKey } = rowActionsComposable;
|
|
170
172
|
const columns = computed(() => {
|
|
171
173
|
const newCols = [];
|
|
172
174
|
if (!disableRowSelection) {
|
|
@@ -243,6 +245,22 @@ export function useTable(props) {
|
|
|
243
245
|
if (!disableRowActions) {
|
|
244
246
|
newCols.push(generateActionColumn());
|
|
245
247
|
}
|
|
248
|
+
newCols.forEach((col) => {
|
|
249
|
+
const existingTdClass = col.meta?.class?.td;
|
|
250
|
+
col.meta = col.meta || {};
|
|
251
|
+
col.meta.class = col.meta.class || {};
|
|
252
|
+
col.meta.class.td = (cell) => {
|
|
253
|
+
const rowKeyValue = cell.row.original[rowKey];
|
|
254
|
+
let highlightClass = "";
|
|
255
|
+
if (deletingRowKey.value !== null && deletingRowKey.value === rowKeyValue) {
|
|
256
|
+
highlightClass = "!bg-(--ui-color-error-50) dark:!bg-(--ui-color-error-900)";
|
|
257
|
+
} else if (editingRowKey.value !== null && editingRowKey.value === rowKeyValue) {
|
|
258
|
+
highlightClass = "!bg-(--ui-color-primary-50) dark:!bg-(--ui-color-primary-900)";
|
|
259
|
+
}
|
|
260
|
+
const existingClass = typeof existingTdClass === "function" ? existingTdClass(cell) : existingTdClass || "";
|
|
261
|
+
return [existingClass, highlightClass].filter(Boolean).join(" ");
|
|
262
|
+
};
|
|
263
|
+
});
|
|
246
264
|
return newCols;
|
|
247
265
|
});
|
|
248
266
|
const tblContextMenuItems = ref([]);
|
|
@@ -345,6 +363,8 @@ export function useTable(props) {
|
|
|
345
363
|
tblHeaderProps,
|
|
346
364
|
tblPaginationProps,
|
|
347
365
|
// others
|
|
348
|
-
tblContextMenuItems
|
|
366
|
+
tblContextMenuItems,
|
|
367
|
+
deletingRowKey,
|
|
368
|
+
editingRowKey
|
|
349
369
|
};
|
|
350
370
|
}
|
|
@@ -8,6 +8,7 @@ export declare function useTableRowActions<T>(props: {
|
|
|
8
8
|
disableRowUpdate?: boolean;
|
|
9
9
|
disableRowCopy?: boolean;
|
|
10
10
|
disableRowDeletion?: boolean;
|
|
11
|
+
disableRowDiff?: boolean;
|
|
11
12
|
onEditRowFromModal?: (...args: any[]) => any;
|
|
12
13
|
extraRowActions?: any[];
|
|
13
14
|
useApiGroup?: (...args: any[]) => any;
|
|
@@ -18,4 +19,6 @@ export declare function useTableRowActions<T>(props: {
|
|
|
18
19
|
getRowActions: (row: TableRow<T>) => DropdownMenuItem[];
|
|
19
20
|
generateActionColumn: () => VColumn<T>;
|
|
20
21
|
actionLoadingRowIdxSet: import("vue").Ref<Set<number> & Omit<Set<number>, keyof Set<any>>, Set<number> | (Set<number> & Omit<Set<number>, keyof Set<any>>)>;
|
|
22
|
+
deletingRowKey: import("vue").Ref<number | null, number | null>;
|
|
23
|
+
editingRowKey: import("vue").Ref<number | null, number | null>;
|
|
21
24
|
};
|
|
@@ -13,6 +13,7 @@ export function useTableRowActions(props) {
|
|
|
13
13
|
disableRowUpdate,
|
|
14
14
|
disableRowCopy,
|
|
15
15
|
disableRowDeletion,
|
|
16
|
+
disableRowDiff,
|
|
16
17
|
onEditRowFromModal,
|
|
17
18
|
extraRowActions,
|
|
18
19
|
useApiGroup,
|
|
@@ -25,6 +26,8 @@ export function useTableRowActions(props) {
|
|
|
25
26
|
const updateDiffModal = overlay.create(UpdateDiffModal);
|
|
26
27
|
const apiGroup = useApiGroup?.();
|
|
27
28
|
const actionLoadingRowIdxSet = ref(/* @__PURE__ */ new Set());
|
|
29
|
+
const deletingRowKey = ref(null);
|
|
30
|
+
const editingRowKey = ref(null);
|
|
28
31
|
function getRowActions(row) {
|
|
29
32
|
const actionItems = [];
|
|
30
33
|
if (!disableRowUpdate && onEditRowFromModal) {
|
|
@@ -32,9 +35,14 @@ export function useTableRowActions(props) {
|
|
|
32
35
|
label: "\u7F16\u8F91",
|
|
33
36
|
icon: "i-lucide-clipboard-pen-line",
|
|
34
37
|
onClick: async () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await
|
|
38
|
+
editingRowKey.value = row.original[rowKey];
|
|
39
|
+
try {
|
|
40
|
+
const result = await onEditRowFromModal(row.original);
|
|
41
|
+
if (result) {
|
|
42
|
+
await fetchList();
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
editingRowKey.value = null;
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
});
|
|
@@ -94,7 +102,7 @@ export function useTableRowActions(props) {
|
|
|
94
102
|
extraRowActions?.forEach((action) => {
|
|
95
103
|
actionItems.push(buildActionItem(action));
|
|
96
104
|
});
|
|
97
|
-
if (tableName) {
|
|
105
|
+
if (tableName && !disableRowDiff) {
|
|
98
106
|
if (actionItems.length > 0 && !disableRowDeletion) {
|
|
99
107
|
actionItems.push({ type: "separator" });
|
|
100
108
|
}
|
|
@@ -120,14 +128,19 @@ export function useTableRowActions(props) {
|
|
|
120
128
|
icon: "i-lucide-trash-2",
|
|
121
129
|
color: "error",
|
|
122
130
|
onSelect: async () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
deletingRowKey.value = row.original[rowKey];
|
|
132
|
+
try {
|
|
133
|
+
const result = await deleteModal.open({
|
|
134
|
+
ids: [row.original[rowKey]],
|
|
135
|
+
models: [row.original],
|
|
136
|
+
displayFn: displayFnInDeleteModal,
|
|
137
|
+
onDelete: (ids) => apiGroup?.batchDelete({ ids })
|
|
138
|
+
}).result;
|
|
139
|
+
if (result) {
|
|
140
|
+
await fetchList();
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
deletingRowKey.value = null;
|
|
131
144
|
}
|
|
132
145
|
}
|
|
133
146
|
});
|
|
@@ -185,6 +198,8 @@ export function useTableRowActions(props) {
|
|
|
185
198
|
return {
|
|
186
199
|
getRowActions,
|
|
187
200
|
generateActionColumn,
|
|
188
|
-
actionLoadingRowIdxSet
|
|
201
|
+
actionLoadingRowIdxSet,
|
|
202
|
+
deletingRowKey,
|
|
203
|
+
editingRowKey
|
|
189
204
|
};
|
|
190
205
|
}
|
|
@@ -27,7 +27,9 @@ export function useProTableView(props) {
|
|
|
27
27
|
tblWhereQueryProps,
|
|
28
28
|
tblHeaderProps,
|
|
29
29
|
tblPaginationProps,
|
|
30
|
-
tblContextMenuItems
|
|
30
|
+
tblContextMenuItems,
|
|
31
|
+
deletingRowKey,
|
|
32
|
+
editingRowKey
|
|
31
33
|
} = useTable(props);
|
|
32
34
|
const thClass = computed(() => {
|
|
33
35
|
const classList = [];
|
|
@@ -145,6 +147,8 @@ export function useProTableView(props) {
|
|
|
145
147
|
tableWidth,
|
|
146
148
|
updateTableWidth,
|
|
147
149
|
tblClasses,
|
|
148
|
-
tblUi
|
|
150
|
+
tblUi,
|
|
151
|
+
deletingRowKey,
|
|
152
|
+
editingRowKey
|
|
149
153
|
};
|
|
150
154
|
}
|
package/package.json
CHANGED