customStatistics.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div>
  3. <div class="query mg-b-8">
  4. <div class="query-items">
  5. <div class="query-item">
  6. <div class="lable">场站:</div>
  7. <div class="search-input">
  8. <el-select
  9. v-model="stationId"
  10. clearable
  11. placeholder="请选择"
  12. popper-class="select"
  13. @change="(stationId) => { Windturbines() }"
  14. >
  15. <el-option
  16. v-for="item in ChangZhan"
  17. :key="item.id"
  18. :value="item.id"
  19. :label="item.name"
  20. ></el-option>
  21. </el-select>
  22. </div>
  23. </div>
  24. <div class="query-item">
  25. <div class="lable">开始日期:</div>
  26. <div class="search-input">
  27. <el-date-picker
  28. v-model="startDate"
  29. type="date"
  30. placeholder="开始日期"
  31. popper-class="date-select"
  32. value-format="YYYY-MM-DD"
  33. ></el-date-picker>
  34. </div>
  35. </div>
  36. <div class="query-item">
  37. <div class="lable">结束日期:</div>
  38. <div class="search-input">
  39. <el-date-picker
  40. v-model="endDate"
  41. type="date"
  42. placeholder="开始日期"
  43. popper-class="date-select"
  44. value-format="YYYY-MM-DD"
  45. ></el-date-picker>
  46. </div>
  47. </div>
  48. <div class="query-actions">
  49. <button class="btn green" @click="getTable()">查询</button>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="table-box">
  54. <div class="title">自定义报警统计</div>
  55. <div class="custom-report-items">
  56. <div class="title" v-for="item in tableData" :key="item" @click="alertDetail(item)">
  57. <div class="alarmName">{{item.alarmtext}}</div>
  58. <div class="alarmCount">{{item.sum}}</div>
  59. </div>
  60. </div>
  61. </div>
  62. <el-dialog
  63. title="自定义报警统计-图表"
  64. v-model="dialogShow"
  65. width="80%"
  66. top="10vh"
  67. custom-class="modal dBody"
  68. :close-on-click-modal="true"
  69. >
  70. <div class="dGrid" height="100%">
  71. <table class="com-table">
  72. <thead>
  73. <tr>
  74. <th>风机</th>
  75. <th>数量</th>
  76. </tr>
  77. </thead>
  78. <el-scrollbar>
  79. <tbody>
  80. <tr v-for="item in dGridData" :key="item">
  81. <td>{{item.name}}</td>
  82. <td>{{item.sum}}</td>
  83. </tr>
  84. </tbody>
  85. </el-scrollbar>
  86. </table>
  87. </div>
  88. <div class="dChart" height="100%" id="dChart">
  89. <!-- <div class="title">报警统计柱状图</div> -->
  90. <!-- <multiple-hover-bar-chart height="80%" width="90%"></multiple-hover-bar-chart> -->
  91. <!-- <multiple-hover-bar-chart height="100%" :list="dChartData"></multiple-hover-bar-chart> -->
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. // import ComTable from "@/components/coms/table/table.vue";
  98. import MultipleHoverBarChart from "../../components/chart/bar/multiple-bar-chart.vue";
  99. import * as echarts from "echarts";
  100. export default {
  101. name: "customStatistics",
  102. components: { MultipleHoverBarChart },
  103. data() {
  104. let that = this;
  105. return {
  106. ChangZhan: [],
  107. stationId: "MHS_FDC",
  108. startDate: "",
  109. endDate: "",
  110. tableData: [],
  111. dialogShow: false,
  112. dGridData: [],
  113. dChartData: []
  114. // tableLoading: true
  115. };
  116. },
  117. created() {
  118. this.ChangZhanVal();
  119. let end = new Date();
  120. let start = new Date(end.getTime() - 1 * 24 * 60 * 60 * 1000);
  121. this.endDate = end.formatDate("yyyy-MM-dd");
  122. this.startDate = start.formatDate("yyyy-MM-dd");
  123. this.getTable();
  124. },
  125. methods: {
  126. // 场站
  127. ChangZhanVal() {
  128. var that = this;
  129. that.API.requestData({
  130. method: "GET",
  131. baseURL: "http://10.83.66.220:8020/",
  132. subUrl: "benchmarking/wplist",
  133. success(res) {
  134. that.ChangZhan = res.data;
  135. that.stationId = res.data[0].id;
  136. }
  137. });
  138. },
  139. getTable() {
  140. let that = this;
  141. this.tableLoading = true;
  142. this.API.requestData({
  143. timeout: 30000,
  144. method: "GET",
  145. baseURL: "http://192.168.1.18:8075/",
  146. subUrl: "alarm/count/querymap2",
  147. data: {
  148. stationid: this.stationId,
  149. datebegin: this.startDate,
  150. dateend: this.endDate
  151. },
  152. success(res) {
  153. let tmpArr = [];
  154. for (var key in res.data) {
  155. let item = res.data[key];
  156. item["key"] = key;
  157. tmpArr.push(item);
  158. }
  159. tmpArr.sort(function(a, b) {
  160. return b["sum"] - a["sum"];
  161. });
  162. that.tableData = tmpArr;
  163. }
  164. });
  165. },
  166. async alertDetail(item) {
  167. this.dialogShow = true;
  168. let resData = await this.API.requestData({
  169. timeout: 30000,
  170. method: "GET",
  171. baseURL: "http://192.168.1.18:8075/",
  172. subUrl: "alarm/count/querybyname2",
  173. data: {
  174. stationid: this.stationId,
  175. datebegin: this.startDate,
  176. dateend: this.endDate,
  177. snapid: item["key"]
  178. }
  179. });
  180. let keyValue = resData.data.data;
  181. const dGridData = [];
  182. for (let key in keyValue) {
  183. dGridData.push({ sum: keyValue[key], name: key });
  184. }
  185. dGridData.sort(function(a, b) {
  186. return b.sum - a.sum;
  187. });
  188. this.dGridData = dGridData;
  189. this.alertDetailChart(item);
  190. },
  191. async alertDetailChart(item) {
  192. let resData = await this.API.requestData({
  193. timeout: 30000,
  194. method: "GET",
  195. baseURL: "http://192.168.1.18:8075/",
  196. subUrl: "alarm/count/lineandproject",
  197. data: {
  198. stationid: this.stationId,
  199. datebegin: this.startDate,
  200. dateend: this.endDate,
  201. snapid: item["key"]
  202. }
  203. });
  204. let dataX = [],
  205. data1 = [],
  206. data2 = [];
  207. for (let item of resData.data.data) {
  208. dataX.push(item["linenum"]);
  209. data1.push(item["happendsum"]);
  210. data2.push(item["sum"]);
  211. }
  212. let option = {
  213. color: ["#05bb4c", "#4b55ae", "#fa8c16"],
  214. title: {
  215. text: "报警统计柱状图",
  216. left: "5%"
  217. },
  218. tooltip: {
  219. trigger: "axis",
  220. axisPointer: {
  221. type: "shadow"
  222. }
  223. },
  224. legend: {
  225. data: ["总数", "发生数量"],
  226. textStyle: {
  227. color: "#fff"
  228. }
  229. },
  230. grid: {
  231. left: "5%",
  232. right: "6%",
  233. bottom: "3%",
  234. containLabel: true
  235. },
  236. xAxis: { name: "线路", type: "category", data: dataX },
  237. yAxis: { name: "数量", type: "value" },
  238. series: [
  239. {
  240. name: "总数",
  241. type: "bar",
  242. barWidth: 40,
  243. barGap: "-100%",
  244. label: { normal: { show: true, position: "top" } },
  245. data: data2
  246. },
  247. {
  248. name: "发生数量",
  249. type: "bar",
  250. barGap: "-100%",
  251. barWidth: 40,
  252. label: { normal: { show: true, position: "inside" } },
  253. data: data1
  254. }
  255. ]
  256. };
  257. let chart = echarts.init(document.getElementById("dChart"));
  258. chart.clear();
  259. chart.setOption(option);
  260. }
  261. }
  262. };
  263. </script>
  264. <style lang="less">
  265. .dGrid {
  266. height: 70vh;
  267. width: 30%;
  268. display: inline-block;
  269. table {
  270. tbody {
  271. height: 65vh;
  272. }
  273. }
  274. }
  275. .dChart {
  276. height: 70vh;
  277. width: 70%;
  278. display: inline-block;
  279. vertical-align: top;
  280. }
  281. .dBody {
  282. height: 80vh;
  283. }
  284. .title {
  285. background: rgba(255, 255, 255, 0.1);
  286. margin-bottom: 8px;
  287. padding: 1vh;
  288. }
  289. .custom-report-items {
  290. display: flex;
  291. flex-wrap: wrap;
  292. .title {
  293. height: 80px;
  294. width: 18.8vw;
  295. background: fade(@gray, 40);
  296. color: @gray-l;
  297. font-size: 1.85vh;
  298. margin-left: 7px;
  299. margin-right: 7px;
  300. margin-top: 7px;
  301. margin-bottom: 7px;
  302. cursor: pointer;
  303. div {
  304. width: 100%;
  305. display: block;
  306. clear: both;
  307. text-align: center;
  308. &:first-child {
  309. margin-bottom: 20px;
  310. }
  311. }
  312. }
  313. }
  314. </style>