From 9c03b92e4cf08c434112f85c4f945a59b6a78e2c Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Thu, 2 Apr 2026 11:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E4=BF=A1=E6=81=AF=E5=B1=95=E7=A4=BA-=E5=8F=AA?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8B=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/game/Channel.php | 24 +++++++++++++++---- .../views/backend/game/channel/popupForm.vue | 15 ++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/game/Channel.php b/app/admin/controller/game/Channel.php index fdd100f..5cec95c 100644 --- a/app/admin/controller/game/Channel.php +++ b/app/admin/controller/game/Channel.php @@ -26,6 +26,12 @@ class Channel extends Backend protected string|array $quickSearchField = ['id', 'code', 'name']; + /** + * 非超级管理员仅能操作 game_channel.admin_id 为当前账号的渠道;超管不限制 + * @see \app\common\controller\Backend::getDataLimitAdminIds() + */ + protected bool|string|int $dataLimit = true; + /** * adminTree 为辅助接口,默认权限节点名 game/channel/admintree 往往未在后台录入; * 与列表权限 game/channel/index 对齐,避免子管理员已勾「渠道管理」仍 401。 @@ -50,11 +56,13 @@ class Channel extends Backend return $this->error(__('You have no permission')); } - $channels = Db::name('game_channel') + $channelQuery = Db::name('game_channel') ->field(['id', 'name', 'admin_group_id']) - ->order('id', 'asc') - ->select() - ->toArray(); + ->order('id', 'asc'); + if (!$this->auth->isSuperAdmin()) { + $channelQuery->where('admin_id', $this->auth->id); + } + $channels = $channelQuery->select()->toArray(); $groupChildrenCache = []; $getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) { @@ -142,6 +150,10 @@ class Channel extends Backend $data = $this->applyInputFilter($data); $data = $this->excludeFields($data); + if (!$this->auth->isSuperAdmin()) { + $data['admin_id'] = $this->auth->id; + } + $adminId = $data['admin_id'] ?? null; if ($adminId === null || $adminId === '') { return $this->error(__('Parameter %s can not be empty', ['admin_id'])); @@ -228,6 +240,10 @@ class Channel extends Backend unset($data['admin_group_id']); } + if (!$this->auth->isSuperAdmin()) { + unset($data['admin_id']); + } + $nextAdminId = array_key_exists('admin_id', $data) ? $data['admin_id'] : ($row['admin_id'] ?? null); if ($nextAdminId !== null && $nextAdminId !== '') { $topGroupId = Db::name('admin_group_access') diff --git a/web/src/views/backend/game/channel/popupForm.vue b/web/src/views/backend/game/channel/popupForm.vue index bfa5ceb..9c6a08b 100644 --- a/web/src/views/backend/game/channel/popupForm.vue +++ b/web/src/views/backend/game/channel/popupForm.vue @@ -61,6 +61,7 @@ :placeholder="t('Please input field', { field: t('game.channel.remark') })" /> import type { FormItemRule } from 'element-plus' -import { inject, reactive, useTemplateRef } from 'vue' +import { computed, inject, useTemplateRef } from 'vue' import { useI18n } from 'vue-i18n' import FormItem from '/@/components/formItem/index.vue' import { useConfig } from '/@/stores/config' +import { useAdminInfo } from '/@/stores/adminInfo' import type baTableClass from '/@/utils/baTable' import { buildValidatorData } from '/@/utils/validate' const config = useConfig() const formRef = useTemplateRef('formRef') const baTable = inject('baTable') as baTableClass +const adminInfo = useAdminInfo() const { t } = useI18n() -const rules: Partial> = reactive({ +const isSuperAdmin = computed(() => adminInfo.super === true) + +const rules = computed>>(() => ({ code: [buildValidatorData({ name: 'required', title: t('game.channel.code') })], name: [buildValidatorData({ name: 'required', title: t('game.channel.name') })], user_count: [buildValidatorData({ name: 'integer', title: t('game.channel.user_count') })], profit_amount: [buildValidatorData({ name: 'float', title: t('game.channel.profit_amount') })], - admin_id: [buildValidatorData({ name: 'required', title: t('game.channel.admin_id') })], + admin_id: isSuperAdmin.value + ? [buildValidatorData({ name: 'required', title: t('game.channel.admin_id') })] + : [], create_time: [buildValidatorData({ name: 'date', title: t('game.channel.create_time') })], update_time: [buildValidatorData({ name: 'date', title: t('game.channel.update_time') })], -}) +}))