VentilateAnalysis.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <CostumeHeader :api="fetchOptions" @change="selectDeviceByID">
  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. <Pie
  12. :option="chartOption"
  13. :chart-data="[
  14. {
  15. value: 70,
  16. name: 'A',
  17. },
  18. {
  19. value: 30,
  20. name: 'B',
  21. },
  22. ]"
  23. height="140px"
  24. />
  25. <div class="flex justify-around mt-10px">
  26. <MiniBoard v-for="item in configs" :key="item.prop" :label="item.label" :value="selectedDevice[item.prop]" layout="label-top" type="D" />
  27. </div>
  28. </template>
  29. <script lang="ts" setup>
  30. import { onMounted, ref } from 'vue';
  31. import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/configuration.api';
  32. import { list } from '@/views/vent/deviceManager/deviceTable/device.api';
  33. import CostumeHeader from './CostumeHeader.vue';
  34. import { RightCircleOutlined } from '@ant-design/icons-vue';
  35. import MiniBoard from './MiniBoard.vue';
  36. import Pie from '/@/components/chart/Pie.vue';
  37. import { EChartsOption } from 'echarts';
  38. // import mapComponent from './components/3Dmap/index.vue';
  39. // 设备类别,是个枚举 TODO: 将手动换为自动获取类别
  40. const devicekind = 'windrect';
  41. const configs = ref<{ prop: string; label: string }[]>([]);
  42. function fetchConfig() {
  43. cfgList({
  44. deviceType: 'devicekind',
  45. }).then(({ records }) => {
  46. const moduleData = JSON.parse(records[0]?.moduleData);
  47. configs.value = Object.keys(moduleData).map((k) => {
  48. return {
  49. prop: k,
  50. label: moduleData[k],
  51. };
  52. });
  53. });
  54. }
  55. const devices = ref<any[]>([]);
  56. const selectedDevice = ref<any>({});
  57. function selectDeviceByID(id: string) {
  58. selectedDevice.value = devices.value.find((e) => {
  59. return e.id === id;
  60. });
  61. }
  62. // 获取全部局扇的数据,并以选项格式返回给 Header 消费
  63. function fetchOptions() {
  64. return list({
  65. devicekind,
  66. }).then(({ records }) => {
  67. devices.value = records;
  68. selectDeviceByID(records[0]?.id);
  69. return records.map((e) => {
  70. return {
  71. label: e.strinstallpos,
  72. key: e.id,
  73. };
  74. });
  75. });
  76. }
  77. // 图标相关
  78. const chartOption: EChartsOption = {
  79. series: [
  80. {
  81. type: 'pie',
  82. radius: ['50%', '75%'],
  83. center: ['50%', '55%'],
  84. data: [],
  85. labelLine: { show: false },
  86. label: {
  87. show: false,
  88. // formatter: '{b} \n ({d}%)',
  89. // color: '#B1B9D3',
  90. },
  91. itemStyle: {
  92. shadowBlur: 20,
  93. shadowColor: '#259bcf',
  94. },
  95. },
  96. ],
  97. color: ['#d9a1ff', '#00d1ff', '#82fe78'],
  98. };
  99. onMounted(() => {
  100. fetchConfig();
  101. });
  102. </script>
  103. <style scoped></style>