2021-03-03 15:06:52 +08:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
import getters from './getters'
|
|
|
|
import app from './modules/app'
|
|
|
|
import settings from './modules/settings'
|
|
|
|
import user from './modules/user'
|
|
|
|
import permission from './modules/permission'
|
|
|
|
import dataset from './modules/dataset'
|
2021-03-03 18:35:51 +08:00
|
|
|
import chart from './modules/chart'
|
2021-03-04 14:58:52 +08:00
|
|
|
import request from './modules/request'
|
2021-03-08 14:31:09 +08:00
|
|
|
import panel from './modules/panel'
|
2021-03-29 21:24:33 +08:00
|
|
|
import application from './modules/application'
|
2021-05-12 16:19:41 +08:00
|
|
|
import lic from './modules/lic'
|
2021-07-09 18:37:07 +08:00
|
|
|
import msg from './modules/msg'
|
2021-07-27 18:03:56 +08:00
|
|
|
import map from './modules/map'
|
2021-03-30 15:38:32 +08:00
|
|
|
import animation from '@/components/canvas/store/animation'
|
|
|
|
import compose from '@/components/canvas/store/compose'
|
|
|
|
import contextmenu from '@/components/canvas/store/contextmenu'
|
|
|
|
import copy from '@/components/canvas/store/copy'
|
|
|
|
import event from '@/components/canvas/store/event'
|
|
|
|
import layer from '@/components/canvas/store/layer'
|
|
|
|
import snapshot from '@/components/canvas/store/snapshot'
|
|
|
|
import lock from '@/components/canvas/store/lock'
|
2021-08-10 15:50:00 +08:00
|
|
|
import { valueValid, formatCondition, formatLinkageCondition } from '@/utils/conditionUtil'
|
|
|
|
import { Condition } from '@/components/widget/bean/Condition'
|
|
|
|
|
2021-05-05 22:14:23 +08:00
|
|
|
import {
|
2021-06-24 12:08:42 +08:00
|
|
|
DEFAULT_COMMON_CANVAS_STYLE_STRING
|
2021-05-05 22:14:23 +08:00
|
|
|
} from '@/views/panel/panel'
|
2021-10-11 23:27:48 +08:00
|
|
|
import bus from '@/utils/bus'
|
2021-12-23 18:15:49 +08:00
|
|
|
import { BASE_MOBILE_STYLE } from '@/components/canvas/custom-component/component-list'
|
2021-05-05 22:14:23 +08:00
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
Vue.use(Vuex)
|
|
|
|
|
2021-03-25 19:16:32 +08:00
|
|
|
const data = {
|
|
|
|
state: {
|
|
|
|
...animation.state,
|
|
|
|
...compose.state,
|
|
|
|
...contextmenu.state,
|
|
|
|
...copy.state,
|
|
|
|
...event.state,
|
|
|
|
...layer.state,
|
|
|
|
...snapshot.state,
|
|
|
|
...lock.state,
|
2021-11-23 15:34:42 +08:00
|
|
|
// 编辑器模式 edit preview
|
|
|
|
editMode: 'edit',
|
|
|
|
// 当前页面全局数据 包括扩展公共样式 公共的仪表板样式,用来实时响应样式的变化
|
|
|
|
canvasStyleData: DEFAULT_COMMON_CANVAS_STYLE_STRING,
|
|
|
|
// 当前展示画布缓存数据
|
|
|
|
componentDataCache: null,
|
|
|
|
// 当前展示画布组件数据
|
|
|
|
componentData: [],
|
|
|
|
// PC布局画布组件数据
|
|
|
|
pcComponentData: [],
|
|
|
|
// 移动端布局画布组件数据
|
|
|
|
mobileComponentData: [],
|
|
|
|
// 当前点击组件
|
2021-03-25 19:16:32 +08:00
|
|
|
curComponent: null,
|
2021-06-01 13:40:26 +08:00
|
|
|
curCanvasScale: null,
|
2021-03-25 19:16:32 +08:00
|
|
|
curComponentIndex: null,
|
2021-12-17 18:11:39 +08:00
|
|
|
// 预览仪表板缩放信息
|
|
|
|
previewCanvasScale: {
|
|
|
|
scalePointWidth: 1,
|
|
|
|
scalePointHeight: 1
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
// 点击画布时是否点中组件,主要用于取消选中组件用。
|
|
|
|
// 如果没点中组件,并且在画布空白处弹起鼠标,则取消当前组件的选中状态
|
2021-05-05 22:14:23 +08:00
|
|
|
isClickComponent: false,
|
2021-07-29 12:46:54 +08:00
|
|
|
canvasCommonStyleData: DEFAULT_COMMON_CANVAS_STYLE_STRING,
|
|
|
|
// 联动设置状态
|
2021-08-04 16:52:49 +08:00
|
|
|
linkageSettingStatus: false,
|
|
|
|
// 当前设置联动的组件
|
|
|
|
curLinkageView: null,
|
|
|
|
// 和当前组件联动的目标组件
|
2021-08-10 15:50:00 +08:00
|
|
|
targetLinkageInfo: [],
|
|
|
|
// 当前仪表板联动 下钻 上卷等信息
|
2021-11-23 15:34:42 +08:00
|
|
|
nowPanelTrackInfo: {},
|
|
|
|
// 当前仪表板的跳转信息基础信息
|
|
|
|
nowPanelJumpInfo: {},
|
|
|
|
// 当前仪表板的跳转信息(只包括仪表板)
|
|
|
|
nowPanelJumpInfoTargetPanel: {},
|
2021-09-17 17:48:58 +08:00
|
|
|
// 拖拽的组件信息
|
2021-11-08 19:03:09 +08:00
|
|
|
dragComponentInfo: null,
|
|
|
|
// 仪表板组件间隙大小 px
|
2021-11-23 15:34:42 +08:00
|
|
|
componentGap: 5,
|
|
|
|
// 移动端布局状态
|
|
|
|
mobileLayoutStatus: false,
|
2021-12-14 11:43:41 +08:00
|
|
|
// 公共链接状态(当前是否是公共链接打开)
|
|
|
|
publicLinkStatus: false,
|
2021-11-23 15:34:42 +08:00
|
|
|
pcMatrixCount: {
|
|
|
|
x: 36,
|
|
|
|
y: 18
|
|
|
|
},
|
|
|
|
mobileMatrixCount: {
|
|
|
|
x: 6,
|
|
|
|
y: 12
|
|
|
|
},
|
|
|
|
mobileLayoutStyle: {
|
|
|
|
x: 300,
|
|
|
|
y: 600
|
2022-01-20 11:33:41 +08:00
|
|
|
},
|
|
|
|
scrollAutoMove: 0
|
2021-03-25 19:16:32 +08:00
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
...animation.mutations,
|
|
|
|
...compose.mutations,
|
|
|
|
...contextmenu.mutations,
|
|
|
|
...copy.mutations,
|
|
|
|
...event.mutations,
|
|
|
|
...layer.mutations,
|
|
|
|
...snapshot.mutations,
|
|
|
|
...lock.mutations,
|
|
|
|
|
|
|
|
setClickComponentStatus(state, status) {
|
|
|
|
state.isClickComponent = status
|
|
|
|
},
|
|
|
|
|
|
|
|
setEditMode(state, mode) {
|
|
|
|
state.editMode = mode
|
|
|
|
},
|
|
|
|
|
|
|
|
setCanvasStyle(state, style) {
|
2021-09-15 18:11:05 +08:00
|
|
|
if (style) {
|
|
|
|
style['selfAdaption'] = true
|
|
|
|
}
|
2021-03-25 19:16:32 +08:00
|
|
|
state.canvasStyleData = style
|
|
|
|
},
|
|
|
|
|
|
|
|
setCurComponent(state, { component, index }) {
|
2021-09-16 18:42:11 +08:00
|
|
|
// 当前视图操作状态置空
|
2021-09-17 10:51:22 +08:00
|
|
|
if (component) {
|
|
|
|
component['optStatus'] = {
|
|
|
|
dragging: false,
|
|
|
|
resizing: false
|
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
}
|
2021-07-23 13:45:01 +08:00
|
|
|
state.styleChangeTimes = 0
|
2021-03-25 19:16:32 +08:00
|
|
|
state.curComponent = component
|
|
|
|
state.curComponentIndex = index
|
|
|
|
},
|
|
|
|
|
2021-06-01 13:40:26 +08:00
|
|
|
setCurCanvasScale(state, curCanvasScale) {
|
|
|
|
state.curCanvasScale = curCanvasScale
|
|
|
|
},
|
2021-12-20 18:50:20 +08:00
|
|
|
setPreviewCanvasScale(state, scale) {
|
|
|
|
if (scale.scaleWidth) {
|
|
|
|
state.previewCanvasScale.scalePointWidth = scale.scaleWidth
|
2021-12-17 18:11:39 +08:00
|
|
|
}
|
2021-12-20 18:50:20 +08:00
|
|
|
if (scale.scaleHeight) {
|
|
|
|
state.previewCanvasScale.scalePointHeight = scale.scaleHeight
|
2021-12-17 18:11:39 +08:00
|
|
|
}
|
|
|
|
},
|
2021-06-01 13:40:26 +08:00
|
|
|
setShapeStyle({ curComponent, canvasStyleData, curCanvasScale }, { top, left, width, height, rotate }) {
|
2021-12-22 16:36:33 +08:00
|
|
|
if (curComponent) {
|
|
|
|
if (top || top === 0) curComponent.style.top = (top / curCanvasScale.scalePointHeight) + 0.0000001
|
|
|
|
if (left || left === 0) curComponent.style.left = (left / curCanvasScale.scalePointWidth) + 0.0000001
|
|
|
|
if (width || width === 0) curComponent.style.width = (width / curCanvasScale.scalePointWidth + 0.0000001)
|
|
|
|
if (height || height === 0) curComponent.style.height = (height / curCanvasScale.scalePointHeight) + 0.0000001
|
|
|
|
if (rotate || rotate === 0) curComponent.style.rotate = rotate
|
|
|
|
}
|
2021-03-25 19:16:32 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setShapeSingleStyle({ curComponent }, { key, value }) {
|
|
|
|
curComponent.style[key] = value
|
|
|
|
},
|
|
|
|
|
|
|
|
setComponentData(state, componentData = []) {
|
|
|
|
Vue.set(state, 'componentData', componentData)
|
|
|
|
},
|
|
|
|
|
2021-11-23 15:34:42 +08:00
|
|
|
setPcComponentData(state, pcComponentData = []) {
|
|
|
|
Vue.set(state, 'pcComponentData', pcComponentData)
|
|
|
|
},
|
|
|
|
setComponentDataCache(state, componentDataCache) {
|
|
|
|
Vue.set(state, 'componentDataCache', componentDataCache)
|
|
|
|
},
|
|
|
|
|
|
|
|
setMobileComponentData(state, mobileComponentData = []) {
|
|
|
|
Vue.set(state, 'mobileComponentData', mobileComponentData)
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
addComponent(state, { component, index }) {
|
|
|
|
if (index !== undefined) {
|
|
|
|
state.componentData.splice(index, 0, component)
|
|
|
|
} else {
|
|
|
|
state.componentData.push(component)
|
|
|
|
}
|
|
|
|
},
|
2021-06-08 12:39:04 +08:00
|
|
|
removeViewFilter(state, componentId) {
|
|
|
|
state.componentData = state.componentData.map(item => {
|
|
|
|
const newItem = item
|
|
|
|
newItem.filters = newItem.filters && newItem.filters.filter(filter => filter.componentId !== componentId) || []
|
|
|
|
return newItem
|
|
|
|
})
|
|
|
|
},
|
|
|
|
addViewFilter(state, data) {
|
|
|
|
const condition = formatCondition(data)
|
|
|
|
const vValid = valueValid(condition)
|
|
|
|
// 1.根据componentId过滤
|
|
|
|
const filterComponentId = condition.componentId
|
2021-03-25 19:16:32 +08:00
|
|
|
|
2021-06-08 12:39:04 +08:00
|
|
|
// 2.循环每个Component 得到 三种情况 a增加b删除c无操作
|
|
|
|
const viewIdMatch = (viewIds, viewId) => !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
2021-03-25 19:16:32 +08:00
|
|
|
|
2021-06-08 12:39:04 +08:00
|
|
|
for (let index = 0; index < state.componentData.length; index++) {
|
|
|
|
const element = state.componentData[index]
|
|
|
|
if (!element.type || element.type !== 'view') continue
|
|
|
|
const currentFilters = element.filters || []
|
|
|
|
const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId)
|
|
|
|
|
|
|
|
let j = currentFilters.length
|
2021-06-08 16:03:49 +08:00
|
|
|
// let filterExist = false
|
2021-06-08 12:39:04 +08:00
|
|
|
while (j--) {
|
|
|
|
const filter = currentFilters[j]
|
|
|
|
if (filter.componentId === filterComponentId) {
|
2021-06-08 16:03:49 +08:00
|
|
|
// filterExist = true
|
2021-06-08 12:39:04 +08:00
|
|
|
// 已存在该条件 且 条件值有效 直接替换原体检
|
2021-06-08 16:03:49 +08:00
|
|
|
// vidMatch && vValid && (currentFilters[j] = condition)
|
2021-06-08 12:39:04 +08:00
|
|
|
// 已存在该条件 且 条件值无效 直接删除原条件
|
2021-06-08 16:03:49 +08:00
|
|
|
// vidMatch && !vValid && (currentFilters.splice(j, 1))
|
|
|
|
currentFilters.splice(j, 1)
|
2021-06-08 12:39:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// 不存在该条件 且 条件有效 直接保存该条件
|
2021-06-08 16:03:49 +08:00
|
|
|
// !filterExist && vValid && currentFilters.push(condition)
|
|
|
|
vidMatch && vValid && currentFilters.push(condition)
|
2021-06-08 12:39:04 +08:00
|
|
|
element.filters = currentFilters
|
|
|
|
state.componentData[index] = element
|
|
|
|
}
|
|
|
|
},
|
2021-08-10 15:50:00 +08:00
|
|
|
|
|
|
|
// 添加联动 下钻 等过滤组件
|
|
|
|
addViewTrackFilter(state, data) {
|
|
|
|
const viewId = data.viewId
|
2021-10-28 17:05:16 +08:00
|
|
|
let trackInfo
|
|
|
|
if (data.option === 'linkage') {
|
|
|
|
trackInfo = state.nowPanelTrackInfo
|
|
|
|
} else {
|
|
|
|
trackInfo = state.nowPanelJumpInfoTargetPanel
|
|
|
|
}
|
2021-08-10 15:50:00 +08:00
|
|
|
for (let index = 0; index < state.componentData.length; index++) {
|
|
|
|
const element = state.componentData[index]
|
|
|
|
if (!element.type || element.type !== 'view') continue
|
|
|
|
const currentFilters = element.linkageFilters || [] // 当前联动filter
|
|
|
|
|
|
|
|
data.dimensionList.forEach(dimension => {
|
|
|
|
const sourceInfo = viewId + '#' + dimension.id
|
|
|
|
// 获取所有目标联动信息
|
|
|
|
const targetInfoList = trackInfo[sourceInfo] || []
|
|
|
|
targetInfoList.forEach(targetInfo => {
|
|
|
|
const targetInfoArray = targetInfo.split('#')
|
|
|
|
const targetViewId = targetInfoArray[0] // 目标视图
|
|
|
|
if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减
|
|
|
|
const targetFieldId = targetInfoArray[1] // 目标视图列ID
|
|
|
|
const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId])
|
2021-08-17 18:52:22 +08:00
|
|
|
condition.sourceViewId = viewId
|
2021-08-10 15:50:00 +08:00
|
|
|
let j = currentFilters.length
|
|
|
|
while (j--) {
|
|
|
|
const filter = currentFilters[j]
|
|
|
|
// 兼容性准备 viewIds 只会存放一个值
|
|
|
|
if (targetFieldId === filter.fieldId && filter.viewIds.includes(targetViewId)) {
|
|
|
|
currentFilters.splice(j, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 不存在该条件 且 条件有效 直接保存该条件
|
|
|
|
// !filterExist && vValid && currentFilters.push(condition)
|
|
|
|
currentFilters.push(condition)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
element.linkageFilters = currentFilters
|
|
|
|
state.componentData[index] = element
|
|
|
|
}
|
|
|
|
},
|
2021-04-19 10:47:07 +08:00
|
|
|
setComponentWithId(state, component) {
|
|
|
|
for (let index = 0; index < state.componentData.length; index++) {
|
|
|
|
const element = state.componentData[index]
|
|
|
|
if (element.id && element.id === component.id) {
|
|
|
|
state.componentData[index] = component
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
state.componentData.push(component)
|
|
|
|
},
|
|
|
|
deleteComponentWithId(state, id) {
|
|
|
|
for (let index = 0; index < state.componentData.length; index++) {
|
|
|
|
const element = state.componentData[index]
|
|
|
|
if (element.id && element.id === id) {
|
|
|
|
state.componentData.splice(index, 1)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-03-25 19:16:32 +08:00
|
|
|
deleteComponent(state, index) {
|
|
|
|
if (index === undefined) {
|
|
|
|
index = state.curComponentIndex
|
|
|
|
}
|
|
|
|
state.componentData.splice(index, 1)
|
2021-07-29 12:46:54 +08:00
|
|
|
},
|
2021-08-04 16:52:49 +08:00
|
|
|
setLinkageInfo(state, targetLinkageInfo) {
|
|
|
|
state.linkageSettingStatus = true
|
|
|
|
state.curLinkageView = state.curComponent
|
|
|
|
state.targetLinkageInfo = targetLinkageInfo
|
|
|
|
},
|
|
|
|
clearLinkageSettingInfo(state) {
|
|
|
|
state.linkageSettingStatus = false
|
|
|
|
state.curLinkageView = null
|
|
|
|
state.targetLinkageInfo = []
|
2021-08-10 15:50:00 +08:00
|
|
|
},
|
|
|
|
setNowPanelTrackInfo(state, trackInfo) {
|
|
|
|
state.nowPanelTrackInfo = trackInfo
|
2021-08-10 17:45:23 +08:00
|
|
|
},
|
2021-10-28 17:05:16 +08:00
|
|
|
setNowPanelJumpInfo(state, jumpInfo) {
|
|
|
|
state.nowPanelJumpInfo = jumpInfo.baseJumpInfoMap
|
|
|
|
},
|
|
|
|
setNowTargetPanelJumpInfo(state, jumpInfo) {
|
|
|
|
state.nowPanelJumpInfoTargetPanel = jumpInfo.baseJumpInfoPanelMap
|
|
|
|
},
|
2021-08-10 17:45:23 +08:00
|
|
|
clearPanelLinkageInfo(state) {
|
|
|
|
state.componentData.forEach(item => {
|
|
|
|
if (item.linkageFilters && item.linkageFilters.length > 0) {
|
|
|
|
item.linkageFilters.splice(0, item.linkageFilters.length)
|
|
|
|
}
|
|
|
|
})
|
2021-08-23 15:10:13 +08:00
|
|
|
// state.styleChangeTimes++
|
2021-09-17 17:48:58 +08:00
|
|
|
},
|
|
|
|
setDragComponentInfo(state, dragComponentInfo) {
|
2021-09-22 16:51:41 +08:00
|
|
|
dragComponentInfo['shadowStyle'] = {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
height: 0,
|
|
|
|
width: 0
|
|
|
|
}
|
2021-09-17 17:48:58 +08:00
|
|
|
state.dragComponentInfo = dragComponentInfo
|
|
|
|
},
|
|
|
|
clearDragComponentInfo(state) {
|
2021-10-11 23:27:48 +08:00
|
|
|
// 如果当前没有拖拽的元素没有放置到画布 清理一下矩阵的占位符
|
|
|
|
if (state.dragComponentInfo.moveStatus !== 'drop') {
|
|
|
|
bus.$emit('onRemoveLastItem')
|
|
|
|
}
|
2021-09-17 17:48:58 +08:00
|
|
|
state.dragComponentInfo = null
|
2021-11-23 15:34:42 +08:00
|
|
|
},
|
|
|
|
setMobileLayoutStatus(state, status) {
|
|
|
|
state.mobileLayoutStatus = status
|
2021-12-07 17:32:02 +08:00
|
|
|
},
|
2021-12-14 11:43:41 +08:00
|
|
|
setPublicLinkStatus(state, status) {
|
|
|
|
state.publicLinkStatus = status
|
|
|
|
},
|
2021-12-07 17:32:02 +08:00
|
|
|
// 启用移动端布局
|
|
|
|
openMobileLayout(state) {
|
2021-12-24 17:54:28 +08:00
|
|
|
state.componentDataCache = null
|
2021-12-07 17:32:02 +08:00
|
|
|
state.componentDataCache = JSON.stringify(state.componentData)
|
|
|
|
state.pcComponentData = state.componentData
|
|
|
|
const mainComponentData = []
|
|
|
|
// 移动端布局转换
|
|
|
|
state.componentData.forEach(item => {
|
2021-12-23 18:15:49 +08:00
|
|
|
item.mobileStyle = (item.mobileStyle || BASE_MOBILE_STYLE)
|
2021-12-07 17:32:02 +08:00
|
|
|
if (item.mobileSelected) {
|
2021-12-22 12:19:40 +08:00
|
|
|
item.style.width = item.mobileStyle.style.width
|
|
|
|
item.style.height = item.mobileStyle.style.height
|
|
|
|
item.style.top = item.mobileStyle.style.top
|
|
|
|
item.style.left = item.mobileStyle.style.left
|
|
|
|
item.style.borderRadius = 3
|
2021-12-07 17:32:02 +08:00
|
|
|
item.x = item.mobileStyle.x
|
|
|
|
item.y = item.mobileStyle.y
|
|
|
|
item.sizex = item.mobileStyle.sizex
|
|
|
|
item.sizey = item.mobileStyle.sizey
|
|
|
|
item.auxiliaryMatrix = item.mobileStyle.auxiliaryMatrix
|
|
|
|
mainComponentData.push(item)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
state.componentData = mainComponentData
|
|
|
|
state.mobileLayoutStatus = !state.mobileLayoutStatus
|
2022-01-20 11:33:41 +08:00
|
|
|
},
|
|
|
|
setScrollAutoMove(state, offset) {
|
|
|
|
state.scrollAutoMove = offset
|
2021-03-25 19:16:32 +08:00
|
|
|
}
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
modules: {
|
|
|
|
app,
|
|
|
|
settings,
|
|
|
|
user,
|
|
|
|
permission,
|
2021-03-03 18:35:51 +08:00
|
|
|
dataset,
|
2021-03-04 14:58:52 +08:00
|
|
|
chart,
|
2021-03-08 14:31:09 +08:00
|
|
|
request,
|
2021-03-29 21:24:33 +08:00
|
|
|
panel,
|
2021-05-12 16:19:41 +08:00
|
|
|
application,
|
2021-07-09 18:37:07 +08:00
|
|
|
lic,
|
2021-07-27 18:03:56 +08:00
|
|
|
msg,
|
|
|
|
map
|
2021-03-03 15:06:52 +08:00
|
|
|
},
|
|
|
|
getters
|
2021-03-25 19:16:32 +08:00
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
|
2021-03-25 19:16:32 +08:00
|
|
|
export default new Vuex.Store(data)
|