UX-2(操作级权限控制)

This commit is contained in:
Cheng Zhou
2025-12-17 15:11:02 +08:00
parent dd51f56707
commit 9ca30d12f8
29 changed files with 288 additions and 131 deletions
+11 -8
View File
@@ -3,7 +3,9 @@
<el-card class="mb-12">
<div class="actions">
<h3>里程碑</h3>
<el-button type="primary" v-if="canEdit" @click="openCreate">新增里程碑</el-button>
<PermissionAction action="milestone.create">
<el-button type="primary" @click="openCreate">新增里程碑</el-button>
</PermissionAction>
</div>
</el-card>
@@ -15,9 +17,11 @@
<el-table-column prop="actual_date" label="实际日期" width="140" />
<el-table-column prop="status" label="状态" width="140" />
<el-table-column prop="owner_id" label="负责人" width="160" />
<el-table-column label="操作" width="120" v-if="canEdit">
<el-table-column label="操作" width="120">
<template #default="scope">
<el-button type="primary" link size="small" @click="openEdit(scope.row)">编辑</el-button>
<PermissionAction action="milestone.create">
<el-button type="primary" link size="small" @click="openEdit(scope.row)">编辑</el-button>
</PermissionAction>
</template>
</el-table-column>
</el-table>
@@ -28,23 +32,22 @@
</template>
<script setup lang="ts">
import { onMounted, ref, computed } from "vue";
import { onMounted, ref } from "vue";
import { ElMessage } from "element-plus";
import { fetchMilestones } from "../api/milestones";
import { useStudyStore } from "../store/study";
import { useAuthStore } from "../store/auth";
import PermissionAction from "../components/PermissionAction.vue";
import { usePermission } from "../utils/permission";
import MilestoneForm from "../components/MilestoneForm.vue";
const study = useStudyStore();
const auth = useAuthStore();
const { can } = usePermission();
const milestones = ref<any[]>([]);
const loading = ref(false);
const showForm = ref(false);
const editingMilestone = ref<any | null>(null);
const canEdit = computed(() => auth.user?.role === "ADMIN" || auth.user?.role === "PM");
const loadMilestones = async () => {
if (!study.currentStudy) return;
loading.value = true;