reportDialog.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <template>
  2. <div class="exportPDF">
  3. <el-button round size="mini" class="buttons" @click="savePdf"
  4. >导出PDF</el-button
  5. >
  6. <!-- <el-button round size="mini" class="buttons" @click="exportWord"
  7. >导出Word</el-button
  8. > -->
  9. </div>
  10. <div
  11. :class="showWhite ? 'monthReportWhite' : 'monthReport'"
  12. v-loading="loading"
  13. >
  14. <div class="dialogHeader">
  15. <span
  16. >{{ dialogTitle }}号风机{{ pickerTimerYear }}年{{
  17. pickerTimerMonth
  18. }}月运行指标性能分析</span
  19. >
  20. </div>
  21. <div class="monthReportTable">
  22. <el-table :data="monthReportData" stripe size="mini" style="width: 100%">
  23. <el-table-column
  24. v-for="(item, index) in tableHeader"
  25. :key="index"
  26. :prop="item.field"
  27. :label="item.name"
  28. align="center"
  29. :width="item.width"
  30. >
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <div class="monthReportMsage">
  35. <div class="textIndent">
  36. 1.本月{{ dialogTitle }}号风机风机设备利用小时数{{
  37. tableVal.byzb && tableVal.byzb.lyxs
  38. }}小时、同比{{ tableVal.tpzb && tableVal.tpzb.lyxs }}小时,
  39. 设备可利用率{{ tableVal.byzb && tableVal.byzb.sbklyl }}%、同比{{
  40. tableVal.tpzb && tableVal.tpzb.sbklyl
  41. }}%, 等效可用系数{{ tableVal.byzb && tableVal.byzb.dxklyxs }}%、同比{{
  42. tableVal.tpzb && tableVal.tpzb.dxklyxs
  43. }}%, 静风频率达到{{ tableVal.byzb && tableVal.byzb.jfpl }}%、同比{{
  44. tableVal.tpzb && tableVal.tpzb.jfpl
  45. }}%, 机组功率特性一致性系数达到{{
  46. tableVal.byzb && tableVal.byzb.glyzxxs
  47. }}%、同比{{ tableVal.tpzb && tableVal.tpzb.glyzxxs }}%。
  48. </div>
  49. <div class="textIndent">
  50. 2.{{ dialogTitle }}风机{{ pickerTimerYear }}年{{
  51. pickerTimerMonth
  52. }}月平均风速{{ tableVal.byzb && tableVal.byzb.fs }}m/s、同比{{
  53. tableVal.tpzb && tableVal.tpzb.fs
  54. }}m/s, 小风平均切入风速{{
  55. tableVal.byzb && tableVal.byzb.xfqr
  56. }}m/s、同比{{ tableVal.tpzb && tableVal.tpzb.xfqr }}m/s, 有效风时数{{
  57. tableVal.byzb && tableVal.byzb.yxfss
  58. }}小时、同比{{ tableVal.tpzb && tableVal.tpzb.yxfss }}小时,
  59. 实际发电电量{{ tableVal.byzb && tableVal.byzb.fdl }}万kwh、同比{{
  60. tableVal.tpzb && tableVal.tpzb.fdl
  61. }}万kwh, 同比增长率{{
  62. tableVal.tbzb && tableVal.tbzb.fdl
  63. }}%,各项损失电量累计{{
  64. tableVal.byzb && tableVal.byzb.llfdl - tableVal.byzb.fdl
  65. }}万kwh、 同比{{
  66. tableVal.tpzb && tableVal.tpzb.llfdl - tableVal.tpzb.fdl
  67. }}万kwh,同比增长率{{
  68. tableVal.tbzb && tableVal.byzb.llfdl - tableVal.tbzb.fdl
  69. }}%, 理论发电量{{
  70. tableVal.byzb && tableVal.byzb.llfdl
  71. }}万kwh,实际发电量与理论发电量相差{{
  72. tableVal.tbzb && tableVal.tbzb.llfdl
  73. }}万kwh。
  74. </div>
  75. <div class="textIndent">
  76. 3.本月静风频率{{
  77. tableVal.byzb && tableVal.byzb.jfpl
  78. }}%,月累计待机小时{{
  79. tableVal.byzb && tableVal.byzb.tjxs
  80. }}小时,待机占比{{ tableVal.tbzb && tableVal.tbzb.tjxs }}%。
  81. </div>
  82. </div>
  83. <div class="monthReportEcharts">
  84. <div id="ffEchart" style="width: 100%; height: 350px"></div>
  85. <div id="fiveEchart" style="width: 100%; height: 350px"></div>
  86. <!-- <div id="jfdjEchart" style="width: 100%; height: 350px"></div> -->
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import {
  92. getApisingleanalysisSub,
  93. getApisingleanalysisChart,
  94. } from "@/api/monthlyPerformanceAnalysis";
  95. import * as echarts from "echarts";
  96. import Get_PDF from "@/tools/htmlToPdf.js";
  97. // import { exportWord, getBase64Sync } from "@/tools/exportFile.js";
  98. import dayjs from "dayjs";
  99. import PizZip from "pizzip";
  100. import docxtemplater from "docxtemplater";
  101. import JSZipUtils from "jszip-utils";
  102. import { saveAs } from "file-saver";
  103. export default {
  104. data() {
  105. return {
  106. img0: "",
  107. img1: "",
  108. img2: "",
  109. showWhite: true,
  110. dialogTitle: "",
  111. pickerTimerYear: "",
  112. pickerTimerMonth: "",
  113. monthReportData: [],
  114. loading: false,
  115. tableHeader: [
  116. { name: "指标名称", field: "name", width: "240" },
  117. { name: "本月值", field: "byzb" },
  118. { name: "去年同期", field: "hqzb" },
  119. { name: "同比增长率(%)", field: "hbzb" },
  120. { name: "环比", field: "tqzb" },
  121. { name: "环比端值(%)", field: "tbzb" },
  122. ],
  123. tabrow: {
  124. fdl: "实际发电量(万千瓦时)",
  125. fs: "平均风速(m/s)",
  126. gzss: "故障损失电量(万千瓦时)",
  127. jxss: "计划检修损失电量(万千瓦时)",
  128. xdss: "调度限电损失电量(万千瓦时)",
  129. xnss: "性能未达标损失电量(万千瓦时)",
  130. slss: "受累损失电量(万千瓦时)",
  131. llfdl: "理论发电量(万千瓦时)",
  132. gzxs: "故障停运时间(小时)",
  133. jxxs: "检修停运时间(小时)",
  134. tjxs: "待机时间(小时)",
  135. zdxs: "通讯中断时间(小时)",
  136. yxxs: "并网时间(小时)",
  137. lyxs: "设备利用小时(小时)",
  138. sbklyl: "设备利用率(%)",
  139. dxklyxs: "等效可用系数(%)",
  140. xfqr: "小风切入风速(m/s)",
  141. glyzxxs: "功率特性一致性系数(%)",
  142. yxfss: "有效风时数(小时)",
  143. xfqrhgl: "小风切入合格率(%)",
  144. jfpl: "静风频率(%)",
  145. },
  146. tableVal: "",
  147. rowData: {},
  148. form: {},
  149. };
  150. },
  151. methods: {
  152. init(row) {
  153. this.monthReportData = [];
  154. this.tableVal = "";
  155. this.showWhite = true;
  156. this.rowData = row;
  157. this.getTableData(row);
  158. },
  159. changeModel() {
  160. this.showWhite = !this.showWhite;
  161. if (!this.showWhite) {
  162. document.querySelector(".monthReport").style.background = "#000";
  163. } else {
  164. document.querySelector(".monthReportWhite").style.background = "#fff";
  165. }
  166. this.getEchartsData(this.rowData);
  167. },
  168. savePdf() {
  169. let dom = "";
  170. if (!this.showWhite) {
  171. dom = document.querySelector(".monthReport");
  172. } else {
  173. dom = document.querySelector(".monthReportWhite");
  174. }
  175. Get_PDF.downloadPDF(
  176. dom,
  177. "运行指标性能分析报告" +
  178. dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
  179. this.showWhite
  180. );
  181. // exportWord(dom, "运行指标性能分析报告.docx", this.showWhite);
  182. },
  183. base64DataURLToArrayBuffer(dataURL) {
  184. const base64Regex = /^data:image\/(png|jpg|svg|svg\+xml);base64,/;
  185. if (!base64Regex.test(dataURL)) {
  186. return false;
  187. }
  188. const stringBase64 = dataURL.replace(base64Regex, "");
  189. let binaryString;
  190. if (typeof window !== "undefined") {
  191. binaryString = window.atob(stringBase64);
  192. } else {
  193. binaryString = new Buffer(stringBase64, "base64").toString("binary");
  194. }
  195. const len = binaryString.length;
  196. const bytes = new Uint8Array(len);
  197. for (let i = 0; i < len; i++) {
  198. const ascii = binaryString.charCodeAt(i);
  199. bytes[i] = ascii;
  200. }
  201. return bytes.buffer;
  202. },
  203. //点击按钮导出word (形参作为word发送到邮箱标识 无需考虑)
  204. exportWord(fileExport) {
  205. //这里要引入处理图片的插件,下载docxtemplater后,引入的就在其中了
  206. //编写docx模板 本文后续有文档模板语法教学
  207. var ImageModule = require("docxtemplater-image-module-free");
  208. var fs = require("fs");
  209. let _this = this;
  210. // 读取并获得模板文件的二进制内容,放在项目根目录public中即可
  211. JSZipUtils.getBinaryContent(
  212. "dataStatistics.docx",
  213. function (error, content) {
  214. if (error) {
  215. throw error;
  216. }
  217. // 图片处理
  218. let opts = {};
  219. opts = { centered: false };
  220. opts.getImage = (chartId) => {
  221. return _this.base64DataURLToArrayBuffer(chartId);
  222. };
  223. opts.getSize = function (img, tagValue, tagName) {
  224. //自定义指定图像大小,此处可动态调试各别图片的大小
  225. return [650, 300]; //例子:宽50px 高度100px
  226. };
  227. // 创建一个PizZip实例,内容为模板的内容
  228. let zip = new PizZip(content);
  229. // 创建并加载docxtemplater实例对象
  230. let doc = new docxtemplater();
  231. doc.attachModule(new ImageModule(opts));
  232. doc.loadZip(zip);
  233. // 设置模板变量的值
  234. doc.setData({
  235. dialogTitle: _this.dialogTitle,
  236. pickerTimerYear: _this.pickerTimerYear,
  237. pickerTimerMonth: _this.pickerTimerMonth,
  238. ..._this.articleParams, //详情内容字段(Object)
  239. table: _this.detailParams, //表格内容(Array)
  240. img0: _this.img0, // echarts图片
  241. img1: _this.img1,
  242. img2: _this.img2,
  243. monthReportData: _this.monthReportData,
  244. lyxs: _this.tableVal.byzb.lyxs,
  245. tplyxs: _this.tableVal.tqzb.lyxs,
  246. sbklyl: _this.tableVal.byzb.sbklyl,
  247. tpsbklyl: _this.tableVal.tqzb.sbklyl,
  248. dxklyxs: _this.tableVal.byzb.dxklyxs,
  249. tpdxklyxs: _this.tableVal.tqzb.dxklyxs,
  250. jfpl: _this.tableVal.byzb.jfpl,
  251. tpjfpl: _this.tableVal.tqzb.jfpl,
  252. glyzxxs: _this.tableVal.byzb.glyzxxs,
  253. tpglyzxxs: _this.tableVal.tqzb.glyzxxs,
  254. // fs: _this.tableVal.byzb.fs,
  255. // tpfs: _this.tableVal.tqzb.fs,
  256. // xfqr: _this.tableVal.byzb.xfqr,
  257. // tpxfqr: _this.tableVal.tqzb.xfqr,
  258. // yxfss : _this.tableVal.byzb.yxfss ,
  259. // tpyxfss : _this.tableVal.tqzb.yxfss ,
  260. // fdl: _this.tableVal.byzb.fdl,
  261. // tpfdl: _this.tableVal.tqzb.fdl,
  262. // tbfdl: _this.tableVal.tbzb.fdl,
  263. // ssfdl: _this.tableVal.byzb.llfdl - _this.tableVal.byzb.fdl,
  264. // tbsfdl: _this.tableVal.tpzb.llfdl - _this.tableVal.tpzb.fdl,
  265. // zzl: _this.tableVal.byzb.llfdl - _this.tableVal.tbzb.fdl,
  266. // llfdl: _this.tableVal.byzb.llfdl,
  267. // xcfdl: _this.tableVal.tbzb.llfdl,
  268. });
  269. try {
  270. // 用模板变量的值替换所有模板变量
  271. doc.render();
  272. } catch (error) {
  273. // 抛出异常
  274. let e = {
  275. message: error.message,
  276. name: error.name,
  277. stack: error.stack,
  278. properties: error.properties,
  279. };
  280. throw error;
  281. }
  282. // 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
  283. let out = doc.getZip().generate({
  284. type: "blob",
  285. mimeType:
  286. "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  287. });
  288. //此文件流 可以传送到后端服务器生成二进制文件(包含上传到阿里云服务器)
  289. if (fileExport == "export") {
  290. let formData = new FormData(); //创建formdata来存文件
  291. const chunkfile = new File([out], "性能分析.docx");
  292. formData.append("file", chunkfile); //存入文件
  293. formData.append("toEmailList", _this.mailForm.toEmailList);
  294. formData.append("customSubject", _this.mailForm.customSubject);
  295. //formData文件 需注意此api请求方式 下文会描述
  296. dataDetailsEmailApi(formData).then((res) => {
  297. if (res.data.code == 200) {
  298. _this.$message.success("发送成功");
  299. }
  300. });
  301. } else {
  302. // 将目标文件对象保存为目标类型的文件,并命名
  303. saveAs(out, "性能分析.docx");
  304. }
  305. }
  306. );
  307. },
  308. async getTableData(row) {
  309. this.loading = true;
  310. let params = {
  311. wtId: row.windturbineid,
  312. year: this.pickerTimerYear,
  313. month: this.pickerTimerMonth,
  314. };
  315. const { data: datas } = await getApisingleanalysisSub(params);
  316. this.tableVal = datas.data;
  317. let arr = [];
  318. let keyarr = Object.keys(datas.data.byzb);
  319. let jarr = Object.keys(datas.data);
  320. for (let k of keyarr) {
  321. let obj = {
  322. name: k,
  323. byzb: null,
  324. hbzb: null,
  325. hqzb: null,
  326. tbzb: null,
  327. tqzb: null,
  328. };
  329. for (let i in datas.data) {
  330. for (let j of jarr) {
  331. if (i == j) {
  332. obj[j] = datas.data[i][k];
  333. }
  334. }
  335. }
  336. arr.push(obj);
  337. }
  338. arr = arr.filter((e) => {
  339. return (
  340. e.name != "id" &&
  341. e.name != "windturbineid" &&
  342. e.name != "companyId" &&
  343. e.name != "types" &&
  344. e.name != "windturbineName" &&
  345. e.name != "windPowerStationId" &&
  346. e.name != "windPowerStationName" &&
  347. e.name != "recorddate" &&
  348. e.name != "swdl" &&
  349. e.name != "gwdl" &&
  350. e.name != "rlxs" &&
  351. e.name != "fjrl"
  352. );
  353. });
  354. arr.forEach((e) => {
  355. e.name = this.tabrow[e.name];
  356. });
  357. this.monthReportData = arr;
  358. this.getEchartsData(row);
  359. },
  360. async getEchartsData(row) {
  361. let params = {
  362. wtId: row.windturbineid,
  363. year: this.pickerTimerYear,
  364. month: this.pickerTimerMonth,
  365. };
  366. const { data: datas } = await getApisingleanalysisChart(params);
  367. const res = datas.data;
  368. // 日发电量与风速
  369. this.makePowerAndWind(res);
  370. // 五项损失
  371. this.makeFiveBarEchart(res);
  372. //静风频率和待机时间
  373. // this.makeQuietAirStandby(res);
  374. this.loading = false;
  375. },
  376. //日发电量与风速----数据整体与展示
  377. makePowerAndWind(res) {
  378. let arrfffdl = [];
  379. let arrfffs = [];
  380. let xAxis = [];
  381. res.ff.forEach((e) => {
  382. let date = e.recorddate.substring(
  383. e.recorddate.indexOf("-") + 1,
  384. e.recorddate.indexOf("T")
  385. );
  386. xAxis.push(date);
  387. let objfdl = {
  388. name: "日发电量",
  389. value: e.fdl,
  390. itemStyle: {
  391. color: "#05bb4c",
  392. },
  393. };
  394. let objfs = {
  395. name: "风速",
  396. value: e.fs,
  397. itemStyle: {
  398. color: "#dcc652",
  399. },
  400. };
  401. arrfffdl.push(objfdl);
  402. arrfffs.push(objfs);
  403. });
  404. this.getPowerAndWind(xAxis, arrfffdl, arrfffs);
  405. },
  406. getPowerAndWind(xAxis, barData, lineData) {
  407. let option = {
  408. backgroundColor: this.showWhite ? "#fff" : "",
  409. color: ["#05bb4c", "#dcc652"],
  410. title: {
  411. text: "日发电量",
  412. textStyle: {
  413. color: this.showWhite ? "#000" : "#fff",
  414. },
  415. },
  416. tooltip: {
  417. trigger: "axis",
  418. },
  419. legend: {
  420. right: "20",
  421. data: ["日发电量", "风速"],
  422. textStyle: {
  423. color: this.showWhite ? "#000" : "#fff",
  424. },
  425. },
  426. xAxis: [
  427. {
  428. type: "category",
  429. data: xAxis,
  430. axisLabel: {
  431. color: this.showWhite ? "#000" : "#fff",
  432. },
  433. },
  434. ],
  435. yAxis: [
  436. {
  437. type: "value",
  438. name: "日发电量",
  439. // min: 0,
  440. // max: 250,
  441. // interval: 50,
  442. nameTextStyle: {
  443. color: this.showWhite ? "#000" : "#fff",
  444. },
  445. axisLabel: {
  446. color: this.showWhite ? "#000" : "#fff",
  447. formatter: "{value} 万(Kwh)",
  448. },
  449. },
  450. {
  451. type: "value",
  452. name: "风速",
  453. // min: 0,
  454. // max: 25,
  455. interval: 5,
  456. nameTextStyle: {
  457. color: this.showWhite ? "#000" : "#fff",
  458. },
  459. axisLabel: {
  460. color: this.showWhite ? "#000" : "#fff",
  461. formatter: "{value}(m/s)",
  462. },
  463. },
  464. ],
  465. series: [
  466. {
  467. name: "日发电量",
  468. type: "bar",
  469. barWidth: 40,
  470. data: barData,
  471. },
  472. {
  473. name: "风速",
  474. type: "line",
  475. data: lineData,
  476. },
  477. ],
  478. };
  479. // 基于准备好的dom,初始化echarts实例
  480. let dom = document.getElementById("ffEchart");
  481. dom.removeAttribute("_echarts_instance_");
  482. let myChart = echarts.init(dom);
  483. myChart.setOption(option, this.showWhite ? "" : "dark");
  484. this.img0 = myChart.getDataURL({
  485. pixelRatio: 1, // 导出的图片分辨率比例,默认为 1。
  486. backgroundColor: "#ffffff", // 导出的图片背景色,默认使用 option 里的 backgroundColor
  487. });
  488. window.addEventListener("resize", function () {
  489. myChart.resize();
  490. });
  491. },
  492. //五项损失
  493. makeFiveBarEchart(res) {
  494. let arrwslegend = [
  495. "限电损失电量",
  496. "性能未达标损失电量",
  497. "检修损失电量",
  498. "故障损失电量",
  499. "受累损失电量",
  500. ];
  501. let arrwsdata = [
  502. {
  503. name: "限电损失电量",
  504. type: "bar",
  505. stack: "one",
  506. barWidth: "10%",
  507. data: res.ws.map((i) => i.xdss),
  508. },
  509. {
  510. name: "性能未达标损失电量",
  511. type: "bar",
  512. stack: "one",
  513. barWidth: "10%",
  514. data: res.ws.map((i) => i.xnss),
  515. },
  516. {
  517. name: "检修损失电量",
  518. type: "bar",
  519. stack: "one",
  520. barWidth: "10%",
  521. data: res.ws.map((i) => i.jxss),
  522. },
  523. {
  524. name: "故障损失电量",
  525. type: "bar",
  526. stack: "one",
  527. barWidth: "10%",
  528. data: res.ws.map((i) => i.gzss),
  529. },
  530. {
  531. name: "受累损失电量",
  532. type: "bar",
  533. stack: "one",
  534. barWidth: "10%",
  535. data: res.ws.map((i) => i.slss),
  536. },
  537. ];
  538. let xAxis = res.ws.map((i) => dayjs(i.recorddate).format("YYYY-MM-DD"));
  539. this.getFiveBarEchart(xAxis, arrwslegend, arrwsdata);
  540. },
  541. getFiveBarEchart(xAxis, lenged, series) {
  542. let option = {
  543. backgroundColor: this.showWhite ? "#fff" : "",
  544. color: [
  545. "#05bb4c",
  546. "#4b55ae",
  547. "#e17e23",
  548. "#02BB4C",
  549. "#EDB32F",
  550. "#EDEB2F",
  551. ],
  552. title: {
  553. text: "损失电量分析",
  554. textStyle: {
  555. color: this.showWhite ? "#000" : "#fff",
  556. },
  557. },
  558. tooltip: {
  559. trigger: "axis",
  560. textStyle: {
  561. color: this.showWhite ? "#000" : "#fff",
  562. },
  563. },
  564. legend: {
  565. data: lenged,
  566. right: 20,
  567. textStyle: {
  568. color: this.showWhite ? "#000" : "#fff",
  569. },
  570. },
  571. xAxis: [
  572. {
  573. type: "category",
  574. axisLabel: {
  575. color: this.showWhite ? "#000" : "#fff",
  576. },
  577. data: xAxis,
  578. },
  579. ],
  580. yAxis: [
  581. {
  582. type: "value",
  583. name: "",
  584. nameTextStyle: {
  585. color: this.showWhite ? "#000" : "#fff",
  586. },
  587. axisLabel: {
  588. color: this.showWhite ? "#000" : "#fff",
  589. },
  590. },
  591. ],
  592. series: series,
  593. };
  594. // 基于准备好的dom,初始化echarts实例
  595. let dom = document.getElementById("fiveEchart");
  596. dom.removeAttribute("_echarts_instance_");
  597. let myChart = echarts.init(dom);
  598. myChart.setOption(option, this.showWhite ? "" : "dark");
  599. setTimeout(() => {
  600. this.img1 = myChart.getDataURL({
  601. pixelRatio: 1, // 导出的图片分辨率比例,默认为 1。
  602. backgroundColor: "#ffffff", // 导出的图片背景色,默认使用 option 里的 backgroundColor
  603. });
  604. }, 2000);
  605. window.addEventListener("resize", function () {
  606. myChart.resize();
  607. });
  608. },
  609. //静风频率和待机时间
  610. makeQuietAirStandby(res) {
  611. // let arrjdjf = [];
  612. // let arrjddj = [];
  613. // let xAxis = [];
  614. // let series = [];
  615. // res.jd.forEach((e) => {
  616. // series;
  617. // let date = e.recorddate.substring(
  618. // e.recorddate.indexOf("-") + 1,
  619. // e.recorddate.indexOf("T")
  620. // );
  621. // xAxis.push(date);
  622. // arrjdjf.push(e.jfpl);
  623. // arrjddj.push(e.tjxs);
  624. // });
  625. // let obj = {
  626. // title: "静风时长(小时)",
  627. // type: "line",
  628. // value: arrjdjf,
  629. // };
  630. // series.push(obj);
  631. // let obj1 = {
  632. // title: "待机时长(小时)",
  633. // type: "line",
  634. // value: arrjddj,
  635. // };
  636. // series.push(obj1);
  637. // this.getQuietAirStandbyLineEchart(xAxis, series);
  638. },
  639. getQuietAirStandbyLineEchart(xAxis, series) {
  640. let option = {
  641. backgroundColor: this.showWhite ? "#fff" : "",
  642. color: ["#05bb4c", "#4b55ae"],
  643. title: {
  644. text: "损失电量分析",
  645. textStyle: {
  646. color: this.showWhite ? "#000" : "#fff",
  647. },
  648. },
  649. tooltip: {
  650. trigger: "axis",
  651. },
  652. legend: {
  653. right: "20",
  654. data: ["静风时长(小时)", "待机时长(小时)"],
  655. },
  656. xAxis: {
  657. type: "category",
  658. boundaryGap: false,
  659. data: xAxis,
  660. },
  661. yAxis: {
  662. type: "value",
  663. },
  664. series: series,
  665. };
  666. // 基于准备好的dom,初始化echarts实例
  667. let dom = document.getElementById("jfdjEchart");
  668. dom.removeAttribute("_echarts_instance_");
  669. let myChart = echarts.init(dom, this.showWhite ? "" : "dark");
  670. myChart.setOption(option);
  671. this.img2 = myChart.getDataURL({
  672. pixelRatio: 2, // 导出的图片分辨率比例,默认为 1。
  673. backgroundColor: "#999999", // 导出的图片背景色,默认使用 option 里的 backgroundColor
  674. });
  675. window.addEventListener("resize", function () {
  676. myChart.resize();
  677. });
  678. },
  679. },
  680. };
  681. </script>
  682. <style lang="less">
  683. .exportPDF {
  684. float: right;
  685. margin-right: 35px;
  686. margin-top: 10px;
  687. .buttons {
  688. background-color: rgba(0, 70, 199, 1);
  689. color: #fff;
  690. font-size: 14px;
  691. }
  692. }
  693. .monthReport {
  694. padding: 0 23px;
  695. padding-top: 20px;
  696. .dialogHeader {
  697. text-align: center;
  698. color: #fff;
  699. font-weight: 600;
  700. font-size: 16px;
  701. margin-bottom: 40px;
  702. span {
  703. position: relative;
  704. left: 5%;
  705. }
  706. }
  707. .el-button {
  708. min-height: 25px;
  709. height: 25px;
  710. span {
  711. position: relative;
  712. top: -8px;
  713. }
  714. }
  715. .monthReportTable {
  716. margin: 10px;
  717. padding-bottom: 10px;
  718. background: rgba(0, 0, 0, 0.4);
  719. }
  720. .monthReportMsage {
  721. .textIndent {
  722. color: #fff;
  723. font-size: 16px;
  724. line-height: 30px;
  725. text-indent: 2em;
  726. }
  727. }
  728. .monthReportEcharts {
  729. margin-top: 20px;
  730. }
  731. .el-loading-mask {
  732. background-color: rgba(0, 0, 0, 1) !important;
  733. }
  734. }
  735. .monthReportWhite {
  736. padding: 0 23px;
  737. background: #fff;
  738. padding-top: 20px;
  739. .dialogHeader {
  740. text-align: center;
  741. color: #000;
  742. font-weight: 600;
  743. font-size: 16px;
  744. margin-bottom: 40px;
  745. span {
  746. position: relative;
  747. left: 5%;
  748. }
  749. }
  750. .el-button {
  751. min-height: 25px;
  752. height: 25px;
  753. span {
  754. position: relative;
  755. top: -8px;
  756. }
  757. }
  758. .monthReportTable {
  759. margin: 10px;
  760. padding-bottom: 10px;
  761. background: rgba(255, 255, 255, 0.4);
  762. .el-table__header-wrapper {
  763. .has-gutter {
  764. tr {
  765. color: #000;
  766. }
  767. }
  768. }
  769. .el-table__body-wrapper {
  770. .el-table__body {
  771. tr {
  772. color: #000;
  773. }
  774. }
  775. }
  776. }
  777. .monthReportMsage {
  778. .textIndent {
  779. color: #000;
  780. font-size: 16px;
  781. line-height: 30px;
  782. text-indent: 2em;
  783. }
  784. }
  785. .monthReportEcharts {
  786. margin-top: 20px;
  787. }
  788. .el-loading-mask {
  789. // background-color: rgba(0,0,0,1) !important;
  790. }
  791. }
  792. </style>