fix: Problem read permission

This commit is contained in:
zhangzhanwei 2025-08-05 11:45:42 +08:00 committed by zhanweizhang7
parent 3edc68471b
commit 1febd0a957
4 changed files with 39 additions and 4 deletions

View File

@ -150,8 +150,7 @@ const share = {
], ],
'OR' 'OR'
), ),
problem_read: () => false, problem_read: () =>
problem_relate: () =>
hasPermission ( hasPermission (
[ [
RoleConst.ADMIN, RoleConst.ADMIN,
@ -159,6 +158,14 @@ const share = {
], ],
'OR' 'OR'
), ),
problem_relate: () =>
hasPermission (
[
RoleConst.ADMIN,
PermissionConst.SHARED_KNOWLEDGE_PROBLEM_RELATE
],
'OR'
),
problem_delete: () => problem_delete: () =>
hasPermission ( hasPermission (
[ [

View File

@ -212,7 +212,16 @@ const workspace = {
] ]
,'OR' ,'OR'
), ),
problem_read: () => false, problem_read: (source_id:string) =>
hasPermission(
[
new ComplexPermission([RoleConst.USER],[PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(source_id)],[],'AND'),
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
PermissionConst.KNOWLEDGE_PROBLEM_READ.getKnowledgeWorkspaceResourcePermission(source_id),
PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermissionWorkspaceManageRole,
],
'OR',
),
problem_create: (source_id:string) => problem_create: (source_id:string) =>
hasPermission( hasPermission(
[ [

View File

@ -195,6 +195,7 @@ const PermissionConst = {
SHARED_KNOWLEDGE_PROBLEM_CREATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+CREATE'), SHARED_KNOWLEDGE_PROBLEM_CREATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+CREATE'),
SHARED_KNOWLEDGE_PROBLEM_EDIT: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+EDIT'), SHARED_KNOWLEDGE_PROBLEM_EDIT: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+EDIT'),
SHARED_KNOWLEDGE_PROBLEM_DELETE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+DELETE'), SHARED_KNOWLEDGE_PROBLEM_DELETE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+DELETE'),
SHARED_KNOWLEDGE_PROBLEM_RELATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+RELATE'),
SHARED_KNOWLEDGE_HIT_TEST_READ: new Permission('SYSTEM_KNOWLEDGE_HIT_TEST:READ'), SHARED_KNOWLEDGE_HIT_TEST_READ: new Permission('SYSTEM_KNOWLEDGE_HIT_TEST:READ'),
KNOWLEDGE_HIT_TEST_READ: new Permission('KNOWLEDGE_HIT_TEST:READ'), KNOWLEDGE_HIT_TEST_READ: new Permission('KNOWLEDGE_HIT_TEST:READ'),

View File

@ -37,6 +37,7 @@
<el-col :span="6" class="border-l" style="width: 300px"> <el-col :span="6" class="border-l" style="width: 300px">
<!-- 关联问题 --> <!-- 关联问题 -->
<ProblemComponent <ProblemComponent
v-if="permissionPrecise.problem_read(id)"
:paragraphId="paragraphId" :paragraphId="paragraphId"
:docId="document_id" :docId="document_id"
:knowledgeId="id" :knowledgeId="id"
@ -56,12 +57,14 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch, nextTick } from 'vue' import { ref, watch, nextTick, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { cloneDeep, debounce } from 'lodash' import { cloneDeep, debounce } from 'lodash'
import ParagraphForm from '@/views/paragraph/component/ParagraphForm.vue' import ParagraphForm from '@/views/paragraph/component/ParagraphForm.vue'
import ProblemComponent from '@/views/paragraph/component/ProblemComponent.vue' import ProblemComponent from '@/views/paragraph/component/ProblemComponent.vue'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api' import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import permissionMap from '@/permission'
const props = defineProps<{ const props = defineProps<{
title: String title: String
@ -73,6 +76,21 @@ const {
params: { id, documentId }, params: { id, documentId },
} = route as any } = route as any
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.query.from == 'systemManage') {
return 'systemManage'
} else {
return 'workspace'
}
})
const permissionPrecise = computed(() => {
return permissionMap['knowledge'][apiType.value]
})
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
const ProblemRef = ref() const ProblemRef = ref()