WorkSurface.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <CostumeHeader v-model:value="selectedDeviceID" :options="options">
  4. <!-- <div class="w-200px flex flex-items-center">
  5. <RightCircleOutlined class="w-30px" />
  6. <div class="flex-grow-1">
  7. {{ selectedDevice.strinstallpos }}
  8. </div>
  9. </div> -->
  10. </CostumeHeader>
  11. <LineMulti
  12. :option="chartOption"
  13. :prop-type-arr="propTypeArr"
  14. x-axis-prop-type="x"
  15. :chart-data="chartData"
  16. height="140px"
  17. class="worksurface-chart"
  18. />
  19. <div class="flex justify-around">
  20. <MiniBoard
  21. v-for="(label, prop) in configs.list"
  22. :key="`vhccws-${prop}`"
  23. :label="label"
  24. :value="get(selectedDevice, prop)"
  25. layout="label-top"
  26. type="B"
  27. />
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import LineMulti from '/@/components/chart/LineMulti.vue';
  32. import CostumeHeader from './CostumeHeader.vue';
  33. import { computed, onMounted, ref } from 'vue';
  34. import { EChartsOption } from 'echarts';
  35. import { useInitConfig, useInitDevices } from '../hooks/useInit';
  36. import { get } from '../../billboard/utils';
  37. import _ from 'lodash-es';
  38. import MiniBoard from './MiniBoard.vue';
  39. // import mapComponent from './components/3Dmap/index.vue';
  40. // 设备类别,是个枚举 TODO: 将手动换为自动获取类别
  41. const devicekind = 'fanlocal';
  42. const { configs, fetchConfig } = useInitConfig(devicekind);
  43. const { options, selectedDevice, selectedDeviceID, fetchDevices } = useInitDevices(devicekind);
  44. onMounted(() => {
  45. fetchConfig();
  46. fetchDevices();
  47. });
  48. const chartData = ref<any[]>([
  49. { valueA: 1, valueB: 3, x: 2 },
  50. { valueA: 2, valueB: 1, x: 3 },
  51. { valueA: 1, valueB: 1, x: 4 },
  52. { valueA: 3, valueB: 2, x: 5 },
  53. { valueA: 2, valueB: 1, x: 6 },
  54. { valueA: 1, valueB: 2, x: 7 },
  55. ]);
  56. const propTypeArr = computed(() => {
  57. if (configs.value.chart) {
  58. const map = new Map();
  59. _.forEach(configs.value.chart || [], (label, prop) => {
  60. map.set(prop, label);
  61. });
  62. return map;
  63. } else {
  64. return new Map([
  65. ['valueA', '值A'],
  66. ['valueB', '值B'],
  67. ]);
  68. }
  69. });
  70. function fetchChartData() {}
  71. onMounted(() => {
  72. fetchChartData();
  73. });
  74. // 图表相关
  75. const chartOption: EChartsOption = {
  76. legend: {
  77. top: 10,
  78. right: 10,
  79. textStyle: {
  80. color: '#fff',
  81. },
  82. },
  83. grid: {
  84. top: 35,
  85. height: 80,
  86. },
  87. yAxis: {
  88. type: 'value',
  89. splitLine: {
  90. lineStyle: {
  91. color: '#fff',
  92. opacity: 0.3,
  93. },
  94. },
  95. },
  96. textStyle: {
  97. color: '#fff',
  98. },
  99. backgroundColor: '#081f33',
  100. // backgroundColor: '#0091ff12',
  101. };
  102. </script>
  103. <style scoped lang="less">
  104. @import '@/design/vent/color.less';
  105. .worksurface-chart {
  106. border: 1px solid @vent-configurable-home-light-border;
  107. }
  108. </style>