Commit f6a2ccb4 authored by 任建锋's avatar 任建锋

增加复制粘贴到不同视图

parent 385306d8
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
"Save And Close": "Save And Close", "Save And Close": "Save And Close",
"Reset": "Reset", "Reset": "Reset",
"Copy": "Copy", "Copy": "Copy",
"Paste same level":"粘贴到同级",
"Paste child":"粘贴到子级",
"Exit": "Exit", "Exit": "Exit",
"Props": "Props", "Props": "Props",
"Behavior": "Behavior", "Behavior": "Behavior",
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
"Save And Close": "保存并关闭", "Save And Close": "保存并关闭",
"Reset": "重置", "Reset": "重置",
"Copy": "复制", "Copy": "复制",
"Paste same level":"粘贴到同级",
"Paste child":"粘贴到子级",
"Exit": "退出", "Exit": "退出",
"Props": "属性", "Props": "属性",
"Behavior": "行为", "Behavior": "行为",
......
...@@ -41,11 +41,12 @@ function setUUIDForAllChildren(node){ ...@@ -41,11 +41,12 @@ function setUUIDForAllChildren(node){
for(let i=0 ;i<node.children.length;i++){ for(let i=0 ;i<node.children.length;i++){
node.children[i]=copyBaseRoot(node.children[i]) node.children[i]=copyBaseRoot(node.children[i])
setUUIDForAllChildren(node.children[i]) setUUIDForAllChildren(node.children[i])
} }
} }
} }
let copyNodeCatch=null;
function copyBaseRoot(node){ function copyBaseRoot(node){
let _node=JSON.parse(JSON.stringify(node)); let _node=JSON.parse(JSON.stringify(node));
...@@ -322,8 +323,30 @@ export const projectStore = { ...@@ -322,8 +323,30 @@ export const projectStore = {
copyNode(state, { node, parentNode }) { copyNode(state, { node, parentNode }) {
let _node1=node let _node1=node
copyNodeCatch=_node1;
//localStorage.copyNodeCatch=_node1;
// let _node=copyBaseRoot(_node1);
// setUUIDForAllChildren(_node)
// if (parentNode) {
// if (!parentNode.children) {
// Vue.set(parentNode, 'children', []);
// }
// parentNode.children.push(_node);
// } else {
// state.data.views.push(_node);
// }
},
pasteNode(state, { node, parentNode,pasteState}) {
let _node1=copyNodeCatch;
console.log(copyNodeCatch)
if(_node1){
let _node=copyBaseRoot(_node1); let _node=copyBaseRoot(_node1);
setUUIDForAllChildren(_node) setUUIDForAllChildren(_node)
if(pasteState==1){
parentNode=parentNode;
}else{
parentNode=node;
}
if (parentNode) { if (parentNode) {
if (!parentNode.children) { if (!parentNode.children) {
Vue.set(parentNode, 'children', []); Vue.set(parentNode, 'children', []);
...@@ -332,6 +355,7 @@ export const projectStore = { ...@@ -332,6 +355,7 @@ export const projectStore = {
} else { } else {
state.data.views.push(_node); state.data.views.push(_node);
} }
}
}, },
importAssets(state, assets) { importAssets(state, assets) {
state.data.assets.push(...assets); state.data.assets.push(...assets);
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">{{$t('Delete')}}</el-dropdown-item> <el-dropdown-item command="delete">{{$t('Delete')}}</el-dropdown-item>
<el-dropdown-item command="copy">{{$t('Copy')}}</el-dropdown-item> <el-dropdown-item command="copy">{{$t('Copy')}}</el-dropdown-item>
<el-dropdown-item command="paste">{{$t('Paste same level')}}</el-dropdown-item>
<el-dropdown-item command="pasteChild">{{$t('Paste child')}}</el-dropdown-item>
<el-dropdown-item command="export" divided v-if="!node.parent.parent">{{$t('Export')}} <el-dropdown-item command="export" divided v-if="!node.parent.parent">{{$t('Export')}}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-for="(type, key, index) in $t('view_node_menu')" <el-dropdown-item v-for="(type, key, index) in $t('view_node_menu')"
...@@ -173,6 +175,20 @@ ...@@ -173,6 +175,20 @@
parentNode: node.parent.data parentNode: node.parent.data
}); });
break; break;
case 'paste':
this.pasteNode({
node: data,
parentNode: node.parent.data,
pasteState:1
});
break;
case 'pasteChild':
this.pasteNode({
node: data,
parentNode: node.parent.data,
pasteState:2
});
break;
case 'export': case 'export':
this.exportView(data); this.exportView(data);
break; break;
...@@ -188,7 +204,7 @@ ...@@ -188,7 +204,7 @@
break; break;
} }
}, },
...mapMutations(['copyNode','deleteNode', 'addNode']), ...mapMutations(['copyNode','pasteNode','deleteNode', 'addNode']),
...mapActions(['exportView', 'importView']) ...mapActions(['exportView', 'importView'])
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment