@liujitcn/kratos-admin-system 0.0.1
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/README.md +137 -0
- package/dist/package/declarations/index.d.ts +1 -0
- package/dist/package/declarations/src/ai.d.ts +10 -0
- package/dist/package/declarations/src/api/base/ai_message.d.ts +27 -0
- package/dist/package/declarations/src/api/base/ai_session.d.ts +17 -0
- package/dist/package/declarations/src/api/base/ai_tool.d.ts +7 -0
- package/dist/package/declarations/src/api/base/oauth.d.ts +13 -0
- package/dist/package/declarations/src/api/base/sse.d.ts +31 -0
- package/dist/package/declarations/src/api/system/auth.d.ts +17 -0
- package/dist/package/declarations/src/api/system/base_api.d.ts +22 -0
- package/dist/package/declarations/src/api/system/base_area.d.ts +19 -0
- package/dist/package/declarations/src/api/system/base_config.d.ts +20 -0
- package/dist/package/declarations/src/api/system/base_dept.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_dict.d.ts +32 -0
- package/dist/package/declarations/src/api/system/base_job.d.ts +28 -0
- package/dist/package/declarations/src/api/system/base_log.d.ts +9 -0
- package/dist/package/declarations/src/api/system/base_menu.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_migration.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_post.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_role.d.ts +23 -0
- package/dist/package/declarations/src/api/system/base_tenant.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_user.d.ts +23 -0
- package/dist/package/declarations/src/api/system/code_gen.d.ts +14 -0
- package/dist/package/declarations/src/api/system/code_gen_column.d.ts +12 -0
- package/dist/package/declarations/src/api/system/code_gen_proto.d.ts +10 -0
- package/dist/package/declarations/src/api/system/code_gen_sse.d.ts +8 -0
- package/dist/package/declarations/src/api/system/code_gen_table.d.ts +18 -0
- package/dist/package/declarations/src/api/system/project_document.d.ts +9 -0
- package/dist/package/declarations/src/components/Ai.vue.d.ts +3 -0
- package/dist/package/declarations/src/index.d.ts +3 -0
- package/dist/package/declarations/src/module.d.ts +2 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_message.d.ts +82 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +176 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +59 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +167 -0
- package/dist/package/declarations/src/rpc/base/v1/sse.d.ts +13 -0
- package/dist/package/declarations/src/rpc/common/v1/common.d.ts +57 -0
- package/dist/package/declarations/src/rpc/common/v1/enum.d.ts +58 -0
- package/dist/package/declarations/src/rpc/common/v1/types.d.ts +60 -0
- package/dist/package/declarations/src/rpc/google/protobuf/empty.d.ts +11 -0
- package/dist/package/declarations/src/rpc/google/protobuf/timestamp.d.ts +107 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +156 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_api.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_area.d.ts +82 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dept.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +215 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +177 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +87 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +151 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_post.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +128 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +161 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +155 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +143 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_proto.d.ts +86 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +149 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/project_document.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +67 -0
- package/dist/package/declarations/src/views/ai/chat/attachment.d.ts +14 -0
- package/dist/package/declarations/src/views/ai/chat/components/AiMarkdown.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/ai/chat/components/ChatPanel.vue.d.ts +45 -0
- package/dist/package/declarations/src/views/ai/chat/components/SessionPanel.vue.d.ts +34 -0
- package/dist/package/declarations/src/views/ai/chat/components/XSender.vue.d.ts +12 -0
- package/dist/package/declarations/src/views/ai/chat/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/ai/chat/message.d.ts +59 -0
- package/dist/package/declarations/src/views/ai/chat/stream.d.ts +10 -0
- package/dist/package/declarations/src/views/ai/chat/types.d.ts +115 -0
- package/dist/package/declarations/src/views/base/api/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/area/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/config/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dept/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/item.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/log.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/menu/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/migration/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/base/post/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/role/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/tenant/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/user/components/dept-tree.vue.d.ts +19 -0
- package/dist/package/declarations/src/views/base/user/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/base.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/profile/components/password.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/security.vue.d.ts +15 -0
- package/dist/package/declarations/src/views/profile/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/api-doc/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/tool/code-gen/code-preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/option-copy.d.ts +25 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenProgressDialog.vue.d.ts +16 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodePreviewPane.vue.d.ts +9 -0
- package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +32 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/capabilities.d.ts +20 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/data.d.ts +42 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/proto/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/table/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/project-doc/index.vue.d.ts +4 -0
- package/dist/package/src/ai.ts +16 -0
- package/dist/package/src/api/base/ai_message.ts +139 -0
- package/dist/package/src/api/base/ai_session.ts +77 -0
- package/dist/package/src/api/base/ai_tool.ts +22 -0
- package/dist/package/src/api/base/oauth.ts +47 -0
- package/dist/package/src/api/base/sse.ts +192 -0
- package/dist/package/src/api/system/auth.ts +65 -0
- package/dist/package/src/api/system/base_api.ts +95 -0
- package/dist/package/src/api/system/base_area.ts +73 -0
- package/dist/package/src/api/system/base_config.ts +82 -0
- package/dist/package/src/api/system/base_dept.ts +83 -0
- package/dist/package/src/api/system/base_dict.ts +144 -0
- package/dist/package/src/api/system/base_job.ts +125 -0
- package/dist/package/src/api/system/base_log.ts +32 -0
- package/dist/package/src/api/system/base_menu.ts +83 -0
- package/dist/package/src/api/system/base_migration.ts +35 -0
- package/dist/package/src/api/system/base_post.ts +83 -0
- package/dist/package/src/api/system/base_role.ts +93 -0
- package/dist/package/src/api/system/base_tenant.ts +83 -0
- package/dist/package/src/api/system/base_user.ts +93 -0
- package/dist/package/src/api/system/code_gen.ts +56 -0
- package/dist/package/src/api/system/code_gen_column.ts +43 -0
- package/dist/package/src/api/system/code_gen_proto.ts +32 -0
- package/dist/package/src/api/system/code_gen_sse.ts +33 -0
- package/dist/package/src/api/system/code_gen_table.ts +74 -0
- package/dist/package/src/api/system/project_document.ts +33 -0
- package/dist/package/src/components/Ai.vue +57 -0
- package/dist/package/src/index.ts +3 -0
- package/dist/package/src/module.ts +17 -0
- package/dist/package/src/rpc/base/v1/ai_message.ts +98 -0
- package/dist/package/src/rpc/base/v1/ai_session.ts +214 -0
- package/dist/package/src/rpc/base/v1/ai_tool.ts +74 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +199 -0
- package/dist/package/src/rpc/base/v1/sse.ts +22 -0
- package/dist/package/src/rpc/common/v1/common.ts +71 -0
- package/dist/package/src/rpc/common/v1/enum.ts +71 -0
- package/dist/package/src/rpc/common/v1/types.ts +77 -0
- package/dist/package/src/rpc/google/protobuf/empty.ts +19 -0
- package/dist/package/src/rpc/google/protobuf/timestamp.ts +115 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +208 -0
- package/dist/package/src/rpc/system/admin/v1/base_api.ts +241 -0
- package/dist/package/src/rpc/system/admin/v1/base_area.ts +105 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dept.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +249 -0
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +206 -0
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +101 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +195 -0
- package/dist/package/src/rpc/system/admin/v1/base_migration.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_post.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_role.ts +151 -0
- package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +190 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +176 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +170 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_proto.ts +104 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +179 -0
- package/dist/package/src/rpc/system/admin/v1/project_document.ts +79 -0
- package/dist/package/src/rpc/system/common/v1/enum.ts +80 -0
- package/dist/package/src/typings/swagger-ui-dist.d.ts +28 -0
- package/dist/package/src/typings/x-markdown-vue.d.ts +1 -0
- package/dist/package/src/views/ai/chat/attachment.ts +65 -0
- package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +162 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +1861 -0
- package/dist/package/src/views/ai/chat/components/SessionPanel.vue +316 -0
- package/dist/package/src/views/ai/chat/components/XSender.vue +554 -0
- package/dist/package/src/views/ai/chat/index.vue +848 -0
- package/dist/package/src/views/ai/chat/message.ts +416 -0
- package/dist/package/src/views/ai/chat/stream.ts +115 -0
- package/dist/package/src/views/ai/chat/types.ts +126 -0
- package/dist/package/src/views/base/api/index.vue +455 -0
- package/dist/package/src/views/base/area/index.vue +269 -0
- package/dist/package/src/views/base/config/index.vue +530 -0
- package/dist/package/src/views/base/dept/index.vue +461 -0
- package/dist/package/src/views/base/dict/index.vue +304 -0
- package/dist/package/src/views/base/dict/item.vue +373 -0
- package/dist/package/src/views/base/job/index.vue +535 -0
- package/dist/package/src/views/base/job/log.vue +202 -0
- package/dist/package/src/views/base/log/index.vue +317 -0
- package/dist/package/src/views/base/menu/index.vue +944 -0
- package/dist/package/src/views/base/migration/index.vue +791 -0
- package/dist/package/src/views/base/post/index.vue +324 -0
- package/dist/package/src/views/base/role/index.vue +684 -0
- package/dist/package/src/views/base/tenant/index.vue +328 -0
- package/dist/package/src/views/base/user/components/dept-tree.vue +75 -0
- package/dist/package/src/views/base/user/index.vue +783 -0
- package/dist/package/src/views/profile/components/base.vue +320 -0
- package/dist/package/src/views/profile/components/password.vue +269 -0
- package/dist/package/src/views/profile/components/security.vue +443 -0
- package/dist/package/src/views/profile/index.vue +199 -0
- package/dist/package/src/views/tool/api-doc/index.vue +275 -0
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +233 -0
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1456 -0
- package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +125 -0
- package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +328 -0
- package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +42 -0
- package/dist/package/src/views/tool/code-gen/config.ts +175 -0
- package/dist/package/src/views/tool/code-gen/preview/capabilities.ts +34 -0
- package/dist/package/src/views/tool/code-gen/preview/data.ts +331 -0
- package/dist/package/src/views/tool/code-gen/preview/index.vue +831 -0
- package/dist/package/src/views/tool/code-gen/proto/index.vue +703 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +864 -0
- package/dist/package/src/views/tool/project-doc/index.vue +561 -0
- package/package.json +60 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
<!-- 租户管理 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="table-box">
|
|
4
|
+
<ProTable
|
|
5
|
+
ref="proTable"
|
|
6
|
+
row-key="id"
|
|
7
|
+
:columns="columns"
|
|
8
|
+
:header-actions="headerActions"
|
|
9
|
+
:request-api="requestBaseTenantTable"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<FormDialog
|
|
13
|
+
v-model="dialog.visible"
|
|
14
|
+
ref="formDialogRef"
|
|
15
|
+
:title="dialog.title"
|
|
16
|
+
width="780px"
|
|
17
|
+
:model="formData"
|
|
18
|
+
:fields="formFields"
|
|
19
|
+
:rules="rules"
|
|
20
|
+
label-width="100px"
|
|
21
|
+
@confirm="handleSubmit"
|
|
22
|
+
@close="handleCloseDialog"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { reactive, ref } from "vue";
|
|
29
|
+
import { ElMessage, ElMessageBox } from "element-plus";
|
|
30
|
+
import { CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
|
|
31
|
+
import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
32
|
+
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
33
|
+
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
34
|
+
import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
35
|
+
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
36
|
+
import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/base_tenant";
|
|
37
|
+
import type { BaseTenant, BaseTenantForm, PageBaseTenantRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_tenant";
|
|
38
|
+
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
39
|
+
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
40
|
+
|
|
41
|
+
defineOptions({
|
|
42
|
+
name: "BaseTenant",
|
|
43
|
+
inheritAttrs: false
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const { BUTTONS } = useAuthButtons();
|
|
47
|
+
const proTable = ref<ProTableInstance>();
|
|
48
|
+
const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
49
|
+
|
|
50
|
+
const dialog = reactive({
|
|
51
|
+
title: "",
|
|
52
|
+
visible: false
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const formData = reactive<BaseTenantForm>({
|
|
56
|
+
/** 租户ID */
|
|
57
|
+
id: 0,
|
|
58
|
+
/** 租户编号 */
|
|
59
|
+
code: "",
|
|
60
|
+
/** 租户名称 */
|
|
61
|
+
name: "",
|
|
62
|
+
/** 联系人 */
|
|
63
|
+
contact_name: "",
|
|
64
|
+
/** 联系电话 */
|
|
65
|
+
contact_phone: "",
|
|
66
|
+
/** 状态 */
|
|
67
|
+
status: Status.ENABLE,
|
|
68
|
+
/** 备注 */
|
|
69
|
+
remark: ""
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/** 租户表单校验规则。 */
|
|
73
|
+
const rules = reactive({
|
|
74
|
+
name: [
|
|
75
|
+
{ required: true, message: "请输入租户名称", trigger: "blur" },
|
|
76
|
+
{ max: 100, message: "租户名称不能超过 100 个字符", trigger: "blur" }
|
|
77
|
+
],
|
|
78
|
+
contact_name: [{ max: 50, message: "联系人不能超过 50 个字符", trigger: "blur" }],
|
|
79
|
+
contact_phone: [
|
|
80
|
+
{ max: 20, message: "联系电话不能超过 20 个字符", trigger: "blur" },
|
|
81
|
+
{ pattern: /^1[3-9]\d{9}$/, message: "请输入正确的联系电话", trigger: "blur" }
|
|
82
|
+
],
|
|
83
|
+
status: [{ required: true, message: "请选择状态", trigger: "change" }],
|
|
84
|
+
remark: [{ max: 500, message: "备注不能超过 500 个字符", trigger: "blur" }]
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const statusOptions: ProFormOption[] = [
|
|
88
|
+
{ label: "启用", value: Status.ENABLE },
|
|
89
|
+
{ label: "禁用", value: Status.DISABLE }
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/** 租户表单字段配置。 */
|
|
93
|
+
const formFields: ProFormField[] = [
|
|
94
|
+
{
|
|
95
|
+
prop: "code",
|
|
96
|
+
label: "租户编号",
|
|
97
|
+
component: "input",
|
|
98
|
+
props: { disabled: true },
|
|
99
|
+
visible: model => Boolean(model.id)
|
|
100
|
+
},
|
|
101
|
+
{ prop: "name", label: "租户名称", component: "input", props: { placeholder: "请输入租户名称" } },
|
|
102
|
+
{ prop: "contact_name", label: "联系人", component: "input", props: { placeholder: "请输入联系人" } },
|
|
103
|
+
{ prop: "contact_phone", label: "联系电话", component: "input", props: { placeholder: "请输入联系电话" } },
|
|
104
|
+
{ prop: "status", label: "状态", component: "radio-group", options: statusOptions },
|
|
105
|
+
{ prop: "remark", label: "备注", component: "textarea", props: { placeholder: "请输入备注", rows: 3 }, colSpan: 24 }
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
/** 租户表格列配置。 */
|
|
109
|
+
const columns: ColumnProps[] = [
|
|
110
|
+
{ type: "selection", width: 55, selectable: row => !isProtectedManagementTenant(row as BaseTenant) },
|
|
111
|
+
{ prop: "code", label: "租户编号", minWidth: 140, search: { el: "input", order: 1 } },
|
|
112
|
+
{ prop: "name", label: "租户名称", minWidth: 160, search: { el: "input", order: 2 } },
|
|
113
|
+
{ prop: "contact_name", label: "联系人", minWidth: 120 },
|
|
114
|
+
{ prop: "contact_phone", label: "联系电话", minWidth: 140 },
|
|
115
|
+
{
|
|
116
|
+
prop: "status",
|
|
117
|
+
label: "状态",
|
|
118
|
+
minWidth: 100,
|
|
119
|
+
search: { el: "select" },
|
|
120
|
+
cellType: "status",
|
|
121
|
+
statusProps: {
|
|
122
|
+
activeValue: Status.ENABLE,
|
|
123
|
+
inactiveValue: Status.DISABLE,
|
|
124
|
+
activeText: "启用",
|
|
125
|
+
inactiveText: "禁用",
|
|
126
|
+
disabled: scope => isProtectedManagementTenant(scope.row as BaseTenant) || !BUTTONS.value["base:tenant:status"],
|
|
127
|
+
beforeChange: scope => handleBeforeSetStatus(scope.row as BaseTenant)
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{ prop: "created_at", label: "创建时间", minWidth: 180 },
|
|
131
|
+
{ prop: "updated_at", label: "更新时间", minWidth: 180 },
|
|
132
|
+
{
|
|
133
|
+
prop: "operation",
|
|
134
|
+
label: "操作",
|
|
135
|
+
width: 150,
|
|
136
|
+
fixed: "right",
|
|
137
|
+
cellType: "actions",
|
|
138
|
+
actions: [
|
|
139
|
+
{
|
|
140
|
+
label: "编辑",
|
|
141
|
+
type: "primary",
|
|
142
|
+
link: true,
|
|
143
|
+
icon: EditPen,
|
|
144
|
+
hidden: scope => isProtectedManagementTenant(scope.row as BaseTenant) || !BUTTONS.value["base:tenant:update"],
|
|
145
|
+
params: scope => ({ tenantId: scope.row.id }),
|
|
146
|
+
onClick: (scope, params) => handleOpenDialog((params?.tenantId as number | undefined) ?? (scope.row as BaseTenant).id)
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
label: "删除",
|
|
150
|
+
type: "danger",
|
|
151
|
+
link: true,
|
|
152
|
+
icon: Delete,
|
|
153
|
+
hidden: scope => isProtectedManagementTenant(scope.row as BaseTenant) || !BUTTONS.value["base:tenant:delete"],
|
|
154
|
+
onClick: scope => handleDelete(scope.row as BaseTenant)
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
/** 租户顶部按钮配置。 */
|
|
161
|
+
const headerActions: HeaderActionProps[] = [
|
|
162
|
+
{
|
|
163
|
+
label: "新增",
|
|
164
|
+
type: "success",
|
|
165
|
+
icon: CirclePlus,
|
|
166
|
+
hidden: () => !BUTTONS.value["base:tenant:create"],
|
|
167
|
+
onClick: () => handleOpenDialog()
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: "删除",
|
|
171
|
+
type: "danger",
|
|
172
|
+
icon: Delete,
|
|
173
|
+
hidden: () => !BUTTONS.value["base:tenant:delete"],
|
|
174
|
+
disabled: scope => !scope.selectedList.length,
|
|
175
|
+
onClick: scope => handleDelete(scope.selectedList as BaseTenant[])
|
|
176
|
+
}
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 请求租户列表,并由 ProTable 统一维护分页与搜索参数。
|
|
181
|
+
*/
|
|
182
|
+
async function requestBaseTenantTable(params: PageBaseTenantRequest) {
|
|
183
|
+
const data = await defBaseTenantService.PageBaseTenant(buildPageRequest(params));
|
|
184
|
+
return { data: { list: data.base_tenants ?? [], total: data.total } };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 刷新租户表格。
|
|
189
|
+
*/
|
|
190
|
+
function refreshTable() {
|
|
191
|
+
proTable.value?.getTableList();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 根据后端管理保护标记判断租户是否禁止通过租户管理操作。
|
|
196
|
+
*/
|
|
197
|
+
function isProtectedManagementTenant(row?: BaseTenant) {
|
|
198
|
+
return Boolean(row?.is_protected);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 打开租户弹窗,并按新增或编辑场景回填表单数据。
|
|
203
|
+
*/
|
|
204
|
+
async function handleOpenDialog(tenantId?: number) {
|
|
205
|
+
resetForm();
|
|
206
|
+
dialog.title = tenantId ? "修改租户" : "新增租户";
|
|
207
|
+
dialog.visible = true;
|
|
208
|
+
if (!tenantId) return;
|
|
209
|
+
|
|
210
|
+
const data = await defBaseTenantService.GetBaseTenant({ id: tenantId });
|
|
211
|
+
Object.assign(formData, data);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 关闭租户弹窗并恢复默认表单值。
|
|
216
|
+
*/
|
|
217
|
+
function handleCloseDialog() {
|
|
218
|
+
dialog.visible = false;
|
|
219
|
+
resetForm();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 重置租户表单,避免新增时保留旧值。
|
|
224
|
+
*/
|
|
225
|
+
function resetForm() {
|
|
226
|
+
formDialogRef.value?.resetFields();
|
|
227
|
+
formDialogRef.value?.clearValidate();
|
|
228
|
+
formData.id = 0;
|
|
229
|
+
formData.code = "";
|
|
230
|
+
formData.name = "";
|
|
231
|
+
formData.contact_name = "";
|
|
232
|
+
formData.contact_phone = "";
|
|
233
|
+
formData.status = Status.ENABLE;
|
|
234
|
+
formData.remark = "";
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 提交租户表单。
|
|
239
|
+
*/
|
|
240
|
+
function handleSubmit() {
|
|
241
|
+
formDialogRef.value?.validate()?.then(valid => {
|
|
242
|
+
if (!valid) return;
|
|
243
|
+
|
|
244
|
+
const submitData = JSON.parse(JSON.stringify(formData)) as BaseTenantForm;
|
|
245
|
+
const request = submitData.id
|
|
246
|
+
? defBaseTenantService.UpdateBaseTenant({ base_tenant: submitData })
|
|
247
|
+
: defBaseTenantService.CreateBaseTenant({ base_tenant: submitData });
|
|
248
|
+
request.then(() => {
|
|
249
|
+
ElMessage.success(submitData.id ? "修改租户成功" : "新增租户成功");
|
|
250
|
+
handleCloseDialog();
|
|
251
|
+
refreshTable();
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 在租户状态切换前先完成确认与接口调用。
|
|
258
|
+
*/
|
|
259
|
+
async function handleBeforeSetStatus(row: BaseTenant) {
|
|
260
|
+
if (isProtectedManagementTenant(row)) {
|
|
261
|
+
ElMessage.warning("默认租户不能修改状态");
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const nextStatus = row.status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
266
|
+
const text = nextStatus === Status.ENABLE ? "启用" : "禁用";
|
|
267
|
+
try {
|
|
268
|
+
await ElMessageBox.confirm(`是否确定${text}租户?\n租户名称:${row.name || `ID:${row.id}`}`, "提示", {
|
|
269
|
+
confirmButtonText: "确认",
|
|
270
|
+
cancelButtonText: "取消",
|
|
271
|
+
type: "warning"
|
|
272
|
+
});
|
|
273
|
+
await defBaseTenantService.SetBaseTenantStatus({ id: row.id, status: nextStatus });
|
|
274
|
+
ElMessage.success(`${text}成功`);
|
|
275
|
+
refreshTable();
|
|
276
|
+
return true;
|
|
277
|
+
} catch {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 删除租户,兼容单项删除与多选删除。
|
|
284
|
+
*/
|
|
285
|
+
function handleDelete(selected?: number | string | Array<number | string> | BaseTenant | BaseTenant[]) {
|
|
286
|
+
const tenantList = Array.isArray(selected)
|
|
287
|
+
? (selected.filter(item => typeof item === "object") as BaseTenant[])
|
|
288
|
+
: selected && typeof selected === "object"
|
|
289
|
+
? [selected as BaseTenant]
|
|
290
|
+
: [];
|
|
291
|
+
if (tenantList.some(isProtectedManagementTenant)) {
|
|
292
|
+
ElMessage.warning("默认租户不能删除");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const tenantIds = (
|
|
297
|
+
tenantList.length
|
|
298
|
+
? tenantList.map(item => item.id)
|
|
299
|
+
: normalizeSelectedIds(selected as number | string | Array<number | string>)
|
|
300
|
+
).join(",");
|
|
301
|
+
if (!tenantIds) {
|
|
302
|
+
ElMessage.warning("请勾选删除项");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const confirmMessage = tenantList.length
|
|
307
|
+
? tenantList.length === 1
|
|
308
|
+
? `是否确定删除租户?\n租户名称:${tenantList[0].name || `ID:${tenantList[0].id}`}`
|
|
309
|
+
: `确认删除已选中的 ${tenantList.length} 项租户吗?`
|
|
310
|
+
: "确认删除已选中的租户吗?";
|
|
311
|
+
|
|
312
|
+
ElMessageBox.confirm(confirmMessage, "警告", {
|
|
313
|
+
confirmButtonText: "确定",
|
|
314
|
+
cancelButtonText: "取消",
|
|
315
|
+
type: "warning"
|
|
316
|
+
}).then(
|
|
317
|
+
() => {
|
|
318
|
+
defBaseTenantService.DeleteBaseTenant({ id: tenantIds }).then(() => {
|
|
319
|
+
ElMessage.success("删除租户成功");
|
|
320
|
+
refreshTable();
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
() => {
|
|
324
|
+
ElMessage.info("已取消删除租户");
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
</script>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- 部门树 -->
|
|
2
|
+
<template>
|
|
3
|
+
<el-card shadow="never">
|
|
4
|
+
<el-input v-model="name" placeholder="部门名称" clearable>
|
|
5
|
+
<template #prefix>
|
|
6
|
+
<el-icon><Search /></el-icon>
|
|
7
|
+
</template>
|
|
8
|
+
</el-input>
|
|
9
|
+
|
|
10
|
+
<el-tree
|
|
11
|
+
ref="baseDeptTreeRef"
|
|
12
|
+
class="mt-2"
|
|
13
|
+
:data="baseDeptList"
|
|
14
|
+
:props="{ children: 'children', label: 'label', disabled: '' }"
|
|
15
|
+
:expand-on-click-node="false"
|
|
16
|
+
:filter-node-method="handleFilter"
|
|
17
|
+
default-expand-all
|
|
18
|
+
highlight-current
|
|
19
|
+
@node-click="handleNodeClick"
|
|
20
|
+
/>
|
|
21
|
+
</el-card>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { onBeforeMount, ref, watchEffect } from "vue";
|
|
26
|
+
import { useVModel } from "@vueuse/core";
|
|
27
|
+
import { ElTree } from "element-plus";
|
|
28
|
+
import { defBaseDeptService } from "@liujitcn/kratos-admin-system/api/system/base_dept";
|
|
29
|
+
import { TreeOptionResponse_Option } from "@liujitcn/kratos-admin-system/rpc/common/v1/common";
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
modelValue: {
|
|
32
|
+
type: [Number],
|
|
33
|
+
default: undefined
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const baseDeptList = ref<TreeOptionResponse_Option[]>(); // 部门列表
|
|
38
|
+
const baseDeptTreeRef = ref<InstanceType<typeof ElTree>>(); // 部门树
|
|
39
|
+
const name = ref(); // 部门名称
|
|
40
|
+
|
|
41
|
+
const emits = defineEmits(["nodeClick"]);
|
|
42
|
+
|
|
43
|
+
const baseDeptId = useVModel(props, "modelValue", emits);
|
|
44
|
+
|
|
45
|
+
watchEffect(
|
|
46
|
+
() => {
|
|
47
|
+
baseDeptTreeRef.value?.filter(name.value);
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
flush: "post" // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 部门筛选
|
|
56
|
+
*/
|
|
57
|
+
function handleFilter(value: string, data: any) {
|
|
58
|
+
if (!value) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return data.label.indexOf(value) !== -1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 部门树节点 Click */
|
|
65
|
+
function handleNodeClick(data: { [key: string]: any }) {
|
|
66
|
+
baseDeptId.value = data.value;
|
|
67
|
+
emits("nodeClick");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onBeforeMount(() => {
|
|
71
|
+
defBaseDeptService.OptionBaseDept({}).then(response => {
|
|
72
|
+
baseDeptList.value = response.list;
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
</script>
|