Unverified 提交 3fd9defe authored 作者: 王嘉豪's avatar 王嘉豪 提交者: GitHub

Merge pull request #166 from dataease/pr@dev@panel

Pr@dev@panel
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class PanelView implements Serializable {
private String id;
private String panelId;
private String chartViewId;
private String createBy;
private Long createTime;
private String updateBy;
private Long updateTime;
private byte[] content;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.PanelView;
import io.dataease.base.domain.PanelViewExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PanelViewMapper {
long countByExample(PanelViewExample example);
int deleteByExample(PanelViewExample example);
int deleteByPrimaryKey(String id);
int insert(PanelView record);
int insertSelective(PanelView record);
List<PanelView> selectByExampleWithBLOBs(PanelViewExample example);
List<PanelView> selectByExample(PanelViewExample example);
PanelView selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") PanelView record, @Param("example") PanelViewExample example);
int updateByExampleWithBLOBs(@Param("record") PanelView record, @Param("example") PanelViewExample example);
int updateByExample(@Param("record") PanelView record, @Param("example") PanelViewExample example);
int updateByPrimaryKeySelective(PanelView record);
int updateByPrimaryKeyWithBLOBs(PanelView record);
int updateByPrimaryKey(PanelView record);
}
\ No newline at end of file
...@@ -16,4 +16,6 @@ public interface ExtChartViewMapper { ...@@ -16,4 +16,6 @@ public interface ExtChartViewMapper {
@Select("select id from chart_view where table_id = #{tableId}") @Select("select id from chart_view where table_id = #{tableId}")
List<String> allViewIds(@Param("tableId") String tableId); List<String> allViewIds(@Param("tableId") String tableId);
String searchAdviceSceneId(@Param("userId") String userId,@Param("panelId") String panelId);
} }
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
`scene_id`, `scene_id`,
`table_id`, `table_id`,
`type`, `type`,
`title`, GET_CHART_VIEW_COPY_NAME ( #{oldChartId} ),
`x_axis`, `x_axis`,
`y_axis`, `y_axis`,
`custom_attr`, `custom_attr`,
...@@ -68,4 +68,19 @@ ...@@ -68,4 +68,19 @@
WHERE WHERE
id = #{oldChartId} id = #{oldChartId}
</insert> </insert>
<select id="searchAdviceSceneId" resultType="String">
SELECT DISTINCT
( scene_id )
FROM
( SELECT GET_V_AUTH_MODEL_ID_P_USE ( #{userId}, 'chart' ) cids ) t,
panel_view
LEFT JOIN chart_view ON panel_view.chart_view_id = chart_view.id
LEFT JOIN chart_group ON chart_view.scene_id = chart_group.id
WHERE
FIND_IN_SET( chart_view.scene_id, cids ) and panel_view.panel_id =#{panelId}
ORDER BY
chart_group.create_time DESC
LIMIT 1
</select>
</mapper> </mapper>
package io.dataease.base.mapper.ext; package io.dataease.base.mapper.ext;
import io.dataease.base.domain.PanelView;
import io.dataease.dto.panel.PanelViewDto; import io.dataease.dto.panel.PanelViewDto;
import io.dataease.dto.panel.po.PanelViewInsertDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -9,4 +12,8 @@ public interface ExtPanelViewMapper { ...@@ -9,4 +12,8 @@ public interface ExtPanelViewMapper {
List<PanelViewDto> groups(String userId); List<PanelViewDto> groups(String userId);
List<PanelViewDto> views(String userId); List<PanelViewDto> views(String userId);
void deleteWithPanelId(String panelId);
void savePanelView(@Param("panelViews") List<PanelViewInsertDTO> panelViews);
} }
...@@ -31,6 +31,16 @@ ...@@ -31,6 +31,16 @@
</select> </select>
<delete id="deleteWithPanelId">
delete from panel_view where panel_id =#{panelId}
</delete>
<insert id="savePanelView">
INSERT INTO `panel_view` (id,chart_view_id, panel_id) VALUES
<foreach collection="panelViews" item="panelView" index="index" separator=",">
(uuid(),#{panelView.chartViewId},#{panelView.panelId})
</foreach>
</insert>
......
...@@ -60,4 +60,9 @@ public class ChartViewController { ...@@ -60,4 +60,9 @@ public class ChartViewController {
public String chartCopy(@PathVariable String id) { public String chartCopy(@PathVariable String id) {
return chartViewService.chartCopy(id); return chartViewService.chartCopy(id);
} }
@GetMapping("searchAdviceSceneId/{panelId}")
public String searchAdviceSceneId(@PathVariable String panelId){
return chartViewService.searchAdviceSceneId(panelId);
}
} }
package io.dataease.dto.panel.po;
import io.dataease.base.domain.PanelView;
/**
* Author: wangjiahao
* Date: 2021-07-06
* Description:
*/
public class PanelViewInsertDTO extends PanelView {
public PanelViewInsertDTO() {
}
public PanelViewInsertDTO(String chartViewId,String panelGroupId) {
super();
super.setChartViewId(chartViewId);
super.setPanelId(panelGroupId);
}
}
...@@ -405,4 +405,8 @@ public class ChartViewService { ...@@ -405,4 +405,8 @@ public class ChartViewService {
extChartViewMapper.chartCopy(newChartId,id); extChartViewMapper.chartCopy(newChartId,id);
return newChartId; return newChartId;
} }
public String searchAdviceSceneId(String panelId){
return extChartViewMapper.searchAdviceSceneId(AuthUtils.getUser().getUserId().toString(),panelId);
}
} }
...@@ -53,6 +53,8 @@ public class PanelGroupService { ...@@ -53,6 +53,8 @@ public class PanelGroupService {
private PanelLinkService panelLinkService; private PanelLinkService panelLinkService;
@Resource @Resource
private SysAuthService sysAuthService; private SysAuthService sysAuthService;
@Resource
private PanelViewService panelViewService;
public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) { public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) {
String userId = String.valueOf(AuthUtils.getUser().getUserId()); String userId = String.valueOf(AuthUtils.getUser().getUserId());
...@@ -72,6 +74,12 @@ public class PanelGroupService { ...@@ -72,6 +74,12 @@ public class PanelGroupService {
@Transactional @Transactional
public PanelGroup saveOrUpdate(PanelGroupRequest request) { public PanelGroup saveOrUpdate(PanelGroupRequest request) {
try{
panelViewService.syncPanelViews(request);
}catch (Exception e){
e.printStackTrace();
LOGGER.error("更新panelView出错panelId:{}" ,request.getId());
}
String panelId = request.getId(); String panelId = request.getId();
if (StringUtils.isEmpty(panelId)) { if (StringUtils.isEmpty(panelId)) {
// 新建 // 新建
...@@ -163,4 +171,5 @@ public class PanelGroupService { ...@@ -163,4 +171,5 @@ public class PanelGroupService {
}); });
return chartViewDTOList; return chartViewDTOList;
} }
} }
package io.dataease.service.panel; package io.dataease.service.panel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.dataease.base.domain.PanelGroup;
import io.dataease.base.domain.PanelGroupWithBLOBs;
import io.dataease.base.mapper.PanelViewMapper;
import io.dataease.base.mapper.ext.ExtPanelViewMapper; import io.dataease.base.mapper.ext.ExtPanelViewMapper;
import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.dto.panel.PanelViewDto; import io.dataease.dto.panel.PanelViewDto;
import io.dataease.dto.panel.po.PanelViewInsertDTO;
import io.dataease.dto.panel.po.PanelViewPo; import io.dataease.dto.panel.po.PanelViewPo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -22,6 +34,7 @@ public class PanelViewService { ...@@ -22,6 +34,7 @@ public class PanelViewService {
@Autowired(required = false) @Autowired(required = false)
private ExtPanelViewMapper extPanelViewMapper; private ExtPanelViewMapper extPanelViewMapper;
private final static String SCENE_TYPE = "scene"; private final static String SCENE_TYPE = "scene";
public List<PanelViewDto> groups(){ public List<PanelViewDto> groups(){
...@@ -63,4 +76,25 @@ public class PanelViewService { ...@@ -63,4 +76,25 @@ public class PanelViewService {
// 最后 没有孩子的老东西淘汰 // 最后 没有孩子的老东西淘汰
return roots.stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).collect(Collectors.toList()); return roots.stream().filter(item -> CollectionUtils.isNotEmpty(item.getChildren())).collect(Collectors.toList());
} }
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void syncPanelViews(PanelGroupWithBLOBs panelGroup){
String panelId = panelGroup.getId();
Assert.notNull(panelId, "panelId cannot be null");
String panelData = panelGroup.getPanelData();
if(StringUtils.isNotEmpty(panelData)){
JSONArray dataArray = JSON.parseArray(panelData);
List<PanelViewInsertDTO> panelViewInsertDTOList = new ArrayList<>();
for(int i=0;i<dataArray.size();i++){
JSONObject jsonObject = dataArray.getJSONObject(i);
if("view".equals(jsonObject.getString("type"))){
panelViewInsertDTOList.add(new PanelViewInsertDTO(jsonObject.getJSONObject("propValue").getString("viewId"),panelId));
}
}
extPanelViewMapper.deleteWithPanelId(panelId);
if(CollectionUtils.isNotEmpty(panelViewInsertDTOList)){
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
}
}
}
} }
DROP TABLE IF EXISTS `panel_view`;
CREATE TABLE `panel_view` (
`id` varchar(50) NOT NULL,
`panel_id` varchar(50) DEFAULT NULL COMMENT 'panel_id',
`chart_view_id` varchar(50) DEFAULT NULL COMMENT 'chart_view_id',
`content` blob COMMENT '内容',
`create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
`create_time` bigint(13) DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(255) DEFAULT NULL COMMENT '更新人',
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<!-- </table>--> <!-- </table>-->
<!-- <table tableName="v_dataset"/>--> <!-- <table tableName="v_dataset"/>-->
<!-- <table tableName="sys_auth_detail"/>--> <!-- <table tableName="sys_auth_detail"/>-->
<table tableName="dataset_table"/> <table tableName="panel_view"/>
</context> </context>
......
...@@ -35,3 +35,19 @@ export function chartCopy(id) { ...@@ -35,3 +35,19 @@ export function chartCopy(id) {
loading: true loading: true
}) })
} }
export function chartGroupTree(data) {
return request({
url: '/chart/group/tree',
method: 'post',
loading: true,
data
})
}
export function searchAdviceSceneId(panelId) {
return request({
url: '/chart/view/searchAdviceSceneId/' + panelId,
method: 'get',
loading: true
})
}
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
if (this.curComponent.type === 'view') { if (this.curComponent.type === 'view') {
this.$store.dispatch('chart/setViewId', null) this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId) this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId }}) bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
} }
if (this.curComponent.type === 'custom') { if (this.curComponent.type === 'custom') {
bus.$emit('component-dialog-edit') bus.$emit('component-dialog-edit')
......
...@@ -708,6 +708,8 @@ export default { ...@@ -708,6 +708,8 @@ export default {
area_mode: 'Area', area_mode: 'Area',
rose_radius: 'Fillet', rose_radius: 'Fillet',
view_name: 'Chart Title', view_name: 'Chart Title',
belong_group: 'Belong Group',
select_group: 'Select Group',
name_can_not_empty: 'Name cannot be empty', name_can_not_empty: 'Name cannot be empty',
template_can_not_empty: 'Please check a Template', template_can_not_empty: 'Please check a Template',
custom_count: 'Number of records', custom_count: 'Number of records',
......
...@@ -708,6 +708,8 @@ export default { ...@@ -708,6 +708,8 @@ export default {
area_mode: '面積', area_mode: '面積',
rose_radius: '園角', rose_radius: '園角',
view_name: '視圖標題', view_name: '視圖標題',
belong_group: '所属分组',
select_group: '选择分组',
name_can_not_empty: '名稱不能為空', name_can_not_empty: '名稱不能為空',
template_can_not_empty: '請選擇儀表板', template_can_not_empty: '請選擇儀表板',
custom_count: '記錄數', custom_count: '記錄數',
......
...@@ -708,6 +708,8 @@ export default { ...@@ -708,6 +708,8 @@ export default {
area_mode: '面积', area_mode: '面积',
rose_radius: '圆角', rose_radius: '圆角',
view_name: '视图标题', view_name: '视图标题',
belong_group: '所属分组',
select_group: '选择分组',
name_can_not_empty: '名称不能为空', name_can_not_empty: '名称不能为空',
template_can_not_empty: '请选择仪表版', template_can_not_empty: '请选择仪表版',
custom_count: '记录数', custom_count: '记录数',
......
...@@ -290,17 +290,29 @@ ...@@ -290,17 +290,29 @@
class="dialog-css" class="dialog-css"
:destroy-on-close="true" :destroy-on-close="true"
> >
<el-row style="width: 400px;"> <el-row style="width: 800px;">
<el-form ref="form" :model="table" label-width="80px" size="mini" class="form-item"> <el-form ref="form" :model="table" label-width="80px" size="mini" class="form-item">
<el-form-item :label="$t('chart.view_name')"> <el-col :span="12">
<el-input v-model="chartName" size="mini" /> <el-form-item :label="$t('chart.view_name')">
</el-form-item> <el-input v-model="chartName" style="height: 34px" size="mini" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="optFrom==='panel'">
<el-form-item :label="$t('chart.belong_group')">
<treeselect
v-model="currGroup.id"
:options="chartGroupTreeAvailable"
:normalizer="normalizer"
:placeholder="$t('chart.select_group')"
/>
</el-form-item>
</el-col>
</el-form> </el-form>
</el-row> </el-row>
<table-selector @getTable="getTable" /> <table-selector @getTable="getTable" />
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeCreateChart">{{ $t('chart.cancel') }}</el-button> <el-button size="mini" @click="closeCreateChart">{{ $t('chart.cancel') }}</el-button>
<el-button type="primary" size="mini" :disabled="!table.id" @click="createChart">{{ $t('chart.confirm') }}</el-button> <el-button type="primary" size="mini" :disabled="!table.id || !currGroup.id" @click="createChart">{{ $t('chart.confirm') }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -327,7 +339,7 @@ ...@@ -327,7 +339,7 @@
</template> </template>
<script> <script>
import { post } from '@/api/chart/chart' import { post, chartGroupTree } from '@/api/chart/chart'
import { authModel } from '@/api/system/sysAuth' import { authModel } from '@/api/system/sysAuth'
import TableSelector from '../view/TableSelector' import TableSelector from '../view/TableSelector'
import GroupMoveSelector from '../components/TreeSelector/GroupMoveSelector' import GroupMoveSelector from '../components/TreeSelector/GroupMoveSelector'
...@@ -353,6 +365,17 @@ export default { ...@@ -353,6 +365,17 @@ export default {
type: Object, type: Object,
required: false, required: false,
default: null default: null
},
// 操作来源 'panel' 为仪表板
optFrom: {
type: String,
required: false,
default: null
},
adviceGroupId: {
type: String,
required: false,
default: null
} }
}, },
data() { data() {
...@@ -416,7 +439,8 @@ export default { ...@@ -416,7 +439,8 @@ export default {
groupMoveConfirmDisabled: true, groupMoveConfirmDisabled: true,
dsMoveConfirmDisabled: true, dsMoveConfirmDisabled: true,
moveDialogTitle: '', moveDialogTitle: '',
isTreeSearch: false isTreeSearch: false,
chartGroupTreeAvailable: []
} }
}, },
computed: { computed: {
...@@ -444,12 +468,19 @@ export default { ...@@ -444,12 +468,19 @@ export default {
}, },
saveStatus() { saveStatus() {
this.refreshNodeBy(this.saveStatus.sceneId) this.refreshNodeBy(this.saveStatus.sceneId)
},
adviceGroupId() {
// 仪表板新建视图建议的存放路径
if (this.optFrom === 'panel') {
this.currGroup['id'] = this.adviceGroupId
}
} }
}, },
mounted() { mounted() {
this.treeNode(this.groupForm) this.treeNode(this.groupForm)
this.refresh() this.refresh()
// this.chartTree() // this.chartTree()
this.getChartGroupTree()
}, },
methods: { methods: {
clickAdd(param) { clickAdd(param) {
...@@ -760,10 +791,14 @@ export default { ...@@ -760,10 +791,14 @@ export default {
this.$store.dispatch('chart/setTableId', null) this.$store.dispatch('chart/setTableId', null)
this.$store.dispatch('chart/setTableId', this.table.id) this.$store.dispatch('chart/setTableId', this.table.id)
// this.$router.push('/chart/chart-edit') // this.$router.push('/chart/chart-edit')
this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': response.data.id }}) if (this.optFrom === 'panel') {
// this.$store.dispatch('chart/setViewId', response.data.id) this.$emit('newViewInfo', { 'id': response.data.id })
// this.chartTree() } else {
this.refreshNodeBy(view.sceneId) this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': response.data.id }})
// this.$store.dispatch('chart/setViewId', response.data.id)
// this.chartTree()
this.refreshNodeBy(view.sceneId)
}
}) })
}, },
...@@ -953,6 +988,18 @@ export default { ...@@ -953,6 +988,18 @@ export default {
this.isTreeSearch = false this.isTreeSearch = false
this.treeNode(this.groupForm) this.treeNode(this.groupForm)
} }
},
getChartGroupTree() {
chartGroupTree({}).then(res => {
this.chartGroupTreeAvailable = res.data
})
},
normalizer(node) {
// 去掉children=null的属性
if (node.children === null || node.children === 'null') {
delete node.children
}
} }
} }
} }
...@@ -1047,4 +1094,11 @@ export default { ...@@ -1047,4 +1094,11 @@ export default {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
} }
/deep/ .vue-treeselect__control{
height: 28px;
}
/deep/ .vue-treeselect__single-value{
color:#606266;
line-height: 28px!important;
}
</style> </style>
...@@ -497,7 +497,11 @@ export default { ...@@ -497,7 +497,11 @@ export default {
}, },
watch: { watch: {
'param': function() { 'param': function() {
this.getData(this.param.id) if(this.param.optType === 'new'){
}else{
this.getData(this.param.id)
}
}, },
searchField(val) { searchField(val) {
this.fieldFilter(val) this.fieldFilter(val)
......
...@@ -2,13 +2,19 @@ ...@@ -2,13 +2,19 @@
<el-col v-loading="loading"> <el-col v-loading="loading">
<el-row style="margin-top: 5px"> <el-row style="margin-top: 5px">
<el-row style="margin-left: 5px;margin-right: 5px"> <el-row style="margin-left: 5px;margin-right: 5px">
<el-input <el-col :span="16">
v-model="templateFilterText" <el-input
:placeholder="$t('panel.filter_keywords')" v-model="templateFilterText"
size="mini" :placeholder="$t('panel.filter_keywords')"
clearable size="mini"
prefix-icon="el-icon-search" clearable
/> prefix-icon="el-icon-search"
/>
</el-col>
<el-col :span="7">
<el-button type="primary" size="mini" style="float: right" @click="newChart">新建 </el-button>
</el-col>
</el-row> </el-row>
<el-row style="margin-top: 5px"> <el-row style="margin-top: 5px">
<el-tree <el-tree
...@@ -117,6 +123,9 @@ export default { ...@@ -117,6 +123,9 @@ export default {
}, },
allowDrop(draggingNode, dropNode, type) { allowDrop(draggingNode, dropNode, type) {
return false return false
},
newChart() {
this.$emit('newChart')
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<!--横向工具栏--> <!--横向工具栏-->
<el-col :span="16"> <el-col :span="16">
<Toolbar <Toolbar
ref="toolbar"
:style-button-active="show&&showIndex===2" :style-button-active="show&&showIndex===2"
:aided-button-active="aidedButtonActive" :aided-button-active="aidedButtonActive"
@showPanel="showPanel" @showPanel="showPanel"
...@@ -87,7 +88,7 @@ ...@@ -87,7 +88,7 @@
:close-on-press-escape="false" :close-on-press-escape="false"
:modal-append-to-body="true" :modal-append-to-body="true"
> >
<view-select v-show=" show && showIndex===0" /> <view-select v-show=" show && showIndex===0" @newChart="newChart" />
<filter-group v-show=" show &&showIndex===1" /> <filter-group v-show=" show &&showIndex===1" />
<subject-setting v-show=" show &&showIndex===2" /> <subject-setting v-show=" show &&showIndex===2" />
<assist-component v-show=" show &&showIndex===3" /> <assist-component v-show=" show &&showIndex===3" />
...@@ -160,6 +161,15 @@ ...@@ -160,6 +161,15 @@
<RectangleAttr v-if="curComponent&&curComponent.type==='rect-shape'" /> <RectangleAttr v-if="curComponent&&curComponent.type==='rect-shape'" />
<TextAttr v-if="curComponent&&curComponent.type==='v-text'" /> <TextAttr v-if="curComponent&&curComponent.type==='v-text'" />
<!--复用ChartGroup组件 不做显示-->
<ChartGroup
ref="chartGroup"
:opt-from="'panel'"
:advice-group-id="adviceGroupId"
style="height: 0px;width:0px;overflow: hidden"
@newViewInfo="newViewInfo"
/>
</el-row> </el-row>
</template> </template>
...@@ -187,6 +197,8 @@ import AttrListExtend from '@/components/canvas/components/AttrListExtend' ...@@ -187,6 +197,8 @@ import AttrListExtend from '@/components/canvas/components/AttrListExtend'
import elementResizeDetectorMaker from 'element-resize-detector' import elementResizeDetectorMaker from 'element-resize-detector'
import AssistComponent from '@/views/panel/AssistComponent' import AssistComponent from '@/views/panel/AssistComponent'
import PanelTextEditor from '@/components/canvas/custom-component/PanelTextEditor' import PanelTextEditor from '@/components/canvas/custom-component/PanelTextEditor'
import ChartGroup from '@/views/chart/group/Group'
import { searchAdviceSceneId } from '@/api/chart/chart'
// 引入样式 // 引入样式
import '@/components/canvas/assets/iconfont/iconfont.css' import '@/components/canvas/assets/iconfont/iconfont.css'
...@@ -220,7 +232,8 @@ export default { ...@@ -220,7 +232,8 @@ export default {
AssistComponent, AssistComponent,
PanelTextEditor, PanelTextEditor,
RectangleAttr, RectangleAttr,
TextAttr TextAttr,
ChartGroup
}, },
data() { data() {
return { return {
...@@ -255,7 +268,8 @@ export default { ...@@ -255,7 +268,8 @@ export default {
}, },
beforeDialogValue: [], beforeDialogValue: [],
styleDialogVisible: false, styleDialogVisible: false,
currentDropElement: null currentDropElement: null,
adviceGroupId: null
} }
}, },
...@@ -605,6 +619,49 @@ export default { ...@@ -605,6 +619,49 @@ export default {
} else { } else {
return y return y
} }
},
newChart() {
this.adviceGroupId = null
this.show = false
searchAdviceSceneId(this.panelInfo.id).then(res => {
this.adviceGroupId = res.data
this.$refs['chartGroup'].selectTable()
})
},
newViewInfo(newViewInfo) {
debugger
let component
const newComponentId = uuid.v1()
// 用户视图设置 复制一个模板
componentList.forEach(componentTemp => {
if (componentTemp.type === 'view') {
component = deepCopy(componentTemp)
const propValue = {
id: newComponentId,
viewId: newViewInfo.id
}
component.propValue = propValue
component.filters = []
}
})
// position = absolution 或导致有偏移 这里中和一下偏移量
component.style.top = 0
component.style.left = 600
component.id = newComponentId
this.$store.commit('addComponent', { component })
this.$store.commit('recordSnapshot')
this.clearCurrentInfo()
this.$store.commit('setCurComponent', { component: component, index: this.componentData.length - 1 })
// 编辑时临时保存 当前修改的画布
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))
this.$store.dispatch('panel/setCanvasStyleDataTemp', JSON.stringify(this.canvasStyleData))
if (this.curComponent.type === 'view') {
this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论