文件
shanghaipeiwan/admin/arco-design-pro-vite/src/views/activity/list/index.vue

433 行
15 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<div class="container">
<a-breadcrumb class="breadcrumb">
<a-breadcrumb-item>活动与组局监管</a-breadcrumb-item>
<a-breadcrumb-item>同城组局列表</a-breadcrumb-item>
</a-breadcrumb>
<a-card class="general-card" title="同城组局全流程监管">
<template #extra>
<a-space>
<a-button type="primary" @click="openCreateModal">
<template #icon><icon-plus /></template>
发起同城组局
</a-button>
<a-button @click="fetchData">
<template #icon><icon-refresh /></template>
刷新
</a-button>
</a-space>
</template>
<!-- 筛选栏 -->
<a-row :gutter="16" style="margin-bottom: 16px">
<a-col :span="6">
<a-input
v-model="searchKeyword"
placeholder="搜索组局标题、地点"
allow-clear
>
<template #prefix><icon-search /></template>
</a-input>
</a-col>
<a-col :span="5">
<a-select v-model="categoryFilter" placeholder="选择活动品类" allow-clear>
<a-option value="ALL">全部品类</a-option>
<a-option value="同城陪吃">同城陪吃</a-option>
<a-option value="同城陪喝">同城陪喝</a-option>
<a-option value="KTV陪唱">KTV陪唱</a-option>
<a-option value="线上电竞">线上电竞</a-option>
</a-select>
</a-col>
<a-col :span="5">
<a-select v-model="payTypeFilter" placeholder="付费类型" allow-clear>
<a-option :value="0">全部模式</a-option>
<a-option :value="1">AA制付费</a-option>
<a-option :value="2">项目制包揽</a-option>
</a-select>
</a-col>
</a-row>
<!-- 组局表格 -->
<a-table
:data="filteredList"
:loading="loading"
:pagination="{ pageSize: 10, showTotal: true }"
row-key="id"
>
<template #columns>
<a-table-column title="活动ID" data-index="id" :width="130">
<template #cell="{ record }">
<span class="code-font">{{ record.id }}</span>
</template>
</a-table-column>
<a-table-column title="组局详情" :width="260">
<template #cell="{ record }">
<div class="activity-title">{{ record.title }}</div>
<div class="activity-location">
<icon-location style="margin-right: 4px; color: #165dff" />
{{ record.location || '公开商圈集合' }}
</div>
</template>
</a-table-column>
<a-table-column title="品类" :width="110">
<template #cell="{ record }">
<a-tag :color="getCategoryColor(record.gameCategory)">
{{ record.gameCategory }}
</a-tag>
</template>
</a-table-column>
<a-table-column title="付费模式" :width="110">
<template #cell="{ record }">
<a-tag :color="record.payType === 1 ? 'blue' : 'gold'">
{{ record.payType === 1 ? 'AA制付费' : '项目制包揽' }}
</a-tag>
</template>
</a-table-column>
<a-table-column title="费用预算" :width="120">
<template #cell="{ record }">
<div v-if="record.perPersonFeeCents" class="price-text">
¥{{ (record.perPersonFeeCents / 100).toFixed(2) }}
<span class="sub-text">/人</span>
</div>
<div v-else-if="record.totalFeeCents" class="price-text">
¥{{ (record.totalFeeCents / 100).toFixed(2) }}
<span class="sub-text">总额</span>
</div>
</template>
</a-table-column>
<a-table-column title="报名进度" :width="130">
<template #cell="{ record }">
<a-progress
:percent="record.maxParticipants ? Math.min(1, (record.joinedCount || 0) / record.maxParticipants) : 0.5"
size="small"
:status="(record.joinedCount || 0) >= record.maxParticipants ? 'success' : 'normal'"
/>
<div style="font-size: 12px; margin-top: 4px; color: var(--color-text-3)">
已报 {{ record.joinedCount || 0 }} / 限 {{ record.maxParticipants }}人
</div>
</template>
</a-table-column>
<a-table-column title="动态改价" :width="130">
<template #cell="{ record }">
<a-badge
:status="record.allowDynamicPrice ? 'processing' : 'default'"
:text="record.allowDynamicPrice ? '允许追加加价' : '固定出价'"
/>
<div v-if="record.priceAdjustRule" style="font-size: 11px; color: var(--color-text-3)">
高价取齐差额同享
</div>
</template>
</a-table-column>
<a-table-column title="操作" :width="260" fixed="right">
<template #cell="{ record }">
<a-space>
<a-button
type="text"
size="small"
@click="goToVerify(record.id)"
>
4位核销码
</a-button>
<a-button
type="text"
size="small"
@click="openAdjustModal(record)"
>
追加赏金
</a-button>
<a-popconfirm
v-if="record.status !== 'CANCELLED' && record.status !== 'FINISHED'"
content="确定要违规下架该组局吗?下架后将自动原路退款已报名成员。"
type="warning"
@ok="handleCancelActivity(record)"
>
<a-button type="text" status="danger" size="small">
违规下架
</a-button>
</a-popconfirm>
<span v-else style="color: var(--color-text-4); font-size: 12px">已结案/已下架</span>
</a-space>
</template>
</a-table-column>
</template>
</a-table>
</a-card>
<!-- 发起同城组局 Modal -->
<a-modal
v-model:visible="createModalVisible"
title="发起同城组局项目"
@ok="handleCreateSubmit"
@cancel="createModalVisible = false"
>
<a-form :model="createForm" layout="vertical">
<a-form-item label="组局标题" required>
<a-input v-model="createForm.title" placeholder="如:三里屯太二酸菜鱼AA探店" />
</a-form-item>
<a-form-item label="活动主打品类" required>
<a-select v-model="createForm.gameCategory">
<a-option value="同城陪吃">同城陪吃</a-option>
<a-option value="同城陪喝">同城陪喝</a-option>
<a-option value="KTV陪唱">KTV陪唱</a-option>
<a-option value="线上电竞">线上电竞</a-option>
</a-select>
</a-form-item>
<a-form-item label="线下公开商圈集合地点" required>
<a-input v-model="createForm.location" placeholder="必须为商圈公共餐厅/KTV等公开场所" />
</a-form-item>
<a-form-item label="活动时段" required>
<a-date-picker
v-model="createForm.startTime"
show-time
format="YYYY-MM-DD HH:mm"
value-format="YYYY-MM-DD HH:mm"
placeholder="请选择活动开始时间"
style="width: 100%"
/>
</a-form-item>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="付费模式">
<a-radio-group v-model="createForm.payType">
<a-radio :value="1">AA制</a-radio>
<a-radio :value="2">项目制包揽</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="人数上限">
<a-input-number v-model="createForm.maxParticipants" :min="2" :max="20" />
</a-form-item>
</a-col>
</a-row>
<a-form-item label="单人预算 / 人均金额(元)" required>
<a-input-number v-model="createForm.perPersonFee" :min="10" :precision="2" />
</a-form-item>
</a-form>
</a-modal>
<!-- 追加赏金 / 房主调价 Modal -->
<a-modal
v-model:visible="adjustModalVisible"
title="房主追加赏金与调价"
@ok="handleAdjustSubmit"
@cancel="adjustModalVisible = false"
>
<div v-if="currentAdjustRecord" style="margin-bottom: 16px">
<a-alert type="info">
平台保障规则:根据《统一取齐》高价机制,追加调价后已报名的老成员将由系统自动触发差额退补流水,保障公平履约。
</a-alert>
<div style="margin-top: 12px; font-weight: 500">
组局:{{ currentAdjustRecord.title }}
</div>
</div>
<a-form :model="adjustForm" layout="vertical">
<a-form-item label="调整后新出价(元/人)" required>
<a-input-number v-model="adjustForm.newPrice" :min="50" :precision="2" />
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import axios from 'axios';
import { Message } from '@arco-design/web-vue';
const router = useRouter();
const loading = ref(false);
const rawList = ref<any[]>([]);
const searchKeyword = ref('');
const categoryFilter = ref('ALL');
const payTypeFilter = ref<number>(0);
// 创建 Modal
const createModalVisible = ref(false);
const createForm = ref({
title: '',
gameCategory: '同城陪吃',
location: '',
startTime: '',
payType: 1,
maxParticipants: 4,
perPersonFee: 100,
});
// 调价 Modal
const adjustModalVisible = ref(false);
const currentAdjustRecord = ref<any>(null);
const adjustForm = ref({
newPrice: 150,
});
const fetchData = async () => {
loading.value = true;
try {
const res: any = await axios.get('/api/activities');
if (res && res.data) {
rawList.value = res.data;
}
} catch (err: any) {
Message.error(err.message || '获取活动列表失败');
} finally {
loading.value = false;
}
};
const filteredList = computed(() => {
return rawList.value.filter((item) => {
const matchKeyword =
!searchKeyword.value ||
item.title.includes(searchKeyword.value) ||
(item.location && item.location.includes(searchKeyword.value));
const matchCategory =
categoryFilter.value === 'ALL' || item.gameCategory === categoryFilter.value;
const matchPayType =
!payTypeFilter.value || item.payType === payTypeFilter.value;
return matchKeyword && matchCategory && matchPayType;
});
});
const getCategoryColor = (cat: string) => {
switch (cat) {
case '同城陪吃':
return 'blue';
case '同城陪喝':
return 'orange';
case 'KTV陪唱':
return 'purple';
case '线上电竞':
return 'green';
default:
return 'arcoblue';
}
};
const goToVerify = (actId: string) => {
router.push({
path: '/activity/verify',
query: { id: actId },
});
};
const openCreateModal = () => {
createForm.value = {
title: '',
gameCategory: '同城陪吃',
location: '',
startTime: '',
payType: 1,
maxParticipants: 4,
perPersonFee: 100,
};
createModalVisible.value = true;
};
const handleCreateSubmit = async () => {
if (!createForm.value.title || !createForm.value.location) {
Message.warning('请填写完整的组局标题与公开地点');
return;
}
if (!createForm.value.startTime) {
Message.warning('请选择活动时段');
return;
}
try {
await axios.post('/api/activities', {
creatorId: 1001,
title: createForm.value.title,
gameCategory: createForm.value.gameCategory,
location: createForm.value.location,
startTime: createForm.value.startTime,
payType: createForm.value.payType,
maxParticipants: createForm.value.maxParticipants,
perPersonFeeCents: createForm.value.perPersonFee * 100,
totalFeeCents: createForm.value.perPersonFee * createForm.value.maxParticipants * 100,
allowDynamicPrice: true,
priceAdjustRule: 'UNIFIED_HIGH',
});
Message.success('同城组局发起成功');
createModalVisible.value = false;
fetchData();
} catch (err: any) {
Message.error(err.message || '发起组局失败');
}
};
const openAdjustModal = (record: any) => {
currentAdjustRecord.value = record;
adjustForm.value.newPrice = (record.perPersonFeeCents || 10000) / 100 + 50;
adjustModalVisible.value = true;
};
const handleAdjustSubmit = async () => {
if (!currentAdjustRecord.value) return;
try {
await axios.post(`/api/activities/${currentAdjustRecord.value.id}/adjust-price`, {
operatorId: 1001,
newPriceCents: adjustForm.value.newPrice * 100,
adjustRule: 'UNIFIED_HIGH',
});
Message.success('追加赏金成功,老成员同享调价差额流水已记录');
adjustModalVisible.value = false;
fetchData();
} catch (err: any) {
Message.error(err.message || '调价失败');
}
};
const handleCancelActivity = async (record: any) => {
try {
await axios.post(`/api/activities/${record.id}/cancel`, {
hostId: record.creatorId || 1001,
reason: '平台风控巡查违规下架退款',
});
Message.success('组局已违规下架,已报名搭子款项已全额原路退还');
fetchData();
} catch (err: any) {
Message.error(err.response?.data?.message || err.message || '下架失败');
}
};
onMounted(() => {
fetchData();
});
</script>
<style scoped lang="less">
.container {
padding: 16px 20px;
}
.breadcrumb {
margin-bottom: 16px;
}
.code-font {
font-family: monospace;
font-weight: 500;
}
.activity-title {
font-weight: 600;
color: var(--color-text-1);
}
.activity-location {
font-size: 12px;
color: var(--color-text-3);
margin-top: 2px;
display: flex;
align-items: center;
}
.price-text {
font-size: 15px;
font-weight: 700;
color: #ff5722;
}
.sub-text {
font-size: 11px;
font-weight: normal;
color: var(--color-text-3);
}
</style>