From 94c54e928adafc245e50889a4bb6ef99d0220258 Mon Sep 17 00:00:00 2001 From: wesley <470822125@qq.com> Date: Tue, 31 May 2022 12:59:22 +0800 Subject: [PATCH] 1 --- src/api/QuestionBank.js | 14 ++++++++++++++ src/views/QuestionBank/QuestionDimension.vue | 4 ++-- src/views/QuestionBank/components/EditDimension.vue | 7 ++++++- src/views/QuestionBank/index.vue | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- src/views/TestPaper/ManualTestPaper.vue | 19 +++++++++++++------ src/views/TestPaper/TestPaperList.vue | 54 +++++++++++++++++++++++++++++++++++++++--------------- src/views/user/userlist.vue | 16 +++++++++++----- vue.config.js | 4 ++-- 8 files changed, 301 insertions(+), 57 deletions(-) diff --git a/src/api/QuestionBank.js b/src/api/QuestionBank.js index e8b591f..fdd6cb6 100644 --- a/src/api/QuestionBank.js +++ b/src/api/QuestionBank.js @@ -39,6 +39,20 @@ export function DelQuestionBankEvent(id) { method: 'post', }) } +//删除题目,标记删除 +export function ChangeQuestionBankClass(id,type) { + return request({ + url: `/QuestionBank/ChangeQuestionBankClass?id=${id}&type=${type}`, + method: 'post', + }) +} +//删除题目,标记删除 +export function ChangeQuestionBankType(id,type) { + return request({ + url: `/QuestionBank/ChangeQuestionBankType?id=${id}&type=${type}`, + method: 'post', + }) +} //读取题目信息 export function GetQuestionBankById(id) { return request({ diff --git a/src/views/QuestionBank/QuestionDimension.vue b/src/views/QuestionBank/QuestionDimension.vue index e792b55..86acbdb 100644 --- a/src/views/QuestionBank/QuestionDimension.vue +++ b/src/views/QuestionBank/QuestionDimension.vue @@ -142,14 +142,14 @@ > - + - + @@ -158,6 +158,10 @@ // this.show(); }, methods: { + handleclose(){ + this.dialogFormVisible = false; + this.$emit('close',this.data); + }, handleSave() { if (!this.data.ClassificationName) { this.$message.warning('请填写名称!', "消息"); @@ -168,6 +172,7 @@ if (res.data.code == 200) { this.$message.success('保存成功!', "消息"); this.dialogFormVisible = false; + this.$emit('save',this.data); this.data = { rules: [ { diff --git a/src/views/QuestionBank/index.vue b/src/views/QuestionBank/index.vue index 87d87e2..14501f9 100644 --- a/src/views/QuestionBank/index.vue +++ b/src/views/QuestionBank/index.vue @@ -13,18 +13,22 @@ - + 添加顶级 + + + class="eltree" :expand-on-click-node="false" ref="tree"> {{ node.label }} - + 添加下级 - 编辑 + + 编辑 删除 @@ -38,8 +42,16 @@
+ + 添加题目 + 批量删除 + + 批量修改分类 + + 批量修改题型 +
+ " :header-cell-class-name="headerStyle" :stripe="true" ref="table"> + @@ -231,7 +280,7 @@ getQuestionClassList, DelQuestionBankEvent, GetQuestionBankById, - CreateQuestionClass, + CreateQuestionClass, ChangeQuestionBankClass, ChangeQuestionBankType } from "@/api/QuestionBank"; import { parseTime } from "@/utils/index.js"; import EditDimension from "./components/EditDimension.vue"; @@ -257,6 +306,13 @@ }, Count: 0, QuestList: [], + QuestionClassId: 0, + dialogsubjectlVisibleSetCat: false, + + QuestionTypeId: '', + dialogsubjectlVisibleSetType: false, + + dialogsubjectlVisible: false, dialogClassIVIsible: false, OptionVisible: true, @@ -271,13 +327,13 @@ fraction: 0, singleFraction: 0, addTime: "2021-11-12", - state: 1, + state: 1, }, subjectContent: [ { option: "A", optionContent: "", - scorerule:'高' + scorerule: '高' }, ], QuestionClass: [], @@ -292,7 +348,9 @@ firstTreeData: [], secondTreeData: [], CreatClassId: 0, - scoreRules:['高','中','低'], + scoreRules: ['高', '中', '低'], + currentEditNode: undefined, + currentExpend:[1] }; }, created() { }, @@ -309,7 +367,99 @@ this.getQuestionClassListHeadler(); }, methods: { - AddSubject() { + closeEditDim(data) { + }, + + saveEditDim(data) { + // if(this.currentEditNode && this.currentEditNode.parent) + // this.currentExpend=[this.currentEditNode.parent.data.id]; + // { + // this.currentEditNode.label = data.ClassificationName; + // this.currentEditNode.data.ClassificationName = data.ClassificationName; + // if(this.currentEditNode.parent) + // { + // this.currentEditNode.parent.loaded =false; + // this.currentEditNode.parent.expand(); + // } + // } + this.getQuestionClassListHeadler(); + this.$forceUpdate(); + }, + handleDelete() { + var rows = this.$refs.table.selection; + if (!rows || rows.length < 1) { + this.$message.warning('至少选择一项进行操作!'); + return; + } + this.$confirm("确认删除选择的题目吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + DelQuestionBankEvent(rows.map(o => o.id).join(',')).then((o) => { + this.$message.success("删除成功"); + this.GetList(); + }); + }); + + }, + handleSetClass() { + var rows = this.$refs.table.selection; + if (!this.QuestionClassId || this.QuestionClassId < 1) { + this.$message.warning('至少选择一个分类进行操作!'); + return; + } + this.$confirm("确认批量修改题目分类吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + ChangeQuestionBankClass(rows.map(o => o.id).join(','), this.QuestionClassId).then((o) => { + this.$message.success("修改成功"); + this.GetList(); + this.dialogsubjectlVisibleSetCat = false; + }); + }); + }, + handleChangeCat() { + var rows = this.$refs.table.selection; + if (!rows || rows.length < 1) { + this.$message.warning('至少选择一项进行操作!'); + return; + } + this.dialogsubjectlVisibleSetCat = true; + }, + + + handleSetType() { + var rows = this.$refs.table.selection; + if (!this.QuestionTypeId || this.QuestionTypeId < 1) { + this.$message.warning('至少选择一个类型进行操作!'); + return; + } + this.$confirm("确认批量修改题目类型吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + ChangeQuestionBankType(rows.map(o => o.id).join(','), this.QuestionTypeId).then((o) => { + this.$message.success("修改成功"); + this.GetList(); + this.dialogsubjectlVisibleSetType = false; + }); + }); + }, + handleChangeType() { + var rows = this.$refs.table.selection; + if (!rows || rows.length < 1) { + this.$message.warning('至少选择一项进行操作!'); + return; + } + this.dialogsubjectlVisibleSetType = true; + }, + + + AddSubject() { this.FormClassType = 0; // if(!this.Dataform.scoperule) // this.Dataform.scoperule='高'; @@ -325,6 +475,7 @@ // this.$refs.editDimensionDialog.dialogFormVisible = true; this.$refs.editDimensionDialog.show(data.id); this.currentEditDimension = data; + this.currentEditNode = node; }, //切换分类 handleTabsClick(e) { @@ -386,10 +537,13 @@ this.dialogsubjectlVisible = true; }); }, - showClassDialog(node) { + showClassDialog(node, parent, type) { this.dialogClassIVIsible = true; console.log(node); - this.QuestionClassInfo.ParentId = node.data.value; + if (parent && parent == 0) this.QuestionClassInfo.ParentId = 0; + if (node) + this.QuestionClassInfo.ParentId = node.data.value; + if (type != undefined) this.QuestionClassInfo.ClassType = type; // alert(this.QuestionClassInfo.ParentId); }, //关闭弹框的事件 @@ -402,6 +556,16 @@ this.OptionVisible = true; this.GroupVisible = true; }, + closeDialogCat() { + this.QuestionClassId = 0; + this.dialogsubjectlVisibleSetCat = false; + }, + closeDialogType() { + this.QuestionClassTypeId = ''; + this.dialogsubjectlVisibleSetType = false; + }, + + //选择题目类型来判断是否显示部分表单 changeQuestionType(val) { if (val == 3 || val == 4) { @@ -513,14 +677,38 @@ t.label = t.ClassificationName; return t; }); - let firstClass = list.find((t) => t.id == 6); - firstClass.children = this.getSubTree(6, list); - let secondClass = list.find((t) => t.id == 1); - secondClass.children = this.getSubTree(1, list); + // let firstClass = list.find((t) => t.id == 6); + // firstClass.children = this.getSubTree(6, list); + // let secondClass = list.find((t) => t.id == 1); + // secondClass.children = this.getSubTree(1, list); this.QuestionClass = list; - this.firstTreeData = [firstClass]; - this.secondTreeData = [secondClass]; + var firstlist = list.filter(o => o.ClassType == 0 && o.ParentId == 0).map(o => { + o.children = this.getSubTree(o.id, list); + return o; + }); + + var twolist = list.filter(o => o.ClassType == 2 && o.ParentId == 0).map(o => { + o.children = this.getSubTree(o.id, list); + return o; + + }); + + this.firstTreeData = firstlist; + this.secondTreeData = twolist; + // _this.$nextTick(()=>{ + // if(_this.currentEditNode){ + // _this.$refs.tree.getNode(_this.currentEditNode.parent).loaded = false + // _this.$refs.tree.getNode(_this.currentEditNode.parent).expand(); + // _this.$refs.tree.getNode(_this.currentEditNode.parent).expanded=true; + // _this.$forceUpdate() + + // } + + // }); + + // this.firstTreeData = [firstClass]; + // this.secondTreeData = [secondClass]; }); }, }, diff --git a/src/views/TestPaper/ManualTestPaper.vue b/src/views/TestPaper/ManualTestPaper.vue index 5d47a4a..05b4007 100644 --- a/src/views/TestPaper/ManualTestPaper.vue +++ b/src/views/TestPaper/ManualTestPaper.vue @@ -30,16 +30,17 @@
- {{ TestPaper.TestPaperTitle }} - + + + 题目内容
-
  • - +
  • +

    {{item.option}}:{{item.optionContent}}

    @@ -55,7 +56,7 @@
    组卷基本信息
    - {{TestPaper.TestPaperTitle}} + {{arr2.length}} @@ -429,6 +430,7 @@ SubmitTestPaper() { this.$refs['form'].validate((valid) => { + if (valid) { this.TestPaper.QuestionBankIds = this.arr2.map((u) => u.id); var d = this.TestPaper; @@ -436,6 +438,11 @@ EditTestPaper(this.TestPaper).then((res) => { if (res.data.code == 200) { this.$confirm("组卷成功!", "消息"); + this.$router.push({ + path: '/views/TestPaperList', + query: { + } + }) } else { this.$confirm("组卷失败!", "消息"); } diff --git a/src/views/TestPaper/TestPaperList.vue b/src/views/TestPaper/TestPaperList.vue index 70066d8..0e133fe 100644 --- a/src/views/TestPaper/TestPaperList.vue +++ b/src/views/TestPaper/TestPaperList.vue @@ -21,7 +21,7 @@ {{ scope.row.TotalScore }} - +