fix: bug#18505、18507
This commit is contained in:
parent
a9e25810f9
commit
654c344455
|
@ -88,7 +88,6 @@ import Save from './save/index.vue'
|
||||||
import { onlyMessage} from '@/utils/comm';
|
import { onlyMessage} from '@/utils/comm';
|
||||||
import Export from './Export/index.vue'
|
import Export from './Export/index.vue'
|
||||||
import { usePermissionStore } from '@/store/permission';
|
import { usePermissionStore } from '@/store/permission';
|
||||||
import { first } from 'lodash-es';
|
|
||||||
const emit = defineEmits(['selectData'])
|
const emit = defineEmits(['selectData'])
|
||||||
const hasPermission = usePermissionStore().hasPermission;
|
const hasPermission = usePermissionStore().hasPermission;
|
||||||
const saveShow = ref(false)
|
const saveShow = ref(false)
|
||||||
|
|
|
@ -5,17 +5,16 @@
|
||||||
<AIcon type="SearchOutlined" @click="search" />
|
<AIcon type="SearchOutlined" @click="search" />
|
||||||
</template>
|
</template>
|
||||||
</j-input>
|
</j-input>
|
||||||
<div class="controls">
|
<div class="controls" v-if="admin">
|
||||||
<PermissionButton
|
<j-button
|
||||||
type="primary"
|
type="primary"
|
||||||
hasPermission="system/Dictionary:add"
|
@click="addGroup"
|
||||||
@click="addGroup"
|
style="width: 100%"
|
||||||
style="width: 100%"
|
|
||||||
>
|
>
|
||||||
新增分组
|
新增分组
|
||||||
</PermissionButton>
|
</j-button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="listBox">
|
||||||
<j-tree :tree-data="listData" v-if="listData.length" :fieldNames="{title:'name',key:'id'}" blockNode :selectedKeys="selectedKeys">
|
<j-tree :tree-data="listData" v-if="listData.length" :fieldNames="{title:'name',key:'id'}" blockNode :selectedKeys="selectedKeys">
|
||||||
<template #title="item">
|
<template #title="item">
|
||||||
<div class="treeItem" @click="()=>selectGroup(item.data.id)" v-if="!item.data?.edit">
|
<div class="treeItem" @click="()=>selectGroup(item.data.id)" v-if="!item.data?.edit">
|
||||||
|
@ -31,6 +30,7 @@
|
||||||
title: `确定要删除?`,
|
title: `确定要删除?`,
|
||||||
onConfirm: () => deleteGroup(item.id),
|
onConfirm: () => deleteGroup(item.id),
|
||||||
}"
|
}"
|
||||||
|
:disabled="item.id === 'default_group'"
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
type="text"
|
type="text"
|
||||||
hasPermission="system/Role:update"
|
hasPermission="system/Role:update"
|
||||||
@click="editGroup(item.data)"
|
@click="editGroup(item.data)"
|
||||||
|
:disabled="item.id === 'default_group'"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
@ -45,7 +46,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<j-input v-model:value="addName" @blur="()=>saveGroup(item.data)" ref="inputRef" :maxlength="64"></j-input>
|
<j-input v-model:value="addName" @blur="()=>saveGroup(item.data)" ref="inputRef" :maxlength="64"></j-input>
|
||||||
<div style="color: red;" v-if="validateTip">分组名称不能为空</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</j-tree>
|
</j-tree>
|
||||||
|
@ -56,15 +56,22 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import { queryRoleGroup , saveRoleGroup , deleteRoleGroup } from '@/api/system/role'
|
import { queryRoleGroup , saveRoleGroup , deleteRoleGroup } from '@/api/system/role';
|
||||||
import { randomString } from '@/utils/utils'
|
import { randomString } from '@/utils/utils';
|
||||||
|
import { useUserInfo } from '@/store/userInfo';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
const emit = defineEmits(['selectData'])
|
const emit = defineEmits(['selectData'])
|
||||||
|
const userInfoStore = useUserInfo()
|
||||||
|
const { userInfos } = storeToRefs(userInfoStore)
|
||||||
|
const admin = computed(() => {
|
||||||
|
return userInfos.value?.username === 'admin';
|
||||||
|
})
|
||||||
const listData:any = ref([])
|
const listData:any = ref([])
|
||||||
const selectedKeys = ref<string[]>([])
|
const selectedKeys = ref<string[]>([])
|
||||||
const searchValue = ref()
|
const searchValue = ref()
|
||||||
const inputRef = ref()
|
const inputRef = ref()
|
||||||
const validateTip = ref()
|
|
||||||
const addName = ref()
|
const addName = ref()
|
||||||
|
const addStatus = ref(false) // 新增分组状态
|
||||||
const queryGroup = async(select?:Boolean,searchName?:string) =>{
|
const queryGroup = async(select?:Boolean,searchName?:string) =>{
|
||||||
const params = searchName ? {sorts: [{ name: 'createTime', order: 'desc' }],terms:[{terms:[{value:'%'+ searchName +'%',termType:'like',column:'name'}]}]} : {sorts: [{ name: 'createTime', order: 'desc' }]}
|
const params = searchName ? {sorts: [{ name: 'createTime', order: 'desc' }],terms:[{terms:[{value:'%'+ searchName +'%',termType:'like',column:'name'}]}]} : {sorts: [{ name: 'createTime', order: 'desc' }]}
|
||||||
const req:any = await queryRoleGroup(params)
|
const req:any = await queryRoleGroup(params)
|
||||||
|
@ -77,7 +84,7 @@ const queryGroup = async(select?:Boolean,searchName?:string) =>{
|
||||||
}
|
}
|
||||||
const addGroup = () =>{
|
const addGroup = () =>{
|
||||||
addName.value = ''
|
addName.value = ''
|
||||||
listData.value.push({
|
listData.value.unshift({
|
||||||
name:'',
|
name:'',
|
||||||
edit:true,
|
edit:true,
|
||||||
id: randomString()
|
id: randomString()
|
||||||
|
@ -88,9 +95,8 @@ const addGroup = () =>{
|
||||||
}
|
}
|
||||||
const saveGroup = async(data:any) =>{
|
const saveGroup = async(data:any) =>{
|
||||||
if(addName.value === ''){
|
if(addName.value === ''){
|
||||||
validateTip.value = true
|
listData.value.shift()
|
||||||
}else{
|
}else{
|
||||||
validateTip.value = false
|
|
||||||
const saveData = {
|
const saveData = {
|
||||||
name:addName.value,
|
name:addName.value,
|
||||||
id:data.id
|
id:data.id
|
||||||
|
@ -103,6 +109,7 @@ const saveGroup = async(data:any) =>{
|
||||||
onlyMessage('操作失败!')
|
onlyMessage('操作失败!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addStatus.value = false
|
||||||
}
|
}
|
||||||
const search = () =>{
|
const search = () =>{
|
||||||
queryGroup(true,searchValue.value)
|
queryGroup(true,searchValue.value)
|
||||||
|
@ -152,4 +159,7 @@ onMounted(()=>{
|
||||||
max-width:40%
|
max-width:40%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.listBox{
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue