fuliqi
2024-06-07 b2ab6a12f2718ecedd933e5a8f9171a6efd73012
模板试卷增删改查
3个文件已修改
91 ■■■■ 已修改文件
src/api/examPaper.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Manage/TestPaper/PaperTemplate.vue 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Manage/TestPaper/index.vue 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/examPaper.js
@@ -2,7 +2,7 @@
export default {
  pageList: query => post('/api/admin/exam/paper/page', query),
  taskExamPage: query => post('/api/admin/exam/paper/taskExamPage', query),
  addPaper: query => post('/api/admin/exam/paper/addPaper', query),
  edit: query => post('/api/admin/exam/paper/edit', query),
  select: id => post('/api/admin/exam/paper/select/' + id),
  deletePaper: id => post('/api/admin/exam/paper/delete/' + id)
src/views/Manage/TestPaper/PaperTemplate.vue
@@ -88,8 +88,8 @@
            >
              <template slot-scope="scope">
                <el-button type="text">预览</el-button>
                <el-button type="text">编辑</el-button>
                <el-button type="text" @click="deletePaper(scope.row)" class="link-left">删除</el-button>
                <el-button type="text" @click="handleUpdate(scope.row)">编辑</el-button>
                <el-button type="text" @click="deleteTemplate(scope.row)" class="link-left">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
@@ -124,8 +124,8 @@
              <el-input-number v-model="form.suggestTime" placeholder="请输入考试时长"/>
            </el-form-item>
            <el-form-item label="权限" prop="visibility">
              <el-radio v-model="form.visibility" :label="1">私有</el-radio>
              <el-radio v-model="form.visibility" :label="2">公开</el-radio>
              <el-radio v-model="form.visibility" :label="'1'">私有</el-radio>
              <el-radio v-model="form.visibility" :label="'2'">公开</el-radio>
            </el-form-item>
            <el-form-item label="多选题得分类型" prop="deductType" v-show="addedQuestionTypes.includes(2)"><!-- 有多选才出现 -->
              <div>
@@ -137,7 +137,7 @@
                    :value="item.value"
                  />
                </el-select>
                <el-input-number v-model="form.score" placeholder="请输入多选得分分数"
                <el-input-number v-model="form.deductTypeScore" placeholder="请输入多选评分"
                                 v-show="form.deductType === 2 || form.deductType === 3"/>
              </div>
            </el-form-item>
@@ -233,6 +233,7 @@
} from '@/api/examTemplate'
import subjectApi from '@/api/subject'
import Pagination from "@/components/Pagination"
import question from "../../../api/question";
export default {
  components: {Pagination},
@@ -400,6 +401,8 @@
        name: null,
        subjectId: null,
        suggestTime: null,
        deductType: null,
        deductTypeScore: null,
        visibility: 1
      };
      this.addedQuestionTypes = []
@@ -420,6 +423,7 @@
    //新增模板
    addTemplate() {
      this.reset();
      this.questionReset();
      this.title = "新增模板"
      this.open = true;
    },
