Commit 3ed9be764e7475433ed2386654df1e6c316522b6
1 parent
295b2782
perf: adjust modal width && link visual options and component config
Showing
13 changed files
with
124 additions
and
67 deletions
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | - import { computed } from 'vue'; | 2 | + import { computed, unref } from 'vue'; | 
| 3 | import { Space, Tooltip } from 'ant-design-vue'; | 3 | import { Space, Tooltip } from 'ant-design-vue'; | 
| 4 | - import type { DigitalDashBoardLayout, DigitalDashBoardValue } from './digitalDashBoard.config'; | 4 | + import { | 
| 5 | + DigitalComponentDefaultConfig, | ||
| 6 | + DigitalDashBoardLayout, | ||
| 7 | + DigitalDashBoardValue, | ||
| 8 | + } from './digitalDashBoard.config'; | ||
| 5 | import { dateUtil } from '/@/utils/dateUtil'; | 9 | import { dateUtil } from '/@/utils/dateUtil'; | 
| 6 | import { | 10 | import { | 
| 7 | fontSize, | 11 | fontSize, | 
| @@ -9,6 +13,7 @@ | @@ -9,6 +13,7 @@ | ||
| 9 | DEFAULT_DATE_FORMAT, | 13 | DEFAULT_DATE_FORMAT, | 
| 10 | DEFAULT_RADIO_RECORD, | 14 | DEFAULT_RADIO_RECORD, | 
| 11 | } from '../../detail/config/util'; | 15 | } from '../../detail/config/util'; | 
| 16 | + import { isNaN } from 'lodash'; | ||
| 12 | 17 | ||
| 13 | const props = defineProps<{ | 18 | const props = defineProps<{ | 
| 14 | layout: DigitalDashBoardLayout; | 19 | layout: DigitalDashBoardLayout; | 
| @@ -16,8 +21,12 @@ | @@ -16,8 +21,12 @@ | ||
| 16 | radio?: RadioRecord; | 21 | radio?: RadioRecord; | 
| 17 | }>(); | 22 | }>(); | 
| 18 | 23 | ||
| 24 | + const getPropsValue = computed(() => { | ||
| 25 | + return { ...DigitalComponentDefaultConfig, ...props.value }; | ||
| 26 | + }); | ||
| 27 | + | ||
| 19 | const integerPart = computed(() => { | 28 | const integerPart = computed(() => { | 
| 20 | - let { value = 0 } = props.value; | 29 | + let { value = 0 } = unref(getPropsValue); | 
| 21 | const { max = 5 } = props.layout; | 30 | const { max = 5 } = props.layout; | 
| 22 | if (isNaN(value)) value = 0; | 31 | if (isNaN(value)) value = 0; | 
| 23 | let _value = Number(value).toFixed(2).split('.')[0]; | 32 | let _value = Number(value).toFixed(2).split('.')[0]; | 
| @@ -28,7 +37,7 @@ | @@ -28,7 +37,7 @@ | ||
| 28 | }); | 37 | }); | 
| 29 | 38 | ||
| 30 | const decimalPart = computed(() => { | 39 | const decimalPart = computed(() => { | 
| 31 | - let { value = 0 } = props.value; | 40 | + let { value = 0 } = unref(getPropsValue); | 
| 32 | const { keepNumber = 2 } = props.layout; | 41 | const { keepNumber = 2 } = props.layout; | 
| 33 | if (isNaN(value)) value = 0; | 42 | if (isNaN(value)) value = 0; | 
| 34 | let _value = Number(value)?.toFixed(2).split('.')[1]; | 43 | let _value = Number(value)?.toFixed(2).split('.')[1]; | 
| @@ -56,7 +65,7 @@ | @@ -56,7 +65,7 @@ | ||
| 56 | :key="number" | 65 | :key="number" | 
| 57 | class="border border-gray-400 p-2" | 66 | class="border border-gray-400 p-2" | 
| 58 | :style="{ | 67 | :style="{ | 
| 59 | - color: props.value.fontColor, | 68 | + color: getPropsValue.fontColor, | 
| 60 | fontSize: fontSize({ radio: getRadio, basic: 20 }), | 69 | fontSize: fontSize({ radio: getRadio, basic: 20 }), | 
| 61 | }" | 70 | }" | 
| 62 | > | 71 | > | 
| @@ -69,7 +78,7 @@ | @@ -69,7 +78,7 @@ | ||
| 69 | :key="number" | 78 | :key="number" | 
| 70 | class="border border-gray-400 p-1" | 79 | class="border border-gray-400 p-1" | 
| 71 | :style="{ | 80 | :style="{ | 
| 72 | - color: props.value.fontColor, | 81 | + color: getPropsValue.fontColor, | 
| 73 | fontSize: fontSize({ radio: getRadio, basic: 18 }), | 82 | fontSize: fontSize({ radio: getRadio, basic: 18 }), | 
| 74 | }" | 83 | }" | 
| 75 | > | 84 | > | 
| @@ -84,7 +93,7 @@ | @@ -84,7 +93,7 @@ | ||
| 84 | :style="{ fontSize: fontSize({ radio: getRadio, basic: 18 }) }" | 93 | :style="{ fontSize: fontSize({ radio: getRadio, basic: 18 }) }" | 
| 85 | > | 94 | > | 
| 86 | <span>{{ props.value.name || '电表' }}</span> | 95 | <span>{{ props.value.name || '电表' }}</span> | 
| 87 | - <span class="px-1">({{ 'kw/h' }})</span> | 96 | + <span class="px-1">({{ getPropsValue.unit }})</span> | 
| 88 | </div> | 97 | </div> | 
| 89 | <div | 98 | <div | 
| 90 | class="text-center mt-1 text-gray-400 text-xs truncate" | 99 | class="text-center mt-1 text-gray-400 text-xs truncate" | 
| 1 | import { EChartsOption } from 'echarts'; | 1 | import { EChartsOption } from 'echarts'; | 
| 2 | import { fontSize } from '../../detail/config/util'; | 2 | import { fontSize } from '../../detail/config/util'; | 
| 3 | import { Gradient, visualOptionField } from '../../detail/config/visualOptions'; | 3 | import { Gradient, visualOptionField } from '../../detail/config/visualOptions'; | 
| 4 | -import { DataComponentRecord, DataSource, GradientInfo } from '/@/api/dataBoard/model'; | 4 | +import { | 
| 5 | + ComponentInfo, | ||
| 6 | + DataComponentRecord, | ||
| 7 | + DataSource, | ||
| 8 | + GradientInfo, | ||
| 9 | +} from '/@/api/dataBoard/model'; | ||
| 5 | import { isArray } from '/@/utils/is'; | 10 | import { isArray } from '/@/utils/is'; | 
| 6 | import { buildUUID } from '/@/utils/uuid'; | 11 | import { buildUUID } from '/@/utils/uuid'; | 
| 7 | 12 | ||
| @@ -36,11 +41,13 @@ export interface DashboardComponentLayout { | @@ -36,11 +41,13 @@ export interface DashboardComponentLayout { | ||
| 36 | componentType: InstrumentComponentType; | 41 | componentType: InstrumentComponentType; | 
| 37 | } | 42 | } | 
| 38 | 43 | ||
| 39 | -export const instrumentComponent1 = (params?: { | ||
| 40 | - value: number; | ||
| 41 | - unit: string; | ||
| 42 | - fontColor: string; | ||
| 43 | -}): EChartsOption => { | 44 | +export enum GradientColor { | 
| 45 | + FIRST = '#67e0e3', | ||
| 46 | + SECOND = '#37a2da', | ||
| 47 | + THIRD = '#fd666d', | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +export const instrumentComponent1 = (params?: Partial<ComponentInfo>): EChartsOption => { | ||
| 44 | const { value = 10, unit = '°C' } = params || {}; | 51 | const { value = 10, unit = '°C' } = params || {}; | 
| 45 | return { | 52 | return { | 
| 46 | series: [ | 53 | series: [ | 
| @@ -108,7 +115,7 @@ export const instrumentComponent1 = (params?: { | @@ -108,7 +115,7 @@ export const instrumentComponent1 = (params?: { | ||
| 108 | }, | 115 | }, | 
| 109 | data: [ | 116 | data: [ | 
| 110 | { | 117 | { | 
| 111 | - value: value, | 118 | + value: value as number, | 
| 112 | }, | 119 | }, | 
| 113 | ], | 120 | ], | 
| 114 | }, | 121 | }, | 
| @@ -146,7 +153,7 @@ export const instrumentComponent1 = (params?: { | @@ -146,7 +153,7 @@ export const instrumentComponent1 = (params?: { | ||
| 146 | }, | 153 | }, | 
| 147 | data: [ | 154 | data: [ | 
| 148 | { | 155 | { | 
| 149 | - value: value, | 156 | + value: value as number, | 
| 150 | }, | 157 | }, | 
| 151 | ], | 158 | ], | 
| 152 | }, | 159 | }, | 
| @@ -154,16 +161,11 @@ export const instrumentComponent1 = (params?: { | @@ -154,16 +161,11 @@ export const instrumentComponent1 = (params?: { | ||
| 154 | }; | 161 | }; | 
| 155 | }; | 162 | }; | 
| 156 | 163 | ||
| 157 | -export const instrumentComponent2 = (params?: { | ||
| 158 | - gradient: GradientInfo[]; | ||
| 159 | - value: number; | ||
| 160 | - unit: string; | ||
| 161 | - fontColor: string; | ||
| 162 | -}): EChartsOption => { | ||
| 163 | - const { gradient = [], value = 0, unit = 'km/h' } = params || {}; | ||
| 164 | - const firstRecord = getGradient(Gradient.FIRST, gradient); | ||
| 165 | - const secondRecord = getGradient(Gradient.SECOND, gradient); | ||
| 166 | - const thirdRecord = getGradient(Gradient.THIRD, gradient); | 164 | +export const instrumentComponent2 = (params?: Partial<ComponentInfo>): EChartsOption => { | 
| 165 | + const { gradientInfo = [], value = 0, unit = 'km/h' } = params || {}; | ||
| 166 | + const firstRecord = getGradient(Gradient.FIRST, gradientInfo); | ||
| 167 | + const secondRecord = getGradient(Gradient.SECOND, gradientInfo); | ||
| 168 | + const thirdRecord = getGradient(Gradient.THIRD, gradientInfo); | ||
| 167 | 169 | ||
| 168 | let max = thirdRecord?.value || secondRecord?.value || firstRecord?.value || 70; | 170 | let max = thirdRecord?.value || secondRecord?.value || firstRecord?.value || 70; | 
| 169 | max = Number(1 + Array(String(max).length).fill(0).join('')); | 171 | max = Number(1 + Array(String(max).length).fill(0).join('')); | 
| @@ -182,9 +184,9 @@ export const instrumentComponent2 = (params?: { | @@ -182,9 +184,9 @@ export const instrumentComponent2 = (params?: { | ||
| 182 | lineStyle: { | 184 | lineStyle: { | 
| 183 | width: 20, | 185 | width: 20, | 
| 184 | color: [ | 186 | color: [ | 
| 185 | - [firstGradient, firstRecord?.color || '#67e0e3'], | ||
| 186 | - [secondGradient, secondRecord?.color || '#37a2da'], | ||
| 187 | - [1, thirdRecord?.color || '#fd666d'], | 187 | + [firstGradient, firstRecord?.color || GradientColor.FIRST], | 
| 188 | + [secondGradient, secondRecord?.color || GradientColor.SECOND], | ||
| 189 | + [1, thirdRecord?.color || GradientColor.THIRD], | ||
| 188 | ], | 190 | ], | 
| 189 | }, | 191 | }, | 
| 190 | }, | 192 | }, | 
| @@ -223,7 +225,7 @@ export const instrumentComponent2 = (params?: { | @@ -223,7 +225,7 @@ export const instrumentComponent2 = (params?: { | ||
| 223 | }, | 225 | }, | 
| 224 | data: [ | 226 | data: [ | 
| 225 | { | 227 | { | 
| 226 | - value: value, | 228 | + value: value as number, | 
| 227 | }, | 229 | }, | 
| 228 | ], | 230 | ], | 
| 229 | }, | 231 | }, | 
| @@ -293,14 +295,23 @@ export const update_instrument_2_value = (value) => { | @@ -293,14 +295,23 @@ export const update_instrument_2_value = (value) => { | ||
| 293 | 295 | ||
| 294 | function setGradientInfo(dataSource: DataSource) { | 296 | function setGradientInfo(dataSource: DataSource) { | 
| 295 | const componentInfo = dataSource.componentInfo; | 297 | const componentInfo = dataSource.componentInfo; | 
| 296 | - return instrumentComponent2({ | ||
| 297 | - unit: componentInfo.unit, | ||
| 298 | - value: 0, | ||
| 299 | - gradient: componentInfo.gradientInfo, | ||
| 300 | - fontColor: componentInfo.fontColor, | ||
| 301 | - }); | 298 | + return instrumentComponent2(componentInfo); | 
| 302 | } | 299 | } | 
| 303 | 300 | ||
| 301 | +export const Instrument1DefaultConfig: Partial<ComponentInfo> = { | ||
| 302 | + fontColor: '#FD7347', | ||
| 303 | +}; | ||
| 304 | + | ||
| 305 | +export const Instrument2DefaultConfig: Partial<ComponentInfo> = { | ||
| 306 | + fontColor: GradientColor.FIRST, | ||
| 307 | + unit: 'km/h', | ||
| 308 | + gradientInfo: [ | ||
| 309 | + { key: Gradient.FIRST, value: 30, color: GradientColor.FIRST }, | ||
| 310 | + { key: Gradient.SECOND, value: 70, color: GradientColor.SECOND }, | ||
| 311 | + { key: Gradient.THIRD, value: 80, color: GradientColor.THIRD }, | ||
| 312 | + ], | ||
| 313 | +}; | ||
| 314 | + | ||
| 304 | export const transformDashboardComponentConfig = ( | 315 | export const transformDashboardComponentConfig = ( | 
| 305 | config: DashboardComponentLayout, | 316 | config: DashboardComponentLayout, | 
| 306 | record: DataComponentRecord, | 317 | record: DataComponentRecord, | 
| 1 | +import { ComponentInfo } from '/@/api/dataBoard/model'; | ||
| 2 | + | ||
| 1 | export type DigitalDashBoardComponentType = 'digital-dashboard-component'; | 3 | export type DigitalDashBoardComponentType = 'digital-dashboard-component'; | 
| 2 | 4 | ||
| 3 | export interface DigitalDashBoardLayout { | 5 | export interface DigitalDashBoardLayout { | 
| @@ -12,3 +14,8 @@ export interface DigitalDashBoardValue { | @@ -12,3 +14,8 @@ export interface DigitalDashBoardValue { | ||
| 12 | value?: number; | 14 | value?: number; | 
| 13 | fontColor?: string; | 15 | fontColor?: string; | 
| 14 | } | 16 | } | 
| 17 | + | ||
| 18 | +export const DigitalComponentDefaultConfig: Partial<ComponentInfo> = { | ||
| 19 | + fontColor: '#000', | ||
| 20 | + unit: 'kw/h', | ||
| 21 | +}; | 
| 1 | import { EChartsOption } from 'echarts'; | 1 | import { EChartsOption } from 'echarts'; | 
| 2 | import { Component } from 'vue'; | 2 | import { Component } from 'vue'; | 
| 3 | import { WidgetComponentType } from '../../detail/config/visualOptions'; | 3 | import { WidgetComponentType } from '../../detail/config/visualOptions'; | 
| 4 | -import { instrumentComponent1, instrumentComponent2 } from './dashBoardComponent.config'; | 4 | +import { | 
| 5 | + Instrument1DefaultConfig, | ||
| 6 | + Instrument2DefaultConfig, | ||
| 7 | + instrumentComponent1, | ||
| 8 | + instrumentComponent2, | ||
| 9 | +} from './dashBoardComponent.config'; | ||
| 5 | import DashBoardComponent from './DashBoardComponent.vue'; | 10 | import DashBoardComponent from './DashBoardComponent.vue'; | 
| 6 | import DigitalDashBoard from './DigitalDashBoard.vue'; | 11 | import DigitalDashBoard from './DigitalDashBoard.vue'; | 
| 7 | import { buildUUID } from '/@/utils/uuid'; | 12 | import { buildUUID } from '/@/utils/uuid'; | 
| @@ -20,13 +25,13 @@ interface InstrumentComponentConfig { | @@ -20,13 +25,13 @@ interface InstrumentComponentConfig { | ||
| 20 | export const instrumentComponentConfig: InstrumentComponentConfig[] = [ | 25 | export const instrumentComponentConfig: InstrumentComponentConfig[] = [ | 
| 21 | { | 26 | { | 
| 22 | id: 'instrument-component-1', | 27 | id: 'instrument-component-1', | 
| 23 | - layout: { chartOption: instrumentComponent1() }, | 28 | + layout: { chartOption: instrumentComponent1(Instrument1DefaultConfig) }, | 
| 24 | component: DashBoardComponent, | 29 | component: DashBoardComponent, | 
| 25 | value: { id: buildUUID() }, | 30 | value: { id: buildUUID() }, | 
| 26 | }, | 31 | }, | 
| 27 | { | 32 | { | 
| 28 | id: 'instrument-component-2', | 33 | id: 'instrument-component-2', | 
| 29 | - layout: { chartOption: instrumentComponent2() }, | 34 | + layout: { chartOption: instrumentComponent2(Instrument2DefaultConfig) }, | 
| 30 | component: DashBoardComponent, | 35 | component: DashBoardComponent, | 
| 31 | value: { id: buildUUID() }, | 36 | value: { id: buildUUID() }, | 
| 32 | }, | 37 | }, | 
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | DEFAULT_RADIO_RECORD, | 7 | DEFAULT_RADIO_RECORD, | 
| 8 | DEFAULT_DATE_FORMAT, | 8 | DEFAULT_DATE_FORMAT, | 
| 9 | } from '../../detail/config/util'; | 9 | } from '../../detail/config/util'; | 
| 10 | - import type { TextComponentLayout, TextComponentValue } from './config'; | 10 | + import { TextComponentDefaultConfig, TextComponentLayout, TextComponentValue } from './config'; | 
| 11 | import { SvgIcon } from '/@/components/Icon'; | 11 | import { SvgIcon } from '/@/components/Icon'; | 
| 12 | import { dateUtil } from '/@/utils/dateUtil'; | 12 | import { dateUtil } from '/@/utils/dateUtil'; | 
| 13 | const props = defineProps({ | 13 | const props = defineProps({ | 
| @@ -17,7 +17,8 @@ | @@ -17,7 +17,8 @@ | ||
| 17 | }, | 17 | }, | 
| 18 | value: { | 18 | value: { | 
| 19 | type: Object as PropType<TextComponentValue>, | 19 | type: Object as PropType<TextComponentValue>, | 
| 20 | - default: () => ({ name: '温度', value: 123 } as TextComponentValue), | 20 | + default: () => | 
| 21 | + ({ ...TextComponentDefaultConfig, name: '温度', value: 123 } as TextComponentValue), | ||
| 21 | }, | 22 | }, | 
| 22 | radio: { | 23 | radio: { | 
| 23 | type: Object as PropType<RadioRecord>, | 24 | type: Object as PropType<RadioRecord>, | 
| 1 | -import { formatToDateTime } from '/@/utils/dateUtil'; | ||
| 2 | -import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; | 1 | +import { ComponentInfo, DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; | 
| 3 | export interface TextComponentLayout { | 2 | export interface TextComponentLayout { | 
| 4 | id: string; | 3 | id: string; | 
| 5 | base?: boolean; | 4 | base?: boolean; | 
| @@ -26,28 +25,21 @@ export type TextComponentType = | @@ -26,28 +25,21 @@ export type TextComponentType = | ||
| 26 | | 'text-component-4' | 25 | | 'text-component-4' | 
| 27 | | 'text-component-5'; | 26 | | 'text-component-5'; | 
| 28 | 27 | ||
| 29 | -type TextComponentDefault = TextComponentLayout & { value: TextComponentValue }; | 28 | +type TextComponentDefault = TextComponentLayout; | 
| 30 | 29 | ||
| 31 | export const TextComponent1Config: TextComponentDefault = { | 30 | export const TextComponent1Config: TextComponentDefault = { | 
| 32 | id: 'text-component-1', | 31 | id: 'text-component-1', | 
| 33 | base: true, | 32 | base: true, | 
| 34 | - value: { value: 123, name: '温度' }, | ||
| 35 | }; | 33 | }; | 
| 36 | 34 | ||
| 37 | export const TextComponent2Config: TextComponentDefault = { | 35 | export const TextComponent2Config: TextComponentDefault = { | 
| 38 | id: 'text-component-2', | 36 | id: 'text-component-2', | 
| 39 | base: false, | 37 | base: false, | 
| 40 | - value: { value: 123, name: '温度' }, | ||
| 41 | }; | 38 | }; | 
| 42 | export const TextComponent3Config: TextComponentDefault = { | 39 | export const TextComponent3Config: TextComponentDefault = { | 
| 43 | id: 'text-component-3', | 40 | id: 'text-component-3', | 
| 44 | base: false, | 41 | base: false, | 
| 45 | showUpdate: true, | 42 | showUpdate: true, | 
| 46 | - value: { | ||
| 47 | - value: 123, | ||
| 48 | - name: '温度', | ||
| 49 | - updateTime: formatToDateTime(new Date(), 'YYYY-MM-DD HH:mm:ss'), | ||
| 50 | - }, | ||
| 51 | }; | 43 | }; | 
| 52 | export const TextComponent4Config: TextComponentDefault = { | 44 | export const TextComponent4Config: TextComponentDefault = { | 
| 53 | id: 'text-component-4', | 45 | id: 'text-component-4', | 
| @@ -55,19 +47,19 @@ export const TextComponent4Config: TextComponentDefault = { | @@ -55,19 +47,19 @@ export const TextComponent4Config: TextComponentDefault = { | ||
| 55 | showIcon: true, | 47 | showIcon: true, | 
| 56 | showUpdate: true, | 48 | showUpdate: true, | 
| 57 | showUnit: true, | 49 | showUnit: true, | 
| 58 | - value: { | ||
| 59 | - value: 123, | ||
| 60 | - name: '温度', | ||
| 61 | - updateTime: formatToDateTime(new Date(), 'YYYY-MM-DD HH:mm:ss'), | ||
| 62 | - unit: '℃', | ||
| 63 | - }, | ||
| 64 | }; | 50 | }; | 
| 65 | export const TextComponent5Config: TextComponentDefault = { | 51 | export const TextComponent5Config: TextComponentDefault = { | 
| 66 | id: 'text-component-5', | 52 | id: 'text-component-5', | 
| 67 | base: false, | 53 | base: false, | 
| 68 | showIcon: true, | 54 | showIcon: true, | 
| 69 | showUnit: true, | 55 | showUnit: true, | 
| 70 | - value: { value: 123, name: '温度', unit: '℃' }, | 56 | +}; | 
| 57 | + | ||
| 58 | +export const TextComponentDefaultConfig: Partial<ComponentInfo> = { | ||
| 59 | + fontColor: '#000', | ||
| 60 | + unit: '℃', | ||
| 61 | + iconColor: '#000', | ||
| 62 | + icon: 'CO2', | ||
| 71 | }; | 63 | }; | 
| 72 | 64 | ||
| 73 | export const textComponentConfig: TextComponentDefault[] = [ | 65 | export const textComponentConfig: TextComponentDefault[] = [ | 
| @@ -11,8 +11,9 @@ | @@ -11,8 +11,9 @@ | ||
| 11 | import type { ComponentInfo, DataSource } from '/@/api/dataBoard/model'; | 11 | import type { ComponentInfo, DataSource } from '/@/api/dataBoard/model'; | 
| 12 | import { useMessage } from '/@/hooks/web/useMessage'; | 12 | import { useMessage } from '/@/hooks/web/useMessage'; | 
| 13 | import { DataBoardLayoutInfo } from '../../types/type'; | 13 | import { DataBoardLayoutInfo } from '../../types/type'; | 
| 14 | - import { FrontComponent } from '../config/help'; | 14 | + import { FrontComponent, getComponentDefaultConfig } from '../config/help'; | 
| 15 | import { computed } from '@vue/reactivity'; | 15 | import { computed } from '@vue/reactivity'; | 
| 16 | + import { WidgetComponentType } from '../config/visualOptions'; | ||
| 16 | 17 | ||
| 17 | type DataSourceFormEL = { [key: string]: Nullable<FormActionType> }; | 18 | type DataSourceFormEL = { [key: string]: Nullable<FormActionType> }; | 
| 18 | 19 | ||
| @@ -96,9 +97,14 @@ | @@ -96,9 +97,14 @@ | ||
| 96 | createMessage.warning('请先选择可视化组件'); | 97 | createMessage.warning('请先选择可视化组件'); | 
| 97 | return; | 98 | return; | 
| 98 | } | 99 | } | 
| 100 | + | ||
| 101 | + const defaultConfig = getComponentDefaultConfig(props.frontId as WidgetComponentType); | ||
| 102 | + | ||
| 103 | + const componentInfo: ComponentInfo = { ...defaultConfig, ...(item.componentInfo || {}) }; | ||
| 104 | + | ||
| 99 | openModal(true, { | 105 | openModal(true, { | 
| 100 | recordId: item.id, | 106 | recordId: item.id, | 
| 101 | - componentInfo: item.componentInfo, | 107 | + componentInfo, | 
| 102 | }); | 108 | }); | 
| 103 | }; | 109 | }; | 
| 104 | 110 | 
| @@ -36,7 +36,6 @@ | @@ -36,7 +36,6 @@ | ||
| 36 | componentRecord.value = data.record || ({} as unknown as DataBoardLayoutInfo); | 36 | componentRecord.value = data.record || ({} as unknown as DataBoardLayoutInfo); | 
| 37 | frontId.value = data.record?.record?.frontId || ''; | 37 | frontId.value = data.record?.record?.frontId || ''; | 
| 38 | isEdit.value = data.isEdit || false; | 38 | isEdit.value = data.isEdit || false; | 
| 39 | - console.log(unref(isEdit)); | ||
| 40 | } | 39 | } | 
| 41 | ); | 40 | ); | 
| 42 | 41 | 
| @@ -87,7 +87,7 @@ | @@ -87,7 +87,7 @@ | ||
| 87 | @register="register" | 87 | @register="register" | 
| 88 | @ok="handleClose" | 88 | @ok="handleClose" | 
| 89 | title="选项" | 89 | title="选项" | 
| 90 | - width="60%" | 90 | + width="40%" | 
| 91 | > | 91 | > | 
| 92 | <BasicForm class="form" @register="registerForm" :schemas="getSchemas" /> | 92 | <BasicForm class="form" @register="registerForm" :schemas="getSchemas" /> | 
| 93 | </BasicModal> | 93 | </BasicModal> | 
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | :style="{ borderColor: props.controlId === props.checkedId ? '#1a74e8' : '#f0f0f0' }" | 23 | :style="{ borderColor: props.controlId === props.checkedId ? '#1a74e8' : '#f0f0f0' }" | 
| 24 | hoverable | 24 | hoverable | 
| 25 | bordered | 25 | bordered | 
| 26 | - class="w-60 h-60 widget-select !bg-light-50" | 26 | + class="w-60 h-60 widget-select !bg-light-50 cursor-pointer" | 
| 27 | @click="handleClick" | 27 | @click="handleClick" | 
| 28 | > | 28 | > | 
| 29 | <div class="widget-container"> | 29 | <div class="widget-container"> | 
| @@ -6,20 +6,24 @@ import { | @@ -6,20 +6,24 @@ import { | ||
| 6 | TextComponent3Config, | 6 | TextComponent3Config, | 
| 7 | TextComponent4Config, | 7 | TextComponent4Config, | 
| 8 | TextComponent5Config, | 8 | TextComponent5Config, | 
| 9 | + TextComponentDefaultConfig, | ||
| 9 | transformTextComponentConfig, | 10 | transformTextComponentConfig, | 
| 10 | } from '../../components/TextComponent/config'; | 11 | } from '../../components/TextComponent/config'; | 
| 11 | -import { DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; | 12 | +import { ComponentInfo, DataComponentRecord, DataSource } from '/@/api/dataBoard/model'; | 
| 12 | import DashBoardComponent from '../../components/InstrumentComponent/DashBoardComponent.vue'; | 13 | import DashBoardComponent from '../../components/InstrumentComponent/DashBoardComponent.vue'; | 
| 13 | import PictureComponent from '../../components/PictureComponent/PictureComponent.vue'; | 14 | import PictureComponent from '../../components/PictureComponent/PictureComponent.vue'; | 
| 14 | import { transformPictureConfig } from '../../components/PictureComponent/pictureComponent.config'; | 15 | import { transformPictureConfig } from '../../components/PictureComponent/pictureComponent.config'; | 
| 15 | import { WidgetComponentType } from './visualOptions'; | 16 | import { WidgetComponentType } from './visualOptions'; | 
| 16 | import { | 17 | import { | 
| 17 | DashboardComponentLayout, | 18 | DashboardComponentLayout, | 
| 19 | + Instrument1DefaultConfig, | ||
| 20 | + Instrument2DefaultConfig, | ||
| 18 | instrumentComponent1, | 21 | instrumentComponent1, | 
| 19 | instrumentComponent2, | 22 | instrumentComponent2, | 
| 20 | transformDashboardComponentConfig, | 23 | transformDashboardComponentConfig, | 
| 21 | } from '../../components/InstrumentComponent/dashBoardComponent.config'; | 24 | } from '../../components/InstrumentComponent/dashBoardComponent.config'; | 
| 22 | import DigitalDashBoard from '../../components/InstrumentComponent/DigitalDashBoard.vue'; | 25 | import DigitalDashBoard from '../../components/InstrumentComponent/DigitalDashBoard.vue'; | 
| 26 | +import { DigitalComponentDefaultConfig } from '../../components/InstrumentComponent/digitalDashBoard.config'; | ||
| 23 | export enum FrontComponent { | 27 | export enum FrontComponent { | 
| 24 | TEXT_COMPONENT_1 = 'text-component-1', | 28 | TEXT_COMPONENT_1 = 'text-component-1', | 
| 25 | TEXT_COMPONENT_2 = 'text-component-2', | 29 | TEXT_COMPONENT_2 = 'text-component-2', | 
| @@ -42,6 +46,11 @@ export interface ComponentConfig { | @@ -42,6 +46,11 @@ export interface ComponentConfig { | ||
| 42 | ) => Recordable; | 46 | ) => Recordable; | 
| 43 | } | 47 | } | 
| 44 | 48 | ||
| 49 | +export const frontComponentDefaultConfigMap = new Map< | ||
| 50 | + WidgetComponentType, | ||
| 51 | + Partial<ComponentInfo> | ||
| 52 | +>(); | ||
| 53 | + | ||
| 45 | export const frontComponentMap = new Map<WidgetComponentType, ComponentConfig>(); | 54 | export const frontComponentMap = new Map<WidgetComponentType, ComponentConfig>(); | 
| 46 | 55 | ||
| 47 | frontComponentMap.set(FrontComponent.TEXT_COMPONENT_1, { | 56 | frontComponentMap.set(FrontComponent.TEXT_COMPONENT_1, { | 
| @@ -103,3 +112,21 @@ frontComponentMap.set(FrontComponent.PICTURE_COMPONENT_1, { | @@ -103,3 +112,21 @@ frontComponentMap.set(FrontComponent.PICTURE_COMPONENT_1, { | ||
| 103 | ComponentConfig: {}, | 112 | ComponentConfig: {}, | 
| 104 | transformConfig: transformPictureConfig, | 113 | transformConfig: transformPictureConfig, | 
| 105 | }); | 114 | }); | 
| 115 | + | ||
| 116 | +frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_1, TextComponentDefaultConfig); | ||
| 117 | +frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_2, TextComponentDefaultConfig); | ||
| 118 | +frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_3, TextComponentDefaultConfig); | ||
| 119 | +frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_4, TextComponentDefaultConfig); | ||
| 120 | +frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_5, TextComponentDefaultConfig); | ||
| 121 | + | ||
| 122 | +frontComponentDefaultConfigMap.set(FrontComponent.INSTRUMENT_COMPONENT_1, Instrument1DefaultConfig); | ||
| 123 | +frontComponentDefaultConfigMap.set(FrontComponent.INSTRUMENT_COMPONENT_2, Instrument2DefaultConfig); | ||
| 124 | + | ||
| 125 | +frontComponentDefaultConfigMap.set( | ||
| 126 | + FrontComponent.DIGITAL_DASHBOARD_COMPONENT, | ||
| 127 | + DigitalComponentDefaultConfig | ||
| 128 | +); | ||
| 129 | + | ||
| 130 | +export const getComponentDefaultConfig = (key: WidgetComponentType) => { | ||
| 131 | + return frontComponentDefaultConfigMap.get(key) || {}; | ||
| 132 | +}; | 
| @@ -175,7 +175,7 @@ schemasMap.set('text-component-1', modeOne); | @@ -175,7 +175,7 @@ schemasMap.set('text-component-1', modeOne); | ||
| 175 | schemasMap.set('text-component-2', modeOne); | 175 | schemasMap.set('text-component-2', modeOne); | 
| 176 | schemasMap.set('text-component-3', modeOne); | 176 | schemasMap.set('text-component-3', modeOne); | 
| 177 | schemasMap.set('text-component-4', modeTwo); | 177 | schemasMap.set('text-component-4', modeTwo); | 
| 178 | -schemasMap.set('text-component-4', modeTwo); | 178 | +schemasMap.set('text-component-5', modeTwo); | 
| 179 | schemasMap.set('instrument-component-1', modeOne); | 179 | schemasMap.set('instrument-component-1', modeOne); | 
| 180 | schemasMap.set('instrument-component-2', modeThree); | 180 | schemasMap.set('instrument-component-2', modeThree); | 
| 181 | schemasMap.set('digital-dashboard-component', modeFour); | 181 | schemasMap.set('digital-dashboard-component', modeFour); | 
| @@ -88,9 +88,9 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | @@ -88,9 +88,9 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { | ||
| 88 | throw Error(error as string); | 88 | throw Error(error as string); | 
| 89 | } | 89 | } | 
| 90 | }, | 90 | }, | 
| 91 | - onDisconnected() { | ||
| 92 | - close(); | ||
| 93 | - }, | 91 | + // onDisconnected() { | 
| 92 | + // close(); | ||
| 93 | + // }, | ||
| 94 | }); | 94 | }); | 
| 95 | 95 | ||
| 96 | const setCmdId = (cmdId: number, record: CmdMapping) => { | 96 | const setCmdId = (cmdId: number, record: CmdMapping) => { |