Commit e8b5a88c authored by 张伯涛's avatar 张伯涛

用户管理初步调整

parent e622c0a2
......@@ -14,8 +14,9 @@ import { defHttp } from '@/utils/http/axios';
enum Api {
AccountList = '/system/user/list',
deleteUserApi = '/system/user/deleteLogical/',
IsAccountExist = '/system/accountExist',
DeptList = '/system/getDeptList',
DeptList = '/system/dept/listAll',
setRoleStatus = '/system/setRoleStatus',
MenuList = '/system/getMenuList',
RolePageList = '/system/getRoleListByPage',
......@@ -25,6 +26,9 @@ enum Api {
export const getAccountList = (params: AccountParams) =>
defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
export const deleteUser = (params?: any) =>
defHttp.delete<any>({ url: Api.deleteUserApi +params.id });
export const getDeptList = (params?: DeptListItem) =>
defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
......
......@@ -13,7 +13,7 @@ export default {
// The number field name of each page displayed in the background
sizeField: 'pageSize',
// Field name of the form data returned by the interface
listField: 'rows',
listField: 'data',
// Total number of tables returned by the interface field name
totalField: 'total',
},
......
......@@ -2,20 +2,21 @@
<div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree
title="部门列表"
ref="basicTreeRef"
toolbar
search
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
:clickRowToExpand="false"
:clickRowToExpand="true"
:defaultExpandAll="true"
:treeData="treeData"
:fieldNames="{ key: 'id', title: 'deptName' }"
:fieldNames="{ key: 'businessId', title: 'deptName' }"
@select="handleSelect"
/>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { BasicTree, TreeItem } from '@/components/Tree';
import {BasicTree, TreeItem} from '@/components/Tree';
import { getDeptList } from '@/api/demo/system';
defineOptions({ name: 'DeptTree' });
......@@ -25,7 +26,28 @@
const treeData = ref<TreeItem[]>([]);
async function fetch() {
treeData.value = (await getDeptList()) as unknown as TreeItem[];
const res = await getDeptList()
treeData.value = handleTree(res.data, 'businessId',undefined,undefined,undefined)
}
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id'
parentId = parentId || 'parentId'
children = children || 'children'
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
// 循环所有项
const treeData = cloneData.filter(father => {
const branchArr = cloneData.filter(child => {
// 返回每一项的子级数组
return father[id] === child[parentId]
})
branchArr.length > 0 ? father.children = branchArr : ''
// 返回第一层
return father[parentId] === rootId
})
return treeData !== '' ? treeData : data
}
function handleSelect(keys) {
......
<template>
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
<!-- <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />-->
<DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
<BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo">
<template #toolbar>
<a-button type="primary" @click="handleCreate">新增</a-button>
......@@ -10,11 +10,6 @@
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: 'clarity:info-standard-line',
tooltip: '详情',
onClick: handleView.bind(null, record),
},
{
icon: 'clarity:note-edit-line',
tooltip: '编辑',
......@@ -40,9 +35,8 @@
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { getAccountList } from '@/api/demo/system';
import {getAccountList, deleteUser} from '@/api/demo/system';
import { PageWrapper } from '@/components/Page';
import DeptTree from './DeptTree.vue';
......@@ -82,12 +76,13 @@
},
});
/** 新增按钮*/
function handleCreate() {
openModal(true, {
isUpdate: false,
});
}
/** 编辑按钮*/
function handleEdit(record: Recordable) {
console.log(record);
openModal(true, {
......@@ -96,10 +91,13 @@
});
}
/** 删除按钮*/
function handleDelete(record: Recordable) {
console.log(record);
deleteUser({ id: record.businessId });
reload();
}
/** 导出按钮*/
function handleExport() {
console.log(getSearchInfo());
}
......@@ -114,7 +112,7 @@
reload();
}
}
/** 部门树的select*/
function handleSelect(deptId = '') {
searchInfo.deptId = deptId;
reload();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment