bizAccess.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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>今天</el-button>
  6. <el-button type="primary" plain>3天</el-button>
  7. <el-button type="primary" plain>7天</el-button>
  8. <el-button type="primary" plain>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-card>
  26. <div ref="chartAccess" style="height: 600px;"></div>
  27. </el-card>
  28. <!-- <el-table v-loading="loading" :data="recordList" border>-->
  29. <!-- <el-table-column label="告警ID" align="center" prop="modelId" width="80"/>-->
  30. <!-- <el-table-column label="业务模型" align="center" prop="modelName"/>-->
  31. <!-- <el-table-column label="最近1小时系统压力值" align="center" prop="access"/>-->
  32. <!-- <el-table-column label="告警数量" align="center" prop="num" />-->
  33. <!-- <el-table-column label="操作" align="center" prop="alarmTime" width="180">-->
  34. <!-- <template #default="scope">-->
  35. <!-- <el-button type="text" plain icon="Position" @click="handleDetails(scope.row)">明细</el-button>-->
  36. <!-- </template>-->
  37. <!-- </el-table-column>-->
  38. <!-- </el-table>-->
  39. <!-- <pagination-->
  40. <!-- v-show="total>0"-->
  41. <!-- :total="total"-->
  42. <!-- v-model:page="queryParams.pageNum"-->
  43. <!-- v-model:limit="queryParams.pageSize"-->
  44. <!-- @pagination="getList"-->
  45. <!-- />-->
  46. </div>
  47. </template>
  48. <script setup name="Record">
  49. import {getBizAccess} from "@/api/alarm/record";
  50. import {useRouter} from "vue-router";
  51. import * as echarts from "echarts";
  52. const {proxy} = getCurrentInstance();
  53. const {alarm_level} = proxy.useDict('alarm_level');
  54. const recordList = ref([]);
  55. const open = ref(false);
  56. const loading = ref(true);
  57. const showSearch = ref(true);
  58. const ids = ref([]);
  59. const single = ref(true);
  60. const multiple = ref(true);
  61. const total = ref(0);
  62. const title = ref("");
  63. const daterangeAlarmTime = ref([]);
  64. const router = useRouter();
  65. const chartAccess = ref();
  66. const data = reactive({
  67. form: {},
  68. queryParams: {
  69. start: null,
  70. end: null,
  71. },
  72. });
  73. function handleDetails(row) {
  74. console.log(row, router)
  75. }
  76. const {queryParams, form} = toRefs(data);
  77. function initChart(res) {
  78. let myChart = echarts.init(chartAccess.value);
  79. let img = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjUzOTAwNTEzMjYyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxNjkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mYWNlIHsgZm9udC1mYW1pbHk6IGZlZWRiYWNrLWljb25mb250OyBzcmM6IHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUud29mZjI/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmMiIpLCB1cmwoIi8vYXQuYWxpY2RuLmNvbS90L2ZvbnRfMTAzMTE1OF91Njl3OHloeGR1LndvZmY/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmIiksIHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUudHRmP3Q9MTYzMDAzMzc1OTk0NCIpIGZvcm1hdCgidHJ1ZXR5cGUiKTsgfQo8L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDBoMzJ2MTYwaC0zMnpNNTEyIDI1NmgzMnYxNjBoLTMyek01MTIgNTEyaDMydjE2MGgtMzJ6TTUxMiA3NjhoMzJ2MTYwaC0zMnoiIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjIxNzAiPjwvcGF0aD48L3N2Zz4=";
  80. let datas = [];
  81. let legendData1 = [];
  82. let legendData2 = [];
  83. let xMax1 = 50;
  84. let xMax2 = 50;
  85. for (let i in res.data) {
  86. let obj = res.data[i];
  87. datas.push(obj.modelName);
  88. legendData1.push(obj.access);
  89. legendData2.push(obj.num);
  90. if (obj.access > xMax1) {
  91. xMax1 = obj.access;
  92. }
  93. if (obj.num > xMax2) {
  94. xMax2 = obj.num;
  95. }
  96. }
  97. let dataheng = [xMax1+2, xMax1+2, xMax1+2, xMax1+2, xMax1+2];
  98. let option = {
  99. backgroundColor: '#fff',
  100. tooltip: {
  101. show: true,
  102. trigger: 'axis',
  103. axisPointer: {
  104. type: 'shadow',
  105. shadowStyle: {
  106. color: 'rgba(210,219,238,0.2)',
  107. },
  108. },
  109. },
  110. legend: {},
  111. grid: [{
  112. show: false,
  113. left: '0',
  114. top: 0,
  115. bottom: 22,
  116. width: '15%',
  117. },
  118. {
  119. containLabel: true,
  120. top: 0,
  121. left: '20%',
  122. bottom: '0%',
  123. width: '50%',
  124. show: false
  125. },
  126. {
  127. left: '74%',
  128. right: '0%',
  129. top: 0,
  130. bottom: '0%',
  131. containLabel: true,
  132. show: false
  133. },
  134. ],
  135. xAxis: [{
  136. gridIndex: 0,
  137. show: false,
  138. },
  139. {
  140. gridIndex: 1,
  141. show: false,
  142. max: xMax1,
  143. },
  144. {
  145. gridIndex: 2,
  146. show: false,
  147. max: xMax2,
  148. },
  149. ],
  150. yAxis: [{
  151. gridIndex: 0,
  152. type: 'category',
  153. inverse: true,
  154. position: 'right',
  155. axisLine: {
  156. show: false,
  157. },
  158. axisTick: {
  159. show: false,
  160. },
  161. data: datas.map(function (value) {
  162. return {
  163. value: value,
  164. textStyle: {
  165. align: 'right',
  166. },
  167. };
  168. }),
  169. axisLabel: {
  170. fontSize: 14,
  171. align: 'left',
  172. rich: {
  173. a: {
  174. color: '#fff',
  175. backgroundColor: '#49a2ff',
  176. width: 24,
  177. height: 24,
  178. align: 'center',
  179. borderRadius: 3,
  180. },
  181. a1: {
  182. color: '#fff',
  183. backgroundColor: '#f5576c',
  184. width: 24,
  185. height: 24,
  186. align: 'center',
  187. borderRadius: 3,
  188. },
  189. a2: {
  190. color: '#fff',
  191. backgroundColor: '#fee140',
  192. width: 24,
  193. height: 24,
  194. align: 'center',
  195. borderRadius: 3,
  196. },
  197. a3: {
  198. color: '#fff',
  199. backgroundColor: '#96fbc4',
  200. width: 24,
  201. height: 24,
  202. align: 'center',
  203. borderRadius: 3,
  204. },
  205. b: {
  206. color: '#333',
  207. width: 100,
  208. height: 30,
  209. align: 'right',
  210. },
  211. },
  212. formatter: function (params) {
  213. var index = datas.map((item) => item).indexOf(params);
  214. index = index + 1;
  215. if (index < 4) {
  216. return [`{a${index}|${index}}{b|${params}}`].join('\n');
  217. } else {
  218. return [`{a|${index}}{b|${params}}`].join('\n');
  219. }
  220. },
  221. },
  222. },
  223. {
  224. inverse: true,
  225. gridIndex: 1,
  226. data: datas,
  227. // max:10,
  228. axisLabel: {
  229. // margin: 80,
  230. show: false
  231. },
  232. axisLine: {
  233. show: false,
  234. },
  235. axisTick: {
  236. show: false,
  237. },
  238. axisPointer: {
  239. label: {
  240. show: false,
  241. margin: 30,
  242. },
  243. },
  244. },
  245. {
  246. gridIndex: 2,
  247. inverse: true,
  248. data: datas,
  249. // max:10,
  250. axisLine: {
  251. show: false,
  252. },
  253. axisTick: {
  254. show: false,
  255. },
  256. axisLabel: {
  257. show: false,
  258. },
  259. axisPointer: {
  260. label: {
  261. show: false,
  262. margin: 30,
  263. },
  264. },
  265. },
  266. ],
  267. series: [{
  268. type: 'bar',
  269. name: '系统压力值',
  270. stack: '2',
  271. barWidth: 20,
  272. z: 10,
  273. barCategoryGap: 15,
  274. // barGap:i==1?'-100%':'0',
  275. xAxisIndex: 1,
  276. yAxisIndex: 1,
  277. itemStyle: {
  278. color: '#ffc001',
  279. barBorderRadius: [0, 10, 10, 0],
  280. // barBorderRadius: legendData[i].barBorderRadius,
  281. emphasis: {
  282. color: '#ffc001',
  283. },
  284. },
  285. // 数字
  286. label: {
  287. show: true,
  288. position: 'inside',
  289. right: 0,
  290. color: '#fff',
  291. formatter: function (params) {
  292. if (params.value == 0) {
  293. return '';
  294. } else {
  295. return params.value;
  296. }
  297. },
  298. },
  299. data: legendData1,
  300. },
  301. //虚线
  302. {
  303. name: '',
  304. type: 'pictorialBar',
  305. xAxisIndex: 1,
  306. yAxisIndex: 1,
  307. symbolSize: [7, 30],
  308. symbolOffset: [15, 0],
  309. symbol: 'image://' + img,
  310. symbolPosition: 'end',
  311. barWidth: "20",
  312. z: 12,
  313. color: '#fe5959',
  314. data: dataheng,
  315. tooltip: {
  316. show: false,
  317. },
  318. },
  319. //右边的柱状图
  320. {
  321. xAxisIndex: 2,
  322. yAxisIndex: 2,
  323. type: 'bar',
  324. name: '告警数量',
  325. stack: '3',
  326. barWidth: 30,
  327. barCategoryGap: 15,
  328. // barGap:i==1?'-100%':'0',
  329. itemStyle: {
  330. color: '#fe5959',
  331. barBorderRadius: [0, 20, 20, 0],
  332. emphasis: {
  333. color: '#fe5959',
  334. },
  335. },
  336. // 数字
  337. label: {
  338. show: true,
  339. position: 'inside',
  340. right: 0,
  341. color: '#fff',
  342. formatter: function (params) {
  343. if (params.value == 0) {
  344. return '';
  345. } else {
  346. return params.value;
  347. }
  348. },
  349. },
  350. data: legendData2,
  351. },
  352. ],
  353. };
  354. // 3.配置项和数据给实例化对象
  355. myChart.setOption(option);
  356. }
  357. /** 查询告警记录列表 */
  358. function getList() {
  359. loading.value = true;
  360. queryParams.value.params = {};
  361. if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
  362. queryParams.value.start = daterangeAlarmTime.value[0];
  363. queryParams.value.end = daterangeAlarmTime.value[1];
  364. }
  365. getBizAccess(queryParams.value).then(response => {
  366. // recordList.value = response.rows;
  367. // total.value = response.total;
  368. loading.value = false;
  369. initChart(response);
  370. });
  371. }
  372. /** 搜索按钮操作 */
  373. function handleQuery() {
  374. queryParams.value.pageNum = 1;
  375. getList();
  376. }
  377. /** 重置按钮操作 */
  378. function resetQuery() {
  379. daterangeAlarmTime.value = [];
  380. proxy.resetForm("queryRef");
  381. handleQuery();
  382. }
  383. getList();
  384. </script>