forked from github/dataease
Merge pull request #7200 from dataease/pr@dev-v2@refactor_copy
refactor: 优化复制操作
This commit is contained in:
commit
d1f66ce127
@ -56,6 +56,7 @@ public class CoreVisualizationManage {
|
||||
}
|
||||
QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
queryWrapper.ne("pid",-1);
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(request.getLeaf()), "node_type", ObjectUtils.isNotEmpty(request.getLeaf()) && request.getLeaf() ? "leaf" : "folder");
|
||||
queryWrapper.eq("type", request.getBusiFlag());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
@ -108,6 +109,10 @@ public class CoreVisualizationManage {
|
||||
|
||||
@XpackInteract(value = "visualizationResourceTree", before = false)
|
||||
public Long innerSave(DataVisualizationInfo visualizationInfo) {
|
||||
return preInnerSave(visualizationInfo);
|
||||
}
|
||||
|
||||
public Long preInnerSave(DataVisualizationInfo visualizationInfo){
|
||||
if (visualizationInfo.getId() == null) {
|
||||
Long id = IDUtils.snowID();
|
||||
visualizationInfo.setId(id);
|
||||
|
@ -122,18 +122,24 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
||||
}
|
||||
DataVisualizationInfo visualizationInfo = new DataVisualizationInfo();
|
||||
BeanUtils.copyBean(visualizationInfo, request);
|
||||
|
||||
// 检查当前节点的pid是否一致如果不一致 需要调用move 接口(预存 可能会出现pid =-1的情况)
|
||||
if (request.getPid() != -1) {
|
||||
QueryWrapper<DataVisualizationInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("pid", request.getPid());
|
||||
queryWrapper.eq("id", dvId);
|
||||
if (!visualizationInfoMapper.exists(queryWrapper)) {
|
||||
request.setMoveFromUpdate(true);
|
||||
coreVisualizationManage.move(request);
|
||||
if(DataVisualizationConstants.RESOURCE_OPT_TYPE.COPY.equals(request.getOptType())){
|
||||
// 复制更新 新建权限插入
|
||||
visualizationInfoMapper.deleteById(dvId);
|
||||
visualizationInfo.setNodeType(DataVisualizationConstants.NODE_TYPE.LEAF);
|
||||
coreVisualizationManage.innerSave(visualizationInfo);
|
||||
}else{
|
||||
// 检查当前节点的pid是否一致如果不一致 需要调用move 接口(预存 可能会出现pid =-1的情况)
|
||||
if (request.getPid() != -1) {
|
||||
QueryWrapper<DataVisualizationInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("pid", request.getPid());
|
||||
queryWrapper.eq("id", dvId);
|
||||
if (!visualizationInfoMapper.exists(queryWrapper)) {
|
||||
request.setMoveFromUpdate(true);
|
||||
coreVisualizationManage.move(request);
|
||||
}
|
||||
}
|
||||
coreVisualizationManage.innerEdit(visualizationInfo);
|
||||
}
|
||||
coreVisualizationManage.innerEdit(visualizationInfo);
|
||||
//保存视图信
|
||||
chartDataManage.saveChartViewFromVisualization(request.getComponentData(), dvId, request.getCanvasViewInfo());
|
||||
}
|
||||
@ -214,8 +220,10 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
||||
extDataVisualizationMapper.copyLinkJump(copyId);
|
||||
extDataVisualizationMapper.copyLinkJumpInfo(copyId);
|
||||
extDataVisualizationMapper.copyLinkJumpTargetInfo(copyId);
|
||||
|
||||
coreVisualizationManage.innerSave(newDv);
|
||||
DataVisualizationInfo visualizationInfoTarget = new DataVisualizationInfo();
|
||||
BeanUtils.copyBean(visualizationInfoTarget,newDv);
|
||||
visualizationInfoTarget.setPid(-1L);
|
||||
coreVisualizationManage.preInnerSave(visualizationInfoTarget);
|
||||
return String.valueOf(newDvId);
|
||||
}
|
||||
|
||||
@ -321,6 +329,7 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
||||
}
|
||||
wrapper.eq("delete_flag", 0);
|
||||
wrapper.eq("pid", request.getPid());
|
||||
wrapper.ne("pid", -1);
|
||||
wrapper.eq("name", request.getName().trim());
|
||||
wrapper.eq("node_type", request.getNodeType());
|
||||
wrapper.eq("type", request.getType());
|
||||
|
@ -52,6 +52,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
// 大屏基础信息
|
||||
dvInfo: {
|
||||
dataState: null,
|
||||
optType: null,
|
||||
id: null,
|
||||
name: null,
|
||||
pid: null,
|
||||
@ -845,6 +846,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
resetDvInfo() {
|
||||
this.dvInfo = {
|
||||
dataState: null,
|
||||
optType: null,
|
||||
id: null,
|
||||
name: null,
|
||||
pid: null,
|
||||
@ -871,6 +873,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
updateDvInfoId(newId) {
|
||||
if (this.dvInfo) {
|
||||
this.dvInfo.dataState = 'ready'
|
||||
this.dvInfo.optType = null
|
||||
this.dvInfo.id = newId
|
||||
}
|
||||
},
|
||||
@ -878,6 +881,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
const optName = dvType === 'dashboard' ? '新建仪表板' : '新建数据大屏'
|
||||
this.dvInfo = {
|
||||
dataState: 'prepare',
|
||||
optType: null,
|
||||
id: resourceId,
|
||||
name: optName,
|
||||
pid: pid,
|
||||
@ -899,6 +903,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
this.componentData = []
|
||||
this.dvInfo = {
|
||||
dataState: null,
|
||||
optType: null,
|
||||
id: null,
|
||||
name: null,
|
||||
pid: null,
|
||||
|
@ -289,7 +289,7 @@ export function filterEmptyFolderTree(nodes) {
|
||||
|
||||
export function findParentIdByChildIdRecursive(tree, targetChildId) {
|
||||
function findParentId(node, targetChildId) {
|
||||
if (node.type === 'folder' && node.children) {
|
||||
if (node.children) {
|
||||
for (const childNode of node.children) {
|
||||
if (childNode.id === targetChildId) {
|
||||
return node.id // 找到匹配的子节点,返回其父节点的 ID
|
||||
|
@ -244,9 +244,9 @@ const operation = (cmd: string, data: BusiTreeNode, nodeType: string) => {
|
||||
copyResource(params).then(data => {
|
||||
const baseUrl =
|
||||
curCanvasType.value === 'dataV'
|
||||
? '#/dvCanvas?opt=copy&dvId='
|
||||
: '#/dashboard?opt=copy&resourceId='
|
||||
window.open(baseUrl + data.data, '_blank')
|
||||
? `#/dvCanvas?opt=copy&pid=${params.pid}&dvId=${data.data}`
|
||||
: `#/dashboard?opt=copy&pid=${params.pid}&resourceId=${data.data}`
|
||||
window.open(baseUrl, '_blank')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,15 @@ const eventCheck = e => {
|
||||
const dvMainStore = dvMainStoreWithOut()
|
||||
const snapshotStore = snapshotStoreWithOut()
|
||||
|
||||
const { componentData, curComponent, canvasStyleData, canvasViewInfo, editMode, batchOptStatus } =
|
||||
storeToRefs(dvMainStore)
|
||||
const {
|
||||
componentData,
|
||||
curComponent,
|
||||
canvasStyleData,
|
||||
canvasViewInfo,
|
||||
editMode,
|
||||
batchOptStatus,
|
||||
dvInfo
|
||||
} = storeToRefs(dvMainStore)
|
||||
const dataInitState = ref(false)
|
||||
|
||||
const state = reactive({
|
||||
@ -62,6 +69,14 @@ onMounted(() => {
|
||||
dataInitState.value = false
|
||||
initCanvasData(resourceId, 'dashboard', function () {
|
||||
dataInitState.value = true
|
||||
if (dvInfo.value && opt === 'copy') {
|
||||
dvInfo.value.dataState = 'prepare'
|
||||
dvInfo.value.optType = 'copy'
|
||||
dvInfo.value.pid = pid
|
||||
setTimeout(() => {
|
||||
snapshotStore.recordSnapshotCache()
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
} else if (opt && opt === 'create') {
|
||||
dataInitState.value = false
|
||||
|
@ -193,13 +193,18 @@ onMounted(() => {
|
||||
state.canvasInitStatus = false
|
||||
initCanvasData(dvId, 'dataV', function () {
|
||||
state.canvasInitStatus = true
|
||||
if (dvInfo.value && opt === 'copy') {
|
||||
dvInfo.value.dataState = 'prepare'
|
||||
}
|
||||
// afterInit
|
||||
nextTick(() => {
|
||||
dvMainStore.setDataPrepareState(true)
|
||||
snapshotStore.recordSnapshotCache('renderChart')
|
||||
if (dvInfo.value && opt === 'copy') {
|
||||
dvInfo.value.dataState = 'prepare'
|
||||
dvInfo.value.optType = 'copy'
|
||||
dvInfo.value.pid = pid
|
||||
setTimeout(() => {
|
||||
snapshotStore.recordSnapshotCache('renderChart')
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
})
|
||||
} else if (opt && opt === 'create') {
|
||||
|
Loading…
Reference in New Issue
Block a user