|
@@ -193,7 +193,6 @@ const mutations = {
|
|
|
if(state.editComponentType == 7){
|
|
|
state.componentViewData.titleName = state.pageData.index[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if(state.pageStatus == 2){}
|
|
@@ -216,8 +215,9 @@ const mutations = {
|
|
|
},
|
|
|
|
|
|
addModule(state,data){
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
if(state.pageData.index.length >= 10){
|
|
|
Message.error('最多只能添加10个模块!');
|
|
@@ -288,20 +288,91 @@ const mutations = {
|
|
|
state.gridlayoutObj.$children[state.pageData.index.length].$refs.item.style.display="block";
|
|
|
} catch {}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 2){}
|
|
|
-
|
|
|
- if(state.pageStatus == 3){}
|
|
|
-
|
|
|
+
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+
|
|
|
+
|
|
|
+ if(state.pageData.list.length >= 10){
|
|
|
+ Message.error('最多只能添加10个模块!');
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ if(data.source == "click"){
|
|
|
+ console.log("通过点击添加一个板块");
|
|
|
+
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+
|
|
|
+
|
|
|
+ const maxY = Math.max(...state.pageData.list.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ let dataSort = state.pageData.list.length;
|
|
|
+
|
|
|
+
|
|
|
+ state.pageData.list.push({
|
|
|
+ i: id,
|
|
|
+ x: 0,
|
|
|
+ y: maxY + 1,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(data.source == "drag"){
|
|
|
+
|
|
|
+ console.log("通过拖拽添加一个板块");
|
|
|
+
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+
|
|
|
+
|
|
|
+ const maxY = Math.max(...state.pageData.list.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ let dataSort = state.pageData.list.length;
|
|
|
+
|
|
|
+ state.pageData.list.push({
|
|
|
+
|
|
|
+ i: id,
|
|
|
+ x: data.x,
|
|
|
+ y: data.y,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+ console.log("当前添加模块的dataSort为:" + dataSort);
|
|
|
+
|
|
|
+ console.log(state.pageData.list);
|
|
|
+
|
|
|
+ state.gridlayoutObj.dragEvent('dragend', data.i, data.x, data.y, 1,1);
|
|
|
+ try {
|
|
|
+ state.gridlayoutObj.$children[state.pageData.list.length].$refs.item.style.display="block";
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if(state.pageStatus == 4){}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 5){}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 6){}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 7){}
|
|
|
},
|
|
|
|
|
@@ -310,6 +381,7 @@ const mutations = {
|
|
|
|
|
|
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
const indexToRemove = state.pageData.index.findIndex(item => item.i === data.i);
|
|
|
if (indexToRemove !== -1) {
|
|
@@ -319,6 +391,7 @@ const mutations = {
|
|
|
} else {
|
|
|
Message.warning('未找到要删除的模块!');
|
|
|
}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -327,7 +400,19 @@ const mutations = {
|
|
|
|
|
|
if(state.pageStatus == 2){}
|
|
|
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+
|
|
|
+
|
|
|
+ const indexToRemove = state.pageData.list.findIndex(item => item.i === data.i);
|
|
|
+ if (indexToRemove !== -1) {
|
|
|
+ state.pageData.list.splice(indexToRemove, 1);
|
|
|
+ Message.success('模块已删除!');
|
|
|
+ console.log('模块已删除,当前的页面构建数据为:', state.pageData.list);
|
|
|
+ } else {
|
|
|
+ Message.warning('未找到要删除的模块!');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 4){}
|
|
|
|
|
@@ -346,6 +431,7 @@ const mutations = {
|
|
|
console.log(id,dataSort,sort,num);
|
|
|
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
let module = JSON.parse(JSON.stringify(state.pageData.index[dataSort]));
|
|
|
|
|
@@ -360,11 +446,29 @@ const mutations = {
|
|
|
Vue.set(state.pageData.index, dataSort, module);
|
|
|
console.log("当前的板块数据为:");
|
|
|
console.log(state.pageData.index);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(state.pageStatus == 2){}
|
|
|
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+
|
|
|
+
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[dataSort]));
|
|
|
+
|
|
|
+
|
|
|
+ Vue.set(module.content.componentList, sort, {
|
|
|
+ ...module.content.componentList[sort],
|
|
|
+ component_style: num
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Vue.set(state.pageData.list, dataSort, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 4){}
|
|
|
|
|
@@ -380,6 +484,7 @@ const mutations = {
|
|
|
console.log("当前编辑板块:" + data.id)
|
|
|
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
const targetModuleIndex = state.pageData.index.findIndex(module => module.i === data.id);
|
|
|
console.log("要修改的模块id为:")
|
|
|
console.log(data.sort)
|
|
@@ -439,11 +544,58 @@ const mutations = {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(state.pageStatus == 2){}
|
|
|
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+
|
|
|
+ const targetModuleIndex = state.pageData.list.findIndex(module => module.i === data.id);
|
|
|
+ console.log("要修改的模块id为:")
|
|
|
+ console.log(data.sort)
|
|
|
+ console.log(targetModuleIndex)
|
|
|
+ if(state.editComponentType == 1){
|
|
|
+
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[targetModuleIndex]));
|
|
|
+
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr;
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize;
|
|
|
+
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[targetModuleIndex]));
|
|
|
+
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr;
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize;
|
|
|
+
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 3){;
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[targetModuleIndex]));
|
|
|
+ module.content.componentList[data.sort].componentData.text = data.data.adName;
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[targetModuleIndex]));
|
|
|
+ module.content.componentList[data.sort].componentData.text = data.data.titleName;
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 4){}
|
|
|
|
|
@@ -538,6 +690,7 @@ const mutations = {
|
|
|
drag(state, data) {
|
|
|
|
|
|
if (state.pageStatus == 1) {
|
|
|
+
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
|
|
|
let mouseInGrid = false;
|
|
@@ -578,11 +731,54 @@ const mutations = {
|
|
|
state.pageData.index = state.pageData.index.filter(obj => obj.i !== 'drop');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (state.pageStatus == 2) {}
|
|
|
|
|
|
- if (state.pageStatus == 3) {}
|
|
|
+ if (state.pageStatus == 3) {
|
|
|
+
|
|
|
+ let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
+
|
|
|
+ let mouseInGrid = false;
|
|
|
+ if (((state.mouseXY.x > parentRect.left) && (state.mouseXY.x < parentRect.right)) && ((state.mouseXY.y > parentRect.top) && (state.mouseXY.y < parentRect.bottom))) {
|
|
|
+ mouseInGrid = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mouseInGrid === true && (state.pageData.list.findIndex(item => item.i === 'drop')) === -1) {
|
|
|
+ state.pageData.list.push({
|
|
|
+ x: (state.pageData.list.length * 2) % (this.colNum || 12),
|
|
|
+ y: state.pageData.list.length + (this.colNum || 12),
|
|
|
+ w: 12,
|
|
|
+ h: 2,
|
|
|
+ i: 'drop',
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ let index = state.pageData.list.findIndex(item => item.i === 'drop');
|
|
|
+ if (index !== -1) {
|
|
|
+ try {
|
|
|
+ state.gridlayoutObj.$children[state.pageData.list.length].$refs.item.style.display = "none";
|
|
|
+ } catch {
|
|
|
+
|
|
|
+ }
|
|
|
+ let el = state.gridlayoutObj.$children[index];
|
|
|
+ el.dragging = {"top": state.mouseXY.y - parentRect.top, "left": state.mouseXY.x - parentRect.left};
|
|
|
+ let new_pos = el.calcXY(state.mouseXY.y - parentRect.top, state.mouseXY.x - parentRect.left);
|
|
|
+
|
|
|
+ if (mouseInGrid === true) {
|
|
|
+ state.gridlayoutObj.dragEvent('dragstart', 'drop', new_pos.x, new_pos.y, 2, 12);
|
|
|
+ state.DragPos.i = String(index);
|
|
|
+ state.DragPos.x = state.pageData.list[index].x;
|
|
|
+ state.DragPos.y = state.pageData.list[index].y;
|
|
|
+ }
|
|
|
+ if (mouseInGrid === false) {
|
|
|
+ state.gridlayoutObj.dragEvent('dragend', 'drop', new_pos.x, new_pos.y, 2, 12);
|
|
|
+ state.pageData.list = state.pageData.list.filter(obj => obj.i !== 'drop');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if (state.pageStatus == 4) {}
|
|
|
|
|
@@ -594,9 +790,9 @@ const mutations = {
|
|
|
},
|
|
|
|
|
|
dragend(state, data) {
|
|
|
-
|
|
|
|
|
|
if (state.pageStatus == 1) {
|
|
|
+
|
|
|
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
|
|
@@ -636,13 +832,40 @@ const mutations = {
|
|
|
}
|
|
|
|
|
|
this.commit('template/addModule',sendData);
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (state.pageStatus == 2) {}
|
|
|
|
|
|
- if (state.pageStatus == 3) {}
|
|
|
+ if (state.pageStatus == 3) {
|
|
|
+
|
|
|
+
|
|
|
+ let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
+
|
|
|
+ let mouseInGrid = false;
|
|
|
+ if (((state.mouseXY.x > parentRect.left) && (state.mouseXY.x < parentRect.right)) && ((state.mouseXY.y > parentRect.top) && (state.mouseXY.y < parentRect.bottom))) {
|
|
|
+ mouseInGrid = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mouseInGrid === true) {
|
|
|
+ alert(`Dropped element props:\n${JSON.stringify(state.DragPos, ['x', 'y', 'w', 'h'], 2)}`);
|
|
|
+ state.gridlayoutObj.dragEvent('dragend', 'drop', state.DragPos.x, state.DragPos.y, 1, 1);
|
|
|
+ state.pageData.list = state.pageData.list.filter(obj => obj.i !== 'drop');
|
|
|
+
|
|
|
+ let sendData = {
|
|
|
+ source:"drag",
|
|
|
+ type:data.type,
|
|
|
+ h:data.h,
|
|
|
+ jsonData:data.jsonData,
|
|
|
+ x: state.DragPos.x,
|
|
|
+ y: state.DragPos.y,
|
|
|
+ w: 12,
|
|
|
+ }
|
|
|
+ this.commit('template/addModule',sendData);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if (state.pageStatus == 4) {}
|
|
|
|
|
@@ -663,7 +886,11 @@ const mutations = {
|
|
|
|
|
|
if (state.pageStatus == 2) {}
|
|
|
|
|
|
- if (state.pageStatus == 3) {}
|
|
|
+ if (state.pageStatus == 3) {
|
|
|
+ console.log(data);
|
|
|
+ state.pageData.list[data.i].h = data.h;
|
|
|
+ console.log(state.pageData.list[data.i]);
|
|
|
+ }
|
|
|
|
|
|
if (state.pageStatus == 4) {}
|
|
|
|
|
@@ -686,15 +913,19 @@ const mutations = {
|
|
|
console.log(clonedData.data[index].content);
|
|
|
|
|
|
Vue.set(clonedData.data[index].content, 'sort', Number(index) + 1);
|
|
|
- if (data.type == "index") {
|
|
|
-
|
|
|
- websiteData.push(clonedData.data[index].content);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ websiteData.push(clonedData.data[index].content);
|
|
|
}
|
|
|
|
|
|
if (data.type == "index") {
|
|
|
state.webSiteData.template.index = websiteData;
|
|
|
}
|
|
|
+ if (data.type == "list") {
|
|
|
+ state.webSiteData.template.list = websiteData;
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
saveTemplate(state) {
|
|
@@ -703,6 +934,8 @@ const mutations = {
|
|
|
|
|
|
|
|
|
this.commit('template/formatTemplateInfo',{data:state.pageData.index,type:"index"});
|
|
|
+
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.list,type:"list"});
|
|
|
console.log(state.webSiteData);
|
|
|
},
|
|
|
|