@@ -429,15 +433,28 @@
      this.questionTitle = "添加题目"
      this.questionOpen = true;
    },
    deletePaper(row) {
    //删除模板
    deleteTemplate(row) {
      deleteExamTemplateById(row.id).then(re => {
        if (re.code === 1) {
        if (re.data.code === 1) {
          this.getPage()
          this.$message.success("删除成功")
        } else {
          this.$message.error(re.message)
          this.$message.error(re.data.message)
        }
      })
    },
    //编辑模板
    handleUpdate(row) {
      this.reset();
      this.questionReset();
      this.form = row;
      this.questionList = row.questionList;
      if (this.questionList && this.questionList.length > 0) {
        this.addedQuestionTypes = this.questionList.map(question => question.questionType);
      }
      this.title="编辑模板"
      this.open = true;
    },
    getPage() {
      this.listLoading = true
@@ -488,13 +505,13 @@
          temp.questionList = this.questionList
          if (temp.id != null) {
            editExamTemplate(temp).then(response => {
              this.$message("修改成功");
              this.$message.success("修改成功");
              this.open = false;
              this.getPage();
            });
          } else {
            addExamTemplate(temp).then(response => {
              this.$message("新增成功");
              this.$message.success("新增成功");
              this.open = false;
              this.reset()
              this.getPage();
src/views/Manage/TestPaper/index.vue
@@ -121,7 +121,7 @@
            >
              <template slot-scope="scope">
              <el-button type="text">预览</el-button>
              <el-button type="text">编辑</el-button>
              <el-button type="text" @click="handleUpdate(scope.row)">编辑</el-button>
              <el-button type="text" @click="deletePaper(scope.row)" class="link-left">删除</el-button>
              </template>
            </el-table-column>
@@ -154,12 +154,30 @@
            </el-form-item>
            <el-form-item label="试卷类型" prop="paperType">
              <el-select v-model="form.paperType" placeholder="请选择试卷类型" style="width: 200px">
                <el-option label="固定试卷" value="1" />
                <el-option label="随序试卷" value="3" />
                <el-option label="固定试卷" :value= "1" />
                <el-option label="随序试卷" :value= "3" />
              </el-select>
            </el-form-item>
            <el-form-item label="多选题得分类型" prop="deductType">
              <div>
                <el-select v-model="form.deductType" placeholder="请选择多选题得分类型" style="width: 200px;margin-right: 30px">
                  <el-option
                    v-for="item in deductTypeList"
                    :key="item.value"
                    :label="item.name"
                    :value="item.value"
                  />
                </el-select>
                <el-input-number v-model="form.deductTypeScore" placeholder="请输入多选评分"
                                 v-show="form.deductType === 2 || form.deductType === 3"/>
              </div>
            </el-form-item>
            <el-form-item label="考试时长(分钟)" prop="suggestTime">
              <el-input-number v-model="form.suggestTime" placeholder="请输入考试时长"/>
            </el-form-item>
            <el-form-item label="权限" prop="visibility">
              <el-radio v-model="form.visibility" :label="'1'">私有</el-radio>
              <el-radio v-model="form.visibility" :label="'2'">公开</el-radio>
            </el-form-item>
            <el-button type="primary" @click="toCreate">编辑题目</el-button>
          </el-form>
@@ -196,6 +214,11 @@
        pageIndex: 1,
        pageSize: 10
      },
      deductTypeList: [
        {name: '答错不得分', value: 1},
        {name: '漏选得固定分值,包含错误选项不得分', value: 2},
        {name: '每对一题得相应分值,包含错误选项不得分', value: 3},
      ],
      form: {},
      tableData: [],
      subjects: [],
@@ -264,6 +287,13 @@
        path: "/manage/paper-template",
      });
    },
    //编辑试卷
    handleUpdate(row) {
      this.reset();
      this.form = row;
      this.title="编辑试卷"
      this.open = true;
    },
    deletePaper (row) {
      examPaperApi.deletePaper(row.id).then(re => {
        if (re.code === 1) {
@@ -294,25 +324,21 @@
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.deptId && this.form.deptId.length > 0) {
            this.form.deptId = this.form.deptId[this.form.deptId.length - 1]
          }
          let temp = {
            ...this.form,
            category: parseInt(this.form.category)
          };
          if (temp.id != null) {
            updatePoint(temp).then(response => {
              this.$modal.msgSuccess("修改成功");
            examPaperApi.edit(temp).then(response => {
              this.$message.success("修改成功");
              this.open = false;
              this.getList();
              this.getPage();
            });
          } else {
            addPoint(temp).then(response => {
              this.$modal.msgSuccess("新增成功");
            examPaperApi.addPaper(temp).then(response => {
              this.$message.success("新增成功");
              this.open = false;
              this.reset()
              this.getList();
              this.getPage();
            });
          }
        } else {