fix: Chat_log_permission

This commit is contained in:
zhangzhanwei 2025-08-29 15:39:19 +08:00 committed by zhanweizhang7
parent 6b17b450d4
commit 53e67caaff
3 changed files with 45 additions and 9 deletions

View File

@ -59,15 +59,16 @@ import type { FormInstance, FormRules } from 'element-plus'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import useStore from '@/stores'
import { t } from '@/locales'
const props = defineProps<{
data?: {
type: object
default: () => null
}
const props = withDefaults(defineProps<{
data?: any,
postKnowledgeHandler?: (knowledge_list:Array<any>) => Array<any>
apiType: 'systemShare' | 'workspace' | 'systemManage'
isApplication?: boolean,
workspaceId?: string,
}>()
}>(), {
postKnowledgeHandler: (k_l: Array<any>) => k_l,
data: () => null
})
const { user } = useStore()
@ -111,8 +112,10 @@ const loadTree = async (node: any, resolve: any) => {
}
await loadSharedApi({ type: 'knowledge', systemType: props.apiType })
.getKnowledgeList(obj, optionLoading)
.then((ok: any)=>ok.data)
.then(props.postKnowledgeHandler)
.then((res: any) => {
resolve(res.data)
resolve(res)
})
}

View File

@ -50,7 +50,9 @@
</el-form-item>
</el-form>
<SelectKnowledgeDocument
v-if="detail.workspace_id"
ref="SelectKnowledgeDocumentRef"
:post-knowledge-handler="postKnowledgeHandler"
:apiType="apiType"
@changeKnowledge="changeKnowledge"
@changeDocument="changeDocument"
@ -75,6 +77,10 @@ import type { FormInstance, FormRules } from 'element-plus'
import imageApi from '@/api/image'
import { t } from '@/locales'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import { Permission } from '@/utils/permission/type'
import { hasPermission } from '@/utils/permission'
import { PermissionConst, RoleConst } from '@/utils/permission/data'
const route = useRoute()
const {
params: { id },
@ -87,6 +93,18 @@ const apiType = computed(() => {
}
})
const postKnowledgeHandler = (knowledgeList: Array<any>) => {
return knowledgeList.filter(item => {
if (apiType.value === 'workspace') {
return hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole(),
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspacePermissionWorkspaceManageRole,
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspaceResourcePermission('KNOWLEDGE', item.id)], 'OR')
} else if (apiType.value === 'systemManage') {
return hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_EDIT],'OR')
}
})
}
const emit = defineEmits(['refresh'])
const formRef = ref()
@ -127,7 +145,6 @@ const SelectKnowledgeDocumentRef = ref()
const dialogVisible = ref<boolean>(false)
const loading = ref(false)
const detail = ref<any>({})
const form = ref<any>({
chat_id: '',
record_id: '',

View File

@ -222,6 +222,7 @@
:close-on-press-escape="false"
>
<SelectKnowledgeDocument
:post-knowledge-handler="postKnowledgeHandler"
ref="SelectKnowledgeDocumentRef"
:apiType="apiType"
:workspace-id="detail.workspace_id"
@ -252,6 +253,10 @@ import { t } from '@/locales'
import { ElTable } from 'element-plus'
import permissionMap from '@/permission'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import { Permission } from '@/utils/permission/type'
import { hasPermission } from '@/utils/permission'
import { PermissionConst, RoleConst } from '@/utils/permission/data'
const route = useRoute()
const apiType = computed(() => {
@ -349,7 +354,18 @@ const filter = ref<any>({
min_trample: 0,
comparer: 'and',
})
const postKnowledgeHandler = (knowledgeList: Array<any>) => {
return knowledgeList.filter(item => {
if (apiType.value === 'workspace') {
return hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole(),
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspacePermissionWorkspaceManageRole,
new Permission("KNOWLEDGE_DOCUMENT:READ+EDIT").getWorkspaceResourcePermission('KNOWLEDGE', item.id)], 'OR')
} else if (apiType.value === 'systemManage') {
return hasPermission([RoleConst.ADMIN, PermissionConst.RESOURCE_KNOWLEDGE_DOCUMENT_EDIT],'OR')
}
})
}
function filterChange(val: string) {
if (val === 'clear') {
filter.value = cloneDeep(defaultFilter)