From 97a3d24939544e384dfa0af0914d25b166ec4d9d Mon Sep 17 00:00:00 2001 From: huanghao1412 Date: Thu, 1 Feb 2024 18:52:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commonDataComponents/usePointTableRes.ts | 17 +++ src/hooks/useChartCommonData.hook.ts | 7 ++ .../Tables/Tables/TablesBasic/config.ts | 13 ++- .../Tables/Tables/TablesBasic/config.vue | 105 ++++++++++++------ .../Tables/Tables/TablesBasic/index.vue | 40 ++++++- .../components/Tables/Tables/index.ts | 2 +- src/packages/index.d.ts | 2 +- src/packages/index.ts | 4 +- src/packages/public/publicConfig.ts | 4 + .../chartEditStore/chartEditStore.d.ts | 11 +- .../ChartDataV2/components/PointTable.vue | 84 ++++++++++++++ .../components/ChartDataV2/index.d.ts | 5 + .../components/ChartDataV2/index.vue | 2 + 13 files changed, 245 insertions(+), 51 deletions(-) create mode 100644 src/hooks/commonDataComponents/usePointTableRes.ts create mode 100644 src/views/chart/ContentConfigurations/components/ChartDataV2/components/PointTable.vue diff --git a/src/hooks/commonDataComponents/usePointTableRes.ts b/src/hooks/commonDataComponents/usePointTableRes.ts new file mode 100644 index 00000000..bcb7ea23 --- /dev/null +++ b/src/hooks/commonDataComponents/usePointTableRes.ts @@ -0,0 +1,17 @@ +import moment from "moment"; +import { publicInterface } from "@/api/path"; +import { DateTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' +import { commonDataType, PointTableType } from '@/store/modules/chartEditStore/chartEditStore.d' +import { CreateComponentType } from '@/packages/index.d' +import { ResultErrcode } from '@/enums/httpEnum' +import dataJson from './data.json' + +export const handlePointTable = (targetComponent: CreateComponentType) => { + let { ids, enable } = (targetComponent.commonData as commonDataType).pointTable as PointTableType + if(!enable) return { + errcode: ResultErrcode.SUCCESS, + data: { ...dataJson }, + errmsg: '' + } + return publicInterface('/dcim/system/custom_large_screen', 'get_table_point_value', ids) +} diff --git a/src/hooks/useChartCommonData.hook.ts b/src/hooks/useChartCommonData.hook.ts index 96b190b2..6c70b4c8 100644 --- a/src/hooks/useChartCommonData.hook.ts +++ b/src/hooks/useChartCommonData.hook.ts @@ -13,6 +13,7 @@ import { handlePointRealTime } from './commonDataComponents/usePointRealTimeRes' import { handleSinglePoint } from './commonDataComponents/useSinglePointRes' import { handleMonthAlarmClass } from './commonDataComponents/useMonthAlarmClassRes' import { handleDeviceClass } from './commonDataComponents/useDeviceClassRes' +import { handlePointTable } from "./commonDataComponents/usePointTableRes"; import { handleNoParam } from './commonDataComponents/useNoParamRes' import { ResultErrcode } from '@/enums/httpEnum' @@ -77,6 +78,9 @@ export const useChartCommonData = ( } } } + else if(chartFrame === ChartFrameEnum.COMMON) { + targetComponent.option.dataset = dataset + } } let stopWatch = false const requestIntervalFn = () => { @@ -122,6 +126,9 @@ export const useChartCommonData = ( case CurrentSourceEnum.DEVICECLASS: res = await handleDeviceClass(targetComponent) break; + case CurrentSourceEnum.POINTTABLE: + res = await handlePointTable(targetComponent) + break; default: // res = await handleNoParam(targetComponent) break; diff --git a/src/packages/components/Tables/Tables/TablesBasic/config.ts b/src/packages/components/Tables/Tables/TablesBasic/config.ts index f1151226..f14ee32c 100644 --- a/src/packages/components/Tables/Tables/TablesBasic/config.ts +++ b/src/packages/components/Tables/Tables/TablesBasic/config.ts @@ -7,21 +7,26 @@ import dataJson from './data.json' const { dimensions, source } = dataJson export const option = { - dataset: { dimensions, source }, + dataset: { dimensions: [], source: [] }, + // 展示列 + header: { + value: [], + options: [] + }, pagination: { page: 1, pageSize: 5 }, align: 'center', style: { - border: 'on', + border: 'off', singleColumn: 'off', singleLine: 'off', - bottomBordered: 'on', + bottomBordered: 'off', striped: 'on', fontSize: 16, borderWidth: 0, - borderColor: 'black', + borderColor: 'rgba(0, 0, 0, 1)', borderStyle: 'solid' }, inputShow: 'none' diff --git a/src/packages/components/Tables/Tables/TablesBasic/config.vue b/src/packages/components/Tables/Tables/TablesBasic/config.vue index 9e8369ae..6ee0f7aa 100644 --- a/src/packages/components/Tables/Tables/TablesBasic/config.vue +++ b/src/packages/components/Tables/Tables/TablesBasic/config.vue @@ -1,6 +1,19 @@ @@ -36,6 +37,9 @@ import { computed, PropType, toRefs, watch, reactive, ref } from 'vue' import { CreateComponentType } from '@/packages/index.d' import { icon } from '@/plugins' +import {useChartCommonData} from "@/hooks"; +import {useChartEditStore} from "@/store/modules/chartEditStore/chartEditStore"; +import { cloneDeep } from 'lodash' const props = defineProps({ chartConfig: { @@ -67,22 +71,48 @@ const { w, h } = toRefs(props.chartConfig.attr) const option = reactive({ dataset: props.chartConfig.option.dataset, - style: props.chartConfig.option.style + style: props.chartConfig.option.style, + header: props.chartConfig.option.header }) watch( () => props.chartConfig.option.dataset, (newData: any) => { option.dataset = newData - option?.dataset?.dimensions?.forEach((header: any) => { - header.align = align.value - }) + option.header.value = newData.dimensions + console.log(newData.dimensions.toString(), option.header.options.map((_: {value: string}) => _.value).toString()) + if(newData.dimensions.toString() === option.header.options.map((_: {value: string}) => _.value).toString()) return + option.header.options = newData.dimensions.map((_: string) => ({label: _, value: _})) + // option?.dataset?.dimensions?.forEach((header: any) => { + // header.align = align.value + // }) }, { immediate: true, deep: true } ) + +watch(() => props.chartConfig.option.header, v => { + option.header = v +}, { + immediate: true, + deep: true +}) + +const columns = computed(() => { + let dimensions = option.header.options.filter((_: {label: string, value: string}) => option.header.value.includes(_.value)) + dimensions = dimensions.map((_: {label: string, value: string}) => { + return { + title: _.label, + key: _.value, + align: align.value + } + }) + return dimensions +}) + +useChartCommonData(props.chartConfig, useChartEditStore) diff --git a/src/views/chart/ContentConfigurations/components/ChartDataV2/index.d.ts b/src/views/chart/ContentConfigurations/components/ChartDataV2/index.d.ts index f734400a..c52adb3b 100644 --- a/src/views/chart/ContentConfigurations/components/ChartDataV2/index.d.ts +++ b/src/views/chart/ContentConfigurations/components/ChartDataV2/index.d.ts @@ -155,6 +155,11 @@ export const sourceOptions: sourceOptionsItemType[] = [ value: CurrentSourceEnum.MONTHALARMCLASS, type: optionTypeEnum.MULTIPLE, }, + { + label: '测点表格值', + value: CurrentSourceEnum.POINTTABLE, + type: optionTypeEnum.MULTIPLE, + }, { label: '单测点实时值', value: CurrentSourceEnum.SINGLEPOINT, diff --git a/src/views/chart/ContentConfigurations/components/ChartDataV2/index.vue b/src/views/chart/ContentConfigurations/components/ChartDataV2/index.vue index f3df6eca..9e4a0c46 100644 --- a/src/views/chart/ContentConfigurations/components/ChartDataV2/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartDataV2/index.vue @@ -10,6 +10,7 @@ +