|
@@ -1,13 +1,160 @@
|
|
<template>
|
|
<template>
|
|
- <div class="build-paper-manual">BuildPaperManual</div>
|
|
|
|
|
|
+ <div class="build-paper-manual">
|
|
|
|
+ <div class="build-step-title">
|
|
|
|
+ <h3><span>大题设置</span></h3>
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ size="small"
|
|
|
|
+ icon="el-icon-circle-plus-outline"
|
|
|
|
+ @click="addDetail"
|
|
|
|
+ >新增大题</el-button
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <el-collapse v-model="activeNames">
|
|
|
|
+ <el-collapse-item
|
|
|
|
+ v-for="(detail, dindex) in details"
|
|
|
|
+ :key="detail.id"
|
|
|
|
+ :name="detail.id"
|
|
|
|
+ >
|
|
|
|
+ <div slot="title" class="detail-header">
|
|
|
|
+ <h3>
|
|
|
|
+ {{ dindex + 1 }}、{{ detail.name }}(题目数量
|
|
|
|
+ <span class="color-primary">{{ detail.questions.length }}</span
|
|
|
|
+ >,每题分数<span class="color-primary">{{
|
|
|
|
+ detail.scorePerQuestion
|
|
|
|
+ }}</span
|
|
|
|
+ >)
|
|
|
|
+ </h3>
|
|
|
|
+ <div>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-edit"
|
|
|
|
+ title="编辑"
|
|
|
|
+ @click.stop="editDetail(detail)"
|
|
|
|
+ ></el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
+ title="删除"
|
|
|
|
+ @click.stop="removeDetail(dindex)"
|
|
|
|
+ ></el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="detail-desc">
|
|
|
|
+ <rich-text :text-json="detail.remark"></rich-text>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="detail-questions">
|
|
|
|
+ <template v-for="(question, qindex) in detail.questions">
|
|
|
|
+ <build-paper-question-base
|
|
|
|
+ v-if="checkIsBaseQuestion(question.questionType)"
|
|
|
|
+ :key="question.id"
|
|
|
|
+ v-model="question.score"
|
|
|
|
+ :question="question"
|
|
|
|
+ :question-serialno="qindex"
|
|
|
|
+ @on-edit="toEditQuestion"
|
|
|
|
+ @on-remove="toRemoveQuestion"
|
|
|
|
+ >
|
|
|
|
+ </build-paper-question-base>
|
|
|
|
+ <build-paper-question-nested
|
|
|
|
+ v-else
|
|
|
|
+ :key="question.id"
|
|
|
|
+ :question="question"
|
|
|
|
+ :question-serialno="qindex"
|
|
|
|
+ @on-edit="toEditQuestion"
|
|
|
|
+ @on-remove="toRemoveQuestion"
|
|
|
|
+ ></build-paper-question-nested>
|
|
|
|
+ </template>
|
|
|
|
+ </div>
|
|
|
|
+ <el-button type="primary" @click="toAddQuestion">新增小题</el-button>
|
|
|
|
+ </el-collapse-item>
|
|
|
|
+ </el-collapse>
|
|
|
|
+
|
|
|
|
+ <!-- ModifyDetailStruct -->
|
|
|
|
+ <modify-detail-struct
|
|
|
|
+ ref="ModifyDetailStruct"
|
|
|
|
+ :detail="curDetail"
|
|
|
|
+ @modified="detailModified"
|
|
|
|
+ ></modify-detail-struct>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import ModifyDetailStruct from "../components/ModifyDetailStruct.vue";
|
|
|
|
+import BuildPaperQuestionBase from "./BuildPaperQuestionBase.vue";
|
|
|
|
+import BuildPaperQuestionNested from "./BuildPaperQuestionNested.vue";
|
|
|
|
+import { BASE_QUESTION_TYPES } from "@/constants/constants";
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: "BuildPaperManual",
|
|
name: "BuildPaperManual",
|
|
|
|
+ components: {
|
|
|
|
+ ModifyDetailStruct,
|
|
|
|
+ BuildPaperQuestionBase,
|
|
|
|
+ BuildPaperQuestionNested,
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
- return {};
|
|
|
|
|
|
+ return {
|
|
|
|
+ details: [],
|
|
|
|
+ curDetail: {},
|
|
|
|
+ activeNames: [],
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ checkIsBaseQuestion(questionType) {
|
|
|
|
+ const qtype = BASE_QUESTION_TYPES.find(
|
|
|
|
+ (item) => item.code === questionType
|
|
|
|
+ );
|
|
|
|
+ return !!qtype;
|
|
|
|
+ },
|
|
|
|
+ addDetail() {
|
|
|
|
+ this.curDetail = {};
|
|
|
|
+ this.$refs.ModifyDetailStruct.open();
|
|
|
|
+ },
|
|
|
|
+ editDetail(curDetail) {
|
|
|
|
+ this.curDetail = curDetail;
|
|
|
|
+ this.$refs.ModifyDetailStruct.open();
|
|
|
|
+ },
|
|
|
|
+ async removeDetail(index) {
|
|
|
|
+ const confirm = await this.$confirm(`确定要删除当前大题吗?`, "提示", {
|
|
|
|
+ type: "warning",
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+ if (confirm !== "confirm") return;
|
|
|
|
+
|
|
|
|
+ const delDetailId = this.details[index].id;
|
|
|
|
+ this.activeNames = this.activeNames.filter(
|
|
|
|
+ (item) => item !== delDetailId
|
|
|
|
+ );
|
|
|
|
+ this.details.splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+ detailModified(data) {
|
|
|
|
+ const index = this.details.findIndex((item) => item.id === data.id);
|
|
|
|
+ if (index === -1) {
|
|
|
|
+ this.details.push({ ...data, questions: [] });
|
|
|
|
+ if (!this.activeNames.includes(data.id)) this.activeNames.push(data.id);
|
|
|
|
+ } else {
|
|
|
|
+ this.$set(
|
|
|
|
+ this.details,
|
|
|
|
+ index,
|
|
|
|
+ Object.assign({}, this.details[index], data)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ console.log(this.details);
|
|
|
|
+ },
|
|
|
|
+ toAddQuestion() {
|
|
|
|
+ console.log("add");
|
|
|
|
+ },
|
|
|
|
+ toEditQuestion(question) {
|
|
|
|
+ this.curQuestion = question;
|
|
|
|
+ // todo edit question
|
|
|
|
+ },
|
|
|
|
+ toRemoveQuestion(question) {
|
|
|
|
+ this.details.forEach((detail) => {
|
|
|
|
+ const qindex = detail.questions.findIndex((q) => q.id === question.id);
|
|
|
|
+ if (qindex !== -1) detail.splice(qindex, 1);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- methods: {},
|
|
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|