whssl.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <div class="ztfx">
  3. <div class="action-bar">
  4. <div class="query mg-b-16">
  5. <div class="query-items">
  6. <div class="query-item">
  7. <div class="lable">日期:</div>
  8. <div class="search-input">
  9. <el-date-picker
  10. v-model="monthValue"
  11. type="year"
  12. placeholder="选择年份"
  13. popper-class="date-select"
  14. :clearable="false"
  15. >
  16. </el-date-picker>
  17. </div>
  18. </div>
  19. <div class="query-item">
  20. <div class="search-input select-btn">
  21. <button class="btn green" @click="onClickSearch">搜索</button>
  22. </div>
  23. <div class="search-input select-btn">
  24. <button class="btn green" @click="exportPDF">导出</button>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <el-row :gutter="20" class="table-panel pdfDom">
  31. <el-col :span="24">
  32. <!-- <panel :title="'月度'" :showLine="false"> -->
  33. <div class="table">
  34. <table style="width: 100%" border="0" cellspacing="0">
  35. <thead>
  36. <tr>
  37. <th rowspan="2" class="type1" style="width: 4vh"></th>
  38. <template v-for="m of monthData" :key="m">
  39. <th style="width: 6vh" class="type1" rowspan="2">{{ m }}</th>
  40. </template>
  41. </tr>
  42. </thead>
  43. </table>
  44. <div style="">
  45. <table
  46. style="width: 100%; text-align: center"
  47. border="0"
  48. cellspacing="0"
  49. >
  50. <tbody>
  51. <tr>
  52. <td style="width: 4vh"></td>
  53. <template v-for="(x, i) of MhsLists" :key="i">
  54. <td style="width: 3vh">本期</td>
  55. <td style="width: 3vh">同期</td>
  56. </template>
  57. </tr>
  58. <tr>
  59. <td class="td-item" style="width: 4vh">麻黄山</td>
  60. <template v-for="(item, index) of MhsLists" :key="index">
  61. <td style="width: 3vh">
  62. {{ item.current }}
  63. <template v-if="item.compare === -1">
  64. <span class="svg-icon svg-icon-yellow">
  65. <svg-icon svgid="svg-arrow-dpwn-1" />
  66. </span>
  67. </template>
  68. <template v-if="item.compare === 1">
  69. <span class="svg-icon svg-icon-green">
  70. <svg-icon svgid="svg-arrow-up-1" />
  71. </span>
  72. </template>
  73. </td>
  74. <td style="width: 3vh">
  75. {{ item.sameperiod }}
  76. </td>
  77. </template>
  78. </tr>
  79. <tr>
  80. <td class="td-item" style="width: 4vh">牛首山</td>
  81. <template v-for="(item, index) of NshList" :key="index">
  82. <td style="width: 3vh">
  83. {{ item.current }}
  84. <template v-if="item.compare === -1">
  85. <span class="svg-icon svg-icon-yellow">
  86. <svg-icon svgid="svg-arrow-dpwn-1" />
  87. </span>
  88. </template>
  89. <template v-if="item.compare === 1">
  90. <span class="svg-icon svg-icon-green">
  91. <svg-icon svgid="svg-arrow-up-1" />
  92. </span>
  93. </template>
  94. </td>
  95. <td style="width: 3vh">
  96. {{ item.sameperiod }}
  97. </td>
  98. </template>
  99. </tr>
  100. <tr>
  101. <td class="td-item" style="width: 4vh">青山</td>
  102. <template v-for="(item, index) of QshList" :key="index">
  103. <td style="width: 3vh">
  104. {{ item.current }}
  105. <template v-if="item.compare === -1">
  106. <span class="svg-icon svg-icon-yellow">
  107. <svg-icon svgid="svg-arrow-dpwn-1" />
  108. </span>
  109. </template>
  110. <template v-if="item.compare === 1">
  111. <span class="svg-icon svg-icon-green">
  112. <svg-icon svgid="svg-arrow-up-1" />
  113. </span>
  114. </template>
  115. </td>
  116. <td style="width: 3vh">
  117. {{ item.sameperiod }}
  118. </td>
  119. </template>
  120. </tr>
  121. <tr>
  122. <td class="td-item" style="width: 4vh">石板泉</td>
  123. <template v-for="(item, index) of SbaqList" :key="index">
  124. <td style="width: 3vh">
  125. {{ item.current }}
  126. <template v-if="item.compare === -1">
  127. <span class="svg-icon svg-icon-yellow">
  128. <svg-icon svgid="svg-arrow-dpwn-1" />
  129. </span>
  130. </template>
  131. <template v-if="item.compare === 1">
  132. <span class="svg-icon svg-icon-green">
  133. <svg-icon svgid="svg-arrow-up-1" />
  134. </span>
  135. </template>
  136. </td>
  137. <td style="width: 3vh">
  138. {{ item.sameperiod }}
  139. </td>
  140. </template>
  141. </tr>
  142. <tr>
  143. <td class="td-item" style="width: 4vh">香山</td>
  144. <template v-for="(item, index) of XshList" :key="index">
  145. <td style="width: 3vh">
  146. {{ item.current }}
  147. <template v-if="item.compare === -1">
  148. <span class="svg-icon svg-icon-yellow">
  149. <svg-icon svgid="svg-arrow-dpwn-1" />
  150. </span>
  151. </template>
  152. <template v-if="item.compare === 1">
  153. <span class="svg-icon svg-icon-green">
  154. <svg-icon svgid="svg-arrow-up-1" />
  155. </span>
  156. </template>
  157. </td>
  158. <td style="width: 3vh">
  159. {{ item.sameperiod }}
  160. </td>
  161. </template>
  162. </tr>
  163. <tr>
  164. <td class="td-item" style="width: 4vh">公司</td>
  165. <template v-for="(item, index) of GsList" :key="index">
  166. <td style="width: 3vh">
  167. {{ item.current }}
  168. <template v-if="item.compare === -1">
  169. <span class="svg-icon svg-icon-yellow">
  170. <svg-icon svgid="svg-arrow-dpwn-1" />
  171. </span>
  172. </template>
  173. <template v-if="item.compare === 1">
  174. <span class="svg-icon svg-icon-green">
  175. <svg-icon svgid="svg-arrow-up-1" />
  176. </span>
  177. </template>
  178. </td>
  179. <td style="width: 3vh">
  180. {{ item.sameperiod }}
  181. </td>
  182. </template>
  183. </tr>
  184. </tbody>
  185. </table>
  186. </div>
  187. <!-- </el-scrollbar> -->
  188. </div>
  189. </el-col>
  190. </el-row>
  191. <el-row :gutter="20" class="table-panel">
  192. <el-col :span="24">
  193. <panel title="公司维护损失率分析" :showLine="false">
  194. <!-- <vertival-bar-line-chart
  195. :height="'360px'"
  196. :units="units"
  197. :bardata="bardata"
  198. :lineData="lineData"
  199. /> -->
  200. <MultipleLineChart
  201. :list="DayPower.value"
  202. :units="DayPower.units"
  203. height="40vh"
  204. :showLegend="true"
  205. />
  206. <!-- :units="units"
  207. :bardata="bardata"
  208. :lineData="lineData" -->
  209. </panel>
  210. </el-col>
  211. </el-row>
  212. </div>
  213. </template>
  214. <script>
  215. // import VertivalBarLineChart from "../../components/chart/combination/vertival-bar-line-chart.vue";
  216. // import VertivalBarLineChart from "../../components/chart/bar/list-bar-chart.vue";
  217. import MultipleLineChart from "../../components/chart/bar/multiple-bar-chart.vue";
  218. import Panel from "../../components/coms/panel/panel.vue";
  219. import DualPieChart from "../../components/chart/pie/dual-pie-chart.vue";
  220. import SvgIcon from "../../components/coms/icon/svg-icon.vue";
  221. import Get_PDF from "@tools/htmlToPdf";
  222. export default {
  223. setup() {},
  224. components: {
  225. Panel,
  226. DualPieChart,
  227. SvgIcon,
  228. // VertivalBarLineChart,
  229. MultipleLineChart,
  230. },
  231. data() {
  232. return {
  233. monthData: [],
  234. MhsLists: [],
  235. NshList: [],
  236. QshList: [],
  237. SbaqList: [],
  238. XshList: [],
  239. GsList: [],
  240. units: [],
  241. nowCurrent: 1,
  242. months: new Date().getMonth() + 1,
  243. pickerOptions: {},
  244. bardata: { area: [], legend: [], data: [] }, // 损失电量分析echart数值
  245. lineData: [],
  246. timmer: null,
  247. monthValue: this.getmonthValue(),
  248. list: [],
  249. DayPower: {
  250. // 图表所用单位
  251. units: [""],
  252. value: [
  253. {
  254. title: "",
  255. yAxisIndex: 0, // 使用单位
  256. value: [],
  257. },
  258. ],
  259. },
  260. };
  261. },
  262. created() {
  263. let _this = this;
  264. // _this.$nextTick(() => {
  265. _this.getLists(false);
  266. // _this.timmer = setInterval(() => {
  267. // _this.getLists(false)
  268. // }, _this.$store.state.websocketTimeSec);
  269. // });
  270. },
  271. unmounted() {
  272. clearInterval(this.timmer);
  273. this.timmer = null;
  274. },
  275. mounted() {},
  276. methods: {
  277. exportPDF(name) {
  278. this.BASE.showMsg({
  279. type: "success",
  280. msg: "正在导出...请稍后...",
  281. });
  282. Get_PDF.downloadPDF(document.querySelector(".pdfDom"), "维护损失率");
  283. },
  284. getmonthValue() {
  285. let year = new Date().getFullYear().toString();
  286. return year;
  287. },
  288. onClickSearch() {
  289. this.getLists(false);
  290. },
  291. monthChange(data) {
  292. let year = data.getFullYear().toString();
  293. return year;
  294. },
  295. isNumber(val) {
  296. return typeof val === "number" && !isNaN(val);
  297. },
  298. getLists(showLoading) {
  299. let MhsLists = [];
  300. let NshList = [];
  301. let QshList = [];
  302. let SbaqList = [];
  303. let XshList = [];
  304. let GsList = [];
  305. let _this = this;
  306. let year = "";
  307. if (typeof this.monthValue === "string") {
  308. year = this.monthValue;
  309. } else {
  310. year = this.monthChange(this.monthValue);
  311. }
  312. const site = ["compare", "year", "month"];
  313. _this.API.requestData({
  314. showLoading,
  315. method: "GET",
  316. baseURL: "http://10.155.32.4:8034",
  317. subUrl: "/specific/whsslList",
  318. data: {
  319. year: year,
  320. },
  321. success(res) {
  322. console.log(res);
  323. _this.list = res.data.map((item) => {
  324. for (let key in item) {
  325. if (!site.includes(key)) {
  326. if (_this.isNumber(item[key])) {
  327. item[key] = item[key].toFixed(2);
  328. } else if (!item[key]) {
  329. item[key] = 0;
  330. item[key] = item[key].toFixed(2);
  331. }
  332. }
  333. }
  334. if (item.wpid === "MHS_FDC") {
  335. MhsLists.push(item);
  336. } else if (item.wpid === "NSS_FDC") {
  337. NshList.push(item);
  338. } else if (item.wpid === "QS_FDC") {
  339. QshList.push(item);
  340. } else if (item.wpid === "NSS_FDC") {
  341. NshList.push(item);
  342. } else if (item.wpid === "SBQ_FDC") {
  343. SbaqList.push(item);
  344. } else if (item.wpid === "XS_FDC") {
  345. XshList.push(item);
  346. } else {
  347. GsList.push(item);
  348. }
  349. });
  350. _this.MhsLists = MhsLists.sort(_this.compare("month"));
  351. _this.NshList = NshList.sort(_this.compare("month"));
  352. _this.QshList = QshList.sort(_this.compare("month"));
  353. _this.SbaqList = SbaqList.sort(_this.compare("month"));
  354. _this.XshList = XshList.sort(_this.compare("month"));
  355. _this.GsList = GsList.sort(_this.compare("month"));
  356. let nowCureent = [];
  357. let sameCureent = [];
  358. let monthData = [];
  359. let monthsAll = [];
  360. _this.GsList.map((item) => {
  361. let objs = {};
  362. let obj = {};
  363. monthsAll.push(item.month);
  364. if (item.month > 10) {
  365. objs.text = item.month.toString();
  366. obj.text = item.month.toString();
  367. } else {
  368. item.text = "0" + item.month;
  369. objs.text = item.text;
  370. obj.text = item.text;
  371. }
  372. for (let key in item) {
  373. if (key === "current") {
  374. objs.value = item.current;
  375. nowCureent.push(objs);
  376. } else if (key === "sameperiod") {
  377. obj.value = item.sameperiod;
  378. sameCureent.push(obj);
  379. }
  380. }
  381. });
  382. _this.monthData = monthsAll;
  383. _this.DayPower = {
  384. // 图表所用单位
  385. units: [""],
  386. value: [
  387. {
  388. title: "本期",
  389. yAxisIndex: 0, // 使用单位
  390. value: nowCureent,
  391. // nowCureent
  392. },
  393. {
  394. title: "同期",
  395. yAxisIndex: 0, // 使用单位
  396. value: sameCureent,
  397. // sameCureent
  398. },
  399. ],
  400. };
  401. // _this.DayPower = {
  402. // // 图表所用单位
  403. // units: [""],
  404. // value: [
  405. // {
  406. // title: "本期",
  407. // yAxisIndex: 0, // 使用单位
  408. // value: [],
  409. // },
  410. // {
  411. // title: "同期",
  412. // yAxisIndex: 0, // 使用单位
  413. // value: [],
  414. // },
  415. // ],
  416. // },
  417. // _this.bardata.legend = ["本期", "同期"]
  418. // _this.lineData = [];
  419. // _this.bardata.area = monthData;
  420. // _this.bardata.data[0] = sameCureent;
  421. // _this.bardata.data[1] = nowCureent;
  422. },
  423. });
  424. },
  425. compare(property) {
  426. return (a, b) => {
  427. let val1 = a[property];
  428. let val2 = b[property];
  429. return val1 - val2;
  430. };
  431. },
  432. },
  433. };
  434. </script>
  435. <style lang="less">
  436. .ztfx {
  437. font-size: 12px;
  438. .select-btn {
  439. width: 92px;
  440. }
  441. .com-panel {
  442. border: 1px solid #6067697d;
  443. }
  444. .table-complex {
  445. margin-top: 10px;
  446. .table {
  447. border: 1px solid #6067697d;
  448. tbody {
  449. tr:nth-child(2n) td {
  450. background-color: fade(@gray, 20%);
  451. &.item {
  452. background-color: transparent;
  453. }
  454. }
  455. }
  456. th {
  457. background: fade(@gray, 40);
  458. font-size: 12px;
  459. font-weight: 400;
  460. line-height: 24px;
  461. color: @gray-l;
  462. &.type1 {
  463. border-left: 0;
  464. border-right: 0;
  465. }
  466. }
  467. td {
  468. color: @gray-l;
  469. text-align: center;
  470. height: 26px;
  471. line-height: 26px;
  472. // &.item {
  473. // width: 100px;
  474. // }
  475. }
  476. svg {
  477. height: 1.222vh;
  478. }
  479. }
  480. }
  481. .table-panel {
  482. margin-top: 10px;
  483. .panel-header {
  484. text-align: center;
  485. }
  486. .table {
  487. border: 1px solid #6067697d;
  488. tbody {
  489. tr:nth-child(2n) td {
  490. background-color: fade(@gray, 20%);
  491. &.item {
  492. background-color: transparent;
  493. }
  494. }
  495. }
  496. .td-item {
  497. width: 6vh;
  498. }
  499. th {
  500. background: fade(@gray, 40);
  501. font-size: 12px;
  502. font-weight: 400;
  503. line-height: 24px;
  504. color: @gray-l;
  505. &.type1 {
  506. border-left: 0;
  507. border-right: 0;
  508. height: 4vh;
  509. }
  510. }
  511. td {
  512. color: @gray-l;
  513. text-align: center;
  514. height: 46px;
  515. line-height: 46px;
  516. &.item {
  517. width: 100px;
  518. }
  519. }
  520. svg {
  521. height: 1.222vh;
  522. }
  523. }
  524. }
  525. .pie-chart-panel {
  526. margin-top: 10px;
  527. .line {
  528. border: none;
  529. }
  530. }
  531. }
  532. </style>