机构:修改无上级机构时显示名称,修改查询逻辑

角色:修改用户角色列表显示逻辑
This commit is contained in:
高云鹏 2024-10-15 12:49:39 +08:00
parent c2c967216d
commit 3728641a29
3 changed files with 22 additions and 12 deletions

View File

@ -322,7 +322,7 @@ const addInstitutional = (rightClick = false) => {
const submitAddForm = () => {
console.log(formModel.value)
if (!formRef.value) return
formRef.value.validate((valid:boolean) => {
formRef.value.validate((valid: boolean) => {
if (valid) {
if (dialogTitle.value === '新增机构') {
formModel.value.parentOrgId = formModel.value.parentOrgId ?? '0'
@ -330,7 +330,7 @@ const submitAddForm = () => {
.then((res) => {
if (res.success) {
ElMessage.success('新增成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
dialogVible.value = false
refreshTreeData(formModel.value.parentOrgId)
} else {
@ -345,7 +345,7 @@ const submitAddForm = () => {
.then((res) => {
if (res.success) {
ElMessage.success('编辑成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
dialogVible.value = false
refreshTreeData(rightClickMenuData.value!.parentOrgId).then(() => {
refreshTreeData(formModel.value.parentOrgId)
@ -368,7 +368,14 @@ const closeAddForm = () => {
const getInstitutionList = (data: getDataType = { name: null }) => {
getInstitutionalListReq(data).then((res) => {
pageTotal.value = res.total
originData.value = res.rows
console.log(res.rows);
originData.value = res.rows.map(item=>{
return {
...item,
parentOrgName:item.parentOrgName ? item.parentOrgName : '无'
}
})
})
}
@ -450,7 +457,7 @@ const delForm = (column: getTreeDataReturnType) => {
.then((res) => {
if (res.success) {
ElMessage.success('删除成功')
getInstitutionList()
getInstitutionList({parentOrgId:rightClickMenuData.value?.parentOrgId})
refreshTreeData(column.parentOrgId)
} else {
ElMessage.error(res?.msg ?? '删除失败')
@ -470,6 +477,7 @@ const treeReplaceProps = {
const treeSelectReplaceProps = {
label: 'name',
children: 'children',
isLeaf: 'isLeaf',
}
const loadTreeData = (node: Node, resolve: any) => {
if (node.level === 0) {
@ -489,7 +497,6 @@ const loadTreeData = (node: Node, resolve: any) => {
})
}
const loadSelectTreeData = (node: Node, resolve: any) => {
console.log(node)
if (node.level === 0) {
return getTreeData(null)
@ -497,7 +504,8 @@ const loadSelectTreeData = (node: Node, resolve: any) => {
if (!res.length) {
node.data.isLeaf = true
}
resolve(res)
resolve([{ id: '0', name: '无', isLeaf: true }, ...res])
})
.catch((err) => {
console.log(err)
@ -552,8 +560,6 @@ const refreshTreeData = (parentOrgId: string | number | null) => {
return new Promise((resolve) => {
const data = parentOrgId === 0 || parentOrgId === '0' ? null : parentOrgId
getTreeData(data).then((res) => {
console.log('res,', res)
console.log(data)
if (data) {
treeRef.value?.updateKeyChildren(parentOrgId!, res)
} else {

View File

@ -5,7 +5,7 @@
<template v-for="item in formColumnList" :key="item.prop">
<el-form-item :label="item.label" :rules="item.rule" :label-width="80" :prop="item.prop">
<template v-if="item.type === 'input'">
<el-input v-model="formModel[item.prop]" :placeholder="'请输入' + item.label"></el-input>
<el-input v-model="formModel[item.prop] as string" :placeholder="'请输入' + item.label"></el-input>
</template>
<template v-if="item.type === 'custom'">
<template v-if="item.prop === 'authList'">
@ -241,13 +241,15 @@ const getRoleList = (roleName = '') => {
getRoleListReq({
roleName,
}).then((res) => {
console.log(res)
pageTotal.value = res.total
originData.value = res.rows.map((item) => {
return {
roleCode: item.roleCode,
roleName: item.roleName,
listName: item.list.map((item) => item.authorityName).join(','),
authList: item.list.map((item) => item.id),
authList: item.list.map((item) => parseInt(item.id)),
id: item.id,
revision: item.revision,
}

View File

@ -12,6 +12,8 @@ export type formDataType = {
roleCode: string
}
export type formDataEnumKeyJointType = keyof typeof formDataEnum
export type formColumnListType<T extends formDataEnumKeyJointType> = {
@ -49,7 +51,7 @@ export type tableDataType<T extends authorityDataListType> = {
roleCode: number
roleName: string
listName: T['authorityName']
authList: T['id'][]
authList: number[]
}
export type tableColumnType<T extends tableDataColumnTypeJointType> = {