refactor(仪表板): 仪表板的复用支持复用所有组件

This commit is contained in:
wangjiahao 2022-07-25 11:57:49 +08:00
parent ef41583187
commit 03e81d2205
7 changed files with 37 additions and 11 deletions

View File

@ -5,7 +5,7 @@
@click="handleClick" @click="handleClick"
@mousedown="elementMouseDown" @mousedown="elementMouseDown"
> >
<edit-bar v-if="componentActiveFlag" :element="config" @showViewDetails="showViewDetails" /> <edit-bar v-if="componentActiveFlag" :element="config" :show-position="showPosition" @showViewDetails="showViewDetails" />
<div :id="componentCanvasId" :style="commonStyle" class="main_view"> <div :id="componentCanvasId" :style="commonStyle" class="main_view">
<close-bar v-if="previewVisible" @closePreview="closePreview" /> <close-bar v-if="previewVisible" @closePreview="closePreview" />
<de-out-widget <de-out-widget
@ -150,7 +150,7 @@ export default {
return style return style
}, },
componentActiveFlag() { componentActiveFlag() {
return (this.curComponent && this.config === this.curComponent) && !this.previewVisible && !this.showPosition.includes('multiplexing') && !this.showPosition.includes('email-task') return (this.curComponent && this.config === this.curComponent && !this.previewVisible && this.showPosition.includes('multiplexing') && !this.showPosition.includes('email-task')) || this.showPosition.includes('multiplexing')
}, },
curGap() { curGap() {
return (this.canvasStyleData.panel.gap === 'yes' && this.config.auxiliaryMatrix) ? this.componentGap : 0 return (this.canvasStyleData.panel.gap === 'yes' && this.config.auxiliaryMatrix) ? this.componentGap : 0

View File

@ -5,6 +5,9 @@
<el-checkbox v-model="linkageInfo.linkageActive" size="medium" /> <el-checkbox v-model="linkageInfo.linkageActive" size="medium" />
<linkage-field v-if="linkageInfo.linkageActive" :element="element" /> <linkage-field v-if="linkageInfo.linkageActive" :element="element" />
</div> </div>
<div v-if="positionCheck('multiplexing')" style="margin-right: 1px;width: 18px;z-index: 5">
<el-checkbox v-model="multiplexingCheckModel" size="medium" @change="multiplexingCheck" />
</div>
<div v-if="batchOptAreaShow" style="margin-right: -1px;width: 20px;z-index: 5"> <div v-if="batchOptAreaShow" style="margin-right: -1px;width: 20px;z-index: 5">
<el-checkbox size="medium" @change="batchOptChange" /> <el-checkbox size="medium" @change="batchOptChange" />
</div> </div>
@ -73,10 +76,16 @@ export default {
previewVisible: { previewVisible: {
type: Boolean, type: Boolean,
default: false default: false
},
showPosition: {
type: String,
required: false,
default: 'NotProvided'
} }
}, },
data() { data() {
return { return {
multiplexingCheckModel: false,
barWidth: 24, barWidth: 24,
componentType: null, componentType: null,
linkageActiveStatus: false, linkageActiveStatus: false,
@ -106,7 +115,6 @@ export default {
return 'bar-main-preview' return 'bar-main-preview'
} }
}, },
showJumpFlag() { showJumpFlag() {
return this.curComponent && this.curComponent.hyperlinks && this.curComponent.hyperlinks.enable return this.curComponent && this.curComponent.hyperlinks && this.curComponent.hyperlinks.enable
}, },
@ -120,7 +128,7 @@ export default {
}, },
// //
normalAreaShow() { normalAreaShow() {
return !this.linkageSettingStatus && !this.batchOptStatus return !this.linkageSettingStatus && !this.batchOptStatus && !this.positionCheck('multiplexing')
}, },
existLinkage() { existLinkage() {
let linkageFiltersCount = 0 let linkageFiltersCount = 0
@ -166,6 +174,18 @@ export default {
beforeDestroy() { beforeDestroy() {
}, },
methods: { methods: {
positionCheck(position) {
return this.showPosition.includes(position)
},
multiplexingCheck(val) {
if (val) {
// push
this.$store.commit('addCurMultiplexingComponent', { 'component': this.element, 'componentId': this.element.id })
} else {
// remove
this.$store.commit('removeCurMultiplexingComponentWithId', this.element.id )
}
},
closePreview() { closePreview() {
this.$emit('closePreview') this.$emit('closePreview')
}, },
@ -217,8 +237,7 @@ export default {
edit() { edit() {
if (this.curComponent.type === 'custom') { if (this.curComponent.type === 'custom') {
bus.$emit('component-dialog-edit', 'update') bus.$emit('component-dialog-edit', 'update')
} } else if (this.curComponent.type === 'custom-button') {
else if (this.curComponent.type === 'custom-button') {
bus.$emit('button-dialog-edit') bus.$emit('button-dialog-edit')
} else if (this.curComponent.type === 'v-text' || this.curComponent.type === 'de-rich-text' || this.curComponent.type === 'rect-shape') { } else if (this.curComponent.type === 'v-text' || this.curComponent.type === 'de-rich-text' || this.curComponent.type === 'rect-shape') {
bus.$emit('component-dialog-style') bus.$emit('component-dialog-style')

View File

@ -236,7 +236,7 @@ export default {
} }
}, },
editBarViewShowFlag() { editBarViewShowFlag() {
return (this.active && this.inTab && !this.mobileLayoutStatus) || this.showPosition.includes('multiplexing') || this.showPosition.includes('email-task') return (this.active && this.inTab && !this.mobileLayoutStatus) && !this.showPosition.includes('multiplexing') || this.showPosition.includes('email-task')
}, },
charViewShowFlag() { charViewShowFlag() {
return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.chart.type !== 'label' && this.renderComponent() === 'echarts' return this.httpRequest.status && this.chart.type && !this.chart.type.includes('table') && !this.chart.type.includes('text') && this.chart.type !== 'label' && this.renderComponent() === 'echarts'

View File

@ -35,10 +35,10 @@ export default {
const canvasStyleData = state.canvasStyleData const canvasStyleData = state.canvasStyleData
const curCanvasScale = state.curCanvasScale const curCanvasScale = state.curCanvasScale
const componentGap = state.componentGap const componentGap = state.componentGap
Object.keys(state.curMultiplexingComponents).forEach(function(viewId, index) { Object.keys(state.curMultiplexingComponents).forEach(function(componentId, index) {
const component = const component =
{ {
...deepCopy(state.curMultiplexingComponents[viewId]), ...deepCopy(state.curMultiplexingComponents[componentId]),
...deepCopy(deepCopy(state.viewBase)), ...deepCopy(deepCopy(state.viewBase)),
'auxiliaryMatrix': canvasStyleData.auxiliaryMatrix 'auxiliaryMatrix': canvasStyleData.auxiliaryMatrix
} }

View File

@ -80,6 +80,7 @@
:filters="filterMap[item.content.propValue && item.content.propValue.viewId] || []" :filters="filterMap[item.content.propValue && item.content.propValue.viewId] || []"
:out-style="outStyle" :out-style="outStyle"
:canvas-style-data="canvasStyleData" :canvas-style-data="canvasStyleData"
:show-position="showPosition"
/> />
</div> </div>
@ -193,6 +194,11 @@ export default {
h: { h: {
type: Number, type: Number,
default: 200 default: 200
},
showPosition: {
type: String,
required: false,
default: 'NotProvided'
} }
}, },
data() { data() {

View File

@ -329,7 +329,7 @@ export default {
if (result !== 'success' && result !== 'fail') { if (result !== 'success' && result !== 'fail') {
window.location.href = result window.location.href = result
} else { } else {
this.$router.push(`/login?redirect=${this.$route.fullPath}`) this.$router.push('/login')
} }
}, },
loadUiInfo() { loadUiInfo() {

View File

@ -92,7 +92,8 @@ router.beforeEach(async(to, from, next) => {
next() next()
} else { } else {
// other pages that do not have permission to access are redirected to the login page. // other pages that do not have permission to access are redirected to the login page.
next(`/login?redirect=${to.path}`) // next(`/login?redirect=${to.path}`)
next('/login')
NProgress.done() NProgress.done()
} }
} }