|
@@ -82,9 +82,12 @@
|
|
|
</div>
|
|
|
<el-collapse-transition>
|
|
|
<div v-show="showTopic">
|
|
|
- <el-checkbox-group v-model="checkList" class="topic-group">
|
|
|
- <el-checkbox v-for="item in questionList" :label="item.name" :key="item.name"></el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
+ <div class="topic-group">
|
|
|
+ <el-checkbox v-for="(item, index) in questionList" :label="item.name" :key="index"
|
|
|
+ @change="checked=>selectCheckbox(checked,item,index)" :checked="isChecked(index)"
|
|
|
+ :disabled="isDisabled(index)">
|
|
|
+ </el-checkbox>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</el-collapse-transition>
|
|
|
</div>
|
|
@@ -98,7 +101,8 @@ import editorApi from "../../api/editor";
|
|
|
export default {
|
|
|
props: {
|
|
|
testcaseId: "",
|
|
|
- resultCount: 0
|
|
|
+ resultCount: 0,
|
|
|
+ questions: []
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -111,11 +115,12 @@ export default {
|
|
|
questionPages: [],
|
|
|
resultPageCount: this.resultCount,
|
|
|
resultPages: [],
|
|
|
- checkList: ["4.选中且禁用"],
|
|
|
showTopic: true,
|
|
|
topicIcon: "../../static/img/up-arrow.png",
|
|
|
questionList: [],
|
|
|
- isShowQuestion: false
|
|
|
+ isShowQuestion: false,
|
|
|
+ currentPage: 0,
|
|
|
+ selectQuestions: this.questions
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -161,6 +166,57 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ isChecked(index) {
|
|
|
+ var question = this.questionList[index].questionId;
|
|
|
+ var arrTemp = [];
|
|
|
+ this.selectQuestions.forEach(function(value, key, arr) {
|
|
|
+ arrTemp.push(...value);
|
|
|
+ });
|
|
|
+ return arrTemp.indexOf(question) != -1;
|
|
|
+ },
|
|
|
+ isDisabled(index) {
|
|
|
+ var question = this.questionList[index].questionId;
|
|
|
+ var arrTemp = [];
|
|
|
+ this.selectQuestions.forEach(function(value, key, arr) {
|
|
|
+ arrTemp.push(...value);
|
|
|
+ });
|
|
|
+ let questions = this.selectQuestions[this.currentPage - 1] || [];
|
|
|
+ if (questions.indexOf(question) == -1) {
|
|
|
+ if (questions.length == 2) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return arrTemp.indexOf(question) != -1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ selectCheckbox(checked, item, index) {
|
|
|
+ console.log("选中", checked, item, index);
|
|
|
+ let questions = this.selectQuestions[this.currentPage - 1] || [];
|
|
|
+ if (checked) {
|
|
|
+ questions.push(item.questionId);
|
|
|
+ console.log("AAAAAAAAA", questions);
|
|
|
+ } else {
|
|
|
+ questions.splice(
|
|
|
+ questions.findIndex(itemTemp => itemTemp === item.questionId),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ console.log("DDDDDDDDDD", questions);
|
|
|
+ }
|
|
|
+
|
|
|
+ var selecteQuestionList = [];
|
|
|
+ for (var i = 0; i < questions.length; i++) {
|
|
|
+ var selectQID = questions[i];
|
|
|
+ for (var n = 0; n < this.questionList.length; n++) {
|
|
|
+ if (this.questionList[n].questionId == selectQID) {
|
|
|
+ selecteQuestionList.push(this.questionList[n]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log("RRRRRRRRRR", selecteQuestionList);
|
|
|
+ this.$store.dispatch("addQuestion", selecteQuestionList);
|
|
|
+ },
|
|
|
isShow: function(index) {
|
|
|
var result = false;
|
|
|
if (index > 0) {
|
|
@@ -255,6 +311,8 @@ export default {
|
|
|
var position = this.pages.length - this.resultPageCount;
|
|
|
this.$store.dispatch("addPagePosition", position);
|
|
|
this.isShowQuestion = true;
|
|
|
+ this.selectQuestions.push([]);
|
|
|
+ this.currentPage += 1;
|
|
|
},
|
|
|
addResultPage() {
|
|
|
this.bodyBackgroundColor =
|
|
@@ -265,6 +323,7 @@ export default {
|
|
|
this.isShowQuestion = false;
|
|
|
},
|
|
|
setEditingPage(page, index) {
|
|
|
+ this.currentPage = index;
|
|
|
if (index == 0 || this.isShowResult(index)) {
|
|
|
this.isShowQuestion = false;
|
|
|
} else {
|
|
@@ -293,6 +352,14 @@ export default {
|
|
|
},
|
|
|
resultCount(val) {
|
|
|
this.resultPageCount = val;
|
|
|
+ },
|
|
|
+ questions(val) {
|
|
|
+ console.log("当前页数:", val);
|
|
|
+ this.selectQuestions = val;
|
|
|
+ },
|
|
|
+ currentPage(val) {
|
|
|
+ console.log("当前页数:", val);
|
|
|
+ this.questionList = this.questionList;
|
|
|
}
|
|
|
}
|
|
|
};
|