feat:实现超级管理员拥有批量删除questions
This commit is contained in:
parent
fe0c82c185
commit
4f26d97ff9
File diff suppressed because one or more lines are too long
|
@ -27,10 +27,11 @@ export function updateQuestioncat(id, data) {
|
|||
//删除题目类型
|
||||
export function deleteQuestioncat(id) {
|
||||
return request({
|
||||
url: `/exam/questioncat/${id}/`,
|
||||
url: `/exam/question/${id}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
//题目列表
|
||||
export function getQuestionList(query) {
|
||||
return request({
|
||||
|
@ -69,6 +70,14 @@ export function deleteQuestion(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
//批量删除题目类型
|
||||
export function deletesQuestion(data) {
|
||||
return request({
|
||||
url: `/exam/question/deletes/`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
//导入题目
|
||||
export function importQuestion(data) {
|
||||
return request({
|
||||
|
@ -82,7 +91,7 @@ export function exportQuestion(data) {
|
|||
return request({
|
||||
url: `/exam/question/export/`,
|
||||
method: 'get',
|
||||
params: query
|
||||
params: data
|
||||
})
|
||||
}
|
||||
//启用题目
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
<el-button slot="reference">Excel导入</el-button>
|
||||
</el-popover>
|
||||
<el-button type="primary" icon="el-icon-download" @click="exportQuestion">导出Excel</el-button>
|
||||
<el-button type="primary" icon="el-icon-download" @click="exportQuestions">导出Excel</el-button>
|
||||
<el-button type="danger" :disabled="this.selects.length==0" @click="batchDelete()">批量删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="tableData" style="width: 100%;margin-top:10px;" border stripe fit v-loading="listLoading"
|
||||
|
@ -104,6 +105,7 @@
|
|||
importQuestion,
|
||||
exportQuestion,
|
||||
enableQuestions,
|
||||
deletesQuestion,
|
||||
} from "@/api/exam";
|
||||
import checkPermission from "@/utils/permission";
|
||||
import Pagination from "@/components/Pagination";
|
||||
|
@ -159,7 +161,6 @@ export default {
|
|||
handleUploadSuccess(res, file) {
|
||||
if (res.code == 201) {
|
||||
const loading = this.$loading({ text: "正在导入中..." })
|
||||
console.log(res.data);
|
||||
importQuestion(res.data).then(response => {
|
||||
loading.close()
|
||||
if (response.code == 200) {
|
||||
|
@ -235,15 +236,44 @@ export default {
|
|||
// console.error(err);
|
||||
});
|
||||
},
|
||||
exportQuestion() {
|
||||
exportQuestions() {
|
||||
const loading = this.$loading({
|
||||
text: '正在准备..'
|
||||
});
|
||||
console.log(this.listQuery)
|
||||
exportQuestion(this.listQuery).then(response => {
|
||||
loading.close()
|
||||
window.open(response.data.path, "_blank");
|
||||
}).catch(e => { loading.close() });
|
||||
},
|
||||
batchDelete() {
|
||||
if (this.selects.length === 0) {
|
||||
this.$message({
|
||||
message: '请选择要删除的项',
|
||||
type: 'warning'
|
||||
});
|
||||
return;
|
||||
}else{
|
||||
// 删除前的提示
|
||||
this.$confirm("确认删除记录吗?", "提示", {
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
console.log(this.selects)
|
||||
this.deleteItems(this.selects);
|
||||
this.getList()});
|
||||
}
|
||||
},
|
||||
deleteItems(ids){
|
||||
let item = {ids:ids};
|
||||
deletesQuestion(item).then(response => {
|
||||
if (response.code == 200) {
|
||||
this.$message.success("删除成功");
|
||||
this.getList();
|
||||
} else {
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
changeSort(val) {
|
||||
if (val.order == "ascending") {
|
||||
this.listQuery.ordering = val.prop;
|
||||
|
|
Loading…
Reference in New Issue