This commit is contained in:
zhx 2026-06-12 19:35:51 +08:00
parent d56fc0f50e
commit cd9cbea7d6
2 changed files with 73 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import {
FormItem,
Input,
Modal,
Switch,
message,
} from 'antdv-next';
@ -30,6 +31,10 @@ const emit = defineEmits<{
const saving = ref(false);
const form = reactive({
canAddBdLeader: true,
canBanUser: true,
canGiftProps: true,
canUnbanUser: true,
contact: '',
id: '',
regionId: '',
@ -51,6 +56,10 @@ watch(
form.sysOrigin = props.row?.sysOrigin || props.sysOrigin || 'LIKEI';
form.contact = props.row?.contact || '';
form.regionId = String(props.row?.regionId || '');
form.canAddBdLeader = props.row?.canAddBdLeader !== false;
form.canGiftProps = props.row?.canGiftProps !== false;
form.canBanUser = props.row?.canBanUser !== false;
form.canUnbanUser = props.row?.canUnbanUser !== false;
},
{ immediate: true },
);
@ -67,6 +76,10 @@ async function handleSubmit() {
saving.value = true;
try {
const payload = {
canAddBdLeader: form.canAddBdLeader,
canBanUser: form.canBanUser,
canGiftProps: form.canGiftProps,
canUnbanUser: form.canUnbanUser,
contact: form.contact.trim(),
id: form.id || undefined,
regionId: form.regionId,
@ -114,6 +127,42 @@ async function handleSubmit() {
<FormItem label="联系方式">
<Input v-model:value="form.contact" placeholder="联系方式" />
</FormItem>
<FormItem label="功能开关">
<div class="feature-switches">
<label class="feature-switch-row">
<span>加BD Leader</span>
<Switch v-model:checked="form.canAddBdLeader" />
</label>
<label class="feature-switch-row">
<span>赠送道具</span>
<Switch v-model:checked="form.canGiftProps" />
</label>
<label class="feature-switch-row">
<span>封禁用户</span>
<Switch v-model:checked="form.canBanUser" />
</label>
<label class="feature-switch-row">
<span>解封用户</span>
<Switch v-model:checked="form.canUnbanUser" />
</label>
</div>
</FormItem>
</Form>
</Modal>
</template>
<style scoped>
.feature-switches {
display: grid;
gap: 10px;
}
.feature-switch-row {
align-items: center;
border: 1px solid #e5e7eb;
border-radius: 6px;
display: flex;
justify-content: space-between;
padding: 10px 12px;
}
</style>

View File

@ -23,6 +23,7 @@ import {
Pagination,
Space,
Table,
Tag,
message,
} from 'antdv-next';
@ -55,12 +56,20 @@ const columns = [
{ dataIndex: 'userProfile', key: 'userProfile', title: '经理', width: 240 },
{ dataIndex: 'regionName', key: 'regionName', title: '区域', width: 140 },
{ dataIndex: 'contact', key: 'contact', title: '联系方式', width: 180 },
{ dataIndex: 'features', key: 'features', title: '功能开关', width: 280 },
{ dataIndex: 'createUserName', key: 'createUserName', title: '创建人', width: 140 },
{ dataIndex: 'updateUserName', key: 'updateUserName', title: '修改人', width: 140 },
{ dataIndex: 'createTime', key: 'createTime', title: '创建时间', width: 180 },
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 120 },
];
const managerFeatureSwitches = [
{ key: 'canAddBdLeader', label: '加BD Leader' },
{ key: 'canGiftProps', label: '赠送道具' },
{ key: 'canBanUser', label: '封禁用户' },
{ key: 'canUnbanUser', label: '解封用户' },
];
function hasPermission(code: string) {
const codes = accessStore.accessCodes || [];
return codes.length === 0 || codes.includes(code);
@ -75,6 +84,10 @@ function getUserShortId(profile?: Record<string, any> | null) {
return profile?.actualAccount || profile?.account || profile?.id || '-';
}
function isFeatureEnabled(record: Record<string, any>, key: string) {
return record?.[key] !== false;
}
async function loadData(reset = false) {
if (reset) {
query.cursor = 1;
@ -186,6 +199,17 @@ loadData(true);
<template v-else-if="column.key === 'contact'">
{{ canEdit ? record.contact || '-' : '-' }}
</template>
<template v-else-if="column.key === 'features'">
<Space wrap :size="[4, 4]">
<Tag
v-for="item in managerFeatureSwitches"
:key="item.key"
:color="isFeatureEnabled(record, item.key) ? 'green' : 'red'"
>
{{ item.label }}{{ isFeatureEnabled(record, item.key) ? '开' : '关' }}
</Tag>
</Space>
</template>
<template v-else-if="column.key === 'createTime'">
{{ formatDate(record.createTime) }}
</template>