Merge branch 'dev-v2' into pr@dev-v2@perf_i18n

This commit is contained in:
fit2cloud-chenyw
2024-12-04 09:26:07 +08:00
10 changed files with 86 additions and 37 deletions

View File

@@ -413,7 +413,7 @@ public class ChartViewThresholdManage {
DatasetTableFieldDTO field = item.getField();
String dataeaseName = field.getDataeaseName();
String value = item.getValue();
float tempFVal = 0f;
Float tempFVal = StringUtils.equalsAny(value, "min", "max") ? null : 0f;
int validLen = 0;
for (Map<String, Object> row : rows) {
@@ -421,9 +421,17 @@ public class ChartViewThresholdManage {
if (ObjectUtils.isEmpty(o)) continue;
float fvalue = Float.parseFloat(o.toString());
if (StringUtils.equals("min", value)) {
tempFVal = Math.min(tempFVal, fvalue);
if (ObjectUtils.isEmpty(tempFVal)) {
tempFVal = fvalue;
} else {
tempFVal = Math.min(tempFVal, fvalue);
}
} else if (StringUtils.equals("max", value)) {
tempFVal = Math.max(tempFVal, fvalue);
if (ObjectUtils.isEmpty(tempFVal)) {
tempFVal = fvalue;
} else {
tempFVal = Math.max(tempFVal, fvalue);
}
} else if (StringUtils.equals("average", value)) {
tempFVal += fvalue;
validLen++;

View File

@@ -19,7 +19,7 @@
<el-input
v-model="state.form.appName"
autocomplete="off"
:placeholder="t('visualization.input_name')"
:placeholder="t('common.input_name')"
/>
</el-form-item>
<el-form-item :label="t('visualization.app_version')" prop="version">

View File

@@ -1,6 +1,6 @@
<template>
<div
v-if="existLinkage && !dvMainStore.mobileInPc"
v-if="existLinkage && (!dvMainStore.mobileInPc || isMobile())"
class="bar-main-right"
:class="{ 'bar-main-edit-right': dvEditMode }"
@mousedown="handOptBarMousedown"
@@ -19,7 +19,7 @@ import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { computed } from 'vue'
import { isMainCanvas } from '@/utils/canvasUtils'
import { useEmitt } from '@/hooks/web/useEmitt'
import { isMobile } from '@/utils/utils'
const dvMainStore = dvMainStoreWithOut()
const props = defineProps({
@@ -49,7 +49,7 @@ const clearAllLinkage = () => {
}
const dvEditMode = computed(() => {
return dvMainStore.dvInfo.type === 'dataV' && dvMainStore.editMode === 'preview'
return dvMainStore.dvInfo.type === 'dataV' && dvMainStore.editMode === 'preview' && !isMobile()
})
const existLinkage = computed(() => {
if (isMainCanvas(props.canvasId)) {

View File

@@ -148,6 +148,7 @@ onBeforeUnmount(() => {
<el-form-item
v-if="curComponent.style.adaptation"
class="form-item form-item-custom"
:class="'form-item-' + themes"
:label="t('visualization.pic_adaptor_type')"
size="small"
:effect="themes"

View File

@@ -1188,6 +1188,9 @@ span {
background: #f5f6f7;
&.field-style-dark {
background: #1a1a1a;
:deep(.field-text) {
color: #a6a6a6;
}
}
}
}

View File

@@ -917,6 +917,7 @@ const onTypeChange = (render, type) => {
view.value.render = render
view.value.type = type
emitter.emit('chart-type-change')
emitter.emit('chart-type-change-' + view.value.id)
// 处理配置项默认值,不同图表的同一配置项默认值不同
const chartViewInstance = chartViewManager.getChartView(view.value.render, view.value.type)
if (chartViewInstance) {

View File

@@ -1505,7 +1505,7 @@ export function configMergeCells(chart: Chart, options: S2Options, dataConfig: S
showText: j === textIndex
})
}
if (index === end) {
if (index === end && lastVal === curVal) {
tmpMergeCells.push({
colIndex: showIndex ? i + 1 : i,
rowIndex: index,
@@ -1513,7 +1513,7 @@ export function configMergeCells(chart: Chart, options: S2Options, dataConfig: S
})
}
mergedCellsInfo.push(tmpMergeCells)
curMergedColInfo.push([lastIndex, index === end ? index : index - 1])
curMergedColInfo.push([lastIndex, index === end && lastVal === curVal ? index : index - 1])
}
lastVal = curVal
lastIndex = index

View File

@@ -456,8 +456,12 @@ export const getGeoJsonFile = async (areaId: string): Promise<FeatureCollection>
return toRaw(geoJson)
}
const getExcelDownloadRequest = data => {
const fields = JSON.parse(JSON.stringify(data.fields))
const getExcelDownloadRequest = (data, type?) => {
let fields = JSON.parse(JSON.stringify(data.fields))
// liquid gauge 只需要导出一个字段
if (['gauge', 'liquid'].includes(type) && fields.length > 1) {
fields = fields.slice(1)
}
const tableRow = JSON.parse(JSON.stringify(data.tableRow))
const excelHeader = fields.map(item => item.chartShowName ?? item.name)
const excelTypes = fields.map(item => item.deType)
@@ -516,7 +520,7 @@ export const exportExcelDownload = (chart, callBack?) => {
delete request.multiInfo
}
} else {
const req = getExcelDownloadRequest(chart.data)
const req = getExcelDownloadRequest(chart.data, chart.type)
request = {
...request,
...req

View File

@@ -54,6 +54,7 @@ import { viewFieldTimeTrans } from '@/utils/viewUtils'
import { CHART_TYPE_CONFIGS } from '@/views/chart/components/editor/util/chart'
import request from '@/config/axios'
import { store } from '@/store'
import { clearExtremum } from '@/views/chart/components/js/extremumUitl'
const { wsCache } = useCache()
const chartComponent = ref<any>()
@@ -138,8 +139,7 @@ const props = defineProps({
}
})
const dynamicAreaId = ref('')
const { view, showPosition, element, active, searchCount, scale } = toRefs(props)
const { view, showPosition, element, active, searchCount, scale, suffixId } = toRefs(props)
const titleShow = computed(() => {
return (
!['rich-text', 'picture-group'].includes(element.value.innerType) &&
@@ -617,6 +617,8 @@ onBeforeMount(() => {
const listenerEnable = computed(() => {
return !showPosition.value.includes('viewDialog')
})
// 存储所有数据集字段,用于判断图表拖入的字段是否存在
const viewAllDatasetFields = new Map()
const showEmpty = ref(false)
const checkFieldIsAllowEmpty = (allField?) => {
showEmpty.value = false
@@ -632,47 +634,68 @@ const checkFieldIsAllowEmpty = (allField?) => {
return
}
const axisConfigMap = new Map(Object.entries(chartView.axisConfig))
// 验证拖入的字段是否包含在当前数据集字段中,如果一个不在数据集字段中,则显示空图表
// 验证拖入的字段是否包含在当前数据集字段中,如果一个不在数据集字段中,则显示空图表
let includeDatasetField = false
if (allField && allField.length > 0) {
axisConfigMap.forEach((value, key) => {
if (view.value?.[key]?.length > 0) {
view.value[key].forEach(item => {
if (!allField.find(field => field.id === item.id)) {
includeDatasetField = true
return false
}
})
if (includeDatasetField) {
return false
viewAllDatasetFields.set(view.value.id, allField)
outerLoop: for (const [key, value] of axisConfigMap) {
// 只判断必须的
if (value['allowEmpty']) continue
if (!view.value?.[key]?.length) continue
for (const item of view.value[key]) {
if (!allField.find(field => field.id === item.id)) {
includeDatasetField = true
break outerLoop
}
}
})
}
}
if (includeDatasetField) {
showEmpty.value = true
return
}
axisConfigMap.forEach((value, key) => {
// 允许为空,并且没限制长度
if (!value['allowEmpty'] && !value['limit'] && view.value?.[key]?.length === 0) {
showEmpty.value = true
return false
for (const [key, value] of axisConfigMap) {
// 跳过允许为空的配置项
if (value['allowEmpty']) continue
// 如果有数据集字段并且字段值存在且不为空
if (viewAllDatasetFields.get(view.value?.id)) {
if (!view.value?.[key]?.length) continue
// 检查图表字段是否有不在数据集中
for (const item of view.value[key]) {
if (!viewAllDatasetFields.get(view.value?.id).find(field => field.id === item.id)) {
includeDatasetField = true
break
}
}
// 如果有不在数据集中
if (includeDatasetField) {
showEmpty.value = true
break
}
}
// 不允许为空, 限制长度
// 如果没有限制长度,且值为空,标记为空并跳出
if (!value['limit'] && view.value?.[key]?.length === 0) {
showEmpty.value = true
break
}
// 如果有限制长度,且字段长度不足,标记为空并跳出
if (
!value['allowEmpty'] &&
value['limit'] &&
(!view.value?.[key] || view.value?.[key]?.length < parseInt(value['limit']))
) {
showEmpty.value = true
return false
break
}
// 如果是table-info类型且字段为空标记为空并跳出
if (view.value?.type === 'table-info' && view.value?.[key]?.length === 0) {
showEmpty.value = true
return false
break
}
})
}
}
}
const changeChartType = () => {
@@ -793,6 +816,15 @@ onMounted(() => {
initTitle()
}
})
useEmitt({
name: 'chart-type-change-' + view.value.id,
callback: () => {
const chart = cloneDeep(view.value)
chart.container =
'container-' + showPosition.value + '-' + view.value.id + '-' + suffixId.value
clearExtremum(chart)
}
})
const { refreshViewEnable, refreshUnit, refreshTime } = view.value
buildInnerRefreshTimer(refreshViewEnable, refreshUnit, refreshTime)