From 840c924a4bab1e30283fa341f98ce981f9fa0ec4 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 04 Aug 2021 20:59:06 +0800
Subject: [PATCH] 考试题目新增实现
---
src/api/examapi/examSubjects.js | 57 +-
src/views/exam/addsubject.vue | 918 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/styles/element-ui.scss | 4
src/views/exam/subject.vue | 15
4 files changed, 968 insertions(+), 26 deletions(-)
diff --git a/src/api/examapi/examSubjects.js b/src/api/examapi/examSubjects.js
index 36f863b..b5bd82f 100644
--- a/src/api/examapi/examSubjects.js
+++ b/src/api/examapi/examSubjects.js
@@ -1,37 +1,46 @@
import request from '@/router/axios';
export const getPaperList = (current, size, params) => {
- return request({
- url: '/api/examSubjectChoices/getEexPaperChoices',
- method: 'get',
- params: {
- ...params,
- current,
- size
- }
- })
+ return request({
+ url: '/api/examSubjectChoices/getEexPaperChoices',
+ method: 'get',
+ params: {
+ ...params,
+ current,
+ size
+ }
+ })
}
export const updatePaper = (row) => {
- return request({
- url: '/api/examSubjectChoices/updateChoicesValue',
- method: 'post',
- params: {
- ...row
- }
- })
+ return request({
+ url: '/api/examSubjectChoices/updateChoicesValue',
+ method: 'post',
+ params: {
+ ...row
+ }
+ })
+}
+
+
+export const saveSubjectChoicesAndOption = (row) => {
+ return request({
+ url: '/api/examSubjectChoices/saveSubjectChoicesAndOption',
+ method: 'post',
+ data: row
+ })
}
export const remove = (params) => {
- return request({
- url: '/api/exampaper/UnbindSubject',
- method: 'get',
- params: {
- ...params
- }
- })
-}
+ return request({
+ url: '/api/exampaper/UnbindSubject',
+ method: 'get',
+ params: {
+ ...params
+ }
+ })
+}
\ No newline at end of file
diff --git a/src/styles/element-ui.scss b/src/styles/element-ui.scss
index f29c9bb..b179094 100644
--- a/src/styles/element-ui.scss
+++ b/src/styles/element-ui.scss
@@ -160,8 +160,8 @@
}
.morpheus-box .el-card.is-never-shadow.avue-crud__search {
- width: calc(100% - 390px) !important;
- left: 270px !important;
+ width: calc(100% - 490px) !important;
+ left: 320px !important;
}
.morpheus-box-exam .el-card.is-never-shadow.avue-crud__search {
diff --git a/src/views/exam/addsubject.vue b/src/views/exam/addsubject.vue
new file mode 100644
index 0000000..b1eb01c
--- /dev/null
+++ b/src/views/exam/addsubject.vue
@@ -0,0 +1,918 @@
+<template>
+ <el-dialog
+ :title="this.id?'新增':'修改'"
+ width="60%"
+ modal-append-to-body='false'
+ append-to-body='true'
+ :close-on-click-model="true"
+ :visible.sync="visible"
+ >
+ <el-row style="margin-left:60px;margin-bottom:40px">
+ <el-radio-group v-model="choicesType">
+ <el-radio label="0">单选题</el-radio>
+ <el-radio label="1">多选题</el-radio>
+ <el-radio label="2">判断题</el-radio>
+ <el-radio label="3">填空题</el-radio>
+ </el-radio-group>
+ </el-row>
+ <avue-form ref="form" :option="option" v-model="form" @submit="submit" v-if="choicesType=='0'"></avue-form>
+ <avue-form ref="formCheckbox" :option="optionCheckbox" v-model="formCheckbox" @submit="submitCheckbox" v-if="choicesType=='1'"></avue-form>
+ <avue-form ref="formJudge" :option="optionJudge" v-model="formJudge" @submit="submitJudge" v-if="choicesType=='2'"></avue-form>
+ <avue-form ref="formFill" :option="optionFill" v-model="formFill" @submit="submitFill" v-if="choicesType=='3'">
+ <template slot="optionContent">
+ <!-- <el-button type="success" icon="el-icon-plus" circle style="margin-bottom:20px" @click="addRows"></el-button>
+ <div v-for="(item,index) in list" :key="index">
+ <div class="optionContent-suffix">
+ <span>{{index+1}}: </span>
+ <el-input class="optionContent-input"
+ placeholder="请输入内容"
+ v-model="inputs[`input${index + 1}`]">
+ </el-input>
+ <el-button type="danger" class="optionContent-botton" icon="el-icon-delete" circle @click="deleteRows(index)"></el-button>
+ </div>
+ </div> -->
+ <!-- <el-row :span="24">
+ <el-col :span="6">
+ 值:{{arrContent}}<br />
+ <avue-array v-model="arrContent" placeholder="请输入内容"></avue-array>
+ </el-col>
+ </el-row> -->
+ </template>
+ </avue-form>
+
+
+ </el-dialog>
+</template>
+
+<script>
+import { mapState } from 'vuex'
+import {saveSubjectChoicesAndOption} from "@/api/examapi/examSubjects";
+
+export default {
+ name: "add",
+ data() {
+ return {
+ inputs:{
+ input1: 1,
+ },
+ arrContent:["1"],
+ list:[
+ {
+ data:1
+ },
+ {
+ data:1
+ },
+ {
+ data:1
+ },
+ ],
+ id:1,
+ // index:1,
+ visible:false,
+ choicesType:"0",
+ loading: true,
+ form:{
+ score:2
+ },
+ option: {
+ height: "auto",
+ calcHeight: 80,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: false,
+ stripe: true,
+ align: "center",
+ index: true,
+ selection: true,
+ viewBtn: true,
+ defaultExpandAll: true,
+ dialogClickModal: false,
+ column: [
+ {
+ label: "题目名称",
+ prop: "subjectName",
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入题目名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "类型",
+ prop: "tktype",
+ slot: true,
+ type: "checkbox",
+ dicData: [
+ {
+ label: '简易题库',
+ value: 'A'
+ },
+ {
+ label: '复杂题库',
+ value: 'B'
+ },
+ {
+ label: '模拟题库',
+ value: 'C'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择类型",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "选项",
+ prop: "",
+ type:"text",
+ span:24
+ },
+ {
+ label: "A",
+ prop: "optionContentA",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "B",
+ prop: "optionContentB",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "C",
+ prop: "optionContentC",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "D",
+ prop: "optionContentD",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "答案",
+ prop: "answer",
+ span: 24,
+ // type: "checkbox",
+ type: "radio",
+ dicData: [
+ {
+ label: 'A',
+ value: 'A'
+ },
+ {
+ label: 'B',
+ value: 'B'
+ },
+ {
+ label: 'C',
+ value: 'C'
+ },
+ {
+ label: 'D',
+ value: 'D'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择答案",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "解析",
+ prop: "analysis",
+ span:24,
+ type:"textarea"
+ },
+ {
+ label: "分值",
+ prop: "score",
+ span:24,
+ rules: [
+ {
+ required: true,
+ message: "请输入分值",
+ trigger: "blur",
+ },
+ ],
+ },
+
+ ],
+
+ },
+ formCheckbox:{
+ score:2
+ },
+ optionCheckbox: {
+ height: "auto",
+ calcHeight: 80,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: false,
+ stripe: true,
+ align: "center",
+ index: true,
+ selection: true,
+ viewBtn: true,
+ defaultExpandAll: true,
+ dialogClickModal: false,
+ column: [
+ {
+ label: "题目名称",
+ prop: "subjectName",
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入题目名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "类型",
+ prop: "tktype",
+ slot: true,
+ type: "checkbox",
+ dicData: [
+ {
+ label: '简易题库',
+ value: 'A'
+ },
+ {
+ label: '复杂题库',
+ value: 'B'
+ },
+ {
+ label: '模拟题库',
+ value: 'C'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择类型",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "选项",
+ prop: "",
+ type:"text",
+ span:24
+ },
+ {
+ label: "A",
+ prop: "optionContentA",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "B",
+ prop: "optionContentB",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "C",
+ prop: "optionContentC",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "D",
+ prop: "optionContentD",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "答案",
+ prop: "answer",
+ span: 24,
+ type: "checkbox",
+ // type: "radio",
+ dicData: [
+ {
+ label: 'A',
+ value: 'A'
+ },
+ {
+ label: 'B',
+ value: 'B'
+ },
+ {
+ label: 'C',
+ value: 'C'
+ },
+ {
+ label: 'D',
+ value: 'D'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择答案",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "解析",
+ prop: "analysis",
+ span:24,
+ type:"textarea"
+ },
+ {
+ label: "分值",
+ prop: "score",
+ span:24,
+ rules: [
+ {
+ required: true,
+ message: "请输入分值",
+ trigger: "blur",
+ },
+ ],
+ },
+
+ ],
+
+ },
+ formJudge:{
+ score:1
+ },
+ optionJudge: {
+ height: "auto",
+ calcHeight: 80,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: false,
+ stripe: true,
+ align: "center",
+ index: true,
+ selection: true,
+ viewBtn: true,
+ defaultExpandAll: true,
+ dialogClickModal: false,
+ column: [
+ {
+ label: "题目名称",
+ prop: "subjectName",
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入题目名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "类型",
+ prop: "tktype",
+ slot: true,
+ type: "checkbox",
+ dicData: [
+ {
+ label: '简易题库',
+ value: 'A'
+ },
+ {
+ label: '复杂题库',
+ value: 'B'
+ },
+ {
+ label: '模拟题库',
+ value: 'C'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择类型",
+ trigger: "blur",
+ },
+ ],
+ },
+ // {
+ // label: "选项",
+ // prop: "",
+ // type:"text",
+ // span:24
+ // },
+ // {
+ // label: "正确",
+ // prop: "optionContentA",
+ // span:24
+ // },
+ // {
+ // label: "错误",
+ // prop: "optionContentB",
+ // span:24
+ // },
+ {
+ label: "答案",
+ prop: "answer",
+ span: 24,
+ type: "radio",
+ dicData: [
+ {
+ label: '正确',
+ value: '正确'
+ },
+ {
+ label: '错误',
+ value: '错误'
+ }
+ ],
+ mock:{
+ type:'dic',
+ },
+ rules: [
+ {
+ required: true,
+ message: "请选择答案",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "解析",
+ prop: "analysis",
+ span:24,
+ type:"textarea"
+ },
+ {
+ label: "分值",
+ prop: "score",
+ defaultValue:2,
+ span:24,
+ rules: [
+ {
+ required: true,
+ message: "请输入分值",
+ trigger: "blur",
+ },
+ ],
+ },
+
+ ],
+
+ },
+ formFill:{
+ score:1
+ },
+ optionFill: {
+ height: "auto",
+ calcHeight: 80,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: false,
+ stripe: true,
+ align: "center",
+ index: true,
+ selection: true,
+ viewBtn: true,
+ defaultExpandAll: true,
+ dialogClickModal: false,
+ column: [
+ {
+ label: "题目名称",
+ prop: "subjectName",
+ search: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入题目名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "类型",
+ prop: "tktype",
+ slot: true,
+ type: "checkbox",
+ dicData: [
+ {
+ label: '简易题库',
+ value: 'A'
+ },
+ {
+ label: '复杂题库',
+ value: 'B'
+ },
+ {
+ label: '模拟题库',
+ value: 'C'
+ }
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请选择类型",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "选项",
+ prop: "",
+ type:"text",
+ span:24
+ },
+ {
+ label: "1",
+ prop: "optionContent1",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "2",
+ prop: "optionContent2",
+ span:24,
+ placeholder:"请输入内容",
+ rules: [
+ {
+ required: true,
+ message: "请输入内容",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "3",
+ prop: "optionContent3",
+ span:24,
+ placeholder:"请输入内容"
+ },
+ {
+ label: "4",
+ prop: "optionContent4",
+ span:24,
+ placeholder:"请输入内容"
+ },
+ {
+ label: "5",
+ prop: "optionContent5",
+ span:24,
+ placeholder:"请输入内容"
+ },
+ {
+ label: "答案",
+ prop: "answer",
+ span: 24,
+ rules: [
+ {
+ required: true,
+ message: "请输入答案",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "解析",
+ prop: "analysis",
+ span:24,
+ type:"textarea"
+ },
+ {
+ label: "分值",
+ prop: "score",
+ span:24,
+ rules: [
+ {
+ required: true,
+ message: "请输入分值",
+ trigger: "blur",
+ },
+ ],
+ }
+
+ ],
+
+ },
+ data: [],
+ }
+ },
+ computed: {
+ ...mapState({
+ userInfo: state => state.user.userInfo
+ })
+ },
+ mounted() {
+
+ },
+ methods: {
+ //初始化
+ inits(id) {
+ this.id = id || 1;
+ this.visible = true;
+ this.list = [{data:1}]
+ },
+ //加一行
+ addRows(){
+ //获取已有行的数据
+ // debugger;
+ if(this.index==6){
+ return;
+ }
+ this.index++;
+ this.list.push({
+ data:this.index
+ })
+ this.inputs[`input${this.index+1}`] = '';
+ console.log(this.inputs)
+ console.log(this.list,111);
+ },
+ //减一行
+ deleteRows(index){
+ if(this.index==1){
+ return;
+ }
+ this.index--;
+ this.list.splice(index,1);
+ },
+ //单选题提交(新增)数据
+ submit(row, done, loading) {
+ var that = this;
+ row['choicesType'] = this.choicesType;
+ row['creator'] = this.userInfo.user_name;
+ row.tktype = row.tktype.join(",");
+ //选项信息
+ const examSubjectOptions = [
+ {
+ optionName:"A",
+ optionContent:row.optionContentA,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"B",
+ optionContent:row.optionContentB,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"C",
+ optionContent:row.optionContentC,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"D",
+ optionContent:row.optionContentD,
+ creator:this.userInfo.user_name,
+ }
+ ]
+ row['examSubjectOptions'] = examSubjectOptions;
+ saveSubjectChoicesAndOption(row).then(
+ () => {
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.visible = false;
+ that.$refs.form.resetFields();
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
+ //多选题提交(新增)数据
+ submitCheckbox(row, done, loading) {
+ var that = this;
+ row['choicesType'] = this.choicesType;
+ row['creator'] = this.userInfo.user_name;
+ row.tktype = row.tktype.join(",");
+ row.answer = row.answer.join(",");
+ //选项信息
+ const examSubjectOptions = [
+ {
+ optionName:"A",
+ optionContent:row.optionContentA,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"B",
+ optionContent:row.optionContentB,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"C",
+ optionContent:row.optionContentC,
+ creator:this.userInfo.user_name,
+ },
+ {
+ optionName:"D",
+ optionContent:row.optionContentD,
+ creator:this.userInfo.user_name,
+ }
+ ]
+ row['examSubjectOptions'] = examSubjectOptions;
+ saveSubjectChoicesAndOption(row).then(
+ () => {
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.visible = false;
+ that.$refs.formCheckbox.resetFields();
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
+ //判断题提交(新增)数据
+ submitJudge(row, done, loading) {
+ var that = this;
+ row['choicesType'] = this.choicesType;
+ row['creator'] = this.userInfo.user_name;
+ row.tktype = row.tktype.join(",");
+ saveSubjectChoicesAndOption(row).then(
+ () => {
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.visible = false;
+ that.$refs.formJudge.resetFields();
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
+ //填空排序题提交(新增)数据
+ submitFill(row, done, loading) {
+ var that = this;
+ row['choicesType'] = this.choicesType;
+ row['creator'] = this.userInfo.user_name;
+ row.tktype = row.tktype.join(",");
+ //选项信息
+ var examSubjectOptions = [];
+ if(row.optionContent1){
+ examSubjectOptions.push({
+ optionName:"1",
+ optionContent:row.optionContent1,
+ creator:this.userInfo.user_name,
+ })
+ }
+ if(row.optionContent2){
+ examSubjectOptions.push({
+ optionName:"2",
+ optionContent:row.optionContent2,
+ creator:this.userInfo.user_name,
+ })
+ }
+ if(row.optionContent3){
+ examSubjectOptions.push({
+ optionName:"3",
+ optionContent:row.optionContent3,
+ creator:this.userInfo.user_name,
+ })
+ }
+ if(row.optionContent4){
+ examSubjectOptions.push({
+ optionName:"4",
+ optionContent:row.optionContent4,
+ creator:this.userInfo.user_name,
+ })
+ }
+ if(row.optionContent5){
+ examSubjectOptions.push({
+ optionName:"5",
+ optionContent:row.optionContent5,
+ creator:this.userInfo.user_name,
+ })
+ }
+ row['examSubjectOptions'] = examSubjectOptions;
+ saveSubjectChoicesAndOption(row).then(
+ () => {
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.visible = false;
+ that.$refs.formFill.resetFields();
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ loading();
+ }
+ );
+ },
+
+
+ },
+};
+</script>
+<style scoped>
+
+.optionContent-suffix{
+ margin-top: 5px;
+}
+
+.optionContent-suffix span{
+ margin-left: -20px;
+}
+
+
+.optionContent-suffix .optionContent-input{
+ width: 90%;
+ margin-left: 10px;
+}
+
+
+.optionContent-suffix .optionContent-botton{
+ margin-left: 10px;
+}
+
+</style>
\ No newline at end of file
diff --git a/src/views/exam/subject.vue b/src/views/exam/subject.vue
index 22c054e..b48a3c7 100644
--- a/src/views/exam/subject.vue
+++ b/src/views/exam/subject.vue
@@ -6,6 +6,7 @@
* menu-name 题库查询
*/
<template>
+ <div>
<el-row class="morpheus-box">
<el-col :span="24">
<el-card>
@@ -28,6 +29,11 @@
@row-del="questionBankHandleDel">
<template slot="menuLeft">
+ <el-button type="primary"
+ size="small"
+ icon="el-icon-plus"
+ @click="questionBankHandleAdd">新 增
+ </el-button>
<el-button type="danger"
size="small"
icon="el-icon-delete"
@@ -42,6 +48,8 @@
</el-card>
</el-col>
</el-row>
+ <addsubject ref="addsubject"></addsubject>
+</div>
</template>
<script>
@@ -50,8 +58,12 @@
remove,
} from "@/api/examapi/subject";
+import addsubject from "./addsubject.vue";
export default {
+ components:{
+ addsubject
+ },
data () {
return {
questionBankOption: {
@@ -178,6 +190,9 @@
},
},
methods: {
+ questionBankHandleAdd(){
+ this.$refs.addsubject.inits();
+ },
questionBankOnLoad (page, params = {}) {
this.questionBankLoading = false;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
--
Gitblit v1.9.3