historyDetail.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div class="historycutInAndOut">
  3. <div class="historycutInAndOut_top">
  4. <!-- <el-select
  5. size="mini"
  6. v-model="hiscompanyVal"
  7. placeholder="请选择"
  8. @change="changeCompan"
  9. >
  10. <el-option
  11. v-for="item in historyCompanyOptions"
  12. :key="item.id"
  13. :label="item.aname"
  14. :value="item.id"
  15. >
  16. </el-option>
  17. </el-select>
  18. <div class="tabCut">
  19. <div
  20. @click="changeBtn(val.id)"
  21. :class="tabIndex === val.id ? 'active' : ''"
  22. v-for="val in tabOptions"
  23. :key="val.id"
  24. >
  25. <span>{{ val.name }}</span>
  26. </div>
  27. </div>
  28. <div class="station">
  29. 场站:
  30. <el-select
  31. size="mini"
  32. v-model="hisstationVal"
  33. placeholder="请选择"
  34. clearable
  35. @change="changeStation"
  36. >
  37. <el-option
  38. v-for="item in hisStationAll"
  39. :key="item.id"
  40. :label="item.name"
  41. :value="item.id"
  42. >
  43. </el-option>
  44. </el-select>
  45. </div> -->
  46. <div class="stationsv">
  47. <span class="timeaa">时间</span>
  48. <el-date-picker
  49. v-model="pickerTimer"
  50. type="daterange"
  51. range-separator="至"
  52. start-placeholder="开始时间"
  53. end-placeholder="结束时间"
  54. size="mini"
  55. format="YYYY/MM/DD"
  56. value-format="YYYY-MM-DD"
  57. />
  58. </div>
  59. <div class="but">
  60. <el-button round size="mini" class="buttons" @click="seachData"
  61. >搜 索</el-button
  62. >
  63. <el-button round size="mini" class="buttons" @click="downXlsxFn"
  64. >导出</el-button
  65. >
  66. </div>
  67. </div>
  68. <div class="economicTable1">
  69. <el-table
  70. :data="historycutInAndOutData"
  71. stripe
  72. size="mini"
  73. height="calc(100% - 40px - 20px)"
  74. ref="historycutInAndOutTable"
  75. style="width: 100%"
  76. >
  77. <el-table-column
  78. align="center"
  79. prop="wtcode"
  80. label="风机"
  81. width="150"
  82. fixed="left"
  83. >
  84. </el-table-column>
  85. <el-table-column
  86. v-for="(item, index) in tableHeader"
  87. :key="index"
  88. sortable
  89. :prop="item.code"
  90. :label="item.title"
  91. header-align="center"
  92. align="center"
  93. >
  94. <template #header="scope">
  95. <div
  96. v-for="(item, index) in headerArr(scope.column.label)"
  97. :key="index"
  98. >
  99. {{ item }}
  100. </div>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <el-pagination
  105. @current-change="handleCurrentChange"
  106. :current-page="page.currentPage"
  107. :page-size="page.pagesize"
  108. @size-change="handleSizeChange"
  109. :page-sizes="[20, 50, 100, 500]"
  110. layout="total, sizes, prev, pager, next, jumper"
  111. :total="page.total"
  112. >
  113. </el-pagination>
  114. </div>
  115. </div>
  116. </template>
  117. <script>
  118. import {
  119. getApioutputSpeedhistorylist,
  120. getApiwpByCplistlist,
  121. } from "@/api/monthlyPerformanceAnalysis";
  122. import utils from "@/utills/downXlsx";
  123. import dataJson from "./dataJson.json"
  124. export default {
  125. props: {
  126. historyCompanyOptions: {
  127. type: Array,
  128. default: [],
  129. },
  130. historyStationOptions: {
  131. type: Array,
  132. default: () => [],
  133. },
  134. tableHeader: {
  135. type: Array,
  136. default: () => [],
  137. },
  138. },
  139. data() {
  140. return {
  141. hiscompanyVal: "",
  142. hisstationVal: "",
  143. hiswindId: "",
  144. pickerTimer: [],
  145. historycutInAndOutData: [],
  146. hisStationAll: [],
  147. showBtn: true,
  148. tabIndex: -1,
  149. tabOptions: [
  150. { id: -1, name: "风电" },
  151. { id: -2, name: "光伏" },
  152. ],
  153. page: {
  154. pagesize: 20,
  155. currentPage: 1,
  156. total: 0,
  157. },
  158. };
  159. },
  160. methods: {
  161. init(row) {
  162. this.hiscompanyVal = row.companyId;
  163. this.hisstationVal = row.windpowerstationId;
  164. this.hiswindId = row.windturbineId;
  165. this.tableHeader.forEach((it, index) => {
  166. if (it.title === "操作") {
  167. this.tableHeader.splice(index);
  168. }
  169. });
  170. this.hisStationAll = this.historyStationOptions;
  171. this.getTableData();
  172. },
  173. changeCompan(val) {
  174. this.hiscompanyVal = val;
  175. this.getStationData();
  176. },
  177. async getStationData() {
  178. this.hisstationVal = "";
  179. this.hisStationAll = [];
  180. let params = {
  181. type: this.tabIndex,
  182. companyid: this.hiscompanyVal,
  183. };
  184. const { data: datas } = await getApiwpByCplistlist(params);
  185. this.hisStationAll = datas.data;
  186. this.hisstationVal = datas.data[0].id;
  187. },
  188. changeStation(val) {
  189. this.hisstationVal = val;
  190. this.getTableData();
  191. },
  192. headerArr(label) {
  193. let arr = [];
  194. let num = 0;
  195. if (label.length > 2) {
  196. if (label.indexOf("风") > 0) {
  197. arr.push(label.substring(0, label.indexOf("风") + 1));
  198. num = label.indexOf("风");
  199. }
  200. if (label.indexOf("入") > 0 || label.indexOf("出") > 0) {
  201. if (label.indexOf("入") > 0) {
  202. arr.push(label.substring(num + 1, label.indexOf("入") + 1));
  203. num = label.indexOf("入");
  204. } else {
  205. arr.push(label.substring(num + 1, label.indexOf("出") + 1));
  206. num = label.indexOf("出");
  207. }
  208. }
  209. arr.push(label.substring(num + 1, label.length));
  210. } else [arr.push(label)];
  211. return arr;
  212. },
  213. changeBtn(id) {
  214. this.tabIndex = id;
  215. this.getStationData();
  216. },
  217. seachData() {
  218. this.getTableData();
  219. },
  220. async getTableData() {
  221. let params = {
  222. cmId: this.hiscompanyVal,
  223. type: this.tabIndex,
  224. pageNum: this.page.currentPage,
  225. pageSize: this.page.pagesize,
  226. beginDate: this.pickerTimer[0],
  227. endDate: this.pickerTimer[1],
  228. wpId: this.hisstationVal,
  229. wtId: this.hiswindId,
  230. };
  231. // this.historycutInAndOutData = dataJson.data.data.records;
  232. // this.page.total = dataJson.data.data.total;
  233. const { data: datas } = await getApioutputSpeedhistorylist(params);
  234. this.historycutInAndOutData = datas.data.records;
  235. this.page.total = datas.data.total;
  236. },
  237. handleSizeChange(val) {
  238. this.page.currentPage = 1;
  239. this.page.pagesize = val;
  240. this.getTableData();
  241. },
  242. handleCurrentChange(val) {
  243. this.page.currentPage = val;
  244. this.getTableData();
  245. },
  246. //转换时间
  247. getchangeTime(date) {
  248. var y = date.getFullYear();
  249. var m = date.getMonth() + 1;
  250. m = m < 10 ? "0" + m : m;
  251. var d = date.getDate();
  252. d = d < 10 ? "0" + d : d;
  253. return y + "-" + m + "-" + d;
  254. },
  255. downXlsxFn() {
  256. let header = [];
  257. this.tableHeader.forEach((it) => {
  258. header.push(it.title);
  259. });
  260. utils.exportExcel(
  261. this.$refs["historycutInAndOutTable"].$el,
  262. header,
  263. "切入切出历史分析"
  264. );
  265. },
  266. },
  267. };
  268. </script>
  269. <style lang="less" scoped>
  270. .historycutInAndOut {
  271. height: 100%;
  272. .historycutInAndOut_top {
  273. display: flex;
  274. flex-direction: row;
  275. align-items: center;
  276. padding-bottom: 10px;
  277. padding-top: 10px;
  278. .station {
  279. display: flex;
  280. flex-direction: row;
  281. align-items: center;
  282. font-size: 14px;
  283. font-family: Microsoft YaHei;
  284. font-weight: 400;
  285. color: #b3b3b3;
  286. margin-right: 10px;
  287. margin-left: 10px;
  288. }
  289. .stationsv {
  290. .timeaa {
  291. font-size: 14px;
  292. font-family: Microsoft YaHei;
  293. font-weight: 400;
  294. color: #b3b3b3;
  295. margin-right: 10px;
  296. margin-left: 10px;
  297. }
  298. }
  299. .tabCut {
  300. display: inline-block;
  301. margin: 0 10px;
  302. div {
  303. display: inline-block;
  304. width: 60px;
  305. height: 27px;
  306. border: 1px solid #274934;
  307. text-align: center;
  308. line-height: 25px;
  309. cursor: pointer;
  310. }
  311. div:nth-child(1) {
  312. border-radius: 13px 0px 0px 13px;
  313. }
  314. div:nth-child(2) {
  315. border-radius: 0px 13px 13px 0px;
  316. }
  317. .active {
  318. background-color: rgba(5, 187, 76, 0.9);
  319. color: #fff;
  320. }
  321. }
  322. .search-input {
  323. margin-left: 10px;
  324. .el-input__inner {
  325. width: 175px;
  326. }
  327. .el-input__suffix {
  328. right: -50px;
  329. }
  330. }
  331. .but {
  332. display: flex;
  333. flex-direction: row;
  334. align-content: center;
  335. margin-left: 20px;
  336. .buttons {
  337. background-color: rgba(5, 187, 76, 0.2);
  338. border: 1px solid #3b6c53;
  339. color: #b3b3b3;
  340. font-size: 14px;
  341. &:hover,
  342. &.active {
  343. background-color: rgba(5, 187, 76, 0.5);
  344. color: #ffffff;
  345. }
  346. }
  347. }
  348. .el-date-editor--daterange {
  349. background: transparent;
  350. border: 1px solid #2a374f;
  351. border-radius: 30px;
  352. height: 25px;
  353. .el-range-input {
  354. background: transparent;
  355. color: #fff;
  356. }
  357. .el-range-separator {
  358. width: 10%;
  359. color: #fff;
  360. position: relative;
  361. }
  362. }
  363. }
  364. .el-pagination ::v-deep {
  365. .el-pagination__sizes {
  366. .el-input__inner {
  367. width: 100% !important;
  368. border-radius: 0 !important;
  369. }
  370. }
  371. }
  372. }
  373. </style>