diff --git a/backend/src/main/java/com/ipsos/service/chart/ChartViewService.java b/backend/src/main/java/com/ipsos/service/chart/ChartViewService.java index 9e53060..c2b0f0f 100644 --- a/backend/src/main/java/com/ipsos/service/chart/ChartViewService.java +++ b/backend/src/main/java/com/ipsos/service/chart/ChartViewService.java @@ -197,6 +197,11 @@ public class ChartViewService { }.getType()); yAxis.addAll(yAxisExt); } + if (StringUtils.equalsIgnoreCase(view.getType(), "table-normal")) { + List yAxisExt = new Gson().fromJson(view.getYAxisExt(), new TypeToken>() { + }.getType()); + xAxis.addAll(yAxisExt); + } List extStack = new Gson().fromJson(view.getExtStack(), new TypeToken>() { }.getType()); List extBubble = new Gson().fromJson(view.getExtBubble(), new TypeToken>() { diff --git a/conf/data/ehcache/jdbc_provider_cache.data b/conf/data/ehcache/jdbc_provider_cache.data deleted file mode 100644 index e69de29..0000000 diff --git a/conf/data/ehcache/jdbc_provider_cache.index b/conf/data/ehcache/jdbc_provider_cache.index deleted file mode 100644 index 711006c..0000000 Binary files a/conf/data/ehcache/jdbc_provider_cache.index and /dev/null differ diff --git a/conf/data/ehcache/users_info.data b/conf/data/ehcache/users_info.data deleted file mode 100644 index e69de29..0000000 diff --git a/conf/data/ehcache/users_info.index b/conf/data/ehcache/users_info.index deleted file mode 100644 index 711006c..0000000 Binary files a/conf/data/ehcache/users_info.index and /dev/null differ diff --git a/conf/data/ehcache/users_permissions_info.data b/conf/data/ehcache/users_permissions_info.data deleted file mode 100644 index e69de29..0000000 diff --git a/conf/data/ehcache/users_permissions_info.index b/conf/data/ehcache/users_permissions_info.index deleted file mode 100644 index 711006c..0000000 Binary files a/conf/data/ehcache/users_permissions_info.index and /dev/null differ diff --git a/conf/data/ehcache/users_roles_info.data b/conf/data/ehcache/users_roles_info.data deleted file mode 100644 index e69de29..0000000 diff --git a/conf/data/ehcache/users_roles_info.index b/conf/data/ehcache/users_roles_info.index deleted file mode 100644 index 711006c..0000000 Binary files a/conf/data/ehcache/users_roles_info.index and /dev/null differ diff --git a/frontend/src/views/chart/components/table/TableNormal.vue b/frontend/src/views/chart/components/table/TableNormal.vue index 7bc01b6..15b3675 100644 --- a/frontend/src/views/chart/components/table/TableNormal.vue +++ b/frontend/src/views/chart/components/table/TableNormal.vue @@ -11,7 +11,10 @@ :width-resize="true" :header-row-style="table_header_class" :row-style="getRowStyle" + :cell-style="getColumStyle" class="table-class" + show-overflow="tooltip" + show-header-overflow="tooltip" :class="chart.id" :show-summary="showSummary" :summary-method="summaryMethod" @@ -19,15 +22,13 @@ - - - - + :sortable="!field.rowName" + :fixed="field.fixed" + :title="field.rowName?field.name+' \\ '+field.rowName:field.name" + /> @@ -97,7 +98,7 @@ export default { table_header_class: { fontSize: '12px', color: '#606266', - background: '#e8eaec', + backgroundColor: '#e8eaec', height: '36px' }, table_item_class: { @@ -162,15 +163,66 @@ export default { const that = this let datas = [] if (this.chart.data) { - console.log(this.chart) this.fields = JSON.parse(JSON.stringify(this.chart.data.fields)) datas = JSON.parse(JSON.stringify(this.chart.data.tableRow)) + const findRowIndex = this.fields.findIndex(e => e.chartType === 'row') + const findValueIndex = this.fields.findIndex(e => e.chartType === 'bar') + const findIndex = this.fields.findIndex(e => e.chartType === null) if (this.chart.type === 'table-info') { // 计算分页 this.currentPage.show = datas.length const pageStart = (this.currentPage.page - 1) * this.currentPage.pageSize const pageEnd = pageStart + this.currentPage.pageSize datas = datas.slice(pageStart, pageEnd) + } else if (this.chart.type === 'table-normal' && findRowIndex >= 0) { + // 交叉表数据处理 + this.fields[0].rowName = this.fields[findRowIndex].name + this.fields[0].fixed = 'left' + const fieldRowName = this.fields[findRowIndex].dataeaseName + const fieldValueName = this.fields[findValueIndex].dataeaseName + const fieldName = this.fields[findIndex].dataeaseName + const fields = [this.fields[0]] + let name = null + let flag = true + let rowSum = 0 + const columnValue = [] + datas.forEach((ele, index) => { + if (name !== ele[fieldName] && name !== null) { + flag = false + } + if (name !== ele[fieldName]) { + columnValue.push({ + [fieldName]: ele[fieldName] + }) + } + name = ele[fieldName] + if (name === ele[fieldName] && flag) { + fields.push({ + dataeaseName: fieldRowName + ele[fieldRowName], + name: ele[fieldRowName] + }) + } + }) + columnValue.forEach(ele => { + datas.forEach(subEle => { + if (ele[fieldName] === subEle[fieldName]) { + const key = fieldRowName + subEle[fieldRowName] + ele[key] = subEle[fieldValueName] + rowSum += subEle[fieldValueName] + } + }) + ele.rowTotal = rowSum + rowSum = 0 + }) + fields.push({ + dataeaseName: 'rowTotal', + fixed: 'right', + name: `合计(${this.fields[findValueIndex].name})` + }) + datas = columnValue + this.fields = fields + console.log(columnValue) + console.log(fields) } } else { this.fields = [] @@ -222,7 +274,7 @@ export default { const customAttr = JSON.parse(this.chart.customAttr) if (customAttr.color) { this.table_header_class.color = customAttr.color.tableFontColor - this.table_header_class.background = hexColorToRGBA(customAttr.color.tableHeaderBgColor, customAttr.color.alpha) + this.table_header_class.backgroundColor = hexColorToRGBA(customAttr.color.tableHeaderBgColor, customAttr.color.alpha) this.table_item_class.color = customAttr.color.tableFontColor this.table_item_class.background = hexColorToRGBA(customAttr.color.tableItemBgColor, customAttr.color.alpha) } @@ -265,7 +317,7 @@ export default { // console.log(s_table) let s = '' for (const i in this.table_header_class) { - s += (i === 'fontSize' ? 'font-size' : i) + ':' + this.table_header_class[i] + ';' + s += (i === 'fontSize' ? 'font-size' : i === 'backgroundColor' ? 'background-color' : i) + ':' + this.table_header_class[i] + ';' } // console.log(s_table) for (let i = 0; i < s_table.length; i++) { @@ -280,14 +332,28 @@ export default { return this.table_item_class } }, + getColumStyle({ columnIndex }) { + const findRowIndex = this.fields.findIndex(e => e.rowName) + if (this.chart.type === 'table-normal' && findRowIndex >= 0 && (columnIndex === 0 || columnIndex === this.fields.length - 1)) { + return this.table_header_class + } else { + return '' + } + }, summaryMethod({ columns, data }) { const that = this const means = [] // 合计 + const findRowIndex = this.fields.findIndex(e => e.rowName) + const findValueIndex = this.chart.data.fields.findIndex(e => e.chartType === 'bar') columns.forEach((column, columnIndex) => { if (columnIndex === 0) { - means.push('合计') + if (findRowIndex !== -1 && findValueIndex !== -1) { + means.push(`合计(${this.chart.data.fields[findValueIndex].name})`) + } else { + means.push('合计') + } } else { - if (columnIndex >= that.chart.data.fields.length - that.chart.data.series.length) { + if (columnIndex >= that.chart.data.fields.length - that.chart.data.series.length || findRowIndex !== -1) { const values = data.map(item => Number(item[column.property])) // 合计 if (!values.every(value => isNaN(value))) { @@ -375,4 +441,10 @@ export default { .page-style >>> .el-input__inner{ height: 24px; } + .colum-header { + font-size: 12px; + color: #000; + background: rgb(78, 129, 187); + height: 36px; + } diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 742b364..2ece763 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -158,16 +158,16 @@
- - - - - - - - - - + + + + + + @@ -183,8 +183,6 @@ - -
@@ -212,7 +210,7 @@ - +
@@ -942,7 +940,26 @@ export default { ele.filter = [] } }) - if (view.type === 'chart-mix' || view.type === 'table-normal') { + if (view.type === 'table-normal') { + view.yaxisExt.forEach(function(ele) { + if (!ele.chartType) { + ele.chartType = 'row' + } + if (!ele.dateStyle || ele.dateStyle === '') { + ele.dateStyle = 'y_M_d' + } + if (!ele.datePattern || ele.datePattern === '') { + ele.datePattern = 'date_sub' + } + if (!ele.sort || ele.sort === '') { + ele.sort = 'none' + } + if (!ele.filter) { + ele.filter = [] + } + }) + } + if (view.type === 'chart-mix') { view.yaxisExt.forEach(function(ele) { if (!ele.chartType) { ele.chartType = 'bar' @@ -1068,10 +1085,6 @@ export default { this.view.customAttr = this.view.customAttr ? JSON.parse(this.view.customAttr) : {} this.view.customStyle = this.view.customStyle ? JSON.parse(this.view.customStyle) : {} this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {} - console.log(this.view.xaxis) - console.log(this.view.yaxis) - console.log(this.view.yaxisExt) - console.log(this.view.type) // 将视图传入echart组件 this.chart = response.data this.data = response.data.data @@ -1427,7 +1440,7 @@ export default { } }, addXaxis(e) { - if (this.view.type === 'map' && this.view.xaxis.length > 1) { + if ((this.view.type === 'map' && this.view.xaxis.length > 1) || (this.view.type === 'table-normal' && this.view.xaxis.length > 1 && this.view.yaxisExt.length > 0)) { this.view.xaxis = [this.view.xaxis[0]] } if (this.view.type !== 'table-info') { @@ -1437,13 +1450,21 @@ export default { this.save(true) }, addRowXaxis(e) { - this.view.yaxisExt = [this.view.yaxisExt[0]] + if (this.view.yaxisExt.length > 1) { + this.view.yaxisExt = [this.view.yaxisExt[0]] + } + if (this.view.xaxis.length > 1) { + this.view.xaxis = [this.view.xaxis[0]] + } + if (this.view.yaxis.length > 1) { + this.view.yaxis = [this.view.yaxis[0]] + } this.dragCheckType(this.view.yaxisExt, 'd') this.dragMoveDuplicate(this.view.yaxisExt, e) this.save(true) }, addYaxis(e) { - if (this.view.type === 'map' && this.view.yaxis.length > 1) { + if ((this.view.type === 'map' && this.view.yaxis.length > 1) || (this.view.type === 'table-normal' && this.view.yaxis.length > 1 && this.view.yaxisExt.length > 0)) { this.view.yaxis = [this.view.yaxis[0]] } this.dragCheckType(this.view.yaxis, 'q')