feat: 数据字典权限
This commit is contained in:
parent
6a62c2bf4e
commit
a3b29ae01e
|
@ -4013,6 +4013,93 @@ export default [
|
||||||
accessSupport: { text: "不支持", value: "unsupported" },
|
accessSupport: { text: "不支持", value: "unsupported" },
|
||||||
supportDataAccess: false
|
supportDataAccess: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
code: 'system/Dictionary',
|
||||||
|
name: '数据字典',
|
||||||
|
owner: 'iot',
|
||||||
|
id: 'b69782873cc24be8165c6ad292359092',
|
||||||
|
sortIndex: 12,
|
||||||
|
url: '/system/Dictionary',
|
||||||
|
icon: 'FormOutlined',
|
||||||
|
showPage: [],
|
||||||
|
permissions: [],
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
id: "add",
|
||||||
|
name: "新增",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"save"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "delete",
|
||||||
|
name: "删除",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"delete"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "update",
|
||||||
|
name: "编辑",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"save"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "import",
|
||||||
|
name: "导入",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"save"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "down",
|
||||||
|
name: "下载",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"query"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "action",
|
||||||
|
name: "启用/禁用",
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: "dictionary",
|
||||||
|
actions: [
|
||||||
|
"save"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
accessSupport: { text: "不支持", value: "unsupported" },
|
||||||
|
supportDataAccess: false
|
||||||
|
},
|
||||||
// {
|
// {
|
||||||
// code: 'system/License',
|
// code: 'system/License',
|
||||||
// name: 'License管理',
|
// name: 'License管理',
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="left-contain">
|
<div class="left-contain">
|
||||||
<j-input placeholder="字典名称">
|
<j-input placeholder="字典名称" v-model:value="searchValue" @pressEnter="search" @change="searchChange">
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<AIcon type="SearchOutlined" />
|
<AIcon type="SearchOutlined" @click="search" />
|
||||||
</template>
|
</template>
|
||||||
</j-input>
|
</j-input>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="primary"
|
type="primary"
|
||||||
:hasPermission="true"
|
hasPermission="system/Dictionary:add"
|
||||||
@click="showSave"
|
@click="showSave"
|
||||||
style="width: 60%"
|
style="width: 60%"
|
||||||
>
|
>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<!-- <j-button type="primary" @click="showSave" style="width: 60%;">新增字典</j-button> -->
|
<!-- <j-button type="primary" @click="showSave" style="width: 60%;">新增字典</j-button> -->
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="text"
|
type="text"
|
||||||
:hasPermission="true"
|
hasPermission="system/Dictionary:down"
|
||||||
@click="downVisible=true"
|
@click="downVisible=true"
|
||||||
>
|
>
|
||||||
下载
|
下载
|
||||||
|
@ -28,22 +28,30 @@
|
||||||
accept=".json"
|
accept=".json"
|
||||||
:show-upload-list="false"
|
:show-upload-list="false"
|
||||||
>
|
>
|
||||||
<j-button type="text">导入</j-button>
|
<PermissionButton
|
||||||
|
type="text"
|
||||||
|
hasPermission="system/Dictionary:import"
|
||||||
|
>
|
||||||
|
导入
|
||||||
|
</PermissionButton>
|
||||||
</j-upload>
|
</j-upload>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<j-tree :tree-data="listData" :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="()=>selectDic(item.data)">
|
<div class="treeItem" @click="()=>selectDic(item.data)">
|
||||||
<div class="itemText"><Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis></div>
|
<div class="itemText"><Ellipsis style="width: calc(100%-100px)">{{ item.name }}</Ellipsis></div>
|
||||||
<div @click="(e) => e.stopPropagation()">
|
<div @click="(e) => e.stopPropagation()">
|
||||||
<j-popconfirm :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)">
|
<j-popconfirm v-if="hasPermission('system/Dictionary:action')" :title="item.data.status === 1 ? '确定禁用?' : '确定启用?'" @confirm="()=>updateDic(item.data)">
|
||||||
<j-switch v-model:checked="item.status" :checkedValue="1" :unCheckedValue="0"></j-switch>
|
<j-switch v-model:checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch>
|
||||||
</j-popconfirm>
|
</j-popconfirm>
|
||||||
|
<j-tooltip v-else placement="top" title="暂无权限,请联系管理员">
|
||||||
|
<j-switch v-model:checked="item.status" :disabled="!hasPermission('system/Dictionary:action')" :checkedValue="1" :unCheckedValue="0"></j-switch>
|
||||||
|
</j-tooltip>
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="text"
|
type="text"
|
||||||
:hasPermission="true"
|
hasPermission="system/Dictionary:delete"
|
||||||
:popConfirm="{
|
:popConfirm="{
|
||||||
title: `确定要删除?`,
|
title: `确定要删除?`,
|
||||||
onConfirm: () => deleteDic(item.id),
|
onConfirm: () => deleteDic(item.id),
|
||||||
|
@ -56,7 +64,7 @@
|
||||||
</j-popconfirm> -->
|
</j-popconfirm> -->
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="text"
|
type="text"
|
||||||
:hasPermission="true"
|
hasPermission="system/Dictionary:update"
|
||||||
@click="showEdit(item.data)"
|
@click="showEdit(item.data)"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
|
@ -66,6 +74,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</j-tree>
|
</j-tree>
|
||||||
|
<j-empty v-else style="margin-top: 100px;"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Save v-if="saveShow" :type="addType" @close-save="saveShow = false" @success="saveSuccess" :data="editData"/>
|
<Save v-if="saveShow" :type="addType" @close-save="saveShow = false" @success="saveSuccess" :data="editData"/>
|
||||||
|
@ -78,7 +87,10 @@ import { getDicList ,deleteDictionary,addDictionary} from '@/api/system/dictiona
|
||||||
import Save from './save/index.vue'
|
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 { first } from 'lodash-es';
|
||||||
const emit = defineEmits(['selectData'])
|
const emit = defineEmits(['selectData'])
|
||||||
|
const hasPermission = usePermissionStore().hasPermission;
|
||||||
const saveShow = ref(false)
|
const saveShow = ref(false)
|
||||||
const addType = ref('add')
|
const addType = ref('add')
|
||||||
const listData = ref<any[]>([])
|
const listData = ref<any[]>([])
|
||||||
|
@ -89,16 +101,27 @@ const showSave = () =>{
|
||||||
addType.value = 'add'
|
addType.value = 'add'
|
||||||
}
|
}
|
||||||
const downVisible = ref(false)
|
const downVisible = ref(false)
|
||||||
const queryData = (first?:Boolean) =>{
|
const searchValue = ref()
|
||||||
getDicList({sorts: [{ name: 'createTime', order: 'desc' }]}).then((res:any)=>{
|
const queryData = (first?:Boolean,searchName?:any) =>{
|
||||||
|
const params = searchName ? {sorts: [{ name: 'createTime', order: 'desc' }],terms:[{terms:[{value:'%'+ searchName +'%',termType:'like',column:'name'}]}]} : {sorts: [{ name: 'createTime', order: 'desc' }]}
|
||||||
|
getDicList(params).then((res:any)=>{
|
||||||
if(res.status === 200){
|
if(res.status === 200){
|
||||||
listData.value = res.result
|
listData.value = res.result
|
||||||
if(first){
|
if(first && res.result.length){
|
||||||
selectDic(res.result[0])
|
selectDic(res.result[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const search = () =>{
|
||||||
|
queryData(true,searchValue.value)
|
||||||
|
}
|
||||||
|
const searchChange = () =>{
|
||||||
|
console.log(searchValue.value ==='')
|
||||||
|
if(searchValue.value === ''){
|
||||||
|
queryData(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
const showEdit = (data:any) =>{
|
const showEdit = (data:any) =>{
|
||||||
saveShow.value = true
|
saveShow.value = true
|
||||||
addType.value = 'edit'
|
addType.value = 'edit'
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<PermissionButton
|
<PermissionButton
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="add"
|
@click="add"
|
||||||
|
hasPermission="system/Dictionary:add"
|
||||||
>
|
>
|
||||||
新增
|
新增
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
style="padding: 0 5px"
|
style="padding: 0 5px"
|
||||||
:danger="i.key === 'delete'"
|
:danger="i.key === 'delete'"
|
||||||
:hasPermission="
|
:hasPermission="
|
||||||
true
|
'system/Dictionary:' + i.key
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #icon
|
<template #icon
|
||||||
|
@ -63,7 +64,6 @@ import Save from './Save/index.vue'
|
||||||
import type { ActionsType } from './typings';
|
import type { ActionsType } from './typings';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { table } from 'console';
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data:{
|
data:{
|
||||||
type:Object,
|
type:Object,
|
||||||
|
|
|
@ -50,7 +50,7 @@ const form = reactive({
|
||||||
id:'',
|
id:'',
|
||||||
name:'',
|
name:'',
|
||||||
describe:'',
|
describe:'',
|
||||||
status:0,
|
status:1,
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* 校验id
|
* 校验id
|
||||||
|
|
Loading…
Reference in New Issue