forked from github/dataease
refactor(仪表板): Tab组件复制支持同时复制内部组件
This commit is contained in:
parent
e6293fe1dc
commit
b175eeff75
@ -28,7 +28,7 @@ export function getChartTree(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function chartCopy(id, panelId) {
|
export async function chartCopy(id, panelId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/chart/view/chartCopy/' + id + '/' + panelId,
|
url: '/chart/view/chartCopy/' + id + '/' + panelId,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -36,7 +36,7 @@ export function chartCopy(id, panelId) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function chartBatchCopy(params, panelId) {
|
export async function chartBatchCopy(params, panelId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/chart/view/chartBatchCopy/' + panelId,
|
url: '/chart/view/chartBatchCopy/' + panelId,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
@ -91,6 +91,7 @@ export default {
|
|||||||
component['canvasId'] = 'canvas-main'
|
component['canvasId'] = 'canvas-main'
|
||||||
component['canvasPid'] = '0'
|
component['canvasPid'] = '0'
|
||||||
state.copyData = {
|
state.copyData = {
|
||||||
|
dataFrom: 'multiplexing',
|
||||||
data: component,
|
data: component,
|
||||||
index: index
|
index: index
|
||||||
}
|
}
|
||||||
@ -107,10 +108,17 @@ export default {
|
|||||||
state.isCut = false
|
state.isCut = false
|
||||||
},
|
},
|
||||||
|
|
||||||
paste(state, needAdaptor) {
|
async paste(state, needAdaptor) {
|
||||||
if (!state.copyData) {
|
if (!state.copyData) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let targetComponentData
|
||||||
|
|
||||||
|
if (state.copyData.dataFrom === 'multiplexing') {
|
||||||
|
targetComponentData = state.previewComponentData
|
||||||
|
} else {
|
||||||
|
targetComponentData = state.componentData
|
||||||
|
}
|
||||||
const data = state.copyData.data
|
const data = state.copyData.data
|
||||||
// 仪表板复制的组件默认不在移动端部署中mobileSelected = false
|
// 仪表板复制的组件默认不在移动端部署中mobileSelected = false
|
||||||
data.mobileSelected = false
|
data.mobileSelected = false
|
||||||
@ -118,7 +126,6 @@ export default {
|
|||||||
data.style.top = Number(data.style.top) + 20
|
data.style.top = Number(data.style.top) + 20
|
||||||
data.style.left = Number(data.style.left) + 20
|
data.style.left = Number(data.style.left) + 20
|
||||||
}
|
}
|
||||||
data.id = generateID()
|
|
||||||
// 如果是用户视图 测先进行底层复制
|
// 如果是用户视图 测先进行底层复制
|
||||||
if (data.type === 'view') {
|
if (data.type === 'view') {
|
||||||
chartCopy(data.propValue.viewId, state.panel.panelInfo.id).then(res => {
|
chartCopy(data.propValue.viewId, state.panel.panelInfo.id).then(res => {
|
||||||
@ -137,6 +144,7 @@ export default {
|
|||||||
store.commit('addComponent', { component: newView })
|
store.commit('addComponent', { component: newView })
|
||||||
})
|
})
|
||||||
} else if (data.type === 'de-tabs') {
|
} else if (data.type === 'de-tabs') {
|
||||||
|
const newTabComponents = []
|
||||||
const sourceAndTargetIds = {}
|
const sourceAndTargetIds = {}
|
||||||
const newCop = deepCopy(data)
|
const newCop = deepCopy(data)
|
||||||
newCop.id = uuid.v1()
|
newCop.id = uuid.v1()
|
||||||
@ -149,14 +157,35 @@ export default {
|
|||||||
if (item.content.filters && item.content.filters.length) {
|
if (item.content.filters && item.content.filters.length) {
|
||||||
item.content.filters = []
|
item.content.filters = []
|
||||||
}
|
}
|
||||||
|
} else if (item.content && item.content.type === 'canvas') {
|
||||||
|
const oldTabCanvasId = data.id + '-' + item.name
|
||||||
|
const newTabCanvasId = newCop.id + '-' + item.name
|
||||||
|
targetComponentData.forEach(component => {
|
||||||
|
if (component.canvasId === oldTabCanvasId) {
|
||||||
|
const newTabCop = deepCopy(component)
|
||||||
|
newTabCop.id = uuid.v1()
|
||||||
|
newTabCop.canvasId = newTabCanvasId
|
||||||
|
if (component.component === 'user-view') {
|
||||||
|
newTabCop.propValue.viewId = uuid.v1()
|
||||||
|
sourceAndTargetIds[component.propValue.viewId] = newTabCop.propValue.viewId
|
||||||
|
}
|
||||||
|
if (needAdaptor && store.state.multiplexingStyleAdapt) {
|
||||||
|
adaptCurThemeCommonStyle(newTabCop, 'copy')
|
||||||
|
}
|
||||||
|
newTabComponents.push(newTabCop)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
chartBatchCopy({ 'sourceAndTargetIds': sourceAndTargetIds }, state.panel.panelInfo.id).then((rsp) => {
|
await chartBatchCopy({ 'sourceAndTargetIds': sourceAndTargetIds }, state.panel.panelInfo.id).then((rsp) => {
|
||||||
if (needAdaptor && store.state.multiplexingStyleAdapt) {
|
if (needAdaptor && store.state.multiplexingStyleAdapt) {
|
||||||
adaptCurThemeCommonStyle(newCop, 'copy')
|
adaptCurThemeCommonStyle(newCop, 'copy')
|
||||||
}
|
}
|
||||||
store.commit('addComponent', { component: newCop })
|
store.commit('addComponent', { component: newCop })
|
||||||
})
|
})
|
||||||
|
if (newTabComponents) {
|
||||||
|
store.commit('addBatchComponent', newTabComponents)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const newCop = deepCopy(data)
|
const newCop = deepCopy(data)
|
||||||
newCop.id = uuid.v1()
|
newCop.id = uuid.v1()
|
||||||
|
@ -275,6 +275,9 @@ const data = {
|
|||||||
setMobileComponentData(state, mobileComponentData = []) {
|
setMobileComponentData(state, mobileComponentData = []) {
|
||||||
Vue.set(state, 'mobileComponentData', mobileComponentData)
|
Vue.set(state, 'mobileComponentData', mobileComponentData)
|
||||||
},
|
},
|
||||||
|
addBatchComponent(state, components = []) {
|
||||||
|
state.componentData.push(...components)
|
||||||
|
},
|
||||||
addComponent(state, { component, index }) {
|
addComponent(state, { component, index }) {
|
||||||
if (index !== undefined) {
|
if (index !== undefined) {
|
||||||
state.componentData.splice(index, 0, component)
|
state.componentData.splice(index, 0, component)
|
||||||
|
Loading…
Reference in New Issue
Block a user