forked from github/dataease
Merge pull request #99 from dataease/pr@dev@wjh-copy-view
feat: 仪表板编辑时可以进行视图的复制,复制后的视图样式等改变不影响原有视图
This commit is contained in:
commit
43b85e6108
@ -12,6 +12,8 @@ import java.util.List;
|
||||
public interface ExtChartViewMapper {
|
||||
List<ChartViewDTO> search(ChartViewRequest request);
|
||||
|
||||
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId);
|
||||
|
||||
@Select("select id from chart_view where table_id = #{tableId}")
|
||||
List<String> allViewIds(@Param("tableId") String tableId);
|
||||
}
|
||||
|
@ -27,4 +27,45 @@
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="chartCopy">
|
||||
INSERT INTO chart_view (
|
||||
`id`,
|
||||
`name`,
|
||||
`scene_id`,
|
||||
`table_id`,
|
||||
`type`,
|
||||
`title`,
|
||||
`x_axis`,
|
||||
`y_axis`,
|
||||
`custom_attr`,
|
||||
`custom_style`,
|
||||
`custom_filter`,
|
||||
`create_by`,
|
||||
`create_time`,
|
||||
`update_time`,
|
||||
`snapshot`,
|
||||
`style_priority`
|
||||
) SELECT
|
||||
#{newChartId},
|
||||
GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ),
|
||||
`scene_id`,
|
||||
`table_id`,
|
||||
`type`,
|
||||
`title`,
|
||||
`x_axis`,
|
||||
`y_axis`,
|
||||
`custom_attr`,
|
||||
`custom_style`,
|
||||
`custom_filter`,
|
||||
`create_by`,
|
||||
`create_time`,
|
||||
`update_time`,
|
||||
`snapshot`,
|
||||
`style_priority`
|
||||
FROM
|
||||
chart_view
|
||||
WHERE
|
||||
id = #{oldChartId}
|
||||
</insert>
|
||||
</mapper>
|
||||
|
@ -55,4 +55,9 @@ public class ChartViewController {
|
||||
public Map<String, Object> chartDetail(@PathVariable String id) {
|
||||
return chartViewService.getChartDetail(id);
|
||||
}
|
||||
|
||||
@PostMapping("chartCopy/{id}")
|
||||
public String chartCopy(@PathVariable String id) {
|
||||
return chartViewService.chartCopy(id);
|
||||
}
|
||||
}
|
||||
|
@ -342,4 +342,10 @@ public class ChartViewService {
|
||||
public ChartViewWithBLOBs findOne(String id) {
|
||||
return chartViewMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public String chartCopy(String id) {
|
||||
String newChartId = UUID.randomUUID().toString();
|
||||
extChartViewMapper.chartCopy(newChartId,id);
|
||||
return newChartId;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
DROP FUNCTION IF EXISTS `GET_CHART_VIEW_COPY_NAME`;
|
||||
delimiter ;;
|
||||
CREATE DEFINER=`root`@`%` FUNCTION `GET_CHART_VIEW_COPY_NAME`(chartId varchar(255)) RETURNS varchar(255) CHARSET utf8
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
|
||||
DECLARE chartName varchar(255);
|
||||
|
||||
DECLARE pid varchar(255);
|
||||
|
||||
DECLARE regexpInfo varchar(255);
|
||||
|
||||
DECLARE chartNameCount INTEGER;
|
||||
|
||||
select `name` ,`scene_id` into chartName, pid from chart_view where id =chartId;
|
||||
|
||||
set regexpInfo = concat('^',chartName,'-copy','\\(([0-9])+\\)$');
|
||||
|
||||
select (count(1)+1) into chartNameCount from chart_view where name REGEXP regexpInfo;
|
||||
|
||||
RETURN concat(chartName,'-copy(',chartNameCount,')');
|
||||
|
||||
END
|
||||
;;
|
||||
delimiter ;
|
@ -27,3 +27,11 @@ export function getChartTree(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function chartCopy(id) {
|
||||
return request({
|
||||
url: '/chart/view/chartCopy/' + id,
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
<template v-if="curComponent">
|
||||
<template v-if="!curComponent.isLock">
|
||||
<li v-if="editFilter.includes(curComponent.type)" @click="edit"> {{ $t('panel.edit') }}</li>
|
||||
<!-- <li @click="copy"> {{ $t('panel.copy') }}</li>-->
|
||||
<li @click="copy"> {{ $t('panel.copy') }}</li>
|
||||
<li @click="paste"> {{ $t('panel.paste') }}</li>
|
||||
<li @click="cut"> {{ $t('panel.cut') }}</li>
|
||||
<li @click="deleteComponent"> {{ $t('panel.delete') }}</li>
|
||||
|
@ -2,6 +2,7 @@ import store from '@/store/index'
|
||||
import toast from '@/components/canvas/utils/toast'
|
||||
import generateID from '@/components/canvas/utils/generateID'
|
||||
import { deepCopy } from '@/components/canvas/utils/utils'
|
||||
import { chartCopy } from '@/api/chart/chart'
|
||||
|
||||
export default {
|
||||
state: {
|
||||
@ -36,7 +37,18 @@ export default {
|
||||
}
|
||||
|
||||
data.id = generateID()
|
||||
|
||||
// 如果是用户视图 测先进行底层复制
|
||||
debugger
|
||||
if (data.type === 'view') {
|
||||
chartCopy(data.propValue.viewId).then(res => {
|
||||
const newView = deepCopy(data)
|
||||
newView.propValue.viewId = res.data
|
||||
store.commit('addComponent', { component: newView })
|
||||
})
|
||||
} else {
|
||||
store.commit('addComponent', { component: deepCopy(data) })
|
||||
}
|
||||
if (state.isCut) {
|
||||
state.copyData = null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user