mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
fix: dept
This commit is contained in:
parent
bb48e93ed2
commit
2e30dd03e2
@ -1,6 +1,6 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
export type DeptVO = {
|
export type DeptVO = {
|
||||||
id: number
|
id?: number
|
||||||
name: string
|
name: string
|
||||||
parentId: number
|
parentId: number
|
||||||
status: number
|
status: number
|
||||||
|
@ -54,9 +54,9 @@
|
|||||||
<el-select v-model="leaderUserId">
|
<el-select v-model="leaderUserId">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in userOption"
|
v-for="item in userOption"
|
||||||
:key="parseInt(item.id)"
|
:key="item.id"
|
||||||
:label="item.nickname"
|
:label="item.nickname"
|
||||||
:value="parseInt(item.id)"
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@ -83,7 +83,7 @@ import { VxeGridInstance } from 'vxe-table'
|
|||||||
import { ElSelect, ElTreeSelect, ElOption } from 'element-plus'
|
import { ElSelect, ElTreeSelect, ElOption } from 'element-plus'
|
||||||
import { allSchemas } from './dept.data'
|
import { allSchemas } from './dept.data'
|
||||||
import * as DeptApi from '@/api/system/dept'
|
import * as DeptApi from '@/api/system/dept'
|
||||||
import { getListSimpleUsersApi } from '@/api/system/user'
|
import { getListSimpleUsersApi, UserVO } from '@/api/system/user'
|
||||||
import { required } from '@/utils/formRules.js'
|
import { required } from '@/utils/formRules.js'
|
||||||
import { handleTree } from '@/utils/tree'
|
import { handleTree } from '@/utils/tree'
|
||||||
import { FormExpose } from '@/components/Form'
|
import { FormExpose } from '@/components/Form'
|
||||||
@ -99,12 +99,7 @@ const treeConfig = {
|
|||||||
parentField: 'parentId',
|
parentField: 'parentId',
|
||||||
expandAll: true
|
expandAll: true
|
||||||
}
|
}
|
||||||
const { gridOptions, getList, deleteData } = useVxeGrid<DeptApi.DeptVO>({
|
|
||||||
allSchemas: allSchemas,
|
|
||||||
treeConfig: treeConfig,
|
|
||||||
getListApi: DeptApi.getDeptPageApi,
|
|
||||||
deleteApi: DeptApi.deleteDeptApi
|
|
||||||
})
|
|
||||||
// 弹窗相关的变量
|
// 弹窗相关的变量
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
const dialogTitle = ref('edit') // 弹出层标题
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
@ -114,7 +109,7 @@ const deptParentId = ref(0) // 上级ID
|
|||||||
const leaderUserId = ref()
|
const leaderUserId = ref()
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
const deptOptions = ref() // 树形结构
|
const deptOptions = ref() // 树形结构
|
||||||
const userOption = ref()
|
const userOption = ref<UserVO[]>([])
|
||||||
// 新增和修改的表单校验
|
// 新增和修改的表单校验
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
name: [required],
|
name: [required],
|
||||||
@ -130,6 +125,10 @@ const defaultProps = {
|
|||||||
label: 'name',
|
label: 'name',
|
||||||
value: 'id'
|
value: 'id'
|
||||||
}
|
}
|
||||||
|
const getUserList = async () => {
|
||||||
|
const res = await getListSimpleUsersApi()
|
||||||
|
userOption.value = res
|
||||||
|
}
|
||||||
// 获取下拉框[上级]的数据
|
// 获取下拉框[上级]的数据
|
||||||
const getTree = async () => {
|
const getTree = async () => {
|
||||||
deptOptions.value = []
|
deptOptions.value = []
|
||||||
@ -138,11 +137,12 @@ const getTree = async () => {
|
|||||||
dept.children = handleTree(res)
|
dept.children = handleTree(res)
|
||||||
deptOptions.value.push(dept)
|
deptOptions.value.push(dept)
|
||||||
}
|
}
|
||||||
const getUserList = async () => {
|
const { gridOptions, getList, deleteData } = useVxeGrid<DeptApi.DeptVO>({
|
||||||
const res = await getListSimpleUsersApi()
|
allSchemas: allSchemas,
|
||||||
userOption.value = res
|
treeConfig: treeConfig,
|
||||||
}
|
getListApi: DeptApi.getDeptPageApi,
|
||||||
|
deleteApi: DeptApi.deleteDeptApi
|
||||||
|
})
|
||||||
// ========== 新增/修改 ==========
|
// ========== 新增/修改 ==========
|
||||||
|
|
||||||
// 设置标题
|
// 设置标题
|
||||||
@ -182,10 +182,11 @@ const submitForm = async () => {
|
|||||||
const data = unref(formRef)?.formModel as DeptApi.DeptVO
|
const data = unref(formRef)?.formModel as DeptApi.DeptVO
|
||||||
data.parentId = deptParentId.value
|
data.parentId = deptParentId.value
|
||||||
data.leaderUserId = leaderUserId.value
|
data.leaderUserId = leaderUserId.value
|
||||||
if (dialogTitle.value.startsWith('新增')) {
|
console.info(data)
|
||||||
|
if (actionType.value === 'create') {
|
||||||
await DeptApi.createDeptApi(data)
|
await DeptApi.createDeptApi(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else if (dialogTitle.value.startsWith('修改')) {
|
} else if (actionType.value === 'update') {
|
||||||
await DeptApi.updateDeptApi(data)
|
await DeptApi.updateDeptApi(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user