增加权限限制

This commit is contained in:
lai
2024-06-06 14:37:27 +08:00
parent 29e092421c
commit b7b66ad28d
2 changed files with 78 additions and 9 deletions

View File

@@ -65,7 +65,12 @@ function fnChangeLocale(e: any) {
<template>
<a-space :size="12" align="center">
<a-button type="text" style="color: inherit" @click="fnClickAlarm">
<a-button
type="text"
style="color: inherit"
@click="fnClickAlarm"
v-roles:has="['administrator']"
>
<template #icon>
<a-badge
:count="useAlarmStore().activeAlarmTotal"
@@ -89,7 +94,12 @@ function fnChangeLocale(e: any) {
<a-tooltip placement="bottom">
<template #title>{{ t('loayouts.rightContent.helpDoc') }}</template>
<a-button type="text" style="color: inherit" @click="fnClickHelpDoc()">
<a-button
type="text"
style="color: inherit"
@click="fnClickHelpDoc()"
v-roles:has="['administrator']"
>
<template #icon>
<QuestionCircleOutlined />
</template>

View File

@@ -23,6 +23,8 @@ import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import saveAs from 'file-saver';
import useUserStore from '@/store/modules/user';
const { t } = useI18n();
/**网元参数 */
@@ -34,6 +36,8 @@ let queryParams = reactive({
neId: undefined,
/**移动编号 */
imsi: '',
/**租户名 */
tenantName: '',
/**移动号 */
msisdn: '',
/**排序字段 */
@@ -51,6 +55,7 @@ function fnQueryReset() {
queryParams = Object.assign(queryParams, {
imsi: '',
msisdn: '',
tenantName: '',
sortField: 'imsi',
sortOrder: 'asc',
pageNum: 1,
@@ -147,6 +152,13 @@ let tableColumns: ColumnsType = [
align: 'center',
width: 100,
},
{
title: 'Tenant Name',
dataIndex: 'tenantName',
align: 'center',
key: 'tenantName',
width: 150,
},
{
title: 'Subscribed Data',
dataIndex: 'smData',
@@ -156,6 +168,7 @@ let tableColumns: ColumnsType = [
minWidth: 150,
maxWidth: 500,
},
{
title: t('common.operate'),
key: 'imsi',
@@ -1055,7 +1068,14 @@ function fnGetList(pageNum?: number) {
queryParams.pageNum = pageNum;
tablePagination.current = pageNum;
}
listSub(toRaw(queryParams)).then(res => {
const selectFrom = Object.assign({}, toRaw(queryParams));
//权限为租户时 需带租户名称
if (useUserStore().roles.includes('tenant')) {
selectFrom.tenantName = useUserStore().userName;
}
listSub(selectFrom).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
@@ -1195,6 +1215,15 @@ onMounted(() => {
}
})
.finally(() => {
console.log(useUserStore().roles);
if (useUserStore().roles.includes('tenant')) {
const operateColumnIndex = tableColumns.findIndex(
column => column.key === 'tenantName'
);
if (operateColumnIndex !== -1) {
tableColumns.splice(operateColumnIndex, 1);
}
}
// 获取列表数据
fnGetList();
});
@@ -1211,7 +1240,7 @@ onMounted(() => {
<!-- 表格搜索栏 -->
<a-form :model="queryParams" name="queryParams" layout="horizontal">
<a-row :gutter="16">
<a-col :lg="6" :md="12" :xs="24">
<a-col :lg="6" :md="12" :xs="24" v-roles:has="['administrator']">
<a-form-item :label="t('views.neUser.sub.neType')" name="neId ">
<a-select
v-model:value="queryParams.neId"
@@ -1249,6 +1278,20 @@ onMounted(() => {
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16" v-roles:has="['administrator']">
<a-col :lg="6" :md="12" :xs="24">
<a-form-item
:label="t('views.neUser.sub.tenantName')"
name="tenantName "
>
<a-input
v-model:value="queryParams.tenantName"
allow-clear
></a-input>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
@@ -1256,14 +1299,22 @@ onMounted(() => {
<!-- 插槽-卡片左侧侧 -->
<template #title>
<div class="button-container">
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
<a-button
type="primary"
@click.prevent="fnModalVisibleByEdit()"
v-perms:has="['neUser:subs:add']"
>
<template #icon>
<PlusOutlined />
</template>
{{ t('common.addText') }}
</a-button>
<a-button type="primary" @click.prevent="fnModalVisibleByBatch(1)">
<a-button
type="primary"
@click.prevent="fnModalVisibleByBatch(1)"
v-perms:has="['neUser:subs:batchAdd']"
>
<template #icon>
<PlusOutlined />
</template>
@@ -1276,6 +1327,7 @@ onMounted(() => {
:disabled="tableState.selectedRowKeys.length <= 0"
:loading="modalState.loadDataLoading"
@click.prevent="fnRecordDelete('0')"
v-perms:has="['neUser:subs:checkDel']"
>
<template #icon><DeleteOutlined /></template>
{{ t('views.neUser.sub.checkDel') }}
@@ -1286,6 +1338,7 @@ onMounted(() => {
danger
ghost
@click.prevent="fnModalVisibleByBatch(0)"
v-perms:has="['neUser:subs:batchDel']"
>
<template #icon>
<DeleteOutlined />
@@ -1305,6 +1358,7 @@ onMounted(() => {
danger
:disabled="modalState.loadDataLoading"
:loading="modalState.loadDataLoading"
v-perms:has="['neUser:subs:load']"
>
<template #icon>
<SyncOutlined />
@@ -1313,7 +1367,11 @@ onMounted(() => {
</a-button>
</a-popconfirm>
<a-button type="dashed" @click.prevent="fnModalUploadImportOpen">
<a-button
type="dashed"
@click.prevent="fnModalUploadImportOpen"
v-perms:has="['neUser:subs:import']"
>
<template #icon>
<ImportOutlined />
</template>
@@ -1330,7 +1388,7 @@ onMounted(() => {
cancel-text="CSV"
@cancel="fnExportList('csv')"
>
<a-button type="dashed">
<a-button type="dashed" v-perms:has="['neUser:subs:export']">
<template #icon>
<ExportOutlined />
</template>
@@ -1352,6 +1410,7 @@ onMounted(() => {
<a-button
type="default"
:disabled="tableState.selectedRowKeys.length <= 0"
v-perms:has="['neUser:subs:checkExport']"
>
<template #icon><ExportOutlined /></template>
{{ t('views.neUser.sub.checkExport') }}
@@ -1430,7 +1489,7 @@ onMounted(() => {
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'imsi'">
<a-space :size="8" align="center">
<a-space :size="8" align="center" v-roles:has="['administrator']">
<a-tooltip>
<template #title>{{ t('common.editText') }}</template>
<a-button