Bläddra i källkod

fix: 选择租户改为多选

qindao 1 år sedan
förälder
incheckning
5b0bf5048e

+ 20 - 12
src/layout/components/Header/SwitchTenant.vue

@@ -1,30 +1,30 @@
 <!-- 切换租户 -->
 <template>
-  <div class="switchTenantLable" v-if="options.length > 0">
+  <div class="switchTenantLable-wrapper" v-if="options.length > 0">
     <div class="switchTenantLable">选择租户</div>
-    <ElSelect
+    <el-tree-select
       v-model="currentTenant"
-      :placeholder="tenantName"
-      style="width: 100px"
+      :data="options"
+      clearable
+      check-strictly
+      placeholder="请选择租户"
       @update:modelValue="handleChange"
-    >
-      <ElOption v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
-    </ElSelect>
+    />
   </div>
 </template>
 <script lang="ts" setup>
-  import { ElSelect } from 'element-plus';
   import { ref, computed, onMounted } from 'vue';
   import { useUserStore } from '@/store/modules/user';
-  import { getListUseZongbu, queryListTenant} from '@/api/tenant';
+  import { queryListTenant} from '@/api/tenant';
   import { useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
-
+  import { replaceParams } from '@/utils/helper/treeHelper';
+  
   interface TenantOption {
     label: string;
     value: string;
   }
 
-  const { setValue, getValue, isSysTenant } = useTargetTenantIdSetting();
+  const { setValue, getValue } = useTargetTenantIdSetting();
 
   const localTId = getValue();
 
@@ -41,7 +41,7 @@
   onMounted(() => {
     queryListTenant().then((res) => {
       if (!res) return;
-      options.value = res.map((x) => ({ ...x, label: x.tenantName, value: x.id }));
+      options.value = replaceParams(res || [], 'tenantName', 'id')
     });
   });
 
@@ -55,8 +55,16 @@
   .switchTenantLable {
     margin-right: 15px;
     display: inline-block;
+    width: 100px;
   }
   .switchTenantWrapper {
     margin-right: 20px;
   }
+
+  .switchTenantLable-wrapper {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    width: 200px;
+  }
 </style>

+ 1 - 1
src/types/dept/type.ts

@@ -19,4 +19,4 @@ export type DeptTree = DeptTreeItem & { children: DeptTreeItem[] }
 
 export type addDeptProps = Pick<DeptTreeItem, 'isDisabled' | 'parentId' | 'deptName' | 'orderNum'>
 
-export type editDeptProps = addDeptProps & {id: DeptTreeItem['id']}
+export type editDeptProps = addDeptProps & {id?: DeptTreeItem['id']}

+ 2 - 21
src/views/auth/dept/CreateDrawer.vue

@@ -40,7 +40,7 @@
   import { ref, computed, watch } from 'vue';
   import { ElMessage } from 'element-plus';
   import type { editDeptProps } from '@/types/dept/type';
-  import { deptInfo, updateDepartments, saveDept } from '@/api/auth/dept';
+  import { updateDepartments, saveDept } from '@/api/auth/dept';
   import { replaceParams } from '@/utils/helper/treeHelper';
   import { IS_DISABLED } from '@/types/common/constants';
   import { DeptTreeItem } from '@/types/dept/type';
@@ -88,12 +88,7 @@
 
   const formParams = ref<editDeptProps>(defaultValueRef());
 
-  function openDrawer(id?) {
-    if (id) {
-      formParams.value.id = id;
-      getInfo();
-      return;
-    }
+  function openDrawer() {
     isDrawer.value = true;
   }
 
@@ -133,20 +128,6 @@
     formParams.value = Object.assign(formParams.value, defaultValueRef());
   }
 
-  function getInfo() {
-    deptInfo({ id: formParams.value.id }).then((res) => {
-      const params = {
-        id: res.id,
-        parentId: res.parentId,
-        isDisabled: res.isDisabled,
-        deptName: res.deptName,
-        orderNum: res.orderNum,
-      };
-      formParams.value = Object.assign(formParams.value, params);
-      isDrawer.value = true;
-    });
-  }
-
   watch(
     () => props.dataSource,
     (value) => {