index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="knowledge-2">
  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 v-model="wpId" clearable placeholder="请选择" popper-class="select">
  9. <el-option v-for="item in wpArray" :key="item.id" :value="item.id" :label="item.name" />
  10. </el-select>
  11. </div>
  12. </div>
  13. <div class="query-item">
  14. <div class="lable">预警分类:</div>
  15. <div class="search-input">
  16. <el-select v-model="wtId" clearable collapse-tags multiple placeholder="请选择"
  17. popper-class="select">
  18. <el-row>
  19. <div class="query-actions" style="margin-left: 15px;">
  20. <button class="btn" :class="active?'green':''" @click="checkAll">全选</button>
  21. </div>
  22. </el-row>
  23. <el-option v-for="(item ,index) in wtIdArr" :key="index" :value="item" :label="item" />
  24. </el-select>
  25. </div>
  26. </div>
  27. <div class="query-item">
  28. <div class="query-item">
  29. <div class="lable">日期:</div>
  30. <div class="search-input">
  31. <el-date-picker v-model="value1" type="month" placeholder="选择日期"></el-date-picker>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="query-actions">
  36. <button class="btn" @click="query">查询</button>
  37. <button class="btn green" @click="">导入</button>
  38. <button class="btn" @click="export">导出</button>
  39. </div>
  40. </div>
  41. </div>
  42. <el-row :type="'flex'" class="content">
  43. <el-col :span="24">
  44. <ComTable :data="tableData" height="85vh"></ComTable>
  45. </el-col>
  46. </el-row>
  47. <el-dialog :title="yssjTitle" v-model="yssjDialog" width="70%" top="15vh" custom-class="modal"
  48. :close-on-click-modal="false" :before-close="yssjDialogClose">
  49. <div class="query mg-b-8">
  50. <div class="query-items">
  51. <div class="query-item">
  52. <div class="lable">等间隔:</div>
  53. <div class="search-input">
  54. <el-select v-if="!chooseStatus" @change="switchChange(selectValue)" class="inputs"
  55. v-model="selectValue" placeholder="请选择">
  56. <el-option v-for="item in timeoptions" :key="item.value" :label="item.label"
  57. :value="item.value">
  58. </el-option>
  59. </el-select>
  60. </div>
  61. </div>
  62. <div class="query-actions">
  63. <button class="btn" @click="queryYssj">查询</button>
  64. </div>
  65. </div>
  66. </div>
  67. <el-row type="flex">
  68. <multiple-y-line-chart-normal height="500px" :list="Powertrend" :showLegend="true" />
  69. </el-row>
  70. </el-dialog>
  71. </div>
  72. </template>
  73. <script>
  74. import ComTable from "@com/coms/table/table.vue";
  75. import MultipleYLineChartNormal from "../../NewPages/multiple-y-line-chart-normal.vue";
  76. import BASE from "@tools/basicTool.js";
  77. export default {
  78. components: {
  79. ComTable,
  80. MultipleYLineChartNormal
  81. },
  82. data() {
  83. let that = this;
  84. return {
  85. active: true,
  86. selectAll: true,
  87. Powertrend: [],
  88. selectValue: "60",
  89. timeoptions: [{
  90. value: "60",
  91. label: "一分钟",
  92. },
  93. {
  94. value: "300",
  95. label: "五分钟",
  96. },
  97. {
  98. value: "600",
  99. label: "十分钟",
  100. },
  101. {
  102. value: "1800",
  103. label: "三十分钟",
  104. },
  105. {
  106. value: "3600",
  107. label: "一小时",
  108. },
  109. {
  110. value: "86400",
  111. label: "一天",
  112. },
  113. ],
  114. yssjDialog: false,
  115. yssjData:{},
  116. value1: '',
  117. month: [],
  118. wpId: "MHS_FDC",
  119. wpArray: [],
  120. wpName: "",
  121. wtId: [],
  122. wtIdArr: [],
  123. wtidData: [],
  124. wtIdNum: false,
  125. tableDataArr: {},
  126. tableData: {
  127. column: [{
  128. name: "序号",
  129. field: "index",
  130. is_num: false,
  131. is_light: false,
  132. width: "60px"
  133. },
  134. {
  135. name: "风机编号",
  136. field: "fjbh",
  137. is_num: false,
  138. is_light: false,
  139. width: "150px"
  140. },
  141. {
  142. name: "预警描述",
  143. field: "yjms",
  144. is_num: false,
  145. is_light: false,
  146. },
  147. {
  148. name: "预警次数(次)",
  149. field: "yjcs",
  150. is_num: false,
  151. is_light: false,
  152. sortable: true,
  153. width: "150px"
  154. }, {
  155. name: "预警时长(分钟)",
  156. field: "yjsc",
  157. is_num: false,
  158. is_light: false,
  159. sortable: true,
  160. width: "150px"
  161. }, {
  162. name: "操作",
  163. field: "cz",
  164. is_num: false,
  165. is_light: false,
  166. width: "150px",
  167. template: function() {
  168. return "<a class='action'>原始数据</a>";
  169. },
  170. click: function(event, data) {
  171. that.yssjTitle = data.yjms;
  172. that.requestDetailData(that.wpId, data.fjbh, data.yjms, that.month);
  173. },
  174. },
  175. ],
  176. data: [],
  177. },
  178. };
  179. },
  180. created() {
  181. this.getWp();
  182. this.value1 = new Date();
  183. this.month = [new Date((new Date() - 3600 * 1000 * 24 * 30)), new Date()];
  184. this.requestSafeList();
  185. },
  186. methods: {
  187. requestDetailData(wpId, fjbh, yjms, time) {
  188. let that = this;
  189. that.yssjData = {
  190. wpId:wpId,
  191. fjbh:fjbh,
  192. yjms:yjms,
  193. time:time
  194. };
  195. BASE.showLoading();
  196. that.API.requestData({
  197. method: "GET",
  198. subUrl: "/analysis/detail",
  199. data: {
  200. station: wpId,
  201. startTs: new Date(new Date(time[0]).formatDate("yyyy/MM/dd")).getTime(),
  202. endTs: new Date(new Date(time[1]).formatDate("yyyy/MM/dd")).getTime(),
  203. interval: that.selectValue,
  204. wtId: fjbh,
  205. name: yjms
  206. },
  207. success(res) {
  208. if (res.data.length != 0) {
  209. let Powertrend = [];
  210. res.data.forEach((cEle, index) => {
  211. Powertrend.push({
  212. title: cEle.name,
  213. smooth: true,
  214. value: [],
  215. })
  216. cEle.data.forEach((rEle) => {
  217. Powertrend[index].value.push({
  218. text: new Date(rEle.ts).formatDate("hh:mm"),
  219. value: rEle.doubleValue
  220. });
  221. });
  222. });
  223. if (Powertrend.length != 0) {
  224. that.Powertrend = Powertrend;
  225. BASE.closeLoading();
  226. that.yssjDialog = true;
  227. }
  228. } else {
  229. BASE.closeLoading();
  230. that.BASE.showMsg({
  231. msg: "暂无数据"
  232. });
  233. }
  234. },
  235. });
  236. },
  237. queryYssj() {
  238. let data = this.yssjData;
  239. this.requestDetailData(data.wpId, data.fjbh, data.yjms, data.time)
  240. },
  241. switchChange(interval, status) {
  242. if (status === 'interval') {
  243. this.chooseStatus = false
  244. this.selectValue = '60'
  245. } else if (status === 'original') {
  246. this.chooseStatus = true
  247. }
  248. },
  249. formatDate(date) {
  250. var date = new Date(date);
  251. var YY = date.getFullYear() + '-';
  252. var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  253. var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  254. return YY + MM + DD;
  255. },
  256. // 获取风场
  257. getWp() {
  258. let that = this;
  259. that.API.requestData({
  260. baseURL: "http://10.155.32.4:8082/",
  261. subUrl: "powercompare/windfarmAjax",
  262. success(res) {
  263. that.wpArray = res.data;
  264. that.wpId = res.data[0].id;
  265. that.wpName = res.data[0].wpName;
  266. }
  267. });
  268. },
  269. // 获取停机事件
  270. requestSafeList(wpId, wtIdData) {
  271. let that = this;
  272. if (wtIdData) {
  273. that.tableData.data = wtIdData;
  274. that.wtIdData = [];
  275. return;
  276. }
  277. if (wpId) {
  278. that.wpId = wpId;
  279. }
  280. that.month[0] = that.formatDate(that.month[0].valueOf())
  281. that.month[1] = that.formatDate(that.month[1].valueOf())
  282. let data = {
  283. stationid: that.wpId,
  284. startdate: that.month[0].valueOf(),
  285. enddate: that.month[1].valueOf(),
  286. };
  287. that.API.requestData({
  288. showLoading: true,
  289. baseURL: "http://192.168.1.18:8075/",
  290. subUrl: "alarm/count/query/new",
  291. data,
  292. success(res) {
  293. if (res.code == 200) {
  294. that.tableData.data = [];
  295. if (res.data.length) {
  296. let data = res.data;
  297. let tabData = [];
  298. let index = 1;
  299. let wtIdArr = [];
  300. data.forEach((ele, idx) => {
  301. let key = Object.keys(ele);
  302. ele[key].forEach((ele2, idx2) => {
  303. if (ele2.time != 0 && ele2.count >= 10) { //过滤条件
  304. wtIdArr.push(ele2.alertText);
  305. let obj = {
  306. index: index++,
  307. fjbh: ele2.windturbineId,
  308. yjms: ele2.alertText,
  309. yjcs: ele2.count,
  310. yjsc: ele2.time,
  311. };
  312. tabData.push(obj);
  313. }
  314. })
  315. })
  316. let set = new Set();
  317. wtIdArr.forEach(item => set.add(item));
  318. that.wtIdArr = Array.from(set);
  319. that.wtId = that.wtIdArr;
  320. that.tableData.data = tabData;
  321. that.tableDataArr = {
  322. column: that.tableData.column,
  323. data: tabData
  324. };
  325. }
  326. }
  327. },
  328. });
  329. },
  330. query() {
  331. this.requestSafeList(this.wpId, this.wtidData);
  332. },
  333. checkAll() {
  334. this.selectAll = !this.selectAll
  335. if (this.selectAll) {
  336. this.wtId = this.wtIdArr;
  337. this.active = true;
  338. } else {
  339. this.active = false;
  340. this.wtId = [];
  341. }
  342. },
  343. formatJson(filterVal, jsonData) {
  344. return jsonData.map(v => filterVal.map(j => v[j]));
  345. },
  346. export() {
  347. let that = this;
  348. const {export_json_to_excel} = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径
  349. let tHeader = []; // 上面设置Excel的表格第一行的标题
  350. let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
  351. that.tableData.column.forEach(ele => {
  352. if(ele.field != 'cz'){
  353. tHeader.push(ele.name);
  354. filterVal.push(ele.field);
  355. }
  356. });
  357. const data = that.formatJson(filterVal, that.tableData.data);
  358. export_json_to_excel(tHeader, data, '预警分析'); // 最后一个是表名字
  359. },
  360. },
  361. watch: {
  362. wpId() {
  363. this.wtidData = undefined;
  364. this.wtIdNum = false;
  365. },
  366. wtId(e) {
  367. if (this.wtIdNum) {
  368. let data = [];
  369. let index = 1;
  370. let tableDataArr = this.tableDataArr;
  371. tableDataArr.data.forEach(ele => {
  372. e.forEach(ele2 => {
  373. if (ele.yjms == ele2) {
  374. let obj = {
  375. index: index++,
  376. fjbh: ele.fjbh,
  377. yjms: ele.yjms,
  378. yjcs: ele.yjcs,
  379. yjsc: ele.yjsc,
  380. };
  381. data.push(obj)
  382. }
  383. })
  384. })
  385. if (data) {
  386. this.wtidData = data;
  387. }
  388. }
  389. this.wtIdNum = true;
  390. },
  391. value1(e) {
  392. this.month = [new Date((e - 3600 * 1000 * 24 * 30)), e];
  393. }
  394. }
  395. };
  396. </script>
  397. <style lang="less" scope>
  398. @titleGray: #9ca5a8;
  399. @rowGray: #606769;
  400. @darkBack: #536268;
  401. .knowledge-2 {
  402. .el-select {
  403. width: 200px;
  404. }
  405. .action {
  406. text-decoration: underline;
  407. color: @green;
  408. cursor: pointer;
  409. }
  410. .el-input {
  411. width: 200px;
  412. }
  413. }
  414. </style>
  415. <style type="text/css">
  416. .el-month-table td.today .cell {
  417. color: #05bb4c;
  418. }
  419. .el-month-table td.end-date .cell,
  420. .el-month-table td.start-date .cell {
  421. background-color: #05bb4c;
  422. }
  423. .el-month-table td.in-range div,
  424. .el-month-table td.in-range div:hover {
  425. background: rgba(96, 103, 105, 0.4);
  426. }
  427. .el-date-editor.el-date-editor--monthrange {
  428. border: 1px solid rgba(96, 103, 105, 0.2);
  429. height: 33px;
  430. padding: 0 8px;
  431. width: 369px;
  432. }
  433. .el-date-editor.el-date-editor--monthrange .el-range-separator {
  434. color: #B3BDC0;
  435. line-height: 33px;
  436. }
  437. .el-date-editor.el-date-editor--monthrange .el-range-input {
  438. flex-basis: 145px;
  439. line-height: 33px;
  440. background: transparent;
  441. color: #B3BDC0;
  442. }
  443. .el-picker-panel.el-date-picker {
  444. background: transparent;
  445. color: #B3BDC0;
  446. }
  447. .el-picker-panel.el-date-picker td.current .cell {
  448. background-color: #05bb4c;
  449. color: white;
  450. }
  451. .el-picker-panel.el-date-picker td .cell:hover {
  452. color: #05bb4c;
  453. }
  454. .el-picker-panel.el-date-picker td.current div,
  455. .el-picker-panel.el-date-picker td.current div:hover {
  456. background: rgba(96, 103, 105, 0.4);
  457. border-radius: 50px;
  458. }
  459. </style>