index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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
  9. v-model="wpId"
  10. clearable
  11. placeholder="请选择"
  12. popper-class="select"
  13. >
  14. <el-option
  15. v-for="item in wpArray"
  16. :key="item.id"
  17. :value="item.id"
  18. :label="item.name"
  19. />
  20. </el-select>
  21. </div>
  22. </div>
  23. <div class="query-item">
  24. <div class="lable">预警分类:</div>
  25. <div class="search-input">
  26. <el-select
  27. v-model="wtId"
  28. clearable
  29. collapse-tags
  30. multiple
  31. placeholder="请选择"
  32. popper-class="select"
  33. >
  34. <el-option
  35. label="全选"
  36. :class="active ? 'selected' : ''"
  37. @click="checkAll"
  38. />
  39. <el-option
  40. v-for="(item, index) in wtIdArr"
  41. :key="index"
  42. :value="item"
  43. :label="item"
  44. />
  45. </el-select>
  46. </div>
  47. </div>
  48. <div class="query-item" style="width: 445px">
  49. <div class="lable">日期:</div>
  50. <div class="search-input">
  51. <el-date-picker
  52. v-model="month"
  53. type="datetimerange"
  54. range-separator="至"
  55. start-placeholder="开始日期"
  56. end-placeholder="结束日期"
  57. >
  58. </el-date-picker>
  59. </div>
  60. </div>
  61. <div class="query-actions">
  62. <button class="btn" @click="query">查询</button>
  63. <!-- <button class="btn" @click="">导入</button> -->
  64. <button class="btn" @click="export">导出</button>
  65. </div>
  66. </div>
  67. </div>
  68. <el-row :type="'flex'" class="content">
  69. <el-col :span="24">
  70. <ComTable :data="tableData" height="85vh"></ComTable>
  71. </el-col>
  72. </el-row>
  73. <el-dialog
  74. :title="yssjTitle"
  75. v-model="yssjDialog"
  76. width="70%"
  77. top="15vh"
  78. custom-class="modal"
  79. :close-on-click-modal="false"
  80. :before-close="yssjDialogClose"
  81. >
  82. <div class="query mg-b-8">
  83. <div class="query-items">
  84. <div class="query-item">
  85. <div class="lable">等间隔:</div>
  86. <div class="search-input">
  87. <el-select
  88. v-if="!chooseStatus"
  89. @change="switchChange(selectValue)"
  90. class="inputs"
  91. v-model="selectValue"
  92. placeholder="请选择"
  93. >
  94. <el-option
  95. v-for="item in timeoptions"
  96. :key="item.value"
  97. :label="item.label"
  98. :value="item.value"
  99. >
  100. </el-option>
  101. </el-select>
  102. </div>
  103. </div>
  104. <div class="query-actions">
  105. <button class="btn" @click="queryYssj">查询</button>
  106. </div>
  107. </div>
  108. </div>
  109. <el-row type="flex">
  110. <multiple-y-line-chart-normal
  111. height="500px"
  112. :list="Analysis"
  113. :yAxises="AnalysisYAxises"
  114. :showLegend="true"
  115. />
  116. </el-row>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script>
  121. import ComTable from "@com/coms/table/table.vue";
  122. import MultipleYLineChartNormal from "../../NewPages/multiple-y-line-chart-normal.vue";
  123. import BASE from "@tools/basicTool.js";
  124. export default {
  125. components: {
  126. ComTable,
  127. MultipleYLineChartNormal,
  128. },
  129. data() {
  130. let that = this;
  131. return {
  132. active: true,
  133. selectAll: true,
  134. AnalysisName: "",
  135. AnalysisUnit: "",
  136. Analysis: [
  137. {
  138. title: "",
  139. yAxisIndex: 0, // 使用单位
  140. value: [],
  141. },
  142. ],
  143. AnalysisYAxises: [
  144. {
  145. name: "",
  146. min: "",
  147. max: "",
  148. unit: "",
  149. position: "left",
  150. },
  151. {
  152. name: "",
  153. min: "",
  154. max: "",
  155. unit: "",
  156. position: "right",
  157. },
  158. ],
  159. selectValue: "60",
  160. timeoptions: [
  161. {
  162. value: "60",
  163. label: "一分钟",
  164. },
  165. {
  166. value: "300",
  167. label: "五分钟",
  168. },
  169. {
  170. value: "600",
  171. label: "十分钟",
  172. },
  173. {
  174. value: "1800",
  175. label: "三十分钟",
  176. },
  177. {
  178. value: "3600",
  179. label: "一小时",
  180. },
  181. {
  182. value: "86400",
  183. label: "一天",
  184. },
  185. ],
  186. yssjDialog: false,
  187. yssjData: {},
  188. month: [],
  189. wpId: "MHS_FDC",
  190. wpArray: [],
  191. wpName: "",
  192. wtId: [],
  193. wtIdArr: [],
  194. wtidData: [],
  195. wtIdNum: false,
  196. tableDataArr: {},
  197. tableData: {
  198. column: [
  199. {
  200. name: "序号",
  201. field: "index",
  202. is_num: false,
  203. is_light: false,
  204. width: "60px",
  205. },
  206. {
  207. name: "风机编号",
  208. field: "fjbh",
  209. is_num: false,
  210. is_light: false,
  211. width: "150px",
  212. },
  213. {
  214. name: "预警分类",
  215. field: "yjfl",
  216. is_num: false,
  217. is_light: false,
  218. width: "300px",
  219. },
  220. {
  221. name: "预警描述",
  222. field: "yjms",
  223. is_num: false,
  224. is_light: false,
  225. },
  226. {
  227. name: "预警次数(次)",
  228. field: "yjcs",
  229. is_num: false,
  230. is_light: false,
  231. sortable: true,
  232. width: "300px",
  233. },
  234. {
  235. name: "预警时长(分钟)",
  236. field: "yjsc",
  237. is_num: false,
  238. is_light: false,
  239. sortable: true,
  240. width: "300px",
  241. },
  242. {
  243. name: "操作",
  244. field: "cz",
  245. is_num: false,
  246. is_light: false,
  247. width: "200px",
  248. template: function () {
  249. return "<a class='action'>原始数据</a>";
  250. },
  251. click: function (event, data) {
  252. that.yssjTitle = data.yjms;
  253. that.requestDetailData(
  254. that.wpId,
  255. data.fjbh,
  256. data.yjms,
  257. that.month
  258. );
  259. },
  260. },
  261. ],
  262. data: [],
  263. },
  264. };
  265. },
  266. created() {
  267. this.getWp();
  268. this.month = [new Date(new Date() - 3600 * 1000 * 24 * 1), new Date()];
  269. this.requestSafeList();
  270. },
  271. methods: {
  272. requestDetailData(wpId, fjbh, yjms, time) {
  273. let that = this;
  274. that.yssjData = {
  275. wpId: wpId,
  276. fjbh: fjbh,
  277. yjms: yjms,
  278. time: time,
  279. };
  280. BASE.showLoading();
  281. that.API.requestData({
  282. method: "GET",
  283. subUrl: "/analysis/detail",
  284. data: {
  285. station: wpId,
  286. startTs: new Date(new Date(time[0]).formatDate("yyyy/MM/dd")).getTime(),
  287. endTs: new Date(new Date(time[1]).formatDate("yyyy/MM/dd")).getTime(),
  288. interval: that.selectValue,
  289. wtId: fjbh,
  290. name: yjms,
  291. },
  292. success(res) {
  293. if (res.data.length == 1) {
  294. that.yssjDialog = true;
  295. BASE.closeLoading();
  296. let yaxises = [
  297. {
  298. name: "",
  299. min: 0,
  300. max: null,
  301. unit: "",
  302. position: "left",
  303. },
  304. ];
  305. // yaxises.name = res.data[0].name;
  306. yaxises.unit = res.data[0].unit;
  307. that.AnalysisYAxises = yaxises;
  308. let aKey1 = ["doubleValue"];
  309. let aList1 = [
  310. {
  311. title: "",
  312. // yAxisIndex:"",
  313. smooth: true,
  314. value: [],
  315. },
  316. ];
  317. aKey1.forEach((keyEle, keyIndex) => {
  318. aList1[keyIndex].title = res.data[keyIndex].name;
  319. res.data[keyIndex].data.forEach((rEle) => {
  320. aList1[keyIndex].value.push({
  321. text: new Date(rEle.ts).formatDate("hh:mm"),
  322. value: rEle.doubleValue,
  323. });
  324. });
  325. });
  326. that.Analysis = aList1;
  327. } else if (res.data.length == 2) {
  328. that.yssjDialog = true;
  329. BASE.closeLoading();
  330. let aKey2 = ["doubleValue", "doubleValue"];
  331. let aList2 = [
  332. {
  333. title: "",
  334. // yAxisIndex:"",
  335. smooth: true,
  336. value: [],
  337. },
  338. {
  339. title: "",
  340. // yAxisIndex:"",
  341. smooth: true,
  342. value: [],
  343. },
  344. ];
  345. let yaxises1 = [
  346. {
  347. name: "",
  348. min: 0,
  349. max: null,
  350. unit: "",
  351. position: "left",
  352. },
  353. {
  354. name: "",
  355. min: 0,
  356. max: null,
  357. unit: "",
  358. position: "right",
  359. },
  360. ];
  361. yaxises1.forEach((aEle, aIndex) => {
  362. res.data.forEach((rEle) => {
  363. // aEle.name = rEle.name;
  364. aEle.unit = rEle.unit;
  365. });
  366. });
  367. that.AnalysisYAxises = yaxises1;
  368. aKey2.forEach((keyEle, keyIndex) => {
  369. aList2[keyIndex].title = res.data[keyIndex].name;
  370. res.data[keyIndex].data.forEach((rEle) => {
  371. aList2[keyIndex].value.push({
  372. text: new Date(rEle.ts).formatDate("hh:mm"),
  373. value: rEle.doubleValue,
  374. });
  375. });
  376. });
  377. that.Analysis = aList2;
  378. } else if (res.data.length == 4) {
  379. that.yssjDialog = true;
  380. BASE.closeLoading();
  381. let aKey4 = [
  382. "doubleValue",
  383. "doubleValue",
  384. "doubleValue",
  385. "doubleValue",
  386. ];
  387. let aList4 = [
  388. {
  389. title: "",
  390. // yAxisIndex:"",
  391. smooth: true,
  392. value: [],
  393. },
  394. {
  395. title: "",
  396. // yAxisIndex:"",
  397. smooth: true,
  398. value: [],
  399. },
  400. {
  401. title: "",
  402. // yAxisIndex:"",
  403. smooth: true,
  404. value: [],
  405. },
  406. {
  407. title: "",
  408. // yAxisIndex:"",
  409. smooth: true,
  410. value: [],
  411. },
  412. ];
  413. let yaxises2 = [
  414. {
  415. name: "",
  416. min: 0,
  417. max: null,
  418. unit: "",
  419. position: "left",
  420. },
  421. {
  422. name: "",
  423. min: 0,
  424. max: null,
  425. unit: "",
  426. position: "right",
  427. },
  428. ];
  429. yaxises2.forEach((aEle, aIndex) => {
  430. res.data.forEach((rEle) => {
  431. // aEle.name = rEle.name;
  432. aEle.unit = rEle.unit;
  433. });
  434. });
  435. that.AnalysisYAxises = yaxises2;
  436. aKey4.forEach((keyEle, keyIndex) => {
  437. aList4[keyIndex].title = res.data[keyIndex].name;
  438. res.data[keyIndex].data.forEach((rEle) => {
  439. aList4[keyIndex].value.push({
  440. text: new Date(rEle.ts).formatDate("hh:mm"),
  441. value: rEle.doubleValue,
  442. });
  443. });
  444. });
  445. that.Analysis = aList4;
  446. } else if (res.data.length == 0) {
  447. that.yssjDialog = false;
  448. BASE.closeLoading();
  449. that.BASE.showMsg({
  450. type: "warning",
  451. msg: "暂无数据",
  452. });
  453. } else {
  454. BASE.closeLoading();
  455. that.BASE.showMsg({
  456. msg: "暂无数据",
  457. });
  458. }
  459. },
  460. });
  461. },
  462. queryYssj() {
  463. let data = this.yssjData;
  464. this.requestDetailData(data.wpId, data.fjbh, data.yjms, data.time);
  465. },
  466. switchChange(interval, status) {
  467. if (status === "interval") {
  468. this.chooseStatus = false;
  469. this.selectValue = "60";
  470. } else if (status === "original") {
  471. this.chooseStatus = true;
  472. }
  473. },
  474. formatDate(dates) {
  475. var date = new Date(dates);
  476. var YY = date.getFullYear() + "-";
  477. var MM =
  478. (date.getMonth() + 1 < 10
  479. ? "0" + (date.getMonth() + 1)
  480. : date.getMonth() + 1) + "-";
  481. var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  482. return YY + MM + DD;
  483. },
  484. // 获取风场
  485. getWp() {
  486. let that = this;
  487. that.API.requestData({
  488. baseURL: "http://10.155.32.4:8082/",
  489. subUrl: "powercompare/windfarmAjax",
  490. success(res) {
  491. that.wpArray = res.data;
  492. that.wpId = res.data[0].id;
  493. that.wpName = res.data[0].wpName;
  494. },
  495. });
  496. },
  497. // 获取停机事件
  498. requestSafeList() {
  499. let that = this;
  500. // if (wtIdData) {
  501. // that.tableData.data = wtIdData;
  502. // that.wtIdData = [];
  503. // return;
  504. // }
  505. // if (wpId) {
  506. // that.wpId = wpId;
  507. // }
  508. that.month[0] = that.formatDate(that.month[0].valueOf());
  509. that.month[1] = that.formatDate(that.month[1].valueOf());
  510. let data = {
  511. stationid: that.wpId,
  512. startdate: that.month[0].valueOf(),
  513. enddate: that.month[1].valueOf(),
  514. };
  515. that.API.requestData({
  516. showLoading: true,
  517. baseURL: "http://192.168.1.18:8075/",
  518. subUrl: "alarm/count/query/new",
  519. data,
  520. success(res) {
  521. if (res.code == 200) {
  522. that.tableData.data = [];
  523. if (res.data.length) {
  524. let data = res.data;
  525. let tabData = [];
  526. let index = 1;
  527. let wtIdArr = [];
  528. data.forEach((ele, idx) => {
  529. let key = Object.keys(ele);
  530. ele[key].forEach((ele2, idx2) => {
  531. if (ele2.time != 0 && ele2.count >= 10) {
  532. //过滤条件
  533. let obj = {
  534. index: index++,
  535. fjbh: ele2.windturbineId,
  536. yjfl: ele2.relatePartsText,
  537. yjms: ele2.alertText,
  538. yjcs: ele2.count,
  539. yjsc: ele2.time,
  540. };
  541. tabData.push(obj);
  542. let result = wtIdArr.some((ele4) => {
  543. return ele2.relatePartsText === ele4;
  544. });
  545. if (result == false) {
  546. wtIdArr.push(ele2.relatePartsText);
  547. }
  548. }
  549. });
  550. });
  551. that.wtIdArr = wtIdArr;
  552. that.wtId = wtIdArr;
  553. that.tableData.data = tabData;
  554. that.tableDataArr = {
  555. column: that.tableData.column,
  556. data: tabData,
  557. };
  558. }
  559. }
  560. },
  561. });
  562. },
  563. query() {
  564. this.requestSafeList();
  565. },
  566. checkAll() {
  567. this.selectAll = !this.selectAll;
  568. if (this.selectAll) {
  569. this.wtId = this.wtIdArr;
  570. this.active = true;
  571. } else {
  572. this.active = false;
  573. this.wtId = [];
  574. }
  575. },
  576. formatJson(filterVal, jsonData) {
  577. return jsonData.map((v) => filterVal.map((j) => v[j]));
  578. },
  579. export() {
  580. let that = this;
  581. const { export_json_to_excel } = require("@tools/excel/Export2Excel.js"); // 注意这个Export2Excel路径
  582. let tHeader = []; // 上面设置Excel的表格第一行的标题
  583. let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
  584. that.tableData.column.forEach((ele) => {
  585. if (ele.field != "cz") {
  586. tHeader.push(ele.name);
  587. filterVal.push(ele.field);
  588. }
  589. });
  590. const data = that.formatJson(filterVal, that.tableData.data);
  591. export_json_to_excel(tHeader, data, "预警分析"); // 最后一个是表名字
  592. },
  593. },
  594. watch: {
  595. wpId() {
  596. this.wtidData = undefined;
  597. this.wtIdNum = false;
  598. },
  599. wtId(e) {
  600. if (this.wtIdNum) {
  601. let data = [];
  602. let index = 1;
  603. let tableDataArr = this.tableDataArr;
  604. tableDataArr.data.forEach((ele) => {
  605. e.forEach((ele2) => {
  606. if (ele.yjfl == ele2) {
  607. let obj = {
  608. index: index++,
  609. fjbh: ele.fjbh,
  610. yjfl: ele.yjfl,
  611. yjms: ele.yjms,
  612. yjcs: ele.yjcs,
  613. yjsc: ele.yjsc,
  614. };
  615. data.push(obj);
  616. }
  617. });
  618. });
  619. if (data) {
  620. this.tableData.data = data;
  621. // this.wtidData = data;
  622. }
  623. }
  624. this.wtIdNum = true;
  625. },
  626. // month(e) {
  627. // this.month = [new Date((e - 3600 * 1000 * 24 * 30)), e];
  628. // }
  629. },
  630. };
  631. </script>
  632. <style lang="less" scope>
  633. @titleGray: #9ca5a8;
  634. @rowGray: #606769;
  635. @darkBack: #536268;
  636. .knowledge-2 {
  637. .el-select {
  638. width: 200px;
  639. }
  640. .action {
  641. text-decoration: underline;
  642. color: @green;
  643. cursor: pointer;
  644. }
  645. .el-input {
  646. width: 200px;
  647. }
  648. }
  649. </style>
  650. <style type="text/css">
  651. .el-month-table td.today .cell {
  652. color: #05bb4c;
  653. }
  654. .el-month-table td.end-date .cell,
  655. .el-month-table td.start-date .cell {
  656. background-color: #05bb4c;
  657. }
  658. .el-month-table td.in-range div,
  659. .el-month-table td.in-range div:hover {
  660. background: rgba(96, 103, 105, 0.4);
  661. }
  662. .el-date-editor.el-date-editor--monthrange {
  663. border: 1px solid rgba(96, 103, 105, 0.2);
  664. height: 33px;
  665. padding: 0 8px;
  666. width: 369px;
  667. }
  668. .el-date-editor.el-date-editor--monthrange .el-range-separator {
  669. color: #b3bdc0;
  670. line-height: 33px;
  671. }
  672. .el-date-editor.el-date-editor--monthrange .el-range-input {
  673. flex-basis: 145px;
  674. line-height: 33px;
  675. background: transparent;
  676. color: #b3bdc0;
  677. }
  678. .el-picker-panel.el-date-picker {
  679. background: transparent;
  680. color: #b3bdc0;
  681. }
  682. .el-picker-panel.el-date-picker td.current .cell {
  683. background-color: #05bb4c;
  684. color: white;
  685. }
  686. .el-picker-panel.el-date-picker td .cell:hover {
  687. color: #05bb4c;
  688. }
  689. .el-picker-panel.el-date-picker td.current div,
  690. .el-picker-panel.el-date-picker td.current div:hover {
  691. background: rgba(96, 103, 105, 0.4);
  692. border-radius: 50px;
  693. }
  694. </style>