refactor: 画板优化

This commit is contained in:
wangjiahao 2021-10-09 22:36:47 +08:00
parent 6ceddf85e4
commit e9bd3bfdfc
6 changed files with 32 additions and 17 deletions

View File

@ -15,10 +15,10 @@
<i v-if="activeModel==='edit'&&curComponent&&editFilter.includes(curComponent.type)" class="icon iconfont icon-edit" @click.stop="edit" /> <i v-if="activeModel==='edit'&&curComponent&&editFilter.includes(curComponent.type)" class="icon iconfont icon-edit" @click.stop="edit" />
</span> </span>
<span :title="$t('panel.matrix')"> <span :title="$t('panel.matrix')">
<i v-if="activeModel==='edit'&&auxiliaryMatrix" class="icon iconfont icon-shujujuzhen" @click.stop="auxiliaryMatrixChange" /> <i v-if="activeModel==='edit'&&curComponent.auxiliaryMatrix" class="icon iconfont icon-shujujuzhen" @click.stop="auxiliaryMatrixChange" />
</span> </span>
<span :title="$t('panel.suspension')"> <span :title="$t('panel.suspension')">
<i v-if="activeModel==='edit'&&!auxiliaryMatrix" class="icon iconfont icon-xuanfuanniu" @click.stop="auxiliaryMatrixChange" /> <i v-if="activeModel==='edit'&&!curComponent.auxiliaryMatrix" class="icon iconfont icon-xuanfuanniu" @click.stop="auxiliaryMatrixChange" />
</span> </span>
<span :title="$t('panel.details')"> <span :title="$t('panel.details')">
<i v-if="curComponent.type==='view'" class="icon iconfont icon-fangda" @click.stop="showViewDetails" /> <i v-if="curComponent.type==='view'" class="icon iconfont icon-fangda" @click.stop="showViewDetails" />
@ -61,13 +61,16 @@ export default {
return { return {
componentType: null, componentType: null,
linkageActiveStatus: false, linkageActiveStatus: false,
auxiliaryMatrix: false,
editFilter: [ editFilter: [
'view', 'view',
'custom' 'custom'
] ],
timer: null
} }
}, },
mounted() {
this.createTimer()
},
computed: { computed: {
existLinkage() { existLinkage() {
let linkageFiltersCount = 0 let linkageFiltersCount = 0
@ -85,9 +88,6 @@ export default {
linkageInfo() { linkageInfo() {
return this.targetLinkageInfo[this.element.propValue.viewId] return this.targetLinkageInfo[this.element.propValue.viewId]
}, },
mounted() {
this.auxiliaryMatrix = this.$store.state.curComponent.auxiliaryMatrix
},
...mapState([ ...mapState([
'menuTop', 'menuTop',
'menuLeft', 'menuLeft',
@ -101,7 +101,23 @@ export default {
'curCanvasScale' 'curCanvasScale'
]) ])
}, },
beforeDestroy() {
this.destroyTimer()
},
methods: { methods: {
createTimer() {
if (!this.timer) {
this.timer = setInterval(() => {
console.log('t=' + this.curComponent.auxiliaryMatrix)
}, 5000)
}
},
destroyTimer() {
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
},
showViewDetails() { showViewDetails() {
this.$emit('showViewDetails') this.$emit('showViewDetails')
}, },
@ -112,14 +128,12 @@ export default {
this.curComponent.style.width = this.curComponent.sizex * this.curCanvasScale.matrixStyleOriginWidth this.curComponent.style.width = this.curComponent.sizex * this.curCanvasScale.matrixStyleOriginWidth
this.curComponent.style.height = this.curComponent.sizey * this.curCanvasScale.matrixStyleOriginHeight this.curComponent.style.height = this.curComponent.sizey * this.curCanvasScale.matrixStyleOriginHeight
this.curComponent.auxiliaryMatrix = false this.curComponent.auxiliaryMatrix = false
this.auxiliaryMatrix = false
} else { } else {
this.curComponent.x = Math.round(this.curComponent.style.left / this.curCanvasScale.matrixStyleOriginWidth) + 1 this.curComponent.x = Math.round(this.curComponent.style.left / this.curCanvasScale.matrixStyleOriginWidth) + 1
this.curComponent.y = Math.round(this.curComponent.style.top / this.curCanvasScale.matrixStyleOriginHeight) + 1 this.curComponent.y = Math.round(this.curComponent.style.top / this.curCanvasScale.matrixStyleOriginHeight) + 1
this.curComponent.sizex = Math.round(this.curComponent.style.width / this.curCanvasScale.matrixStyleOriginWidth) this.curComponent.sizex = Math.round(this.curComponent.style.width / this.curCanvasScale.matrixStyleOriginWidth)
this.curComponent.sizey = Math.round(this.curComponent.style.height / this.curCanvasScale.matrixStyleOriginHeight) this.curComponent.sizey = Math.round(this.curComponent.style.height / this.curCanvasScale.matrixStyleOriginHeight)
this.curComponent.auxiliaryMatrix = true this.curComponent.auxiliaryMatrix = true
this.auxiliaryMatrix = true
} }
this.$store.state.styleChangeTimes++ this.$store.state.styleChangeTimes++
bus.$emit('auxiliaryMatrixChange') bus.$emit('auxiliaryMatrixChange')

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="grid"> <div class="grid">
<!-- positionBox:{{ positionBox.length }}--> <!-- positionBox:{{ positionBox.length }}-->
<!-- <div v-for="(yItem, index) in positionBox" v-if="index<positionBox.length-5" :key="index+'y'" style="float: left; width: 105%">--> <!-- <div v-for="(yItem, index) in positionBox" v-if="index<positionBox.length-5" :key="index+'y'" style="float: left; width: 105%">-->
<div v-for="(yItem, index) in positionBox" :key="index+'y'" style="float: left; width: 105%"> <div v-for="(yItem, index) in positionBox" :key="index+'y'" style="float: left; width: 105%">
<div v-for="(xItem, index) in yItem" :key="index+'x'" :style="classInfo" style="float: left; border: 0.2px solid #b3d4fc "> <div v-for="(xItem, index) in yItem" :key="index+'x'" :style="classInfo" style="float: left; border: 0.2px solid #b3d4fc ;color: #00feff">
{{ xItem.el?1:0 }} {{ xItem.el?1:0 }}
</div> </div>
</div> </div>

View File

@ -13,9 +13,9 @@
@scroll="canvasScroll" @scroll="canvasScroll"
> >
<!-- 网格线 --> <!-- 网格线 -->
<!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />--> <!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />-->
<!-- positionBox:{{positionBoxInfo}}--> <!-- positionBox:{{positionBoxInfo}}-->
<!-- <PGrid :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />--> <!-- <PGrid :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />-->
<!-- 仪表板联动清除按钮--> <!-- 仪表板联动清除按钮-->
<canvas-opt-bar /> <canvas-opt-bar />
@ -1043,7 +1043,7 @@ export default {
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog) eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
setInterval(() => { setInterval(() => {
_this.positionBoxInfoArray = positionBox _this.positionBoxInfoArray = positionBox
}, 0) }, 500)
}, },
created() { created() {
// this.$store.dispatch('conditions/clear') // this.$store.dispatch('conditions/clear')

View File

@ -94,13 +94,11 @@ const data = {
dragging: false, dragging: false,
resizing: false resizing: false
} }
if (!component.auxiliaryMatrix) {
component['auxiliaryMatrix'] = false
}
} }
state.styleChangeTimes = 0 state.styleChangeTimes = 0
state.curComponent = component state.curComponent = component
state.curComponentIndex = index state.curComponentIndex = index
console.log('setCurComponent:' + JSON.stringify(component))
}, },
setCurCanvasScale(state, curCanvasScale) { setCurCanvasScale(state, curCanvasScale) {

View File

@ -386,6 +386,7 @@ export default {
componentDatas.forEach(item => { componentDatas.forEach(item => {
item.filters = (item.filters || []) item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || []) item.linkageFilters = (item.linkageFilters || [])
item.auxiliaryMatrix = (item.auxiliaryMatrix || false)
}) })
this.$store.commit('setComponentData', this.resetID(componentDatas)) this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', this.resetID(JSON.parse(componentDataTemp))) // this.$store.commit('setComponentData', this.resetID(JSON.parse(componentDataTemp)))
@ -399,6 +400,7 @@ export default {
componentDatas.forEach(item => { componentDatas.forEach(item => {
item.filters = (item.filters || []) item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || []) item.linkageFilters = (item.linkageFilters || [])
item.auxiliaryMatrix = (item.auxiliaryMatrix || false)
}) })
this.$store.commit('setComponentData', this.resetID(componentDatas)) this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData))) // this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))

View File

@ -621,6 +621,7 @@ export default {
componentDatas.forEach(item => { componentDatas.forEach(item => {
item.filters = (item.filters || []) item.filters = (item.filters || [])
item.linkageFilters = (item.linkageFilters || []) item.linkageFilters = (item.linkageFilters || [])
item.auxiliaryMatrix = (item.auxiliaryMatrix || false)
}) })
this.$store.commit('setComponentData', this.resetID(componentDatas)) this.$store.commit('setComponentData', this.resetID(componentDatas))
// this.$store.commit('setComponentData', sourceInfo.type === 'custom' ? sourceInfo : this.resetID(sourceInfo)) // this.$store.commit('setComponentData', sourceInfo.type === 'custom' ? sourceInfo : this.resetID(sourceInfo))