|
@@ -120,8 +120,7 @@ const mutations = {
|
|
|
//data.type 组件名称 data.h 模块高度
|
|
|
//计算当前布局的最大 y 值
|
|
|
const maxY = Math.max(...state.pageData.index.map(item => item.y), 0);
|
|
|
- //添加板块id
|
|
|
-
|
|
|
+ //添加板块id
|
|
|
state.pageData.index.push({
|
|
|
i: state.pageData.index.length,
|
|
|
x: 0,
|
|
@@ -129,13 +128,13 @@ const mutations = {
|
|
|
w: 12,
|
|
|
h: data.h,
|
|
|
type: data.type,
|
|
|
- content:"123",
|
|
|
+ content:"",
|
|
|
sectorData:data.jsonData
|
|
|
});
|
|
|
- console.log(state.pageData.index.length);
|
|
|
+ console.log("当前添加的板块id:" + state.pageData.index.length);
|
|
|
data.jsonData.sectorId = state.pageData.index.length;
|
|
|
- console.log(data.jsonData);
|
|
|
-
|
|
|
+ console.log("添加完毕后的数据:");
|
|
|
+ console.log(state.pageData.index);
|
|
|
}
|
|
|
},
|
|
|
//删除首页板块
|
|
@@ -146,6 +145,8 @@ const mutations = {
|
|
|
}
|
|
|
}
|
|
|
Message.success('模块已删除!');
|
|
|
+ console.log("删除后的数据结构:");
|
|
|
+ console.log(state.pageData.index);
|
|
|
},
|
|
|
//修改首页板块高度
|
|
|
setIndexModuleHeight(state,data){
|
|
@@ -273,14 +274,22 @@ const mutations = {
|
|
|
//console.log(data.type);
|
|
|
//按照data.data.y的大小排序
|
|
|
data.data.sort((a, b) => a.y - b.y);
|
|
|
+ console.log(data,data);
|
|
|
+ let websiteData = [];
|
|
|
//获取板块的sort
|
|
|
for (let index in data.data) {
|
|
|
console.log(data.data[index].sectorData);
|
|
|
data.data[index].sectorData.sort = Number(index)+1;
|
|
|
if(data.type=="index"){
|
|
|
- state.webSiteData.template.index.push(data.data[index].sectorData)
|
|
|
+ //不要把数据直接保存到state.webSiteData.template中,否则无法删除
|
|
|
+ websiteData.push(data.data[index].sectorData)
|
|
|
}
|
|
|
}
|
|
|
+ //保存到对应的页面json中
|
|
|
+ if(data.type=="index"){
|
|
|
+ state.webSiteData.template.index = websiteData;
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
//保存模板
|
|
|
saveTemplate(state) {
|