|
@@ -41,9 +41,25 @@
|
|
></el-button>
|
|
></el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div v-if="detail.description" class="detail-desc">
|
|
|
|
|
|
+ <div v-if="!isAnEmptyRichText(detail.description)" class="detail-desc">
|
|
<rich-text :text-json="detail.description"></rich-text>
|
|
<rich-text :text-json="detail.description"></rich-text>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div v-if="detail.selective" class="detail-info">
|
|
|
|
+ <div>
|
|
|
|
+ <p>
|
|
|
|
+ <span>选择题:</span>
|
|
|
|
+ <span
|
|
|
|
+ :class="{
|
|
|
|
+ 'color-danger':
|
|
|
|
+ detail.questions.length < detail.selectiveCount,
|
|
|
|
+ }"
|
|
|
|
+ >{{ detail.questions.length }}选{{ detail.selectiveCount }},{{
|
|
|
|
+ SELECTIVE_RULE_TYPE[detail.selectiveRule]
|
|
|
|
+ }}</span
|
|
|
|
+ >
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div class="detail-questions">
|
|
<div class="detail-questions">
|
|
<template v-for="(question, qindex) in detail.questions">
|
|
<template v-for="(question, qindex) in detail.questions">
|
|
<build-paper-question-base
|
|
<build-paper-question-base
|
|
@@ -55,6 +71,7 @@
|
|
:question-serialno="qindex + 1"
|
|
:question-serialno="qindex + 1"
|
|
@on-edit="toEditQuestion"
|
|
@on-edit="toEditQuestion"
|
|
@on-remove="toRemoveQuestion"
|
|
@on-remove="toRemoveQuestion"
|
|
|
|
+ @change="scoreChange(detail, question)"
|
|
>
|
|
>
|
|
</build-paper-question-base>
|
|
</build-paper-question-base>
|
|
<build-paper-question-nested
|
|
<build-paper-question-nested
|
|
@@ -110,6 +127,9 @@ import SelectQuestionDialog from "./SelectQuestionDialog.vue";
|
|
import QuestionEditDialog from "../../question/components/QuestionEditDialog.vue";
|
|
import QuestionEditDialog from "../../question/components/QuestionEditDialog.vue";
|
|
import { BASE_QUESTION_TYPES } from "@/constants/constants";
|
|
import { BASE_QUESTION_TYPES } from "@/constants/constants";
|
|
import { randomCode } from "@/plugins/utils";
|
|
import { randomCode } from "@/plugins/utils";
|
|
|
|
+import { isAnEmptyRichText } from "@/utils/utils";
|
|
|
|
+import { SELECTIVE_RULE_TYPE } from "@/constants/constants";
|
|
|
|
+import { omit } from "lodash";
|
|
|
|
|
|
// import details from "../datas/details.json";
|
|
// import details from "../datas/details.json";
|
|
|
|
|
|
@@ -130,6 +150,7 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ SELECTIVE_RULE_TYPE,
|
|
details: [],
|
|
details: [],
|
|
// details,
|
|
// details,
|
|
curDetail: {},
|
|
curDetail: {},
|
|
@@ -140,6 +161,7 @@ export default {
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ isAnEmptyRichText,
|
|
checkIsBaseQuestion(questionType) {
|
|
checkIsBaseQuestion(questionType) {
|
|
const qtype = BASE_QUESTION_TYPES.find(
|
|
const qtype = BASE_QUESTION_TYPES.find(
|
|
(item) => item.code === questionType
|
|
(item) => item.code === questionType
|
|
@@ -177,10 +199,11 @@ export default {
|
|
index,
|
|
index,
|
|
Object.assign({}, this.details[index], data)
|
|
Object.assign({}, this.details[index], data)
|
|
);
|
|
);
|
|
-
|
|
|
|
- this.$refs[`BuildPaperQuestion${index}`].forEach((qRef) => {
|
|
|
|
- qRef.setScore(data.scorePerQuestion);
|
|
|
|
- });
|
|
|
|
|
|
+ if (this.$refs[`BuildPaperQuestion${index}`]) {
|
|
|
|
+ this.$refs[`BuildPaperQuestion${index}`].forEach((qRef) => {
|
|
|
|
+ qRef.setScore(data.scorePerQuestion);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
toAddQuestion(detail, detailIndex) {
|
|
toAddQuestion(detail, detailIndex) {
|
|
@@ -196,8 +219,13 @@ export default {
|
|
this.$refs.SelectQuestionDialog.open();
|
|
this.$refs.SelectQuestionDialog.open();
|
|
},
|
|
},
|
|
questionSelected(questions) {
|
|
questionSelected(questions) {
|
|
|
|
+ let scorePerQuestion = this.curDetail.scorePerQuestion;
|
|
|
|
+ if (this.curDetail.selective && this.curDetail.questions.length) {
|
|
|
|
+ scorePerQuestion =
|
|
|
|
+ this.curDetail.questions[0].score || scorePerQuestion;
|
|
|
|
+ }
|
|
questions.forEach((q) => {
|
|
questions.forEach((q) => {
|
|
- q.score = this.curDetail.scorePerQuestion;
|
|
|
|
|
|
+ q.score = scorePerQuestion;
|
|
q.key = randomCode();
|
|
q.key = randomCode();
|
|
});
|
|
});
|
|
this.curDetail.questions.push(...questions);
|
|
this.curDetail.questions.push(...questions);
|
|
@@ -205,7 +233,7 @@ export default {
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.$refs[`BuildPaperQuestion${this.curDetailIndex}`].forEach(
|
|
this.$refs[`BuildPaperQuestion${this.curDetailIndex}`].forEach(
|
|
(qRef) => {
|
|
(qRef) => {
|
|
- qRef.setScore(this.curDetail.scorePerQuestion);
|
|
|
|
|
|
+ qRef.setScore(scorePerQuestion);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
});
|
|
});
|
|
@@ -227,11 +255,16 @@ export default {
|
|
if (qindex !== -1) detail.questions.splice(qindex, 1);
|
|
if (qindex !== -1) detail.questions.splice(qindex, 1);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ scoreChange(detail, question) {
|
|
|
|
+ if (!detail.selective) return;
|
|
|
|
+ detail.questions.forEach((q) => {
|
|
|
|
+ q.score = question.score;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
getData() {
|
|
getData() {
|
|
let detailInfo = this.details.map((item) => {
|
|
let detailInfo = this.details.map((item) => {
|
|
return {
|
|
return {
|
|
- description: item.description,
|
|
|
|
- detailName: item.detailName,
|
|
|
|
|
|
+ ...omit(item, ["id", "questions"]),
|
|
unitInfo: item.questions.map((q) => {
|
|
unitInfo: item.questions.map((q) => {
|
|
if (q.subQuestions && q.subQuestions.length) {
|
|
if (q.subQuestions && q.subQuestions.length) {
|
|
return {
|
|
return {
|
|
@@ -264,6 +297,15 @@ export default {
|
|
return Promise.reject();
|
|
return Promise.reject();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ let selectiveUnvalid = this.details.some(
|
|
|
|
+ (detail) =>
|
|
|
|
+ detail.selective && detail.questions.length < detail.selectiveCount
|
|
|
|
+ );
|
|
|
|
+ if (selectiveUnvalid) {
|
|
|
|
+ this.$message.error("有大题设置的小题数小于选做题数!");
|
|
|
|
+ return Promise.reject();
|
|
|
|
+ }
|
|
|
|
+
|
|
let hasNoScoreQuestion = this.details.some((detail) => {
|
|
let hasNoScoreQuestion = this.details.some((detail) => {
|
|
return detail.questions.some((q) => !q.score);
|
|
return detail.questions.some((q) => !q.score);
|
|
});
|
|
});
|