mtbf.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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="公司MTBF分析" :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"), "MTBF");
  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/mtbfList",
  318. data: {
  319. year: year,
  320. },
  321. success(res) {
  322. _this.list = res.data.map((item) => {
  323. for (let key in item) {
  324. if (!site.includes(key)) {
  325. if (_this.isNumber(item[key])) {
  326. item[key] = item[key].toFixed(2);
  327. } else if (!item[key]) {
  328. item[key] = 0;
  329. item[key] = item[key].toFixed(2);
  330. }
  331. }
  332. }
  333. if (item.wpid === "MHS_FDC") {
  334. MhsLists.push(item);
  335. } else if (item.wpid === "NSS_FDC") {
  336. NshList.push(item);
  337. } else if (item.wpid === "QS_FDC") {
  338. QshList.push(item);
  339. } else if (item.wpid === "NSS_FDC") {
  340. NshList.push(item);
  341. } else if (item.wpid === "SBQ_FDC") {
  342. SbaqList.push(item);
  343. } else if (item.wpid === "XS_FDC") {
  344. XshList.push(item);
  345. } else {
  346. GsList.push(item);
  347. }
  348. });
  349. _this.MhsLists = MhsLists.sort(_this.compare("month"));
  350. _this.NshList = NshList.sort(_this.compare("month"));
  351. _this.QshList = QshList.sort(_this.compare("month"));
  352. _this.SbaqList = SbaqList.sort(_this.compare("month"));
  353. _this.XshList = XshList.sort(_this.compare("month"));
  354. _this.GsList = GsList.sort(_this.compare("month"));
  355. let nowCureent = [];
  356. let sameCureent = [];
  357. let monthData = [];
  358. let monthsAll = [];
  359. _this.GsList.map((item) => {
  360. let objs = {};
  361. let obj = {};
  362. monthsAll.push(item.month);
  363. if (item.month > 10) {
  364. objs.text = item.month.toString();
  365. obj.text = item.month.toString();
  366. } else {
  367. item.text = "0" + item.month;
  368. objs.text = item.text;
  369. obj.text = item.text;
  370. }
  371. for (let key in item) {
  372. if (key === "current") {
  373. objs.value = item.current;
  374. nowCureent.push(objs);
  375. } else if (key === "sameperiod") {
  376. obj.value = item.sameperiod;
  377. sameCureent.push(obj);
  378. }
  379. }
  380. });
  381. _this.monthData = monthsAll;
  382. _this.DayPower = {
  383. // 图表所用单位
  384. units: [""],
  385. value: [
  386. {
  387. title: "本期",
  388. yAxisIndex: 0, // 使用单位
  389. value: nowCureent,
  390. // nowCureent
  391. },
  392. {
  393. title: "同期",
  394. yAxisIndex: 0, // 使用单位
  395. value: sameCureent,
  396. // sameCureent
  397. },
  398. ],
  399. };
  400. // _this.DayPower = {
  401. // // 图表所用单位
  402. // units: [""],
  403. // value: [
  404. // {
  405. // title: "本期",
  406. // yAxisIndex: 0, // 使用单位
  407. // value: [],
  408. // },
  409. // {
  410. // title: "同期",
  411. // yAxisIndex: 0, // 使用单位
  412. // value: [],
  413. // },
  414. // ],
  415. // },
  416. // _this.bardata.legend = ["本期", "同期"]
  417. // _this.lineData = [];
  418. // _this.bardata.area = monthData;
  419. // _this.bardata.data[0] = sameCureent;
  420. // _this.bardata.data[1] = nowCureent;
  421. },
  422. });
  423. },
  424. compare(property) {
  425. return (a, b) => {
  426. let val1 = a[property];
  427. let val2 = b[property];
  428. return val1 - val2;
  429. };
  430. },
  431. },
  432. };
  433. </script>
  434. <style lang="less">
  435. .ztfx {
  436. font-size: 12px;
  437. .select-btn {
  438. width: 92px;
  439. }
  440. .com-panel {
  441. border: 1px solid #6067697d;
  442. }
  443. .table-complex {
  444. margin-top: 10px;
  445. .table {
  446. border: 1px solid #6067697d;
  447. tbody {
  448. tr:nth-child(2n) td {
  449. background-color: fade(@gray, 20%);
  450. &.item {
  451. background-color: transparent;
  452. }
  453. }
  454. }
  455. th {
  456. background: fade(@gray, 40);
  457. font-size: 12px;
  458. font-weight: 400;
  459. line-height: 24px;
  460. color: @gray-l;
  461. &.type1 {
  462. border-left: 0;
  463. border-right: 0;
  464. }
  465. }
  466. td {
  467. color: @gray-l;
  468. text-align: center;
  469. height: 26px;
  470. line-height: 26px;
  471. // &.item {
  472. // width: 100px;
  473. // }
  474. }
  475. svg {
  476. height: 1.222vh;
  477. }
  478. }
  479. }
  480. .table-panel {
  481. margin-top: 10px;
  482. .panel-header {
  483. text-align: center;
  484. }
  485. .table {
  486. border: 1px solid #6067697d;
  487. tbody {
  488. tr:nth-child(2n) td {
  489. background-color: fade(@gray, 20%);
  490. &.item {
  491. background-color: transparent;
  492. }
  493. }
  494. }
  495. .td-item {
  496. width: 6vh;
  497. }
  498. th {
  499. background: fade(@gray, 40);
  500. font-size: 12px;
  501. font-weight: 400;
  502. line-height: 24px;
  503. color: @gray-l;
  504. &.type1 {
  505. border-left: 0;
  506. border-right: 0;
  507. height: 4vh;
  508. }
  509. }
  510. td {
  511. color: @gray-l;
  512. text-align: center;
  513. height: 46px;
  514. line-height: 46px;
  515. &.item {
  516. width: 100px;
  517. }
  518. }
  519. svg {
  520. height: 1.222vh;
  521. }
  522. }
  523. }
  524. .pie-chart-panel {
  525. margin-top: 10px;
  526. .line {
  527. border: none;
  528. }
  529. }
  530. }
  531. </style>