|
@@ -42,37 +42,28 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
visibleChange() {
|
|
|
- let structData = {};
|
|
|
- let curTopicNo = "";
|
|
|
+ let structData = [];
|
|
|
+ let curTopicId = 0;
|
|
|
this.topics.forEach(topic => {
|
|
|
if (!topic.parent) return;
|
|
|
- curTopicNo = topic.parent.topicNo;
|
|
|
- let questionsCount = 0;
|
|
|
- if (topic.type === "EXPLAIN") {
|
|
|
- questionsCount = topic.parent.questionsCount;
|
|
|
- } else if (topic.type === "COMPOSITION") {
|
|
|
- questionsCount = 1;
|
|
|
- } else {
|
|
|
- questionsCount = topic.questionsCount;
|
|
|
- }
|
|
|
|
|
|
- if (structData[curTopicNo]) {
|
|
|
- if (topic.type !== "EXPLAIN") {
|
|
|
- structData[curTopicNo].questionsCount += questionsCount;
|
|
|
+ if (curTopicId !== topic.parent.id) {
|
|
|
+ curTopicId = topic.parent.id;
|
|
|
+ let questionsCount = 0;
|
|
|
+ if (topic.type === "COMPOSITION") {
|
|
|
+ questionsCount = 1;
|
|
|
+ } else {
|
|
|
+ questionsCount = topic.parent.questionsCount;
|
|
|
}
|
|
|
- } else {
|
|
|
- let sd = {
|
|
|
- topicNo: curTopicNo,
|
|
|
+ let data = {
|
|
|
+ topicNo: topic.parent.topicNo,
|
|
|
topicName: topic.parent.topicName,
|
|
|
questionsCount
|
|
|
};
|
|
|
-
|
|
|
- structData[curTopicNo] = sd;
|
|
|
+ structData.push(data);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- structData = Object.values(structData);
|
|
|
- structData.sort((a, b) => a.topicNo - b.topicNo);
|
|
|
this.structData = structData;
|
|
|
},
|
|
|
cancel() {
|