Commit 3f7d4542ba2ca33e9d02b6bf7cbce2aae75c4540
Merge branch 'local_dev_ft' into 'main'
pref:优化首页 See merge request huang/yun-teng-iot-front!463
Showing
4 changed files
with
50 additions
and
47 deletions
| @@ -212,9 +212,14 @@ | @@ -212,9 +212,14 @@ | ||
| 212 | class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" | 212 | class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4" |
| 213 | style="color: #666; width: 50%" | 213 | style="color: #666; width: 50%" |
| 214 | > | 214 | > |
| 215 | - <div class="flex container"> | 215 | + <div class="flex container ml-4"> |
| 216 | <div class="mr-4 flex chart-top"> | 216 | <div class="mr-4 flex chart-top"> |
| 217 | - <PieChartDeviceSub :legendData="legendData" :seriesData="seriesData" :isCircle="true" /> | 217 | + <PieChartDeviceSub |
| 218 | + v-if="seriesData.length > 0" | ||
| 219 | + :legendData="legendData" | ||
| 220 | + :seriesData="seriesData" | ||
| 221 | + :isCircle="true" | ||
| 222 | + /> | ||
| 218 | </div> | 223 | </div> |
| 219 | <div class="ml-20 flex justify-around right-text"> | 224 | <div class="ml-20 flex justify-around right-text"> |
| 220 | <div class="text"> | 225 | <div class="text"> |
| @@ -230,9 +235,10 @@ | @@ -230,9 +235,10 @@ | ||
| 230 | class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:ml-1" | 235 | class="md:w-1/3 w-full !md:mt-0 !mt-4 !md:ml-1" |
| 231 | style="color: #666; width: 50%" | 236 | style="color: #666; width: 50%" |
| 232 | > | 237 | > |
| 233 | - <div class="flex container"> | 238 | + <div class="flex container ml-4"> |
| 234 | <div class="mr-4 flex chart-top"> | 239 | <div class="mr-4 flex chart-top"> |
| 235 | <PieChartDeviceSub | 240 | <PieChartDeviceSub |
| 241 | + v-if="seriesStatusData.length > 0" | ||
| 236 | :legendData="legendStatusData" | 242 | :legendData="legendStatusData" |
| 237 | :seriesData="seriesStatusData" | 243 | :seriesData="seriesStatusData" |
| 238 | :isCircle="false" | 244 | :isCircle="false" |
| @@ -282,42 +288,30 @@ | @@ -282,42 +288,30 @@ | ||
| 282 | 288 | ||
| 283 | const growCardList = ref<CardList>(); | 289 | const growCardList = ref<CardList>(); |
| 284 | 290 | ||
| 291 | + const devicePieColor = [ | ||
| 292 | + { key: 'directConnection', itemStyle: { color: '#5C7BD9' }, value: '直连设备' }, | ||
| 293 | + { key: 'gateWay', itemStyle: { color: '#91CC75' }, value: '网关设备' }, | ||
| 294 | + { key: 'sensor', itemStyle: { color: '#FAC859' }, value: '网关子设备' }, | ||
| 295 | + { key: 'inActive', itemStyle: { color: '#5C7BD9' }, value: '待激活' }, | ||
| 296 | + { key: 'onLine', itemStyle: { color: '#91CC75 ' }, value: '在线' }, | ||
| 297 | + { key: 'offLine', itemStyle: { color: '#EC4040' }, value: '离线' }, | ||
| 298 | + ]; | ||
| 299 | + | ||
| 285 | onMounted(async () => { | 300 | onMounted(async () => { |
| 286 | const res = await getHomeData(); | 301 | const res = await getHomeData(); |
| 287 | growCardList.value = res; | 302 | growCardList.value = res; |
| 288 | - const devObj = growCardList.value?.deviceInfo; | ||
| 289 | - for (let o in devObj) { | ||
| 290 | - if (o === 'directConnection' || o === 'gateWay' || o === 'sensor') { | ||
| 291 | - seriesData.value.push({ | ||
| 292 | - value: | ||
| 293 | - o === 'directConnection' | ||
| 294 | - ? devObj?.directConnection | ||
| 295 | - : o === 'gateWay' | ||
| 296 | - ? devObj?.gateWay | ||
| 297 | - : devObj?.sensor, | ||
| 298 | - name: o === 'directConnection' ? '直连设备' : o === 'gateWay' ? '网关设备' : '网关子设备', | ||
| 299 | - itemStyle: | ||
| 300 | - o === 'directConnection' | ||
| 301 | - ? { color: '#5C7BD9' } | ||
| 302 | - : o === 'gateWay' | ||
| 303 | - ? { color: '#91CC75' } | ||
| 304 | - : { color: '#FAC859' }, | ||
| 305 | - }); | ||
| 306 | - } | ||
| 307 | - if (o === 'inActive' || o === 'onLine' || o === 'offLine') { | ||
| 308 | - seriesStatusData.value.push({ | ||
| 309 | - value: | ||
| 310 | - o === 'inActive' ? devObj?.inActive : o === 'onLine' ? devObj?.onLine : devObj?.offLine, | ||
| 311 | - name: o === 'inActive' ? '待激活' : o === 'onLine' ? '在线' : '离线', | ||
| 312 | - itemStyle: | ||
| 313 | - o === 'inActive' | ||
| 314 | - ? { color: '#5C7BD9' } | ||
| 315 | - : o === 'onLine' | ||
| 316 | - ? { color: '#91CC75' } | ||
| 317 | - : { color: '#FAC859' }, | ||
| 318 | - }); | ||
| 319 | - } | ||
| 320 | - } | 303 | + const { deviceInfo } = growCardList.value!; |
| 304 | + let data = Object.entries(deviceInfo).map(([key, value]) => { | ||
| 305 | + const name = devicePieColor?.find((f) => f.key === key)?.value; | ||
| 306 | + const itemStyle = devicePieColor?.find((f) => f.key === key)?.itemStyle; | ||
| 307 | + return { key, value, itemStyle, name }; | ||
| 308 | + }); | ||
| 309 | + seriesData.value = data.filter( | ||
| 310 | + (f) => f.key === 'directConnection' || f.key === 'gateWay' || f.key === 'sensor' | ||
| 311 | + ); | ||
| 312 | + seriesStatusData.value = data.filter( | ||
| 313 | + (f) => f.key === 'inActive' || f.key === 'onLine' || f.key === 'offLine' | ||
| 314 | + ); | ||
| 321 | }); | 315 | }); |
| 322 | </script> | 316 | </script> |
| 323 | <style lang="css"> | 317 | <style lang="css"> |
| @@ -43,6 +43,12 @@ | @@ -43,6 +43,12 @@ | ||
| 43 | 43 | ||
| 44 | const chartRef = ref<HTMLDivElement | null>(null); | 44 | const chartRef = ref<HTMLDivElement | null>(null); |
| 45 | const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>); | 45 | const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>); |
| 46 | + const labelLine = { | ||
| 47 | + normal: { | ||
| 48 | + show: true, | ||
| 49 | + length2: 1, | ||
| 50 | + }, | ||
| 51 | + } as any; | ||
| 46 | onMounted(() => { | 52 | onMounted(() => { |
| 47 | setOptions({ | 53 | setOptions({ |
| 48 | backgroundColor: '#ffffff', | 54 | backgroundColor: '#ffffff', |
| @@ -70,12 +76,7 @@ | @@ -70,12 +76,7 @@ | ||
| 70 | shadowColor: 'rgba(0, 0, 0, 0.5)', | 76 | shadowColor: 'rgba(0, 0, 0, 0.5)', |
| 71 | }, | 77 | }, |
| 72 | }, | 78 | }, |
| 73 | - labelLine: { | ||
| 74 | - normal: { | ||
| 75 | - show: true, | ||
| 76 | - length2: 1, | ||
| 77 | - }, | ||
| 78 | - }, | 79 | + labelLine, |
| 79 | }, | 80 | }, |
| 80 | ], | 81 | ], |
| 81 | }); | 82 | }); |
| @@ -44,6 +44,7 @@ export interface CardList { | @@ -44,6 +44,7 @@ export interface CardList { | ||
| 44 | } | 44 | } |
| 45 | export type seriesDataT = { | 45 | export type seriesDataT = { |
| 46 | value: number | undefined; | 46 | value: number | undefined; |
| 47 | - name: string; | ||
| 48 | - itemStyle: object; | 47 | + name: string | undefined; |
| 48 | + itemStyle: object | undefined; | ||
| 49 | + key?: string | undefined; | ||
| 49 | }; | 50 | }; |
| @@ -9,7 +9,7 @@ import { scheduleOptions } from './formatData'; | @@ -9,7 +9,7 @@ import { scheduleOptions } from './formatData'; | ||
| 9 | import { copyTransFun } from '/@/utils/fnUtils'; | 9 | import { copyTransFun } from '/@/utils/fnUtils'; |
| 10 | import { numberAndNonegativeRule } from '/@/utils/rules'; | 10 | import { numberAndNonegativeRule } from '/@/utils/rules'; |
| 11 | import { findDictItemByCode } from '/@/api/system/dict'; | 11 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 12 | -import { deviceProfile, queryDeviceProfileBy } from '/@/api/device/deviceManager'; | 12 | +import { queryDeviceProfileBy } from '/@/api/device/deviceManager'; |
| 13 | import { getModelServices } from '/@/api/device/modelOfMatter'; | 13 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
| 14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
| 15 | import useCommonFun from '../hooks/useCommonFun'; | 15 | import useCommonFun from '../hooks/useCommonFun'; |
| @@ -418,7 +418,8 @@ export const actionSchema: FormSchema[] = [ | @@ -418,7 +418,8 @@ export const actionSchema: FormSchema[] = [ | ||
| 418 | component: 'ApiSelect', | 418 | component: 'ApiSelect', |
| 419 | colProps: { span: 6 }, | 419 | colProps: { span: 6 }, |
| 420 | defaultValue: 'SENSOR', | 420 | defaultValue: 'SENSOR', |
| 421 | - componentProps: () => { | 421 | + componentProps: ({ formActionType }) => { |
| 422 | + const { setFieldsValue } = formActionType; | ||
| 422 | return { | 423 | return { |
| 423 | api: findDictItemByCode, | 424 | api: findDictItemByCode, |
| 424 | params: { | 425 | params: { |
| @@ -428,6 +429,11 @@ export const actionSchema: FormSchema[] = [ | @@ -428,6 +429,11 @@ export const actionSchema: FormSchema[] = [ | ||
| 428 | labelField: 'itemText', | 429 | labelField: 'itemText', |
| 429 | valueField: 'itemValue', | 430 | valueField: 'itemValue', |
| 430 | getPopupContainer: () => document.body, | 431 | getPopupContainer: () => document.body, |
| 432 | + onChange(e) { | ||
| 433 | + if (e) { | ||
| 434 | + setFieldsValue({ deviceProfileId: '' }); | ||
| 435 | + } | ||
| 436 | + }, | ||
| 431 | }; | 437 | }; |
| 432 | }, | 438 | }, |
| 433 | ifShow: ({ values }) => isDeviceOut(values.outTarget), | 439 | ifShow: ({ values }) => isDeviceOut(values.outTarget), |
| @@ -440,8 +446,9 @@ export const actionSchema: FormSchema[] = [ | @@ -440,8 +446,9 @@ export const actionSchema: FormSchema[] = [ | ||
| 440 | componentProps: ({ formActionType, formModel }) => { | 446 | componentProps: ({ formActionType, formModel }) => { |
| 441 | const { setFieldsValue } = formActionType; | 447 | const { setFieldsValue } = formActionType; |
| 442 | const deviceType = formModel['deviceType']; | 448 | const deviceType = formModel['deviceType']; |
| 449 | + console.log(deviceType); | ||
| 443 | return { | 450 | return { |
| 444 | - api: deviceProfile, | 451 | + api: queryDeviceProfileBy, |
| 445 | params: { | 452 | params: { |
| 446 | deviceType, | 453 | deviceType, |
| 447 | }, | 454 | }, |