Commit 538ca6d74977294a17290f9c1eda81c9bfa34734
1 parent
cb813ee9
feat(src/views): 新增变量图片组件,上报数据类型为枚举,根据值显示对应图片
Showing
9 changed files
with
158 additions
and
9 deletions
| @@ -31,6 +31,7 @@ interface uploadSizeFormatIF { | @@ -31,6 +31,7 @@ interface uploadSizeFormatIF { | ||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | const props = defineProps({ | 33 | const props = defineProps({ |
| 34 | + uploadIndex: Number, | ||
| 34 | uploadImageUrl: { | 35 | uploadImageUrl: { |
| 35 | type: String as PropType<string>, | 36 | type: String as PropType<string>, |
| 36 | default: '' | 37 | default: '' |
| @@ -60,7 +61,7 @@ const customRequest = (options: UploadCustomRequestOptions) => { | @@ -60,7 +61,7 @@ const customRequest = (options: UploadCustomRequestOptions) => { | ||
| 60 | uploadParams.append('file', newNameFile) | 61 | uploadParams.append('file', newNameFile) |
| 61 | const uploadRes = await uploadFile(uploadParams) | 62 | const uploadRes = await uploadFile(uploadParams) |
| 62 | if (!uploadRes) return | 63 | if (!uploadRes) return |
| 63 | - emit('sendFile', uploadRes?.fileStaticUri) | 64 | + emit('sendFile', uploadRes?.fileStaticUri, props.uploadIndex) |
| 64 | window['$message'].success('上传文件成功!') | 65 | window['$message'].success('上传文件成功!') |
| 65 | } else { | 66 | } else { |
| 66 | window['$message'].error('上传文件失败,请稍后重试!') | 67 | window['$message'].error('上传文件失败,请稍后重试!') |
| @@ -88,7 +89,7 @@ const beforeUploadHandle = (file: UploadFileInfo) => { | @@ -88,7 +89,7 @@ const beforeUploadHandle = (file: UploadFileInfo) => { | ||
| 88 | //单个点击删除 | 89 | //单个点击删除 |
| 89 | const remove = () => { | 90 | const remove = () => { |
| 90 | fileList.value = [] | 91 | fileList.value = [] |
| 91 | - emit('removeFile', true) | 92 | + emit('removeFile', true, props.uploadIndex) |
| 92 | } | 93 | } |
| 93 | </script> | 94 | </script> |
| 94 | 95 |
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | - <n-input :style="`width:${w}px;`" type="text" | 3 | + <n-input :style="`width:${w}px;height:${h}px;`" type="text" |
| 4 | v-model:value="option.value.dataset" | 4 | v-model:value="option.value.dataset" |
| 5 | placeholder="请输入" | 5 | placeholder="请输入" |
| 6 | - @update="onChange"> | 6 | + @blur="onBlur"> |
| 7 | 7 | ||
| 8 | </n-input> | 8 | </n-input> |
| 9 | </div> | 9 | </div> |
| @@ -25,6 +25,7 @@ const props = defineProps({ | @@ -25,6 +25,7 @@ const props = defineProps({ | ||
| 25 | }) | 25 | }) |
| 26 | 26 | ||
| 27 | const { w, h } = toRefs(props.chartConfig.attr) | 27 | const { w, h } = toRefs(props.chartConfig.attr) |
| 28 | + | ||
| 28 | const option = shallowReactive({ | 29 | const option = shallowReactive({ |
| 29 | value: { | 30 | value: { |
| 30 | inputValue: props.chartConfig.option.inputValue, | 31 | inputValue: props.chartConfig.option.inputValue, |
| @@ -32,8 +33,7 @@ const option = shallowReactive({ | @@ -32,8 +33,7 @@ const option = shallowReactive({ | ||
| 32 | } | 33 | } |
| 33 | }) | 34 | }) |
| 34 | 35 | ||
| 35 | -const onChange = (v: string) => { | ||
| 36 | - // if(v == undefined) return; | 36 | +const onBlur = () => { |
| 37 | // 存储到联动数据 | 37 | // 存储到联动数据 |
| 38 | useChartInteract( | 38 | useChartInteract( |
| 39 | props.chartConfig, | 39 | props.chartConfig, |
| @@ -49,7 +49,6 @@ watch( | @@ -49,7 +49,6 @@ watch( | ||
| 49 | () => props.chartConfig.option, | 49 | () => props.chartConfig.option, |
| 50 | (newData: any) => { | 50 | (newData: any) => { |
| 51 | option.value = newData | 51 | option.value = newData |
| 52 | - onChange(newData.inputValue) | ||
| 53 | }, | 52 | }, |
| 54 | { | 53 | { |
| 55 | immediate: true, | 54 | immediate: true, |
| 1 | +import { PublicConfigClass } from '@/packages/public' | ||
| 2 | +import { CreateComponentType } from '@/packages/index.d' | ||
| 3 | +import { chartInitConfig } from '@/settings/designSetting' | ||
| 4 | +import { VariableImageConfig } from './index' | ||
| 5 | +import cloneDeep from 'lodash/cloneDeep' | ||
| 6 | + | ||
| 7 | +export const option = { | ||
| 8 | + dataset: '', | ||
| 9 | + valueConfig: [ | ||
| 10 | + { | ||
| 11 | + value: '', | ||
| 12 | + imageUrl: '' | ||
| 13 | + } | ||
| 14 | + ] | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +export default class Config extends PublicConfigClass implements CreateComponentType { | ||
| 18 | + public key = VariableImageConfig.key | ||
| 19 | + public attr = { ...chartInitConfig, w: 500, h: 300, zIndex: -1 } | ||
| 20 | + public chartConfig = cloneDeep(VariableImageConfig) | ||
| 21 | + public option = cloneDeep(option) | ||
| 22 | +} |
| 1 | +<template> | ||
| 2 | + <collapse-item name="配置" :expanded="true"> | ||
| 3 | + <template v-for="(item, index) in optionData.valueConfig" :key="index"> | ||
| 4 | + <setting-item-box name="变量值" :alone="true"> | ||
| 5 | + <setting-item> | ||
| 6 | + <n-input v-model:value="item.value"></n-input> | ||
| 7 | + </setting-item> | ||
| 8 | + </setting-item-box> | ||
| 9 | + <div style="height: 10px"></div> | ||
| 10 | + <setting-item-box name="变量图片" :alone="true"> | ||
| 11 | + <setting-item> | ||
| 12 | + <TKUpload | ||
| 13 | + :uploadIndex="index" | ||
| 14 | + :uploadImageUrl="item.imageUrl" | ||
| 15 | + @sendFile="handleSendFile" | ||
| 16 | + @removeFile="handleRemoveFile" | ||
| 17 | + /> | ||
| 18 | + </setting-item> | ||
| 19 | + </setting-item-box> | ||
| 20 | + <n-button size="small" @click="optionData.valueConfig.splice(index, 1)"> - </n-button> | ||
| 21 | + </template> | ||
| 22 | + <n-button | ||
| 23 | + style="margin-left: 10px" | ||
| 24 | + v-if="optionData.valueConfig" | ||
| 25 | + size="small" | ||
| 26 | + @click=" | ||
| 27 | + optionData.valueConfig.push({ | ||
| 28 | + value: '', | ||
| 29 | + imageUrl: '', | ||
| 30 | + }) | ||
| 31 | + " | ||
| 32 | + > | ||
| 33 | + + | ||
| 34 | + </n-button> | ||
| 35 | + </collapse-item> | ||
| 36 | +</template> | ||
| 37 | + | ||
| 38 | +<script setup lang="ts"> | ||
| 39 | +import { PropType } from 'vue' | ||
| 40 | +import { option } from './config' | ||
| 41 | +import { TKUpload } from '@/components/external/Common/TKUpload' | ||
| 42 | +import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | ||
| 43 | + | ||
| 44 | +const props = defineProps({ | ||
| 45 | + optionData: { | ||
| 46 | + type: Object as PropType<typeof option>, | ||
| 47 | + required: true | ||
| 48 | + } | ||
| 49 | +}) | ||
| 50 | + | ||
| 51 | +const handleSendFile = (file: string, index: number) => { | ||
| 52 | + if (!file) return | ||
| 53 | + props.optionData.valueConfig[index].imageUrl = file | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +const handleRemoveFile = (status: boolean, index: number) => | ||
| 57 | + status ? (props.optionData.valueConfig[index].imageUrl = '') : null | ||
| 58 | +</script> |
| 1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | ||
| 2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | ||
| 3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | ||
| 4 | + | ||
| 5 | +const { key, conKey, chartKey } = useWidgetKey('VariableImage', true) | ||
| 6 | + | ||
| 7 | +export const VariableImageConfig: ConfigType = { | ||
| 8 | + key, | ||
| 9 | + chartKey, | ||
| 10 | + conKey, | ||
| 11 | + title: '变量图片(适合ws)', | ||
| 12 | + category: ChatCategoryEnum.MORE, | ||
| 13 | + categoryName: ChatCategoryEnumName.MORE, | ||
| 14 | + package: PackagesCategoryEnum.INFORMATIONS, | ||
| 15 | + chartFrame: ChartFrameEnum.COMMON, | ||
| 16 | + image: 'iframe.png' | ||
| 17 | +} |
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <n-image | ||
| 4 | + preview-disabled | ||
| 5 | + :fallback-src="requireErrorImg()" | ||
| 6 | + :src="!dataset ? logo : dataset" | ||
| 7 | + :width="w" | ||
| 8 | + :height="h" | ||
| 9 | + ></n-image> | ||
| 10 | + </div> | ||
| 11 | +</template> | ||
| 12 | + | ||
| 13 | +<script setup lang="ts"> | ||
| 14 | +import { PropType, toRefs, watch } from 'vue' | ||
| 15 | +import { requireErrorImg } from '@/utils' | ||
| 16 | +import { useChartDataFetch } from '@/hooks' | ||
| 17 | +import { CreateComponentType } from '@/packages/index.d' | ||
| 18 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
| 19 | +import { option } from './config' | ||
| 20 | +import logo from '@/assets/logo.png' | ||
| 21 | + | ||
| 22 | +const props = defineProps({ | ||
| 23 | + chartConfig: { | ||
| 24 | + type: Object as PropType<CreateComponentType>, | ||
| 25 | + required: true | ||
| 26 | + } | ||
| 27 | +}) | ||
| 28 | + | ||
| 29 | +const { w, h } = toRefs(props.chartConfig.attr) | ||
| 30 | + | ||
| 31 | +const { dataset, valueConfig } = toRefs(props.chartConfig.option as unknown as typeof option) | ||
| 32 | + | ||
| 33 | +watch( | ||
| 34 | + () => dataset?.value, | ||
| 35 | + newValue => { | ||
| 36 | + const findImageUrl = valueConfig?.value.find( | ||
| 37 | + (valueConfigItem: typeof option['valueConfig'][0]) => String(valueConfigItem.value) === String(newValue) | ||
| 38 | + ) | ||
| 39 | + if (findImageUrl) { | ||
| 40 | + dataset.value = findImageUrl?.imageUrl | ||
| 41 | + } | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + immediate: true | ||
| 45 | + } | ||
| 46 | +) | ||
| 47 | + | ||
| 48 | +// 预览更新 | ||
| 49 | +useChartDataFetch(props.chartConfig, useChartEditStore) | ||
| 50 | +</script> |
| @@ -8,7 +8,7 @@ export const OverrideTextEnumCommonConfig: ConfigType = { | @@ -8,7 +8,7 @@ export const OverrideTextEnumCommonConfig: ConfigType = { | ||
| 8 | key, | 8 | key, |
| 9 | chartKey, | 9 | chartKey, |
| 10 | conKey, | 10 | conKey, |
| 11 | - title: '自定义文字(支持枚举)', | 11 | + title: '文字枚举(适合ws)', |
| 12 | category: ChatCategoryEnum.TEXT, | 12 | category: ChatCategoryEnum.TEXT, |
| 13 | categoryName: ChatCategoryEnumName.TEXT, | 13 | categoryName: ChatCategoryEnumName.TEXT, |
| 14 | package: PackagesCategoryEnum.INFORMATIONS, | 14 | package: PackagesCategoryEnum.INFORMATIONS, |
| @@ -21,6 +21,7 @@ import { CameraConfig } from '@/packages/components/external/Informations/Mores/ | @@ -21,6 +21,7 @@ import { CameraConfig } from '@/packages/components/external/Informations/Mores/ | ||
| 21 | import { SingleCameraConfig } from '@/packages/components/external/Informations/Mores/SingleCamera' | 21 | import { SingleCameraConfig } from '@/packages/components/external/Informations/Mores/SingleCamera' |
| 22 | import { OverrideILoadConfigurationframeConfig } from '@/packages/components/external/Informations/Mores/OverrideILoadConfigurationframe' | 22 | import { OverrideILoadConfigurationframeConfig } from '@/packages/components/external/Informations/Mores/OverrideILoadConfigurationframe' |
| 23 | import { CustomEchartsConfig } from '@/packages/components/external/Informations/Mores/CustomEcharts' | 23 | import { CustomEchartsConfig } from '@/packages/components/external/Informations/Mores/CustomEcharts' |
| 24 | +import { VariableImageConfig } from '@/packages/components/external/Informations/Mores/VariableImage' | ||
| 24 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' | 25 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' |
| 25 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' | 26 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' |
| 26 | import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients' | 27 | import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients' |
| @@ -145,6 +146,7 @@ export function useInjectLib(packagesList: EPackagesType) { | @@ -145,6 +146,7 @@ export function useInjectLib(packagesList: EPackagesType) { | ||
| 145 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, SingleCameraConfig)//新增信息下的单个摄像头 | 146 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, SingleCameraConfig)//新增信息下的单个摄像头 |
| 146 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideILoadConfigurationframeConfig)//新增信息下的加载组态 | 147 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideILoadConfigurationframeConfig)//新增信息下的加载组态 |
| 147 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, CustomEchartsConfig)//新增信息下的自定义ecahrts组件 | 148 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, CustomEchartsConfig)//新增信息下的自定义ecahrts组件 |
| 149 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, VariableImageConfig)//新增信息下的变量图片组件 | ||
| 148 | // | 150 | // |
| 149 | 151 | ||
| 150 | //图表 | 152 | //图表 |
| @@ -275,7 +275,7 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => { | @@ -275,7 +275,7 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => { | ||
| 275 | const requestDataPond = chartEditStore.getRequestGlobalConfig.requestDataPond.map(item => ({ | 275 | const requestDataPond = chartEditStore.getRequestGlobalConfig.requestDataPond.map(item => ({ |
| 276 | id: item.dataPondId, | 276 | id: item.dataPondId, |
| 277 | title: item.dataPondName, | 277 | title: item.dataPondName, |
| 278 | - disabled: false, | 278 | + disabled: true, |
| 279 | type: 'requestDataPond' | 279 | type: 'requestDataPond' |
| 280 | })) | 280 | })) |
| 281 | const tarArr = requestDataPond.concat(mapOptionList) | 281 | const tarArr = requestDataPond.concat(mapOptionList) |