优化游戏渠道信息展示-只显示下级
This commit is contained in:
@@ -26,6 +26,12 @@ class Channel extends Backend
|
|||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
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 往往未在后台录入;
|
* adminTree 为辅助接口,默认权限节点名 game/channel/admintree 往往未在后台录入;
|
||||||
* 与列表权限 game/channel/index 对齐,避免子管理员已勾「渠道管理」仍 401。
|
* 与列表权限 game/channel/index 对齐,避免子管理员已勾「渠道管理」仍 401。
|
||||||
@@ -50,11 +56,13 @@ class Channel extends Backend
|
|||||||
return $this->error(__('You have no permission'));
|
return $this->error(__('You have no permission'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$channels = Db::name('game_channel')
|
$channelQuery = Db::name('game_channel')
|
||||||
->field(['id', 'name', 'admin_group_id'])
|
->field(['id', 'name', 'admin_group_id'])
|
||||||
->order('id', 'asc')
|
->order('id', 'asc');
|
||||||
->select()
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
->toArray();
|
$channelQuery->where('admin_id', $this->auth->id);
|
||||||
|
}
|
||||||
|
$channels = $channelQuery->select()->toArray();
|
||||||
|
|
||||||
$groupChildrenCache = [];
|
$groupChildrenCache = [];
|
||||||
$getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
|
$getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
|
||||||
@@ -142,6 +150,10 @@ class Channel extends Backend
|
|||||||
$data = $this->applyInputFilter($data);
|
$data = $this->applyInputFilter($data);
|
||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
|
|
||||||
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
$data['admin_id'] = $this->auth->id;
|
||||||
|
}
|
||||||
|
|
||||||
$adminId = $data['admin_id'] ?? null;
|
$adminId = $data['admin_id'] ?? null;
|
||||||
if ($adminId === null || $adminId === '') {
|
if ($adminId === null || $adminId === '') {
|
||||||
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
||||||
@@ -228,6 +240,10 @@ class Channel extends Backend
|
|||||||
unset($data['admin_group_id']);
|
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);
|
$nextAdminId = array_key_exists('admin_id', $data) ? $data['admin_id'] : ($row['admin_id'] ?? null);
|
||||||
if ($nextAdminId !== null && $nextAdminId !== '') {
|
if ($nextAdminId !== null && $nextAdminId !== '') {
|
||||||
$topGroupId = Db::name('admin_group_access')
|
$topGroupId = Db::name('admin_group_access')
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
:placeholder="t('Please input field', { field: t('game.channel.remark') })"
|
:placeholder="t('Please input field', { field: t('game.channel.remark') })"
|
||||||
/>
|
/>
|
||||||
<FormItem
|
<FormItem
|
||||||
|
v-if="isSuperAdmin"
|
||||||
:label="t('game.channel.admin_id')"
|
:label="t('game.channel.admin_id')"
|
||||||
type="remoteSelect"
|
type="remoteSelect"
|
||||||
v-model="baTable.form.items!.admin_id"
|
v-model="baTable.form.items!.admin_id"
|
||||||
@@ -84,28 +85,34 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormItemRule } from 'element-plus'
|
import type { FormItemRule } from 'element-plus'
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
import { computed, inject, useTemplateRef } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
import FormItem from '/@/components/formItem/index.vue'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
|
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
import { buildValidatorData } from '/@/utils/validate'
|
import { buildValidatorData } from '/@/utils/validate'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const formRef = useTemplateRef('formRef')
|
const formRef = useTemplateRef('formRef')
|
||||||
const baTable = inject('baTable') as baTableClass
|
const baTable = inject('baTable') as baTableClass
|
||||||
|
const adminInfo = useAdminInfo()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
const isSuperAdmin = computed(() => adminInfo.super === true)
|
||||||
|
|
||||||
|
const rules = computed<Partial<Record<string, FormItemRule[]>>>(() => ({
|
||||||
code: [buildValidatorData({ name: 'required', title: t('game.channel.code') })],
|
code: [buildValidatorData({ name: 'required', title: t('game.channel.code') })],
|
||||||
name: [buildValidatorData({ name: 'required', title: t('game.channel.name') })],
|
name: [buildValidatorData({ name: 'required', title: t('game.channel.name') })],
|
||||||
user_count: [buildValidatorData({ name: 'integer', title: t('game.channel.user_count') })],
|
user_count: [buildValidatorData({ name: 'integer', title: t('game.channel.user_count') })],
|
||||||
profit_amount: [buildValidatorData({ name: 'float', title: t('game.channel.profit_amount') })],
|
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') })],
|
create_time: [buildValidatorData({ name: 'date', title: t('game.channel.create_time') })],
|
||||||
update_time: [buildValidatorData({ name: 'date', title: t('game.channel.update_time') })],
|
update_time: [buildValidatorData({ name: 'date', title: t('game.channel.update_time') })],
|
||||||
})
|
}))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss"></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user