index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div
  3. class="page-wrapper"
  4. v-loading="loading"
  5. element-loading-text="加载中..."
  6. element-loading-background="rgba(4, 12, 11, 0.8)"
  7. >
  8. <!-- 头部按钮选项 -->
  9. <HeaderNav @firstRender="firstRender" :isAll="true" />
  10. <div class="wrapper">
  11. <div class="chart-wrapper">
  12. <div
  13. class="chart-item"
  14. v-for="(item, index) in list"
  15. :key="index"
  16. :style="{ width: isFixed ? '900px' : '935px' }"
  17. @dblclick="handleClick(list[index]?.name, index)"
  18. >
  19. <div class="chart-item-name">
  20. <p class="text" title="双击查看详情">{{ list[index]?.name }}</p>
  21. </div>
  22. <div class="chart-item-chart">
  23. <multipleLineChartVue
  24. ref="multipLineChart"
  25. height="100%"
  26. width="100%"
  27. :type="activeTab"
  28. :chartData="list[index]"
  29. />
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <el-dialog
  35. class="dialogs"
  36. width="75%"
  37. top="120px"
  38. v-model="displayDialog"
  39. :show-close="true"
  40. @close="handleClose"
  41. destroy-on-close
  42. >
  43. <template #title>
  44. <div class="dialog-title">
  45. <div class="title">{{ showName }}功率预测详情</div>
  46. </div>
  47. </template>
  48. <div class="dialog-body" style="height: 600px">
  49. <img class="dialog-img" src="@assets/imgs/dialog.png" />
  50. <div class="dialog-form">
  51. <div class="date-wrapper">
  52. 开始时间
  53. <div style="margin-left: 10px">
  54. <el-date-picker
  55. v-model="beginDate"
  56. type="date"
  57. size="mini"
  58. :disabled-date="disabledDate"
  59. placeholder="选择日期"
  60. popper-class="date-select"
  61. value-format="YYYY-MM-DD"
  62. >
  63. </el-date-picker>
  64. </div>
  65. </div>
  66. <div class="date-wrapper">
  67. 结束时间
  68. <div style="margin-left: 10px">
  69. <el-date-picker
  70. v-model="endDate"
  71. size="mini"
  72. type="date"
  73. :disabled-date="disabledDate2"
  74. popper-class="date-select"
  75. placeholder="选择日期"
  76. value-format="YYYY-MM-DD"
  77. >
  78. </el-date-picker>
  79. </div>
  80. </div>
  81. <div class="btns">
  82. <el-button round size="mini" class="buttons" @click="handleSearch"
  83. >查 询</el-button
  84. >
  85. </div>
  86. </div>
  87. <div class="dialog-chart" v-if="!isDouble">
  88. <multipleLineChartVue
  89. ref="multipLineChart"
  90. :type="activeTab"
  91. :chartData="singleChartData"
  92. />
  93. </div>
  94. <div class="dialog-chart" v-if="isDouble">
  95. <div class="carousel-wrapper">
  96. <el-carousel trigger="click" height="100%" :autoplay="false">
  97. <el-carousel-item
  98. v-for="(chart, key) in doubleChartData"
  99. :key="key"
  100. :name="doubleChartData[key]?.name"
  101. >
  102. <multipleLineChartVue
  103. ref="multipLineChart"
  104. :chartData="doubleChartData[key]"
  105. width="1392px"
  106. :type="activeTab"
  107. height="580px"
  108. :isDouble="isDouble"
  109. />
  110. </el-carousel-item>
  111. </el-carousel>
  112. </div>
  113. </div>
  114. </div>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script>
  119. import HeaderNav from "@/components/headerNavSta/index.vue";
  120. import multipleLineChartVue from "./components/multiple-line-chart.vue";
  121. import { GetAllPowerData, GetPowerData } from "@/api/factoryMonitor/index.js";
  122. import dayjs from "dayjs";
  123. export default {
  124. name: "PowerCurveMatrix", //全景监视
  125. data() {
  126. return {
  127. activeTab: -1,
  128. list: {},
  129. displayDialog: false,
  130. showName: "",
  131. beginDate: "",
  132. endDate: "",
  133. format: "YYYY-MM-DD",
  134. doubleChartData: [],
  135. singleChartData: {},
  136. isDouble: false,
  137. showWpid: "",
  138. isSearch: false,
  139. timer: null,
  140. loading: false,
  141. flag: false,
  142. };
  143. },
  144. components: {
  145. HeaderNav,
  146. multipleLineChartVue,
  147. },
  148. created() {
  149. this.beginDate = dayjs().startOf("day").format(this.format);
  150. this.endDate = dayjs().add(3, "day").format(this.format);
  151. // this.init();
  152. },
  153. mounted() {
  154. this.timer = setInterval(() => {
  155. this.flag = true;
  156. this.init();
  157. }, 15 * 60 * 1000);
  158. },
  159. unmounted() {
  160. clearInterval(this.timer);
  161. this.timer = null;
  162. },
  163. methods: {
  164. // 时间选择器第一个禁用
  165. disabledDate(time) {
  166. if (this.endDate) {
  167. return time.getTime() > Date.parse(this.endDate);
  168. } else {
  169. return null;
  170. }
  171. },
  172. // 时间选择器第二个禁用
  173. disabledDate2(time) {
  174. if (this.beginDate) {
  175. return time.getTime() < Date.parse(this.beginDate);
  176. } else {
  177. return null;
  178. }
  179. },
  180. firstRender(tab) {
  181. this.activeTab = tab;
  182. clearInterval(this.timer);
  183. this.timer = null;
  184. this.flag = false;
  185. this.init();
  186. this.timer = setInterval(() => {
  187. this.flag = true;
  188. this.init();
  189. }, 15 * 60 * 1000);
  190. },
  191. init() {
  192. if (this.flag) {
  193. this.loading = false;
  194. } else {
  195. this.loading = true;
  196. }
  197. GetAllPowerData({
  198. type: this.activeTab == -1 ? "F" : "G",
  199. beginDate: this.beginDate,
  200. endDate: this.endDate,
  201. }).then(({ code, data }) => {
  202. this.loading = false;
  203. if (code == 200) {
  204. this.list = this.dealRes(data);
  205. }
  206. });
  207. },
  208. dealRes(res) {
  209. let resData = JSON.parse(JSON.stringify(res));
  210. for (let key in resData) {
  211. resData[key] = {
  212. name: "",
  213. ycgl: [],
  214. llgl: [],
  215. sjgl: [],
  216. pjfs: [],
  217. ycfs: [],
  218. xAxis: [],
  219. };
  220. }
  221. for (let index in res) {
  222. resData[index].name = res[index][0].name;
  223. res[index].forEach((ele) => {
  224. resData[index].pjfs.push(ele.pjfs);
  225. resData[index].ycfs.push(ele.ycfs);
  226. resData[index].sjgl.push(ele.sjgl);
  227. resData[index].ycgl.push(ele.ycgl);
  228. resData[index].llgl.push(ele.llgl);
  229. resData[index].xAxis.push(dayjs(ele.hours).format("MM-DD HH:mm:ss"));
  230. });
  231. }
  232. return resData;
  233. },
  234. handleClick(name, id) {
  235. this.showName = name;
  236. this.showWpid = id;
  237. this.beginDate = dayjs().startOf("day").format(this.format);
  238. this.endDate = dayjs().add(10, "day").format(this.format);
  239. this.getPowerData();
  240. },
  241. getPowerData() {
  242. GetPowerData({
  243. wpId: this.showWpid,
  244. beginDate: this.beginDate,
  245. endDate: this.endDate,
  246. }).then((res) => {
  247. if (res && res.code == 200) {
  248. if (!this.isSearch) {
  249. this.displayDialog = true;
  250. }
  251. if (Object.keys(res.data).length < 2) {
  252. this.isDouble = false;
  253. this.singleChartData = this.dealRes(res.data)[this.showWpid];
  254. } else if (Object.keys(res.data).length >= 2) {
  255. this.isDouble = true;
  256. this.doubleChartData = this.dealRes(res.data);
  257. }
  258. }
  259. });
  260. },
  261. handleClose() {
  262. this.isSearch = false;
  263. this.showName = "";
  264. this.showWpid = "";
  265. this.singleChartData = [];
  266. this.doubleChartData = [];
  267. },
  268. handleSearch() {
  269. this.isSearch = true;
  270. this.getPowerData();
  271. },
  272. },
  273. computed: {
  274. isFixed() {
  275. return this.$store.state.isFixed;
  276. },
  277. },
  278. };
  279. </script>
  280. <style scoped lang="less">
  281. .carousel-wrapper {
  282. height: 100%;
  283. width: 100%;
  284. .el-carousel {
  285. height: 100%;
  286. width: 100%;
  287. .el-carousel__container {
  288. height: 100%;
  289. width: 100%;
  290. .el-carousel__item {
  291. height: 100%;
  292. width: 100%;
  293. }
  294. }
  295. }
  296. }
  297. .el-carousel__item h3 {
  298. color: #475669;
  299. opacity: 0.75;
  300. line-height: 150px;
  301. margin: 0;
  302. text-align: center;
  303. }
  304. .page-wrapper {
  305. height: 100%;
  306. width: 100%;
  307. .wrapper {
  308. height: calc(100% - 57px);
  309. width: 100%;
  310. padding: 0 20px 10px 20px;
  311. overflow-y: auto;
  312. }
  313. }
  314. .chart-wrapper {
  315. width: 100%;
  316. display: grid;
  317. grid-template-columns: auto auto;
  318. grid-auto-rows: 256px;
  319. grid-gap: 20px;
  320. padding-bottom: 10px;
  321. .chart-item {
  322. width: 935px;
  323. height: 256px;
  324. // border: 1px solid #fff;
  325. display: flex;
  326. align-items: center;
  327. background: url("~@/assets/imgs/power-bg1.png") no-repeat;
  328. background-size: 100% 100%;
  329. cursor: pointer;
  330. .chart-item-name {
  331. display: flex;
  332. width: 50px;
  333. height: 256px;
  334. border-right: 1px solid #3a3f43;
  335. justify-content: center;
  336. align-items: center;
  337. .text {
  338. writing-mode: vertical-lr;
  339. margin: 0;
  340. }
  341. }
  342. .chart-item-chart {
  343. width: calc(100% - 50px);
  344. height: 100%;
  345. }
  346. }
  347. }
  348. .dialog-body {
  349. .dialog-form {
  350. display: flex;
  351. align-items: center;
  352. height: 38px;
  353. .date-wrapper {
  354. display: flex;
  355. align-items: center;
  356. font-size: 13px;
  357. color: #b3b3b3;
  358. margin-right: 10px;
  359. }
  360. .buttons {
  361. background-color: rgba(5, 187, 76, 0.2);
  362. border: 1px solid #3b6c53;
  363. color: #b3b3b3;
  364. font-size: 14px;
  365. &:hover,
  366. &.active {
  367. background-color: rgba(5, 187, 76, 0.5);
  368. color: #ffffff;
  369. }
  370. }
  371. }
  372. .dialog-chart {
  373. height: calc(100% - 38px);
  374. }
  375. }
  376. </style>