|
@@ -1,6 +1,8 @@
|
|
|
import {getSiteInfo,getSiteCategory,selectWebsiteDepartment,selectWebsiteArea,getWebsiteArticlesList,
|
|
|
selectWebsiteArticleInfo} from '@/api/cms'
|
|
|
|
|
|
+import { Message } from 'element-ui';
|
|
|
+
|
|
|
const state = {
|
|
|
|
|
|
editWebsiteId: "",
|
|
@@ -10,7 +12,9 @@ const state = {
|
|
|
pageStatus:1,
|
|
|
menuType:1,
|
|
|
pageData: {
|
|
|
- index:[],
|
|
|
+ index:[
|
|
|
+
|
|
|
+ ],
|
|
|
class:[],//分类页
|
|
|
list:[],
|
|
|
article:[],
|
|
@@ -18,6 +22,7 @@ const state = {
|
|
|
aloneList:[],
|
|
|
aloneArticle:[],
|
|
|
},
|
|
|
+ editWindowStatus:false,
|
|
|
|
|
|
|
|
|
|
|
@@ -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') {
|
|
|
+
|
|
|
+ const thatY = Math.max(
|
|
|
+ ...modules
|
|
|
+ .filter(item => item.y < thisY)
|
|
|
+ .map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === -Infinity) {
|
|
|
+ Message.error('已经是顶部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('上方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [modules[thisIndex].y, modules[thatIndex].y] = [modules[thatIndex].y, modules[thisIndex].y];
|
|
|
+
|
|
|
+ } else if (moveType === 'down') {
|
|
|
+
|
|
|
+ const thatY = Math.min(
|
|
|
+ ...modules
|
|
|
+ .filter(item => item.y > thisY)
|
|
|
+ .map(item => item.y)
|
|
|
+ );
|
|
|
+ if (thatY === Infinity) {
|
|
|
+ Message.error('已经是底部了!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const thatIndex = modules.findIndex(item => item.y === thatY);
|
|
|
+ if (thatIndex === -1) {
|
|
|
+ Message.error('下方模块未找到!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [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);
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
|
@@ -107,6 +173,38 @@ const mutations = {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -134,10 +232,6 @@ const mutations = {
|
|
|
state.area.county = data.region;
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- setDepartmentList(state,data){
|
|
|
- state.departmentList = data;
|
|
|
- },
|
|
|
|
|
|
}
|
|
|
|
|
@@ -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) => {
|