|
@@ -36,17 +36,20 @@
|
|
|
v-if="item.type === 'image'"
|
|
|
:item="item"
|
|
|
:index="index + ''"
|
|
|
+ @addComponent="addComponent"
|
|
|
></h5-image>
|
|
|
<!-- @saveParagraph="text => saveParagraph(text, index)" -->
|
|
|
<h5-paragraph
|
|
|
v-if="item.type === 'paragraph'"
|
|
|
:item="item"
|
|
|
:index="index + ''"
|
|
|
+ @addComponent="addComponent"
|
|
|
></h5-paragraph>
|
|
|
<h5-from-component
|
|
|
v-if="item.type === 'fromComponent'"
|
|
|
:index="index + ''"
|
|
|
:item="item"
|
|
|
+ @addComponent="addComponent"
|
|
|
>
|
|
|
<template
|
|
|
v-for="(v, i) in item.child_list || []"
|
|
@@ -113,14 +116,28 @@
|
|
|
"
|
|
|
width="50vw"
|
|
|
>
|
|
|
- <span>This is a message</span>
|
|
|
- <template #footer>
|
|
|
- <span class="dialog-footer">
|
|
|
- <el-button type="primary" @click="dialogVisible = false">
|
|
|
- 新 增
|
|
|
- </el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
+ <el-table :data="visbileData.list || []">
|
|
|
+ <el-table-column property="title" label="组件名称">
|
|
|
+ <template #default="scope">
|
|
|
+ <span
|
|
|
+ v-text="
|
|
|
+ scope.row.title ? scope.row.title : scope.row.attr ? scope.row.attr.label : scope.row.type
|
|
|
+ "
|
|
|
+ ></span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column property="address" label="操作">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ link
|
|
|
+ @click="() => addComponentItem(scope.row)"
|
|
|
+ >
|
|
|
+ 添加
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
<div class="H5Editor_right">
|
|
@@ -140,7 +157,7 @@
|
|
|
<script setup>
|
|
|
import { ref, provide } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
-import { createTemplateList } from '../../api/index';
|
|
|
+import { createTemplateList, getComponentsList } from '../../api/index';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
|
// 中间显示模块组件
|
|
@@ -179,7 +196,6 @@ const item = JSON.parse(route.query.item || '{}');
|
|
|
const selectPage = ref(0);
|
|
|
const hoversList = ref(item.hoversList || []);
|
|
|
const page = ref({ width: 375, height: 0 });
|
|
|
-
|
|
|
document.title = item.title;
|
|
|
|
|
|
const selectPageFunc = (index = 0) => {
|
|
@@ -191,12 +207,44 @@ const selectComponent = (v, i) => {
|
|
|
leftEle.value = v.leftEle || false;
|
|
|
};
|
|
|
|
|
|
-const addComponent = (type, index) => {
|
|
|
- dialogVisible.value = true;
|
|
|
- visbileData.value = {
|
|
|
- type,
|
|
|
- index,
|
|
|
- };
|
|
|
+const addComponent = (type, componentTyep, index) => {
|
|
|
+ getComponentsList({}).then(r => {
|
|
|
+ const li = r || [];
|
|
|
+ const list = [];
|
|
|
+ for (let i = 0; i < li.length; i++) {
|
|
|
+ const v = li[i];
|
|
|
+ if (componentTyep != 'van-field') {
|
|
|
+ list.push(v);
|
|
|
+ continue;
|
|
|
+ } else if (componentTyep == 'van-field' && v.type == 'fromComponent') {
|
|
|
+ for (let o = 0; o < v.child_list.length; o++) {
|
|
|
+ const item = v.child_list[o];
|
|
|
+ item.type == componentTyep && list.push(item);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dialogVisible.value = true;
|
|
|
+ visbileData.value = {
|
|
|
+ type,
|
|
|
+ index,
|
|
|
+ list,
|
|
|
+ };
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const addComponentItem = row => {
|
|
|
+ const indexs = visbileData.value.index.split('-');
|
|
|
+ const page = item.hoversList
|
|
|
+ ? item.hoversList[selectPage.value]
|
|
|
+ : { components: [] };
|
|
|
+ let i = visbileData.value.type === 'top' ? 0 : 1;
|
|
|
+ if (indexs.length == 1) {
|
|
|
+ page.components.splice(indexs[0] - 0 + i, 0, row);
|
|
|
+ } else {
|
|
|
+ page.components[indexs[0]].child_list.splice(indexs[1] - 0 + i, 0, row);
|
|
|
+ }
|
|
|
+ dialogVisible.value = false;
|
|
|
};
|
|
|
|
|
|
// 查看页面大小,
|