diff --git a/src/api/registration.js b/src/api/registration.js
index 135e961..e5cefe3 100644
--- a/src/api/registration.js
+++ b/src/api/registration.js
@@ -52,3 +52,36 @@ export function getAllRegistrations() {
method: 'get'
})
}
+
+// ====== 期次管理 API ======
+
+export function getSessionList(params) {
+ return request({
+ url: '/api/period/list',
+ method: 'get',
+ params
+ })
+}
+
+export function addSession(data) {
+ return request({
+ url: '/api/period',
+ method: 'post',
+ data
+ })
+}
+
+export function updateSession(id, data) {
+ return request({
+ url: `/api/period/${id}`,
+ method: 'put',
+ data
+ })
+}
+
+export function deleteSession(id) {
+ return request({
+ url: `/api/period/${id}`,
+ method: 'delete'
+ })
+}
diff --git a/src/main.js b/src/main.js
index 8897637..18dbcff 100644
--- a/src/main.js
+++ b/src/main.js
@@ -3,6 +3,7 @@ import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
+import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import './assets/styles/main.css'
@@ -14,5 +15,5 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
}
app.use(router)
-app.use(ElementPlus)
+app.use(ElementPlus, { locale: zhCn })
app.mount('#app')
diff --git a/src/utils/format.js b/src/utils/format.js
new file mode 100644
index 0000000..8a73bfe
--- /dev/null
+++ b/src/utils/format.js
@@ -0,0 +1,21 @@
+/**
+ * 格式化期次显示标签
+ * 同月:第一期 5月22-24日
+ * 不同月:第一期 05月22日 - 06月01日
+ */
+export function formatPeriodLabel(periodName, startDate, endDate) {
+ if (!startDate || !endDate) return periodName
+ const startParts = startDate.split('-')
+ const endParts = endDate.split('-')
+ if (startParts.length !== 3 || endParts.length !== 3) return periodName
+ const startMonth = parseInt(startParts[1], 10)
+ const startDay = parseInt(startParts[2], 10)
+ const endMonth = parseInt(endParts[1], 10)
+ const endDay = parseInt(endParts[2], 10)
+ if (startMonth === endMonth) {
+ return `${periodName} ${startMonth}月${startDay}-${endDay}日`
+ } else {
+ const pad = (n) => String(n).padStart(2, '0')
+ return `${periodName} ${pad(startMonth)}月${pad(startDay)}日 - ${pad(endMonth)}月${pad(endDay)}日`
+ }
+}
diff --git a/src/views/admin/DashboardPage.vue b/src/views/admin/DashboardPage.vue
index 157ab72..c73cb6c 100644
--- a/src/views/admin/DashboardPage.vue
+++ b/src/views/admin/DashboardPage.vue
@@ -25,8 +25,27 @@
-
-
+
+
+
+
+
+
+
+
@@ -76,11 +95,15 @@
-
-
+
搜索
- 刷新
+ 重置
@@ -124,7 +147,11 @@
-
+
+
+ {{ getFormattedPeriodName(row.periodName) }}
+
+
¥{{ row.amount }}
@@ -169,6 +196,9 @@
/>
+
+
+
@@ -190,7 +220,7 @@
{{ currentDetail.phone }}
{{ currentDetail.email }}
{{ currentDetail.idCard }}
- {{ currentDetail.period }}
+ {{ getFormattedPeriodName(currentDetail.periodName) }}
¥{{ currentDetail.amount }}
@@ -223,7 +253,9 @@
import { ref, reactive, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
-import { getRegistrationList, getRegistrationStatistics, updateRegistrationStatus, getRegistrationDetail, getAllRegistrations } from '../../api/registration'
+import { getRegistrationList, getRegistrationStatistics, updateRegistrationStatus, getRegistrationDetail, getAllRegistrations, getSessionList } from '../../api/registration'
+import { formatPeriodLabel } from '../../utils/format'
+import SessionManage from './SessionManage.vue'
const router = useRouter()
// 数据
@@ -245,6 +277,12 @@ const adminUser = reactive({
username: 'admin'
})
+// 当前菜单
+const activeMenu = ref('registration')
+const handleMenuSelect = (index) => {
+ activeMenu.value = index
+}
+
// 统计数据
const statistics = reactive({
total: 0,
@@ -255,12 +293,35 @@ const statistics = reactive({
// 原始数据
const allData = ref([])
+const sessionOptions = ref([])
// 过滤后的数据
const filteredData = computed(() => {
return allData.value
})
+// 期次名称 → 完整标签的映射
+const periodLabelMap = computed(() => {
+ const map = {}
+ sessionOptions.value.forEach(item => {
+ map[item.periodName] = formatPeriodLabel(item.periodName, item.startDate, item.endDate)
+ })
+ return map
+})
+
+// 下拉选项(带格式化标签)
+const formattedSessionOptions = computed(() => {
+ return sessionOptions.value.map(item => ({
+ ...item,
+ label: formatPeriodLabel(item.periodName, item.startDate, item.endDate)
+ }))
+})
+
+// 根据 periodName 获取格式化后的完整标签
+const getFormattedPeriodName = (periodName) => {
+ return periodLabelMap.value[periodName] || periodName
+}
+
// 加载数据
const loadData = async () => {
loading.value = true
@@ -270,7 +331,7 @@ const loadData = async () => {
pageNum: currentPage.value,
pageSize: pageSize.value,
status: filterStatus.value,
- period: filterPeriod.value
+ periodId: filterPeriod.value
})
// 映射接口字段
@@ -281,7 +342,7 @@ const loadData = async () => {
department: item.department,
title: item.title,
phone: item.phone,
- period: item.period,
+ periodName: item.periodName,
amount: item.fee,
status: item.status,
createTime: item.submitTime,
@@ -313,11 +374,29 @@ const loadStatistics = async () => {
}
}
-// 刷新数据
-const refreshData = () => {
+// 加载期次列表
+const loadSessionOptions = async () => {
+ try {
+ const res = await getSessionList({
+ pageNum:1,
+ pageSize: 9999
+ })
+ // 假设返回 res.data 是数组,或者 res.data.records 是数组
+ const list = Array.isArray(res.data) ? res.data : (res.data.records || [])
+ sessionOptions.value = list
+ } catch (e) {
+ console.error('加载期次列表失败', e)
+ }
+}
+
+// 重置筛选
+const resetData = () => {
+ searchKeyword.value = ''
+ filterStatus.value = ''
+ filterPeriod.value = ''
currentPage.value = 1
loadData()
- ElMessage.success('数据已刷新')
+ ElMessage.success('筛选条件已重置')
}
// 搜索
@@ -418,7 +497,7 @@ const exportAllData = async () => {
手机号: item.phone,
邮箱: item.email,
身份证号: item.idCard,
- 期次: item.period,
+ 期次: getFormattedPeriodName(item.periodName),
金额: item.fee,
状态: item.status === 'paid' ? '已支付' : '待支付',
报名时间: formatTime(item.submitTime),
@@ -464,7 +543,7 @@ const exportData = () => {
手机号: item.phone,
邮箱: item.email,
身份证号: item.idCard,
- 期次: item.period,
+ 期次: getFormattedPeriodName(item.periodName),
金额: item.amount,
状态: item.status === 'paid' ? '已支付' : '待支付',
报名时间: formatTime(item.createTime),
@@ -512,12 +591,14 @@ onMounted(() => {
}
loadStatistics()
loadData()
+ loadSessionOptions()
})
diff --git a/src/views/client/FormPage.vue b/src/views/client/FormPage.vue
index c7fa408..ed1aad5 100644
--- a/src/views/client/FormPage.vue
+++ b/src/views/client/FormPage.vue
@@ -177,17 +177,17 @@
培训信息
@@ -232,17 +232,30 @@