Commit 28efc718667ea6cd2d5144354fc81078bf2d955a

Authored by sqy
1 parent 47352daa

'修改首页图表逻辑及样式'

1   -import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
2   -/**
3   - * @description: Request list interface parameters
4   - */
5   -export type MessageConfigParams = BasicPageParams & MessageParams;
6   -
7   -export type MessageParams = {
8   - status?: number;
9   - messageType?: string;
10   -};
11   -
12   -export interface MessageConfig {
13   - id: string;
14   - configName: string;
15   - messageType: string;
16   - platformType: string;
17   - config: ConfigParams;
18   - createTime: string;
19   - updateTime: string;
20   - status: number;
21   -}
22   -export interface ConfigParams {
23   - host: string;
24   - port: number;
25   - username: string;
26   - password: string;
27   - accessKeyId: string;
28   - accessKeySecret: string;
29   -}
30   -
31   -/**
32   - * @description: Request list return value
33   - */
34   -export type MessageConfigResultModel = BasicFetchResult<MessageConfig>;
35   -
36   -export type MessageConfigResult = MessageConfig;
... ... @@ -82,7 +82,6 @@
82 82 padding-left: 7px;
83 83 cursor: pointer;
84 84 transition: all 0.2s ease;
85   -
86 85 &.light {
87 86 border-bottom: 1px solid @border-color-base;
88 87 }
... ...
1 1 <template>
  2 + 123
2 3 <div ref="chartRef" :style="{ height, width }"></div>
3 4 </template>
4 5 <script lang="ts" setup>
5   - import { ref, Ref, withDefaults, defineProps } from 'vue';
  6 + import { ref, Ref, withDefaults } from 'vue';
6 7 import { useECharts } from '/@/hooks/web/useECharts';
7 8
8 9 interface Props {
... ...
... ... @@ -80,7 +80,7 @@
80 80 </div>
81 81 </template>
82 82 <script lang="ts" setup>
83   - import { defineProps, defineExpose, ref, onMounted } from 'vue';
  83 + import { ref, onMounted } from 'vue';
84 84 import { Card } from 'ant-design-vue';
85 85 import { getHomeData } from '/@/api/dashboard';
86 86 import { isAdmin } from '/@/enums/roleEnum';
... ...
... ... @@ -15,22 +15,18 @@
15 15 >{{ item.label }}</span
16 16 >
17 17 </template>
18   - <DatePicker @change="onDateChange" />
  18 + <DatePicker @change="onDateChange" v-model:value="dateValue" />
19 19 </div>
20 20 </template>
21   - <div v-if="activeKey === '1'">
  21 + <div v-show="activeKey === '1'">
22 22 <p class="center">告警数</p>
23 23 <!-- 折线图 -->
24   - <VisitAnalysis v-if="!isAdmin(role)" :alarmList="state.alarmList" />
  24 + <VisitAnalysis :alarmList="state.alarmList" />
25 25 </div>
26   - <div v-if="activeKey === '2'">
  26 + <div v-show="activeKey === '2'">
27 27 <p class="center">消息量</p>
28 28 <!-- 柱形图 -->
29   - <VisitAnalysisBar
30   - v-if="!isAdmin(role)"
31   - :dataPointList="state.dataPointList"
32   - :messageList="state.messageList"
33   - />
  29 + <VisitAnalysisBar :dataPointList="state.dataPointList" :messageList="state.messageList" />
34 30 </div>
35 31 </Card>
36 32 <Card v-bind="$attrs" v-if="isAdmin(role)" title="租户趋势">
... ... @@ -73,7 +69,8 @@
73 69 },
74 70 ];
75 71 // 快速选择日期
76   - const activeIndex = ref(1);
  72 + const activeIndex = ref(3);
  73 + const dateValue = ref();
77 74 const dateList = ref([
78 75 { label: '1小时', value: 3600000 },
79 76 { label: '1天', value: 86400000 },
... ... @@ -82,7 +79,6 @@
82 79 ]);
83 80 // web Socket
84 81 const token: string = getAuthCache(JWT_TOKEN_KEY);
85   -
86 82 const state = reactive({
87 83 server: `${import.meta.env.VITE_WEB_SOCKET}${token}`,
88 84 alarmList: new Array<[number, string]>(),
... ... @@ -141,7 +137,22 @@
141 137 },
142 138 ],
143 139 });
  140 + const sendValue1 = JSON.stringify({
  141 + entityDataCmds: [
  142 + {
  143 + cmdId: activeKey.value,
  144 + historyCmd: {
  145 + keys: ['createdAlarmsCountHourly'],
  146 + startTs: Date.now() - 2592000000,
  147 + endTs: Date.now(),
  148 + interval: 86400000,
  149 + agg: 'COUNT',
  150 + },
  151 + },
  152 + ],
  153 + });
