|
@@ -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
|