|
@@ -8,19 +8,18 @@
|
|
|
:style="styles"
|
|
|
>
|
|
|
<ul>
|
|
|
- <li v-if="IS_CONTAINER_ELEMENT" @click="toEdit">
|
|
|
- <i class="el-icon-edit-outline"></i>编辑元素
|
|
|
+ <li @click="toEdit">
|
|
|
+ <i class="el-icon-edit-outline"></i>
|
|
|
+ {{ IS_CONTAINER_ELEMENT ? "编辑元素" : "编辑编辑框" }}
|
|
|
</li>
|
|
|
- <li v-if="IS_CONTAINER_ELEMENT" class="li-danger" @click="toDelete">
|
|
|
- <i class="el-icon-delete"></i>删除元素
|
|
|
+ <li class="li-danger" @click="toDelete">
|
|
|
+ <i class="el-icon-delete"></i>
|
|
|
+ {{ IS_CONTAINER_ELEMENT ? "删除元素" : "删除编辑框" }}
|
|
|
</li>
|
|
|
- <li v-if="IS_CONTAINER_ELEMENT" @click="toCopyExplainElement">
|
|
|
+ <li v-if="IS_CONTAINER_ELEMENT" @click="toCopyElementChild">
|
|
|
<i class="el-icon-copy-document"></i> 复制元素
|
|
|
</li>
|
|
|
- <li
|
|
|
- v-if="IS_CONTAINER && curCopyElement"
|
|
|
- @click="toPasteExplainElement"
|
|
|
- >
|
|
|
+ <li v-if="IS_CONTAINER && curCopyElement" @click="toPasteElementChild">
|
|
|
<i class="el-icon-document-copy"></i> 粘贴元素
|
|
|
</li>
|
|
|
</ul>
|
|
@@ -31,7 +30,6 @@
|
|
|
<script>
|
|
|
import { mapState, mapMutations, mapActions } from "vuex";
|
|
|
import { deepCopy } from "../plugins/utils";
|
|
|
-import { fetchSameSerialNumberChildrenPositionInfo } from "../store/card";
|
|
|
import Clickoutside from "element-ui/src/utils/clickoutside";
|
|
|
|
|
|
export default {
|
|
@@ -48,7 +46,7 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapState("card", ["curElement", "topics"]),
|
|
|
+ ...mapState("paper-export", ["curElement", "topics"]),
|
|
|
IS_CONTAINER_ELEMENT() {
|
|
|
return !!this.curElement.container;
|
|
|
},
|
|
@@ -68,16 +66,13 @@ export default {
|
|
|
document.removeEventListener("mouseup", this.docMouseUp);
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapMutations("card", ["setOpenElementEditDialog"]),
|
|
|
- ...mapActions("card", [
|
|
|
+ ...mapMutations("paper-export", ["setOpenElementEditDialog"]),
|
|
|
+ ...mapActions("paper-export", [
|
|
|
"actElementById",
|
|
|
"removeElement",
|
|
|
"removeElementChild",
|
|
|
- "pasteExplainElementChild",
|
|
|
+ "pasteElementChild",
|
|
|
"rebuildPages",
|
|
|
- "copyExplainChildren",
|
|
|
- "deleteExplainChildren",
|
|
|
- "topicMoveUp",
|
|
|
]),
|
|
|
init() {
|
|
|
// 注册自定义右键事件菜单
|
|
@@ -103,7 +98,7 @@ export default {
|
|
|
|
|
|
this.actElementById(id);
|
|
|
let curElement = this.curElement;
|
|
|
- const TYPES = ["EXPLAIN", "COMPOSITION"];
|
|
|
+ const TYPES = ["PANE_BOX"];
|
|
|
if (
|
|
|
TYPES.includes(curElement.type) ||
|
|
|
(curElement.container && TYPES.includes(curElement.container.type))
|
|
@@ -114,13 +109,7 @@ export default {
|
|
|
);
|
|
|
curElement = this.topics[pos];
|
|
|
}
|
|
|
- const positionInfos = fetchSameSerialNumberChildrenPositionInfo(
|
|
|
- curElement,
|
|
|
- this.topics
|
|
|
- );
|
|
|
- this.showDeleteChildBtn = positionInfos.length >= 2;
|
|
|
}
|
|
|
- // todo:
|
|
|
this.show();
|
|
|
|
|
|
this.$nextTick(() => {
|
|
@@ -151,19 +140,14 @@ export default {
|
|
|
!(
|
|
|
(parentNode["id"] && parentNode["id"].includes("element-")) ||
|
|
|
parentNode.className.includes("page-column-body") ||
|
|
|
- parentNode.className.includes("card-design")
|
|
|
+ parentNode.className.includes("paper-template-design")
|
|
|
)
|
|
|
) {
|
|
|
parentNode = parentNode.parentNode;
|
|
|
}
|
|
|
const elementType = parentNode.getAttribute("data-type");
|
|
|
- const unValidElement = ["TOPIC_HEAD", "CARD_HEAD"];
|
|
|
|
|
|
- return parentNode["id"] &&
|
|
|
- elementType &&
|
|
|
- !unValidElement.includes(elementType)
|
|
|
- ? parentNode["id"]
|
|
|
- : null;
|
|
|
+ return parentNode["id"] && elementType ? parentNode["id"] : null;
|
|
|
},
|
|
|
toEdit() {
|
|
|
this.curElement._edit = true;
|
|
@@ -180,26 +164,19 @@ export default {
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
- toCopyChildren() {
|
|
|
- this.close();
|
|
|
- this.copyExplainChildren(this.curElement);
|
|
|
- this.toRebuildPages();
|
|
|
- },
|
|
|
- toDeleteChildren() {
|
|
|
- this.close();
|
|
|
- this.deleteExplainChildren(this.curElement);
|
|
|
- this.toRebuildPages();
|
|
|
- },
|
|
|
removeSelectElement() {
|
|
|
- if (!this.curElement["container"]) return;
|
|
|
- this.removeElementChild(this.curElement);
|
|
|
+ if (this.curElement["container"]) {
|
|
|
+ this.removeElementChild(this.curElement);
|
|
|
+ } else {
|
|
|
+ this.removeElement(this.curElement);
|
|
|
+ }
|
|
|
this.toRebuildPages();
|
|
|
},
|
|
|
- toCopyExplainElement() {
|
|
|
+ toCopyElementChild() {
|
|
|
this.close();
|
|
|
this.curCopyElement = deepCopy(this.curElement);
|
|
|
},
|
|
|
- toPasteExplainElement() {
|
|
|
+ toPasteElementChild() {
|
|
|
this.close();
|
|
|
const id = this.curElement.container
|
|
|
? this.curElement.container.id
|
|
@@ -211,32 +188,12 @@ export default {
|
|
|
})
|
|
|
: this.curCopyElement;
|
|
|
|
|
|
- this.pasteExplainElementChild({
|
|
|
+ this.pasteElementChild({
|
|
|
curElement: this.curElement,
|
|
|
pasteElement,
|
|
|
});
|
|
|
this.toRebuildPages();
|
|
|
},
|
|
|
- toMoveUpTopic() {
|
|
|
- this.close();
|
|
|
- this.topicMoveUp(this.curElement.parent.id);
|
|
|
- this.toRebuildPages();
|
|
|
- },
|
|
|
- toMoveDownTopic() {
|
|
|
- this.close();
|
|
|
- const curTopicPos = this.topicSeries.findIndex(
|
|
|
- (item) => item.id === this.curElement.parent.id
|
|
|
- );
|
|
|
- this.topicMoveUp(this.topicSeries[curTopicPos + 1].id);
|
|
|
- this.toRebuildPages();
|
|
|
- },
|
|
|
- toInsetTopic() {
|
|
|
- this.close();
|
|
|
- this.$emit("inset-topic", {
|
|
|
- id: this.curElement.parent.id,
|
|
|
- type: this.curElement.type,
|
|
|
- });
|
|
|
- },
|
|
|
toRebuildPages() {
|
|
|
this.$nextTick(() => {
|
|
|
this.rebuildPages();
|