1.优化后台管理员管理页面的权限设置
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
remoteUrl: '/admin/auth.Admin/index',
|
||||
field: 'username',
|
||||
pk: 'id',
|
||||
disabled: isTopLevelGroup,
|
||||
disabled: isTopLevelGroup || !hasGroupSelected,
|
||||
pagination: false,
|
||||
params: parentSelectParams,
|
||||
placeholder: t('auth.admin.Parent admin placeholder'),
|
||||
@@ -191,6 +191,8 @@ import FormItem from '/@/components/formItem/index.vue'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { useConfig } from '/@/stores/config'
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { auth } from '/@/utils/common'
|
||||
|
||||
const config = useConfig()
|
||||
const adminInfo = useAdminInfo()
|
||||
const formRef = useTemplateRef('formRef')
|
||||
@@ -204,13 +206,32 @@ const isTopLevelGroup = ref(false)
|
||||
|
||||
const isSelfEdit = computed(() => baTable.form.operate === 'Edit' && adminInfo.id == baTable.form.items?.id)
|
||||
|
||||
const hasChannelIndexAuth = computed(
|
||||
() =>
|
||||
adminInfo.super ||
|
||||
auth({ name: '/admin/channel', subNodeName: '/admin/channel/index' }) ||
|
||||
auth({ name: '/admin/Channel', subNodeName: '/admin/Channel/index' })
|
||||
)
|
||||
|
||||
const hasGroupSelected = computed(() => {
|
||||
const group = baTable.form.items?.group_arr
|
||||
if (Array.isArray(group)) {
|
||||
return group.length > 0
|
||||
}
|
||||
return group !== null && group !== undefined && group !== ''
|
||||
})
|
||||
|
||||
const hasParentAdmin = computed(() => {
|
||||
const pid = baTable.form.items?.parent_admin_id
|
||||
return pid !== null && pid !== undefined && pid !== '' && Number(pid) > 0
|
||||
})
|
||||
|
||||
const showChannelEditable = computed(
|
||||
() => adminInfo.super && !hasParentAdmin.value && !isSelfEdit.value
|
||||
() =>
|
||||
hasGroupSelected.value &&
|
||||
!hasParentAdmin.value &&
|
||||
!isSelfEdit.value &&
|
||||
(adminInfo.super || hasChannelIndexAuth.value)
|
||||
)
|
||||
|
||||
const channelDisplayName = computed(() => {
|
||||
@@ -224,14 +245,13 @@ const channelDisplayName = computed(() => {
|
||||
})
|
||||
|
||||
const showChannelReadonly = computed(() => {
|
||||
if (isSelfEdit.value) return false
|
||||
if (isSelfEdit.value || !hasGroupSelected.value) return false
|
||||
if (showChannelEditable.value) return false
|
||||
if (hasParentAdmin.value) return true
|
||||
if (!adminInfo.super && baTable.form.operate === 'Add') return true
|
||||
return channelDisplayName.value !== ''
|
||||
})
|
||||
|
||||
const showParentField = computed(() => adminInfo.super && !isSelfEdit.value)
|
||||
const showParentField = computed(() => !isSelfEdit.value)
|
||||
|
||||
const hasChannelForShare = computed(() => {
|
||||
const cid = baTable.form.items?.channel_id
|
||||
@@ -239,10 +259,8 @@ const hasChannelForShare = computed(() => {
|
||||
})
|
||||
|
||||
const showShareRateField = computed(() => {
|
||||
if (isSelfEdit.value) return false
|
||||
if (!hasChannelForShare.value) return false
|
||||
if (hasParentAdmin.value) return true
|
||||
return true
|
||||
if (isSelfEdit.value || !hasGroupSelected.value) return false
|
||||
return hasChannelForShare.value
|
||||
})
|
||||
|
||||
const parentSelectParams = computed(() => {
|
||||
@@ -310,8 +328,10 @@ const loadParentChannelMeta = async (parentId: unknown) => {
|
||||
const items = baTable.form.items
|
||||
if (!items) return
|
||||
if (parentId === null || parentId === undefined || parentId === '' || Number(parentId) <= 0) {
|
||||
if (showChannelEditable.value) {
|
||||
items['channel_name'] = ''
|
||||
items['channel_name'] = ''
|
||||
if (baTable.form.operate === 'Add') {
|
||||
items.channel_id = null
|
||||
items.commission_share_rate = null
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -374,10 +394,7 @@ const loadShareRemainder = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
let parentId = baTable.form.items?.parent_admin_id
|
||||
if (!adminInfo.super) {
|
||||
parentId = adminInfo.id
|
||||
}
|
||||
const parentId = baTable.form.items?.parent_admin_id
|
||||
if (!parentId || Number(parentId) <= 0) {
|
||||
shareHint.value = ''
|
||||
return
|
||||
@@ -493,11 +510,13 @@ watch(isTopLevelGroup, (topLevel) => {
|
||||
watch(
|
||||
() => baTable.form.operate,
|
||||
(operate) => {
|
||||
if (operate !== 'Add' || adminInfo.super || !baTable.form.items) {
|
||||
if (operate !== 'Add' || !baTable.form.items) {
|
||||
return
|
||||
}
|
||||
baTable.form.items.parent_admin_id = adminInfo.id
|
||||
void loadParentChannelMeta(adminInfo.id)
|
||||
baTable.form.items.parent_admin_id = null
|
||||
baTable.form.items.channel_id = null
|
||||
baTable.form.items['channel_name'] = ''
|
||||
baTable.form.items.commission_share_rate = null
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user