v-nuxt-ui 0.1.32 → 0.1.34
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/assets/css/main.css +1 -1
- package/dist/runtime/components/form/create-modal-template/index.d.vue.ts +3 -1
- package/dist/runtime/components/form/create-modal-template/index.vue +1 -0
- package/dist/runtime/components/form/create-modal-template/index.vue.d.ts +3 -1
- package/dist/runtime/components/sys/role/CreateModal.vue +14 -2
- package/dist/runtime/components/sys/table/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/table/CreateModal.vue +239 -0
- package/dist/runtime/components/sys/table/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/table/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/table/Table.vue +116 -0
- package/dist/runtime/components/sys/table/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/table/TableColumnModal.d.vue.ts +22 -0
- package/dist/runtime/components/sys/table/TableColumnModal.vue +107 -0
- package/dist/runtime/components/sys/table/TableColumnModal.vue.d.ts +22 -0
- package/dist/runtime/components/sys/user/CreateModal.vue +14 -2
- package/dist/runtime/components/table/permission/TablePermissionConfig.d.vue.ts +14 -0
- package/dist/runtime/components/table/permission/TablePermissionConfig.vue +230 -0
- package/dist/runtime/components/table/permission/TablePermissionConfig.vue.d.ts +14 -0
- package/dist/runtime/components/table/permission/TablePermissionTab.d.vue.ts +11 -0
- package/dist/runtime/components/table/permission/TablePermissionTab.vue +95 -0
- package/dist/runtime/components/table/permission/TablePermissionTab.vue.d.ts +11 -0
- package/dist/runtime/components/table/settings/TableSettings.d.vue.ts +3 -0
- package/dist/runtime/components/table/settings/TableSettings.vue +118 -0
- package/dist/runtime/components/table/settings/TableSettings.vue.d.ts +3 -0
- package/dist/runtime/components/table/settings/UserTableColumnModal.d.vue.ts +17 -0
- package/dist/runtime/components/table/settings/UserTableColumnModal.vue +106 -0
- package/dist/runtime/components/table/settings/UserTableColumnModal.vue.d.ts +17 -0
- package/dist/runtime/composables/api/sys/index.d.ts +3 -0
- package/dist/runtime/composables/api/sys/index.js +3 -0
- package/dist/runtime/composables/api/useTableApi.d.ts +2 -0
- package/dist/runtime/composables/api/useTableApi.js +5 -0
- package/dist/runtime/composables/api/useTableColumnApi.d.ts +11 -0
- package/dist/runtime/composables/api/useTableColumnApi.js +11 -0
- package/dist/runtime/composables/api/useTablePermissionApi.d.ts +8 -0
- package/dist/runtime/composables/api/useTablePermissionApi.js +8 -0
- package/dist/runtime/composables/table/useTableColumnPermission.d.ts +34 -0
- package/dist/runtime/composables/table/useTableColumnPermission.js +47 -0
- package/dist/runtime/composables/useAuth.d.ts +56 -0
- package/dist/runtime/composables/useForm.d.ts +1 -1
- package/dist/runtime/composables/useForm.js +7 -3
- package/dist/runtime/types/cmds/sys.d.ts +3 -0
- package/dist/runtime/types/models/index.d.ts +1 -0
- package/dist/runtime/types/models/index.js +1 -0
- package/dist/runtime/types/models/sys.d.ts +3 -0
- package/dist/runtime/types/models/table.d.ts +59 -0
- package/dist/runtime/types/models/table.js +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TablePermission } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
permission?: TablePermission;
|
|
4
|
+
tableId?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
+
close: (args_0: boolean) => any;
|
|
8
|
+
save: (args_0: TablePermission) => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
10
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
11
|
+
onSave?: ((args_0: TablePermission) => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, onMounted } from "vue";
|
|
3
|
+
import { useTableApi, useTableColumnApi } from "#v/composables/api";
|
|
4
|
+
import { useToast } from "@nuxt/ui/composables";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
permission: { type: Object, required: false },
|
|
7
|
+
tableId: { type: Number, required: false }
|
|
8
|
+
});
|
|
9
|
+
const emit = defineEmits(["close", "save"]);
|
|
10
|
+
const tableApi = useTableApi();
|
|
11
|
+
const tableColumnApi = useTableColumnApi();
|
|
12
|
+
const tables = ref([]);
|
|
13
|
+
const selectedTableId = ref(props.tableId);
|
|
14
|
+
const selectedTable = ref();
|
|
15
|
+
const mergedColumns = ref([]);
|
|
16
|
+
const canView = ref(false);
|
|
17
|
+
const canEdit = ref(false);
|
|
18
|
+
const columnPermissions = ref([]);
|
|
19
|
+
const loading = ref(false);
|
|
20
|
+
const saving = ref(false);
|
|
21
|
+
const tableItems = computed(() => tables.value.map((t) => ({
|
|
22
|
+
label: `${t.label} (${t.tblName})`,
|
|
23
|
+
value: t.id
|
|
24
|
+
})));
|
|
25
|
+
async function fetchTables() {
|
|
26
|
+
try {
|
|
27
|
+
loading.value = true;
|
|
28
|
+
const { data } = await tableApi.list({
|
|
29
|
+
pagination: { pageNum: 0, pageSize: 0 },
|
|
30
|
+
orderQuery: [{ field: "label", order: "asc" }]
|
|
31
|
+
});
|
|
32
|
+
if (data.value.error) {
|
|
33
|
+
useToast().add({
|
|
34
|
+
title: "\u83B7\u53D6 Table \u5217\u8868\u5931\u8D25",
|
|
35
|
+
description: data.value.error.message,
|
|
36
|
+
color: "error"
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (data.value.data) {
|
|
41
|
+
tables.value = data.value.data.list;
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
useToast().add({
|
|
45
|
+
title: "\u83B7\u53D6 Table \u5217\u8868\u5931\u8D25",
|
|
46
|
+
description: e instanceof Error ? e.message : "\u672A\u77E5\u9519\u8BEF",
|
|
47
|
+
color: "error"
|
|
48
|
+
});
|
|
49
|
+
} finally {
|
|
50
|
+
loading.value = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function fetchMergedColumns(tblName) {
|
|
54
|
+
try {
|
|
55
|
+
const { data } = await tableColumnApi.getMergedColumns(tblName);
|
|
56
|
+
if (data.value.error) {
|
|
57
|
+
useToast().add({
|
|
58
|
+
title: "\u83B7\u53D6\u5217\u4FE1\u606F\u5931\u8D25",
|
|
59
|
+
description: data.value.error.message,
|
|
60
|
+
color: "error"
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (data.value.data) {
|
|
65
|
+
mergedColumns.value = data.value.data;
|
|
66
|
+
initColumnPermissions();
|
|
67
|
+
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
useToast().add({
|
|
70
|
+
title: "\u83B7\u53D6\u5217\u4FE1\u606F\u5931\u8D25",
|
|
71
|
+
description: e instanceof Error ? e.message : "\u672A\u77E5\u9519\u8BEF",
|
|
72
|
+
color: "error"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function initColumnPermissions() {
|
|
77
|
+
columnPermissions.value = mergedColumns.value.map((col) => {
|
|
78
|
+
const existing = props.permission?.columnPermissions?.find(
|
|
79
|
+
(cp) => cp.columnKey === col.columnKey
|
|
80
|
+
);
|
|
81
|
+
return {
|
|
82
|
+
id: existing?.id ?? 0,
|
|
83
|
+
tablePermissionId: props.permission?.id ?? 0,
|
|
84
|
+
columnKey: col.columnKey,
|
|
85
|
+
canView: existing?.canView ?? col.canView,
|
|
86
|
+
canEdit: existing?.canEdit ?? col.canEdit
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function onTableChange(tableId) {
|
|
91
|
+
selectedTableId.value = tableId;
|
|
92
|
+
const table = tables.value.find((t) => t.id === tableId);
|
|
93
|
+
if (table) {
|
|
94
|
+
selectedTable.value = table;
|
|
95
|
+
fetchMergedColumns(table.tblName);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function handleSave() {
|
|
99
|
+
if (!selectedTableId.value || !selectedTable.value) {
|
|
100
|
+
useToast().add({
|
|
101
|
+
title: "\u8BF7\u9009\u62E9 Table",
|
|
102
|
+
color: "warning"
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
saving.value = true;
|
|
108
|
+
const result = {
|
|
109
|
+
id: props.permission?.id ?? 0,
|
|
110
|
+
name: selectedTable.value.label,
|
|
111
|
+
tableId: selectedTableId.value,
|
|
112
|
+
canView: canView.value,
|
|
113
|
+
canEdit: canEdit.value,
|
|
114
|
+
columnPermissions: columnPermissions.value
|
|
115
|
+
};
|
|
116
|
+
emit("save", result);
|
|
117
|
+
emit("close", true);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
useToast().add({
|
|
120
|
+
title: "\u4FDD\u5B58\u5931\u8D25",
|
|
121
|
+
description: e instanceof Error ? e.message : "\u672A\u77E5\u9519\u8BEF",
|
|
122
|
+
color: "error"
|
|
123
|
+
});
|
|
124
|
+
} finally {
|
|
125
|
+
saving.value = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function handleClose() {
|
|
129
|
+
emit("close", false);
|
|
130
|
+
}
|
|
131
|
+
onMounted(async () => {
|
|
132
|
+
await fetchTables();
|
|
133
|
+
if (props.tableId) {
|
|
134
|
+
selectedTableId.value = props.tableId;
|
|
135
|
+
const table = tables.value.find((t) => t.id === props.tableId);
|
|
136
|
+
if (table) {
|
|
137
|
+
selectedTable.value = table;
|
|
138
|
+
await fetchMergedColumns(table.tblName);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (props.permission) {
|
|
142
|
+
canView.value = props.permission.canView ?? false;
|
|
143
|
+
canEdit.value = props.permission.canEdit ?? false;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<template>
|
|
149
|
+
<UModal
|
|
150
|
+
:title="props.permission ? '\u7F16\u8F91 Table \u6743\u9650' : '\u914D\u7F6E Table \u6743\u9650'"
|
|
151
|
+
size="xl"
|
|
152
|
+
:close="{ onClick: handleClose }"
|
|
153
|
+
>
|
|
154
|
+
<div class="p-4 space-y-4">
|
|
155
|
+
<UFormField label="选择 Table" required>
|
|
156
|
+
<USelect
|
|
157
|
+
v-model="selectedTableId"
|
|
158
|
+
:items="tableItems"
|
|
159
|
+
:loading="loading"
|
|
160
|
+
placeholder="请选择 Table"
|
|
161
|
+
class="w-full"
|
|
162
|
+
@update:model-value="onTableChange"
|
|
163
|
+
/>
|
|
164
|
+
</UFormField>
|
|
165
|
+
|
|
166
|
+
<div v-if="selectedTable" class="space-y-4">
|
|
167
|
+
<div class="text-sm font-medium">
|
|
168
|
+
表级权限
|
|
169
|
+
</div>
|
|
170
|
+
<div class="flex gap-6">
|
|
171
|
+
<UCheckbox
|
|
172
|
+
v-model="canView"
|
|
173
|
+
label="CanView"
|
|
174
|
+
/>
|
|
175
|
+
<UCheckbox
|
|
176
|
+
v-model="canEdit"
|
|
177
|
+
label="CanEdit"
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div class="text-sm font-medium">
|
|
182
|
+
列级权限
|
|
183
|
+
</div>
|
|
184
|
+
<UTable :data="columnPermissions" class="max-h-80">
|
|
185
|
+
<UTableColumn accessor-key="columnKey" header="列标识">
|
|
186
|
+
<template #cell="{ row }">
|
|
187
|
+
<span class="text-sm">
|
|
188
|
+
{{ mergedColumns.find((c) => c.columnKey === row.original.columnKey)?.label || row.original.columnKey }}
|
|
189
|
+
</span>
|
|
190
|
+
</template>
|
|
191
|
+
</UTableColumn>
|
|
192
|
+
<UTableColumn accessor-key="columnKey" header="列名">
|
|
193
|
+
<template #cell="{ row }">
|
|
194
|
+
<span class="text-dimmed text-xs">
|
|
195
|
+
{{ row.original.columnKey }}
|
|
196
|
+
</span>
|
|
197
|
+
</template>
|
|
198
|
+
</UTableColumn>
|
|
199
|
+
<UTableColumn accessor-key="canView" header="CanView">
|
|
200
|
+
<template #cell="{ row }">
|
|
201
|
+
<USwitch v-model="row.original.canView" />
|
|
202
|
+
</template>
|
|
203
|
+
</UTableColumn>
|
|
204
|
+
<UTableColumn accessor-key="canEdit" header="CanEdit">
|
|
205
|
+
<template #cell="{ row }">
|
|
206
|
+
<USwitch v-model="row.original.canEdit" />
|
|
207
|
+
</template>
|
|
208
|
+
</UTableColumn>
|
|
209
|
+
</UTable>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<template #footer>
|
|
214
|
+
<UButton
|
|
215
|
+
label="取消"
|
|
216
|
+
color="neutral"
|
|
217
|
+
variant="subtle"
|
|
218
|
+
@click="handleClose"
|
|
219
|
+
/>
|
|
220
|
+
<UButton
|
|
221
|
+
label="保存"
|
|
222
|
+
color="primary"
|
|
223
|
+
variant="solid"
|
|
224
|
+
:loading="saving"
|
|
225
|
+
:disabled="!selectedTableId"
|
|
226
|
+
@click="handleSave"
|
|
227
|
+
/>
|
|
228
|
+
</template>
|
|
229
|
+
</UModal>
|
|
230
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TablePermission } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
permission?: TablePermission;
|
|
4
|
+
tableId?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
+
close: (args_0: boolean) => any;
|
|
8
|
+
save: (args_0: TablePermission) => any;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
10
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
11
|
+
onSave?: ((args_0: TablePermission) => any) | undefined;
|
|
12
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TablePermission } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
modelValue: TablePermission[];
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:modelValue": (args_0: TablePermission[]) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
"onUpdate:modelValue"?: ((args_0: TablePermission[]) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useOverlay, useToast } from "@nuxt/ui/composables";
|
|
3
|
+
import TablePermissionConfig from "./TablePermissionConfig.vue";
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
modelValue: { type: Array, required: true }
|
|
6
|
+
});
|
|
7
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
8
|
+
const overlay = useOverlay();
|
|
9
|
+
const toast = useToast();
|
|
10
|
+
const tablePermissionConfigModal = overlay.create(TablePermissionConfig);
|
|
11
|
+
function openAddModal() {
|
|
12
|
+
tablePermissionConfigModal.open({}).result.then((result) => {
|
|
13
|
+
if (result?.save) {
|
|
14
|
+
const newPermissions = [...props.modelValue, result.save];
|
|
15
|
+
emit("update:modelValue", newPermissions);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function openEditModal(permission) {
|
|
20
|
+
tablePermissionConfigModal.open({ permission }).result.then((result) => {
|
|
21
|
+
if (result?.save) {
|
|
22
|
+
const newPermissions = props.modelValue.map(
|
|
23
|
+
(p) => p.tableId === result.save.tableId ? result.save : p
|
|
24
|
+
);
|
|
25
|
+
emit("update:modelValue", newPermissions);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function removePermission(tableId) {
|
|
30
|
+
toast.add({
|
|
31
|
+
title: "\u786E\u8BA4\u5220\u9664",
|
|
32
|
+
description: "\u786E\u5B9A\u8981\u5220\u9664\u8BE5 Table \u6743\u9650\u5417\uFF1F",
|
|
33
|
+
color: "warning",
|
|
34
|
+
actions: [
|
|
35
|
+
{ label: "\u53D6\u6D88", variant: "subtle" },
|
|
36
|
+
{
|
|
37
|
+
label: "\u5220\u9664",
|
|
38
|
+
color: "error",
|
|
39
|
+
onClick: () => {
|
|
40
|
+
const newPermissions = props.modelValue.filter((p) => p.tableId !== tableId);
|
|
41
|
+
emit("update:modelValue", newPermissions);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<div class="space-y-3">
|
|
51
|
+
<div class="flex justify-end">
|
|
52
|
+
<UButton
|
|
53
|
+
label="添加 Table 权限"
|
|
54
|
+
icon="i-lucide-plus"
|
|
55
|
+
size="sm"
|
|
56
|
+
@click="openAddModal"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<UTable
|
|
61
|
+
v-if="props.modelValue.length > 0"
|
|
62
|
+
:data="props.modelValue"
|
|
63
|
+
:columns="[
|
|
64
|
+
{ accessorKey: 'name', header: 'Table \u540D\u79F0' },
|
|
65
|
+
{ accessorKey: 'tableId', header: 'Table ID' },
|
|
66
|
+
{ accessorKey: 'canView', header: 'CanView', cell: ({ row: row2 }) => row2.original.canView ? '\u662F' : '\u5426' },
|
|
67
|
+
{ accessorKey: 'canEdit', header: 'CanEdit', cell: ({ row: row2 }) => row2.original.canEdit ? '\u662F' : '\u5426' },
|
|
68
|
+
{ accessorKey: 'columnPermissions', header: '\u5217\u6743\u9650\u6570', cell: ({ row: row2 }) => row2.original.columnPermissions?.length || 0 },
|
|
69
|
+
{ accessorKey: 'actions', header: '\u64CD\u4F5C', cell: ({ row: row2 }) => 'actions' }
|
|
70
|
+
]"
|
|
71
|
+
>
|
|
72
|
+
<template #body-cell-actions="{ row }">
|
|
73
|
+
<div class="flex gap-1">
|
|
74
|
+
<UButton
|
|
75
|
+
icon="i-lucide-edit"
|
|
76
|
+
variant="ghost"
|
|
77
|
+
size="xs"
|
|
78
|
+
@click="openEditModal(row.original)"
|
|
79
|
+
/>
|
|
80
|
+
<UButton
|
|
81
|
+
icon="i-lucide-trash-2"
|
|
82
|
+
variant="ghost"
|
|
83
|
+
size="xs"
|
|
84
|
+
color="error"
|
|
85
|
+
@click="removePermission(row.original.tableId)"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
</UTable>
|
|
90
|
+
|
|
91
|
+
<div v-else class="text-center text-dimmed text-sm py-8">
|
|
92
|
+
暂无 Table 权限配置
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TablePermission } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
modelValue: TablePermission[];
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:modelValue": (args_0: TablePermission[]) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
"onUpdate:modelValue"?: ((args_0: TablePermission[]) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useTableColumnPermission } from "#v/composables/table/useTableColumnPermission";
|
|
3
|
+
import UserTableColumnModal from "./UserTableColumnModal.vue";
|
|
4
|
+
import { ref, h, onMounted } from "vue";
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
const { tables, fetchTables, fetchMergedColumns, saveUserColumns } = useTableColumnPermission();
|
|
9
|
+
const selectedTable = ref(null);
|
|
10
|
+
const mergedColumns = ref([]);
|
|
11
|
+
const editingColumn = ref(null);
|
|
12
|
+
const showColumnModal = ref(false);
|
|
13
|
+
const saving = ref(false);
|
|
14
|
+
async function onTableSelect(table) {
|
|
15
|
+
selectedTable.value = table;
|
|
16
|
+
mergedColumns.value = await fetchMergedColumns(table.tblName ?? "");
|
|
17
|
+
}
|
|
18
|
+
function onEditColumn(column) {
|
|
19
|
+
editingColumn.value = column;
|
|
20
|
+
showColumnModal.value = true;
|
|
21
|
+
}
|
|
22
|
+
async function onColumnSave(config) {
|
|
23
|
+
if (!selectedTable.value) return;
|
|
24
|
+
saving.value = true;
|
|
25
|
+
try {
|
|
26
|
+
await saveUserColumns(selectedTable.value.tblName ?? "", [config]);
|
|
27
|
+
mergedColumns.value = await fetchMergedColumns(selectedTable.value.tblName ?? "");
|
|
28
|
+
showColumnModal.value = false;
|
|
29
|
+
} finally {
|
|
30
|
+
saving.value = false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const columns = [
|
|
34
|
+
{
|
|
35
|
+
accessorKey: "label",
|
|
36
|
+
header: "\u5217\u540D",
|
|
37
|
+
cell: ({ row }) => row.original.label
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
accessorKey: "columnKey",
|
|
41
|
+
header: "\u5217\u6807\u8BC6"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
accessorKey: "width",
|
|
45
|
+
header: "\u5BBD\u5EA6",
|
|
46
|
+
cell: ({ row }) => row.original.width
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
accessorKey: "order",
|
|
50
|
+
header: "\u987A\u5E8F",
|
|
51
|
+
cell: ({ row }) => row.original.order
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
accessorKey: "fixed",
|
|
55
|
+
header: "\u56FA\u5B9A",
|
|
56
|
+
cell: ({ row }) => row.original.fixed || "-"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
accessorKey: "visible",
|
|
60
|
+
header: "\u53EF\u89C1",
|
|
61
|
+
cell: ({ row }) => row.original.visible ? "\u662F" : "\u5426"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
accessorKey: "actions",
|
|
65
|
+
header: "\u64CD\u4F5C",
|
|
66
|
+
cell: ({ row }) => {
|
|
67
|
+
if (!row.original.canEdit) return "-";
|
|
68
|
+
return h("UButton", {
|
|
69
|
+
size: "sm",
|
|
70
|
+
variant: "link",
|
|
71
|
+
label: "\u7F16\u8F91",
|
|
72
|
+
onClick: () => onEditColumn(row.original)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
onMounted(fetchTables);
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<template>
|
|
81
|
+
<div class="flex gap-4 h-full">
|
|
82
|
+
<div class="w-64 border-r pr-4">
|
|
83
|
+
<div class="font-bold mb-2">
|
|
84
|
+
选择 Table
|
|
85
|
+
</div>
|
|
86
|
+
<div
|
|
87
|
+
v-for="table in tables"
|
|
88
|
+
:key="table.id"
|
|
89
|
+
class="p-2 cursor-pointer rounded mb-1"
|
|
90
|
+
:class="{ 'bg-primary text-white': selectedTable?.id === table.id }"
|
|
91
|
+
@click="onTableSelect(table)"
|
|
92
|
+
>
|
|
93
|
+
{{ table.label }} ({{ table.tblName }})
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div class="flex-1">
|
|
98
|
+
<template v-if="selectedTable">
|
|
99
|
+
<div class="font-bold mb-2">
|
|
100
|
+
列配置 - {{ selectedTable.label }}
|
|
101
|
+
</div>
|
|
102
|
+
<UTable :data="mergedColumns" :columns="columns" />
|
|
103
|
+
</template>
|
|
104
|
+
<div v-else class="text-dimmed">
|
|
105
|
+
请选择左侧 Table 查看列配置
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<UserTableColumnModal
|
|
110
|
+
v-if="editingColumn"
|
|
111
|
+
v-model:open="showColumnModal"
|
|
112
|
+
:column="editingColumn"
|
|
113
|
+
:loading="saving"
|
|
114
|
+
@save="onColumnSave"
|
|
115
|
+
@close="showColumnModal = false"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MergedTableColumn, UserTableColumn } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
column: MergedTableColumn;
|
|
4
|
+
open: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
close: () => any;
|
|
9
|
+
"update:open": (args_0: boolean) => any;
|
|
10
|
+
save: (args_0: UserTableColumn) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onClose?: (() => any) | undefined;
|
|
13
|
+
"onUpdate:open"?: ((args_0: boolean) => any) | undefined;
|
|
14
|
+
onSave?: ((args_0: UserTableColumn) => any) | undefined;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import { useAuth } from "#v/composables";
|
|
4
|
+
const { loginUser } = useAuth();
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
column: { type: Object, required: true },
|
|
7
|
+
open: { type: Boolean, required: true },
|
|
8
|
+
loading: { type: Boolean, required: false }
|
|
9
|
+
});
|
|
10
|
+
const emit = defineEmits(["update:open", "close", "save"]);
|
|
11
|
+
const openModel = ref(props.open);
|
|
12
|
+
watch(() => props.open, (val) => {
|
|
13
|
+
openModel.value = val;
|
|
14
|
+
});
|
|
15
|
+
watch(openModel, (val) => {
|
|
16
|
+
if (!val) {
|
|
17
|
+
emit("update:open", false);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const width = ref(props.column.width);
|
|
21
|
+
const order = ref(props.column.order);
|
|
22
|
+
const fixed = ref(props.column.fixed ?? "");
|
|
23
|
+
const visible = ref(props.column.visible);
|
|
24
|
+
watch(() => props.open, (isOpen) => {
|
|
25
|
+
if (isOpen) {
|
|
26
|
+
width.value = props.column.width;
|
|
27
|
+
order.value = props.column.order;
|
|
28
|
+
fixed.value = props.column.fixed ?? "";
|
|
29
|
+
visible.value = props.column.visible;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const fixedOptions = [
|
|
33
|
+
{ label: "\u4E0D\u56FA\u5B9A", value: "" },
|
|
34
|
+
{ label: "\u5DE6\u4FA7\u56FA\u5B9A", value: "left" },
|
|
35
|
+
{ label: "\u53F3\u4FA7\u56FA\u5B9A", value: "right" }
|
|
36
|
+
];
|
|
37
|
+
function handleSave() {
|
|
38
|
+
emit("save", {
|
|
39
|
+
id: props.column.tableColumnId,
|
|
40
|
+
userId: loginUser.value?.id ?? 0,
|
|
41
|
+
tableColumnId: props.column.tableColumnId ?? 0,
|
|
42
|
+
width: width.value,
|
|
43
|
+
order: order.value,
|
|
44
|
+
fixed: fixed.value,
|
|
45
|
+
visible: visible.value
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<UModal
|
|
52
|
+
v-model:open="openModel"
|
|
53
|
+
title="编辑列设置"
|
|
54
|
+
:close="{ onClick: () => emit('close') }"
|
|
55
|
+
>
|
|
56
|
+
<div class="p-4 space-y-4">
|
|
57
|
+
<div class="text-sm text-dimmed mb-2">
|
|
58
|
+
列名: {{ column.label }} ({{ column.columnKey }})
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<UFormField label="宽度">
|
|
62
|
+
<UInputNumber
|
|
63
|
+
v-model="width"
|
|
64
|
+
:min="0"
|
|
65
|
+
class="w-full"
|
|
66
|
+
/>
|
|
67
|
+
</UFormField>
|
|
68
|
+
|
|
69
|
+
<UFormField label="顺序">
|
|
70
|
+
<UInputNumber
|
|
71
|
+
v-model="order"
|
|
72
|
+
:min="0"
|
|
73
|
+
class="w-full"
|
|
74
|
+
/>
|
|
75
|
+
</UFormField>
|
|
76
|
+
|
|
77
|
+
<UFormField label="固定位置">
|
|
78
|
+
<USelect
|
|
79
|
+
v-model="fixed"
|
|
80
|
+
:items="fixedOptions"
|
|
81
|
+
class="w-full"
|
|
82
|
+
/>
|
|
83
|
+
</UFormField>
|
|
84
|
+
|
|
85
|
+
<UFormField label="可见">
|
|
86
|
+
<UCheckbox v-model="visible" label="显示此列" />
|
|
87
|
+
</UFormField>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<template #footer>
|
|
91
|
+
<UButton
|
|
92
|
+
label="取消"
|
|
93
|
+
color="neutral"
|
|
94
|
+
variant="subtle"
|
|
95
|
+
@click="emit('close')"
|
|
96
|
+
/>
|
|
97
|
+
<UButton
|
|
98
|
+
label="保存"
|
|
99
|
+
color="primary"
|
|
100
|
+
variant="solid"
|
|
101
|
+
:loading="loading"
|
|
102
|
+
@click="handleSave"
|
|
103
|
+
/>
|
|
104
|
+
</template>
|
|
105
|
+
</UModal>
|
|
106
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MergedTableColumn, UserTableColumn } from '#v/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
column: MergedTableColumn;
|
|
4
|
+
open: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
|
+
close: () => any;
|
|
9
|
+
"update:open": (args_0: boolean) => any;
|
|
10
|
+
save: (args_0: UserTableColumn) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onClose?: (() => any) | undefined;
|
|
13
|
+
"onUpdate:open"?: ((args_0: boolean) => any) | undefined;
|
|
14
|
+
onSave?: ((args_0: UserTableColumn) => any) | undefined;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -9,3 +9,6 @@ export * from './useMenuApi.js';
|
|
|
9
9
|
export * from './useRoleApi.js';
|
|
10
10
|
export * from './useRowRecord.js';
|
|
11
11
|
export * from './useUserApi.js';
|
|
12
|
+
export * from '../useTableApi.js';
|
|
13
|
+
export * from '../useTableColumnApi.js';
|
|
14
|
+
export * from '../useTablePermissionApi.js';
|
|
@@ -9,3 +9,6 @@ export * from "./useMenuApi.js";
|
|
|
9
9
|
export * from "./useRoleApi.js";
|
|
10
10
|
export * from "./useRowRecord.js";
|
|
11
11
|
export * from "./useUserApi.js";
|
|
12
|
+
export * from "../useTableApi.js";
|
|
13
|
+
export * from "../useTableColumnApi.js";
|
|
14
|
+
export * from "../useTablePermissionApi.js";
|