瀏覽代碼

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

zhangchong 2 年之前
父節點
當前提交
330c1d770c
共有 2 個文件被更改,包括 15 次插入28 次删除
  1. 1 1
      src/views/system/user/component/setRole.vue
  2. 14 27
      src/views/system/user/index.vue

+ 1 - 1
src/views/system/user/component/setRole.vue

@@ -1,6 +1,6 @@
 <template>
 	<div class="system-add-user-container">
-		<el-dialog v-model="state.isShowDialog" width="500px" draggable title="设置角色">
+		<el-dialog v-model="state.isShowDialog" width="500px" draggable :title="`(${state.currentRow.name})设置角色`">
 			<el-form :model="state.ruleForm" label-width="90px" ref="ruleFormRef">
 				<el-row :gutter="35">
 					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">

+ 14 - 27
src/views/system/user/index.vue

@@ -12,14 +12,14 @@
 									:data="state.orgData"
 									highlight-current
 									:expand-on-click-node="false"
-									default-expand-all
 									:props="{ children: 'children', label: 'orgName' }"
 									@node-click="handleNodeClick"
 									ref="treRef"
 									v-loading="state.loading"
-									node-key="id"
+									node-key="orgCode"
 									style="min-width: 100%; display: inline-block"
 									:filter-node-method="filterNodeOrg"
+									:default-expanded-keys="state.defaultExpandedKeys"
 								>
 								</el-tree>
 							</template>
@@ -61,10 +61,10 @@
 								<el-table-column type="selection" width="55" :reserve-selection="true" />
 								<el-table-column type="index" width="60" label="序号" />
 								<el-table-column prop="name" label="用户名" show-overflow-tooltip width="150"></el-table-column>
-								<el-table-column prop="userName" label="账号" show-overflow-tooltip width="150"></el-table-column>
+								<el-table-column prop="userName" label="登录账号" show-overflow-tooltip width="150"></el-table-column>
 								<el-table-column prop="orgName" label="所属部门" show-overflow-tooltip width="190"></el-table-column>
 								<el-table-column prop="roles" label="角色" show-overflow-tooltip width="300"></el-table-column>
-								<el-table-column prop="phoneNo" label="电话号码" show-overflow-tooltip width="130"></el-table-column>
+								<el-table-column prop="phoneNo" label="手机号" show-overflow-tooltip width="130"></el-table-column>
 								<el-table-column prop="staffNo" label="工号" show-overflow-tooltip width="80"></el-table-column>
 								<el-table-column prop="genderText" label="性别" show-overflow-tooltip width="80"></el-table-column>
 								<el-table-column prop="creationTime" label="更新时间" show-overflow-tooltip width="170">
@@ -122,28 +122,8 @@ const AddUer = defineAsyncComponent(() => import('/@/views/system/user/component
 const EditUser = defineAsyncComponent(() => import('/@/views/system/user/component/editUser.vue'));
 const SetRole = defineAsyncComponent(() => import('/@/views/system/user/component/setRole.vue'));
 
-// 定义接口来定义对象的类型
-interface QueryState {
-	queryParams: {
-		PageIndex: number;
-		PageSize: number;
-		PhoneNo?: string;
-		Name?: string;
-		Keyword?: string;
-		OrgCode?: string | null;
-		Role?: string | null;
-	};
-	tableData: Array<any>;
-	total: number;
-	tableLoading: boolean;
-	loading: boolean;
-	multipleSelection: Array<any>;
-	orgData: Array<any>;
-	options: Array<any>;
-}
-
 // 定义变量内容
-const state = reactive<QueryState>({
+const state = reactive<any>({
 	queryParams: {
 		PageIndex: 1,
 		PageSize: 10,
@@ -158,6 +138,7 @@ const state = reactive<QueryState>({
 	multipleSelection: [],
 	orgData: [],
 	options: [],
+	defaultExpandedKeys:[]
 });
 const ruleFormRef = ref<FormInstance>(); //表单ref
 const addUserRef = ref(); //新增用户
@@ -189,6 +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.loading = false;
 		})
 		.catch(() => {
@@ -290,10 +277,10 @@ const onRowDel = (row: any) => {
 const onImportTable = () => {
 	const tabeHeader = [
 		{ key: 'name', colWidth: '', title: '姓名', type: 'text', isCheck: true },
-		{ key: 'userName', colWidth: '', title: '账号', type: 'text', isCheck: true },
+		{ key: 'userName', colWidth: '', title: '登录账号', type: 'text', isCheck: true },
 		{ key: 'orgName', colWidth: '', title: '所属部门', type: 'text', isCheck: true },
 		{ key: 'roles', colWidth: '', title: '角色', type: 'text', isCheck: true },
-		{ key: 'phoneNo', colWidth: '', title: '电话号码', type: 'text', isCheck: true },
+		{ key: 'phoneNo', colWidth: '', title: '手机号', type: 'text', isCheck: true },
 		{ key: 'staffNo', colWidth: '', title: '工号', type: 'text', isCheck: true },
 		{ key: 'defaultTelNo', colWidth: '', title: '默认分机', type: 'text', isCheck: true },
 		{ key: 'creationTime', colWidth: '', title: '更新时间', type: 'text', isCheck: true },