|
@@ -1,6 +1,8 @@
|
|
|
import {getSiteInfo,getSiteCategory,selectWebsiteDepartment,selectWebsiteArea,getWebsiteArticlesList,
|
|
|
selectWebsiteArticleInfo} from '@/api/cms'
|
|
|
|
|
|
+import { Message } from 'element-ui'; //注意在这里引入是非常不符合规范的
|
|
|
+
|
|
|
const state = {
|
|
|
//0.全局配置 start------------------------------------------------------------>
|
|
|
editWebsiteId: "",//当前编辑网站的id
|
|
@@ -10,7 +12,9 @@ const state = {
|
|
|
pageStatus:1,//当前编辑哪个页面 1=首页 2=分类页 3=列表页 4=详情页 5=搜索页 6=自定义列表页 7=自定义详情页
|
|
|
menuType:1, //当前菜单显示板块还是组件 1=板块 2=组件
|
|
|
pageData: { //准备提交到后台的数据
|
|
|
- index:[],//首页
|
|
|
+ index:[
|
|
|
+
|
|
|
+ ],//首页
|
|
|
class:[],//分类页
|
|
|
list:[],//列表页
|
|
|
article:[],//详情页
|
|
@@ -18,6 +22,7 @@ const state = {
|
|
|
aloneList:[],//自定义列表页
|
|
|
aloneArticle:[],//自定义详情页
|
|
|
},
|
|
|
+ editWindowStatus:false,//编辑弹出框是否显示
|
|
|
// layout: [
|
|
|
// // i = id
|
|
|
// // w = 最大宽度是12
|
|
@@ -70,6 +75,7 @@ const mutations = {
|
|
|
type: data.type,
|
|
|
content:""
|
|
|
});
|
|
|
+ console.log(state.pageData.index);
|
|
|
},
|
|
|
//删除首页板块
|
|
|
deleteIndexModule(state,data){
|
|
@@ -78,6 +84,7 @@ const mutations = {
|
|
|
state.pageData.index.splice(i, 1);
|
|
|
}
|
|
|
}
|
|
|
+ Message.success('模块已删除!');
|
|
|
},
|
|
|
//修改首页板块高度
|
|
|
setIndexModuleHeight(state,data){
|
|
@@ -85,6 +92,65 @@ const mutations = {
|
|
|
state.pageData.index[data.i].h = data.h;
|
|
|
console.log(state.pageData.index[data.i]);
|
|
|
},
|
|
|
+ moveIndexModule(state, data) {
|
|
|
+ const moveType = data.moveType;
|
|
|
+ const moduleId = data.i;
|
|
|
+ const modules = state.pageData.index;
|
|
|
+ // 查找模块在数组中的实际索引
|
|
|
+ const thisIndex = modules.findIndex(module => module.i === moduleId);
|
|
|
+ if (thisIndex === -1) {
|
|
|
+ Message.error('模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const thisY = modules[thisIndex].y;
|
|
|
+
|
|
|
+ if (moveType === 'up') {
|
|
|
+ // 查找比当前模块 y 值小的最大的 y 值
|
|
|
+ const thatY = Math.max(
|
|
|
+ ...modules
|
|
|
+ .filter(item => item.y < thisY)
|
|
|
+ .map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === -Infinity) {
|
|
|
+ Message.error('已经是顶部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查找具有 thatY 的模块索引
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('上方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 交换 y 值
|
|
|
+ [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+
|
|
|
+ } else if (moveType === 'down') {
|
|
|
+ // 查找比当前模块 y 值大的最小的 y 值
|
|
|
+ const thatY = Math.min(
|
|
|
+ ...modules
|
|
|
+ .filter(item => item.y > thisY)
|
|
|
+ .map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === Infinity) {
|
|
|
+ Message.error('已经是底部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查找具有 thatY 的模块索引
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('下方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 交换 y 值
|
|
|
+ [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Message.error('未知的移动类型!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 交换后对模块进行排序以确保顺序一致
|
|
|
+ state.pageData.index.sort((a, b) => a.y - b.y);
|
|
|
+ },
|
|
|
//添加模块
|
|
|
// addModule(state,data) {
|
|
|
// //data.type 组件名称 data.h 模块高度
|
|
@@ -107,6 +173,38 @@ const mutations = {
|
|
|
// if(state.layout[i].i == item.i) {
|
|
|
// state.layout.splice(i, 1);
|
|
|
// }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ //移动模块
|
|
|
+ // moveIndexModule(state,data){
|
|
|
+ // console.log(state.pageData.index[data.i]);
|
|
|
+
|
|
|
+ // if(data.moveType == 'up'){
|
|
|
+
|
|
|
+ // }else{
|
|
|
+
|
|
|
+ // if(state.pageData.index[data.i].y === Math.max(...state.pageData.index.map(item => item.y))){
|
|
|
+ // Message.error('已经是底部了!');
|
|
|
+ // }else{
|
|
|
+ // console.log(state.pageData.index);
|
|
|
+ // //当前选择的模块
|
|
|
+ // let thisIndex = data.i;
|
|
|
+ // let thisY = state.pageData.index[thisIndex].y;
|
|
|
+
|
|
|
+ // //找到下方的模块的y值
|
|
|
+ // //注意,这里不能用i去定位,因为模块是通过y值去排序的,跟数据的位置,i的位置都没有关系
|
|
|
+ // const thatY = Math.min(...state.pageData.index
|
|
|
+ // .filter(item => item.y > thisY)
|
|
|
+ // .map(item => item.y),
|
|
|
+ // Infinity);
|
|
|
+ // //再通过y值找到对应的模块i
|
|
|
+ // const thatIndex = state.pageData.index.findIndex(item => item.y === thatY);
|
|
|
+
|
|
|
+ // //最后交换位置
|
|
|
+ // state.pageData.index[thisIndex].y = thatY;
|
|
|
+ // state.pageData.index[thatIndex].y = thisY;
|
|
|
+ // }
|
|
|
+
|
|
|
// }
|
|
|
// },
|
|
|
//1.配置模块 end------------------------------------------------------------>
|
|
@@ -134,10 +232,6 @@ const mutations = {
|
|
|
state.area.county = data.region;
|
|
|
}
|
|
|
},
|
|
|
- //设置职能部门
|
|
|
- setDepartmentList(state,data){
|
|
|
- state.departmentList = data;
|
|
|
- },
|
|
|
//2.获取站点信息 end------------------------------------------------------------>
|
|
|
}
|
|
|
|
|
@@ -176,17 +270,6 @@ const actions = {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- //设置职能部门
|
|
|
- selectWebsiteDepartment({commit},data){
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- selectWebsiteDepartment(data).then(response => {
|
|
|
- commit('setDepartmentList', response.data);
|
|
|
- resolve(response)
|
|
|
- }).catch(error => {
|
|
|
- reject(error)
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
//获取新闻列表
|
|
|
getWebsiteArticlesList({commit},data){
|
|
|
return new Promise((resolve, reject) => {
|