Bladeren bron

修复用户默认展开一级部门树

zhangchong 2 jaren geleden
bovenliggende
commit
3685da1988
1 gewijzigde bestanden met toevoegingen van 11 en 11 verwijderingen
  1. 11 11
      src/views/system/user/index.vue

+ 11 - 11
src/views/system/user/index.vue

@@ -105,7 +105,7 @@
 </template>
 
 <script lang="ts" setup name="systemUser">
-import { defineAsyncComponent, ref, reactive, onMounted, watch,onActivated } from 'vue';
+import { defineAsyncComponent, ref, reactive, onMounted, watch, onActivated } from 'vue';
 import { ElMessageBox, ElMessage } from 'element-plus';
 import type { FormInstance } from 'element-plus';
 import table2excel from 'js-table2excel';
@@ -138,7 +138,7 @@ const state = reactive<any>({
 	multipleSelection: [],
 	orgData: [],
 	options: [],
-	defaultExpandedKeys:[]
+	defaultExpandedKeys: [],
 });
 const ruleFormRef = ref<FormInstance>(); //表单ref
 const addUserRef = ref(); //新增用户
@@ -170,12 +170,12 @@ const getOrgListApi = () => {
 	getOrgList()
 		.then((res: any) => {
 			state.orgData = res?.result ?? [];
-			state.defaultExpandedKeys = state.orgData.map((v:any)=>{
-				return v.children.map((i:any)=>{
-					return i.orgCode
-				})
-			})
-			state.defaultExpandedKeys.push(state.orgData[0].orgCode) //默认展开一级部门
+			state.defaultExpandedKeys = state.orgData.map((v: any) => {
+				return v.children.map((i: any) => {
+					return i.orgCode;
+				});
+			});
+			state.defaultExpandedKeys.push(state.orgData[0].orgCode); //默认展开一级部门
 			state.loading = false;
 		})
 		.catch(() => {
@@ -200,7 +200,7 @@ const getList = () => {
 const getRolesFn = () => {
 	getRoles({ PageIndex: 1, PageSize: 999 }).then((res: any) => {
 		state.options = res?.result.items ?? [];
-		state.options = state.options.map((item) => ({
+		state.options = state.options.map((item: any) => ({
 			value: item.id,
 			label: item.displayName,
 		}));
@@ -296,11 +296,11 @@ onMounted(() => {
 	getList();
 	getOrgListApi();
 });
-onActivated(()=>{
+onActivated(() => {
 	getRolesFn();
 	getList();
 	getOrgListApi();
-})
+});
 </script>
 <style lang="scss" scoped>
 .system-user-container {