Merge branch 'dev' of github.com:dataease/dataease into dev

This commit is contained in:
taojinlong 2022-01-25 17:38:31 +08:00
commit 48808467ce
10 changed files with 88 additions and 150 deletions

View File

@ -1,4 +1,8 @@
import request from '@/utils/request'
import { panelInit } from '@/components/canvas/utils/utils'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
import store from '@/store'
export function deleteSubject(id) {
return request({
@ -128,3 +132,25 @@ export function delGroup(groupId) {
method: 'post'
})
}
export function initPanelData(panelId, callback) {
// 加载视图数据
findOne(panelId).then(response => {
// 初始化视图data和style 数据
panelInit(JSON.parse(response.data.panelData), JSON.parse(response.data.panelStyle))
// 设置当前仪表板全局信息
store.dispatch('panel/setPanelInfo', {
id: response.data.id,
name: response.data.name
})
// 刷新联动信息
getPanelAllLinkageInfo(panelId).then(rsp => {
store.commit('setNowPanelTrackInfo', rsp.data)
})
// 刷新跳转信息
queryPanelJumpInfo(panelId).then(rsp => {
store.commit('setNowPanelJumpInfo', rsp.data)
})
callback(response)
})
}

View File

@ -6,10 +6,8 @@
<script>
import Preview from './Preview'
import { uuid } from 'vue-uuid'
import { findOne } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { queryPanelJumpInfo, queryTargetPanelJumpInfo } from '@/api/panel/linkJump'
import { panelInit } from '@/components/canvas/utils/utils'
import { initPanelData } from '@/api/panel/panel'
import { queryTargetPanelJumpInfo } from '@/api/panel/linkJump'
export default {
components: { Preview },
@ -37,31 +35,14 @@ export default {
this.mainHeight = mainHeight
},
restore() {
this.dataLoading = true
this.panelId = this.$route.params.reportId
if (this.$route.params.backScreenShot !== undefined) {
this.backScreenShot = this.$route.params.backScreenShot
const _this = this
_this.dataLoading = true
_this.panelId = this.$route.params.reportId
if (_this.$route.params.backScreenShot !== undefined) {
_this.backScreenShot = _this.$route.params.backScreenShot
}
//
findOne(this.panelId).then(response => {
const componentDatas = JSON.parse(response.data.panelData)
panelInit(componentDatas)
this.dataLoading = false
this.$store.commit('setComponentData', this.resetID(componentDatas))
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
const data = {
id: response.data.id,
name: response.data.name
}
//
getPanelAllLinkageInfo(this.panelId).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(this.panelId).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(this.panelId, function() {
//
const tempParam = localStorage.getItem('jumpInfoParam')
if (tempParam) {
@ -71,17 +52,16 @@ export default {
sourcePanelId: jumpParam.sourcePanelId,
sourceViewId: jumpParam.sourceViewId,
sourceFieldId: jumpParam.sourceFieldId,
targetPanelId: this.panelId
targetPanelId: _this.panelId
}
this.dataLoading = true
_this.dataLoading = true
//
queryTargetPanelJumpInfo(jumpRequestParam).then(rsp => {
this.dataLoading = false
this.$store.commit('setNowTargetPanelJumpInfo', rsp.data)
this.$store.commit('addViewTrackFilter', jumpParam)
_this.dataLoading = false
_this.$store.commit('setNowTargetPanelJumpInfo', rsp.data)
_this.$store.commit('addViewTrackFilter', jumpParam)
})
}
this.$store.dispatch('panel/setPanelInfo', data)
})
},
resetID(data) {

View File

@ -6,6 +6,8 @@ import {
import {
ApplicationContext
} from '@/utils/ApplicationContext'
import { uuid } from 'vue-uuid'
import store from '@/store'
export function deepCopy(target) {
if (typeof target === 'object') {
@ -63,8 +65,8 @@ export function mobile2MainCanvas(mainSource, mobileSource) {
mainSource.mobileStyle.sizey = mobileSource.sizey
}
export function panelInit(componentDatas) {
componentDatas.forEach(item => {
export function panelInit(componentData, componentStyle) {
componentData.forEach(item => {
if (item.component && item.component === 'de-date') {
if (item.options.attrs &&
(!item.options.attrs.default || (item.serviceName === 'timeYearWidget' && item.options.attrs.default.dynamicInfill !== 'year') || (item.serviceName === 'timeMonthWidget' && item.options.attrs.default.dynamicInfill !== 'month'))) {
@ -92,4 +94,21 @@ export function panelInit(componentDatas) {
item.hyperlinks = (item.hyperlinks || HYPERLINKS)
}
})
// style初始化
componentStyle.refreshTime = (componentStyle.refreshTime || 5)
componentStyle.refreshViewLoading = (componentStyle.refreshViewLoading || false)
componentStyle.refreshUnit = (componentStyle.refreshUnit || 'minute')
// 将data 和 style 数据设置到全局store中
store.commit('setComponentData', resetID(componentData))
store.commit('setCanvasStyle', componentStyle)
}
export function resetID(data) {
if (data) {
data.forEach(item => {
item.type !== 'custom' && (item.id = uuid.v1())
})
}
return data
}

View File

@ -116,7 +116,7 @@ export default {
borderRadius: '0px',
currentPage: {
page: 1,
pageSize: 10,
pageSize: 20,
show: 0
}
}
@ -165,7 +165,7 @@ export default {
if (this.chart.data) {
this.fields = JSON.parse(JSON.stringify(this.chart.data.fields))
const attr = JSON.parse(this.chart.customAttr)
this.currentPage.pageSize = parseInt(attr.size.tablePageSize ? attr.size.tablePageSize : 10)
this.currentPage.pageSize = parseInt(attr.size.tablePageSize ? attr.size.tablePageSize : 20)
datas = JSON.parse(JSON.stringify(this.chart.data.tableRow))
if (this.chart.type === 'table-info') {
//
@ -341,7 +341,7 @@ export default {
resetPage() {
this.currentPage = {
page: 1,
pageSize: 10,
pageSize: 20,
show: 0
}
}

View File

@ -45,7 +45,6 @@ export default {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
this.$store.commit('setComponentData', this.resetID(JSON.parse(res.data.panelData)))
// this.$store.commit('setComponentData', JSON.parse(res.data.panelData))
this.$store.commit('setCanvasStyle', JSON.parse(res.data.panelStyle))
//
queryPanelJumpInfo(this.resourceId).then(rsp => {

View File

@ -50,10 +50,8 @@
<script>
import { loadTree, loadShareOutTree, removeShares } from '@/api/panel/share'
import { uuid } from 'vue-uuid'
import { get } from '@/api/panel/panel'
import { get, initPanelData } from '@/api/panel/panel'
import bus from '@/utils/bus'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
export default {
name: 'ShareTree',
props: {
@ -105,36 +103,13 @@ export default {
return loadShareOutTree()
},
handleNodeClick(data) {
get('panel/group/findOne/' + data.id).then(response => {
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
this.$store.dispatch('panel/setPanelInfo', data)
//
getPanelAllLinkageInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(data.id, function() {
bus.$emit('set-panel-show-type', 1)
})
this.$refs['botTree'].setCurrentKey(null)
},
viewMyShare(data) {
get('panel/group/findOne/' + data.id).then(response => {
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
this.$store.dispatch('panel/setPanelInfo', data)
//
getPanelAllLinkageInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(data.id, function() {
bus.$emit('set-panel-show-type', 2)
})
this.$refs['topTree'].setCurrentKey(null)

View File

@ -221,8 +221,7 @@ import componentList, { BASE_MOBILE_STYLE, HYPERLINKS } from '@/components/canva
import { mapState } from 'vuex'
import { uuid } from 'vue-uuid'
import Toolbar from '@/components/canvas/components/Toolbar'
import { findOne } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { initPanelData } from '@/api/panel/panel'
import Preview from '@/components/canvas/components/Editor/Preview'
import AttrListExtend from '@/components/canvas/components/AttrListExtend'
import elementResizeDetectorMaker from 'element-resize-detector'
@ -239,7 +238,6 @@ import toast from '@/components/canvas/utils/toast'
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
import generateID from '@/components/canvas/utils/generateID'
import TextAttr from '@/components/canvas/components/TextAttr'
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
import ComponentWait from '@/views/panel/edit/ComponentWait'
import { deleteEnshrine, saveEnshrine, starStatus } from '@/api/panel/enshrine'
@ -414,9 +412,6 @@ export default {
removeClass(document.body, 'showRightPanel')
}
},
panelInfo(newVal, oldVal) {
this.init(newVal.id)
},
'$store.state.styleChangeTimes'() {
if (this.$store.state.styleChangeTimes > 0) {
this.destroyTimeMachine()
@ -467,42 +462,19 @@ export default {
},
methods: {
init(panelId) {
this.initHasStar()
const _this = this
_this.initHasStar()
// 使
const componentDataTemp = this.$store.state.panel.componentDataTemp
const canvasStyleDataTemp = this.$store.state.panel.canvasStyleDataTemp
if (componentDataTemp && canvasStyleDataTemp) {
const componentDatas = JSON.parse(componentDataTemp)
panelInit(componentDatas)
this.$store.commit('setComponentData', this.resetID(componentDatas))
const temp = JSON.parse(canvasStyleDataTemp)
temp.refreshTime = (temp.refreshTime || 5)
temp.refreshViewLoading = (temp.refreshViewLoading || false)
temp.refreshUnit = (temp.refreshUnit || 'minute')
this.$store.commit('setCanvasStyle', temp)
panelInit(JSON.parse(componentDataTemp), JSON.parse(canvasStyleDataTemp))
//
this.$store.dispatch('panel/setComponentDataTemp', null)
this.$store.dispatch('panel/setCanvasStyleDataTemp', null)
_this.$store.dispatch('panel/setComponentDataTemp', null)
_this.$store.dispatch('panel/setCanvasStyleDataTemp', null)
} else if (panelId) {
findOne(panelId).then(response => {
const componentDatas = JSON.parse(response.data.panelData)
panelInit(componentDatas)
this.$store.commit('setComponentData', this.resetID(componentDatas))
const panelStyle = JSON.parse(response.data.panelStyle)
panelStyle.refreshTime = (panelStyle.refreshTime || 5)
panelStyle.refreshViewLoading = (panelStyle.refreshViewLoading || false)
panelStyle.refreshUnit = (panelStyle.refreshUnit || 'minute')
this.$store.commit('setCanvasStyle', panelStyle)
this.$store.commit('recordSnapshot', 'init')//
//
getPanelAllLinkageInfo(panelId).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(panelId).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(panelId, function() {
_this.$store.commit('recordSnapshot', 'init')//
})
}
},

View File

@ -27,10 +27,8 @@
<script>
import { deleteEnshrine, enshrineList } from '@/api/panel/enshrine'
import { uuid } from 'vue-uuid'
import { get } from '@/api/panel/panel'
import { initPanelData } from '@/api/panel/panel'
import bus from '@/utils/bus'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
export default {
name: 'Enshrine',
data() {
@ -49,22 +47,7 @@ export default {
},
methods: {
showPanel(row) {
get('panel/group/findOne/' + row.panelGroupId).then(response => {
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
const data = {
id: row.panelGroupId,
name: row.name
}
this.$store.dispatch('panel/setPanelInfo', data)
//
getPanelAllLinkageInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(row.panelGroupId, function() {
bus.$emit('set-panel-show-type', 0)
})
},

View File

@ -226,16 +226,13 @@ import LinkGenerate from '@/views/link/generate'
import { uuid } from 'vue-uuid'
import bus from '@/utils/bus'
import EditPanel from './EditPanel'
import { addGroup, delGroup, groupTree, defaultTree, findOne, panelSave } from '@/api/panel/panel'
import { getPanelAllLinkageInfo } from '@/api/panel/linkage'
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
import { addGroup, delGroup, groupTree, defaultTree, panelSave, initPanelData } from '@/api/panel/panel'
import { mapState } from 'vuex'
import {
DEFAULT_COMMON_CANVAS_STYLE_STRING
} from '@/views/panel/panel'
import TreeSelector from '@/components/TreeSelector'
import { queryAuthModel } from '@/api/authModel/authModel'
import { panelInit } from '@/components/canvas/utils/utils'
export default {
name: 'PanelList',
@ -649,29 +646,7 @@ export default {
if (data.nodeType === 'panel') {
// pc
this.$store.commit('setComponentDataCache', null)
//
findOne(data.id).then(response => {
const componentDatas = JSON.parse(response.data.panelData)
panelInit(componentDatas)
this.$store.commit('setComponentData', this.resetID(componentDatas))
const temp = JSON.parse(response.data.panelStyle)
temp.refreshTime = (temp.refreshTime || 5)
temp.refreshViewLoading = (temp.refreshViewLoading || false)
temp.refreshUnit = (temp.refreshUnit || 'minute')
this.$store.commit('setCanvasStyle', temp)
this.$store.dispatch('panel/setPanelInfo', data)
//
getPanelAllLinkageInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelTrackInfo', rsp.data)
})
//
queryPanelJumpInfo(data.id).then(rsp => {
this.$store.commit('setNowPanelJumpInfo', rsp.data)
})
initPanelData(data.id, function(response) {
bus.$emit('set-panel-show-type', 0)
})
}

View File

@ -68,6 +68,12 @@
</el-tooltip>
</span>
<span style="float: right;margin-right: 10px">
<el-tooltip :content="$t('commons.refresh')">
<el-button class="el-icon-refresh" size="mini" circle @click="refreshPanel" />
</el-tooltip>
</span>
</el-col>
</div>
</el-row>
@ -130,6 +136,7 @@ import { starStatus, saveEnshrine, deleteEnshrine } from '@/api/panel/enshrine'
import bus from '@/utils/bus'
import { queryAll } from '@/api/panel/pdfTemplate'
import ShareHead from '@/views/panel/GrantAuth/ShareHead'
import { initPanelData } from '@/api/panel/panel'
export default {
name: 'PanelViewShow',
@ -334,8 +341,10 @@ export default {
},
editPanel() {
this.$emit('editPanel')
},
refreshPanel() {
initPanelData(this.panelInfo.id)
}
}
}
</script>