diff --git a/src/api/infra/demo/demo03/normal/index.ts b/src/api/infra/demo/demo03/normal/index.ts
index f15ee1dc..56a824dd 100644
--- a/src/api/infra/demo/demo03/normal/index.ts
+++ b/src/api/infra/demo/demo03/normal/index.ts
@@ -1,53 +1,81 @@
import request from '@/config/axios'
+import type { Dayjs } from 'dayjs';
-export interface Demo03StudentVO {
- id: number
- name: string
- sex: number
- birthday: Date
- description: string
+/** 学生课程信息 */
+export interface Demo03Course {
+ id: number; // 编号
+ studentId?: number; // 学生编号
+ name?: string; // 名字
+ score?: number; // 分数
}
-// 查询学生分页
-export const getDemo03StudentPage = async (params) => {
- return await request.get({ url: `/infra/demo03-student/page`, params })
+/** 学生班级信息 */
+export interface Demo03Grade {
+ id: number; // 编号
+ studentId?: number; // 学生编号
+ name?: string; // 名字
+ teacher?: string; // 班主任
}
-// 查询学生详情
-export const getDemo03Student = async (id: number) => {
- return await request.get({ url: `/infra/demo03-student/get?id=` + id })
+/** 学生信息 */
+export interface Demo03Student {
+ id: number; // 编号
+ name?: string; // 名字
+ sex?: number; // 性别
+ birthday?: string | Dayjs; // 出生日期
+ description?: string; // 简介
+ demo03courses?: Demo03Course[]
+ demo03grade?: Demo03Grade
}
-// 新增学生
-export const createDemo03Student = async (data: Demo03StudentVO) => {
- return await request.post({ url: `/infra/demo03-student/create`, data })
-}
+// 学生 API
+export const Demo03StudentApi = {
+ // 查询学生分页
+ getDemo03StudentPage: async (params: any) => {
+ return await request.get({ url: `/infra/demo03-student-normal/page`, params })
+ },
-// 修改学生
-export const updateDemo03Student = async (data: Demo03StudentVO) => {
- return await request.put({ url: `/infra/demo03-student/update`, data })
-}
+ // 查询学生详情
+ getDemo03Student: async (id: number) => {
+ return await request.get({ url: `/infra/demo03-student-normal/get?id=` + id })
+ },
-// 删除学生
-export const deleteDemo03Student = async (id: number) => {
- return await request.delete({ url: `/infra/demo03-student/delete?id=` + id })
-}
+ // 新增学生
+ createDemo03Student: async (data: Demo03Student) => {
+ return await request.post({ url: `/infra/demo03-student-normal/create`, data })
+ },
-// 导出学生 Excel
-export const exportDemo03Student = async (params) => {
- return await request.download({ url: `/infra/demo03-student/export-excel`, params })
-}
+ // 修改学生
+ updateDemo03Student: async (data: Demo03Student) => {
+ return await request.put({ url: `/infra/demo03-student-normal/update`, data })
+ },
+
+ // 删除学生
+ deleteDemo03Student: async (id: number) => {
+ return await request.delete({ url: `/infra/demo03-student-normal/delete?id=` + id })
+ },
+
+ /** 批量删除学生 */
+ deleteDemo03StudentList: async (ids: number[]) => {
+ return await request.delete({ url: `/infra/demo03-student-normal/delete-list?ids=${ids.join(',')}` })
+ },
+
+ // 导出学生 Excel
+ exportDemo03Student: async (params) => {
+ return await request.download({ url: `/infra/demo03-student-normal/export-excel`, params })
+ },
// ==================== 子表(学生课程) ====================
-// 获得学生课程列表
-export const getDemo03CourseListByStudentId = async (studentId) => {
- return await request.get({ url: `/infra/demo03-student/demo03-course/list-by-student-id?studentId=` + studentId })
-}
+ // 获得学生课程列表
+ getDemo03CourseListByStudentId: async (studentId) => {
+ return await request.get({ url: `/infra/demo03-student-normal/demo03-course/list-by-student-id?studentId=` + studentId })
+ },
// ==================== 子表(学生班级) ====================
-// 获得学生班级
-export const getDemo03GradeByStudentId = async (studentId) => {
- return await request.get({ url: `/infra/demo03-student/demo03-grade/get-by-student-id?studentId=` + studentId })
-}
\ No newline at end of file
+ // 获得学生班级
+ getDemo03GradeByStudentId: async (studentId) => {
+ return await request.get({ url: `/infra/demo03-student-normal/demo03-grade/get-by-student-id?studentId=` + studentId })
+ },
+}
diff --git a/src/views/infra/demo/demo03/normal/Demo03StudentForm.vue b/src/views/infra/demo/demo03/normal/Demo03StudentForm.vue
index 00508228..fc38099b 100644
--- a/src/views/infra/demo/demo03/normal/Demo03StudentForm.vue
+++ b/src/views/infra/demo/demo03/normal/Demo03StudentForm.vue
@@ -50,10 +50,13 @@
\ No newline at end of file
+
diff --git a/src/views/infra/demo/demo03/normal/components/Demo03CourseForm.vue b/src/views/infra/demo/demo03/normal/components/Demo03CourseForm.vue
index b6f58572..7d617887 100644
--- a/src/views/infra/demo/demo03/normal/components/Demo03CourseForm.vue
+++ b/src/views/infra/demo/demo03/normal/components/Demo03CourseForm.vue
@@ -35,17 +35,17 @@
\ No newline at end of file
+
diff --git a/src/views/infra/demo/demo03/normal/components/Demo03GradeForm.vue b/src/views/infra/demo/demo03/normal/components/Demo03GradeForm.vue
index 12653b6c..9aa8f7dc 100644
--- a/src/views/infra/demo/demo03/normal/components/Demo03GradeForm.vue
+++ b/src/views/infra/demo/demo03/normal/components/Demo03GradeForm.vue
@@ -6,7 +6,7 @@
label-width="100px"
v-loading="formLoading"
>
-
+
@@ -15,17 +15,17 @@
\ No newline at end of file
+
diff --git a/src/views/infra/demo/demo03/normal/index.vue b/src/views/infra/demo/demo03/normal/index.vue
index 8a5dc1a9..5c3ebf4d 100644
--- a/src/views/infra/demo/demo03/normal/index.vue
+++ b/src/views/infra/demo/demo03/normal/index.vue
@@ -1,6 +1,4 @@
-
-
-
+
@@ -60,13 +63,30 @@
>
导出
+
+ 批量删除
+
-
+
+
@@ -89,7 +109,7 @@
:formatter="dateFormatter"
width="180px"
/>
-
+
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
+import { isEmpty } from '@/utils/is'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
-import * as Demo03StudentApi from '@/api/infra/demo/demo03/normal'
+import { Demo03StudentApi, Demo03Student } from '@/api/infra/demo/demo03/normal'
import Demo03StudentForm from './Demo03StudentForm.vue'
+/** 学生 列表 */
defineOptions({ name: 'Demo03Student' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
-const list = ref([]) // 列表的数据
+const list = ref([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
- name: null,
- sex: null,
- description: null,
- createTime: []
+ name: undefined,
+ sex: undefined,
+ description: undefined,
+ createTime: [],
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
@@ -192,6 +214,22 @@ const handleDelete = async (id: number) => {
} catch {}
}
+/** 批量删除学生 */
+const handleDeleteBatch = async () => {
+ try {
+ // 删除的二次确认
+ await message.delConfirm()
+ await Demo03StudentApi.deleteDemo03StudentList(checkedIds.value);
+ message.success(t('common.delSuccess'))
+ await getList();
+ } catch {}
+}
+
+const checkedIds = ref([])
+const handleRowCheckboxChange = (records: Demo03Student[]) => {
+ checkedIds.value = records.map((item) => item.id);
+}
+
/** 导出按钮操作 */
const handleExport = async () => {
try {