From 3526d39e01b404e9301981cf4d4a40b54a1dc331 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 29 Apr 2021 12:12:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 12 +++++-- frontend/src/views/chart/chart/chart.js | 36 +++++++++---------- frontend/src/views/dataset/add/AddExcel.vue | 35 ++++++++---------- frontend/src/views/dataset/add/AddSQL.vue | 24 ++++++++++--- .../src/views/dataset/data/TabDataPreview.vue | 2 +- 5 files changed, 63 insertions(+), 46 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 2941638e8e..d3d38f781b 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -81,7 +81,15 @@ public class DataSetTableService { saveTableField(datasetTable); } } else { - datasetTableMapper.updateByPrimaryKeySelective(datasetTable); + int update = datasetTableMapper.updateByPrimaryKeySelective(datasetTable); + // sql 更新 + if (update == 1) { + if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) { + // 删除所有字段,重新抽象 + dataSetTableFieldsService.deleteByTableId(datasetTable.getId()); + saveTableField(datasetTable); + } + } } return datasetTable; } @@ -262,7 +270,7 @@ public class DataSetTableService { DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setDatasource(ds); String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql(); - datasourceRequest.setQuery(sql); + datasourceRequest.setQuery("SELECT * FROM (" + sql + ") AS tmp LIMIT 0,1000"); Map result = datasourceProvider.fetchResultAndField(datasourceRequest); List data = result.get("dataList"); List fields = result.get("fieldList"); diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js index 6571d9ad5f..a9efd53629 100644 --- a/frontend/src/views/chart/chart/chart.js +++ b/frontend/src/views/chart/chart/chart.js @@ -88,9 +88,9 @@ export const BASE_BAR = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: {}, legend: { show: true, @@ -117,9 +117,9 @@ export const HORIZONTAL_BAR = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: {}, legend: { show: true, @@ -147,9 +147,9 @@ export const BASE_LINE = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: {}, legend: { show: true, @@ -178,9 +178,9 @@ export const BASE_PIE = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: {}, legend: { show: true, @@ -211,9 +211,9 @@ export const BASE_FUNNEL = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: { trigger: 'item' }, @@ -267,9 +267,9 @@ export const BASE_RADAR = { title: { text: '' }, - grid: { - containLabel: true - }, + // grid: { + // containLabel: true + // }, tooltip: {}, legend: { show: true, diff --git a/frontend/src/views/dataset/add/AddExcel.vue b/frontend/src/views/dataset/add/AddExcel.vue index 92b98aa8c7..50a2d6cfed 100644 --- a/frontend/src/views/dataset/add/AddExcel.vue +++ b/frontend/src/views/dataset/add/AddExcel.vue @@ -19,10 +19,10 @@ - + - + - +
{{ $t('dataset.data_preview') }} @@ -100,27 +100,13 @@ export default { } }, watch: { - // dataSource(val) { - // if (val) { - // post('/datasource/getTables', { id: val }).then(response => { - // this.tables = response.data - // this.tableData = JSON.parse(JSON.stringify(this.tables)) - // }) - // } - // }, - // searchTable(val) { - // if (val && val !== '') { - // this.tableData = JSON.parse(JSON.stringify(this.tables.filter(ele => { return ele.includes(val) }))) - // } else { - // this.tableData = JSON.parse(JSON.stringify(this.tables)) - // } - // } }, mounted() { // this.initDataSource() - }, - activated() { - // this.initDataSource() + window.onresize = () => { + this.calHeight() + } + this.calHeight() }, methods: { // initDataSource() { @@ -128,6 +114,13 @@ export default { // this.options = response.data // }) // }, + calHeight() { + const that = this + setTimeout(function() { + const currentHeight = document.documentElement.clientHeight + that.height = currentHeight - 56 - 30 - 26 - 25 - 35 - 10 - 37 - 20 - 10 + }, 10) + }, uploadSuccess(response, file, fileList) { // console.log(response) // console.log(file) diff --git a/frontend/src/views/dataset/add/AddSQL.vue b/frontend/src/views/dataset/add/AddSQL.vue index 4bb5811761..7d1414211a 100644 --- a/frontend/src/views/dataset/add/AddSQL.vue +++ b/frontend/src/views/dataset/add/AddSQL.vue @@ -76,6 +76,11 @@ />
+ + {{ $t('dataset.preview_show') }} + 1000 + {{ $t('dataset.preview_item') }} +
@@ -155,11 +160,9 @@ export default { }, mounted() { window.onresize = () => { - return (() => { - this.height = window.innerHeight / 2 - })() + this.calHeight() } - this.height = window.innerHeight / 2 + this.calHeight() this.initDataSource() this.$refs.myCm.codemirror.on('keypress', () => { this.$refs.myCm.codemirror.showHint() @@ -168,6 +171,13 @@ export default { this.initTableInfo() }, methods: { + calHeight() { + const that = this + setTimeout(function() { + const currentHeight = document.documentElement.clientHeight + that.height = currentHeight - 56 - 30 - 26 - 25 - 43 - 160 - 10 - 37 - 20 - 10 - 16 + }, 10) + }, initDataSource() { listDatasource().then(response => { this.options = response.data @@ -303,4 +313,10 @@ export default { span{ font-size: 14px; } + .span-number{ + color: #f18126; + } + .table-count{ + color: #606266; + } diff --git a/frontend/src/views/dataset/data/TabDataPreview.vue b/frontend/src/views/dataset/data/TabDataPreview.vue index d9cd02d34e..c07d22316c 100644 --- a/frontend/src/views/dataset/data/TabDataPreview.vue +++ b/frontend/src/views/dataset/data/TabDataPreview.vue @@ -160,7 +160,7 @@ export default { float: right; } span{ - font-size: 14px; + font-size: 12px; } .span-number{ color: #f18126;