|
|
@@ -95,7 +95,8 @@
|
|
|
<template slot-scope="{ row }">
|
|
|
<el-link @click="openForm(row)" icon="el-icon-edit" type="primary" :underline="false"
|
|
|
v-if="permission.includes(permissionMap['edit'])">修改</el-link>
|
|
|
- <el-popconfirm title="确定要删除此试卷吗?" @confirm="remove(row)" class="ele-action">
|
|
|
+ <el-popconfirm title="确定要删除此试卷吗?删除后该试卷下的所有试题也将被删除!" confirm-button-text="确定删除"
|
|
|
+ cancel-button-text="取消" @confirm="remove(row)" class="ele-action">
|
|
|
<el-link slot="reference" icon="el-icon-delete" type="danger" :underline="false"
|
|
|
v-if="permission.includes(permissionMap['delete'])">删除</el-link>
|
|
|
</el-popconfirm>
|
|
|
@@ -234,13 +235,34 @@ export default {
|
|
|
remove(row) {
|
|
|
let ids = row ? [row.id] : this.choose.map((d) => d.id);
|
|
|
if (ids.length === 0) return this.$message.error("请至少选择一条数据");
|
|
|
- this.$confirm("确定要删除选中的试卷吗?", "提示", { type: "warning" }).then(() => {
|
|
|
- this.$http.post("/papers/delete", { id: ids }).then((res) => {
|
|
|
- if (res.data.code === 0) {
|
|
|
- this.$message.success(res.data.msg);
|
|
|
- this.$refs.table.reload();
|
|
|
- } else this.$message.error(res.data.msg);
|
|
|
+
|
|
|
+ // 批量删除时使用确认对话框
|
|
|
+ if (!row && ids.length > 0) {
|
|
|
+ const paperText = ids.length === 1 ? '此试卷' : `选中的${ids.length}个试卷`;
|
|
|
+ this.$confirm(`确定要删除${paperText}吗?删除后该试卷下的所有试题也将被删除!`, "提示", {
|
|
|
+ type: "warning",
|
|
|
+ confirmButtonText: "确定删除",
|
|
|
+ cancelButtonText: "取消"
|
|
|
+ }).then(() => {
|
|
|
+ this.doDelete(ids);
|
|
|
+ }).catch(() => {
|
|
|
+ // 用户取消删除
|
|
|
});
|
|
|
+ } else {
|
|
|
+ // 单个删除时直接执行(el-popconfirm已经确认过了)
|
|
|
+ this.doDelete(ids);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ doDelete(ids) {
|
|
|
+ this.$http.post("/papers/delete", { id: ids }).then((res) => {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ this.$message.success(res.data.msg || "删除成功");
|
|
|
+ this.$refs.table.reload();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ this.$message.error("删除失败:" + e.message);
|
|
|
});
|
|
|
},
|
|
|
beforeUpload(file) {
|
|
|
@@ -260,14 +282,25 @@ export default {
|
|
|
batchRemove() {
|
|
|
let ids = this.choose.map(d => d.id);
|
|
|
if (ids.length === 0) return this.$message.warning("请至少选择一条数据");
|
|
|
- this.$confirm("确定要删除选中的试卷吗?", "提示", { type: "warning" }).then(() => {
|
|
|
- this.$http.post("/exam/papers/delete", { ids }).then(res => {
|
|
|
+ const paperText = ids.length === 1 ? '此试卷' : `选中的${ids.length}个试卷`;
|
|
|
+ this.$confirm(`确定要删除${paperText}吗?删除后该试卷下的所有试题也将被删除!`, "提示", {
|
|
|
+ type: "warning",
|
|
|
+ confirmButtonText: "确定删除",
|
|
|
+ cancelButtonText: "取消"
|
|
|
+ }).then(() => {
|
|
|
+ this.$http.post("/papers/delete", { id: ids }).then(res => {
|
|
|
if (res.data.code === 0) {
|
|
|
this.$message.success("删除成功")
|
|
|
this.$refs.table.reload()
|
|
|
- } else this.$message.error(res.data.msg);
|
|
|
- })
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.msg);
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ this.$message.error("删除失败:" + e.message);
|
|
|
+ });
|
|
|
+ }).catch(() => {
|
|
|
+ // 用户取消删除
|
|
|
+ });
|
|
|
},
|
|
|
// 打开试题管理弹窗
|
|
|
openTopicManager(row) {
|