From d3c31980357fab5cc50051df1235628bf8d054ef Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 16 Jun 2022 11:49:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=86=E5=9B=BE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/view/ChartEdit.vue | 260 ++++++++++++++++---- 1 file changed, 218 insertions(+), 42 deletions(-) diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index bf0418bafa..933ace7366 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -66,15 +66,32 @@ clearable class="main-area-input" /> - + + + + + + + {{ $t('chart.ds_field_edit') }} + + + {{ $t('chart.chart_field_edit') }} + + + - + - {{ item.name }} + {{ item.name }} + + + + + + {{ $t('commons.copy') }}... + + @@ -132,7 +157,7 @@ v-for="item in quotaData" v-show="chart.type && (chart.type !== 'table-info' || (chart.type === 'table-info' && item.id !=='count'))" :key="item.id" - class="item-quota" + class="item-quota father" :title="item.name" > @@ -143,7 +168,15 @@ class="field-icon-value" /> - {{ item.name }} + {{ item.name }} + + + + + + {{ $t('commons.copy') }}... + + @@ -151,7 +184,6 @@ - + + + + + + {{ $t('chart.confirm') }} + + + + + @@ -1030,9 +1098,14 @@ import { pluginTypes } from '@/api/chart/chart' import ValueFormatterEdit from '@/views/chart/components/value-formatter/ValueFormatterEdit' import ChartStyle from '@/views/chart/view/ChartStyle' import CustomSortEdit from '@/views/chart/components/compare/CustomSortEdit' +import ChartFieldEdit from '@/views/chart/view/ChartFieldEdit' +import CalcChartFieldEdit from '@/views/chart/view/CalcChartFieldEdit' + export default { name: 'ChartEdit', components: { + CalcChartFieldEdit, + ChartFieldEdit, CustomSortEdit, ChartStyle, ValueFormatterEdit, @@ -1176,6 +1249,9 @@ export default { showCustomSort: false, customSortList: [], customSortField: {}, + showEditChartField: false, + currEditField: {}, + editChartCalcField: false, fieldShow: false } @@ -1329,21 +1405,29 @@ export default { if (this.table) { post('/dataset/table/getFieldsFromDE', this.table).then(response => { // If click too fast on the panel, the data here may be inconsistent, so make a verification - if (this.view.tableId === id) { - this.dimension = response.data.dimension - this.quota = response.data.quota - this.dimensionData = JSON.parse(JSON.stringify(this.dimension)) - this.quotaData = JSON.parse(JSON.stringify(this.quota)) - this.fieldFilter(this.searchField) - if (optType === 'change') { - this.resetChangeTable() - this.$nextTick(() => { - bus.$emit('reset-change-table', 'change') - this.calcData() - }) + post('/chart/field/listByDQ/' + this.param.id + '/' + this.panelInfo.id, null).then(res => { + if (this.view.tableId === id) { + this.dimension = response.data.dimension.concat(res.data.dimensionList) + this.quota = response.data.quota.concat(res.data.quotaList) + this.dimensionData = JSON.parse(JSON.stringify(this.dimension)) + this.quotaData = JSON.parse(JSON.stringify(this.quota)) + this.fieldFilter(this.searchField) + if (optType === 'change') { + this.resetChangeTable() + this.$nextTick(() => { + bus.$emit('reset-change-table', 'change') + this.calcData() + }) + } } - } - this.fieldShow = true + this.fieldShow = true + }).catch(err => { + console.log(err) + this.resetView() + this.httpRequest.status = err.response.data.success + this.httpRequest.msg = err.response.data.message + return true + }) }).catch(err => { console.error(err) @@ -1453,13 +1537,18 @@ export default { if (!ele.chartType) { ele.chartType = 'bar' } - if (!ele.summary || ele.summary === '') { - if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) { - ele.summary = 'count' - } else { - ele.summary = 'sum' + if (ele.chartId) { + ele.summary = '' + } else { + if (!ele.summary || ele.summary === '') { + if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) { + ele.summary = 'count' + } else { + ele.summary = 'sum' + } } } + if (!ele.sort || ele.sort === '') { ele.sort = 'none' } @@ -1475,13 +1564,18 @@ export default { if (!ele.chartType) { ele.chartType = 'bar' } - if (!ele.summary || ele.summary === '') { - if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) { - ele.summary = 'count' - } else { - ele.summary = 'sum' + if (ele.chartId) { + ele.summary = '' + } else { + if (!ele.summary || ele.summary === '') { + if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) { + ele.summary = 'count' + } else { + ele.summary = 'sum' + } } } + if (!ele.sort || ele.sort === '') { ele.sort = 'none' } @@ -2096,9 +2190,12 @@ export default { const optType = this.view.tableId === this.changeTable.id ? 'same' : 'change' // this.save(true, 'chart', false) this.view.tableId = this.changeTable.id - this.calcData(true, 'chart', false) - this.initTableData(this.view.tableId, optType) - this.closeChangeChart() + // 更换数据集后清空视图字段 + post('/chart/field/deleteByChartId/' + this.param.id + '/' + this.panelInfo.id, null).then(response => { + this.calcData(true, 'chart', false) + this.initTableData(this.view.tableId, optType) + this.closeChangeChart() + }) }, fieldFilter(val) { @@ -2124,6 +2221,15 @@ export default { this.initTableField(this.table.id) }, + editChartField() { + this.showEditChartField = true + }, + + closeEditChartField() { + this.showEditChartField = false + this.initTableField(this.table.id) + }, + // drag dragCheckType(list, type) { if (list && list.length > 0) { @@ -2495,6 +2601,50 @@ export default { }) this.closeCustomSort() this.calcData(true) + }, + + fieldEdit(param) { + switch (param.type) { + case 'ds': + this.editField() + break + case 'chart': + this.editChartField() + break + default: + break + } + }, + beforeFieldEdit(type) { + return { + type: type + } + }, + + chartFieldEdit(param) { + this.currEditField = JSON.parse(JSON.stringify(param.item)) + switch (param.type) { + case 'copy': + this.currEditField.id = null + this.currEditField.extField = 1 + this.showChartCalcField() + break + } + }, + handleChartFieldEdit(item, type) { + return { + type: type, + item: item + } + }, + + showChartCalcField() { + this.editChartCalcField = true + }, + closeChartCalcField() { + this.editChartCalcField = false + this.currEditField = {} + this.initTableField(this.table.id) } } } @@ -2574,6 +2724,7 @@ export default { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + position: relative; } .blackTheme .item-dimension { @@ -2612,6 +2763,7 @@ export default { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + position: relative; } .blackTheme .item-quota { @@ -2896,6 +3048,30 @@ span { font-size: 12px; } +.field-name{ + display: inline-block; + width: 90px; + word-break: break-all; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + position: absolute; + top: 2px; +} + +.field-setting{ + position: absolute; + right: 8px; +} + +.father .child { + visibility: hidden; +} + +.father:hover .child { + visibility: visible; +} + .field-split{ height: calc(100% - 40px); }