bizAccess.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="0">
  4. <el-form-item>
  5. <el-button type="primary" plain @click="timeSelect(0)">今天</el-button>
  6. <el-button type="primary" plain @click="timeSelect(3)">3天</el-button>
  7. <el-button type="primary" plain @click="timeSelect(7)">7天</el-button>
  8. <el-button type="primary" plain @click="timeSelect(30)">1月</el-button>
  9. </el-form-item>
  10. <el-form-item label="" style="width: 308px;margin-right:10px">
  11. <el-date-picker
  12. v-model="daterangeAlarmTime"
  13. value-format="YYYY-MM-DD"
  14. type="daterange"
  15. range-separator="-"
  16. start-placeholder="开始日期"
  17. end-placeholder="结束日期"
  18. ></el-date-picker>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  22. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row>
  26. <el-col :span="12">
  27. <div ref="chartAccess" style="height: 600px;"></div>
  28. </el-col>
  29. <el-col :span="12">
  30. <template #header>
  31. <Tickets style="width: 1em; height: 1em; vertical-align: middle;"/>
  32. <span style="vertical-align: middle;">{{ title }}</span></template>
  33. <el-table v-loading="loading" :data="leftList" v-show="sl" border style="height:300px;overflow-y: auto;">
  34. <el-table-column label="序号" align="center" width="80">
  35. <template #default="scope">
  36. <span>{{ scope.$index + 1 }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="组件名称" align="left" prop="modelName"/>
  40. <el-table-column label="系统压力值TPS/QPS" align="center" prop="access" width="150"/>
  41. <el-table-column label="访问错误次数" align="center" prop="num" width="120"/>
  42. </el-table>
  43. <el-table v-loading="loading" :data="rightList" v-show="sr" border style="height:555px;overflow-y: auto;">
  44. <el-table-column label="序号" align="center" width="120">
  45. <template #default="scope">
  46. <span>{{ scope.$index + 1 }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="组件名称" align="left" prop="objName"/>
  50. <el-table-column label="告警数量" align="center" prop="num" width="120">
  51. <template #default="scope">
  52. <el-button link type="primary" @click="msDetail(scope.row)">{{ scope.row.num }}</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <div ref="asLine" v-show="axx" style="height: 400px;padding-top: 20px;"></div>
  57. </el-col>
  58. </el-row>
  59. <!-- 添加或修改应用程序管理对话框 -->
  60. <el-dialog :title="title" v-model="open" width="800px" append-to-body>
  61. <div ref="alarmMs" style="height: 250px;"></div>
  62. <el-table v-loading="loading" :data="msList" border style="height:500px;overflow-y: auto;">
  63. <!-- <el-table-column label="风险对象" align="left" prop="objName"/>-->
  64. <!-- <el-table-column label="风险指标" align="center" prop="metricsName"/>-->
  65. <el-table-column label="序号" align="center" width="120">
  66. <template #default="scope">
  67. <span>{{ scope.$index + 1 }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="指标名称" align="center" prop="metricsName"/>
  71. <el-table-column label="风险级别" align="center" prop="alarmLevel">
  72. <template #default="scope">
  73. <dict-tag :options="alarm_level" :value="scope.row.alarmLevel"/>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="风险状态" align="center" prop="alarmType">
  77. <template #default="scope">
  78. <dict-tag :options="alarm_type" :value="scope.row.alarmType"/>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="风险值" align="center" prop="alarmValue" :formatter="rounding"/>
  82. <el-table-column label="事件时间" align="center" prop="alarmTime" width="220">
  83. <template #default="scope">
  84. <span>{{ parseTime(scope.row.alarmTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </el-dialog>
  89. </div>
  90. </template>
  91. <script setup name="Record">
  92. import {calcMs,getBizAccess} from "@/api/alarm/record";
  93. import {useRoute, useRouter} from "vue-router";
  94. import * as echarts from "echarts";
  95. import moment from "moment";
  96. import {getObjAccess, getObjAlarm} from "../../../api/alarm/record.js";
  97. const {proxy} = getCurrentInstance();
  98. const {alarm_level} = proxy.useDict('alarm_level');
  99. const {biz_type} = proxy.useDict('biz_type');
  100. const {alarm_type} = proxy.useDict('alarm_type');
  101. const leftList = ref([]);
  102. const rightList = ref([]);
  103. const open = ref(false);
  104. const sl = ref(true);
  105. const axx = ref(true);
  106. const sr = ref(false);
  107. const loading = ref(true);
  108. const showSearch = ref(true);
  109. const msList = ref([]);
  110. const ids = ref([]);
  111. const single = ref(true);
  112. const multiple = ref(true);
  113. const total = ref(0);
  114. const title = ref("");
  115. const daterangeAlarmTime = ref([]);
  116. const router = useRouter();
  117. const route = useRoute();
  118. const chartAccess = ref();
  119. const asLine = ref();
  120. const alarmMs = ref();
  121. const data = reactive({
  122. form: {},
  123. queryParams: {
  124. start: null,
  125. end: null,
  126. modeId: null
  127. },
  128. });
  129. function handleDetails(row) {
  130. console.log(row, router)
  131. }
  132. function msDetail(row) {
  133. open.value = true;
  134. title.value = "[" + row.objName + "]详情";
  135. let msParams = {
  136. objId: row.objId,
  137. params: {}
  138. };
  139. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  140. msParams.params["beginAlarmTime"] = daterangeAlarmTime.value[0];
  141. msParams.params["endAlarmTime"] = daterangeAlarmTime.value[1];
  142. }
  143. console.error(msParams)
  144. calcMs(msParams).then(response => {
  145. initMs(response.data.hour);
  146. msList.value = response.data.detail;
  147. });
  148. }
  149. const {queryParams, form} = toRefs(data);
  150. function initChart(res) {
  151. let myChart = echarts.init(chartAccess.value);
  152. let img = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjUzOTAwNTEzMjYyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxNjkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mYWNlIHsgZm9udC1mYW1pbHk6IGZlZWRiYWNrLWljb25mb250OyBzcmM6IHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUud29mZjI/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmMiIpLCB1cmwoIi8vYXQuYWxpY2RuLmNvbS90L2ZvbnRfMTAzMTE1OF91Njl3OHloeGR1LndvZmY/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmIiksIHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUudHRmP3Q9MTYzMDAzMzc1OTk0NCIpIGZvcm1hdCgidHJ1ZXR5cGUiKTsgfQo8L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDBoMzJ2MTYwaC0zMnpNNTEyIDI1NmgzMnYxNjBoLTMyek01MTIgNTEyaDMydjE2MGgtMzJ6TTUxMiA3NjhoMzJ2MTYwaC0zMnoiIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjIxNzAiPjwvcGF0aD48L3N2Zz4=";
  153. let datas = [];
  154. let legendData1 = [];
  155. let legendData2 = [];
  156. let xMax1 = 50;
  157. let xMax2 = 50;
  158. for (let i in res.data) {
  159. let obj = res.data[i];
  160. datas.push(obj.modelName);
  161. legendData1.push({id: obj.modelId, value: obj.access});
  162. legendData2.push({id: obj.modelId, value: obj.num});
  163. if (i == 0) {
  164. dl(obj.modelId, obj.modelName);
  165. }
  166. if (obj.access > xMax1) {
  167. xMax1 = obj.access;
  168. }
  169. if (obj.num > xMax2) {
  170. xMax2 = obj.num;
  171. }
  172. }
  173. let dataheng = [xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2];
  174. let option = {
  175. backgroundColor: '#fff',
  176. tooltip: {
  177. show: true,
  178. trigger: 'axis',
  179. axisPointer: {
  180. type: 'shadow',
  181. shadowStyle: {
  182. color: 'rgba(210,219,238,0.2)',
  183. },
  184. },
  185. },
  186. legend: {},
  187. grid: [{
  188. show: false,
  189. left: '0',
  190. top: 0,
  191. bottom: 22,
  192. width: '15%',
  193. },
  194. {
  195. containLabel: true,
  196. top: 0,
  197. left: '20%',
  198. bottom: '0%',
  199. width: '40%',
  200. show: false
  201. },
  202. {
  203. left: '64%',
  204. right: '10%',
  205. top: 0,
  206. bottom: '0%',
  207. containLabel: true,
  208. show: false
  209. },
  210. ],
  211. xAxis: [{
  212. gridIndex: 0,
  213. show: false,
  214. },
  215. {
  216. gridIndex: 1,
  217. show: false,
  218. max: xMax1,
  219. },
  220. {
  221. gridIndex: 2,
  222. show: false,
  223. max: xMax2,
  224. },
  225. ],
  226. yAxis: [{
  227. gridIndex: 0,
  228. type: 'category',
  229. inverse: true,
  230. position: 'right',
  231. axisLine: {
  232. show: false,
  233. },
  234. axisTick: {
  235. show: false,
  236. },
  237. data: datas.map(function (value) {
  238. return {
  239. value: value,
  240. textStyle: {
  241. align: 'right',
  242. },
  243. };
  244. }),
  245. axisLabel: {
  246. fontSize: 14,
  247. align: 'left',
  248. rich: {
  249. a: {
  250. color: '#fff',
  251. backgroundColor: '#49a2ff',
  252. width: 24,
  253. height: 24,
  254. align: 'center',
  255. borderRadius: 3,
  256. },
  257. a1: {
  258. color: '#fff',
  259. backgroundColor: '#f5576c',
  260. width: 24,
  261. height: 24,
  262. align: 'center',
  263. borderRadius: 3,
  264. },
  265. a2: {
  266. color: '#fff',
  267. backgroundColor: '#fee140',
  268. width: 24,
  269. height: 24,
  270. align: 'center',
  271. borderRadius: 3,
  272. },
  273. a3: {
  274. color: '#fff',
  275. backgroundColor: '#96fbc4',
  276. width: 24,
  277. height: 24,
  278. align: 'center',
  279. borderRadius: 3,
  280. },
  281. b: {
  282. color: '#333',
  283. width: 100,
  284. height: 30,
  285. align: 'right',
  286. },
  287. },
  288. formatter: function (params) {
  289. let index = datas.map((item) => item).indexOf(params);
  290. index = index + 1;
  291. if (index < 4) {
  292. return [`{a${index}|${index}}{b|${params}}`].join('\n');
  293. } else {
  294. return [`{a|${index}}{b|${params}}`].join('\n');
  295. }
  296. },
  297. },
  298. },
  299. {
  300. inverse: true,
  301. gridIndex: 1,
  302. data: datas,
  303. // max:10,
  304. axisLabel: {
  305. // margin: 80,
  306. show: false
  307. },
  308. axisLine: {
  309. show: false,
  310. },
  311. axisTick: {
  312. show: false,
  313. },
  314. axisPointer: {
  315. label: {
  316. show: false,
  317. margin: 30,
  318. },
  319. },
  320. },
  321. {
  322. gridIndex: 2,
  323. inverse: true,
  324. data: datas,
  325. // max:10,
  326. axisLine: {
  327. show: false,
  328. },
  329. axisTick: {
  330. show: false,
  331. },
  332. axisLabel: {
  333. show: false,
  334. },
  335. axisPointer: {
  336. label: {
  337. show: false,
  338. margin: 30,
  339. },
  340. },
  341. },
  342. ],
  343. series: [{
  344. type: 'bar',
  345. name: '系统压力值(次)',
  346. stack: '2',
  347. barWidth: 20,
  348. z: 10,
  349. barCategoryGap: 15,
  350. // barGap:i==1?'-100%':'0',
  351. xAxisIndex: 1,
  352. yAxisIndex: 1,
  353. itemStyle: {
  354. color: '#419491',
  355. barBorderRadius: [0, 10, 10, 0],
  356. // barBorderRadius: legendData[i].barBorderRadius,
  357. emphasis: {
  358. color: '#419491',
  359. },
  360. },
  361. // 数字
  362. label: {
  363. show: true,
  364. position: 'inside',
  365. right: 0,
  366. color: '#fff',
  367. formatter: function (params) {
  368. if (params.value == 0) {
  369. return '';
  370. } else {
  371. return params.value;
  372. }
  373. },
  374. },
  375. data: legendData1,
  376. },
  377. //虚线
  378. {
  379. name: '',
  380. type: 'pictorialBar',
  381. xAxisIndex: 1,
  382. yAxisIndex: 1,
  383. symbolSize: [7, 30],
  384. symbolOffset: [15, 0],
  385. symbol: 'image://' + img,
  386. symbolPosition: 'end',
  387. barWidth: "20",
  388. z: 12,
  389. color: '#fe5959',
  390. data: dataheng,
  391. tooltip: {
  392. show: false,
  393. },
  394. },
  395. //右边的柱状图
  396. {
  397. xAxisIndex: 2,
  398. yAxisIndex: 2,
  399. type: 'bar',
  400. name: '告警数量(次)',
  401. stack: '3',
  402. barWidth: 30,
  403. barCategoryGap: 15,
  404. // barGap:i==1?'-100%':'0',
  405. itemStyle: {
  406. color: '#FFB25C',
  407. barBorderRadius: [0, 20, 20, 0],
  408. emphasis: {
  409. color: '#FFB25C',
  410. },
  411. },
  412. // 数字
  413. label: {
  414. normal: {
  415. color: '#000',
  416. show: true,
  417. position: 'right',
  418. distance: 4,
  419. textStyle: {
  420. fontSize: 16,
  421. },
  422. formatter: '{c}',
  423. },
  424. },
  425. data: legendData2,
  426. },
  427. ],
  428. };
  429. // 3.配置项和数据给实例化对象
  430. myChart.setOption(option);
  431. myChart.on("click", function (param) {
  432. if (param.seriesIndex == 0) {
  433. dl(param.data.id, param.name);
  434. } else {
  435. dr(param.data.id, param.name);
  436. }
  437. console.log(param);
  438. // console.error(param,param.data.id,param.data.value,param.name);
  439. // let url = '/zabbix/zabbix.php?action=map.view&sysmapid=2&kiosk=1&line';
  440. });
  441. }
  442. function initMs(res) {
  443. let myChart = echarts.init(alarmMs.value);
  444. let yd = [];
  445. let xd = [];
  446. for (let i = 0; i < res.length; i++) {
  447. xd.push(res[i].hour);
  448. yd.push(res[i].num);
  449. }
  450. let ss = [];
  451. let xx = {
  452. // name: xd,
  453. type: 'line',
  454. data: yd,
  455. symbolSize: 1,
  456. symbol: 'circle',
  457. smooth: true,
  458. showSymbol: false,
  459. }
  460. ss.push(xx);
  461. let x_data = xd;
  462. let option = {
  463. backgroundColor: '#FFFFFF',
  464. dataZoom: {
  465. type: 'inside', // 内置型数据区域缩放组件
  466. start: 0, // 默认为0,表示从头开始
  467. end: 100 // 默认为100,表示直到末尾
  468. },
  469. title: {
  470. show: true,
  471. text: '告警趋势',
  472. // textStyle: {
  473. // fontFamily: 'PingFangSC-Regular, PingFang SC',
  474. // fontSize: 16,
  475. // fontWeight: 600,
  476. // color: '#848E98'
  477. // },
  478. left: 'left',
  479. // top: '3%'
  480. },
  481. legend: {
  482. icon: 'rect',
  483. top: '3%',
  484. right: '10%',
  485. itemWidth: 10,
  486. itemHeight: 10,
  487. itemGap: 20,
  488. textStyle: {
  489. fontFamily: 'PingFangSC-Regular, PingFang SC',
  490. color: '#848E98'
  491. }
  492. },
  493. tooltip: {
  494. trigger: 'axis',
  495. axisPointer: {
  496. label: {
  497. show: true,
  498. backgroundColor: '#fff',
  499. color: '#556677',
  500. borderColor: 'rgba(0,0,0,0)',
  501. shadowColor: 'rgba(0,0,0,0)',
  502. shadowOffsetY: 0
  503. },
  504. lineStyle: {
  505. width: 0
  506. }
  507. },
  508. backgroundColor: '#fff',
  509. textStyle: {
  510. color: '#5c6c7c'
  511. },
  512. padding: [10, 10],
  513. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  514. },
  515. grid: {
  516. top: '18%'
  517. },
  518. xAxis: [{
  519. type: 'category',
  520. data: x_data,
  521. axisLine: {
  522. show: false,
  523. lineStyle: {
  524. color: '#000000'
  525. }
  526. },
  527. axisTick: {
  528. show: false
  529. },
  530. axisLabel: {
  531. interval: 'auto',
  532. rotate: 45,
  533. textStyle: {
  534. color: '#B7C3CE'
  535. },
  536. // 默认x轴字体大小
  537. fontSize: 12,
  538. // margin:文字到x轴的距离
  539. margin: 5,
  540. hideOverlap: true // 隐藏部分标签避免重叠
  541. }
  542. }],
  543. yAxis: [{
  544. type: 'value',
  545. axisTick: {
  546. show: false
  547. },
  548. axisLine: {
  549. show: false,
  550. },
  551. axisLabel: {
  552. fontSize: 12,
  553. textStyle: {
  554. color: '#B7C3CE'
  555. }
  556. },
  557. splitLine: {
  558. show: true,
  559. lineStyle: {
  560. type: "dashed"
  561. }
  562. }
  563. }],
  564. series: ss
  565. };
  566. myChart.setOption(option)
  567. }
  568. function dl(modelId, name) {
  569. title.value = "[" + name + "] 组件压力排行";
  570. sl.value = true;
  571. axx.value = true;
  572. sr.value = false;
  573. queryParams.value.modelId = modelId;
  574. queryParams.value.params = {};
  575. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  576. queryParams.value.start = daterangeAlarmTime.value[0];
  577. queryParams.value.end = daterangeAlarmTime.value[1];
  578. }
  579. getObjAccess(queryParams.value).then(response => {
  580. loading.value = false;
  581. leftList.value = response.data.objs;
  582. line(response.data.datas);
  583. });
  584. }
  585. function dr(modelId, name) {
  586. title.value = "[" + name + "] 组件告警数量排行";
  587. sl.value = false;
  588. axx.value = false;
  589. sr.value = true;
  590. queryParams.value.modelId = modelId;
  591. queryParams.value.params = {};
  592. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  593. queryParams.value.start = daterangeAlarmTime.value[0];
  594. queryParams.value.end = daterangeAlarmTime.value[1];
  595. }
  596. getObjAlarm(queryParams.value).then(response => {
  597. loading.value = false;
  598. rightList.value = response.data;
  599. });
  600. }
  601. function line(data) {
  602. let myChart = echarts.init(asLine.value);
  603. let colorList = [
  604. '#419491',
  605. '#3581F8',
  606. '#FFB25C',
  607. ];
  608. let x_data = [];
  609. let max_data = [];
  610. let avg_data = [];
  611. let err_data = [];
  612. for (let i = 0; i < data.length; i++) {
  613. x_data.push(data[i].time);
  614. max_data.push(data[i].max);
  615. avg_data.push(data[i].avg);
  616. err_data.push(data[i].error);
  617. }
  618. let option = {
  619. backgroundColor: '#FFFFFF',
  620. dataZoom: {
  621. type: 'inside', // 内置型数据区域缩放组件
  622. start: 0, // 默认为0,表示从头开始
  623. end: 50 // 默认为100,表示直到末尾
  624. },
  625. title: {
  626. show: true,
  627. text: '系统压力值趋势',
  628. // subtext:'分配总量:18041核\n释放总量:5288核',
  629. // textStyle: {
  630. // fontFamily: 'PingFangSC-Regular, PingFang SC',
  631. // fontSize: 14,
  632. // fontWeight: 400,
  633. // color: '#848E98'
  634. // },
  635. left: 'left',
  636. top: '3%'
  637. },
  638. legend: {
  639. icon: 'rect',
  640. top: '3%',
  641. right: '10%',
  642. itemWidth: 10,
  643. itemHeight: 10,
  644. itemGap: 20,
  645. textStyle: {
  646. fontFamily: 'PingFangSC-Regular, PingFang SC',
  647. color: '#848E98'
  648. }
  649. },
  650. tooltip: {
  651. trigger: 'axis',
  652. axisPointer: {
  653. label: {
  654. show: true,
  655. backgroundColor: '#fff',
  656. color: '#556677',
  657. borderColor: 'rgba(0,0,0,0)',
  658. shadowColor: 'rgba(0,0,0,0)',
  659. shadowOffsetY: 0
  660. },
  661. lineStyle: {
  662. width: 0
  663. }
  664. },
  665. backgroundColor: '#fff',
  666. textStyle: {
  667. color: '#5c6c7c'
  668. },
  669. padding: [10, 10],
  670. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  671. },
  672. grid: {
  673. top: '18%'
  674. },
  675. xAxis: [{
  676. type: 'category',
  677. data: x_data,
  678. axisLine: {
  679. show: false,
  680. lineStyle: {
  681. color: '#000000'
  682. }
  683. },
  684. axisTick: {
  685. show: false
  686. },
  687. axisLabel: {
  688. interval: 'auto',
  689. rotate: 45,
  690. textStyle: {
  691. color: '#B7C3CE'
  692. },
  693. // 默认x轴字体大小
  694. fontSize: 12,
  695. // margin:文字到x轴的距离
  696. margin: 5
  697. }
  698. }],
  699. yAxis: [{
  700. type: 'value',
  701. // name: "核数",
  702. // position: 'left',
  703. // offset: 55,
  704. axisTick: {
  705. show: false
  706. },
  707. axisLine: {
  708. show: false,
  709. },
  710. axisLabel: {
  711. fontSize: 12,
  712. textStyle: {
  713. color: '#B7C3CE'
  714. }
  715. },
  716. splitLine: {
  717. show: true,
  718. lineStyle: {
  719. type: "dashed"
  720. }
  721. }
  722. }],
  723. series: [{
  724. name: '最大值',
  725. type: 'line',
  726. data: max_data,
  727. symbolSize: 1,
  728. symbol: 'circle',
  729. smooth: true,
  730. showSymbol: false,
  731. lineStyle: {
  732. width: 1,
  733. type: 'dotted', //'dotted'虚线 'solid'实线
  734. },
  735. itemStyle: {
  736. normal: {
  737. color: colorList[0],
  738. borderColor: colorList[0]
  739. }
  740. }
  741. }, {
  742. name: '平均值',
  743. type: 'line',
  744. data: avg_data,
  745. symbolSize: 1,
  746. symbol: 'circle',
  747. smooth: true,
  748. showSymbol: false,
  749. lineStyle: {
  750. width: 1,
  751. },
  752. itemStyle: {
  753. normal: {
  754. color: colorList[1],
  755. borderColor: colorList[1]
  756. }
  757. }
  758. },
  759. {
  760. name: '错误次数',
  761. type: 'line',
  762. data: err_data,
  763. symbolSize: 1,
  764. symbol: 'circle',
  765. smooth: true,
  766. showSymbol: false,
  767. lineStyle: {
  768. width: 1,
  769. },
  770. itemStyle: {
  771. normal: {
  772. color: colorList[2],
  773. borderColor: colorList[2]
  774. }
  775. }
  776. }
  777. ]
  778. };
  779. myChart.setOption(option);
  780. }
  781. /** 查询告警记录列表 */
  782. function getList() {
  783. loading.value = true;
  784. queryParams.value.params = {};
  785. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  786. queryParams.value.start = daterangeAlarmTime.value[0];
  787. queryParams.value.end = daterangeAlarmTime.value[1];
  788. }
  789. getBizAccess(queryParams.value).then(response => {
  790. // recordList.value = response.rows;
  791. // total.value = response.total;
  792. loading.value = false;
  793. initChart(response);
  794. });
  795. }
  796. /** 搜索按钮操作 */
  797. function handleQuery() {
  798. queryParams.value.pageNum = 1;
  799. getList();
  800. }
  801. function timeSelect(v) {
  802. let end = new Date();
  803. let start = new Date().setDate(end.getDate() - v);
  804. daterangeAlarmTime.value[0] = moment(start).format('YYYY-MM-DD');
  805. daterangeAlarmTime.value[1] = moment(end).format('YYYY-MM-DD');
  806. }
  807. /** 重置按钮操作 */
  808. function resetQuery() {
  809. daterangeAlarmTime.value = [];
  810. proxy.resetForm("queryRef");
  811. handleQuery();
  812. }
  813. if (route.query.today) {
  814. timeSelect(0);
  815. } else {
  816. timeSelect(30);
  817. }
  818. getList();
  819. </script>