ソースを参照

fix: 超级管理员在指定租户下新增机构、用户操作显示了全部租户的数据问题

喵你个旺呀 1 年間 前
コミット
d0a1ec1060

+ 5 - 0
Admin.NET/Admin.NET.Core/Service/Role/Dto/RoleOutput.cs

@@ -25,4 +25,9 @@ public class RoleOutput
     /// 编码
     /// </summary>
     public string Code { get; set; }
+
+    /// <summary>
+    /// 租户Id
+    /// </summary>
+    public long tenantId { get; set; }
 }

+ 6 - 0
Web/src/api-services/models/role-output.ts

@@ -35,4 +35,10 @@ export interface RoleOutput {
      * @memberof RoleOutput
      */
     code?: string | null;
+    /**
+     * 租户Id
+     * @type {number}
+     * @memberof RoleOutput
+     */
+    tenantId?: number;
 }

+ 4 - 4
Web/src/api-services/models/update-tenant-input.ts

@@ -226,15 +226,15 @@ export interface UpdateTenantInput {
      */
     icpUrl: string;
     /**
-     * Logo文件名
+     * Logo图片Base64码
      * @type {string}
      * @memberof UpdateTenantInput
      */
-    logoFileName?: string | null;
+    logoBase64?: string | null;
     /**
-     * Logo图片Base64码
+     * Logo文件名
      * @type {string}
      * @memberof UpdateTenantInput
      */
-    logoBase64?: string | null;
+    logoFileName?: string | null;
 }

+ 3 - 1
Web/src/views/system/org/component/editOrg.vue

@@ -11,7 +11,7 @@
 				<el-row :gutter="35">
 					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
 						<el-form-item label="上级机构">
-							<el-cascader :options="props.orgData" :props="cascaderProps" placeholder="请选择上级机构" clearable filterable class="w100" v-model="state.ruleForm.pid">
+							<el-cascader :options="state.orgData" :props="cascaderProps" placeholder="请选择上级机构" clearable filterable class="w100" v-model="state.ruleForm.pid">
 								<template #default="{ node, data }">
 									<span>{{ data.name }}</span>
 									<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
@@ -83,6 +83,7 @@ const emits = defineEmits(['reload']);
 const ruleFormRef = ref();
 const state = reactive({
 	isShowDialog: false,
+	orgData: [] as Array<SysOrg>,
 	ruleForm: {} as UpdateOrgInput,
 	orgTypeList: [] as any,
 });
@@ -91,6 +92,7 @@ const cascaderProps = { checkStrictly: true, emitPath: false, value: 'id', label
 
 // 打开弹窗
 const openDialog = (row: any) => {
+	state.orgData = (row?.tenantId ? props.orgData?.filter((e) => e.tenantId === row.tenantId) : props.orgData) ?? [];
 	state.ruleForm = JSON.parse(JSON.stringify(row));
 	state.isShowDialog = true;
 	ruleFormRef.value?.resetFields();

+ 1 - 1
Web/src/views/system/org/component/orgTree.vue

@@ -137,7 +137,7 @@ const handleCommand = async (command: string | number | object) => {
 // 与父组件的交互逻辑
 const emits = defineEmits(['node-click']);
 const nodeClick = (node: any) => {
-	emits('node-click', { id: node.id, name: node.name });
+	emits('node-click', node);
 };
 
 // 导出对象

+ 4 - 1
Web/src/views/system/org/index.vue

@@ -90,6 +90,7 @@ const state = reactive({
 		code: undefined,
 		type: undefined,
 	},
+	tenantId: undefined,
 	editOrgTitle: ''
 });
 
@@ -128,7 +129,7 @@ const resetQuery = () => {
 // 打开新增页面
 const openAddOrg = () => {
 	state.editOrgTitle = '添加机构';
-	editOrgRef.value?.openDialog({ status: 1, tenantId: state.queryParams.tenantId, orderNo: 100 });
+	editOrgRef.value?.openDialog({ status: 1, orderNo: 100, tenantId: state.tenantId });
 };
 
 // 打开编辑页面
@@ -167,6 +168,8 @@ const nodeClick = async (node: any) => {
 	state.queryParams.name = undefined;
 	state.queryParams.code = undefined;
 	state.queryParams.type = undefined;
+	state.tenantId = node.tenantId;
+	console.log(node)
 	handleQuery();
 };
 </script>

+ 5 - 2
Web/src/views/system/user/component/editUser.vue

@@ -56,7 +56,7 @@
 							</el-divider>
 							<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 								<el-form-item label="所属机构" prop="orgId" :rules="[{ required: true, message: '所属机构不能为空', trigger: 'blur' }]">
-									<el-cascader :options="props.orgData" :props="cascaderProps" placeholder="所属机构" clearable filterable class="w100" v-model="state.ruleForm.orgId">
+									<el-cascader :options="state.orgData" :props="cascaderProps" placeholder="所属机构" clearable filterable class="w100" v-model="state.ruleForm.orgId">
 										<template #default="{ node, data }">
 											<span>{{ data.name }}</span>
 											<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
@@ -239,6 +239,7 @@ const state = reactive({
 	loading: false,
 	isShowDialog: false,
 	selectedTabName: '0', // 选中的 tab 页
+	orgData: [] as Array<SysOrg>,
 	ruleForm: {} as UpdateUserInput,
 	posData: [] as Array<SysPos>, // 职位数据
 	roleData: [] as Array<RoleOutput>, // 角色数据
@@ -257,8 +258,10 @@ onMounted(async () => {
 
 // 打开弹窗
 const openDialog = async (row: any) => {
+	state.orgData = (row.tenantId ? props.orgData?.filter((e) => e.tenantId === row.tenantId) : props.orgData) ?? [];
+	state.posData = (row.tenantId ? state.posData?.filter((e) => e.tenantId === row.tenantId) : state.posData) ?? [];
+	state.roleData = (row.tenantId ? state.roleData?.filter((e) => e.tenantId === row.tenantId) : state.roleData) ?? [];
 	ruleFormRef.value?.resetFields();
-
 	state.selectedTabName = '0'; // 重置为第一个 tab 页
 	state.ruleForm = JSON.parse(JSON.stringify(row));
 	if (row.id != undefined) {

+ 4 - 3
Web/src/views/system/user/index.vue

@@ -134,9 +134,9 @@ const state = reactive({
 		account: undefined,
 		realName: undefined,
 		phone: undefined,
-		posName: undefined,
-		tenantId: undefined,
+		posName: undefined
 	},
+	tenantId: undefined,
 	tableParams: {
 		page: 1,
 		pageSize: 50,
@@ -181,7 +181,7 @@ const resetQuery = async () => {
 // 打开新增页面
 const openAddUser = () => {
 	state.editUserTitle = '添加账号';
-	editUserRef.value?.openDialog({ id: undefined, birthday: '2000-01-01', sex: 1, tenantId: state.queryParams.tenantId, orderNo: 100, cardType: 0, cultureLevel: 5 });
+	editUserRef.value?.openDialog({ id: undefined, birthday: '2000-01-01', sex: 1, tenantId: state.tenantId, orderNo: 100, cardType: 0, cultureLevel: 5 });
 };
 
 // 打开编辑页面
@@ -278,6 +278,7 @@ const nodeClick = async (node: any) => {
 	state.queryParams.account = undefined;
 	state.queryParams.realName = undefined;
 	state.queryParams.phone = undefined;
+	state.tenantId = node.tenantId;
 	await handleQuery();
 };
 </script>