Commit 233c122d6b2f33c2dbcadcb87edded221c6d51ef

Authored by xp.Huang
2 parents fe107532 55578793

Merge branch 'perf/view-06-03' into 'main_dev'

perf(src/views): 设备地理位置组件,设备在线时显示为绿色,离线时显示为红色,待激活为黄色标,不然全是灰色,而且不注意还不好发现

See merge request yunteng/thingskit-view!273
... ... @@ -31,6 +31,7 @@ interface uploadSizeFormatIF {
31 31 }
32 32
33 33 const props = defineProps({
  34 + uploadIndex: Number,
34 35 uploadImageUrl: {
35 36 type: String as PropType<string>,
36 37 default: ''
... ... @@ -60,7 +61,7 @@ const customRequest = (options: UploadCustomRequestOptions) => {
60 61 uploadParams.append('file', newNameFile)
61 62 const uploadRes = await uploadFile(uploadParams)
62 63 if (!uploadRes) return
63   - emit('sendFile', uploadRes?.fileStaticUri)
  64 + emit('sendFile', uploadRes?.fileStaticUri, props.uploadIndex)
64 65 window['$message'].success('上传文件成功!')
65 66 } else {
66 67 window['$message'].error('上传文件失败,请稍后重试!')
... ... @@ -88,7 +89,7 @@ const beforeUploadHandle = (file: UploadFileInfo) => {
88 89 //单个点击删除
89 90 const remove = () => {
90 91 fileList.value = []
91   - emit('removeFile', true)
  92 + emit('removeFile', true, props.uploadIndex)
92 93 }
93 94 </script>
94 95
... ...
... ... @@ -30,7 +30,7 @@ const { targetData, chartEditStore } = useTargetData()
30 30 const isWebsocket = computed(() => {
31 31 const result = query(chartEditStore.getComponentList)
32 32 if (result === false) return false
33   -
  33 + if (!targetData.value) return
34 34 if (result.id === targetData.value.id)
35 35 return targetData.value.request.requestContentType as RequestContentTypeEnum === RequestContentTypeEnum.WEB_SOCKET
36 36 else {
... ... @@ -42,6 +42,7 @@ function query(list: CreateComponentType[]) {
42 42 if (!list || !list?.length) return false
43 43
44 44 for (const item of list) {
  45 + if (!targetData.value) return
45 46 if (item.id === targetData.value.id) {
46 47 return item
47 48 }
... ...
1 1 <template>
2 2 <div>
3   - <n-input :style="`width:${w}px;`" type="text"
  3 + <n-input :style="`width:${w}px;height:${h}px;`" type="text"
4 4 v-model:value="option.value.dataset"
5 5 placeholder="请输入"
6   - @update="onChange">
  6 + @blur="onBlur">
7 7
8 8 </n-input>
9 9 </div>
... ... @@ -25,6 +25,7 @@ const props = defineProps({
25 25 })
26 26
27 27 const { w, h } = toRefs(props.chartConfig.attr)
  28 +
28 29 const option = shallowReactive({
29 30 value: {
30 31 inputValue: props.chartConfig.option.inputValue,
... ... @@ -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 38 useChartInteract(
39 39 props.chartConfig,
... ... @@ -49,7 +49,6 @@ watch(
49 49 () => props.chartConfig.option,
50 50 (newData: any) => {
51 51 option.value = newData
52   - onChange(newData.inputValue)
53 52 },
54 53 {
55 54 immediate: true,
... ...
... ... @@ -233,13 +233,15 @@ const dataHandle = (newData: dataJsonType) => {
233 233 // 记录新标记
234 234 if (mapMarkerType.value === MarkerEnum.MARKER) {
235 235 newData.markers.forEach((markerItem: dataJsonMarkersType) => {
  236 + console.log("🚀 ~ newData.markers.forEach ~ markerItem:", markerItem.extraInfo.deviceState)
236 237 const markerInstance = new AMapIns.Marker({
237 238 position: [markerItem.position[0], markerItem.position[1]],
238 239 offset: new AMapIns.Pixel(-13, 5),
239 240 icon: new AMapIns.Icon({
240   - image: iconMarker.value,
241   - size: new AMapIns.Size(22, 22), //图标所处区域大小
242   - imageSize: new AMapIns.Size(22, 22) //图标大小
  241 + // image: iconMarker.value,
  242 + image: markerItem.extraInfo.deviceState === 'ONLINE' ? online : markerItem.extraInfo.deviceState === 'INACTIVE' ? inactive : offline,
  243 + size: new AMapIns.Size(35, 35), //图标所处区域大小
  244 + imageSize: new AMapIns.Size(35, 35) //图标大小
243 245 })
244 246 })
245 247 // 原作者这种方式添加,属于JS API 1.4.8版本的
... ...
  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 8 key,
9 9 chartKey,
10 10 conKey,
11   - title: '自定义文字(支持枚举)',
  11 + title: '文字枚举(适合ws)',
12 12 category: ChatCategoryEnum.TEXT,
13 13 categoryName: ChatCategoryEnumName.TEXT,
14 14 package: PackagesCategoryEnum.INFORMATIONS,
... ...
... ... @@ -21,6 +21,7 @@ import { CameraConfig } from '@/packages/components/external/Informations/Mores/
21 21 import { SingleCameraConfig } from '@/packages/components/external/Informations/Mores/SingleCamera'
22 22 import { OverrideILoadConfigurationframeConfig } from '@/packages/components/external/Informations/Mores/OverrideILoadConfigurationframe'
23 23 import { CustomEchartsConfig } from '@/packages/components/external/Informations/Mores/CustomEcharts'
  24 +import { VariableImageConfig } from '@/packages/components/external/Informations/Mores/VariableImage'
24 25 import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon'
25 26 import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon'
26 27 import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients'
... ... @@ -145,6 +146,7 @@ export function useInjectLib(packagesList: EPackagesType) {
145 146 addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, SingleCameraConfig)//新增信息下的单个摄像头
146 147 addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideILoadConfigurationframeConfig)//新增信息下的加载组态
147 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 275 const requestDataPond = chartEditStore.getRequestGlobalConfig.requestDataPond.map(item => ({
276 276 id: item.dataPondId,
277 277 title: item.dataPondName,
278   - disabled: false,
  278 + disabled: true,
279 279 type: 'requestDataPond'
280 280 }))
281 281 const tarArr = requestDataPond.concat(mapOptionList)
... ...
... ... @@ -193,13 +193,13 @@ const btnList: BtnListType[] = [
193 193 icon: DownloadIcon,
194 194 handle: exportHandle
195 195 },
196   - {
197   - key: 'edit',
198   - type: TypeEnum.BUTTON,
199   - name: '编辑',
200   - icon: CreateIcon,
201   - handle: editHandle
202   - },
  196 + // {
  197 + // key: 'edit',
  198 + // type: TypeEnum.BUTTON,
  199 + // name: '编辑',
  200 + // icon: CreateIcon,
  201 + // handle: editHandle
  202 + // },
203 203 {
204 204 key: 'setting',
205 205 type: TypeEnum.BUTTON,
... ...