|
@@ -95,9 +95,9 @@ const fetchAllRelateParentElementPositionInfos = (parentElement, topics) => {
|
|
return postionInfos;
|
|
return postionInfos;
|
|
};
|
|
};
|
|
|
|
|
|
-const fetchFirstSubjectiveTopicPositionInfo = (topics) => {
|
|
|
|
- return topics.findIndex((item) => item.sign === "subjective");
|
|
|
|
-};
|
|
|
|
|
|
+// const fetchFirstSubjectiveTopicPositionInfo = (topics) => {
|
|
|
|
+// return topics.findIndex((item) => item.sign === "subjective");
|
|
|
|
+// };
|
|
|
|
|
|
const fetchSameSerialNumberChildrenPositionInfo = (
|
|
const fetchSameSerialNumberChildrenPositionInfo = (
|
|
elementChildernElement,
|
|
elementChildernElement,
|
|
@@ -287,28 +287,16 @@ const actions = {
|
|
// 新增试题 --------------->
|
|
// 新增试题 --------------->
|
|
addElement({ state, commit, dispatch }, element) {
|
|
addElement({ state, commit, dispatch }, element) {
|
|
let pos = null;
|
|
let pos = null;
|
|
- // 客观题和主观题分别对待
|
|
|
|
if (element.insertTopic && element.insertTopic.id) {
|
|
if (element.insertTopic && element.insertTopic.id) {
|
|
// 存在插入目标元素
|
|
// 存在插入目标元素
|
|
- if (
|
|
|
|
- element.insertTopic.type === "FILL_QUESTION" &&
|
|
|
|
- element.type !== "FILL_QUESTION"
|
|
|
|
- ) {
|
|
|
|
- pos = fetchFirstSubjectiveTopicPositionInfo(state.topics);
|
|
|
|
- } else {
|
|
|
|
- let relateTopicPos = [];
|
|
|
|
- state.topics.forEach((item, index) => {
|
|
|
|
- if (item.parent && item.parent.id === element.insertTopic.id)
|
|
|
|
- relateTopicPos.push(index);
|
|
|
|
- });
|
|
|
|
- pos = relateTopicPos.slice(-1)[0] + 1;
|
|
|
|
- }
|
|
|
|
|
|
+ let relateTopicPos = [];
|
|
|
|
+ state.topics.forEach((item, index) => {
|
|
|
|
+ if (item.parent && item.parent.id === element.insertTopic.id)
|
|
|
|
+ relateTopicPos.push(index);
|
|
|
|
+ });
|
|
|
|
+ pos = relateTopicPos.slice(-1)[0] + 1;
|
|
|
|
+
|
|
delete element.insertTopic;
|
|
delete element.insertTopic;
|
|
- } else {
|
|
|
|
- // 不存在插入目标元素
|
|
|
|
- if (element.sign === "objective") {
|
|
|
|
- pos = fetchFirstSubjectiveTopicPositionInfo(state.topics);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
let preElements = createFunc[element.type](element);
|
|
let preElements = createFunc[element.type](element);
|
|
@@ -662,10 +650,12 @@ const actions = {
|
|
};
|
|
};
|
|
|
|
|
|
const checkElementIsCurColumnFirstType = (element) => {
|
|
const checkElementIsCurColumnFirstType = (element) => {
|
|
- const topicHeadIndex = curColumnElements.findIndex(
|
|
|
|
- (elem) => elem.type === "TOPIC_HEAD" && elem.sign === element.sign
|
|
|
|
- );
|
|
|
|
- return topicHeadIndex === -1;
|
|
|
|
|
|
+ const lastElement = curColumnElements.slice(-1)[0];
|
|
|
|
+ if (lastElement) {
|
|
|
|
+ return lastElement.sign !== element.sign;
|
|
|
|
+ } else {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
// 放入元素通用流程
|
|
// 放入元素通用流程
|