[权限管理]角色组管理

This commit is contained in:
2026-04-15 10:19:45 +08:00
parent 8cc28096c4
commit 979751f719
7 changed files with 158 additions and 7 deletions

View File

@@ -1,6 +1,11 @@
export default {
GroupName: 'Group Name',
'Group name': 'Group Name',
commission_rate: 'Commission rate (%)',
commission_rate_desc_title: 'Group commission notes',
commission_rate_desc_1: 'The total group commission rate under the same parent cannot exceed 100%.',
commission_rate_desc_2: 'Current group commission = channel commission × (1 - parent group commission rate) × current group commission rate.',
commission_rate_desc_3: 'If exceeded, the system returns both exceeded value and remaining quota under current parent.',
jurisdiction: 'Permissions',
'Parent group': 'Superior group',
'The parent group cannot be the group itself': 'The parent group cannot be the group itself',

View File

@@ -1,6 +1,11 @@
export default {
GroupName: '组名',
'Group name': '组别名称',
commission_rate: '分红比例(%)',
commission_rate_desc_title: '角色组分红说明',
commission_rate_desc_1: '同一父级下角色组分红比例总和不能超过100%。',
commission_rate_desc_2: '当前角色分红=渠道设置获取分红×(1-上级角色分红比例)×当前角色分红比例。',
commission_rate_desc_3: '提交超额时,系统会提示超出值与当前父级剩余额度。',
jurisdiction: '权限',
'Parent group': '上级分组',
'The parent group cannot be the group itself': '上级分组不能是分组本身',

View File

@@ -54,7 +54,13 @@ const baTable: baTableClass = new baTableClass(
dblClickNotEditColumn: [undefined],
column: [
{ type: 'selection', align: 'center' },
{ label: t('auth.group.Group name'), prop: 'name', align: 'left', width: '200' },
{
label: t('auth.group.Group name'),
prop: 'name',
align: 'left',
minWidth: '180',
},
{ label: t('auth.group.commission_rate'), prop: 'commission_rate', align: 'center', formatter: formatRatePercent },
{ label: t('auth.group.jurisdiction'), prop: 'rules', align: 'center' },
{
label: t('State'),
@@ -165,6 +171,13 @@ const menuRuleTreeUpdate = () => {
provide('baTable', baTable)
function formatRatePercent(row: anyObj, _column: any, cellValue: number | string | null) {
if (cellValue === null || cellValue === undefined || cellValue === '') {
return '0%'
}
return `${cellValue}%`
}
onMounted(() => {
baTable.table.ref = tableRef.value
baTable.mount()

View File

@@ -49,6 +49,23 @@
:placeholder="t('Please input field', { field: t('auth.group.Group name') })"
></el-input>
</el-form-item>
<FormItem
:label="t('auth.group.commission_rate')"
v-model="baTable.form.items!.commission_rate"
type="number"
prop="commission_rate"
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100, disabled: shouldDisableCommissionRate() }"
:placeholder="t('Please input field', { field: t('auth.group.commission_rate') })"
/>
<el-alert class="commission-rate-alert" :title="t('auth.group.commission_rate_desc_title')" type="info" :closable="false" show-icon>
<template #default>
<ul class="commission-rate-desc-list">
<li>{{ t('auth.group.commission_rate_desc_1') }}</li>
<li>{{ t('auth.group.commission_rate_desc_2') }}</li>
<li>{{ t('auth.group.commission_rate_desc_3') }}</li>
</ul>
</template>
</el-alert>
<el-form-item prop="auth" :label="t('auth.group.jurisdiction')">
<el-tree
ref="treeRef"
@@ -94,16 +111,40 @@ import type { ElTree, FormItemRule } from 'element-plus'
import { buildValidatorData } from '/@/utils/validate'
import type Node from 'element-plus/es/components/tree/src/model/node'
import { useConfig } from '/@/stores/config'
import { useAdminInfo } from '/@/stores/adminInfo'
const config = useConfig()
const adminInfo = useAdminInfo()
const formRef = useTemplateRef('formRef')
const treeRef = useTemplateRef('treeRef')
const baTable = inject('baTable') as baTableClass
const { t } = useI18n()
const shouldDisableCommissionRate = () => {
return false
}
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
name: [buildValidatorData({ name: 'required', title: t('auth.group.Group name') })],
commission_rate: [
{
required: true,
validator: (_rule: any, val: number | string, callback: Function) => {
if (shouldDisableCommissionRate()) {
return callback()
}
const strVal = String(val ?? '').trim()
if (!strVal) {
return callback(new Error(t('Please input field', { field: t('auth.group.commission_rate') })))
}
if (!/^(100(\.00?)?|[0-9]{1,2}(\.[0-9]{1,2})?)$/.test(strVal)) {
return callback(new Error(t('auth.admin.Commission rate must be between 0 and 100 with up to 2 decimals')))
}
return callback()
},
trigger: 'blur',
},
],
auth: [
{
required: true,
@@ -153,6 +194,16 @@ defineExpose({
</script>
<style scoped lang="scss">
.commission-rate-alert {
margin-bottom: 12px;
}
.commission-rate-desc-list {
margin: 6px 0 0;
padding-left: 18px;
line-height: 1.6;
}
:deep(.penultimate-node) {
.el-tree-node__children {
padding-left: 60px;