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

用户管理初步调整

parent e622c0a2
...@@ -14,8 +14,9 @@ import { defHttp } from '@/utils/http/axios'; ...@@ -14,8 +14,9 @@ import { defHttp } from '@/utils/http/axios';
enum Api { enum Api {
AccountList = '/system/user/list', AccountList = '/system/user/list',
deleteUserApi = '/system/user/deleteLogical/',
IsAccountExist = '/system/accountExist', IsAccountExist = '/system/accountExist',
DeptList = '/system/getDeptList', DeptList = '/system/dept/listAll',
setRoleStatus = '/system/setRoleStatus', setRoleStatus = '/system/setRoleStatus',
MenuList = '/system/getMenuList', MenuList = '/system/getMenuList',
RolePageList = '/system/getRoleListByPage', RolePageList = '/system/getRoleListByPage',
...@@ -25,6 +26,9 @@ enum Api { ...@@ -25,6 +26,9 @@ enum Api {
export const getAccountList = (params: AccountParams) => export const getAccountList = (params: AccountParams) =>
defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params }); 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) => export const getDeptList = (params?: DeptListItem) =>
defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params }); defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
......
...@@ -13,7 +13,7 @@ export default { ...@@ -13,7 +13,7 @@ export default {
// The number field name of each page displayed in the background // The number field name of each page displayed in the background
sizeField: 'pageSize', sizeField: 'pageSize',
// Field name of the form data returned by the interface // Field name of the form data returned by the interface
listField: 'rows', listField: 'data',
// Total number of tables returned by the interface field name // Total number of tables returned by the interface field name
totalField: 'total', totalField: 'total',
}, },
......
...@@ -2,20 +2,21 @@ ...@@ -2,20 +2,21 @@
<div class="m-4 mr-0 overflow-hidden bg-white"> <div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree <BasicTree
title="部门列表" title="部门列表"
ref="basicTreeRef"
toolbar toolbar
search search
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto" treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
:clickRowToExpand="false" :clickRowToExpand="true"
:defaultExpandAll="true"
:treeData="treeData" :treeData="treeData"
:fieldNames="{ key: 'id', title: 'deptName' }" :fieldNames="{ key: 'businessId', title: 'deptName' }"
@select="handleSelect" @select="handleSelect"
/> />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import {BasicTree, TreeItem} from '@/components/Tree';
import { BasicTree, TreeItem } from '@/components/Tree';
import { getDeptList } from '@/api/demo/system'; import { getDeptList } from '@/api/demo/system';
defineOptions({ name: 'DeptTree' }); defineOptions({ name: 'DeptTree' });
...@@ -25,7 +26,28 @@ ...@@ -25,7 +26,28 @@
const treeData = ref<TreeItem[]>([]); const treeData = ref<TreeItem[]>([]);
async function fetch() { 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) { function handleSelect(keys) {
......
<template> <template>
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> <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"> <BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreate">新增</a-button> <a-button type="primary" @click="handleCreate">新增</a-button>
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
{
icon: 'clarity:info-standard-line',
tooltip: '详情',
onClick: handleView.bind(null, record),
},
{ {
icon: 'clarity:note-edit-line', icon: 'clarity:note-edit-line',
tooltip: '编辑', tooltip: '编辑',
...@@ -40,9 +35,8 @@ ...@@ -40,9 +35,8 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive } from 'vue'; import { reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table'; 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 { PageWrapper } from '@/components/Page';
import DeptTree from './DeptTree.vue'; import DeptTree from './DeptTree.vue';
...@@ -82,12 +76,13 @@ ...@@ -82,12 +76,13 @@
}, },
}); });
/** 新增按钮*/
function handleCreate() { function handleCreate() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
}); });
} }
/** 编辑按钮*/
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
console.log(record); console.log(record);
openModal(true, { openModal(true, {
...@@ -96,10 +91,13 @@ ...@@ -96,10 +91,13 @@
}); });
} }
/** 删除按钮*/
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
console.log(record); console.log(record);
deleteUser({ id: record.businessId });
reload();
} }
/** 导出按钮*/
function handleExport() { function handleExport() {
console.log(getSearchInfo()); console.log(getSearchInfo());
} }
...@@ -114,7 +112,7 @@ ...@@ -114,7 +112,7 @@
reload(); reload();
} }
} }
/** 部门树的select*/
function handleSelect(deptId = '') { function handleSelect(deptId = '') {
searchInfo.deptId = deptId; searchInfo.deptId = deptId;
reload(); 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