兵马未动 粮草先行

This commit is contained in:
RISE
2026-02-08 23:47:50 +08:00
parent 00a005e65f
commit 2670340af3
47 changed files with 3909 additions and 257 deletions

View File

@@ -1,28 +1,59 @@
<template>
<el-dialog
title="查看详情"
v-model="visible"
:close-on-click-modal="false"
<el-dialog
title="查看详情"
v-model="visible"
:close-on-click-modal="false"
draggable
width="800px">
<div v-loading="loading" class="detail-container" v-if="detailData">
<el-descriptions :column="2" border>
width="960px">
<div class="detail-container">
<!-- 活动主信息来自列表行 -->
<el-descriptions v-if="mainInfo.activityTheme" :column="2" border class="mb16">
<el-descriptions-item label="活动主题" :span="2">
{{ detailData.activityTheme || '-' }}
{{ mainInfo.activityTheme || '-' }}
</el-descriptions-item>
<el-descriptions-item label="活动说明" :span="2">
{{ detailData.remarks || '-' }}
{{ mainInfo.remarks || '-' }}
</el-descriptions-item>
<el-descriptions-item label="活动兼报数">
{{ detailData.maxSub !== undefined && detailData.maxSub !== null ? detailData.maxSub : '-' }}
{{ mainInfo.maxSub !== undefined && mainInfo.maxSub !== null ? mainInfo.maxSub : '-' }}
</el-descriptions-item>
<el-descriptions-item label="开始时间">
{{ parseTime(detailData.startTime, '{y}-{m}-{d}') }}
{{ mainInfo.startTime ? parseTime(mainInfo.startTime, '{y}-{m}-{d}') : '-' }}
</el-descriptions-item>
<el-descriptions-item label="结束时间">
{{ parseTime(detailData.endTime, '{y}-{m}-{d}') }}
{{ mainInfo.endTime ? parseTime(mainInfo.endTime, '{y}-{m}-{d}') : '-' }}
</el-descriptions-item>
</el-descriptions>
<!-- 子项目列表接口getActivityInfoSubList -->
<div class="sub-title">子项目列表</div>
<el-table
:data="subList"
v-loading="loading"
border
size="small"
max-height="400"
style="width: 100%">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="subTitle" label="子项目名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="deptName" label="学院" width="110" show-overflow-tooltip />
<el-table-column prop="classNo" label="班号" width="80" align="center" />
<el-table-column prop="classMasterName" label="班主任" width="90" show-overflow-tooltip />
<el-table-column prop="startTime" label="开始时间" width="155" align="center">
<template #default="scope">
{{ scope.row.startTime ? parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}') : '-' }}
</template>
</el-table-column>
<el-table-column prop="endTime" label="结束时间" width="155" align="center">
<template #default="scope">
{{ scope.row.endTime ? parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') : '-' }}
</template>
</el-table-column>
<el-table-column prop="maxNum" label="人数限制" width="88" align="center" />
<el-table-column prop="applyNums" label="已报名" width="78" align="center" />
<el-table-column prop="position" label="地点" min-width="100" show-overflow-tooltip />
<el-table-column prop="projectDescription" label="项目描述" min-width="180" show-overflow-tooltip />
</el-table>
<el-empty v-if="!loading && subList.length === 0" description="暂无子项目" :image-size="80" />
</div>
<template #footer>
<span class="dialog-footer">
@@ -33,47 +64,40 @@
</template>
<script setup lang="ts" name="ActivityInfoDetailDialog">
import { ref } from 'vue'
import { getDetail } from '/@/api/stuwork/activityinfo'
import { ref, reactive } from 'vue'
import { getActivityInfoSubList } from '/@/api/stuwork/activityinfosub'
import { parseTime } from '/@/utils/formatTime'
import { useMessage } from '/@/hooks/message'
// 定义变量内容
const visible = ref(false)
const loading = ref(false)
const detailData = ref<any>({})
const mainInfo = reactive<Record<string, any>>({})
const subList = ref<any[]>([])
// 打开弹窗
const openDialog = async (id: string) => {
/**
* 打开弹窗:使用接口 getActivityInfoSubList(activityInfoId) 获取详情子项目列表
* @param activityInfoId 活动信息ID
* @param row 列表行数据,用于展示活动主题等主信息
*/
const openDialog = async (activityInfoId: string, row?: any) => {
visible.value = true
loading.value = true
detailData.value = {}
subList.value = []
Object.keys(mainInfo).forEach((k) => delete mainInfo[k])
if (row && typeof row === 'object') {
Object.assign(mainInfo, row)
}
try {
const res = await getDetail(id)
if (res.data) {
// 根据接口文档,返回的数据可能是 { records: [...], total: ... } 格式
// 如果是列表格式,取第一条;如果是对象,直接使用
if (res.data.records && Array.isArray(res.data.records) && res.data.records.length > 0) {
detailData.value = res.data.records[0]
} else if (res.data.records && Array.isArray(res.data.records)) {
// 列表为空
useMessage().warning('未找到详情数据')
visible.value = false
} else {
// 直接是对象
detailData.value = res.data
}
}
} catch (err: any) {
useMessage().error(err.msg || '获取详情失败')
visible.value = false
const res = await getActivityInfoSubList(activityInfoId)
const data = res.data
subList.value = Array.isArray(data) ? data : []
} catch (_err) {
subList.value = []
} finally {
loading.value = false
}
}
// 暴露方法
defineExpose({
openDialog
})
@@ -81,7 +105,15 @@ defineExpose({
<style scoped lang="scss">
.detail-container {
padding: 20px 0;
padding: 8px 0;
}
.mb16 {
margin-bottom: 16px;
}
.sub-title {
margin-bottom: 8px;
font-weight: 600;
color: #303133;
}
</style>