fix: dept

This commit is contained in:
xingyu4j 2022-11-18 11:20:29 +08:00
parent bb48e93ed2
commit 2e30dd03e2
2 changed files with 19 additions and 18 deletions

View File

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

View File

@ -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'))
} }