perf: dept

This commit is contained in:
xingyu 2022-08-01 21:05:42 +08:00
parent 7d3c59af6d
commit 40c92a9ea2
4 changed files with 42 additions and 17 deletions

View File

@ -1,9 +1,12 @@
export type DeptVO = {
id: number
name: string
status: number
parentId: number
createTime: string
status: number
sort: number
leaderUserId: number
phone: string
email: string
}
export type DeptListReqVO = {

View File

@ -17,7 +17,7 @@ export const modelSchema = reactive<FormSchema[]>([
},
{
label: '负责人',
field: 'email',
field: 'leaderUserId',
component: 'Input'
},
{
@ -33,7 +33,7 @@ export const modelSchema = reactive<FormSchema[]>([
{
label: '显示排序',
field: 'sort',
component: 'Input'
component: 'InputNumber'
},
{
label: '状态',

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { useI18n } from '@/hooks/web/useI18n'
import { ElInput, ElCard, ElTree, ElTreeSelect } from 'element-plus'
import { ElInput, ElCard, ElTree, ElTreeSelect, ElSelect, ElOption } from 'element-plus'
import { handleTree } from '@/utils/tree'
import { onMounted, ref, unref, watch } from 'vue'
import * as DeptApi from '@/api/system/dept'
@ -8,6 +8,7 @@ import { Form, FormExpose } from '@/components/Form'
import { modelSchema } from './dept.data'
import { DeptVO } from '@/api/system/dept/types'
import { useMessage } from '@/hooks/web/useMessage'
import { getListSimpleUsersApi } from '@/api/system/user'
const message = useMessage()
interface Tree {
id: number
@ -34,7 +35,7 @@ const filterText = ref('')
const deptOptions = ref() //
const treeRef = ref<InstanceType<typeof ElTree>>()
const getTree = async () => {
const res = await DeptApi.getDeptPageApi(null)
const res = await DeptApi.listSimpleDeptApi()
deptOptions.value = handleTree(res)
}
const filterNode = (value: string, data: Tree) => {
@ -44,6 +45,13 @@ const filterNode = (value: string, data: Tree) => {
watch(filterText, (val) => {
treeRef.value!.filter(val)
})
//
const userOption = ref()
const leaderUserId = ref()
const getUserList = async () => {
const res = await getListSimpleUsersApi()
userOption.value = res
}
//
const handleAdd = (data: { id: number }) => {
//
@ -54,11 +62,12 @@ const handleAdd = (data: { id: number }) => {
}
//
const handleUpdate = async (data: { id: number }) => {
showForm.value = true
const res = await DeptApi.getDeptApi(data.id)
formTitle.value = '修改- ' + res?.name
deptParentId.value = res.parentId
leaderUserId.value = res.leaderUserId
unref(formRef)?.setValues(res)
showForm.value = true
}
//
const handleDelete = async (data: { id: number }) => {
@ -78,7 +87,7 @@ const submitForm = async () => {
try {
const data = unref(formRef)?.formModel as DeptVO
data.parentId = deptParentId.value
// TODO:
data.leaderUserId = leaderUserId.value
if (formTitle.value.startsWith('新增')) {
await DeptApi.createDeptApi(data)
} else if (formTitle.value.startsWith('修改')) {
@ -92,6 +101,7 @@ const submitForm = async () => {
}
onMounted(async () => {
await getTree()
await getUserList()
})
</script>
<template>
@ -159,6 +169,16 @@ onMounted(async () => {
check-strictly
/>
</template>
<template #leaderUserId>
<el-select v-model="leaderUserId">
<el-option
v-for="item in userOption"
:key="parseInt(item.id)"
:label="item.nickname"
:value="parseInt(item.id)"
/>
</el-select>
</template>
</Form>
<!-- 操作按钮 -->
<el-button

View File

@ -9,6 +9,7 @@ import {
ElTreeSelect,
ElSelect,
ElOption,
ElTransfer,
ElForm,
ElFormItem,
ElUpload,
@ -482,7 +483,7 @@ getList()
</template>
</Dialog>
<!-- 分配用户角色 -->
<Dialog v-model="roleDialogVisible" title="分配角色">
<Dialog v-model="roleDialogVisible" title="分配角色" maxHeight="450px">
<el-form :model="userRole" label-width="80px">
<el-form-item label="用户名称">
<el-input v-model="userRole.username" :disabled="true" />
@ -491,14 +492,15 @@ getList()
<el-input v-model="userRole.nickname" :disabled="true" />
</el-form-item>
<el-form-item label="角色">
<el-select v-model="userRole.roleIds" multiple>
<el-option
v-for="item in roleOptions"
:key="parseInt(item.id)"
:label="item.name"
:value="parseInt(item.id)"
/>
</el-select>
<el-transfer
v-model="userRole.roleIds"
:titles="['角色列表', '已选择']"
:props="{
key: 'id',
label: 'name'
}"
:data="roleOptions"
/>
</el-form-item>
</el-form>
<!-- 操作按钮 -->