|
@@ -35,20 +35,23 @@
|
|
|
<h5-image
|
|
|
v-if="item.type === 'image'"
|
|
|
:item="item"
|
|
|
- :index="index"
|
|
|
+ :index="index + ''"
|
|
|
></h5-image>
|
|
|
+ <!-- @saveParagraph="text => saveParagraph(text, index)" -->
|
|
|
<h5-paragraph
|
|
|
v-if="item.type === 'paragraph'"
|
|
|
:item="item"
|
|
|
- :index="index"
|
|
|
- @saveParagraph="text => saveParagraph(text, index)"
|
|
|
+ :index="index + ''"
|
|
|
></h5-paragraph>
|
|
|
<h5-from-component
|
|
|
v-if="item.type === 'fromComponent'"
|
|
|
- :index="index"
|
|
|
+ :index="index + ''"
|
|
|
:item="item"
|
|
|
>
|
|
|
- <template v-for="(v, i) in item.child_list || []" :key="i">
|
|
|
+ <template
|
|
|
+ v-for="(v, i) in item.child_list || []"
|
|
|
+ :key="createKey(i)"
|
|
|
+ >
|
|
|
<h5-van-field
|
|
|
v-if="v.type === 'van-field'"
|
|
|
:item="v"
|
|
@@ -109,16 +112,19 @@ import H5VanButtom from './components/H5Editor/van_buttom.vue';
|
|
|
import H5ImgEditor from './components/H5EditorLeft/imgEditor';
|
|
|
import H5VanFieldLeft from './components/H5EditorLeft/vanField';
|
|
|
import H5VanButtomLeft from './components/H5EditorLeft/vanButtom';
|
|
|
+import H5ParagraphLeft from './components/H5EditorLeft/paragraph';
|
|
|
|
|
|
const H5EditorObj = {
|
|
|
H5ImgEditor,
|
|
|
H5VanFieldLeft,
|
|
|
H5VanButtomLeft,
|
|
|
+ H5ParagraphLeft
|
|
|
};
|
|
|
const H5EditorObjEle = {
|
|
|
image: 'H5ImgEditor',
|
|
|
'van-field': 'H5VanFieldLeft',
|
|
|
'van-buttom': 'H5VanButtomLeft',
|
|
|
+ paragraph: 'H5ParagraphLeft'
|
|
|
};
|
|
|
|
|
|
const H5Editor = ref({});
|
|
@@ -157,8 +163,14 @@ const backgroundStyle = () => {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-const saveParagraph = (paragraph, index) => {
|
|
|
- console.log(paragraph, index);
|
|
|
+// 保存数据
|
|
|
+// const saveParagraph = (paragraph, index) => {
|
|
|
+// console.log(paragraph, index);
|
|
|
+// };
|
|
|
+
|
|
|
+// 防止组件不刷新生成自定义key
|
|
|
+const createKey = i => {
|
|
|
+ return i + Date.now();
|
|
|
};
|
|
|
|
|
|
// provide 传递方法
|
|
@@ -167,23 +179,31 @@ provide('starEditorFormwork', (value, i) => {
|
|
|
});
|
|
|
|
|
|
provide('saveComponents', value => {
|
|
|
- console.log(value);
|
|
|
+ const vList = value.index.toString().split('-');
|
|
|
+ const list = JSON.parse(JSON.stringify(hoversList.value));
|
|
|
+ if (vList.length == 1) {
|
|
|
+ list[selectPage.value].components[vList[0]] = value.item;
|
|
|
+ } else {
|
|
|
+ // 2层组件
|
|
|
+ list[selectPage.value].components[vList[0]].child_list[vList[1]] =
|
|
|
+ value.item;
|
|
|
+ }
|
|
|
+ hoversList.value = list;
|
|
|
+ leftEle.value = false;
|
|
|
// 保存修改
|
|
|
});
|
|
|
|
|
|
provide('deleteItemComponents', value => {
|
|
|
const vList = value.toString().split('-');
|
|
|
- const list = JSON.parse(
|
|
|
- JSON.stringify(hoversList.value[selectPage.value].components)
|
|
|
- );
|
|
|
- console.log(list,vList);
|
|
|
+ const list = JSON.parse(JSON.stringify(hoversList.value));
|
|
|
if (vList.length == 1) {
|
|
|
- list.splice(vList[0], 1);
|
|
|
+ list[selectPage.value].components.splice(vList[0], 1);
|
|
|
} else {
|
|
|
// 2层组件,只删除里层
|
|
|
- list[vList[0]].child_list.splice(vList[1],1);
|
|
|
+ list[selectPage.value].components[vList[0]].child_list.splice(vList[1], 1);
|
|
|
}
|
|
|
- hoversList.value[selectPage.value].components = list;
|
|
|
+ hoversList.value = list;
|
|
|
+ leftEle.value = false;
|
|
|
// 删除组件
|
|
|
});
|
|
|
</script>
|