mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
perf: dept
This commit is contained in:
parent
7d3c59af6d
commit
40c92a9ea2
@ -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 = {
|
||||
|
@ -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: '状态',
|
||||
|
@ -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
|
||||
|
@ -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-transfer
|
||||
v-model="userRole.roleIds"
|
||||
:titles="['角色列表', '已选择']"
|
||||
:props="{
|
||||
key: 'id',
|
||||
label: 'name'
|
||||
}"
|
||||
:data="roleOptions"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 操作按钮 -->
|
||||
|
Loading…
Reference in New Issue
Block a user