bizAccess.vue 10 KB

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