|
@@ -13,6 +13,7 @@
|
|
v-if="H5Editor && leftEle"
|
|
v-if="H5Editor && leftEle"
|
|
:is="H5EditorObj[H5Editor.type]"
|
|
:is="H5EditorObj[H5Editor.type]"
|
|
:item="H5Editor"
|
|
:item="H5Editor"
|
|
|
|
+ :index="H5Editor.index"
|
|
></component>
|
|
></component>
|
|
</van-popup>
|
|
</van-popup>
|
|
<div class="H5Editor_center">
|
|
<div class="H5Editor_center">
|
|
@@ -31,29 +32,45 @@
|
|
v-for="(item, index) in hoversList[selectPage].components || []"
|
|
v-for="(item, index) in hoversList[selectPage].components || []"
|
|
:key="index"
|
|
:key="index"
|
|
>
|
|
>
|
|
- <h5-image v-if="item.type === 'image'" :item="item"></h5-image>
|
|
|
|
|
|
+ <h5-image
|
|
|
|
+ v-if="item.type === 'image'"
|
|
|
|
+ :item="item"
|
|
|
|
+ :index="index"
|
|
|
|
+ ></h5-image>
|
|
<h5-paragraph
|
|
<h5-paragraph
|
|
v-if="item.type === 'paragraph'"
|
|
v-if="item.type === 'paragraph'"
|
|
:item="item"
|
|
:item="item"
|
|
|
|
+ :index="index"
|
|
@saveParagraph="text => saveParagraph(text, index)"
|
|
@saveParagraph="text => saveParagraph(text, index)"
|
|
></h5-paragraph>
|
|
></h5-paragraph>
|
|
<h5-from-component
|
|
<h5-from-component
|
|
v-if="item.type === 'fromComponent'"
|
|
v-if="item.type === 'fromComponent'"
|
|
|
|
+ :index="index"
|
|
:item="item"
|
|
:item="item"
|
|
>
|
|
>
|
|
<template v-for="(v, i) in item.child_list || []" :key="i">
|
|
<template v-for="(v, i) in item.child_list || []" :key="i">
|
|
<h5-van-field
|
|
<h5-van-field
|
|
v-if="v.type === 'van-field'"
|
|
v-if="v.type === 'van-field'"
|
|
:item="v"
|
|
:item="v"
|
|
|
|
+ :index="index + '-' + i"
|
|
@click="
|
|
@click="
|
|
- () => selectComponent({ ...v, leftEle: true }, index)
|
|
|
|
|
|
+ () =>
|
|
|
|
+ selectComponent(
|
|
|
|
+ { ...v, leftEle: true },
|
|
|
|
+ index + '-' + i
|
|
|
|
+ )
|
|
"
|
|
"
|
|
></h5-van-field>
|
|
></h5-van-field>
|
|
<h5-van-buttom
|
|
<h5-van-buttom
|
|
v-if="v.type === 'van-buttom'"
|
|
v-if="v.type === 'van-buttom'"
|
|
|
|
+ :index="index + '-' + i"
|
|
:item="v"
|
|
:item="v"
|
|
@click="
|
|
@click="
|
|
- () => selectComponent({ ...v, leftEle: true }, index)
|
|
|
|
|
|
+ () =>
|
|
|
|
+ selectComponent(
|
|
|
|
+ { ...v, leftEle: true },
|
|
|
|
+ index + '-' + i
|
|
|
|
+ )
|
|
"
|
|
"
|
|
></h5-van-buttom>
|
|
></h5-van-buttom>
|
|
</template>
|
|
</template>
|
|
@@ -114,9 +131,9 @@ const page = ref({ width: 375, height: 0 });
|
|
const selectPageFunc = (index = 0) => {
|
|
const selectPageFunc = (index = 0) => {
|
|
selectPage.value = index;
|
|
selectPage.value = index;
|
|
};
|
|
};
|
|
-const selectComponent = v => {
|
|
|
|
|
|
+const selectComponent = (v, i) => {
|
|
const type = H5EditorObjEle[v.type];
|
|
const type = H5EditorObjEle[v.type];
|
|
- H5Editor.value = { item: v, type };
|
|
|
|
|
|
+ H5Editor.value = { item: v, type, index: i };
|
|
leftEle.value = v.leftEle || false;
|
|
leftEle.value = v.leftEle || false;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -145,16 +162,29 @@ const saveParagraph = (paragraph, index) => {
|
|
};
|
|
};
|
|
|
|
|
|
// provide 传递方法
|
|
// provide 传递方法
|
|
-provide('starEditorFormwork', value => {
|
|
|
|
- selectComponent(value);
|
|
|
|
|
|
+provide('starEditorFormwork', (value, i) => {
|
|
|
|
+ selectComponent(value, i);
|
|
});
|
|
});
|
|
|
|
|
|
provide('saveComponents', value => {
|
|
provide('saveComponents', value => {
|
|
console.log(value);
|
|
console.log(value);
|
|
|
|
+ // 保存修改
|
|
});
|
|
});
|
|
|
|
|
|
provide('deleteItemComponents', value => {
|
|
provide('deleteItemComponents', value => {
|
|
- console.log(value);
|
|
|
|
|
|
+ const vList = value.toString().split('-');
|
|
|
|
+ const list = JSON.parse(
|
|
|
|
+ JSON.stringify(hoversList.value[selectPage.value].components)
|
|
|
|
+ );
|
|
|
|
+ console.log(list,vList);
|
|
|
|
+ if (vList.length == 1) {
|
|
|
|
+ list.splice(vList[0], 1);
|
|
|
|
+ } else {
|
|
|
|
+ // 2层组件,只删除里层
|
|
|
|
+ list[vList[0]].child_list.splice(vList[1],1);
|
|
|
|
+ }
|
|
|
|
+ hoversList.value[selectPage.value].components = list;
|
|
|
|
+ // 删除组件
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
|
|
|