完善班级和学生删除操作
This commit is contained in:
parent
1836348380
commit
ea74885f4f
@ -98,6 +98,10 @@ export function ModifyClass(params) {
|
|||||||
return http.post(`/api/Class/ModifyClass`, params)
|
return http.post(`/api/Class/ModifyClass`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function DeleteClass(classId) {
|
||||||
|
return http.post(`/api/Class/DeleteClass?classId=${classId}`)
|
||||||
|
}
|
||||||
|
|
||||||
export function GetTeacherNames() {
|
export function GetTeacherNames() {
|
||||||
return http.get(`/api/Teacher/GetTeacherNames`)
|
return http.get(`/api/Teacher/GetTeacherNames`)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
<template v-slot="{ row }">
|
<template v-slot="{ row }">
|
||||||
<div class="operate">
|
<div class="operate">
|
||||||
<p class="edit" @click="editTable(row)">编辑</p>
|
<p class="edit" @click="editTable(row)">编辑</p>
|
||||||
|
<p class="delete" @click="deleteOne(row)">删除</p>
|
||||||
<!-- <p class="edit" @click="toDetail(row)">查看详情</p> -->
|
<!-- <p class="edit" @click="toDetail(row)">查看详情</p> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -106,7 +107,7 @@
|
|||||||
import { useStore } from "vuex";
|
import { useStore } from "vuex";
|
||||||
import * as _api from "@/api/grade";
|
import * as _api from "@/api/grade";
|
||||||
import eventBus from "@/eventBus.js"; // 导入事件总线
|
import eventBus from "@/eventBus.js"; // 导入事件总线
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
const formRef = ref(null);
|
const formRef = ref(null);
|
||||||
const formRef1 = ref(null);
|
const formRef1 = ref(null);
|
||||||
@ -391,8 +392,36 @@
|
|||||||
.filter((id) => id !== null); // 过滤掉 null 值
|
.filter((id) => id !== null); // 过滤掉 null 值
|
||||||
}
|
}
|
||||||
//删除表格行
|
//删除表格行
|
||||||
const deleteOne = (e) => {
|
const deleteOne = async (row) => {
|
||||||
console.log(e, "deleteOne");
|
if (row.studentCount > 0) {
|
||||||
|
ElMessage.warning("班级内还有学生,请先删除学生后再删除班级");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(`确定删除${row.gradeName}${row.className}吗?`, "删除班级", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await _api.DeleteClass(row.id);
|
||||||
|
if (res.code !== 200) {
|
||||||
|
ElMessage.error(res.message || "删除班级失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessage.success(res.data || "删除成功");
|
||||||
|
if (data.value.tableNeed.tableData.length === 1 && data.value.tableNeed.pageIndex > 1) {
|
||||||
|
data.value.tableNeed.pageIndex -= 1;
|
||||||
|
}
|
||||||
|
await initApi(data.value);
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(typeof error === "string" ? error : error?.response?.data?.message || "删除班级失败,请稍后重试");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//创建班级
|
//创建班级
|
||||||
function btnClick(val) {
|
function btnClick(val) {
|
||||||
@ -751,6 +780,14 @@
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.delete {
|
||||||
|
margin-left: 16px;
|
||||||
|
color: #f56c6c;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.addTeacherDrawer {
|
.addTeacherDrawer {
|
||||||
.title {
|
.title {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|||||||
@ -915,7 +915,7 @@ const confirmBatchDelete = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(
|
await ElMessageBox.confirm(
|
||||||
`确定删除${studentSummary}吗?删除后无法恢复,请谨慎操作。`,
|
`确定删除${studentSummary}吗?删除后无法恢复;若学生已一键升学,之后撤回升学也不会恢复这些学生。请谨慎操作。`,
|
||||||
'确认批量删除',
|
'确认批量删除',
|
||||||
{
|
{
|
||||||
confirmButtonText: '确认删除',
|
confirmButtonText: '确认删除',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user