红包区域任务
This commit is contained in:
parent
2d19a275a8
commit
720ddc36ad
@ -111,6 +111,25 @@ export interface LegacyEmojiItem {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface AppHomePopupItem {
|
||||
createTime?: string;
|
||||
description?: string;
|
||||
enabled?: boolean;
|
||||
id?: string;
|
||||
image?: string;
|
||||
jumpType?: string;
|
||||
jumpUrl?: string;
|
||||
limitDays?: number;
|
||||
name?: string;
|
||||
popupKey?: string;
|
||||
priority?: number;
|
||||
scene?: string;
|
||||
sysOrigin?: string;
|
||||
title?: string;
|
||||
updateTime?: string;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export async function loginLoggerPage(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult>('/user/login/logger/page', {
|
||||
params,
|
||||
@ -213,6 +232,24 @@ export async function delConfig(id: number | string) {
|
||||
return requestClient.delete(`/sys/enum/config/${id}`);
|
||||
}
|
||||
|
||||
export async function pageAppHomePopups(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult<AppHomePopupItem>>(
|
||||
'/go/app-system/home-popups/configs',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveAppHomePopup(data: Record<string, any>) {
|
||||
return requestClient.post<AppHomePopupItem>(
|
||||
'/go/app-system/home-popups/configs/save',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteAppHomePopup(id: number | string) {
|
||||
return requestClient.delete(`/go/app-system/home-popups/configs/${id}`);
|
||||
}
|
||||
|
||||
export async function getEnumConfigByGroup(group: string) {
|
||||
return requestClient.get<{ result: LegacyEnumConfigItem[] }>(
|
||||
`/sys/enum/config/list/${group}`,
|
||||
|
||||
@ -9,6 +9,8 @@ const ROOM_TURNOVER_REWARD_BASE =
|
||||
'/go/resident-activity/room-turnover-reward';
|
||||
const VIP_BASE = '/go/resident-activity/vip';
|
||||
const RECHARGE_REWARD_BASE = '/go/resident-activity/recharge-reward';
|
||||
const TASK_CENTER_BASE = '/go/resident-activity/task-center';
|
||||
const VOICE_ROOM_RED_PACKET_BASE = '/go/resident-activity/voice-room-red-packet';
|
||||
|
||||
export async function getResidentInviteConfig(sysOrigin: string) {
|
||||
return requestClient.get<Record<string, any>>('/resident-activity/invite/config', {
|
||||
@ -119,6 +121,63 @@ export async function pageResidentRechargeRewardClaimRecords(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getResidentDailyTaskConfig(
|
||||
sysOrigin: string,
|
||||
taskCategory = 'DAILY',
|
||||
) {
|
||||
return requestClient.get<Record<string, any>>(`${TASK_CENTER_BASE}/config`, {
|
||||
params: { sysOrigin, taskCategory },
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveResidentDailyTaskConfig(data: Record<string, any>) {
|
||||
return requestClient.post<Record<string, any>>(`${TASK_CENTER_BASE}/config/save`, {
|
||||
...data,
|
||||
taskCategory: data.taskCategory || 'DAILY',
|
||||
});
|
||||
}
|
||||
|
||||
export async function pageResidentDailyTaskClaimRecords(
|
||||
params: Record<string, any>,
|
||||
) {
|
||||
return requestClient.get<Record<string, any>>(
|
||||
`${TASK_CENTER_BASE}/claim-record/page`,
|
||||
{ params: { ...params, taskCategory: params.taskCategory || 'DAILY' } },
|
||||
);
|
||||
}
|
||||
|
||||
export async function pageResidentDailyTaskEvents(params: Record<string, any>) {
|
||||
return requestClient.get<Record<string, any>>(`${TASK_CENTER_BASE}/event/page`, {
|
||||
params: { ...params, taskCategory: params.taskCategory || 'DAILY' },
|
||||
});
|
||||
}
|
||||
|
||||
export async function getVoiceRoomRedPacketConfig(sysOrigin: string) {
|
||||
return requestClient.get<Record<string, any>>(`${VOICE_ROOM_RED_PACKET_BASE}/config`, {
|
||||
params: { sysOrigin },
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveVoiceRoomRedPacketConfig(data: Record<string, any>) {
|
||||
return requestClient.post<Record<string, any>>(
|
||||
`${VOICE_ROOM_RED_PACKET_BASE}/config/save`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function pageVoiceRoomRedPacketRecords(params: Record<string, any>) {
|
||||
return requestClient.get<Record<string, any>>(`${VOICE_ROOM_RED_PACKET_BASE}/records`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function retryVoiceRoomRedPacketRefund(packetNo: string) {
|
||||
return requestClient.post<Record<string, any>>(
|
||||
`${VOICE_ROOM_RED_PACKET_BASE}/refund/retry`,
|
||||
{ packetNo },
|
||||
);
|
||||
}
|
||||
|
||||
export async function pageSpecifiedGiftWeeklyRankConfigs(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult<Record<string, any>>>(
|
||||
`${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config/page`,
|
||||
|
||||
@ -176,6 +176,23 @@ export async function resetRegionWithdrawal(regionId: number | string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function listVoiceRoomRegionImGroups(params: Record<string, any>) {
|
||||
return requestClient.get<Array<Record<string, any>>>(
|
||||
'/go/region/config/im-groups',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveVoiceRoomRegionImGroup(data: Record<string, any>) {
|
||||
return requestClient.post('/go/region/config/im-groups/save', data);
|
||||
}
|
||||
|
||||
export async function createVoiceRoomRegionImGroup(data: Record<string, any>) {
|
||||
return requestClient.post('/go/region/config/im-groups/create', data);
|
||||
}
|
||||
|
||||
export async function regionAssistConfigTable(params: Record<string, any>) {
|
||||
return requestClient.get<Array<Record<string, any>>>(
|
||||
'/region/assist/config/list',
|
||||
|
||||
@ -16,6 +16,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('#/views/app-system/login-logger.vue'),
|
||||
meta: { title: '登陆日志' },
|
||||
},
|
||||
{
|
||||
name: 'AppSystemHomePopupManager',
|
||||
path: 'home-popups',
|
||||
component: () => import('#/views/app-system/home-popup-manager.vue'),
|
||||
meta: { title: '首页弹窗管理' },
|
||||
},
|
||||
{
|
||||
name: 'AppSystemRoomBlacklist',
|
||||
path: 'log/blacklist',
|
||||
|
||||
@ -29,6 +29,18 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('#/views/resident-activity/recharge-reward-config.vue'),
|
||||
meta: { title: '充值奖励配置' },
|
||||
},
|
||||
{
|
||||
name: 'ResidentDailyTaskConfig',
|
||||
path: 'daily-task/config',
|
||||
component: () => import('#/views/resident-activity/daily-task-config.vue'),
|
||||
meta: { title: '每日任务' },
|
||||
},
|
||||
{
|
||||
name: 'ResidentVoiceRoomRedPacket',
|
||||
path: 'voice-room-red-packet',
|
||||
component: () => import('#/views/resident-activity/voice-room-red-packet.vue'),
|
||||
meta: { title: '红包' },
|
||||
},
|
||||
{
|
||||
name: 'ResidentRegisterRewardConfig',
|
||||
path: 'register-reward/config',
|
||||
|
||||
@ -10,12 +10,6 @@ const routes: RouteRecordRaw[] = [
|
||||
name: 'SystemManager',
|
||||
path: '/sys/manager',
|
||||
children: [
|
||||
{
|
||||
name: 'SystemRegionConfig',
|
||||
path: 'region/config',
|
||||
component: () => import('#/views/system/region-config.vue'),
|
||||
meta: { title: '区域配置' },
|
||||
},
|
||||
{
|
||||
name: 'SystemUserManager',
|
||||
path: 'user',
|
||||
|
||||
@ -28,6 +28,13 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('#/views/team/team-list.vue'),
|
||||
meta: { title: '团队列表' },
|
||||
},
|
||||
{
|
||||
name: 'SystemRegionConfig',
|
||||
path: 'region/config',
|
||||
alias: '/sys/manager/region/config',
|
||||
component: () => import('#/views/system/region-config.vue'),
|
||||
meta: { title: '区域配置' },
|
||||
},
|
||||
{
|
||||
name: 'TeamMemberList',
|
||||
path: 'team/member',
|
||||
|
||||
407
apps/src/views/app-system/home-popup-manager.vue
Normal file
407
apps/src/views/app-system/home-popup-manager.vue
Normal file
@ -0,0 +1,407 @@
|
||||
<script lang="ts" setup>
|
||||
import type { AppHomePopupItem } from '#/api/legacy/app-system';
|
||||
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Modal,
|
||||
Pagination,
|
||||
Select,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
deleteAppHomePopup,
|
||||
pageAppHomePopups,
|
||||
saveAppHomePopup,
|
||||
} from '#/api/legacy/app-system';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
defineOptions({ name: 'AppSystemHomePopupManager' });
|
||||
|
||||
const jumpTypeOptions = [
|
||||
{ label: 'H5', value: 'H5' },
|
||||
{ label: '端内路由', value: 'APP_ROUTE' },
|
||||
{ label: '游戏', value: 'GAME' },
|
||||
{ label: '无跳转', value: 'NOOP' },
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{ dataIndex: 'enabled', key: 'enabled', title: '状态', width: 90 },
|
||||
{ dataIndex: 'popupKey', key: 'popupKey', title: '弹窗 key', width: 160 },
|
||||
{ dataIndex: 'limitDays', key: 'limitDays', title: 'limit时间(天)', width: 130 },
|
||||
{ dataIndex: 'description', key: 'description', title: '描述', width: 220 },
|
||||
{ dataIndex: 'title', key: 'title', title: '标题', width: 180 },
|
||||
{ dataIndex: 'jumpType', key: 'jumpType', title: '跳转类型', width: 120 },
|
||||
{ dataIndex: 'jumpUrl', key: 'jumpUrl', title: '跳转地址', width: 220 },
|
||||
{ dataIndex: 'priority', key: 'priority', title: '优先级', width: 100 },
|
||||
{ dataIndex: 'version', key: 'version', title: '版本', width: 90 },
|
||||
{ dataIndex: 'updateTime', key: 'updateTime', title: '更新时间', width: 180 },
|
||||
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 130, fixed: 'right' as const },
|
||||
];
|
||||
|
||||
const accessStore = useAccessStore();
|
||||
const sysOriginOptions = computed(() => {
|
||||
const options = getAllowedSysOrigins(accessStore.accessCodes || []);
|
||||
return options.length > 0 ? options : getAllowedSysOrigins([]);
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const formOpen = ref(false);
|
||||
const formTitle = ref('新增弹窗');
|
||||
const list = ref<AppHomePopupItem[]>([]);
|
||||
const total = ref(0);
|
||||
|
||||
const query = reactive<Record<string, any>>({
|
||||
cursor: 1,
|
||||
limit: 20,
|
||||
popupKey: '',
|
||||
scene: 'APP_ENTER',
|
||||
sysOrigin: '',
|
||||
});
|
||||
|
||||
const form = reactive<Record<string, any>>(createForm());
|
||||
|
||||
function createForm() {
|
||||
return {
|
||||
description: '',
|
||||
enabled: true,
|
||||
id: '',
|
||||
image: '',
|
||||
jumpType: 'NOOP',
|
||||
jumpUrl: '',
|
||||
limitDays: 7,
|
||||
name: '',
|
||||
popupKey: '',
|
||||
priority: 10,
|
||||
scene: 'APP_ENTER',
|
||||
title: '',
|
||||
version: 1,
|
||||
};
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, createForm());
|
||||
}
|
||||
|
||||
async function loadData(reset = false) {
|
||||
if (!query.sysOrigin) {
|
||||
return;
|
||||
}
|
||||
if (reset) {
|
||||
query.cursor = 1;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await pageAppHomePopups({ ...query });
|
||||
list.value = result.records || [];
|
||||
total.value = Number(result.total || 0);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handlePageChange(page: number, pageSize: number) {
|
||||
query.cursor = page;
|
||||
query.limit = pageSize;
|
||||
void loadData();
|
||||
}
|
||||
|
||||
function handleCreate() {
|
||||
resetForm();
|
||||
formTitle.value = '新增弹窗';
|
||||
formOpen.value = true;
|
||||
}
|
||||
|
||||
function handleEdit(record: AppHomePopupItem) {
|
||||
resetForm();
|
||||
Object.assign(form, {
|
||||
description: record.description || '',
|
||||
enabled: record.enabled !== false,
|
||||
id: record.id || '',
|
||||
image: record.image || '',
|
||||
jumpType: record.jumpType || 'NOOP',
|
||||
jumpUrl: record.jumpUrl || '',
|
||||
limitDays: Number(record.limitDays ?? 7),
|
||||
name: record.name || '',
|
||||
popupKey: record.popupKey || '',
|
||||
priority: Number(record.priority ?? 10),
|
||||
scene: record.scene || 'APP_ENTER',
|
||||
title: record.title || '',
|
||||
version: Number(record.version ?? 1),
|
||||
});
|
||||
formTitle.value = '编辑弹窗';
|
||||
formOpen.value = true;
|
||||
}
|
||||
|
||||
function validateForm() {
|
||||
if (!String(form.popupKey || '').trim()) {
|
||||
message.warning('请输入弹窗 key');
|
||||
return false;
|
||||
}
|
||||
if (Number(form.limitDays) < 0) {
|
||||
message.warning('limit 时间不能小于 0');
|
||||
return false;
|
||||
}
|
||||
if (!String(form.description || '').trim()) {
|
||||
message.warning('请输入描述');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await saveAppHomePopup({
|
||||
description: String(form.description || '').trim(),
|
||||
enabled: Boolean(form.enabled),
|
||||
id: form.id || undefined,
|
||||
image: String(form.image || '').trim(),
|
||||
jumpType: String(form.jumpType || '').trim(),
|
||||
jumpUrl: String(form.jumpUrl || '').trim(),
|
||||
limitDays: Number(form.limitDays || 0),
|
||||
name: String(form.name || '').trim(),
|
||||
popupKey: String(form.popupKey || '').trim(),
|
||||
priority: Number(form.priority || 0),
|
||||
scene: 'APP_ENTER',
|
||||
sysOrigin: query.sysOrigin,
|
||||
title: String(form.title || '').trim(),
|
||||
version: Number(form.version || 1),
|
||||
});
|
||||
message.success('保存成功');
|
||||
formOpen.value = false;
|
||||
await loadData();
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(record: AppHomePopupItem) {
|
||||
Modal.confirm({
|
||||
title: `确认删除 ${record.popupKey || ''} 吗?`,
|
||||
async onOk() {
|
||||
if (!record.id) {
|
||||
return;
|
||||
}
|
||||
await deleteAppHomePopup(record.id);
|
||||
message.success('删除成功');
|
||||
await loadData(true);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
sysOriginOptions,
|
||||
(options) => {
|
||||
if (!query.sysOrigin) {
|
||||
query.sysOrigin = String(options[0]?.value || '');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => query.sysOrigin,
|
||||
(value) => {
|
||||
if (value) {
|
||||
void loadData(true);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="首页弹窗管理">
|
||||
<Card>
|
||||
<InlineFilterToolbar class="toolbar">
|
||||
<InlineFilterField label="系统">
|
||||
<SysOriginSelect
|
||||
v-model:value="query.sysOrigin"
|
||||
:options="sysOriginOptions"
|
||||
style="width: 140px"
|
||||
@change="loadData(true)"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="弹窗 key">
|
||||
<Input
|
||||
v-model:value="query.popupKey"
|
||||
allow-clear
|
||||
placeholder="invite / game"
|
||||
style="width: 180px"
|
||||
@press-enter="loadData(true)"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<Button :loading="loading" type="primary" @click="loadData(true)">
|
||||
搜索
|
||||
</Button>
|
||||
<Button type="primary" @click="handleCreate">新增</Button>
|
||||
</InlineFilterToolbar>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
:scroll="{ x: 1640 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'enabled'">
|
||||
<Tag :color="record.enabled ? 'success' : 'default'">
|
||||
{{ record.enabled ? '启用' : '关闭' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'limitDays'">
|
||||
{{ record.limitDays === 0 ? '每次' : `${record.limitDays} 天` }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<Space>
|
||||
<Button size="small" type="link" @click="handleEdit(record)">
|
||||
编辑
|
||||
</Button>
|
||||
<Button danger size="small" type="link" @click="handleDelete(record)">
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<div class="pager">
|
||||
<Pagination
|
||||
:current="query.cursor"
|
||||
:page-size="query.limit"
|
||||
:total="total"
|
||||
show-size-changer
|
||||
@change="handlePageChange"
|
||||
@show-size-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
:confirm-loading="saving"
|
||||
:open="formOpen"
|
||||
destroy-on-close
|
||||
ok-text="保存"
|
||||
:title="formTitle"
|
||||
width="720px"
|
||||
@cancel="formOpen = false"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<div class="form-grid">
|
||||
<div class="form-item">
|
||||
<label>弹窗 key</label>
|
||||
<Input
|
||||
v-model:value="form.popupKey"
|
||||
:disabled="Boolean(form.id)"
|
||||
placeholder="invite"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>limit时间(天)</label>
|
||||
<InputNumber
|
||||
v-model:value="form.limitDays"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>描述</label>
|
||||
<Input v-model:value="form.description" placeholder="运营备注" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>启用</label>
|
||||
<Switch v-model:checked="form.enabled" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>标题</label>
|
||||
<Input v-model:value="form.title" placeholder="弹窗标题" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>图片</label>
|
||||
<Input v-model:value="form.image" placeholder="https://..." />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>跳转类型</label>
|
||||
<Select
|
||||
v-model:value="form.jumpType"
|
||||
:options="jumpTypeOptions"
|
||||
option-label-prop="label"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>跳转地址</label>
|
||||
<Input v-model:value="form.jumpUrl" placeholder="/game-center" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>优先级</label>
|
||||
<InputNumber
|
||||
v-model:value="form.priority"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label>版本</label>
|
||||
<InputNumber
|
||||
v-model:value="form.version"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.form-item label {
|
||||
color: hsl(var(--muted-foreground));
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
|
||||
682
apps/src/views/resident-activity/daily-task-config.vue
Normal file
682
apps/src/views/resident-activity/daily-task-config.vue
Normal file
@ -0,0 +1,682 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Switch,
|
||||
Table,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Tag,
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
getResidentDailyTaskConfig,
|
||||
pageResidentDailyTaskClaimRecords,
|
||||
pageResidentDailyTaskEvents,
|
||||
saveResidentDailyTaskConfig,
|
||||
} from '#/api/legacy/resident-activity';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
defineOptions({ name: 'ResidentDailyTaskConfigPage' });
|
||||
|
||||
let localRowId = 0;
|
||||
|
||||
function createRowKey(seed?: number | string) {
|
||||
localRowId += 1;
|
||||
return `daily-task-${seed || localRowId}-${localRowId}`;
|
||||
}
|
||||
|
||||
function createTask(sortOrder = 10) {
|
||||
return {
|
||||
conditionType: 'MIC_DURATION_SECONDS',
|
||||
cover: '',
|
||||
enabled: true,
|
||||
id: null,
|
||||
jumpPage: '',
|
||||
jumpType: 'ROOM_RANDOM_WITH_MIC',
|
||||
rewardGold: 0,
|
||||
rowKey: createRowKey(),
|
||||
sortOrder,
|
||||
targetUnit: 'second',
|
||||
targetValue: 60,
|
||||
taskCode: '',
|
||||
taskDesc: '进度 / 目标',
|
||||
taskIcon: '',
|
||||
taskName: '',
|
||||
};
|
||||
}
|
||||
|
||||
function defaultTasks() {
|
||||
return [createTask(10)];
|
||||
}
|
||||
|
||||
const conditionTypeOptions = [
|
||||
{ label: '麦克风时长(秒)', value: 'MIC_DURATION_SECONDS' },
|
||||
{ label: '游戏消耗金币', value: 'GAME_CONSUME_GOLD' },
|
||||
{ label: '礼物消耗金币', value: 'GIFT_CONSUME_GOLD' },
|
||||
{ label: '充值金币', value: 'RECHARGE_GOLD' },
|
||||
];
|
||||
|
||||
const taskCategoryOptions = [
|
||||
{ label: '每日任务', value: 'DAILY' },
|
||||
{ label: '专属任务', value: 'NEWBIE' },
|
||||
];
|
||||
|
||||
const jumpTypeOptions = [
|
||||
{ label: '随机上麦房间', value: 'ROOM_RANDOM_WITH_MIC' },
|
||||
{ label: '随机房间', value: 'ROOM_RANDOM' },
|
||||
{ label: '端内路由', value: 'APP_ROUTE' },
|
||||
{ label: 'H5 链接', value: 'H5_URL' },
|
||||
{ label: '无跳转', value: 'NONE' },
|
||||
];
|
||||
|
||||
const targetUnitOptions = [
|
||||
{ label: '秒', value: 'second' },
|
||||
{ label: '次', value: 'count' },
|
||||
{ label: '金币', value: 'gold' },
|
||||
];
|
||||
|
||||
const taskColumns = [
|
||||
{ dataIndex: 'enabled', key: 'enabled', title: '启用', width: 80 },
|
||||
{ dataIndex: 'taskCode', key: 'taskCode', title: '任务编码', width: 210 },
|
||||
{ dataIndex: 'taskName', key: 'taskName', title: '任务名称', width: 220 },
|
||||
{ dataIndex: 'taskDesc', key: 'taskDesc', title: '说明', width: 160 },
|
||||
{ dataIndex: 'conditionType', key: 'conditionType', title: '条件', width: 190 },
|
||||
{ dataIndex: 'targetValue', key: 'targetValue', title: '目标', width: 130 },
|
||||
{ dataIndex: 'targetUnit', key: 'targetUnit', title: '单位', width: 110 },
|
||||
{ dataIndex: 'rewardGold', key: 'rewardGold', title: '奖励金币', width: 140 },
|
||||
{ dataIndex: 'jumpType', key: 'jumpType', title: '跳转', width: 180 },
|
||||
{ dataIndex: 'jumpPage', key: 'jumpPage', title: '跳转参数', width: 220 },
|
||||
{ dataIndex: 'sortOrder', key: 'sortOrder', title: '排序', width: 110 },
|
||||
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 90 },
|
||||
];
|
||||
|
||||
const claimColumns = [
|
||||
{ dataIndex: 'userId', key: 'userId', title: '用户ID', width: 140 },
|
||||
{ dataIndex: 'taskCode', key: 'taskCode', title: '任务编码', width: 220 },
|
||||
{ dataIndex: 'taskName', key: 'taskName', title: '任务名称', width: 220 },
|
||||
{ dataIndex: 'cycleKey', key: 'cycleKey', title: '周期', width: 130 },
|
||||
{ dataIndex: 'rewardGold', key: 'rewardGold', title: '金币', width: 110 },
|
||||
{ dataIndex: 'status', key: 'status', title: '状态', width: 110 },
|
||||
{ dataIndex: 'walletEventId', key: 'walletEventId', title: '钱包事件ID', width: 260 },
|
||||
{ dataIndex: 'failureReason', key: 'failureReason', title: '失败原因', width: 220 },
|
||||
{ dataIndex: 'createTime', key: 'createTime', title: '创建时间', width: 180 },
|
||||
];
|
||||
|
||||
const eventColumns = [
|
||||
{ dataIndex: 'eventId', key: 'eventId', title: '事件ID', width: 260 },
|
||||
{ dataIndex: 'userId', key: 'userId', title: '用户ID', width: 140 },
|
||||
{ dataIndex: 'eventType', key: 'eventType', title: '事件类型', width: 190 },
|
||||
{ dataIndex: 'taskCode', key: 'taskCode', title: '命中任务', width: 220 },
|
||||
{ dataIndex: 'deltaValue', key: 'deltaValue', title: '增量', width: 100 },
|
||||
{ dataIndex: 'cycleKey', key: 'cycleKey', title: '周期', width: 130 },
|
||||
{ dataIndex: 'occurredAt', key: 'occurredAt', title: '发生时间', width: 180 },
|
||||
{ dataIndex: 'createTime', key: 'createTime', title: '入库时间', width: 180 },
|
||||
];
|
||||
|
||||
const accessStore = useAccessStore();
|
||||
const sysOriginOptions = computed(() => {
|
||||
const options = getAllowedSysOrigins(accessStore.accessCodes || []);
|
||||
return options.length > 0 ? options : getAllowedSysOrigins([]);
|
||||
});
|
||||
|
||||
const selectedSysOrigin = ref('');
|
||||
const activeTaskCategory = ref('DAILY');
|
||||
const activeTab = ref('config');
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const claimLoading = ref(false);
|
||||
const eventLoading = ref(false);
|
||||
|
||||
const form = reactive<Record<string, any>>({
|
||||
configured: false,
|
||||
enabled: false,
|
||||
id: 0,
|
||||
sysOrigin: '',
|
||||
taskCategory: 'DAILY',
|
||||
tasks: defaultTasks(),
|
||||
timezone: 'Asia/Riyadh',
|
||||
updateTime: '',
|
||||
});
|
||||
|
||||
const claimQuery = reactive<Record<string, any>>({
|
||||
cursor: 1,
|
||||
limit: 20,
|
||||
status: '',
|
||||
taskCode: '',
|
||||
userId: '',
|
||||
});
|
||||
|
||||
const eventQuery = reactive<Record<string, any>>({
|
||||
cursor: 1,
|
||||
eventType: '',
|
||||
limit: 20,
|
||||
taskCode: '',
|
||||
userId: '',
|
||||
});
|
||||
|
||||
const claimPage = reactive<Record<string, any>>({
|
||||
current: 1,
|
||||
records: [],
|
||||
size: 20,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const eventPage = reactive<Record<string, any>>({
|
||||
current: 1,
|
||||
records: [],
|
||||
size: 20,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const statusMeta = computed(() => {
|
||||
if (!form.configured) {
|
||||
return { color: 'processing', text: '未配置' };
|
||||
}
|
||||
if (form.enabled) {
|
||||
return { color: 'success', text: '已启用' };
|
||||
}
|
||||
return { color: 'default', text: '已关闭' };
|
||||
});
|
||||
|
||||
const activeTaskCategoryLabel = computed(() => {
|
||||
return taskCategoryOptions.find((item) => item.value === activeTaskCategory.value)?.label || '每日任务';
|
||||
});
|
||||
|
||||
function normalizeConfig(result: null | Record<string, any> | undefined) {
|
||||
const value = result || {};
|
||||
form.configured = Boolean(value.configured);
|
||||
form.enabled = Boolean(value.enabled);
|
||||
form.id = value.id || 0;
|
||||
form.sysOrigin = String(value.sysOrigin || selectedSysOrigin.value || '');
|
||||
form.taskCategory = activeTaskCategory.value;
|
||||
form.timezone = String(value.timezone || 'Asia/Riyadh');
|
||||
form.updateTime = String(value.updateTime || '');
|
||||
const rows = Array.isArray(value.tasks) && value.tasks.length > 0
|
||||
? value.tasks
|
||||
: defaultTasks();
|
||||
form.tasks = rows
|
||||
.map((item: Record<string, any>, index: number) => ({
|
||||
conditionType: String(item.conditionType || 'MIC_DURATION_SECONDS'),
|
||||
cover: String(item.cover || ''),
|
||||
enabled: item.enabled !== false,
|
||||
id: item.id ?? null,
|
||||
jumpPage: String(item.jumpPage || ''),
|
||||
jumpType: String(item.jumpType || 'ROOM_RANDOM_WITH_MIC'),
|
||||
rewardGold: Number(item.rewardGold || 0),
|
||||
rowKey: createRowKey(item.id || index),
|
||||
sortOrder: Number(item.sortOrder || (index + 1) * 10),
|
||||
targetUnit: String(item.targetUnit || 'second'),
|
||||
targetValue: Number(item.targetValue || 0),
|
||||
taskCode: String(item.taskCode || ''),
|
||||
taskDesc: String(item.taskDesc || '进度 / 目标'),
|
||||
taskIcon: String(item.taskIcon || ''),
|
||||
taskName: String(item.taskName || ''),
|
||||
}))
|
||||
.sort((left: Record<string, any>, right: Record<string, any>) =>
|
||||
Number(left.sortOrder || 0) - Number(right.sortOrder || 0),
|
||||
);
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await getResidentDailyTaskConfig(
|
||||
selectedSysOrigin.value,
|
||||
activeTaskCategory.value,
|
||||
);
|
||||
normalizeConfig(result);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function addTask() {
|
||||
const tasks = form.tasks as Array<Record<string, any>>;
|
||||
const maxSort = Math.max(0, ...tasks.map((item) => Number(item.sortOrder || 0)));
|
||||
tasks.push(createTask(maxSort + 10));
|
||||
}
|
||||
|
||||
function removeTask(index: number) {
|
||||
(form.tasks as Array<Record<string, any>>).splice(index, 1);
|
||||
}
|
||||
|
||||
function confirmRemoveTask(index: number) {
|
||||
Modal.confirm({
|
||||
onOk: () => removeTask(index),
|
||||
title: `确认删除该${activeTaskCategoryLabel.value}?`,
|
||||
});
|
||||
}
|
||||
|
||||
function validateBeforeSave() {
|
||||
const tasks = form.tasks as Array<Record<string, any>>;
|
||||
if (tasks.length === 0) {
|
||||
message.warning(`请至少配置一个${activeTaskCategoryLabel.value}`);
|
||||
return false;
|
||||
}
|
||||
const seenCodes = new Set<string>();
|
||||
for (const item of tasks) {
|
||||
const taskCode = String(item.taskCode || '').trim();
|
||||
const taskName = String(item.taskName || '').trim();
|
||||
if (!taskCode) {
|
||||
message.warning('任务编码不能为空');
|
||||
return false;
|
||||
}
|
||||
if (!taskName) {
|
||||
message.warning('任务名称不能为空');
|
||||
return false;
|
||||
}
|
||||
if (Number(item.targetValue || 0) <= 0) {
|
||||
message.warning('任务目标必须大于 0');
|
||||
return false;
|
||||
}
|
||||
if (Number(item.rewardGold || 0) <= 0) {
|
||||
message.warning('奖励金币必须大于 0');
|
||||
return false;
|
||||
}
|
||||
if (seenCodes.has(taskCode)) {
|
||||
message.warning('任务编码不能重复');
|
||||
return false;
|
||||
}
|
||||
seenCodes.add(taskCode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
if (!validateBeforeSave()) {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await saveResidentDailyTaskConfig({
|
||||
enabled: Boolean(form.enabled),
|
||||
id: form.id || 0,
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
taskCategory: activeTaskCategory.value,
|
||||
tasks: (form.tasks || []).map((item: Record<string, any>) => ({
|
||||
conditionType: String(item.conditionType || '').trim(),
|
||||
cover: String(item.cover || '').trim(),
|
||||
enabled: item.enabled !== false,
|
||||
id: item.id || 0,
|
||||
jumpPage: String(item.jumpPage || '').trim(),
|
||||
jumpType: String(item.jumpType || '').trim(),
|
||||
rewardGold: Number(item.rewardGold || 0),
|
||||
sortOrder: Number(item.sortOrder || 0),
|
||||
targetUnit: String(item.targetUnit || '').trim(),
|
||||
targetValue: Number(item.targetValue || 0),
|
||||
taskCode: String(item.taskCode || '').trim(),
|
||||
taskDesc: String(item.taskDesc || '').trim(),
|
||||
taskIcon: String(item.taskIcon || '').trim(),
|
||||
taskName: String(item.taskName || '').trim(),
|
||||
})),
|
||||
timezone: String(form.timezone || '').trim(),
|
||||
});
|
||||
message.success('保存成功');
|
||||
await loadConfig();
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function normalizePage(target: Record<string, any>, result: Record<string, any>) {
|
||||
target.records = Array.isArray(result?.records) ? result.records : [];
|
||||
target.total = Number(result?.total || 0);
|
||||
target.current = Number(result?.current || 1);
|
||||
target.size = Number(result?.size || 20);
|
||||
}
|
||||
|
||||
async function loadClaimRecords() {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
claimLoading.value = true;
|
||||
try {
|
||||
const result = await pageResidentDailyTaskClaimRecords({
|
||||
...claimQuery,
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
taskCategory: activeTaskCategory.value,
|
||||
});
|
||||
normalizePage(claimPage, result || {});
|
||||
} finally {
|
||||
claimLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEvents() {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
eventLoading.value = true;
|
||||
try {
|
||||
const result = await pageResidentDailyTaskEvents({
|
||||
...eventQuery,
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
taskCategory: activeTaskCategory.value,
|
||||
});
|
||||
normalizePage(eventPage, result || {});
|
||||
} finally {
|
||||
eventLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function searchClaimRecords() {
|
||||
claimQuery.cursor = 1;
|
||||
void loadClaimRecords();
|
||||
}
|
||||
|
||||
function searchEvents() {
|
||||
eventQuery.cursor = 1;
|
||||
void loadEvents();
|
||||
}
|
||||
|
||||
function handleClaimTableChange(pagination: Record<string, any>) {
|
||||
claimQuery.cursor = Number(pagination.current || 1);
|
||||
claimQuery.limit = Number(pagination.pageSize || 20);
|
||||
void loadClaimRecords();
|
||||
}
|
||||
|
||||
function handleEventTableChange(pagination: Record<string, any>) {
|
||||
eventQuery.cursor = Number(pagination.current || 1);
|
||||
eventQuery.limit = Number(pagination.pageSize || 20);
|
||||
void loadEvents();
|
||||
}
|
||||
|
||||
watch(
|
||||
sysOriginOptions,
|
||||
(options) => {
|
||||
if (!selectedSysOrigin.value) {
|
||||
selectedSysOrigin.value = String(options[0]?.value || '');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
selectedSysOrigin,
|
||||
(value) => {
|
||||
if (value) {
|
||||
claimQuery.cursor = 1;
|
||||
eventQuery.cursor = 1;
|
||||
void loadConfig();
|
||||
void loadClaimRecords();
|
||||
void loadEvents();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(activeTaskCategory, () => {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
claimQuery.cursor = 1;
|
||||
eventQuery.cursor = 1;
|
||||
void loadConfig();
|
||||
void loadClaimRecords();
|
||||
void loadEvents();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Spin :spinning="loading">
|
||||
<Card :bordered="false">
|
||||
<template #title>
|
||||
<Space align="center" wrap>
|
||||
<span>每日任务</span>
|
||||
<Tag :color="statusMeta.color">{{ statusMeta.text }}</Tag>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<div class="toolbar">
|
||||
<Select
|
||||
v-model:value="selectedSysOrigin"
|
||||
:options="sysOriginOptions"
|
||||
option-filter-prop="label"
|
||||
option-label-prop="label"
|
||||
placeholder="请选择系统"
|
||||
show-search
|
||||
style="width: 180px"
|
||||
/>
|
||||
<Button :loading="loading" @click="loadConfig">刷新配置</Button>
|
||||
</div>
|
||||
|
||||
<Tabs v-model:activeKey="activeTaskCategory" class="category-tabs">
|
||||
<TabPane
|
||||
v-for="item in taskCategoryOptions"
|
||||
:key="item.value"
|
||||
:tab="item.label"
|
||||
/>
|
||||
</Tabs>
|
||||
|
||||
<Tabs v-model:activeKey="activeTab">
|
||||
<TabPane key="config" tab="任务配置">
|
||||
<div class="config-row">
|
||||
<Space align="center" wrap>
|
||||
<span class="field-label">启用</span>
|
||||
<Switch v-model:checked="form.enabled" />
|
||||
<span class="field-label">任务时区</span>
|
||||
<Input v-model:value="form.timezone" style="width: 180px" />
|
||||
<span class="sub-text">更新时间:{{ form.updateTime || '-' }}</span>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
:columns="taskColumns"
|
||||
:data-source="form.tasks"
|
||||
:pagination="false"
|
||||
row-key="rowKey"
|
||||
:scroll="{ x: 1850 }"
|
||||
>
|
||||
<template #bodyCell="{ column, index, record }">
|
||||
<template v-if="column.key === 'enabled'">
|
||||
<Switch v-model:checked="record.enabled" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'taskCode'">
|
||||
<Input
|
||||
v-model:value="record.taskCode"
|
||||
:placeholder="activeTaskCategory === 'DAILY' ? 'DAILY_MIC_DURATION' : 'EXCLUSIVE_RECHARGE'"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'taskName'">
|
||||
<Input v-model:value="record.taskName" placeholder="使用麦克风 %d 分钟。" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'taskDesc'">
|
||||
<Input v-model:value="record.taskDesc" placeholder="进度 / 目标" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'conditionType'">
|
||||
<Select
|
||||
v-model:value="record.conditionType"
|
||||
:options="conditionTypeOptions"
|
||||
style="width: 170px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'targetValue'">
|
||||
<InputNumber
|
||||
v-model:value="record.targetValue"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 100px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'targetUnit'">
|
||||
<Select
|
||||
v-model:value="record.targetUnit"
|
||||
:options="targetUnitOptions"
|
||||
style="width: 90px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'rewardGold'">
|
||||
<InputNumber
|
||||
v-model:value="record.rewardGold"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 110px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'jumpType'">
|
||||
<Select
|
||||
v-model:value="record.jumpType"
|
||||
:options="jumpTypeOptions"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'jumpPage'">
|
||||
<Input v-model:value="record.jumpPage" placeholder="/room" />
|
||||
</template>
|
||||
<template v-else-if="column.key === 'sortOrder'">
|
||||
<InputNumber
|
||||
v-model:value="record.sortOrder"
|
||||
:precision="0"
|
||||
style="width: 80px"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<Button danger type="link" @click="confirmRemoveTask(index)">删除</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<div class="actions">
|
||||
<Button @click="addTask">新增任务</Button>
|
||||
<Button :loading="saving" type="primary" @click="submitForm">
|
||||
保存配置
|
||||
</Button>
|
||||
</div>
|
||||
</TabPane>
|
||||
|
||||
<TabPane key="claims" tab="领取记录">
|
||||
<div class="toolbar">
|
||||
<Input
|
||||
v-model:value="claimQuery.userId"
|
||||
allow-clear
|
||||
placeholder="用户ID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="claimQuery.taskCode"
|
||||
allow-clear
|
||||
placeholder="任务编码"
|
||||
style="width: 220px"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="claimQuery.status"
|
||||
allow-clear
|
||||
:options="[
|
||||
{ label: '成功', value: 'SUCCESS' },
|
||||
{ label: '失败', value: 'FAILED' },
|
||||
]"
|
||||
placeholder="状态"
|
||||
style="width: 140px"
|
||||
/>
|
||||
<Button :loading="claimLoading" type="primary" @click="searchClaimRecords">
|
||||
查询
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
:columns="claimColumns"
|
||||
:data-source="claimPage.records"
|
||||
:loading="claimLoading"
|
||||
:pagination="{
|
||||
current: claimPage.current,
|
||||
pageSize: claimPage.size,
|
||||
showSizeChanger: true,
|
||||
total: claimPage.total,
|
||||
}"
|
||||
row-key="id"
|
||||
:scroll="{ x: 1580 }"
|
||||
@change="handleClaimTableChange"
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
<TabPane key="events" tab="事件流水">
|
||||
<div class="toolbar">
|
||||
<Input
|
||||
v-model:value="eventQuery.userId"
|
||||
allow-clear
|
||||
placeholder="用户ID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="eventQuery.taskCode"
|
||||
allow-clear
|
||||
placeholder="任务编码"
|
||||
style="width: 220px"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="eventQuery.eventType"
|
||||
allow-clear
|
||||
placeholder="事件类型"
|
||||
style="width: 220px"
|
||||
/>
|
||||
<Button :loading="eventLoading" type="primary" @click="searchEvents">
|
||||
查询
|
||||
</Button>
|
||||
</div>
|
||||
<Table
|
||||
:columns="eventColumns"
|
||||
:data-source="eventPage.records"
|
||||
:loading="eventLoading"
|
||||
:pagination="{
|
||||
current: eventPage.current,
|
||||
pageSize: eventPage.size,
|
||||
showSizeChanger: true,
|
||||
total: eventPage.total,
|
||||
}"
|
||||
row-key="id"
|
||||
:scroll="{ x: 1500 }"
|
||||
@change="handleEventTableChange"
|
||||
/>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.config-row {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
color: rgb(71 85 105);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.sub-text {
|
||||
color: rgb(100 116 139);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
</style>
|
||||
494
apps/src/views/resident-activity/voice-room-red-packet.vue
Normal file
494
apps/src/views/resident-activity/voice-room-red-packet.vue
Normal file
@ -0,0 +1,494 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Switch,
|
||||
Table,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Tag,
|
||||
message,
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
getVoiceRoomRedPacketConfig,
|
||||
pageVoiceRoomRedPacketRecords,
|
||||
retryVoiceRoomRedPacketRefund,
|
||||
saveVoiceRoomRedPacketConfig,
|
||||
} from '#/api/legacy/resident-activity';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
defineOptions({ name: 'ResidentVoiceRoomRedPacketPage' });
|
||||
|
||||
const accessStore = useAccessStore();
|
||||
const sysOriginOptions = computed(() => {
|
||||
const options = getAllowedSysOrigins(accessStore.accessCodes || []);
|
||||
return options.length > 0 ? options : getAllowedSysOrigins([]);
|
||||
});
|
||||
|
||||
const activeTab = ref('config');
|
||||
const loading = ref(false);
|
||||
const recordLoading = ref(false);
|
||||
const saving = ref(false);
|
||||
const selectedSysOrigin = ref('');
|
||||
|
||||
const form = reactive<Record<string, any>>({
|
||||
amountOptionsText: '15000,30000,70000,100000',
|
||||
configured: false,
|
||||
countOptionsText: '5,10,20,50',
|
||||
dailySendLimit: 10,
|
||||
delaySeconds: 300,
|
||||
enabled: false,
|
||||
refundAfterSeconds: 7200,
|
||||
sysOrigin: '',
|
||||
timezone: 'Asia/Riyadh',
|
||||
updateTime: '',
|
||||
});
|
||||
|
||||
const recordQuery = reactive<Record<string, any>>({
|
||||
cursor: 1,
|
||||
limit: 20,
|
||||
status: '',
|
||||
userId: '',
|
||||
});
|
||||
|
||||
const recordPage = reactive<Record<string, any>>({
|
||||
records: [],
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '初始化', value: 'INIT' },
|
||||
{ label: '生效中', value: 'ACTIVE' },
|
||||
{ label: '已抢完', value: 'FINISHED' },
|
||||
{ label: '已过期', value: 'EXPIRED' },
|
||||
{ label: '已退款', value: 'REFUNDED' },
|
||||
{ label: '退款失败', value: 'REFUND_FAILED' },
|
||||
{ label: '失败', value: 'FAILED' },
|
||||
];
|
||||
|
||||
const recordColumns = [
|
||||
{ dataIndex: 'packetNo', key: 'packetNo', title: '红包号', width: 190 },
|
||||
{ dataIndex: 'status', key: 'status', title: '状态', width: 110 },
|
||||
{ dataIndex: 'packetMode', key: 'packetMode', title: '形式', width: 100 },
|
||||
{ dataIndex: 'senderUserId', key: 'senderUserId', title: '发送人', width: 140 },
|
||||
{ dataIndex: 'roomId', key: 'roomId', title: '房间ID', width: 160 },
|
||||
{ dataIndex: 'amount', key: 'amount', title: '金额 / 剩余', width: 180 },
|
||||
{ dataIndex: 'count', key: 'count', title: '数量 / 剩余', width: 150 },
|
||||
{ dataIndex: 'refundStatus', key: 'refundStatus', title: '退款', width: 120 },
|
||||
{ dataIndex: 'createTime', key: 'createTime', title: '发送时间', width: 180 },
|
||||
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 120 },
|
||||
];
|
||||
|
||||
const statusMeta = computed(() => {
|
||||
if (!form.configured) {
|
||||
return { color: 'processing', text: '未配置' };
|
||||
}
|
||||
if (form.enabled) {
|
||||
return { color: 'success', text: '已启用' };
|
||||
}
|
||||
return { color: 'default', text: '已关闭' };
|
||||
});
|
||||
|
||||
function parseNumberList(value: string, fieldName: string) {
|
||||
const values = String(value || '')
|
||||
.split(',')
|
||||
.map((item) => Number(String(item).trim()))
|
||||
.filter((item) => Number.isFinite(item));
|
||||
if (values.length === 0) {
|
||||
message.warning(`请配置${fieldName}`);
|
||||
return [];
|
||||
}
|
||||
if (values.some((item) => item <= 0 || !Number.isInteger(item))) {
|
||||
message.warning(`${fieldName}必须是正整数,多个值用英文逗号分隔`);
|
||||
return [];
|
||||
}
|
||||
return Array.from(new Set(values));
|
||||
}
|
||||
|
||||
function listText(values: unknown, fallback: string) {
|
||||
if (Array.isArray(values) && values.length > 0) {
|
||||
return values.map((item) => String(item)).join(',');
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function normalizeConfig(result: null | Record<string, any> | undefined) {
|
||||
const value = result || {};
|
||||
form.amountOptionsText = listText(value.amountOptions, '15000,30000,70000,100000');
|
||||
form.configured = Boolean(value.configured);
|
||||
form.countOptionsText = listText(value.countOptions, '5,10,20,50');
|
||||
form.dailySendLimit = Number(value.dailySendLimit || 10);
|
||||
form.delaySeconds = Number(value.delaySeconds || 300);
|
||||
form.enabled = Boolean(value.enabled);
|
||||
form.refundAfterSeconds = Number(value.refundAfterSeconds || 7200);
|
||||
form.sysOrigin = String(value.sysOrigin || selectedSysOrigin.value || '');
|
||||
form.timezone = String(value.timezone || 'Asia/Riyadh');
|
||||
form.updateTime = String(value.updateTime || '');
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await getVoiceRoomRedPacketConfig(selectedSysOrigin.value);
|
||||
normalizeConfig(result);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
const amountOptions = parseNumberList(form.amountOptionsText, '红包金额');
|
||||
const countOptions = parseNumberList(form.countOptionsText, '红包数量');
|
||||
if (amountOptions.length === 0 || countOptions.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(form.refundAfterSeconds || 0) <= Number(form.delaySeconds || 0)) {
|
||||
message.warning('退款时间必须大于延时领取时间');
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await saveVoiceRoomRedPacketConfig({
|
||||
amountOptions,
|
||||
countOptions,
|
||||
dailySendLimit: Number(form.dailySendLimit || 10),
|
||||
delaySeconds: Number(form.delaySeconds || 300),
|
||||
enabled: Boolean(form.enabled),
|
||||
refundAfterSeconds: Number(form.refundAfterSeconds || 7200),
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
timezone: String(form.timezone || '').trim() || 'Asia/Riyadh',
|
||||
});
|
||||
message.success('保存成功');
|
||||
await loadConfig();
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function confirmSave() {
|
||||
Modal.confirm({
|
||||
async onOk() {
|
||||
await submitForm();
|
||||
},
|
||||
title: '确认保存当前系统的语音房红包配置?',
|
||||
});
|
||||
}
|
||||
|
||||
async function loadRecords(reset = false) {
|
||||
if (!selectedSysOrigin.value) {
|
||||
return;
|
||||
}
|
||||
if (reset) {
|
||||
recordQuery.cursor = 1;
|
||||
}
|
||||
recordLoading.value = true;
|
||||
try {
|
||||
const result = await pageVoiceRoomRedPacketRecords({
|
||||
...recordQuery,
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
});
|
||||
recordPage.records = Array.isArray(result.records) ? result.records : [];
|
||||
recordPage.total = Number(result.total || 0);
|
||||
} finally {
|
||||
recordLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function searchRecords() {
|
||||
void loadRecords(true);
|
||||
}
|
||||
|
||||
function handleRecordTableChange(pagination: Record<string, any>) {
|
||||
recordQuery.cursor = Number(pagination.current || 1);
|
||||
recordQuery.limit = Number(pagination.pageSize || 20);
|
||||
void loadRecords();
|
||||
}
|
||||
|
||||
async function handleRetryRefund(record: Record<string, any>) {
|
||||
const packetNo = String(record.packetNo || '');
|
||||
if (!packetNo) {
|
||||
return;
|
||||
}
|
||||
await retryVoiceRoomRedPacketRefund(packetNo);
|
||||
message.success('已提交重试');
|
||||
await loadRecords();
|
||||
}
|
||||
|
||||
function statusColor(status: string) {
|
||||
switch (String(status || '').toUpperCase()) {
|
||||
case 'ACTIVE':
|
||||
return 'success';
|
||||
case 'FINISHED':
|
||||
case 'REFUNDED':
|
||||
return 'blue';
|
||||
case 'EXPIRED':
|
||||
return 'warning';
|
||||
case 'FAILED':
|
||||
case 'REFUND_FAILED':
|
||||
return 'error';
|
||||
default:
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
|
||||
function refundColor(status: string) {
|
||||
switch (String(status || '').toUpperCase()) {
|
||||
case 'SUCCESS':
|
||||
return 'success';
|
||||
case 'FAILED':
|
||||
return 'error';
|
||||
case 'PENDING':
|
||||
return 'processing';
|
||||
default:
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
sysOriginOptions,
|
||||
(options) => {
|
||||
if (!selectedSysOrigin.value) {
|
||||
selectedSysOrigin.value = String(options[0]?.value || '');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
selectedSysOrigin,
|
||||
(value) => {
|
||||
if (value) {
|
||||
void loadConfig();
|
||||
if (activeTab.value === 'records') {
|
||||
void loadRecords(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(activeTab, (value) => {
|
||||
if (value === 'records') {
|
||||
void loadRecords(true);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="红包">
|
||||
<div class="voice-room-red-packet-page">
|
||||
<Card>
|
||||
<Space wrap>
|
||||
<span>系统</span>
|
||||
<Select
|
||||
v-model:value="selectedSysOrigin"
|
||||
:options="sysOriginOptions"
|
||||
style="width: 180px"
|
||||
/>
|
||||
<Tag :color="statusMeta.color">{{ statusMeta.text }}</Tag>
|
||||
<span v-if="form.updateTime" class="muted-text">
|
||||
更新时间:{{ form.updateTime }}
|
||||
</span>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<Tabs v-model:active-key="activeTab">
|
||||
<TabPane key="config" tab="配置">
|
||||
<Spin :spinning="loading">
|
||||
<Card>
|
||||
<div class="config-grid">
|
||||
<label class="field-row">
|
||||
<span>启用红包</span>
|
||||
<Switch v-model:checked="form.enabled" />
|
||||
</label>
|
||||
<label class="field-row">
|
||||
<span>每日发送次数</span>
|
||||
<InputNumber
|
||||
v-model:value="form.dailySendLimit"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
class="field-control"
|
||||
/>
|
||||
</label>
|
||||
<label class="field-row">
|
||||
<span>延时领取秒数</span>
|
||||
<InputNumber
|
||||
v-model:value="form.delaySeconds"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
class="field-control"
|
||||
/>
|
||||
</label>
|
||||
<label class="field-row">
|
||||
<span>退款等待秒数</span>
|
||||
<InputNumber
|
||||
v-model:value="form.refundAfterSeconds"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
class="field-control"
|
||||
/>
|
||||
</label>
|
||||
<label class="field-row">
|
||||
<span>活动时区</span>
|
||||
<Input v-model:value="form.timezone" class="field-control" />
|
||||
</label>
|
||||
<label class="field-row field-wide">
|
||||
<span>红包金额</span>
|
||||
<Input
|
||||
v-model:value="form.amountOptionsText"
|
||||
class="field-control"
|
||||
placeholder="15000,30000,70000,100000"
|
||||
/>
|
||||
</label>
|
||||
<label class="field-row field-wide">
|
||||
<span>红包数量</span>
|
||||
<Input
|
||||
v-model:value="form.countOptionsText"
|
||||
class="field-control"
|
||||
placeholder="5,10,20,50"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<Space>
|
||||
<Button @click="loadConfig">刷新</Button>
|
||||
<Button type="primary" :loading="saving" @click="confirmSave">
|
||||
保存配置
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Card>
|
||||
</Spin>
|
||||
</TabPane>
|
||||
|
||||
<TabPane key="records" tab="发包记录">
|
||||
<Card>
|
||||
<Space wrap class="record-toolbar">
|
||||
<Select
|
||||
v-model:value="recordQuery.status"
|
||||
:options="statusOptions"
|
||||
style="width: 140px"
|
||||
/>
|
||||
<Input
|
||||
v-model:value="recordQuery.userId"
|
||||
allow-clear
|
||||
placeholder="发送人ID"
|
||||
style="width: 180px"
|
||||
/>
|
||||
<Button type="primary" @click="searchRecords">查询</Button>
|
||||
<Button @click="loadRecords()">刷新</Button>
|
||||
</Space>
|
||||
|
||||
<Table
|
||||
:columns="recordColumns"
|
||||
:data-source="recordPage.records"
|
||||
:loading="recordLoading"
|
||||
:pagination="{
|
||||
current: recordQuery.cursor,
|
||||
pageSize: recordQuery.limit,
|
||||
showSizeChanger: true,
|
||||
total: recordPage.total,
|
||||
}"
|
||||
:scroll="{ x: 1360 }"
|
||||
row-key="packetNo"
|
||||
@change="handleRecordTableChange"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<Tag :color="statusColor(record.status)">
|
||||
{{ record.status || '-' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'amount'">
|
||||
{{ record.totalAmount || 0 }} / {{ record.remainAmount || 0 }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'count'">
|
||||
{{ record.totalCount || 0 }} / {{ record.remainCount || 0 }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'refundStatus'">
|
||||
<Tag :color="refundColor(record.refundStatus)">
|
||||
{{ record.refundStatus || 'NONE' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<Button
|
||||
v-if="record.refundStatus === 'FAILED'"
|
||||
size="small"
|
||||
@click="handleRetryRefund(record)"
|
||||
>
|
||||
重试退款
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Card>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.voice-room-red-packet-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.muted-text {
|
||||
color: rgb(0 0 0 / 45%);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.config-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(260px, 1fr));
|
||||
gap: 18px 24px;
|
||||
max-width: 920px;
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.field-row > span {
|
||||
flex: 0 0 120px;
|
||||
color: rgb(0 0 0 / 65%);
|
||||
}
|
||||
|
||||
.field-control {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.field-wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.record-toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
@ -10,8 +10,10 @@ import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import {
|
||||
addRegionAssistConfig,
|
||||
addRegionConfig,
|
||||
createVoiceRoomRegionImGroup,
|
||||
deleteRegionAssistConfig,
|
||||
getCountryAlls,
|
||||
listVoiceRoomRegionImGroups,
|
||||
regionAssistConfigTable,
|
||||
regionConfigTable,
|
||||
resetRegionWithdrawal,
|
||||
@ -45,6 +47,7 @@ import {
|
||||
Table,
|
||||
TabPane,
|
||||
Tabs,
|
||||
Tag,
|
||||
TextArea,
|
||||
Tooltip,
|
||||
message,
|
||||
@ -241,13 +244,16 @@ const accessStore = useAccessStore();
|
||||
const activeTab = ref('region');
|
||||
const loadingRegion = ref(false);
|
||||
const loadingAssist = ref(false);
|
||||
const loadingImGroup = ref(false);
|
||||
const savingRegion = ref(false);
|
||||
const savingAssist = ref(false);
|
||||
const creatingImGroupCode = ref('');
|
||||
const regionDrawerOpen = ref(false);
|
||||
const assistDrawerOpen = ref(false);
|
||||
|
||||
const regionList = ref<Array<Record<string, any>>>([]);
|
||||
const assistList = ref<Array<Record<string, any>>>([]);
|
||||
const imGroupList = ref<Array<Record<string, any>>>([]);
|
||||
const regionOptions = ref<Array<Record<string, any>>>([]);
|
||||
const countries = ref<Array<Record<string, any>>>([]);
|
||||
|
||||
@ -255,6 +261,10 @@ const regionQuery = reactive({
|
||||
sysOrigin: '',
|
||||
});
|
||||
|
||||
const imGroupQuery = reactive({
|
||||
sysOrigin: '',
|
||||
});
|
||||
|
||||
const assistQuery = reactive({
|
||||
regionId: '',
|
||||
sysOrigin: '',
|
||||
@ -295,6 +305,18 @@ const assistColumns = [
|
||||
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 140 },
|
||||
];
|
||||
|
||||
const imGroupColumns = [
|
||||
{ dataIndex: 'regionCode', key: 'regionCode', title: '区域编码', width: 140 },
|
||||
{ dataIndex: 'regionName', key: 'regionName', title: '区域', width: 160 },
|
||||
{ dataIndex: 'countryCodes', key: 'countryCodes', title: '国家', width: 220 },
|
||||
{ dataIndex: 'groupId', key: 'groupId', title: 'IM 群组 ID', width: 220 },
|
||||
{ dataIndex: 'groupName', key: 'groupName', title: 'IM 群组名称', width: 240 },
|
||||
{ dataIndex: 'status', key: 'status', title: '状态', width: 120 },
|
||||
{ dataIndex: 'lastError', key: 'lastError', title: '错误信息', width: 260 },
|
||||
{ dataIndex: 'updateTime', key: 'updateTime', title: '更新时间', width: 180 },
|
||||
{ dataIndex: 'actions', key: 'actions', title: '操作', width: 140 },
|
||||
];
|
||||
|
||||
const specialAssistTypes = new Set([
|
||||
'WITHDRAW_PROPORTION_TIPS',
|
||||
'COIN_SELLER_WITHDRAW_PROPORTION_TIPS',
|
||||
@ -340,6 +362,9 @@ watch(
|
||||
if (!assistQuery.sysOrigin) {
|
||||
assistQuery.sysOrigin = options[0]?.value ?? 'LIKEI';
|
||||
}
|
||||
if (!imGroupQuery.sysOrigin) {
|
||||
imGroupQuery.sysOrigin = options[0]?.value ?? 'LIKEI';
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@ -353,6 +378,15 @@ watch(
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => activeTab.value,
|
||||
(tab) => {
|
||||
if (tab === 'imGroup' && imGroupList.value.length === 0) {
|
||||
loadImGroupList();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
function assignRegionForm(target: ReturnType<typeof createRegionForm>) {
|
||||
Object.assign(regionForm, cloneValue(target));
|
||||
}
|
||||
@ -501,6 +535,58 @@ async function loadAssistList() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadImGroupList() {
|
||||
if (!imGroupQuery.sysOrigin) {
|
||||
imGroupList.value = [];
|
||||
return;
|
||||
}
|
||||
loadingImGroup.value = true;
|
||||
try {
|
||||
const [regions, groups] = await Promise.all([
|
||||
regionConfigTable({ sysOrigin: imGroupQuery.sysOrigin }),
|
||||
listVoiceRoomRegionImGroups({ sysOrigin: imGroupQuery.sysOrigin }),
|
||||
]);
|
||||
const groupMap = new Map(
|
||||
(groups || []).map((item) => [String(item.regionCode || ''), item]),
|
||||
);
|
||||
const seen = new Set<string>();
|
||||
const rows: Array<Record<string, any>> = (regions || []).map((region) => {
|
||||
const regionCode = String(region.regionCode || '');
|
||||
const group = groupMap.get(regionCode) || {};
|
||||
seen.add(regionCode);
|
||||
return {
|
||||
...region,
|
||||
configured: Boolean(group.configured),
|
||||
groupId: group.groupId || '',
|
||||
groupName: group.groupName || '',
|
||||
lastError: group.lastError || '',
|
||||
status: group.status || '',
|
||||
updateTime: group.updateTime || '',
|
||||
};
|
||||
});
|
||||
for (const group of groups || []) {
|
||||
const regionCode = String(group.regionCode || '');
|
||||
if (seen.has(regionCode)) {
|
||||
continue;
|
||||
}
|
||||
rows.push({
|
||||
configured: Boolean(group.configured),
|
||||
countryCodes: '',
|
||||
groupId: group.groupId || '',
|
||||
groupName: group.groupName || '',
|
||||
lastError: group.lastError || '',
|
||||
regionCode,
|
||||
regionName: group.regionName || regionCode,
|
||||
status: group.status || '',
|
||||
updateTime: group.updateTime || '',
|
||||
});
|
||||
}
|
||||
imGroupList.value = rows;
|
||||
} finally {
|
||||
loadingImGroup.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCountryOptions() {
|
||||
countries.value = (await getCountryAlls()) || [];
|
||||
}
|
||||
@ -527,6 +613,9 @@ async function handleSaveRegion() {
|
||||
regionDrawerOpen.value = false;
|
||||
await loadRegionList();
|
||||
await loadRegionOptions();
|
||||
if (activeTab.value === 'imGroup') {
|
||||
await loadImGroupList();
|
||||
}
|
||||
} finally {
|
||||
savingRegion.value = false;
|
||||
}
|
||||
@ -601,6 +690,46 @@ function handleResetWithdrawal(row: Record<string, any>) {
|
||||
});
|
||||
}
|
||||
|
||||
function getImGroupStatusText(row: Record<string, any>) {
|
||||
if (row.configured || row.status === 'ACTIVE') {
|
||||
return '已创建';
|
||||
}
|
||||
if (row.status === 'FAILED') {
|
||||
return '创建失败';
|
||||
}
|
||||
return '未创建';
|
||||
}
|
||||
|
||||
function getImGroupStatusColor(row: Record<string, any>) {
|
||||
if (row.configured || row.status === 'ACTIVE') {
|
||||
return 'green';
|
||||
}
|
||||
if (row.status === 'FAILED') {
|
||||
return 'red';
|
||||
}
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function handleCreateImGroup(row: Record<string, any>) {
|
||||
Modal.confirm({
|
||||
async onOk() {
|
||||
creatingImGroupCode.value = row.regionCode;
|
||||
try {
|
||||
await createVoiceRoomRegionImGroup({
|
||||
regionCode: row.regionCode,
|
||||
regionName: row.regionName,
|
||||
sysOrigin: imGroupQuery.sysOrigin,
|
||||
});
|
||||
message.success('创建成功');
|
||||
await loadImGroupList();
|
||||
} finally {
|
||||
creatingImGroupCode.value = '';
|
||||
}
|
||||
},
|
||||
title: `确认创建 ${row.regionName || row.regionCode} 的 IM 群组?`,
|
||||
});
|
||||
}
|
||||
|
||||
function openAssistCreate() {
|
||||
assistDrawerTitle.value = '添加';
|
||||
fillAssistForm();
|
||||
@ -690,6 +819,59 @@ loadCountryOptions();
|
||||
</Card>
|
||||
</TabPane>
|
||||
|
||||
<TabPane key="imGroup" tab="IM 群组">
|
||||
<Card>
|
||||
<InlineFilterToolbar class="toolbar">
|
||||
<InlineFilterField label="系统">
|
||||
<SysOriginSelect
|
||||
v-model:value="imGroupQuery.sysOrigin"
|
||||
style="width: 140px"
|
||||
@change="loadImGroupList"
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
</InlineFilterField>
|
||||
<Button type="primary" @click="loadImGroupList">搜索</Button>
|
||||
</InlineFilterToolbar>
|
||||
|
||||
<Table
|
||||
:columns="imGroupColumns"
|
||||
:data-source="imGroupList"
|
||||
:loading="loadingImGroup"
|
||||
:pagination="false"
|
||||
:row-key="(record: Record<string, any>) => record.regionCode"
|
||||
:scroll="{ x: 1540 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'status'">
|
||||
<Tag :color="getImGroupStatusColor(record)">
|
||||
{{ getImGroupStatusText(record) }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'lastError'">
|
||||
<Tooltip v-if="record.lastError" :title="record.lastError">
|
||||
<span class="error-text">{{ record.lastError }}</span>
|
||||
</Tooltip>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'updateTime'">
|
||||
{{ formatDate(record.updateTime) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<Button
|
||||
:disabled="record.configured || record.status === 'ACTIVE'"
|
||||
:loading="creatingImGroupCode === record.regionCode"
|
||||
size="small"
|
||||
type="link"
|
||||
@click="handleCreateImGroup(record)"
|
||||
>
|
||||
创建群组
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Card>
|
||||
</TabPane>
|
||||
|
||||
<TabPane key="assist" tab="辅助配置">
|
||||
<Card>
|
||||
<InlineFilterToolbar class="toolbar">
|
||||
@ -1028,6 +1210,16 @@ loadCountryOptions();
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.error-text {
|
||||
color: #cf1322;
|
||||
display: inline-block;
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.metadata-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
93
scripts/sql/sync_admin_app_home_popup_menu.sql
Normal file
93
scripts/sql/sync_admin_app_home_popup_menu.sql
Normal file
@ -0,0 +1,93 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
INSERT INTO sys_menu (
|
||||
id,
|
||||
parent_id,
|
||||
menu_name,
|
||||
path,
|
||||
menu_type,
|
||||
icon,
|
||||
create_user,
|
||||
update_user,
|
||||
sort,
|
||||
status,
|
||||
router,
|
||||
alias
|
||||
)
|
||||
SELECT
|
||||
1700000268,
|
||||
parent_menu.id,
|
||||
'首页弹窗管理',
|
||||
'app-system/home-popup-manager',
|
||||
2,
|
||||
'form',
|
||||
'0',
|
||||
'0',
|
||||
2,
|
||||
0,
|
||||
'home-popups',
|
||||
'AppSystemHomePopupManager'
|
||||
FROM (
|
||||
SELECT id
|
||||
FROM sys_menu
|
||||
WHERE alias = 'AppSystemManager'
|
||||
OR alias = 'AppSysManager'
|
||||
OR path = '/app/sys/mamange'
|
||||
OR router = '/app/sys/mamange'
|
||||
ORDER BY id
|
||||
LIMIT 1
|
||||
) AS parent_menu
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM sys_menu WHERE alias = 'AppSystemHomePopupManager'
|
||||
);
|
||||
|
||||
UPDATE sys_menu
|
||||
SET
|
||||
parent_id = (
|
||||
SELECT parent_menu.id
|
||||
FROM (
|
||||
SELECT id
|
||||
FROM sys_menu
|
||||
WHERE alias = 'AppSystemManager'
|
||||
OR alias = 'AppSysManager'
|
||||
OR path = '/app/sys/mamange'
|
||||
OR router = '/app/sys/mamange'
|
||||
ORDER BY id
|
||||
LIMIT 1
|
||||
) AS parent_menu
|
||||
),
|
||||
menu_name = '首页弹窗管理',
|
||||
path = 'app-system/home-popup-manager',
|
||||
menu_type = 2,
|
||||
icon = 'form',
|
||||
create_user = '0',
|
||||
update_user = '0',
|
||||
sort = 2,
|
||||
status = 0,
|
||||
router = 'home-popups'
|
||||
WHERE alias = 'AppSystemHomePopupManager';
|
||||
|
||||
INSERT INTO sys_role_menu (role_id, menu_id)
|
||||
SELECT DISTINCT
|
||||
parent_role.role_id,
|
||||
target_menu.id
|
||||
FROM sys_role_menu AS parent_role
|
||||
JOIN sys_menu AS target_menu
|
||||
ON target_menu.alias = 'AppSystemHomePopupManager'
|
||||
LEFT JOIN sys_role_menu AS existing_role_menu
|
||||
ON existing_role_menu.role_id = parent_role.role_id
|
||||
AND existing_role_menu.menu_id = target_menu.id
|
||||
WHERE parent_role.menu_id = (
|
||||
SELECT parent_menu.id
|
||||
FROM (
|
||||
SELECT id
|
||||
FROM sys_menu
|
||||
WHERE alias = 'AppSystemManager'
|
||||
OR alias = 'AppSysManager'
|
||||
OR path = '/app/sys/mamange'
|
||||
OR router = '/app/sys/mamange'
|
||||
ORDER BY id
|
||||
LIMIT 1
|
||||
) AS parent_menu
|
||||
)
|
||||
AND existing_role_menu.id IS NULL;
|
||||
@ -416,6 +416,59 @@ SET
|
||||
router = 'recharge-reward/config'
|
||||
WHERE alias = 'ResidentRechargeRewardConfig';
|
||||
|
||||
INSERT INTO sys_menu (
|
||||
id,
|
||||
parent_id,
|
||||
menu_name,
|
||||
path,
|
||||
menu_type,
|
||||
icon,
|
||||
create_user,
|
||||
update_user,
|
||||
sort,
|
||||
status,
|
||||
router,
|
||||
alias
|
||||
)
|
||||
SELECT
|
||||
1700000263,
|
||||
(SELECT id FROM sys_menu WHERE alias = 'ResidentActivityManager' LIMIT 1),
|
||||
'每日任务',
|
||||
'resident-activity/daily-task-config/index',
|
||||
2,
|
||||
'form',
|
||||
'0',
|
||||
'0',
|
||||
8,
|
||||
0,
|
||||
'daily-task/config',
|
||||
'ResidentDailyTaskConfig'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM sys_menu WHERE alias = 'ResidentDailyTaskConfig'
|
||||
);
|
||||
|
||||
UPDATE sys_menu
|
||||
SET
|
||||
parent_id = (
|
||||
SELECT resident_menu.id
|
||||
FROM (
|
||||
SELECT id
|
||||
FROM sys_menu
|
||||
WHERE alias = 'ResidentActivityManager'
|
||||
LIMIT 1
|
||||
) AS resident_menu
|
||||
),
|
||||
menu_name = '每日任务',
|
||||
path = 'resident-activity/daily-task-config/index',
|
||||
menu_type = 2,
|
||||
icon = 'form',
|
||||
create_user = '0',
|
||||
update_user = '0',
|
||||
sort = 8,
|
||||
status = 0,
|
||||
router = 'daily-task/config'
|
||||
WHERE alias = 'ResidentDailyTaskConfig';
|
||||
|
||||
INSERT INTO sys_menu (
|
||||
id,
|
||||
parent_id,
|
||||
@ -559,6 +612,7 @@ JOIN sys_menu AS target_menu
|
||||
'ResidentSpecifiedGiftWeeklyRank',
|
||||
'ResidentVipConfig',
|
||||
'ResidentRechargeRewardConfig',
|
||||
'ResidentDailyTaskConfig',
|
||||
'OperateGameManager',
|
||||
'GameConfig',
|
||||
'OperateBaishunGameManage'
|
||||
@ -569,6 +623,21 @@ LEFT JOIN sys_role_menu AS existing_role_menu
|
||||
WHERE parent_role.menu_id = 1700000057
|
||||
AND existing_role_menu.id IS NULL;
|
||||
|
||||
INSERT INTO sys_role_menu (role_id, menu_id)
|
||||
SELECT DISTINCT
|
||||
parent_role.role_id,
|
||||
target_menu.id
|
||||
FROM sys_role_menu AS parent_role
|
||||
JOIN sys_menu AS parent_menu
|
||||
ON parent_menu.id = parent_role.menu_id
|
||||
AND parent_menu.alias = 'ResidentActivityManager'
|
||||
JOIN sys_menu AS target_menu
|
||||
ON target_menu.alias = 'ResidentDailyTaskConfig'
|
||||
LEFT JOIN sys_role_menu AS existing_role_menu
|
||||
ON existing_role_menu.role_id = parent_role.role_id
|
||||
AND existing_role_menu.menu_id = target_menu.id
|
||||
WHERE existing_role_menu.id IS NULL;
|
||||
|
||||
UPDATE sys_menu
|
||||
SET menu_name = CONVERT(0xE5B8B8E9A9BBE6B4BBE58AA8 USING utf8mb4)
|
||||
WHERE alias = 'ResidentActivityManager';
|
||||
@ -601,6 +670,10 @@ UPDATE sys_menu
|
||||
SET menu_name = CONVERT(0xE58585E580BCE5A596E58AB1E9858DE7BDAE USING utf8mb4)
|
||||
WHERE alias = 'ResidentRechargeRewardConfig';
|
||||
|
||||
UPDATE sys_menu
|
||||
SET menu_name = CONVERT(0xE6AF8FE697A5E4BBBBE58AA1 USING utf8mb4)
|
||||
WHERE alias = 'ResidentDailyTaskConfig';
|
||||
|
||||
UPDATE sys_menu
|
||||
SET menu_name = CONVERT(0xE6B8B8E6888FE7AEA1E79086 USING utf8mb4)
|
||||
WHERE alias = 'OperateGameManager';
|
||||
@ -612,3 +685,71 @@ WHERE alias = 'GameConfig';
|
||||
UPDATE sys_menu
|
||||
SET menu_name = CONVERT(0xE799BEE9A1BAE9858DE7BDAE USING utf8mb4)
|
||||
WHERE alias = 'OperateBaishunGameManage';
|
||||
|
||||
SET @resident_activity_id := (
|
||||
SELECT id FROM sys_menu WHERE alias = 'ResidentActivityManager' LIMIT 1
|
||||
);
|
||||
|
||||
INSERT INTO sys_menu (
|
||||
id,
|
||||
parent_id,
|
||||
menu_name,
|
||||
path,
|
||||
menu_type,
|
||||
icon,
|
||||
create_user,
|
||||
update_user,
|
||||
sort,
|
||||
status,
|
||||
router,
|
||||
alias
|
||||
)
|
||||
SELECT
|
||||
next_id,
|
||||
@resident_activity_id,
|
||||
CONVERT(0xE7BAA2E58C85 USING utf8mb4),
|
||||
'resident-activity/voice-room-red-packet',
|
||||
2,
|
||||
'form',
|
||||
'0',
|
||||
'0',
|
||||
9,
|
||||
0,
|
||||
'voice-room-red-packet',
|
||||
'ResidentVoiceRoomRedPacket'
|
||||
FROM (
|
||||
SELECT COALESCE(MAX(id), 1700000000) + 1 AS next_id
|
||||
FROM sys_menu
|
||||
) AS menu_id
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM sys_menu WHERE alias = 'ResidentVoiceRoomRedPacket'
|
||||
);
|
||||
|
||||
UPDATE sys_menu
|
||||
SET
|
||||
parent_id = @resident_activity_id,
|
||||
menu_name = CONVERT(0xE7BAA2E58C85 USING utf8mb4),
|
||||
path = 'resident-activity/voice-room-red-packet',
|
||||
menu_type = 2,
|
||||
icon = 'form',
|
||||
create_user = '0',
|
||||
update_user = '0',
|
||||
sort = 9,
|
||||
status = 0,
|
||||
router = 'voice-room-red-packet'
|
||||
WHERE alias = 'ResidentVoiceRoomRedPacket';
|
||||
|
||||
INSERT INTO sys_role_menu (role_id, menu_id)
|
||||
SELECT DISTINCT
|
||||
parent_role.role_id,
|
||||
target_menu.id
|
||||
FROM sys_role_menu AS parent_role
|
||||
JOIN sys_menu AS parent_menu
|
||||
ON parent_menu.id = parent_role.menu_id
|
||||
AND parent_menu.alias = 'ResidentActivityManager'
|
||||
JOIN sys_menu AS target_menu
|
||||
ON target_menu.alias = 'ResidentVoiceRoomRedPacket'
|
||||
LEFT JOIN sys_role_menu AS existing_role_menu
|
||||
ON existing_role_menu.role_id = parent_role.role_id
|
||||
AND existing_role_menu.menu_id = target_menu.id
|
||||
WHERE existing_role_menu.id IS NULL;
|
||||
|
||||
76
scripts/sql/sync_team_region_config_menu.sql
Normal file
76
scripts/sql/sync_team_region_config_menu.sql
Normal file
@ -0,0 +1,76 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
SET @team_manager_id := (
|
||||
SELECT id FROM sys_menu WHERE alias = 'TeamManager' LIMIT 1
|
||||
);
|
||||
|
||||
UPDATE sys_menu
|
||||
SET
|
||||
parent_id = @team_manager_id,
|
||||
menu_name = '区域配置',
|
||||
path = 'team/region-config/index',
|
||||
menu_type = 2,
|
||||
icon = 'form',
|
||||
update_user = '0',
|
||||
sort = 213,
|
||||
status = 0,
|
||||
router = 'region/config'
|
||||
WHERE alias = 'SystemRegionConfig';
|
||||
|
||||
UPDATE sys_menu
|
||||
SET
|
||||
parent_id = @team_manager_id,
|
||||
menu_name = '区域配置',
|
||||
path = 'team/region-config/index',
|
||||
menu_type = 2,
|
||||
icon = 'form',
|
||||
update_user = '0',
|
||||
sort = 213,
|
||||
status = 0,
|
||||
router = 'region/config',
|
||||
alias = 'SystemRegionConfig'
|
||||
WHERE alias = 'RegionConfig'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM (
|
||||
SELECT id FROM sys_menu WHERE alias = 'SystemRegionConfig' LIMIT 1
|
||||
) AS existing_region_config
|
||||
);
|
||||
|
||||
INSERT INTO sys_menu (
|
||||
id,
|
||||
parent_id,
|
||||
menu_name,
|
||||
path,
|
||||
menu_type,
|
||||
icon,
|
||||
create_user,
|
||||
update_user,
|
||||
sort,
|
||||
status,
|
||||
router,
|
||||
alias
|
||||
)
|
||||
SELECT
|
||||
next_id,
|
||||
@team_manager_id,
|
||||
'区域配置',
|
||||
'team/region-config/index',
|
||||
2,
|
||||
'form',
|
||||
'0',
|
||||
'0',
|
||||
213,
|
||||
0,
|
||||
'region/config',
|
||||
'SystemRegionConfig'
|
||||
FROM (
|
||||
SELECT COALESCE(MAX(id), 1700000000) + 1 AS next_id
|
||||
FROM sys_menu
|
||||
) AS menu_id
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM sys_menu WHERE alias = 'SystemRegionConfig'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM sys_menu WHERE id = 1700000089
|
||||
);
|
||||
Loading…
x
Reference in New Issue
Block a user