From 2e6e5105cf558cca67b7c1e5b5f5686b635c1b6a Mon Sep 17 00:00:00 2001
From: zhenhui <1276357500@qq.com>
Date: Wed, 1 Apr 2026 16:37:16 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F-=E7=94=A8=E6=88=B7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86-=E4=BC=98=E5=8C=96=E8=A1=A8=E6=A0=BC=E5=92=8C?=
=?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/admin/controller/game/Channel.php | 85 ++++++++++++
web/src/views/backend/game/user/popupForm.vue | 121 ++++++++++++++----
2 files changed, 183 insertions(+), 23 deletions(-)
diff --git a/app/admin/controller/game/Channel.php b/app/admin/controller/game/Channel.php
index 684fabf..d191808 100644
--- a/app/admin/controller/game/Channel.php
+++ b/app/admin/controller/game/Channel.php
@@ -32,6 +32,91 @@ class Channel extends Backend
return null;
}
+ /**
+ * 渠道-管理员树(父级=渠道,子级=管理员,仅可选择子级)
+ */
+ public function adminTree(WebmanRequest $request): Response
+ {
+ $response = $this->initializeBackend($request);
+ if ($response !== null) return $response;
+
+ $channels = Db::name('game_channel')
+ ->field(['id', 'name', 'admin_group_id'])
+ ->order('id', 'asc')
+ ->select()
+ ->toArray();
+
+ $groupChildrenCache = [];
+ $getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
+ if ($groupId === null || $groupId === '') return [];
+ if (array_key_exists($groupId, $groupChildrenCache)) return $groupChildrenCache[$groupId];
+ $children = Db::name('admin_group')
+ ->where('pid', $groupId)
+ ->where('status', 1)
+ ->column('id');
+ $all = [];
+ foreach ($children as $cid) {
+ $all[] = $cid;
+ foreach ($getGroupChildren($cid) as $cc) {
+ $all[] = $cc;
+ }
+ }
+ $groupChildrenCache[$groupId] = $all;
+ return $all;
+ };
+
+ $tree = [];
+ foreach ($channels as $ch) {
+ $groupId = $ch['admin_group_id'] ?? null;
+ $groupIds = [];
+ if ($groupId !== null && $groupId !== '') {
+ $groupIds[] = $groupId;
+ foreach ($getGroupChildren($groupId) as $gid) {
+ $groupIds[] = $gid;
+ }
+ }
+
+ $adminIds = [];
+ if ($groupIds) {
+ $adminIds = Db::name('admin_group_access')
+ ->where('group_id', 'in', array_unique($groupIds))
+ ->column('uid');
+ }
+ $adminIds = array_values(array_unique($adminIds));
+
+ $admins = [];
+ if ($adminIds) {
+ $admins = Db::name('admin')
+ ->field(['id', 'username'])
+ ->where('id', 'in', $adminIds)
+ ->order('id', 'asc')
+ ->select()
+ ->toArray();
+ }
+
+ $children = [];
+ foreach ($admins as $a) {
+ $children[] = [
+ 'value' => (string) $a['id'],
+ 'label' => $a['username'],
+ 'channel_id' => $ch['id'],
+ 'is_leaf' => true,
+ ];
+ }
+
+ $tree[] = [
+ 'value' => 'channel_' . $ch['id'],
+ 'label' => $ch['name'],
+ 'disabled' => true,
+ 'children' => $children,
+ ];
+ }
+
+ return $this->success('', [
+ 'list' => $tree,
+ ]);
+ }
+
/**
* 添加(重写:管理员只选顶级组;admin_group_id 后端自动写入)
* @throws Throwable
diff --git a/web/src/views/backend/game/user/popupForm.vue b/web/src/views/backend/game/user/popupForm.vue
index 1bf626e..5efd849 100644
--- a/web/src/views/backend/game/user/popupForm.vue
+++ b/web/src/views/backend/game/user/popupForm.vue
@@ -75,22 +75,19 @@
prop="status"
:input-attr="{ content: { '0': t('game.user.status 0'), '1': t('game.user.status 1') } }"
/>
-
-
+
+
+
@@ -107,12 +104,13 @@