144 154 send(sendValue);
  155 + send(sendValue1);
145 156 console.log('建立连接了');
146 157 },
147 158 onMessage(_, e) {
... ... @@ -199,26 +210,30 @@
199 210 close();
200 211 },
201 212 });
  213 +
  214 + // 切换tab页
202 215 function onTabChange(key: string) {
203 216 activeKey.value = key;
204   - if (key === '1') {
205   - const sendAlarmValue = JSON.stringify({
206   - entityDataCmds: [
207   - {
208   - cmdId: activeKey.value,
209   - historyCmd: {
210   - keys: ['createdAlarmsCountHourly'],
211   - startTs: Date.now() - 86400000,
212   - endTs: Date.now(),
213   - interval: 7200000,
214   - limit: 12,
215   - agg: 'COUNT',
216   - },
  217 + activeIndex.value = 3;
  218 + dateValue.value = '';
  219 + const sendValue = JSON.stringify({
  220 + entityDataCmds: [
  221 + {
  222 + cmdId: activeKey.value,
  223 + historyCmd: {
  224 + keys:
  225 + activeKey.value === '1'
  226 + ? ['createdAlarmsCountHourly']
  227 + : ['transportMsgCountHourly', 'transportDataPointsCountHourly'],
  228 + startTs: Date.now() - 2592000000,
  229 + endTs: Date.now(),
  230 + interval: 86400000,
  231 + agg: 'COUNT',
217 232 },
218   - ],
219   - });
220   - send(sendAlarmValue);
221   - } else {
  233 + },
  234 + ],
  235 + });
  236 + if (key === '2') {
222 237 const sendMessageValue = JSON.stringify({
223 238 entityDataCmds: [
224 239 {
... ... @@ -267,24 +282,9 @@
267 282 },
268 283 ],
269 284 });
270   - const sendMessageValue2 = JSON.stringify({
271   - entityDataCmds: [
272   - {
273   - cmdId: activeKey.value,
274   - historyCmd: {
275   - keys: ['transportMsgCountHourly', 'transportDataPointsCountHourly'],
276   - startTs: Date.now() - 86400000,
277   - endTs: Date.now(),
278   - interval: 7200000,
279   - limit: 12,
280   - agg: 'COUNT',
281   - },
282   - },
283   - ],
284   - });
285 285 send(sendMessageValue);
286   - send(sendMessageValue2);
287 286 }
  287 + send(sendValue);
288 288 }
289 289 // 选择日期
290 290 function onDateChange(_, dateString) {
... ... @@ -313,12 +313,14 @@
313 313 }
314 314 // 快速选择时间
315 315 function quickQueryDate(index: number, value: number) {
  316 + if (activeIndex.value === index) return;
316 317 activeIndex.value = index;
317   - let limit = 12;
318   - if (value === 604800000) {
319   - limit = 7;
320   - } else if (value === 2592000000) {
321   - limit = 30;
  318 + dateValue.value = '';
  319 + let interval = 3600000;
  320 + if (value === 86400000) {
  321 + interval = 7200000;
  322 + } else if (value === 604800000 || value === 2592000000) {
  323 + interval = 86400000;
322 324 }
323 325 // 动态发送ws数据
324 326 const sendValue = JSON.stringify({
... ... @@ -332,8 +334,7 @@
332 334 : ['transportMsgCountHourly', 'transportDataPointsCountHourly'],
333 335 startTs: Date.now() - value,
334 336 endTs: Date.now(),
335   - interval: value > 3600000 ? 7200000 : 300000,
336   - limit,
  337 + interval,
337 338 agg: 'COUNT',
338 339 },
339 340 },
... ... @@ -341,7 +342,7 @@
341 342 });
342 343 send(sendValue);
343 344
344   - console.log(value);
  345 + console.log(JSON.parse(sendValue), '----interval');
345 346 }
346 347 </script>
347 348
... ...
1 1 <template>
  2 + 123
2 3 <div ref="chartRef" :style="{ height, width }"></div>
3 4 </template>
4 5 <script lang="ts" setup>
5   - import { ref, Ref, withDefaults, defineProps } from 'vue';
  6 + import { ref, Ref, withDefaults } from 'vue';
6 7 import { useECharts } from '/@/hooks/web/useECharts';
7 8
8 9 interface Props {
... ...
... ... @@ -2,7 +2,7 @@
2 2 <div ref="chartRef" :style="{ height, width }"></div>
3 3 </template>
4 4 <script lang="ts" setup>
5   - import { onMounted, ref, Ref, withDefaults, defineProps, watch } from 'vue';
  5 + import { onMounted, ref, Ref, withDefaults, watch } from 'vue';
6 6 import { useECharts } from '/@/hooks/web/useECharts';
7 7
8 8 interface Props {
... ... @@ -20,43 +20,29 @@
20 20 const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
21 21
22 22 onMounted(() => {
23   - console.log(props.alarmList);
24 23 setOptions({
25 24 tooltip: {
26 25 trigger: 'axis',
27   - axisPointer: {
28   - lineStyle: {
29   - width: 1,
30   - color: '#019680',
31   - },
32   - },
33 26 },
  27 + grid: {
  28 + left: '3%',
  29 + right: '4%',
  30 + bottom: '3%',
  31 + containLabel: true,
  32 + },
  33 +
34 34 xAxis: {
35 35 type: 'time',
36   - boundaryGap: false,
37   - splitLine: {
38   - show: true,
39   - lineStyle: {
40   - width: 1,
41   - type: 'solid',
42   - color: 'rgba(226,226,226,0.5)',
43   - },
44   - },
45   - axisTick: {
46   - show: false,
47   - },
48 36 },
49   - yAxis: {},
50   - grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
  37 + yAxis: {
  38 + type: 'value',
  39 + },
51 40 series: [
52 41 {
53   - smooth: true,
  42 + name: '告警数',
  43 + type: 'bar',
  44 + stack: 'Total',
54 45 data: props.alarmList,
55   - type: 'line',
56   - areaStyle: {},
57   - itemStyle: {
58   - color: '#5ab1ef',
59   - },
60 46 },
61 47 ],
62 48 });
... ... @@ -68,39 +54,26 @@
68 54 setOptions({
69 55 tooltip: {
70 56 trigger: 'axis',
71   - axisPointer: {
72   - lineStyle: {
73   - width: 1,
74   - color: '#019680',
75   - },
76   - },
77 57 },
  58 + grid: {
  59 + left: '3%',
  60 + right: '4%',
  61 + bottom: '3%',
  62 + containLabel: true,
  63 + },
  64 +
78 65 xAxis: {
79 66 type: 'time',
80   - boundaryGap: false,
81   - splitLine: {
82   - show: true,
83   - lineStyle: {
84   - width: 1,
85   - type: 'solid',
86   - color: 'rgba(226,226,226,0.5)',
87   - },
88   - },
89   - axisTick: {
90   - show: false,
91   - },
92 67 },
93   - yAxis: {},
94   - grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
  68 + yAxis: {
  69 + type: 'value',
  70 + },
95 71 series: [
96 72 {
97   - smooth: true,
  73 + name: '告警数',
  74 + type: 'bar',
  75 + stack: 'Total',
98 76 data: newValue,
99   - type: 'line',
100   - areaStyle: {},
101   - itemStyle: {
102   - color: '#5ab1ef',
103   - },
104 77 },
105 78 ],
106 79 });
... ...
... ... @@ -2,7 +2,7 @@
2 2 <div ref="chartRef" :style="{ height, width }"></div>
3 3 </template>
4 4 <script lang="ts" setup>
5   - import { ref, Ref, watch, withDefaults, defineProps } from 'vue';
  5 + import { ref, Ref, watch, withDefaults } from 'vue';
6 6 import { useECharts } from '/@/hooks/web/useECharts';
7 7 type DataItem = [number, string];
8 8 interface Props {
... ... @@ -38,21 +38,25 @@
38 38 },
39 39 yAxis: {},
40 40 grid: {
41   - bottom: 100,
  41 + left: '3%',
  42 + right: '4%',
  43 + bottom: '3%',
  44 + containLabel: true,
42 45 },
43 46 series: [
44 47 {
45   - name: '传输数据点',
  48 + name: '传输消息量',
46 49 type: 'bar',
47 50 stack: 'total',
48   - data: newValue,
  51 + data: newValue1,
  52 + color: '#5c7bd9',
49 53 },
50 54 {
51   - name: '传输消息量',
  55 + name: '传输数据点',
52 56 type: 'bar',
53 57 stack: 'total',
54   -
55   - data: newValue1,
  58 + data: newValue,
  59 + color: '#9fe080',
56 60 },
57 61 ],
58 62 });
... ...
... ... @@ -44,6 +44,13 @@
44 44 labelWidth: 120,
45 45 schemas: alarmSearchSchemas,
46 46 },
  47 + showTableSetting: true,
  48 + tableSetting: {
  49 + redo: true,
  50 + size: false,
  51 + setting: false,
  52 + fullScreen: false,
  53 + },
47 54 useSearchForm: true,
48 55 bordered: true,
49 56 showIndexColumn: false,
... ...