UX-2(操作级权限控制)
This commit is contained in:
@@ -22,7 +22,9 @@
|
||||
@change="load"
|
||||
/>
|
||||
<div class="spacer" />
|
||||
<el-button type="primary" v-if="canEdit" @click="showForm = true">新增交易</el-button>
|
||||
<PermissionAction action="imp.transaction">
|
||||
<el-button type="primary" @click="showForm = true">新增交易</el-button>
|
||||
</PermissionAction>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card>
|
||||
@@ -55,6 +57,8 @@ import { fetchImpTransactions } from "../api/impTransactions";
|
||||
import { fetchImpBatches } from "../api/impBatches";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import { useAuthStore } from "../store/auth";
|
||||
import PermissionAction from "../components/PermissionAction.vue";
|
||||
import { usePermission } from "../utils/permission";
|
||||
import ImpTransactionForm from "../components/ImpTransactionForm.vue";
|
||||
|
||||
const study = useStudyStore();
|
||||
@@ -70,10 +74,8 @@ const loading = ref(false);
|
||||
const showForm = ref(false);
|
||||
const batches = ref<any[]>([]);
|
||||
|
||||
const canEdit = computed(() => {
|
||||
const role = auth.user?.role;
|
||||
return role === "ADMIN" || role === "PM" || role === "IMP";
|
||||
});
|
||||
const { can } = usePermission();
|
||||
const canEdit = computed(() => can("imp.transaction"));
|
||||
|
||||
const loadBatches = async () => {
|
||||
if (!study.currentStudy) return;
|
||||
|
||||
Reference in New Issue
Block a user