|
@@ -1,5 +1,8 @@
|
|
|
-import {getSiteInfo,getSiteCategory,selectWebsiteDepartment,selectWebsiteArea,getWebsiteArticlesList,
|
|
|
- selectWebsiteArticleInfo,getWebsiteCategory} from '@/api/cms'
|
|
|
+
|
|
|
+import {getSiteInfo,getSiteCategory,selectWebsiteDepartment,selectWebsiteArea,getWebsiteArticlesList,selectWebsiteArticleInfo,getWebsiteCategory} from '@/api/cms'
|
|
|
+
|
|
|
+import {getWebsiteintel,addWebsiteTemplateintel,getWebsiteTemplateintel,upWebsiteTemplateintel,getAllTemplateClass,getWebsiteTemplateList,addWebsiteTemplateclassintel,
|
|
|
+ getWebsiteTemplateclassintel} from '@/api/template'
|
|
|
|
|
|
import { Message } from 'element-ui';
|
|
|
|
|
@@ -193,14 +196,54 @@ const mutations = {
|
|
|
if(state.editComponentType == 7){
|
|
|
state.componentViewData.titleName = state.pageData.index[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if(state.pageStatus == 2){}
|
|
|
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ const targetModuleIndex = state.pageData.list.findIndex(module => module.i === data.id);
|
|
|
+
|
|
|
+ if(state.editComponentType == 1){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 3){
|
|
|
+ state.componentViewData.adName = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ state.componentViewData.titleName = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(state.pageStatus == 4){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+
|
|
|
+ const targetModuleIndex = state.pageData.article.findIndex(module => module.i === data.id);
|
|
|
+
|
|
|
+ if(state.editComponentType == 1){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 3){
|
|
|
+ state.componentViewData.adName = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ state.componentViewData.titleName = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 5){}
|
|
|
|
|
@@ -216,8 +259,9 @@ const mutations = {
|
|
|
},
|
|
|
|
|
|
addModule(state,data){
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
if(state.pageData.index.length >= 10){
|
|
|
Message.error('最多只能添加10个模块!');
|
|
@@ -288,20 +332,162 @@ 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 == 4){}
|
|
|
-
|
|
|
+
|
|
|
+ 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.pageData.article.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.article.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ let dataSort = state.pageData.article.length;
|
|
|
+
|
|
|
+
|
|
|
+ state.pageData.article.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.article.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ let dataSort = state.pageData.article.length;
|
|
|
+
|
|
|
+ state.pageData.article.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.article);
|
|
|
+
|
|
|
+ state.gridlayoutObj.dragEvent('dragend', data.i, data.x, data.y, 1,1);
|
|
|
+ try {
|
|
|
+ state.gridlayoutObj.$children[state.pageData.article.length].$refs.item.style.display="block";
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if(state.pageStatus == 5){}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 6){}
|
|
|
-
|
|
|
+
|
|
|
if(state.pageStatus == 7){}
|
|
|
},
|
|
|
|
|
@@ -310,6 +496,7 @@ const mutations = {
|
|
|
|
|
|
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
const indexToRemove = state.pageData.index.findIndex(item => item.i === data.i);
|
|
|
if (indexToRemove !== -1) {
|
|
@@ -319,6 +506,7 @@ const mutations = {
|
|
|
} else {
|
|
|
Message.warning('未找到要删除的模块!');
|
|
|
}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -327,9 +515,33 @@ 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){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+
|
|
|
+
|
|
|
+ const indexToRemove = state.pageData.article.findIndex(item => item.i === data.i);
|
|
|
+ if (indexToRemove !== -1) {
|
|
|
+ state.pageData.article.splice(indexToRemove, 1);
|
|
|
+ Message.success('模块已删除!');
|
|
|
+ console.log('模块已删除,当前的页面构建数据为:', state.pageData.article);
|
|
|
+ } else {
|
|
|
+ Message.warning('未找到要删除的模块!');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 5){}
|
|
|
|
|
@@ -346,6 +558,7 @@ const mutations = {
|
|
|
console.log(id,dataSort,sort,num);
|
|
|
|
|
|
if(state.pageStatus == 1){
|
|
|
+
|
|
|
|
|
|
let module = JSON.parse(JSON.stringify(state.pageData.index[dataSort]));
|
|
|
|
|
@@ -360,13 +573,48 @@ 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){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+
|
|
|
+
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[dataSort]));
|
|
|
+
|
|
|
+
|
|
|
+ Vue.set(module.content.componentList, sort, {
|
|
|
+ ...module.content.componentList[sort],
|
|
|
+ component_style: num
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Vue.set(state.pageData.article, dataSort, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 5){}
|
|
|
|
|
@@ -380,6 +628,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,13 +688,106 @@ 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){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+
|
|
|
+ const targetModuleIndex = state.pageData.article.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.article[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.article, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[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.article, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 3){;
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[targetModuleIndex]));
|
|
|
+ module.content.componentList[data.sort].componentData.text = data.data.adName;
|
|
|
+ Vue.set(state.pageData.article, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[targetModuleIndex]));
|
|
|
+ module.content.componentList[data.sort].componentData.text = data.data.titleName;
|
|
|
+ Vue.set(state.pageData.article, targetModuleIndex, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if(state.pageStatus == 5){}
|
|
|
|
|
@@ -538,6 +880,7 @@ const mutations = {
|
|
|
drag(state, data) {
|
|
|
|
|
|
if (state.pageStatus == 1) {
|
|
|
+
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
|
|
|
let mouseInGrid = false;
|
|
@@ -578,13 +921,98 @@ 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) {}
|
|
|
+ if (state.pageStatus == 4) {
|
|
|
+
|
|
|
+ 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.article.findIndex(item => item.i === 'drop')) === -1) {
|
|
|
+ state.pageData.article.push({
|
|
|
+ x: (state.pageData.article.length * 2) % (this.colNum || 12),
|
|
|
+ y: state.pageData.article.length + (this.colNum || 12),
|
|
|
+ w: 12,
|
|
|
+ h: 2,
|
|
|
+ i: 'drop',
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ let index = state.pageData.article.findIndex(item => item.i === 'drop');
|
|
|
+ if (index !== -1) {
|
|
|
+ try {
|
|
|
+ state.gridlayoutObj.$children[state.pageData.article.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.article[index].x;
|
|
|
+ state.DragPos.y = state.pageData.article[index].y;
|
|
|
+ }
|
|
|
+ if (mouseInGrid === false) {
|
|
|
+ state.gridlayoutObj.dragEvent('dragend', 'drop', new_pos.x, new_pos.y, 2, 12);
|
|
|
+ state.pageData.article = state.pageData.article.filter(obj => obj.i !== 'drop');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if (state.pageStatus == 5) {}
|
|
|
|
|
@@ -594,9 +1022,9 @@ const mutations = {
|
|
|
},
|
|
|
|
|
|
dragend(state, data) {
|
|
|
-
|
|
|
|
|
|
if (state.pageStatus == 1) {
|
|
|
+
|
|
|
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
|
|
@@ -636,15 +1064,69 @@ 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) {}
|
|
|
+ if (state.pageStatus == 4) {
|
|
|
+
|
|
|
+
|
|
|
+ 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.article = state.pageData.article.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 == 5) {}
|
|
|
|
|
@@ -663,9 +1145,17 @@ 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) {}
|
|
|
+ if (state.pageStatus == 4) {
|
|
|
+ console.log(data);
|
|
|
+ state.pageData.article[data.i].h = data.h;
|
|
|
+ console.log(state.pageData.article[data.i]);
|
|
|
+ }
|
|
|
|
|
|
if (state.pageStatus == 5) {}
|
|
|
|
|
@@ -686,15 +1176,22 @@ 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;
|
|
|
+ }
|
|
|
+ if (data.type == "article") {
|
|
|
+ state.webSiteData.template.article = websiteData;
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
saveTemplate(state) {
|
|
@@ -703,6 +1200,10 @@ const mutations = {
|
|
|
|
|
|
|
|
|
this.commit('template/formatTemplateInfo',{data:state.pageData.index,type:"index"});
|
|
|
+
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.list,type:"list"});
|
|
|
+
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.article,type:"article"});
|
|
|
console.log(state.webSiteData);
|
|
|
},
|
|
|
|
|
@@ -771,7 +1272,7 @@ const mutations = {
|
|
|
}
|
|
|
|
|
|
const actions = {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
getSiteInfo({commit},data){
|
|
|
return new Promise((resolve, reject) => {
|
|
@@ -836,7 +1337,90 @@ const actions = {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ getWebsiteintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWebsiteintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ addWebsiteTemplateintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ addWebsiteTemplateintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getWebsiteTemplateintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWebsiteTemplateintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ upWebsiteTemplateintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ upWebsiteTemplateintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getAllTemplateClass({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getAllTemplateClass(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getWebsiteTemplateList({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWebsiteTemplateList(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ addWebsiteTemplateclassintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ addWebsiteTemplateclassintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getWebsiteTemplateclassintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWebsiteTemplateclassintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
}
|
|
|
|
|
|
export default {
|