Quellcode durchsuchen

feat(user): 添加运营用户角色并实现相关功能

- 在 UserRole枚举中添加 operator 角色
- 在 main.js 中提供 isOperator 计算属性,用于判断当前用户是否为运营角色
wui vor 9 Monaten
Ursprung
Commit
0382f6f4a4
4 geänderte Dateien mit 61 neuen und 32 gelöschten Zeilen
  1. 1 1
      src/router/index.js
  2. 30 3
      src/views/MainView.vue
  3. 2 1
      src/views/OcrChannelView.vue
  4. 28 27
      src/views/OcrFavoriteView.vue

+ 1 - 1
src/router/index.js

@@ -97,7 +97,7 @@ const router = createRouter({
                     name: 'ocrFavorite',
                     name: 'ocrFavorite',
                     component: () => import('../views/OcrFavoriteView.vue'),
                     component: () => import('../views/OcrFavoriteView.vue'),
                     meta: {
                     meta: {
-                        title: '收藏列表'
+                        title: '观察列表'
                     }
                     }
                 },
                 },
                 {
                 {

+ 30 - 3
src/views/MainView.vue

@@ -132,7 +132,7 @@ if (user.role === 'admin') {
                 },
                 },
                 {
                 {
                     name: 'ocrFavorite',
                     name: 'ocrFavorite',
-                    title: '收藏列表'
+                    title: '观察列表'
                 },
                 },
                 {
                 {
                     name: 'ocrDevice',
                     name: 'ocrDevice',
@@ -155,7 +155,7 @@ if (user.role === 'admin') {
             icon: Fish
             icon: Fish
         }
         }
     ]
     ]
-} else if (user.role === 'api') {
+} else if (user.role === 'operator') {
     menus = [
     menus = [
         {
         {
             name: 'home',
             name: 'home',
@@ -173,7 +173,34 @@ if (user.role === 'admin') {
                 },
                 },
                 {
                 {
                     name: 'ocrFavorite',
                     name: 'ocrFavorite',
-                    title: '收藏列表'
+                    title: '观察列表'
+                },
+                {
+                    name: 'ocrDevice',
+                    title: '设备列表'
+                },
+                {
+                    name: 'ocrChannel',
+                    title: '渠道数据'
+                }
+            ]
+        }
+    ]
+} else if (user.role === 'api') {
+    menus = [
+        {
+            name: 'home',
+            title: '主页',
+            icon: Home
+        },
+        {
+            name: 'ocr-parent',
+            title: 'OCR管理',
+            icon: TextResize,
+            children: [
+                {
+                    name: 'ocrFavorite',
+                    title: '观察列表'
                 },
                 },
                 {
                 {
                     name: 'ocrDevice',
                     name: 'ocrDevice',

+ 2 - 1
src/views/OcrChannelView.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-    <PagingTable v-if="isAdmin" url="/ocrChannel" :query="query" ref="table">
+    <PagingTable v-if="isAdmin || isOperator" url="/ocrChannel" :query="query" ref="table">
         <template #filter>
         <template #filter>
             <ElInput class="!w-52" placeholder="请输入" clearable v-model="query.id" @keyup.enter="table.refresh(true)">
             <ElInput class="!w-52" placeholder="请输入" clearable v-model="query.id" @keyup.enter="table.refresh(true)">
                 <template #append>
                 <template #append>
@@ -73,6 +73,7 @@ const rules = {
 }
 }
 const isAdmin = inject('isAdmin')
 const isAdmin = inject('isAdmin')
 const isApi = inject('isApi')
 const isApi = inject('isApi')
+const isOperator = inject('isOperator')
 const tableData = ref([])
 const tableData = ref([])
 
 
 onMounted(() => {
 onMounted(() => {

+ 28 - 27
src/views/OcrFavoriteView.vue

@@ -59,40 +59,40 @@
                         <div v-for="(value, key) in JSON.parse(row.detail)" :key="key">
                         <div v-for="(value, key) in JSON.parse(row.detail)" :key="key">
                             <strong
                             <strong
                                 style="
                                 style="
-                            margin-left: 3px;
-                            background-color: #f56c6c;
-                            padding: 2px 4px;
-                            border-radius: 5px;
-                            flex-grow: 1;
-                            text-align: center;
-                            white-space: nowrap;
-                        "
-                            >{{ key }}</strong
+                                    margin-left: 3px;
+                                    background-color: #f56c6c;
+                                    padding: 2px 4px;
+                                    border-radius: 5px;
+                                    flex-grow: 1;
+                                    text-align: center;
+                                    white-space: nowrap;
+                                "
+                                >{{ key }}</strong
                             >
                             >
                             <span
                             <span
                                 style="
                                 style="
-                            background-color: #e0f7fa;
-                            color: #00796b;
-                            padding: 5px 10px;
-                            border-radius: 5px;
-                            white-space: nowrap;
-                            margin-left: 3px;
-                            cursor: pointer;
-                        "
+                                    background-color: #e0f7fa;
+                                    color: #00796b;
+                                    padding: 5px 10px;
+                                    border-radius: 5px;
+                                    white-space: nowrap;
+                                    margin-left: 3px;
+                                    cursor: pointer;
+                                "
                                 @click="copyText(value.address)"
                                 @click="copyText(value.address)"
                                 :title="'点击复制地址: ' + value.address"
                                 :title="'点击复制地址: ' + value.address"
-                            >{{ value.address }}</span
+                                >{{ value.address }}</span
                             >
                             >
                             <span
                             <span
                                 style="
                                 style="
-                            background-color: #f1f8e9;
-                            color: #388e3c;
-                            padding: 5px 10px;
-                            border-radius: 5px;
-                            white-space: nowrap;
-                            margin-left: 3px;
-                        "
-                            >{{ value.balance }}</span
+                                    background-color: #f1f8e9;
+                                    color: #388e3c;
+                                    padding: 5px 10px;
+                                    border-radius: 5px;
+                                    white-space: nowrap;
+                                    margin-left: 3px;
+                                "
+                                >{{ value.balance }}</span
                             >
                             >
                         </div>
                         </div>
                     </div>
                     </div>
@@ -114,7 +114,7 @@
                 <!--                <div v-html="formatRecord(row.record)"></div>-->
                 <!--                <div v-html="formatRecord(row.record)"></div>-->
             </template>
             </template>
         </ElTableColumn>
         </ElTableColumn>
-        <ElTableColumn prop="favorite" label="收藏" align="center" width="60">
+        <ElTableColumn v-if="isAdmin || isOperator" prop="favorite" label="收藏" align="center" width="60">
             <template #default="{ row }">
             <template #default="{ row }">
                 <ElButton
                 <ElButton
                     circle
                     circle
@@ -169,6 +169,7 @@ const model = ref({})
 const { showEditDialog } = setupEditDialog(model)
 const { showEditDialog } = setupEditDialog(model)
 const { copy } = useClipboard({ legacy: true })
 const { copy } = useClipboard({ legacy: true })
 const isAdmin = inject('isAdmin')
 const isAdmin = inject('isAdmin')
+const isOperator = inject('isOperator')
 
 
 function formatRecord(record) {
 function formatRecord(record) {
     return record
     return record