更新工作流权限逻辑
- 根据用户角色(超级管理员与普通管理员)调整工作流的使用和编辑权限,确保超级管理员只能编辑工作流,无法进入创作模式。 - 新增对用户角色的检查,优化工作流列表的点击事件处理,提升用户体验和权限管理的清晰度。
This commit is contained in:
@@ -410,7 +410,7 @@
|
||||
:key="workflow.id"
|
||||
class="workflow-item"
|
||||
:class="{ active: currentEditingWorkflowId === workflow.id }"
|
||||
@click="useWorkflow(workflow)"
|
||||
@click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)"
|
||||
>
|
||||
<div class="workflow-item-content">
|
||||
<div class="workflow-item-name">{{ workflow.flowName }}</div>
|
||||
@@ -418,6 +418,7 @@
|
||||
</div>
|
||||
<div class="workflow-item-actions">
|
||||
<el-button type="primary" link size="small" @click.stop="editWorkflow(workflow)">编辑</el-button>
|
||||
<el-button v-if="!isSuperAdmin" type="success" link size="small" @click.stop="useWorkflow(workflow)">使用</el-button>
|
||||
<el-button type="danger" link size="small" @click.stop="deleteWorkflowAction(workflow)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -444,14 +445,14 @@
|
||||
<div class="workflow-list-vertical" v-loading="workflowListLoading">
|
||||
<el-empty v-if="!workflowListLoading && templateWorkflowList.length === 0" description="暂无模板" :image-size="60" />
|
||||
<div v-else class="workflow-list-scroll">
|
||||
<div v-for="workflow in templateWorkflowList" :key="workflow.id" class="workflow-item" @click="useWorkflow(workflow)">
|
||||
<div v-for="workflow in templateWorkflowList" :key="workflow.id" class="workflow-item" @click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)">
|
||||
<div class="workflow-item-content">
|
||||
<div class="workflow-item-name">{{ workflow.flowName || workflow.flowTemplateName }}</div>
|
||||
<div class="workflow-item-desc">{{ workflow.description || '暂无描述' }}</div>
|
||||
</div>
|
||||
<div class="workflow-item-actions">
|
||||
<el-button type="primary" link size="small" @click.stop="editWorkflow(workflow)">编辑</el-button>
|
||||
<el-button type="success" link size="small" @click.stop="useWorkflow(workflow)">使用</el-button>
|
||||
<el-button v-if="!isSuperAdmin" type="success" link size="small" @click.stop="useWorkflow(workflow)">使用</el-button>
|
||||
<el-button v-if="isAdmin" type="danger" link size="small" @click.stop="deleteWorkflowAction(workflow)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -584,6 +585,7 @@ import {
|
||||
} from '/@/api/digitalHuman/creation';
|
||||
import { uploadFile } from '/@/api/common/upload';
|
||||
import { getModelModuleList, updateChatModel, getIsChatModel } from '/@/api/digitalHuman/modelConfig/modelModule';
|
||||
import { checkIsSuperAdmin } from '/@/api/system/user';
|
||||
|
||||
type NodeType = 'date' | 'contentType' | 'theme' | 'title' | 'html' | 'image';
|
||||
type Item = Record<string, any>;
|
||||
@@ -631,6 +633,7 @@ const workflowTab = ref('user'); // 工作流 Tab:user 或 template
|
||||
const userWorkflowList = ref<WorkflowItem[]>([]); // 用户工作流列表
|
||||
const templateWorkflowList = ref<WorkflowItem[]>([]); // 模板工作流列表
|
||||
const isAdmin = ref(false); // 是否为管理员
|
||||
const isSuperAdmin = ref(false); // 是否为超级管理员(管理员只能编辑,不能创作)
|
||||
const userWorkflowPagination = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -1050,6 +1053,12 @@ const handleSetChatModel = async () => {
|
||||
};
|
||||
// 使用工作流
|
||||
const useWorkflow = async (workflow: WorkflowItem) => {
|
||||
// 管理员权限检查:管理员只能编辑,不能进入创作模式
|
||||
if (isSuperAdmin.value) {
|
||||
ElMessage.warning('管理员只能查看和编辑工作流,不能进入创作模式');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用详情接口获取最新的工作流数据
|
||||
const res = await getWorkflowDetail(workflow.id);
|
||||
@@ -1337,6 +1346,12 @@ const getFieldClass = (type: string) => {
|
||||
const handleTreeNodeClick = async (data: TreeNode) => {
|
||||
// 只处理工作流节点(contentType)
|
||||
if (data.nodeType === 'contentType' && data.workflowId) {
|
||||
// 管理员权限检查:管理员只能编辑,不能进入创作模式
|
||||
if (isSuperAdmin.value) {
|
||||
ElMessage.warning('管理员只能查看和编辑工作流,不能进入创作模式');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 从工作空间进入,使用 execution/get 接口获取执行详情
|
||||
const res = await getExecutionDetail(String(data.workflowId));
|
||||
@@ -2370,6 +2385,14 @@ onMounted(async () => {
|
||||
initLogicFlow();
|
||||
await getNodeLibrary();
|
||||
await fetchWorkflowList();
|
||||
|
||||
// 获取当前用户角色
|
||||
try {
|
||||
const res = await checkIsSuperAdmin();
|
||||
isSuperAdmin.value = res.data || false;
|
||||
} catch (error) {
|
||||
isSuperAdmin.value = false;
|
||||
}
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
logicFlowInstance.value?.destroy();
|
||||
|
||||
Reference in New Issue
Block a user