test: 临时提交测试

This commit is contained in:
junjun 2022-05-09 14:27:49 +08:00
parent 03a257d447
commit 6c0132c23c
15 changed files with 355 additions and 36 deletions

View File

@ -49,7 +49,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from
data_from,
custom_sort
) SELECT
id,
`name`,
@ -78,7 +79,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view
data_from,
custom_sort from chart_view
WHERE
chart_view.id = #{id}
</insert>
@ -112,7 +114,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from
data_from,
custom_sort
) SELECT
#{newViewId} as id,
`name`,
@ -141,7 +144,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view_cache
data_from,
custom_sort from chart_view_cache
WHERE
chart_view_cache.id = #{sourceViewId}
</insert>
@ -175,7 +179,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from
data_from,
custom_sort
) SELECT
id,
`name`,
@ -204,7 +209,8 @@
drill_fields,
senior,
SNAPSHOT,
data_from from chart_view
data_from,
custom_sort from chart_view
WHERE
chart_view.scene_id = #{panelId}
</insert>
@ -287,7 +293,8 @@
`chart_type`,
`is_plugin`,
`senior`,
`data_from`)
`data_from`,
`custom_sort`)
SELECT #{newChartId},
GET_CHART_VIEW_COPY_NAME(#{oldChartId},#{panelId}) as `name`,
#{panelId},
@ -315,7 +322,8 @@
'private',
`is_plugin`,
`senior`,
`data_from`
`data_from`,
`custom_sort`
FROM chart_view
WHERE id = #{oldChartId}
</insert>
@ -365,7 +373,8 @@
custom_filter,
drill_fields,
SNAPSHOT,
data_from)
data_from,
custom_sort)
SELECT pv_copy.chart_view_id AS id,
`name`,
title,
@ -392,7 +401,8 @@
custom_filter,
drill_fields,
SNAPSHOT,
data_from
data_from,
custom_sort
FROM (
SELECT panel_id,
copy_from_view,
@ -502,7 +512,8 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.custom_sort = cve.custom_sort
where cve.id = cv.id and cv.id in
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
#{viewId}
@ -538,7 +549,8 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.custom_sort = cve.custom_sort
where cve.id = cv.id and cv.id =#{viewId}
</update>
@ -572,7 +584,8 @@
cv.drill_fields = cve.drill_fields,
cv.senior = cve.senior,
cv.SNAPSHOT = cve.SNAPSHOT,
cv.data_from = cve.data_from
cv.data_from = cve.data_from,
cv.custom_sort = cve.custom_sort
where cve.id = cv.id and cv.id =#{viewId}
</update>

View File

@ -0,0 +1,4 @@
ALTER TABLE `chart_view` ADD COLUMN `custom_sort` LONGTEXT COMMENT '自定义排序';
UPDATE `chart_view` SET `custom_sort` = '[]';
ALTER TABLE `chart_view_cache` ADD COLUMN `custom_sort` LONGTEXT COMMENT '自定义排序';
UPDATE `chart_view_cache` SET `custom_sort` = '[]';

View File

@ -1095,7 +1095,10 @@ export default {
unit_hundred_million: 'Hundred Million',
formatter_decimal_count_error: 'Range 0-10',
gauge_threshold_compare_error: 'Range must added',
tick_count: 'Tick Split'
tick_count: 'Tick Split',
custom_sort: 'Custom Sort',
custom_sort_tip: 'Custom sort field first',
clean_custom_sort: 'Clean'
},
dataset: {
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',

View File

@ -1095,7 +1095,10 @@ export default {
unit_hundred_million: '億',
formatter_decimal_count_error: '請輸入0-10的整數',
gauge_threshold_compare_error: '阈值範圍需逐級遞增',
tick_count: '刻度間隔數'
tick_count: '刻度間隔數',
custom_sort: '自定義排序',
custom_sort_tip: '自定義排序優先級高於字段排序',
clean_custom_sort: '清除自定義排序'
},
dataset: {
sheet_warn: '有多個 Sheet 頁,默認抽取第一個',

View File

@ -1097,7 +1097,10 @@ export default {
unit_hundred_million: '亿',
formatter_decimal_count_error: '请输入0-10的整数',
gauge_threshold_compare_error: '阈值范围需逐级递增',
tick_count: '刻度间隔数'
tick_count: '刻度间隔数',
custom_sort: '自定义排序',
custom_sort_tip: '自定义排序优先级高于字段排序',
clean_custom_sort: '清除自定义排序'
},
dataset: {
sheet_warn: '有多个 Sheet 页,默认抽取第一个',

View File

@ -10,6 +10,7 @@ import {
getSlider,
getAnalyse
} from '@/views/chart/chart/common/common_antv'
import { customSort } from '@/views/chart/chart/util'
export function baseBarOptionAntV(plot, container, chart, action, isGroup, isStack) {
// theme
@ -22,7 +23,13 @@ export function baseBarOptionAntV(plot, container, chart, action, isGroup, isSta
const xAxis = getXAxis(chart)
const yAxis = getYAxis(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)
@ -122,7 +129,13 @@ export function hBaseBarOptionAntV(plot, container, chart, action, isGroup, isSt
const xAxis = getXAxis(chart)
const yAxis = getYAxis(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)

View File

@ -1,5 +1,6 @@
import { getLabel, getLegend, getPadding, getTheme, getTooltip } from '@/views/chart/chart/common/common_antv'
import { Funnel } from '@antv/g2plot'
import { customSort } from '@/views/chart/chart/util'
export function baseFunnelOptionAntV(plot, container, chart, action) {
// theme
@ -10,7 +11,13 @@ export function baseFunnelOptionAntV(plot, container, chart, action) {
// style
const legend = getLegend(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// options
const options = {
theme: theme,

View File

@ -10,6 +10,7 @@ import {
getSlider,
getAnalyse
} from '@/views/chart/chart/common/common_antv'
import { customSort } from '@/views/chart/chart/util'
export function baseLineOptionAntV(plot, container, chart, action) {
// theme
@ -22,7 +23,13 @@ export function baseLineOptionAntV(plot, container, chart, action) {
const xAxis = getXAxis(chart)
const yAxis = getYAxis(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)
@ -114,7 +121,13 @@ export function baseAreaOptionAntV(plot, container, chart, action) {
const xAxis = getXAxis(chart)
const yAxis = getYAxis(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)

View File

@ -7,6 +7,7 @@ import {
} from '@/views/chart/chart/common/common_antv'
import { Pie, Rose } from '@antv/g2plot'
import { customSort } from '@/views/chart/chart/util'
export function basePieOptionAntV(plot, container, chart, action) {
// theme
@ -17,7 +18,13 @@ export function basePieOptionAntV(plot, container, chart, action) {
// style
const legend = getLegend(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// options
const options = {
theme: theme,
@ -106,7 +113,13 @@ export function basePieRoseOptionAntV(plot, container, chart, action) {
// style
const legend = getLegend(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// options
const options = {
theme: theme,

View File

@ -1,5 +1,6 @@
import { getLabel, getLegend, getPadding, getTheme, getTooltip } from '@/views/chart/chart/common/common_antv'
import { Radar } from '@antv/g2plot'
import { customSort } from '@/views/chart/chart/util'
export function baseRadarOptionAntV(plot, container, chart, action) {
// theme
@ -10,7 +11,14 @@ export function baseRadarOptionAntV(plot, container, chart, action) {
// style
const legend = getLegend(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
const xAxis = {
tickLine: null,
line: null

View File

@ -11,6 +11,7 @@ import {
} from '@/views/chart/chart/common/common_antv'
import { Scatter } from '@antv/g2plot'
import { customSort } from '@/views/chart/chart/util'
export function baseScatterOptionAntV(plot, container, chart, action) {
// theme
@ -23,7 +24,13 @@ export function baseScatterOptionAntV(plot, container, chart, action) {
const xAxis = getXAxis(chart)
const yAxis = getYAxis(chart)
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)

View File

@ -321,3 +321,36 @@ export const TYPE_CONFIGS = [
icon: 'map'
}
]
export function customSort(custom, data) {
const indexArr = []
const joinArr = []
for (let i = 0; i < custom.length; i++) {
const ele = custom[i]
for (let j = 0; j < data.length; j++) {
const d = data[j]
if (ele === d.field) {
joinArr.push(d)
indexArr.push(j)
}
}
}
// 取得 joinArr 就是两者的交集
const indexArrData = []
for (let i = 0; i < data.length; i++) {
indexArrData.push(i)
}
const indexResult = []
for (let i = 0; i < indexArrData.length; i++) {
if (indexArr.indexOf(indexArrData[i]) === -1) {
indexResult.push(indexArrData[i])
}
}
const subArr = []
for (let i = 0; i < indexResult.length; i++) {
subArr.push(data[indexResult[i]])
}
return joinArr.concat(subArr)
}

View File

@ -8,6 +8,7 @@ import {
getYAxis
} from '@/views/chart/chart/common/common_antv'
import { Waterfall } from '@antv/g2plot'
import { customSort } from '@/views/chart/chart/util'
export function baseWaterfallOptionAntV(plot, container, chart, action) {
// theme
@ -27,7 +28,13 @@ export function baseWaterfallOptionAntV(plot, container, chart, action) {
delete yAxis.maxLimit
}
// data
const data = chart.data.datas
let data
const cus = JSON.parse(chart.customSort)
if (cus && cus.length > 0) {
data = customSort(cus, chart.data.datas)
} else {
data = chart.data.datas
}
// total
const total = {
label: '合计',

View File

@ -0,0 +1,125 @@
<template>
<div>
<draggable
v-model="sortList"
group="drag"
animation="300"
:move="onMove"
class="drag-list"
@update="onUpdate"
>
<transition-group class="draggable-group">
<span v-for="(item,index) in sortList" :key="index" class="item-dimension" :title="item">
{{ item }}
</span>
</transition-group>
</draggable>
<p style="margin-top: 10px;color:#F56C6C;font-size: 12px;">{{ $t('chart.custom_sort_tip') }}</p>
</div>
</template>
<script>
import { customSort } from '@/views/chart/chart/util'
export default {
name: 'CustomSortEdit',
props: {
chart: {
type: Object,
required: true
}
},
data() {
return {
sortList: []
}
},
watch: {
chart() {
this.init()
}
},
mounted() {
this.init()
},
methods: {
init() {
console.log(this.chart)
const chart = JSON.parse(JSON.stringify(this.chart))
let customSortData
if (Object.prototype.toString.call(chart.customSort) === '[object Array]') {
customSortData = JSON.parse(JSON.stringify(chart.customSort))
} else {
customSortData = JSON.parse(chart.customSort)
}
if (!customSortData || customSortData.length === 0) {
if (chart && chart.data) {
const data = chart.data.datas
data.forEach(ele => {
this.sortList.push(ele.field)
})
}
} else {
if (chart && chart.data) {
const data = chart.data.datas
const cus = customSort(customSortData, data)
cus.forEach(ele => {
this.sortList.push(ele.field)
})
}
}
},
onMove() {
},
onUpdate() {
this.$emit('onSortChange', this.sortList)
}
}
}
</script>
<style scoped>
.drag-list {
overflow: auto;
height: 50vh;
}
.item-dimension {
padding: 2px 10px;
margin: 2px 2px 0 2px;
border: solid 1px #eee;
text-align: left;
color: #606266;
/*background-color: rgba(35,46,64,.05);*/
background-color: white;
display: block;
word-break: break-all;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.blackTheme .item-dimension {
border: solid 1px;
border-color: var(--TableBorderColor);
color: var(--TextPrimary);
background-color: var(--MainBG);
}
.item-dimension + .item-dimension {
margin-top: 6px;
}
.item-dimension:hover {
color: #1890ff;
background: #e8f4ff;
border-color: #a3d3ff;
cursor: pointer;
}
.blackTheme .item-dimension:hover {
color: var(--Main);
background: var(--ContentBG);
cursor: pointer;
}
</style>

View File

@ -347,6 +347,15 @@
<span
v-else-if="view.type && view.type === 'table-info'"
>{{ $t('chart.dimension_or_quota') }}</span>
<!--自定义排序-->
<i
v-if="false && view.render === 'antv' && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('funnel') || view.type.includes('pie') || view.type.includes('radar') || view.type.includes('scatter') || view.type.includes('waterfall'))"
style="margin-left: 4px;cursor: pointer;"
class="el-icon-sort"
:title="$t('chart.custom_sort')"
@click="customSort"
/>
</span>
<draggable
v-model="view.xaxis"
@ -355,7 +364,8 @@
:move="onMove"
class="drag-block-style"
@add="addXaxis"
@update="calcData(true)"
@update="resetCustomSort"
@remove="resetCustomSort"
>
<transition-group class="draggable-group">
<dimension-item
@ -681,7 +691,12 @@
<span class="padding-lr">{{ $t('chart.shape_attr') }}</span>
<el-collapse v-model="attrActiveNames" class="style-collapse">
<el-collapse-item name="color" :title="$t('chart.color')">
<color-selector :param="param" class="attr-selector" :chart="chart" @onColorChange="onColorChange" />
<color-selector
:param="param"
class="attr-selector"
:chart="chart"
@onColorChange="onColorChange"
/>
</el-collapse-item>
<el-collapse-item
v-show="view.render && view.render === 'echarts' && chart.type !== 'map' && chart.type !== 'waterfall' && chart.type !== 'word-cloud'"
@ -1158,6 +1173,25 @@
<el-button type="primary" size="mini" @click="saveValueFormatter">{{ $t('chart.confirm') }}</el-button>
</div>
</el-dialog>
<!--自定义排序-->
<el-dialog
v-if="showCustomSort"
v-dialogDrag
:title="$t('chart.custom_sort')"
:visible="showCustomSort"
:show-close="false"
width="500px"
class="dialog-css"
>
<!-- <value-formatter-edit :formatter-item="valueFormatterItem" :chart="chart" />-->
<custom-sort-edit :chart="chart" @onSortChange="customSortChange" />
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeCustomSort">{{ $t('chart.cancel') }}</el-button>
<el-button size="mini" @click="resetCustomSort">{{ $t('chart.clean_custom_sort') }}</el-button>
<el-button type="primary" size="mini" @click="saveCustomSort">{{ $t('chart.confirm') }}</el-button>
</div>
</el-dialog>
</el-row>
</template>
@ -1240,9 +1274,11 @@ import TotalCfg from '@/views/chart/components/shape-attr/TotalCfg'
import LabelNormalText from '@/views/chart/components/normal/LabelNormalText'
import { pluginTypes } from '@/api/chart/chart'
import ValueFormatterEdit from '@/views/chart/components/value-formatter/ValueFormatterEdit'
import CustomSortEdit from '@/views/chart/components/compare/CustomSortEdit'
export default {
name: 'ChartEdit',
components: {
CustomSortEdit,
ValueFormatterEdit,
LabelNormalText,
TotalCfg,
@ -1344,7 +1380,8 @@ export default {
},
customFilter: [],
render: 'antv',
isPlugin: false
isPlugin: false,
customSort: []
},
moveId: -1,
chart: {
@ -1395,7 +1432,9 @@ export default {
preChartId: '',
pluginRenderOptions: [],
showValueFormatter: false,
valueFormatterItem: {}
valueFormatterItem: {},
showCustomSort: false,
customSortList: []
}
},
@ -1488,6 +1527,7 @@ export default {
this.resetDrill()
this.initFromPanel()
this.getChart(this.param.id)
this.getData(this.param.id)
},
bindPluginEvent() {
bus.$on('show-dimension-edit-filter', this.showDimensionEditFilter)
@ -1754,6 +1794,7 @@ export default {
view.drillFields = JSON.stringify(view.drillFields)
view.extBubble = JSON.stringify(view.extBubble)
view.senior = JSON.stringify(view.senior)
view.customSort = JSON.stringify(view.customSort)
delete view.data
return view
},
@ -1804,6 +1845,7 @@ export default {
const view = this.buildParam(true, 'chart', false, switchType)
if (!view) return
viewEditSave(this.panelInfo.id, view).then(() => {
this.getData(this.param.id)
bus.$emit('view-in-cache', { type: 'propChange', viewId: this.param.id })
})
},
@ -1822,6 +1864,7 @@ export default {
view.customStyle = JSON.stringify(this.view.customStyle)
view.customFilter = JSON.stringify(this.view.customFilter)
view.senior = JSON.stringify(this.view.senior)
view.customSort = JSON.stringify(this.view.customSort)
view.title = this.view.title
view.stylePriority = this.view.stylePriority
// view.data = this.data
@ -1867,12 +1910,12 @@ export default {
}
},
getData(id) {
this.hasEdit = false
// this.hasEdit = true
if (id) {
ajaxGetDataOnly(id, this.panelInfo.id, {
filter: [],
drill: this.drillClickDimensionList,
queryFrom: 'panelEdit'
queryFrom: 'panel'
}).then(response => {
this.initTableData(response.data.tableId)
this.view = JSON.parse(JSON.stringify(response.data))
@ -1887,6 +1930,7 @@ export default {
this.view.customStyle = this.view.customStyle ? JSON.parse(this.view.customStyle) : {}
this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {}
this.view.senior = this.view.senior ? JSON.parse(this.view.senior) : {}
this.view.customSort = this.view.customSort ? JSON.parse(this.view.customSort) : []
// echart
this.chart = response.data
this.data = response.data.data
@ -1938,6 +1982,7 @@ export default {
this.view.customStyle = this.view.customStyle ? JSON.parse(this.view.customStyle) : {}
this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {}
this.view.senior = this.view.senior ? JSON.parse(this.view.senior) : {}
this.view.customSort = this.view.customSort ? JSON.parse(this.view.customSort) : []
// echart
this.chart = response.data
@ -2337,7 +2382,7 @@ export default {
if ((this.view.type === 'map' || this.view.type === 'word-cloud' || this.view.type === 'label') && this.view.xaxis.length > 1) {
this.view.xaxis = [this.view.xaxis[0]]
}
this.calcData(true)
this.resetCustomSort()
},
addXaxisExt(e) {
if (this.view.type !== 'table-info') {
@ -2460,12 +2505,12 @@ export default {
if (this.chart.type === 'map' || this.chart.type === 'buddle-map') {
if (this.sendToChildren(param)) {
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
// this.getData(this.param.id)
this.getData(this.param.id)
this.calcData(true, 'chart', false, false)
}
} else {
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
// this.getData(this.param.id)
this.getData(this.param.id)
this.calcData(true, 'chart', false, false)
}
} else if (this.view.drillFields.length > 0) {
@ -2500,7 +2545,7 @@ export default {
this.backToParent(index, length)
}
// this.getData(this.param.id)
this.getData(this.param.id)
this.calcData(true, 'chart', false, false)
},
//
@ -2583,6 +2628,7 @@ export default {
resetViewCacheCallBack(_this.param.id, _this.panelInfo.id, function(rsp) {
_this.changeEditStatus(false)
_this.getChart(_this.param.id, 'panel')
_this.getData(_this.param.id)
bus.$emit('view-in-cache', { type: 'propChange', viewId: _this.param.id })
})
},
@ -2647,6 +2693,27 @@ export default {
}
this.calcData(true)
this.closeValueFormatter()
},
customSort() {
this.showCustomSort = true
},
customSortChange(val) {
this.customSortList = val
},
closeCustomSort() {
this.showCustomSort = false
},
saveCustomSort() {
this.view.customSort = JSON.parse(JSON.stringify(this.customSortList))
this.calcData(true)
this.closeCustomSort()
},
resetCustomSort() {
this.chart.customSort = []
this.view.customSort = []
this.calcData(true)
this.closeCustomSort()
}
}
}