forked from github/dataease
Merge pull request #10203 from dataease/pr@dev-v2@feat_chart
feat(图表): 图表中支持直接复制字段
This commit is contained in:
commit
22a028baa3
@ -13,6 +13,7 @@ import io.dataease.chart.dao.ext.mapper.ExtChartViewMapper;
|
||||
import io.dataease.dataset.dao.auto.entity.CoreDatasetTableField;
|
||||
import io.dataease.dataset.dao.auto.mapper.CoreDatasetTableFieldMapper;
|
||||
import io.dataease.dataset.manage.PermissionManage;
|
||||
import io.dataease.dataset.utils.TableUtils;
|
||||
import io.dataease.dto.dataset.DatasetTableFieldDTO;
|
||||
import io.dataease.engine.constant.ExtFieldConstant;
|
||||
import io.dataease.engine.func.FunctionConstant;
|
||||
@ -189,6 +190,8 @@ public class ChartViewManege {
|
||||
coreDatasetTableField.setExtField(2);
|
||||
coreDatasetTableField.setOriginName("[" + id + "]");
|
||||
coreDatasetTableField.setId(IDUtils.snowID());
|
||||
coreDatasetTableField.setDataeaseName(TableUtils.fieldNameShort(coreDatasetTableField.getId() + "_" + coreDatasetTableField.getOriginName()));
|
||||
coreDatasetTableField.setFieldShortName(coreDatasetTableField.getDataeaseName());
|
||||
coreDatasetTableFieldMapper.insert(coreDatasetTableField);
|
||||
}
|
||||
|
||||
@ -205,6 +208,12 @@ public class ChartViewManege {
|
||||
coreDatasetTableFieldMapper.deleteById(id);
|
||||
}
|
||||
|
||||
public void deleteFieldByChartId(Long chartId) {
|
||||
QueryWrapper<CoreDatasetTableField> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("chart_id", chartId);
|
||||
coreDatasetTableFieldMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
public DatasetTableFieldDTO createCountField(Long id) {
|
||||
DatasetTableFieldDTO dto = new DatasetTableFieldDTO();
|
||||
dto.setId(-1L);
|
||||
|
@ -67,4 +67,9 @@ public class ChartViewServer implements ChartViewApi {
|
||||
public void deleteField(Long id) {
|
||||
chartViewManege.deleteField(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFieldByChart(Long chartId) {
|
||||
chartViewManege.deleteFieldByChartId(chartId);
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,12 @@ export const deleteChartField = async (id): Promise<IResponse> => {
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteChartFieldByChartId = async (chartId): Promise<IResponse> => {
|
||||
return request.post({ url: `/chart/deleteFieldByChart/${chartId}`, data: {} }).then(res => {
|
||||
return res?.data
|
||||
})
|
||||
}
|
||||
|
||||
// 通过图表对象获取数据
|
||||
export const getData = async (data): Promise<IResponse> => {
|
||||
delete data.data
|
||||
|
@ -50,7 +50,13 @@ import chartViewManager from '@/views/chart/components/js/panel'
|
||||
import DatasetSelect from '@/views/chart/components/editor/dataset-select/DatasetSelect.vue'
|
||||
import { useDraggable } from '@vueuse/core'
|
||||
import { set, concat, keys } from 'lodash-es'
|
||||
import { Field, getFieldByDQ, copyChartField, deleteChartField } from '@/api/chart'
|
||||
import {
|
||||
Field,
|
||||
getFieldByDQ,
|
||||
copyChartField,
|
||||
deleteChartField,
|
||||
deleteChartFieldByChartId
|
||||
} from '@/api/chart'
|
||||
import ChartTemplateInfo from '@/views/chart/components/editor/common/ChartTemplateInfo.vue'
|
||||
import { XpackComponent } from '@/components/plugin'
|
||||
import { useEmbedded } from '@/store/modules/embedded'
|
||||
@ -191,15 +197,22 @@ provide('filedList', () => filedList.value)
|
||||
watch(
|
||||
[() => view.value['tableId']],
|
||||
() => {
|
||||
getFields(props.view.tableId, props.view.id)
|
||||
const nodeId = view.value['tableId']
|
||||
if (!!nodeId) {
|
||||
cacheId = nodeId as unknown as string
|
||||
}
|
||||
const node = datasetSelector?.value?.getNode(nodeId)
|
||||
if (node?.data) {
|
||||
curDatasetWeight.value = node.data.weight
|
||||
}
|
||||
fieldLoading.value = true
|
||||
deleteChartFieldByChartId(props.view.id)
|
||||
.then(() => {
|
||||
getFields(props.view.tableId, props.view.id)
|
||||
const nodeId = view.value['tableId']
|
||||
if (!!nodeId) {
|
||||
cacheId = nodeId as unknown as string
|
||||
}
|
||||
const node = datasetSelector?.value?.getNode(nodeId)
|
||||
if (node?.data) {
|
||||
curDatasetWeight.value = node.data.weight
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
fieldLoading.value = false
|
||||
})
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
@ -51,4 +51,8 @@ public interface ChartViewApi {
|
||||
@Operation(summary = "视图删除字段")
|
||||
@PostMapping("deleteField/{id}")
|
||||
void deleteField(@PathVariable Long id);
|
||||
|
||||
@Operation(summary = "清空当前视图计算字段")
|
||||
@PostMapping("deleteFieldByChart/{chartId}")
|
||||
void deleteFieldByChart(@PathVariable Long chartId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user