|
@@ -1,5 +1,8 @@
|
|
|
-import {getSiteInfo,getSiteCategory,selectWebsiteDepartment,selectWebsiteArea,getWebsiteArticlesList,
|
|
|
- selectWebsiteArticleInfo,getWebsiteCategory} from '@/api/cms'
|
|
|
+//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;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//pageStatus==2 分类页
|
|
|
if(state.pageStatus == 2){}
|
|
|
//pageStatus==3 列表页
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ const targetModuleIndex = state.pageData.list.findIndex(module => module.i === data.id);
|
|
|
+ //判断组件类型 1=普通新闻 2=tabs新闻选项卡 3=广告 4=友情链接 6=静态组件 7=文本 8=评论
|
|
|
+ if(state.editComponentType == 1){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+ //2=tabs新闻选项卡
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+ //3=广告名称
|
|
|
+ if(state.editComponentType == 3){
|
|
|
+ state.componentViewData.adName = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ //7=标题
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ state.componentViewData.titleName = state.pageData.list[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
//pageStatus==4 详情页
|
|
|
- if(state.pageStatus == 4){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+
|
|
|
+ const targetModuleIndex = state.pageData.article.findIndex(module => module.i === data.id);
|
|
|
+ //判断组件类型 1=普通新闻 2=tabs新闻选项卡 3=广告 4=友情链接 6=静态组件 7=文本 8=评论
|
|
|
+ if(state.editComponentType == 1){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+ //2=tabs新闻选项卡
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ state.componentViewData.pid_arr = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.category_id;
|
|
|
+ state.componentViewData.pageSize = state.editComponentSize;
|
|
|
+ }
|
|
|
+ //3=广告名称
|
|
|
+ if(state.editComponentType == 3){
|
|
|
+ state.componentViewData.adName = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ //7=标题
|
|
|
+ if(state.editComponentType == 7){
|
|
|
+ state.componentViewData.titleName = state.pageData.article[targetModuleIndex].content.componentList[data.sort].componentData.text;
|
|
|
+ }
|
|
|
+ }
|
|
|
//pageStatus==5 搜索页
|
|
|
if(state.pageStatus == 5){}
|
|
|
//pageStatus==6 自定义列表页
|
|
@@ -216,8 +259,9 @@ const mutations = {
|
|
|
},
|
|
|
//添加板块
|
|
|
addModule(state,data){
|
|
|
- //pageStatus==1 首页
|
|
|
+ //pageStatus==1 首页 index
|
|
|
if(state.pageStatus == 1){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
//判断当前一共有多少个模块最多能添加10个
|
|
|
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 {}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
}
|
|
|
- //pageStatus==2 分类页
|
|
|
+ //pageStatus==2 分类页 class
|
|
|
if(state.pageStatus == 2){}
|
|
|
- //pageStatus==3 列表页
|
|
|
- if(state.pageStatus == 3){}
|
|
|
- //pageStatus==4 详情页
|
|
|
- if(state.pageStatus == 4){}
|
|
|
- //pageStatus==5 搜索页
|
|
|
+ //pageStatus==3 列表页 list
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //判断当前一共有多少个模块最多能添加10个
|
|
|
+ if(state.pageData.list.length >= 10){
|
|
|
+ Message.error('最多只能添加10个模块!');
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ //判断是拖拽的还是点击添加进来的 click=点击
|
|
|
+ if(data.source == "click"){
|
|
|
+ console.log("通过点击添加一个板块");
|
|
|
+ //通过时间戳生成id
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+ //data.type 组件名称 data.h 模块高度
|
|
|
+ //计算当前布局的最大 y 值
|
|
|
+ const maxY = Math.max(...state.pageData.list.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+ //设置数据在构建json中的位置
|
|
|
+ let dataSort = state.pageData.list.length;
|
|
|
+
|
|
|
+ //添加板块id
|
|
|
+ state.pageData.list.push({
|
|
|
+ i: id,
|
|
|
+ x: 0,
|
|
|
+ y: maxY + 1,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //drag=拖拽
|
|
|
+ if(data.source == "drag"){
|
|
|
+ //拖拽添加
|
|
|
+ console.log("通过拖拽添加一个板块");
|
|
|
+ //通过时间戳生成id
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+ //data.type 组件名称 data.h 模块高度
|
|
|
+ //计算当前布局的最大 y 值
|
|
|
+ const maxY = Math.max(...state.pageData.list.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+ //设置数据在构建json中的位置
|
|
|
+ let dataSort = state.pageData.list.length;
|
|
|
+ //添加板块id
|
|
|
+ state.pageData.list.push({
|
|
|
+ //i: state.pageData.list.length, //base 0.0.1 此方法会导致重复的id出现
|
|
|
+ i: id,
|
|
|
+ x: data.x,
|
|
|
+ y: data.y,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+ //sectorData:data.jsonData //base 0.0.1 此问题导致深层数据无法被视图渲染
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+ console.log("当前添加模块的dataSort为:" + dataSort);
|
|
|
+ //当前的页面构建数据
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ //需要调查一下这里最后的1,1
|
|
|
+ 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 {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
+ //pageStatus==4 详情页 article
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //判断当前一共有多少个模块最多能添加10个
|
|
|
+ if(state.pageData.article.length >= 10){
|
|
|
+ Message.error('最多只能添加10个模块!');
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ //判断是拖拽的还是点击添加进来的 click=点击
|
|
|
+ if(data.source == "click"){
|
|
|
+ console.log("通过点击添加一个板块");
|
|
|
+ //通过时间戳生成id
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+ //data.type 组件名称 data.h 模块高度
|
|
|
+ //计算当前布局的最大 y 值
|
|
|
+ const maxY = Math.max(...state.pageData.article.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+ //设置数据在构建json中的位置
|
|
|
+ let dataSort = state.pageData.article.length;
|
|
|
+
|
|
|
+ //添加板块id
|
|
|
+ state.pageData.article.push({
|
|
|
+ i: id,
|
|
|
+ x: 0,
|
|
|
+ y: maxY + 1,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //drag=拖拽
|
|
|
+ if(data.source == "drag"){
|
|
|
+ //拖拽添加
|
|
|
+ console.log("通过拖拽添加一个板块");
|
|
|
+ //通过时间戳生成id
|
|
|
+ const currentTimestamp = Date.now();
|
|
|
+ let id = currentTimestamp;
|
|
|
+ //data.type 组件名称 data.h 模块高度
|
|
|
+ //计算当前布局的最大 y 值
|
|
|
+ const maxY = Math.max(...state.pageData.article.map(item => item.y), 0);
|
|
|
+ console.log(data);
|
|
|
+ //设置数据在构建json中的位置
|
|
|
+ let dataSort = state.pageData.article.length;
|
|
|
+ //添加板块id
|
|
|
+ state.pageData.article.push({
|
|
|
+ //i: state.pageData.article.length, //base 0.0.1 此方法会导致重复的id出现
|
|
|
+ i: id,
|
|
|
+ x: data.x,
|
|
|
+ y: data.y,
|
|
|
+ w: 12,
|
|
|
+ h: data.h,
|
|
|
+ type: data.type,
|
|
|
+ //sectorData:data.jsonData //base 0.0.1 此问题导致深层数据无法被视图渲染
|
|
|
+ content:data.jsonData,
|
|
|
+ dataSort:dataSort
|
|
|
+ });
|
|
|
+ console.log("当前添加模块的dataSort为:" + dataSort);
|
|
|
+ //当前的页面构建数据
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ //需要调查一下这里最后的1,1
|
|
|
+ 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 {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
+ //pageStatus==5 搜索页 search
|
|
|
if(state.pageStatus == 5){}
|
|
|
- //pageStatus==6 自定义列表页
|
|
|
+ //pageStatus==6 自定义列表页 aloneList
|
|
|
if(state.pageStatus == 6){}
|
|
|
- //pageStatus==7 自定义详情页
|
|
|
+ //pageStatus==7 自定义详情页 aloneArticle
|
|
|
if(state.pageStatus == 7){}
|
|
|
},
|
|
|
//删除板块
|
|
@@ -310,6 +496,7 @@ const mutations = {
|
|
|
//data.dataSort = dataSort
|
|
|
//pageStatus==1 首页
|
|
|
if(state.pageStatus == 1){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
//必须通过重新查找id的方式来删除
|
|
|
const indexToRemove = state.pageData.index.findIndex(item => item.i === data.i);
|
|
|
if (indexToRemove !== -1) {
|
|
@@ -319,6 +506,7 @@ const mutations = {
|
|
|
} else {
|
|
|
Message.warning('未找到要删除的模块!');
|
|
|
}
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
// base 0.0.2 如果使用splice方法删除sort,当你就剩下最后一个的时候,会出现找不到那个元素的问题
|
|
|
// state.pageData.index.splice(data.dataSort,1);
|
|
|
// Message.success('模块已删除!');
|
|
@@ -327,9 +515,33 @@ const mutations = {
|
|
|
//pageStatus==2 分类页
|
|
|
if(state.pageStatus == 2){}
|
|
|
//pageStatus==3 列表页
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //必须通过重新查找id的方式来删除
|
|
|
+ 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('未找到要删除的模块!');
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==4 详情页
|
|
|
- if(state.pageStatus == 4){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //必须通过重新查找id的方式来删除
|
|
|
+ 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('未找到要删除的模块!');
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==5 搜索页
|
|
|
if(state.pageStatus == 5){}
|
|
|
//pageStatus==6 自定义列表页
|
|
@@ -346,6 +558,7 @@ const mutations = {
|
|
|
console.log(id,dataSort,sort,num);
|
|
|
//pageStatus==1 首页
|
|
|
if(state.pageStatus == 1){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
// 获取当前模块数据并进行深拷贝
|
|
|
let module = JSON.parse(JSON.stringify(state.pageData.index[dataSort]));
|
|
|
//module.content.componentList[sort].component_style = num;
|
|
@@ -360,13 +573,48 @@ const mutations = {
|
|
|
Vue.set(state.pageData.index, dataSort, module);
|
|
|
console.log("当前的板块数据为:");
|
|
|
console.log(state.pageData.index);
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
}
|
|
|
//pageStatus==2 分类页
|
|
|
if(state.pageStatus == 2){}
|
|
|
//pageStatus==3 列表页
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ // 获取当前模块数据并进行深拷贝
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[dataSort]));
|
|
|
+ //module.content.componentList[sort].component_style = num;
|
|
|
+ //确保修改属性时 Vue 能监控到变化
|
|
|
+ Vue.set(module.content.componentList, sort, {
|
|
|
+ ...module.content.componentList[sort],
|
|
|
+ component_style: num
|
|
|
+ });
|
|
|
+ // 拷贝后直接替换原来的板块
|
|
|
+ //state.pageData.index[id] = module;
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.list, dataSort, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==4 详情页
|
|
|
- if(state.pageStatus == 4){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ // 获取当前模块数据并进行深拷贝
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[dataSort]));
|
|
|
+ //module.content.componentList[sort].component_style = num;
|
|
|
+ //确保修改属性时 Vue 能监控到变化
|
|
|
+ Vue.set(module.content.componentList, sort, {
|
|
|
+ ...module.content.componentList[sort],
|
|
|
+ component_style: num
|
|
|
+ });
|
|
|
+ // 拷贝后直接替换原来的板块
|
|
|
+ //state.pageData.index[id] = module;
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.article, dataSort, module);
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==5 搜索页
|
|
|
if(state.pageStatus == 5){}
|
|
|
//pageStatus==6 自定义列表页
|
|
@@ -380,6 +628,7 @@ const mutations = {
|
|
|
console.log("当前编辑板块:" + data.id)
|
|
|
//pageStatus==1 首页
|
|
|
if(state.pageStatus == 1){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
const targetModuleIndex = state.pageData.index.findIndex(module => module.i === data.id);
|
|
|
console.log("要修改的模块id为:") //找到要修改的板块
|
|
|
console.log(data.sort) //找到要修改的板块
|
|
@@ -439,13 +688,106 @@ const mutations = {
|
|
|
}
|
|
|
//8=评论
|
|
|
//if(state.editComponentType == 8){}
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
}
|
|
|
//pageStatus==2 分类页
|
|
|
if(state.pageStatus == 2){}
|
|
|
//pageStatus==3 列表页
|
|
|
- if(state.pageStatus == 3){}
|
|
|
+ if(state.pageStatus == 3){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ 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])); // 深拷贝整个模块
|
|
|
+ // 更新 category_id 和 pageSize
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr; // 设置 category_id
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize; // 设置 pageSize
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module); // 替换为深拷贝的模块
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+ //2=tabs新闻选项卡
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ // 获取当前模块数据并进行深拷贝
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.list[targetModuleIndex])); // 深拷贝整个模块
|
|
|
+ // 更新 category_id 和 pageSize
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr; // 设置 category_id
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize; // 设置 pageSize
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.list, targetModuleIndex, module); // 替换为深拷贝的模块
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.list);
|
|
|
+ }
|
|
|
+ //3=广告
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //7=文本
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==4 详情页
|
|
|
- if(state.pageStatus == 4){}
|
|
|
+ if(state.pageStatus == 4){
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ 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])); // 深拷贝整个模块
|
|
|
+ // 更新 category_id 和 pageSize
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr; // 设置 category_id
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize; // 设置 pageSize
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.article, targetModuleIndex, module); // 替换为深拷贝的模块
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+ //2=tabs新闻选项卡
|
|
|
+ if(state.editComponentType == 2){
|
|
|
+ // 获取当前模块数据并进行深拷贝
|
|
|
+ let module = JSON.parse(JSON.stringify(state.pageData.article[targetModuleIndex])); // 深拷贝整个模块
|
|
|
+ // 更新 category_id 和 pageSize
|
|
|
+ module.content.componentList[data.sort].componentData.category_id = data.data.pid_arr; // 设置 category_id
|
|
|
+ module.content.componentList[data.sort].componentData.pageSize = state.editComponentSize; // 设置 pageSize
|
|
|
+ // 使用Vue.set来强制视图更新
|
|
|
+ Vue.set(state.pageData.article, targetModuleIndex, module); // 替换为深拷贝的模块
|
|
|
+ console.log("当前的板块数据为:");
|
|
|
+ console.log(state.pageData.article);
|
|
|
+ }
|
|
|
+ //3=广告
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //7=文本
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
//pageStatus==5 搜索页
|
|
|
if(state.pageStatus == 5){}
|
|
|
//pageStatus==6 自定义列表页
|
|
@@ -538,6 +880,7 @@ const mutations = {
|
|
|
drag(state, data) {
|
|
|
// pageStatus == 1 首页
|
|
|
if (state.pageStatus == 1) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
//console.log(parentRect); 获取画布
|
|
|
let mouseInGrid = false;
|
|
@@ -578,13 +921,98 @@ const mutations = {
|
|
|
state.pageData.index = state.pageData.index.filter(obj => obj.i !== 'drop');
|
|
|
}
|
|
|
}
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
}
|
|
|
// pageStatus == 2 分类页
|
|
|
if (state.pageStatus == 2) {}
|
|
|
// pageStatus == 3 列表页
|
|
|
- if (state.pageStatus == 3) {}
|
|
|
+ if (state.pageStatus == 3) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
+ //console.log(parentRect); 获取画布
|
|
|
+ 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), // puts it at the bottom
|
|
|
+ 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');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
// pageStatus == 4 详情页
|
|
|
- if (state.pageStatus == 4) {}
|
|
|
+ if (state.pageStatus == 4) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
+ //console.log(parentRect); 获取画布
|
|
|
+ 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), // puts it at the bottom
|
|
|
+ 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');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
// pageStatus == 5 搜索页
|
|
|
if (state.pageStatus == 5) {}
|
|
|
// pageStatus == 6 自定义列表页
|
|
@@ -594,9 +1022,9 @@ const mutations = {
|
|
|
},
|
|
|
//拖拽结束 定位落点
|
|
|
dragend(state, data) {
|
|
|
-
|
|
|
// pageStatus == 1 首页
|
|
|
if (state.pageStatus == 1) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
//获取画布尺寸
|
|
|
let parentRect = document.getElementById('content').getBoundingClientRect();
|
|
|
//判断是否在画布内
|
|
@@ -636,15 +1064,69 @@ const mutations = {
|
|
|
}
|
|
|
//开发到这里了,注意我可能还需要上面那个 this.$refs.gridLayout.dragEvent方法
|
|
|
this.commit('template/addModule',sendData);
|
|
|
-
|
|
|
}
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
}
|
|
|
// pageStatus == 2 分类页
|
|
|
if (state.pageStatus == 2) {}
|
|
|
// pageStatus == 3 列表页
|
|
|
- if (state.pageStatus == 3) {}
|
|
|
+ if (state.pageStatus == 3) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //获取画布尺寸
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
// pageStatus == 4 详情页
|
|
|
- if (state.pageStatus == 4) {}
|
|
|
+ if (state.pageStatus == 4) {
|
|
|
+ //开始复制 start------------------------------------------------------------>
|
|
|
+ //获取画布尺寸
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ //开始复制 end------------------------------------------------------------>
|
|
|
+ }
|
|
|
// pageStatus == 5 搜索页
|
|
|
if (state.pageStatus == 5) {}
|
|
|
// pageStatus == 6 自定义列表页
|
|
@@ -663,9 +1145,17 @@ const mutations = {
|
|
|
// pageStatus == 2 分类页
|
|
|
if (state.pageStatus == 2) {}
|
|
|
// pageStatus == 3 列表页
|
|
|
- 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]);
|
|
|
+ }
|
|
|
// pageStatus == 4 详情页
|
|
|
- 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]);
|
|
|
+ }
|
|
|
// pageStatus == 5 搜索页
|
|
|
if (state.pageStatus == 5) {}
|
|
|
// pageStatus == 6 自定义列表页
|
|
@@ -686,15 +1176,22 @@ const mutations = {
|
|
|
console.log(clonedData.data[index].content);
|
|
|
// 使用 Vue.set 来确保属性变更能被 Vue 追踪
|
|
|
Vue.set(clonedData.data[index].content, 'sort', Number(index) + 1);
|
|
|
- if (data.type == "index") {
|
|
|
- // 不要把数据直接保存到 state.webSiteData.template 中,否则无法删除
|
|
|
- websiteData.push(clonedData.data[index].content);
|
|
|
- }
|
|
|
+ // if (data.type == "index") {
|
|
|
+ // // 不要把数据直接保存到 state.webSiteData.template 中,否则无法删除
|
|
|
+ // websiteData.push(clonedData.data[index].content);
|
|
|
+ // }
|
|
|
+ websiteData.push(clonedData.data[index].content);
|
|
|
}
|
|
|
// 保存到对应的页面 json 中
|
|
|
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 = {
|
|
|
//调用mutations中的方法无需使用$store
|
|
|
//格式化index的信息
|
|
|
this.commit('template/formatTemplateInfo',{data:state.pageData.index,type:"index"});
|
|
|
+ //格式化list的信息
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.list,type:"list"});
|
|
|
+ //格式化article的信息
|
|
|
+ this.commit('template/formatTemplateInfo',{data:state.pageData.article,type:"article"});
|
|
|
console.log(state.webSiteData);
|
|
|
},
|
|
|
//随机生成模板
|
|
@@ -771,7 +1272,7 @@ const mutations = {
|
|
|
}
|
|
|
|
|
|
const actions = {
|
|
|
- //1.站点数据 start------------------------------------------------------------>
|
|
|
+ //1.显示画板组件数据 start------------------------------------------------------------>
|
|
|
//获取网站基本信息
|
|
|
getSiteInfo({commit},data){
|
|
|
return new Promise((resolve, reject) => {
|
|
@@ -836,7 +1337,90 @@ const actions = {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- //1.站点数据 end------------------------------------------------------------>
|
|
|
+ //1.显示画板组件数据 end------------------------------------------------------------>
|
|
|
+
|
|
|
+ //2.构建网站json start------------------------------------------------------------>
|
|
|
+ //搜索网站
|
|
|
+ getWebsiteintel({commit},data){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ getWebsiteintel(data).then(response => {
|
|
|
+ resolve(response)
|
|
|
+ }).catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //添加网站基本信息 如果只传入website_id,则验证是否已经关联导航池
|
|
|
+ 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)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //2.构建网站json end------------------------------------------------------------>
|
|
|
}
|
|
|
|
|
|
export default {
|