浏览代码

用户不能操作被分享APP

hzx 1 周之前
父节点
当前提交
e66814ae64

+ 20 - 0
src/views/main/userModule/relieveLogsList.vue

@@ -86,6 +86,8 @@ const store = useStore()
 const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
 const form = ref(null);
 const tableData = ref([]);
+// 用户分享的渠道AppiD
+//const shareAppIds = ref([]);
 
 // 分页参数, 供table使用
 const page = reactive({
@@ -159,6 +161,19 @@ const getApiOptions = async () => {
       value: item.ditchId
     }))
 
+    // const currentUserId = store.state.user.info.userId
+    // ditchData.forEach(item => {
+    //   // 检查是否满足条件:sharedUserId 等于当前登录用户的 userId
+    //   if (item.sharedUserId === currentUserId) {
+    //     // 将符合条件的 appId 添加到 shareAppIds 数组中
+    //     shareAppIds.value.push(item.appId)
+    //   }
+    // })
+
+    // // 去重,避免重复添加相同的 appId
+    // shareAppIds.value = [...new Set(shareAppIds.value)]
+    // console.log("分享的appId",shareAppIds)  
+
     // 赋值到表单项
     dynamicFormItems.value[2].options = ditchOptions
 
@@ -246,6 +261,11 @@ const formEdit = ref({
 })
 
 const edit = (row) => {
+  // 检查权限
+  // if (shareAppIds.value.includes(row.appId)) {
+  //   ElMessage.warning('您没有权限修改此应用下的用户状态')
+  //   return
+  // }
   ruleForm.value?.resetFields()
   layer.value.show = true
 

+ 41 - 0
src/views/main/userModule/riskLogsList.vue

@@ -55,6 +55,27 @@
             {{ convertUTCToBeijing(scope.row.registryTime) }}
           </template>
         </el-table-column>
+        
+        <!-- <el-table-column label="操作" width="150" fixed="right">
+          <template #default="scope">
+            <div class="button">
+              <el-tooltip 
+                :content="shareAppIds.includes(scope.row.appId) ? '您没有权限解封此应用下的用户' : '用户解封'"
+                placement="top"
+              >
+                <el-button 
+                  class="button-item" 
+                  type="primary" 
+                  style="margin-bottom: 5px;" 
+                  @click="editUserType(scope.row)"
+                  :disabled="shareAppIds.includes(scope.row.appId)"
+                >
+                解封
+                </el-button>
+              </el-tooltip>
+            </div>
+          </template>
+        </el-table-column>   -->
       </Table>
     </div>
 
@@ -88,6 +109,8 @@
   const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
   const form = ref(null);
   const tableData = ref([]);
+  // 用户分享的渠道AppiD
+  //const shareAppIds = ref([]);
 
   // 分页参数, 供table使用
   const page = reactive({
@@ -166,6 +189,19 @@ const getApiOptions = async () => {
     // 赋值到表单项
     dynamicFormItems.value[3].options = ditchOptions
 
+    // const currentUserId = store.state.user.info.userId
+    // ditchData.forEach(item => {
+    //   // 检查是否满足条件:sharedUserId 等于当前登录用户的 userId
+    //   if (item.sharedUserId === currentUserId) {
+    //     // 将符合条件的 appId 添加到 shareAppIds 数组中
+    //     shareAppIds.value.push(item.appId)
+    //   }
+    // })
+    // // 去重,避免重复添加相同的 appId
+    // shareAppIds.value = [...new Set(shareAppIds.value)]
+    // console.log("分享的appId",shareAppIds)
+
+
     // 获取列表数据
     getList()
   } catch (err) {
@@ -259,6 +295,11 @@ const getApiOptions = async () => {
   })
 
   const editUserType = (row) => {
+    // 检查权限
+    // if (shareAppIds.value.includes(row.appId)) {
+    //   ElMessage.warning('您没有权限解封此应用下的用户')
+    //   return
+    // }
     ruleForm.value?.resetFields()
     layer.value.show = true
     layer.value.title = `解封用户${row.nickName}`

+ 23 - 9
src/views/main/userModule/userList.vue

@@ -7,13 +7,13 @@
     <div class="btn">
       <el-button type="" v-if="formSearch.appIds && selectData.length > 0" @click="clearSelection">取消全选</el-button>
       <!-- <el-button type="primary" :disabled="!selectData.length > 0" @click="userCheck">批量审核</el-button> -->
-      <el-button type="danger" :disabled="!selectData.length > 0" @click="edit({}, 2)">批量封禁母包</el-button>
-      <el-button type="danger" :disabled="!selectData.length > 0" @click="edit({}, 1)">批量封禁</el-button>
-      <el-button type="danger" :disabled="!selectData.length > 0" @click="edit({}, 3)">批量封禁IP</el-button>
-      <el-button type="primary" :disabled="!selectData.length > 0" @click="editUserType({}, true)">批量解封</el-button>
-      <el-button type="success" :disabled="!selectData.length > 0" @click="exportUserList">批量导出</el-button>
-      <el-tooltip class="box-item" effect="dark" content="慎用 比较占用服务器资源!!! 导出数量(根据左下角条数)" placement="bottom">
-        <el-button type="warning" :disabled="!page.total > 0" @click="allExportUserList">全部导出</el-button>
+      <el-button type="danger" v-if="appShare" :disabled="!selectData.length > 0" @click="edit({}, 2)">批量封禁母包</el-button>
+      <el-button type="danger" v-if="appShare" :disabled="!selectData.length > 0" @click="edit({}, 1)">批量封禁</el-button>
+      <el-button type="danger" v-if="appShare" :disabled="!selectData.length > 0" @click="edit({}, 3)">批量封禁IP</el-button>
+      <el-button type="primary" v-if="appShare" :disabled="!selectData.length > 0" @click="editUserType({}, true)">批量解封</el-button>
+      <el-button type="success" v-if="appShare" :disabled="!selectData.length > 0" @click="exportUserList">批量导出</el-button>
+      <el-tooltip class="box-item" v-if="appShare" effect="dark" content="慎用 比较占用服务器资源!!! 导出数量(根据左下角条数)" placement="bottom">
+        <el-button type="warning"  :disabled="!page.total > 0" @click="allExportUserList">全部导出</el-button>
       </el-tooltip>
     </div>
 
@@ -204,6 +204,9 @@ const { loadDictData, getOptions, getDictionaryName } = useGetDictList();
 const tableData = ref([]);
 const table = ref(null)
 const appType = ref(1)
+const appShare = ref(false);
+// 新增:存储所有应用选项的响应式变量
+const allAppsOptions = ref([]);
 
 // 分页参数, 供table使用
 const page = reactive({
@@ -315,8 +318,10 @@ const getApiOptions = async () => {
     const appsOptions = appData.map(item => ({
       label: item.appName,
       value: item.appId,
-      appType: item.appType
+      appType: item.appType,
+      appUserId: item.userId
     }))
+    allAppsOptions.value = appsOptions;
 
     // 赋值到表单项
     dynamicFormItems.value[3].options = ditchOptions
@@ -329,6 +334,9 @@ const getApiOptions = async () => {
       dynamicFormItems.value[2].defaultVal = firstApp.value
       formSearch.value.appIds = firstApp.value
 
+      // 判断第一个应用是否属于当前用户
+      appShare.value = appsOptions[0].appUserId == store.state.user.info.userId;
+
       dynamicFormItemsTarget.value = appsOptions[0].appType === 1
         ? dynamicFormItems.value.slice(0, 7)
         : dynamicFormItems.value
@@ -433,11 +441,17 @@ const handleFormReset = () => {
 
 const handleFormSelect = (item, e) => {
   if (item.prop === 'appIds') {
+    // 查找选中的应用信息
+    const selectedApp = allAppsOptions.value.find(app => app.value === e);
+    if (selectedApp) {
+      // 判断选中的应用是否属于当前用户
+      appShare.value = selectedApp.appUserId == store.state.user.info.userId;
+    } 
+
     const options = item.options
     // appType 1-安卓 2-IOS
     const appTypeNum = options.find((item) => item.value === e).appType
 
-
     dynamicFormItems.value[0].defaultVal = formSearch.value.nickName
     dynamicFormItems.value[1].defaultVal = formSearch.value.userId
     dynamicFormItems.value[2].defaultVal = e