WorkSurface.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <ModuleBasic :title="config.moduleName" :version="config.showStyle?.version" :size="config.showStyle?.size" :position="config.showStyle?.position">
  4. <CostumeHeader v-model:value="selectedDeviceID" :options="options">
  5. <!-- <div class="w-200px flex flex-items-center">
  6. <RightCircleOutlined class="w-30px" />
  7. <div class="flex-grow-1">
  8. {{ selectedDevice.strinstallpos }}
  9. </div>
  10. </div> -->
  11. </CostumeHeader>
  12. <LineMulti
  13. :option="chartOption"
  14. :prop-type-arr="propTypeArr"
  15. x-axis-prop-type="time"
  16. :chart-data="chartData"
  17. height="140px"
  18. class="worksurface-chart"
  19. />
  20. <div class="flex justify-around">
  21. <MiniBoard
  22. v-for="(label, prop) in config.moduleData?.main"
  23. :key="`vhccws-${prop}`"
  24. :label="label"
  25. :value="get(selectedDevice, prop)"
  26. layout="label-top"
  27. type="B"
  28. />
  29. </div>
  30. </ModuleBasic>
  31. </template>
  32. <script lang="ts" setup>
  33. import LineMulti from '/@/components/chart/LineMulti.vue';
  34. import CostumeHeader from './CostumeHeader.vue';
  35. import { computed, onMounted, ref } from 'vue';
  36. import { EChartsOption } from 'echarts';
  37. import { useInitDevices } from '../hooks/useInit';
  38. import { get } from '../../billboard/utils';
  39. import _ from 'lodash-es';
  40. import MiniBoard from './MiniBoard.vue';
  41. import ModuleBasic from './moduleBasic.vue';
  42. // import mapComponent from './components/3Dmap/index.vue';
  43. // 设备类别,是个枚举 TODO: 将手动换为自动获取类别
  44. const devicekind = 'sys_surface_caimei';
  45. const config = ref({
  46. moduleName: '采煤工作面智能管控',
  47. moduleData: {
  48. main: {
  49. jin: '进风',
  50. hui: '回风',
  51. xufengliang: '需风量',
  52. },
  53. // 这里的配置比较特殊,需要配置为数据中 history 对象下的取值路径。无法针对 x 轴进行配置
  54. // 例如数据为 { history: [ jin: 10 ] },那么需要配置为 jin
  55. chart: {
  56. hui: '回风量',
  57. jin: '进风量',
  58. },
  59. },
  60. showStyle: {
  61. size: 'width:450px;height:280px;',
  62. position: 'right:0px;top:350px;',
  63. version: 'enhanced',
  64. },
  65. });
  66. // const { config: remoteConfig, fetchConfig } = useInitConfig(devicekind);
  67. const { options, selectedDevice, selectedDeviceID, fetchDevices } = useInitDevices(devicekind);
  68. onMounted(() => {
  69. // fetchConfig();
  70. fetchDevices();
  71. });
  72. const chartData = computed(() => {
  73. return selectedDevice.value.history || [];
  74. });
  75. const propTypeArr = computed(() => {
  76. const map = new Map();
  77. if (config.value.moduleData?.chart) {
  78. _.forEach(config.value.moduleData?.chart || [], (label, prop) => {
  79. map.set(prop, label);
  80. });
  81. }
  82. return map;
  83. });
  84. // 图表相关
  85. const chartOption: EChartsOption = {
  86. legend: {
  87. top: 10,
  88. right: 10,
  89. textStyle: {
  90. color: '#fff',
  91. },
  92. },
  93. grid: {
  94. top: 35,
  95. height: 80,
  96. },
  97. yAxis: {
  98. type: 'value',
  99. splitLine: {
  100. lineStyle: {
  101. color: '#fff',
  102. opacity: 0.3,
  103. },
  104. },
  105. },
  106. textStyle: {
  107. color: '#fff',
  108. },
  109. backgroundColor: '#081f33',
  110. // backgroundColor: '#0091ff12',
  111. };
  112. </script>
  113. <style scoped lang="less">
  114. @import '@/design/vent/color.less';
  115. .worksurface-chart {
  116. border: 1px solid @vent-configurable-home-light-border;
  117. }
  118. </style>