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 @@