fix: bug#18898
This commit is contained in:
parent
9d4177e1c9
commit
06f128bd0b
|
@ -6,24 +6,14 @@
|
|||
</template>
|
||||
</j-input>
|
||||
<div class="controls" v-if="admin">
|
||||
<j-button
|
||||
type="primary"
|
||||
@click="addGroup"
|
||||
style="width: 100%"
|
||||
>
|
||||
<j-button type="primary" @click="addGroup" style="width: 100%">
|
||||
新增分组
|
||||
</j-button>
|
||||
</div>
|
||||
<div class="listBox">
|
||||
<j-tree
|
||||
:tree-data="listData"
|
||||
v-if="listData.length"
|
||||
:fieldNames="{title:'name',key:'id',children:'children'}"
|
||||
blockNode
|
||||
:selectedKeys="selectedKeys"
|
||||
:default-expanded-keys="['global_role']"
|
||||
:showLine="{ showLeafIcon: false }"
|
||||
>
|
||||
<j-tree :tree-data="listData" v-if="listData.length" :fieldNames="{ title: 'name', key: 'id', children: 'children' }"
|
||||
blockNode :selectedKeys="selectedKeys" :default-expanded-keys="['global_role']"
|
||||
:showLine="{ showLeafIcon: false }">
|
||||
<template #title="item">
|
||||
<div class="treeItem" @click="() => selectGroup(item.data.id)" v-if="!item.data?.edit">
|
||||
<template v-if="!item?.children">
|
||||
|
@ -31,28 +21,25 @@
|
|||
<Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis>
|
||||
</div>
|
||||
<div @click="(e) => e.stopPropagation()" v-if="item.id !== 'default_group'">
|
||||
<PermissionButton
|
||||
type="text"
|
||||
hasPermission="system/Role:groupDelete"
|
||||
:popConfirm="{
|
||||
<PermissionButton type="text" hasPermission="system/Role:groupDelete" :popConfirm="{
|
||||
title: `确定要删除?`,
|
||||
onConfirm: () => deleteGroup(item.id),
|
||||
}"
|
||||
:disabled="item.id === 'default_group'"
|
||||
>
|
||||
}" :disabled="item.id === 'default_group'">
|
||||
删除
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
type="text"
|
||||
hasPermission="system/Role:groupUpdate"
|
||||
@click="editGroup(item.data)"
|
||||
:disabled="item.id === 'default_group'"
|
||||
>
|
||||
<PermissionButton type="text" hasPermission="system/Role:groupUpdate"
|
||||
@click="editGroup(item.data)" :disabled="item.id === 'default_group'">
|
||||
编辑
|
||||
</PermissionButton>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else><Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis></template>
|
||||
<template v-else>
|
||||
<Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else>
|
||||
<j-input v-model:value="addName" @blur="() => saveGroup(item.data)" ref="inputRef"
|
||||
:maxlength="64"></j-input>
|
||||
</div>
|
||||
</template>
|
||||
</j-tree>
|
||||
|
@ -95,7 +82,7 @@ const queryGroup = async(select?:Boolean,searchName?:string) =>{
|
|||
}
|
||||
const addGroup = () => {
|
||||
addName.value = ''
|
||||
listData.value.unshift({
|
||||
listData.value[0].children.unshift({
|
||||
name: '',
|
||||
edit: true,
|
||||
id: randomString()
|
||||
|
@ -106,7 +93,7 @@ const addGroup = () =>{
|
|||
}
|
||||
const saveGroup = async (data: any) => {
|
||||
if (addName.value === '') {
|
||||
listData.value.shift()
|
||||
listData.value[0].children.shift()
|
||||
} else {
|
||||
const saveData = {
|
||||
name: addName.value,
|
||||
|
@ -146,7 +133,7 @@ const deleteGroup = async(id:string)=>{
|
|||
}
|
||||
const editGroup = (data: any) => {
|
||||
addName.value = data.name
|
||||
listData.value.forEach((item:any)=>{
|
||||
listData.value[0].children.forEach((item: any) => {
|
||||
if (item.id === data.id) {
|
||||
item.edit = true
|
||||
}
|
||||
|
@ -160,14 +147,17 @@ onMounted(()=>{
|
|||
.controls {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.treeItem {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.itemText {
|
||||
line-height: 32px;
|
||||
max-width: 40%
|
||||
}
|
||||
}
|
||||
|
||||
.listBox {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue