feat: improve filtered exports and server pagination
This commit is contained in:
1 parent
4e37f3bb5c
commit
1ddfecbecc
26 files changed
+645
-120
No files matched your search
@@ -242,10 +242,28 @@ async function downloadTemplate() {
|
||||
|
||||
async function exportRows() {
|
||||
try {
|
||||
const params = active.value === 'classes'
|
||||
? {
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
collegeId: listFilters.collegeId, majorId: listFilters.majorId,
|
||||
grade: listFilters.grade, isEnabled: listFilters.isEnabled,
|
||||
}
|
||||
: active.value === 'classrooms'
|
||||
? {
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
campusId: listFilters.campusId, buildingId: listFilters.buildingId,
|
||||
minimumCapacity: listFilters.minimumCapacity,
|
||||
teachingVenueNature: listFilters.teachingVenueNature,
|
||||
isEnabled: listFilters.isEnabled,
|
||||
}
|
||||
: {
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
isArchived: active.value === 'terms' ? archiveFilter.value : undefined,
|
||||
}
|
||||
await downloadApiFile(
|
||||
`/base-data/${active.value}/export`,
|
||||
`${title.value}.xlsx`,
|
||||
{ params: active.value === 'terms' ? { isArchived: archiveFilter.value, keyword: keyword.value.trim() || undefined } : undefined },
|
||||
{ params },
|
||||
)
|
||||
ElMessage.success(`${title.value}已导出`)
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
import { downloadApiFile } from '../api/excel'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
|
||||
type ProjectStatus = 'Draft' | 'Published' | 'Closed'
|
||||
@@ -15,6 +16,8 @@ const isStudent = computed(() => auth.user?.roles.includes('Student') ?? false)
|
||||
const canManage = computed(() => auth.user?.roles.some(x => ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin'].includes(x)) ?? false)
|
||||
const tab = ref(isStudent.value ? 'projects' : 'manage')
|
||||
const projects = ref<Project[]>([]); const mine = ref<Application[]>([]); const applications = ref<Application[]>([]); const applicationsPage = ref(1); const applicationsPageSize = ref(20); const applicationsTotal = ref(0); const loading = ref(false); const dialog = ref(false); const editingId = ref<string | null>(null)
|
||||
const applicationProjectId = ref('')
|
||||
const applicationStatusFilter = ref<ApplicationStatus | ''>('')
|
||||
const balance = ref(0)
|
||||
const form = reactive({ code: '', name: '', description: '', registrationStartsAt: '', registrationEndsAt: '', capacity: 50, feeAmount: 0, requiresReview: true, status: 'Draft' as ProjectStatus, contactName: '', contactPhone: '', notes: '' })
|
||||
const statusLabel: Record<ApplicationStatus, string> = { PendingReview: '待审核', PendingPayment: '待缴费', Confirmed: '已确认', Waitlisted: '候补中', Rejected: '已驳回', Cancelled: '已取消' }
|
||||
@@ -29,7 +32,7 @@ function resetForm(project?: Project) { editingId.value = project?.id ?? null; O
|
||||
async function loadProjects() { const { data } = await http.get('/campus-registrations/projects'); projects.value = data }
|
||||
async function loadMine() { if (isStudent.value) { const { data } = await http.get('/campus-registrations/mine'); mine.value = data } }
|
||||
async function loadWallet() { if (isStudent.value) { const { data } = await http.get('/campus-registrations/wallet/mine'); balance.value = data.balance } }
|
||||
async function loadApplications() { if (canManage.value) { const { data } = await http.get<PagedResult<Application>>('/campus-registrations/applications', { params: { page: applicationsPage.value, pageSize: applicationsPageSize.value } }); applications.value = data.items; applicationsTotal.value = data.total; if (applications.value.length === 0 && applicationsTotal.value > 0 && applicationsPage.value > 1) { applicationsPage.value--; await loadApplications() } } }
|
||||
async function loadApplications(resetPage = false) { if (canManage.value) { if (resetPage) applicationsPage.value = 1; const { data } = await http.get<PagedResult<Application>>('/campus-registrations/applications', { params: { projectId: applicationProjectId.value || undefined, status: applicationStatusFilter.value || undefined, page: applicationsPage.value, pageSize: applicationsPageSize.value } }); applications.value = data.items; applicationsTotal.value = data.total; if (applications.value.length === 0 && applicationsTotal.value > 0 && applicationsPage.value > 1) { applicationsPage.value--; await loadApplications() } } }
|
||||
async function changeApplicationsPage(page: number) { applicationsPage.value = page; await loadApplications() }
|
||||
async function changeApplicationsPageSize(pageSize: number) { applicationsPageSize.value = pageSize; applicationsPage.value = 1; await loadApplications() }
|
||||
async function saveProject() { try { const payload = { ...form, registrationStartsAt: new Date(form.registrationStartsAt).toISOString(), registrationEndsAt: new Date(form.registrationEndsAt).toISOString(), collegeId: null }; if (editingId.value) await http.put(`/campus-registrations/projects/${editingId.value}`, payload); else await http.post('/campus-registrations/projects', payload); ElMessage.success('项目已保存'); dialog.value = false; await loadProjects() } catch (e) { ElMessage.error(apiErrorMessage(e)) } }
|
||||
@@ -38,7 +41,7 @@ async function review(item: Application, approved: boolean) { try { const { valu
|
||||
async function confirmOffline(item: Application) { try { const { value } = await ElMessageBox.prompt('填写线下收款凭据编号(可选)', '确认线下缴费'); await http.post(`/campus-registrations/orders/${item.order!.id}/confirm-offline`, { referenceNumber: value || null, note: null }); ElMessage.success('已确认收款和报名'); await loadApplications() } catch (e) { if (e !== 'cancel' && e !== 'close') ElMessage.error(apiErrorMessage(e)) } }
|
||||
async function cancel(item: Application) { try { await ElMessageBox.confirm('撤销后不可恢复,确定继续吗?', '撤销报名', { type: 'warning' }); await http.post(`/campus-registrations/applications/${item.id}/cancel`); ElMessage.success('报名已撤销'); await loadMine() } catch (e) { if (e !== 'cancel' && e !== 'close') ElMessage.error(apiErrorMessage(e)) } }
|
||||
async function payBalance(item: Application) { try { await ElMessageBox.confirm(`将从校园余额扣除 ${amount(item.order!.amount)},确定支付吗?`, '余额支付', { type: 'warning' }); await http.post(`/campus-registrations/orders/${item.order!.id}/pay-balance`); ElMessage.success('余额支付成功,报名已确认'); await Promise.all([loadMine(), loadWallet(), loadProjects()]) } catch (e) { if (e !== 'cancel' && e !== 'close') ElMessage.error(apiErrorMessage(e)) } }
|
||||
async function exportApplications() { loading.value = true; try { const response = await http.get('/campus-registrations/applications/export.xlsx', { responseType: 'blob' }); const url = URL.createObjectURL(response.data); const a = document.createElement('a'); a.href = url; a.download = '校园报名与缴费.xlsx'; a.click(); URL.revokeObjectURL(url) } finally { loading.value = false } }
|
||||
async function exportApplications() { loading.value = true; try { await downloadApiFile('/campus-registrations/applications/export.xlsx', '校园报名与缴费.xlsx', { params: { projectId: applicationProjectId.value || undefined, status: applicationStatusFilter.value || undefined } }) } finally { loading.value = false } }
|
||||
onMounted(async () => { loading.value = true; try { await Promise.all([loadProjects(), loadMine(), loadWallet(), loadApplications()]) } finally { loading.value = false } })
|
||||
</script>
|
||||
|
||||
@@ -47,7 +50,7 @@ onMounted(async () => { loading.value = true; try { await Promise.all([loadProje
|
||||
<header class="page-heading"><div><p class="eyebrow">CAMPUS SERVICES</p><h2>校园支付与报名</h2><p>报名、审核、线下缴费确认和名单导出在同一闭环内完成。</p></div><el-button v-if="canManage" type="primary" @click="resetForm()">新建报名项目</el-button></header>
|
||||
<el-tabs v-model="tab"><el-tab-pane label="报名项目" name="projects"><div class="project-grid"><el-card v-for="project in projects" :key="project.id" class="project-card"><template #header><div class="card-head"><b>{{ project.name }}</b><el-tag :type="project.status === 'Published' ? 'success' : 'info'">{{ projectStatusLabel[project.status] }}</el-tag></div></template><p class="code">{{ project.code }} · {{ project.collegeName }}</p><p class="description">{{ project.description || '暂无项目说明。' }}</p><dl><div><dt>报名时间</dt><dd>{{ localDateTime(project.registrationStartsAt) }} 至 {{ localDateTime(project.registrationEndsAt) }}</dd></div><div><dt>名额 / 已确认</dt><dd>{{ project.capacity }} / {{ project.confirmedCount }} 人</dd></div><div><dt>费用</dt><dd>{{ amount(project.feeAmount) }} {{ project.requiresReview ? '· 需审核' : '· 自动受理' }}</dd></div></dl><div class="card-actions"><el-button v-if="isStudent" type="primary" :disabled="!project.isAvailableNow" @click="apply(project)">{{ project.isAvailableNow ? '立即报名' : '当前不可报名' }}</el-button><el-button v-if="canManage" @click="resetForm(project)">编辑项目</el-button></div></el-card></div><el-empty v-if="projects.length === 0" description="暂无可见报名项目" /></el-tab-pane>
|
||||
<el-tab-pane v-if="isStudent" label="我的报名与订单" name="mine"><div class="wallet"><span>校园余额</span><b>{{ amount(balance) }}</b><small>余额由管理员调整,可用于支付待缴费报名。</small></div><el-table :data="mine"><el-table-column prop="projectName" label="项目" min-width="190"/><el-table-column label="状态" width="120"><template #default="{ row }"><el-tag :type="applicationStatus(row.status).type">{{ applicationStatus(row.status).label }}</el-tag></template></el-table-column><el-table-column label="订单" min-width="210"><template #default="{ row }"><span v-if="application(row).order">{{ amount(application(row).order!.amount) }} · {{ application(row).order!.paymentMethod === 'Offline' ? '线下缴费' : application(row).order!.paymentMethod === 'Balance' ? '余额支付' : '免费' }} · {{ application(row).order!.status === 'Paid' ? '已确认' : '待确认' }}</span><span v-else>—</span></template></el-table-column><el-table-column prop="reviewComment" label="审核意见" min-width="160"/><el-table-column label="操作" width="160"><template #default="{ row }"><el-button v-if="application(row).status === 'PendingPayment' && application(row).order?.status === 'Pending'" link type="primary" @click="payBalance(application(row))">余额支付</el-button><el-button v-if="['PendingReview','PendingPayment','Waitlisted'].includes(application(row).status)" link type="danger" @click="cancel(application(row))">撤销</el-button></template></el-table-column></el-table><el-empty v-if="mine.length === 0" description="尚未提交报名" /></el-tab-pane>
|
||||
<el-tab-pane v-if="canManage" label="审核与收款" name="manage"><div class="toolbar"><span>所有操作均按项目所属学院的数据范围限制。</span><el-button @click="exportApplications">导出当前可见报名</el-button></div><el-table :data="applications"><el-table-column label="项目与学生" min-width="220"><template #default="{ row }"><b>{{ application(row).projectName }}</b><small>{{ application(row).projectCode }} · {{ application(row).studentNumber }} {{ application(row).studentName }}</small></template></el-table-column><el-table-column label="报名状态" width="120"><template #default="{ row }"><el-tag :type="applicationStatus(row.status).type">{{ applicationStatus(row.status).label }}</el-tag></template></el-table-column><el-table-column label="订单" min-width="190"><template #default="{ row }"><span v-if="application(row).order">{{ application(row).order!.orderNumber }}<small>{{ amount(application(row).order!.amount) }} · {{ application(row).order!.status }}</small></span><span v-else>—</span></template></el-table-column><el-table-column prop="createdAt" label="提交时间" width="170"><template #default="{ row }">{{ localDateTime(application(row).createdAt) }}</template></el-table-column><el-table-column label="操作" width="190" fixed="right"><template #default="{ row }"><el-button v-if="application(row).status === 'PendingReview'" link type="success" @click="review(application(row), true)">通过</el-button><el-button v-if="application(row).status === 'PendingReview'" link type="danger" @click="review(application(row), false)">驳回</el-button><el-button v-if="application(row).status === 'PendingPayment' && application(row).order?.paymentMethod === 'Offline'" link type="primary" @click="confirmOffline(application(row))">确认收款</el-button></template></el-table-column></el-table><el-pagination v-if="applicationsTotal > 0" class="pagination" background layout="total, sizes, prev, pager, next" :current-page="applicationsPage" :page-size="applicationsPageSize" :page-sizes="[20, 50, 100]" :total="applicationsTotal" @update:current-page="changeApplicationsPage" @update:page-size="changeApplicationsPageSize"/><el-empty v-if="applications.length === 0" description="暂无待处理或历史报名" /></el-tab-pane></el-tabs>
|
||||
<el-tab-pane v-if="canManage" label="审核与收款" name="manage"><div class="toolbar"><span>所有操作均按项目所属学院的数据范围限制。</span><el-select v-model="applicationProjectId" clearable filterable placeholder="全部项目" style="width:200px" @change="loadApplications(true)"><el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id" /></el-select><el-select v-model="applicationStatusFilter" clearable placeholder="全部状态" style="width:140px" @change="loadApplications(true)"><el-option v-for="(label, value) in statusLabel" :key="value" :label="label" :value="value" /></el-select><el-button @click="exportApplications">导出当前筛选</el-button></div><el-table :data="applications"><el-table-column label="项目与学生" min-width="220"><template #default="{ row }"><b>{{ application(row).projectName }}</b><small>{{ application(row).projectCode }} · {{ application(row).studentNumber }} {{ application(row).studentName }}</small></template></el-table-column><el-table-column label="报名状态" width="120"><template #default="{ row }"><el-tag :type="applicationStatus(row.status).type">{{ applicationStatus(row.status).label }}</el-tag></template></el-table-column><el-table-column label="订单" min-width="190"><template #default="{ row }"><span v-if="application(row).order">{{ application(row).order!.orderNumber }}<small>{{ amount(application(row).order!.amount) }} · {{ application(row).order!.status }}</small></span><span v-else>—</span></template></el-table-column><el-table-column prop="createdAt" label="提交时间" width="170"><template #default="{ row }">{{ localDateTime(application(row).createdAt) }}</template></el-table-column><el-table-column label="操作" width="190" fixed="right"><template #default="{ row }"><el-button v-if="application(row).status === 'PendingReview'" link type="success" @click="review(application(row), true)">通过</el-button><el-button v-if="application(row).status === 'PendingReview'" link type="danger" @click="review(application(row), false)">驳回</el-button><el-button v-if="application(row).status === 'PendingPayment' && application(row).order?.paymentMethod === 'Offline'" link type="primary" @click="confirmOffline(application(row))">确认收款</el-button></template></el-table-column></el-table><el-pagination v-if="applicationsTotal > 0" class="pagination" background layout="total, sizes, prev, pager, next" :current-page="applicationsPage" :page-size="applicationsPageSize" :page-sizes="[20, 50, 100]" :total="applicationsTotal" @update:current-page="changeApplicationsPage" @update:page-size="changeApplicationsPageSize"/><el-empty v-if="applications.length === 0" description="暂无待处理或历史报名" /></el-tab-pane></el-tabs>
|
||||
<el-dialog v-model="dialog" :title="editingId ? '编辑报名项目' : '新建报名项目'" width="680px"><el-form label-position="top"><div class="form-grid"><el-form-item label="项目编码" required><el-input v-model="form.code" placeholder="如 CAMPUS-2026-001"/></el-form-item><el-form-item label="项目名称" required><el-input v-model="form.name"/></el-form-item><el-form-item label="报名开始" required><el-date-picker v-model="form.registrationStartsAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" style="width:100%"/></el-form-item><el-form-item label="报名结束" required><el-date-picker v-model="form.registrationEndsAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" style="width:100%"/></el-form-item><el-form-item label="名额" required><el-input-number v-model="form.capacity" :min="1" style="width:100%"/></el-form-item><el-form-item label="收费金额(元)"><el-input-number v-model="form.feeAmount" :min="0" :precision="2" style="width:100%"/></el-form-item></div><el-form-item label="项目说明"><el-input v-model="form.description" type="textarea" :rows="3"/></el-form-item><el-form-item label="受理方式"><el-switch v-model="form.requiresReview" active-text="人工审核后受理" inactive-text="直接受理"/></el-form-item><el-form-item label="发布状态"><el-radio-group v-model="form.status"><el-radio-button value="Draft">草稿</el-radio-button><el-radio-button value="Published">发布</el-radio-button><el-radio-button value="Closed">关闭</el-radio-button></el-radio-group></el-form-item><div class="form-grid"><el-form-item label="联系人"><el-input v-model="form.contactName"/></el-form-item><el-form-item label="联系电话"><el-input v-model="form.contactPhone"/></el-form-item></div><el-form-item label="管理备注"><el-input v-model="form.notes" type="textarea" :rows="2"/></el-form-item></el-form><template #footer><el-button @click="dialog=false">取消</el-button><el-button type="primary" @click="saveProject">保存</el-button></template></el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -55,7 +55,11 @@ async function downloadTemplate() {
|
||||
catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
async function exportWallets() {
|
||||
try { await downloadApiFile('/campus-registrations/wallets/export.xlsx', '学生余额.xlsx') }
|
||||
try {
|
||||
await downloadApiFile('/campus-registrations/wallets/export.xlsx', '学生余额.xlsx', {
|
||||
params: { keyword: keyword.value || undefined, ...filters.value },
|
||||
})
|
||||
}
|
||||
catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
||||
}
|
||||
async function importFile(event: Event) {
|
||||
|
||||
Loaded 3 of 26 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user