bizAccess.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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="15">
  27. <div ref="chartAccess" style="height: 600px;"></div>
  28. </el-col>
  29. <el-col :span="9">
  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="60">
  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" width="150"/>
  40. <el-table-column label="应用编码" align="left" prop="code" width="150">
  41. <template #default="scope">
  42. <el-button link type="primary" @click="jumpPP(scope.row)">{{ scope.row.code }}</el-button>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="系统压力值TPS/QPS" align="center" prop="access" width="150"/>
  46. <el-table-column label="访问错误次数" align="center" prop="num" width="120"/>
  47. </el-table>
  48. <el-table v-loading="loading" :data="rightList" v-show="sr" border style="height:555px;overflow-y: auto;">
  49. <el-table-column label="序号" align="center" width="120">
  50. <template #default="scope">
  51. <span>{{ scope.$index + 1 }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="组件名称" align="left" prop="objName"/>
  55. <el-table-column label="告警数量" align="center" prop="num" width="120">
  56. <template #default="scope">
  57. <el-button link type="primary" @click="msDetail(scope.row)">{{ scope.row.num }}</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <div ref="asLine" v-show="axx" style="height: 400px;padding-top: 20px;"></div>
  62. </el-col>
  63. </el-row>
  64. <!-- 添加或修改应用程序管理对话框 -->
  65. <el-dialog :title="title" v-model="open" width="800px" append-to-body>
  66. <div ref="alarmMs" style="height: 250px;"></div>
  67. <el-table v-loading="loading" :data="msList" border style="height:500px;overflow-y: auto;">
  68. <!-- <el-table-column label="风险对象" align="left" prop="objName"/>-->
  69. <!-- <el-table-column label="风险指标" align="center" prop="metricsName"/>-->
  70. <el-table-column label="序号" align="center" width="120">
  71. <template #default="scope">
  72. <span>{{ scope.$index + 1 }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="指标名称" align="center" prop="metricsName"/>
  76. <el-table-column label="风险级别" align="center" prop="alarmLevel">
  77. <template #default="scope">
  78. <dict-tag :options="alarm_level" :value="scope.row.alarmLevel"/>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="风险状态" align="center" prop="alarmType">
  82. <template #default="scope">
  83. <dict-tag :options="alarm_type" :value="scope.row.alarmType"/>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="风险值" align="center" prop="alarmValue" :formatter="rounding"/>
  87. <el-table-column label="事件时间" align="center" prop="alarmTime" width="220">
  88. <template #default="scope">
  89. <span>{{ parseTime(scope.row.alarmTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script setup name="Record">
  97. import {calcMs, getBizAccess} from "@/api/alarm/record";
  98. import {useRoute, useRouter} from "vue-router";
  99. import * as echarts from "echarts";
  100. import moment from "moment";
  101. import {getObjAccess, getObjAlarm} from "../../../api/alarm/record.js";
  102. const {proxy} = getCurrentInstance();
  103. const {alarm_level} = proxy.useDict('alarm_level');
  104. const {biz_type} = proxy.useDict('biz_type');
  105. const {alarm_type} = proxy.useDict('alarm_type');
  106. const leftList = ref([]);
  107. const rightList = ref([]);
  108. const open = ref(false);
  109. const sl = ref(true);
  110. const axx = ref(true);
  111. const sr = ref(false);
  112. const loading = ref(true);
  113. const showSearch = ref(true);
  114. const msList = ref([]);
  115. const ids = ref([]);
  116. const single = ref(true);
  117. const multiple = ref(true);
  118. const total = ref(0);
  119. const title = ref("");
  120. const daterangeAlarmTime = ref([]);
  121. const router = useRouter();
  122. const route = useRoute();
  123. const chartAccess = ref();
  124. const asLine = ref();
  125. const alarmMs = ref();
  126. const data = reactive({
  127. form: {},
  128. queryParams: {
  129. start: null,
  130. end: null,
  131. modeId: null
  132. },
  133. });
  134. function jumpPP(row) {
  135. const today = new Date();
  136. today.setHours(0, 0, 0, 0);
  137. const now = new Date();
  138. now.setHours(now.getHours(), now.getMinutes(), 0, 0);
  139. let num = (now - today) / (1000 * 60);
  140. num = num.toFixed(0);
  141. const last = formatDate(now);
  142. const suffix = '/main/' + row.code + '@SPRING_BOOT/' + num + '分钟/' + last;
  143. router.push({path: '/link/pp-link/', query: {suffix: suffix}})
  144. }
  145. function formatDate(date) {
  146. const day = date.getDate().toString().padStart(2, '0');
  147. const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的
  148. const year = date.getFullYear();
  149. const hours = date.getHours().toString().padStart(2, '0');
  150. const minutes = date.getMinutes().toString().padStart(2, '0');
  151. const seconds = date.getSeconds().toString().padStart(2, '0');
  152. return `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;
  153. }
  154. function handleDetails(row) {
  155. console.log(row, router)
  156. }
  157. function msDetail(row) {
  158. open.value = true;
  159. title.value = "[" + row.objName + "]详情";
  160. let msParams = {
  161. objId: row.objId,
  162. params: {}
  163. };
  164. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  165. msParams.params["beginAlarmTime"] = daterangeAlarmTime.value[0];
  166. msParams.params["endAlarmTime"] = daterangeAlarmTime.value[1];
  167. }
  168. console.error(msParams)
  169. calcMs(msParams).then(response => {
  170. initMs(response.data.hour);
  171. msList.value = response.data.detail;
  172. });
  173. }
  174. const {queryParams, form} = toRefs(data);
  175. function initChart(res) {
  176. let myChart = echarts.init(chartAccess.value);
  177. let img = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjUzOTAwNTEzMjYyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxNjkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mYWNlIHsgZm9udC1mYW1pbHk6IGZlZWRiYWNrLWljb25mb250OyBzcmM6IHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUud29mZjI/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmMiIpLCB1cmwoIi8vYXQuYWxpY2RuLmNvbS90L2ZvbnRfMTAzMTE1OF91Njl3OHloeGR1LndvZmY/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmIiksIHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUudHRmP3Q9MTYzMDAzMzc1OTk0NCIpIGZvcm1hdCgidHJ1ZXR5cGUiKTsgfQo8L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDBoMzJ2MTYwaC0zMnpNNTEyIDI1NmgzMnYxNjBoLTMyek01MTIgNTEyaDMydjE2MGgtMzJ6TTUxMiA3NjhoMzJ2MTYwaC0zMnoiIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjIxNzAiPjwvcGF0aD48L3N2Zz4=";
  178. let datas = [];
  179. let legendData1 = [];
  180. let legendData2 = [];
  181. let legendData3 = [];
  182. let legendData4 = [];
  183. let legendData5 = [];
  184. let dataheng = [];
  185. let xMax1 = 50;
  186. let xMax2 = 1;
  187. let xMax3 = 10000;
  188. let xMax4 = 10000;
  189. let xMax5 = 10000;
  190. for (let i in res.data) {
  191. let obj = res.data[i];
  192. datas.push(obj.modelName);
  193. //访问次数
  194. legendData1.push({id: obj.modelId, value: obj.access});
  195. //访问错误
  196. legendData2.push({id: obj.modelId, value: obj.num});
  197. //告警
  198. legendData3.push({id: obj.modelId, value: obj.n1});
  199. //服务数量
  200. legendData4.push({id: obj.modelId, value: obj.n2});
  201. //容器数量
  202. legendData5.push({id: obj.modelId, value: obj.n3});
  203. if (i == 0) {
  204. dl(obj.modelId, obj.modelName);
  205. }
  206. if (obj.access > xMax1) {
  207. xMax1 = obj.access;
  208. }
  209. if (obj.num > xMax2) {
  210. xMax2 = obj.num;
  211. }
  212. if (obj.n1 > xMax3) {
  213. xMax3 = obj.n1;
  214. }
  215. if (obj.n2 > xMax4) {
  216. xMax4 = obj.n2;
  217. }
  218. if (obj.n3 > xMax5) {
  219. xMax5 = obj.n3;
  220. }
  221. }
  222. for (let i in res.data) {
  223. dataheng.push(xMax1 + 2);
  224. }
  225. // let dataheng = [xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2];
  226. let option = {
  227. backgroundColor: '#fff',
  228. tooltip: {
  229. show: true,
  230. trigger: 'axis',
  231. axisPointer: {
  232. type: 'shadow',
  233. shadowStyle: {
  234. color: 'rgba(210,219,238,0.2)',
  235. },
  236. },
  237. },
  238. legend: {},
  239. grid: [{
  240. show: false,
  241. left: '0',
  242. top: 30,
  243. bottom: 22,
  244. width: '14%',
  245. },
  246. {
  247. containLabel: true,
  248. top: 30,
  249. left: '20%',
  250. bottom: '0%',
  251. width: '30%',
  252. show: false
  253. },
  254. {
  255. left: '52%',
  256. right: '10%',
  257. top: 30,
  258. bottom: '0%',
  259. width: '10%',
  260. containLabel: true,
  261. show: false
  262. },
  263. {
  264. left: '70%',
  265. // right: '2%',
  266. top: 30,
  267. bottom: '0%',
  268. width: '10%',
  269. containLabel: true,
  270. show: false
  271. },
  272. {
  273. left: '80%',
  274. // right: '2%',
  275. width: '10%',
  276. top: 30,
  277. bottom: '0%',
  278. containLabel: true,
  279. show: false
  280. },
  281. {
  282. left: '90%',
  283. // right: '2%',
  284. width: '10%',
  285. top: 30,
  286. bottom: '0%',
  287. containLabel: true,
  288. show: false
  289. },
  290. ],
  291. xAxis: [{
  292. gridIndex: 0,
  293. show: false,
  294. },
  295. {
  296. gridIndex: 1,
  297. show: false,
  298. max: xMax1,
  299. },
  300. {
  301. gridIndex: 2,
  302. show: false,
  303. max: xMax2,
  304. },
  305. {
  306. gridIndex: 3,
  307. show: false,
  308. max: xMax3,
  309. },
  310. {
  311. gridIndex: 4,
  312. show: false,
  313. max: xMax4,
  314. },
  315. {
  316. gridIndex: 5,
  317. show: false,
  318. max: xMax5,
  319. },
  320. ],
  321. yAxis: [{
  322. gridIndex: 0,
  323. type: 'category',
  324. inverse: true,
  325. position: 'right',
  326. axisLine: {
  327. show: false,
  328. },
  329. axisTick: {
  330. show: false,
  331. },
  332. data: datas.map(function (value) {
  333. return {
  334. value: value,
  335. textStyle: {
  336. align: 'right',
  337. },
  338. };
  339. }),
  340. axisLabel: {
  341. fontSize: 14,
  342. align: 'left',
  343. rich: {
  344. a: {
  345. color: '#fff',
  346. backgroundColor: '#49a2ff',
  347. width: 24,
  348. height: 24,
  349. align: 'center',
  350. borderRadius: 3,
  351. },
  352. a1: {
  353. color: '#fff',
  354. backgroundColor: '#f5576c',
  355. width: 24,
  356. height: 24,
  357. align: 'center',
  358. borderRadius: 3,
  359. },
  360. a2: {
  361. color: '#fff',
  362. backgroundColor: '#fee140',
  363. width: 24,
  364. height: 24,
  365. align: 'center',
  366. borderRadius: 3,
  367. },
  368. a3: {
  369. color: '#fff',
  370. backgroundColor: '#96fbc4',
  371. width: 24,
  372. height: 24,
  373. align: 'center',
  374. borderRadius: 3,
  375. },
  376. b: {
  377. color: '#333',
  378. width: 100,
  379. height: 30,
  380. align: 'right',
  381. },
  382. },
  383. formatter: function (params) {
  384. let index = datas.map((item) => item).indexOf(params);
  385. index = index + 1;
  386. if (index < 4) {
  387. return [`{a${index}|${index}}{b|${params}}`].join('\n');
  388. } else {
  389. return [`{a|${index}}{b|${params}}`].join('\n');
  390. }
  391. },
  392. },
  393. },
  394. {
  395. inverse: true,
  396. gridIndex: 1,
  397. data: datas,
  398. // max:10,
  399. axisLabel: {
  400. // margin: 80,
  401. show: false
  402. },
  403. axisLine: {
  404. show: false,
  405. },
  406. axisTick: {
  407. show: false,
  408. },
  409. axisPointer: {
  410. label: {
  411. show: false,
  412. margin: 30,
  413. },
  414. },
  415. },
  416. {
  417. gridIndex: 2,
  418. inverse: true,
  419. data: datas,
  420. // max:10,
  421. axisLine: {
  422. show: false,
  423. },
  424. axisTick: {
  425. show: false,
  426. },
  427. axisLabel: {
  428. show: false,
  429. },
  430. axisPointer: {
  431. label: {
  432. show: false,
  433. margin: 30,
  434. },
  435. },
  436. },
  437. {
  438. gridIndex: 3,
  439. inverse: true,
  440. data: datas,
  441. // max:10,
  442. axisLine: {
  443. show: false,
  444. },
  445. axisTick: {
  446. show: false,
  447. },
  448. axisLabel: {
  449. show: false,
  450. },
  451. axisPointer: {
  452. label: {
  453. show: false,
  454. margin: 30,
  455. },
  456. },
  457. },
  458. {
  459. gridIndex: 4,
  460. inverse: true,
  461. data: datas,
  462. // max:10,
  463. axisLine: {
  464. show: false,
  465. },
  466. axisTick: {
  467. show: false,
  468. },
  469. axisLabel: {
  470. show: false,
  471. },
  472. axisPointer: {
  473. label: {
  474. show: false,
  475. margin: 30,
  476. },
  477. },
  478. },
  479. {
  480. gridIndex: 5,
  481. inverse: true,
  482. data: datas,
  483. // max:10,
  484. axisLine: {
  485. show: false,
  486. },
  487. axisTick: {
  488. show: false,
  489. },
  490. axisLabel: {
  491. show: false,
  492. },
  493. axisPointer: {
  494. label: {
  495. show: false,
  496. margin: 30,
  497. },
  498. },
  499. },
  500. ],
  501. series: [{
  502. type: 'bar',
  503. name: '系统压力值(次)',
  504. stack: '2',
  505. barWidth: 20,
  506. z: 10,
  507. barCategoryGap: 15,
  508. // barGap:i==1?'-100%':'0',
  509. xAxisIndex: 1,
  510. yAxisIndex: 1,
  511. itemStyle: {
  512. color: '#419491',
  513. barBorderRadius: [0, 10, 10, 0],
  514. // barBorderRadius: legendData[i].barBorderRadius,
  515. emphasis: {
  516. color: '#419491',
  517. },
  518. },
  519. // 数字
  520. label: {
  521. show: true,
  522. position: 'inside',
  523. right: 0,
  524. color: '#fff',
  525. formatter: function (params) {
  526. if (params.value == 0) {
  527. return '';
  528. } else {
  529. return params.value;
  530. }
  531. },
  532. },
  533. data: legendData1,
  534. },
  535. //虚线
  536. {
  537. name: '',
  538. type: 'pictorialBar',
  539. xAxisIndex: 1,
  540. yAxisIndex: 1,
  541. symbolSize: [7, 30],
  542. symbolOffset: [15, 0],
  543. symbol: 'image://' + img,
  544. symbolPosition: 'end',
  545. barWidth: "20",
  546. z: 999,
  547. color: '#fe5959',
  548. data: dataheng,
  549. tooltip: {
  550. show: false,
  551. },
  552. },
  553. //右边的柱状图
  554. {
  555. xAxisIndex: 2,
  556. yAxisIndex: 2,
  557. type: 'bar',
  558. name: '访问错误(次)',
  559. stack: '3',
  560. barWidth: 20,
  561. barCategoryGap: 15,
  562. // barGap:i==1?'-100%':'0',
  563. itemStyle: {
  564. color: '#FFB25C',
  565. barBorderRadius: [0, 20, 20, 0],
  566. emphasis: {
  567. color: '#FFB25C',
  568. },
  569. },
  570. // 数字
  571. label: {
  572. normal: {
  573. color: '#FFB25C',
  574. show: true,
  575. position: 'right',
  576. distance: 4,
  577. textStyle: {
  578. fontSize: 16,
  579. },
  580. formatter: '{c}',
  581. },
  582. },
  583. data: legendData2,
  584. },
  585. //右边的柱状图
  586. {
  587. xAxisIndex: 3,
  588. yAxisIndex: 3,
  589. type: 'bar',
  590. name: '告警(次)',
  591. barWidth: 1,
  592. barCategoryGap: 15,
  593. // barGap:i==1?'-100%':'0',
  594. itemStyle: {
  595. color: '#333333',
  596. barBorderRadius: [0, 20, 20, 0],
  597. emphasis: {
  598. color: '#333333',
  599. },
  600. },
  601. // 数字
  602. label: {
  603. normal: {
  604. color: '#333333',
  605. show: true,
  606. position: 'right',
  607. distance: 4,
  608. textStyle: {
  609. fontSize: 16,
  610. },
  611. formatter: '{c}',
  612. },
  613. },
  614. data: legendData3,
  615. },
  616. //右边的柱状图
  617. {
  618. xAxisIndex: 4,
  619. yAxisIndex: 4,
  620. type: 'bar',
  621. name: '服务数量(个)',
  622. barWidth: 1,
  623. barCategoryGap: 15,
  624. // barGap:i==1?'-100%':'0',
  625. itemStyle: {
  626. color: '#555555',
  627. barBorderRadius: [0, 20, 20, 0],
  628. emphasis: {
  629. color: '#555555',
  630. },
  631. },
  632. // 数字
  633. label: {
  634. normal: {
  635. color: '#555555',
  636. show: true,
  637. position: 'right',
  638. distance: 4,
  639. textStyle: {
  640. fontSize: 16,
  641. },
  642. formatter: '{c}',
  643. },
  644. },
  645. data: legendData4,
  646. },
  647. //右边的柱状图
  648. {
  649. xAxisIndex: 5,
  650. yAxisIndex: 5,
  651. type: 'bar',
  652. name: '容器数量(个)',
  653. barWidth: 1,
  654. barCategoryGap: 15,
  655. // barGap:i==1?'-100%':'0',
  656. itemStyle: {
  657. color: '#888888',
  658. barBorderRadius: [0, 20, 20, 0],
  659. emphasis: {
  660. color: '#888888',
  661. },
  662. },
  663. // 数字
  664. label: {
  665. normal: {
  666. color: '#888888',
  667. show: true,
  668. position: 'right',
  669. distance: 4,
  670. textStyle: {
  671. fontSize: 16,
  672. },
  673. formatter: '{c}',
  674. },
  675. },
  676. data: legendData5,
  677. },
  678. ],
  679. };
  680. // 3.配置项和数据给实例化对象
  681. myChart.setOption(option);
  682. myChart.on("click", function (param) {
  683. switch (param.seriesIndex) {
  684. case 0:
  685. case 1:
  686. case 2:
  687. dl(param.data.id, param.name);
  688. break;
  689. case 3:
  690. dr(param.data.id, param.name);
  691. break;
  692. }
  693. // if (param.seriesIndex == 0) {
  694. // dl(param.data.id, param.name);
  695. // } else {
  696. // dr(param.data.id, param.name);
  697. // }
  698. // console.log(param);
  699. // console.error(param,param.data.id,param.data.value,param.name);
  700. // let url = '/zabbix/zabbix.php?action=map.view&sysmapid=2&kiosk=1&line';
  701. });
  702. }
  703. function initMs(res) {
  704. let myChart = echarts.init(alarmMs.value);
  705. let yd = [];
  706. let xd = [];
  707. for (let i = 0; i < res.length; i++) {
  708. xd.push(res[i].hour);
  709. yd.push(res[i].num);
  710. }
  711. let ss = [];
  712. let xx = {
  713. // name: xd,
  714. type: 'line',
  715. data: yd,
  716. symbolSize: 1,
  717. symbol: 'circle',
  718. smooth: true,
  719. showSymbol: false,
  720. }
  721. ss.push(xx);
  722. let x_data = xd;
  723. let option = {
  724. backgroundColor: '#FFFFFF',
  725. dataZoom: {
  726. type: 'inside', // 内置型数据区域缩放组件
  727. start: 0, // 默认为0,表示从头开始
  728. end: 100 // 默认为100,表示直到末尾
  729. },
  730. title: {
  731. show: true,
  732. text: '告警趋势',
  733. // textStyle: {
  734. // fontFamily: 'PingFangSC-Regular, PingFang SC',
  735. // fontSize: 16,
  736. // fontWeight: 600,
  737. // color: '#848E98'
  738. // },
  739. left: 'left',
  740. // top: '3%'
  741. },
  742. legend: {
  743. icon: 'rect',
  744. top: '3%',
  745. right: '10%',
  746. itemWidth: 10,
  747. itemHeight: 10,
  748. itemGap: 20,
  749. textStyle: {
  750. fontFamily: 'PingFangSC-Regular, PingFang SC',
  751. color: '#848E98'
  752. }
  753. },
  754. tooltip: {
  755. trigger: 'axis',
  756. axisPointer: {
  757. label: {
  758. show: true,
  759. backgroundColor: '#fff',
  760. color: '#556677',
  761. borderColor: 'rgba(0,0,0,0)',
  762. shadowColor: 'rgba(0,0,0,0)',
  763. shadowOffsetY: 0
  764. },
  765. lineStyle: {
  766. width: 0
  767. }
  768. },
  769. backgroundColor: '#fff',
  770. textStyle: {
  771. color: '#5c6c7c'
  772. },
  773. padding: [10, 10],
  774. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  775. },
  776. grid: {
  777. top: '18%'
  778. },
  779. xAxis: [{
  780. type: 'category',
  781. data: x_data,
  782. axisLine: {
  783. show: false,
  784. lineStyle: {
  785. color: '#000000'
  786. }
  787. },
  788. axisTick: {
  789. show: false
  790. },
  791. axisLabel: {
  792. interval: 'auto',
  793. rotate: 45,
  794. textStyle: {
  795. color: '#B7C3CE'
  796. },
  797. // 默认x轴字体大小
  798. fontSize: 12,
  799. // margin:文字到x轴的距离
  800. margin: 5,
  801. hideOverlap: true // 隐藏部分标签避免重叠
  802. }
  803. }],
  804. yAxis: [{
  805. type: 'value',
  806. axisTick: {
  807. show: false
  808. },
  809. axisLine: {
  810. show: false,
  811. },
  812. axisLabel: {
  813. fontSize: 12,
  814. textStyle: {
  815. color: '#B7C3CE'
  816. }
  817. },
  818. splitLine: {
  819. show: true,
  820. lineStyle: {
  821. type: "dashed"
  822. }
  823. }
  824. }],
  825. series: ss
  826. };
  827. myChart.setOption(option)
  828. }
  829. function dl(modelId, name) {
  830. title.value = "[" + name + "] 组件压力排行";
  831. sl.value = true;
  832. axx.value = true;
  833. sr.value = false;
  834. queryParams.value.modelId = modelId;
  835. queryParams.value.params = {};
  836. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  837. queryParams.value.start = daterangeAlarmTime.value[0];
  838. queryParams.value.end = daterangeAlarmTime.value[1];
  839. }
  840. getObjAccess(queryParams.value).then(response => {
  841. loading.value = false;
  842. leftList.value = response.data.objs;
  843. line(response.data.datas);
  844. });
  845. }
  846. function dr(modelId, name) {
  847. title.value = "[" + name + "] 组件告警数量排行";
  848. sl.value = false;
  849. axx.value = false;
  850. sr.value = true;
  851. queryParams.value.modelId = modelId;
  852. queryParams.value.params = {};
  853. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  854. queryParams.value.start = daterangeAlarmTime.value[0];
  855. queryParams.value.end = daterangeAlarmTime.value[1];
  856. }
  857. getObjAlarm(queryParams.value).then(response => {
  858. loading.value = false;
  859. rightList.value = response.data;
  860. });
  861. }
  862. function line(data) {
  863. let myChart = echarts.init(asLine.value);
  864. let colorList = [
  865. '#419491',
  866. '#3581F8',
  867. '#FFB25C',
  868. ];
  869. let x_data = [];
  870. let max_data = [];
  871. let avg_data = [];
  872. let err_data = [];
  873. for (let i = 0; i < data.length; i++) {
  874. x_data.push(data[i].time);
  875. max_data.push(data[i].max);
  876. avg_data.push(data[i].avg);
  877. err_data.push(data[i].error);
  878. }
  879. let option = {
  880. backgroundColor: '#FFFFFF',
  881. dataZoom: {
  882. type: 'inside', // 内置型数据区域缩放组件
  883. start: 0, // 默认为0,表示从头开始
  884. end: 50 // 默认为100,表示直到末尾
  885. },
  886. title: {
  887. show: true,
  888. text: '系统压力值趋势',
  889. // subtext:'分配总量:18041核\n释放总量:5288核',
  890. // textStyle: {
  891. // fontFamily: 'PingFangSC-Regular, PingFang SC',
  892. // fontSize: 14,
  893. // fontWeight: 400,
  894. // color: '#848E98'
  895. // },
  896. left: 'left',
  897. top: '3%'
  898. },
  899. legend: {
  900. icon: 'rect',
  901. top: '3%',
  902. right: '10%',
  903. itemWidth: 10,
  904. itemHeight: 10,
  905. itemGap: 20,
  906. textStyle: {
  907. fontFamily: 'PingFangSC-Regular, PingFang SC',
  908. color: '#848E98'
  909. }
  910. },
  911. tooltip: {
  912. trigger: 'axis',
  913. axisPointer: {
  914. label: {
  915. show: true,
  916. backgroundColor: '#fff',
  917. color: '#556677',
  918. borderColor: 'rgba(0,0,0,0)',
  919. shadowColor: 'rgba(0,0,0,0)',
  920. shadowOffsetY: 0
  921. },
  922. lineStyle: {
  923. width: 0
  924. }
  925. },
  926. backgroundColor: '#fff',
  927. textStyle: {
  928. color: '#5c6c7c'
  929. },
  930. padding: [10, 10],
  931. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  932. },
  933. grid: {
  934. top: '18%'
  935. },
  936. xAxis: [{
  937. type: 'category',
  938. data: x_data,
  939. axisLine: {
  940. show: false,
  941. lineStyle: {
  942. color: '#000000'
  943. }
  944. },
  945. axisTick: {
  946. show: false
  947. },
  948. axisLabel: {
  949. interval: 'auto',
  950. rotate: 45,
  951. textStyle: {
  952. color: '#B7C3CE'
  953. },
  954. // 默认x轴字体大小
  955. fontSize: 12,
  956. // margin:文字到x轴的距离
  957. margin: 5
  958. }
  959. }],
  960. yAxis: [{
  961. type: 'value',
  962. // name: "核数",
  963. // position: 'left',
  964. // offset: 55,
  965. axisTick: {
  966. show: false
  967. },
  968. axisLine: {
  969. show: false,
  970. },
  971. axisLabel: {
  972. fontSize: 12,
  973. textStyle: {
  974. color: '#B7C3CE'
  975. }
  976. },
  977. splitLine: {
  978. show: true,
  979. lineStyle: {
  980. type: "dashed"
  981. }
  982. }
  983. }],
  984. series: [{
  985. name: '最大值',
  986. type: 'line',
  987. data: max_data,
  988. symbolSize: 1,
  989. symbol: 'circle',
  990. smooth: true,
  991. showSymbol: false,
  992. lineStyle: {
  993. width: 1,
  994. type: 'dotted', //'dotted'虚线 'solid'实线
  995. },
  996. itemStyle: {
  997. normal: {
  998. color: colorList[0],
  999. borderColor: colorList[0]
  1000. }
  1001. }
  1002. }, {
  1003. name: '平均值',
  1004. type: 'line',
  1005. data: avg_data,
  1006. symbolSize: 1,
  1007. symbol: 'circle',
  1008. smooth: true,
  1009. showSymbol: false,
  1010. lineStyle: {
  1011. width: 1,
  1012. },
  1013. itemStyle: {
  1014. normal: {
  1015. color: colorList[1],
  1016. borderColor: colorList[1]
  1017. }
  1018. }
  1019. },
  1020. {
  1021. name: '错误次数',
  1022. type: 'line',
  1023. data: err_data,
  1024. symbolSize: 1,
  1025. symbol: 'circle',
  1026. smooth: true,
  1027. showSymbol: false,
  1028. lineStyle: {
  1029. width: 1,
  1030. },
  1031. itemStyle: {
  1032. normal: {
  1033. color: colorList[2],
  1034. borderColor: colorList[2]
  1035. }
  1036. }
  1037. }
  1038. ]
  1039. };
  1040. myChart.setOption(option);
  1041. }
  1042. /** 查询告警记录列表 */
  1043. function getList() {
  1044. loading.value = true;
  1045. queryParams.value.params = {};
  1046. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  1047. queryParams.value.start = daterangeAlarmTime.value[0];
  1048. queryParams.value.end = daterangeAlarmTime.value[1];
  1049. }
  1050. getBizAccess(queryParams.value).then(response => {
  1051. // recordList.value = response.rows;
  1052. // total.value = response.total;
  1053. loading.value = false;
  1054. initChart(response);
  1055. });
  1056. }
  1057. /** 搜索按钮操作 */
  1058. function handleQuery() {
  1059. queryParams.value.pageNum = 1;
  1060. getList();
  1061. }
  1062. function timeSelect(v) {
  1063. let end = new Date();
  1064. let start = new Date().setDate(end.getDate() - v);
  1065. daterangeAlarmTime.value[0] = moment(start).format('YYYY-MM-DD');
  1066. daterangeAlarmTime.value[1] = moment(end).format('YYYY-MM-DD');
  1067. }
  1068. /** 重置按钮操作 */
  1069. function resetQuery() {
  1070. daterangeAlarmTime.value = [];
  1071. proxy.resetForm("queryRef");
  1072. handleQuery();
  1073. }
  1074. if (route.query.today) {
  1075. timeSelect(0);
  1076. } else {
  1077. timeSelect(30);
  1078. }
  1079. getList();
  1080. </script>