Zoology.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-10-21 17:51:22
  4. * @LastEditTime: 2021-12-17 08:48:08
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 生态监测页面
  7. * @FilePath: \hyyfScreen\src\views\Zoology\Zoology.vue
  8. -->
  9. <template>
  10. <div class="zoology">
  11. <div class="left">
  12. <div class="left-top">
  13. <!-- 左上标题 -->
  14. <div class="left-top-title">
  15. <div class="left-top-title-left"></div>
  16. <div class="left-top-title-center">
  17. <span>育肥一栋</span>
  18. <div class="left-top-title-icon" @click="leftTopSelect"></div>
  19. <!-- 可选择的栋 -->
  20. <div class="left-top-select" v-show="leftTopSelected">
  21. <select-block :title="'一栋'">
  22. <template v-slot:left>
  23. <select-column :list="simulatedData"></select-column>
  24. </template>
  25. <template v-slot:right>
  26. <select-column :floor="false" :type="1"></select-column>
  27. </template>
  28. </select-block>
  29. </div>
  30. </div>
  31. <div class="left-top-title-right"></div>
  32. </div>
  33. <!-- 左上循环滑动 -->
  34. <div
  35. class="left-top-content"
  36. v-loading="loading"
  37. element-loading-text="拼命加载中"
  38. element-loading-spinner="el-icon-loading"
  39. element-loading-background="rgba(0, 0, 0, 0.8)"
  40. >
  41. <swiper
  42. style="height: 600px; margin-top: auto; margin-bottom: auto;"
  43. ref="mySwiper"
  44. class="swiper"
  45. :options="swiperOption"
  46. >
  47. <swiper-slide v-for="item in swiperData" :key="item.roomId">
  48. <swiper-content
  49. @getRoomId="getRoomId"
  50. :list="item"
  51. @onLeave="onLeave"
  52. @onEnter="onEnter"
  53. ></swiper-content>
  54. </swiper-slide>
  55. </swiper>
  56. </div>
  57. </div>
  58. <div
  59. class="left-middle"
  60. v-loading="weatherLoading"
  61. element-loading-text="拼命加载中"
  62. element-loading-spinner="el-icon-loading"
  63. element-loading-background="rgba(0, 0, 0, 0.8)"
  64. >
  65. <chart-board
  66. :title="roomName + '用水量'"
  67. :ifDate="true"
  68. @emitDates="getWaterDates"
  69. >
  70. <chart-line :data="waterData" :id="1"></chart-line>
  71. </chart-board>
  72. </div>
  73. <div class="left-bottom">
  74. <chart-board
  75. :title="roomName + '整栋用电量'"
  76. :ifDate="true"
  77. @emitDates="getElecDates"
  78. >
  79. <chart-line-and :data="waterData" :id="2"></chart-line-and>
  80. </chart-board>
  81. </div>
  82. </div>
  83. <div class="right">
  84. <div class="right-top">
  85. <div class="kuang">
  86. <iframe
  87. :src="
  88. 'static/jinm/index.html?' +
  89. '1' +
  90. ',' +
  91. cameraOne +
  92. ',' +
  93. cameraTwo +
  94. ',' +
  95. '100%' +
  96. ',' +
  97. '0'
  98. "
  99. style="width: 100%; height: 100%;"
  100. frameborder="0"
  101. allowfullscreen="true"
  102. ></iframe>
  103. </div>
  104. </div>
  105. <div class="right-bottom">
  106. <div
  107. class="right-bottom-left"
  108. v-loading="chartLoading"
  109. element-loading-text="拼命加载中"
  110. element-loading-spinner="el-icon-loading"
  111. element-loading-background="rgba(0, 0, 0, 0.8)"
  112. >
  113. <chart-board :title="roomName + '温度'" @emitDates="getWaterDates">
  114. <chart-line :data="tempData" :id="4"></chart-line>
  115. </chart-board>
  116. </div>
  117. <div
  118. class="right-bottom-right"
  119. v-loading="chartLoading"
  120. element-loading-text="拼命加载中"
  121. element-loading-spinner="el-icon-loading"
  122. element-loading-background="rgba(0, 0, 0, 0.8)"
  123. >
  124. <chart-board :title="roomName + '湿度'" @emitDates="getWaterDates">
  125. <chart-line :data="rhData" :id="5"></chart-line>
  126. </chart-board>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. import SelectBlock from "./leftTop/SelectBlock.vue";
  134. import SelectColumn from "./leftTop/SelectColumn.vue";
  135. import { swiper, swiperSlide } from "vue-awesome-swiper";
  136. import "swiper/css/swiper.css";
  137. import SwiperContent from "./leftTop/SwiperContent.vue";
  138. import ChartBoard from "./charts/ChartBoard.vue";
  139. import ChartLine from "./charts/ChartLine.vue";
  140. import ChartLineAnd from "./charts/ChartLineAnd.vue";
  141. import { getEnv, getByRoom, getListWater, getRoomVideo } from "@/utils/api";
  142. import { timeDate, Debounce } from "@/utils";
  143. export default {
  144. name: "Zoology",
  145. components: {
  146. SelectBlock,
  147. SelectColumn,
  148. swiper,
  149. swiperSlide,
  150. SwiperContent,
  151. ChartBoard,
  152. ChartLine,
  153. ChartLineAnd,
  154. },
  155. data() {
  156. return {
  157. leftTopSelected: false, // 左上是否点击了要选择
  158. simulatedData: [
  159. // 左上 —— 模拟的数据
  160. { id: 1, name: "1" },
  161. { id: 2, name: "11" },
  162. { id: 3, name: "111" },
  163. { id: 4, name: "1111" },
  164. { id: 5, name: "1111" },
  165. { id: 6, name: "11111" },
  166. { id: 7, name: "111111" },
  167. { id: 8, name: "1111111" },
  168. ],
  169. swiperOption: {
  170. // 左上 —— 循环滑动
  171. slidesPerView: 4,
  172. autoplay: {
  173. delay: 3000,
  174. stopOnLastSlide: true,
  175. disableOnInteraction: true,
  176. },
  177. loop: true,
  178. },
  179. swiperData: [],
  180. waterDates: [], // 用水量模拟
  181. waterData: {
  182. // 左中 —— 模拟数据
  183. xAxisName: "水量",
  184. xAxisData: ["07-01", "07-02", "07-03", "07-04", "07-05"],
  185. yAxisName: "吨",
  186. yAxisData: [37.1, 37.4, 36.8, 37.9, 34.2],
  187. },
  188. tempData: {
  189. xAxisName: "温度",
  190. xAxisData: [],
  191. yAxisName: "℃",
  192. yAxisData: [],
  193. },
  194. rhData: {
  195. xAxisName: "湿度",
  196. xAxisData: [],
  197. yAxisName: "RH",
  198. yAxisData: [],
  199. },
  200. roomName: "",
  201. elecDates: [], // 用电量时间
  202. isVideo: false,
  203. cameraOne:
  204. "ws://36.26.62.70:9080/camera_relay?tcpaddr=admin%3Ahmkj6688%40172.16.3.62",
  205. cameraTwo:
  206. "rtsp://admin:hmkj6688@172.16.3.62/cam/realmonitor?channel=1&subtype=0",
  207. loading: true,
  208. weatherLoading: true,
  209. chartLoading: true,
  210. };
  211. },
  212. computed: {
  213. swipers() {
  214. return this.$refs.mySwiper.swiper;
  215. },
  216. },
  217. methods: {
  218. init() {
  219. getEnv({}).then((res) => {
  220. if (res.code === 10000) {
  221. this.swiperData = res.data;
  222. this.loading = false;
  223. }
  224. });
  225. },
  226. leftTopSelect() {
  227. // 左上角的选择是否显示
  228. this.leftTopSelected = !this.leftTopSelected;
  229. },
  230. getWaterDates(value) {
  231. // 左中 获取时间
  232. this.waterDates = value;
  233. },
  234. getElecDates(value) {
  235. // 左下 获取时间
  236. this.elecDates = value;
  237. },
  238. getRoomId: Debounce(function(id) {
  239. let params = {
  240. roomId: id,
  241. endDate: timeDate(new Date().getTime()),
  242. type: 1,
  243. };
  244. getByRoom(params).then((res) => {
  245. if (res.code === 10000) {
  246. this.setTempAndRh(res.data);
  247. }
  248. });
  249. let params1 = {
  250. roomId: id,
  251. endDate: timeDate(new Date().getTime()),
  252. type: 2,
  253. };
  254. getListWater(params1).then((res) => {
  255. if (res.code === 10000) {
  256. this.setWeather(res.data);
  257. }
  258. });
  259. getRoomVideo({ roomId: id }).then((res) => {
  260. if (res.code === 10000) {
  261. this.isVideo = true;
  262. this.cameraOne = res.data.wsUrl;
  263. this.cameraTwo = res.data.rtspUrl;
  264. }
  265. });
  266. }),
  267. setTempAndRh(data) {
  268. this.tempData.xAxisData = [];
  269. this.tempData.yAxisData = [];
  270. this.rhData.xAxisData = [];
  271. this.rhData.yAxisData = [];
  272. this.roomName = data.roomName;
  273. data.semperatures.forEach((item) => {
  274. this.tempData.xAxisData.push(item.createTime);
  275. this.tempData.yAxisData.push(item.value);
  276. });
  277. data.humidities.forEach((item) => {
  278. this.rhData.xAxisData.push(item.createTime);
  279. this.rhData.yAxisData.push(item.value);
  280. });
  281. this.chartLoading = false;
  282. },
  283. setWeather(data) {
  284. this.waterData.xAxisData = [];
  285. this.waterData.yAxisData = [];
  286. data.data.forEach((item) => {
  287. this.waterData.xAxisData.push(item.createTime);
  288. this.waterData.yAxisData.push(item.value);
  289. });
  290. this.weatherLoading = false;
  291. },
  292. initData() {
  293. getByRoom({}).then((res) => {
  294. if (res.code === 10000) {
  295. this.setTempAndRh(res.data);
  296. }
  297. });
  298. let params1 = {
  299. endDate: timeDate(new Date().getTime()),
  300. type: 2,
  301. };
  302. getListWater(params1).then((res) => {
  303. if (res.code === 10000) {
  304. this.setWeather(res.data);
  305. }
  306. });
  307. },
  308. onEnter() {
  309. this.swipers.autoplay.stop();
  310. },
  311. onLeave() {
  312. this.swipers.autoplay.start();
  313. },
  314. },
  315. mounted() {
  316. this.init();
  317. this.initData();
  318. },
  319. };
  320. </script>
  321. <style scoped>
  322. .zoology {
  323. width: 100%;
  324. height: 100%;
  325. display: flex;
  326. justify-content: space-around;
  327. padding-top: 20px;
  328. }
  329. /** 左边 */
  330. .left {
  331. /* background-color: #fff; */
  332. width: 40%;
  333. height: 95%;
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: space-between;
  337. }
  338. /* 左上 */
  339. .left-top {
  340. width: 100%;
  341. height: 30%;
  342. background: linear-gradient(
  343. 156deg,
  344. rgba(15, 21, 43, 1) 0%,
  345. rgba(0, 0, 0, 1) 100%
  346. );
  347. }
  348. /* 左上 - title */
  349. .left-top-title {
  350. width: 100%;
  351. height: 26px;
  352. display: flex;
  353. }
  354. .left-top-title-left {
  355. width: 325px;
  356. height: 26px;
  357. background: url("../../assets/BioSafety/u1717.svg") no-repeat;
  358. background-size: 100% 100%;
  359. position: relative;
  360. }
  361. .left-top-title-left::before {
  362. content: "";
  363. height: 85%;
  364. border: 2px solid #66ffff;
  365. position: absolute;
  366. top: 0;
  367. left: 0;
  368. }
  369. .left-top-title-center {
  370. padding: 0 15px;
  371. width: 130px;
  372. height: 26px;
  373. background: url("../../assets/BioSafety/u1719.svg") no-repeat;
  374. background-size: 100% 100%;
  375. line-height: 26px;
  376. color: white;
  377. font-size: 16px;
  378. display: flex;
  379. justify-content: space-around;
  380. position: relative;
  381. }
  382. .left-top-title-icon {
  383. width: 20px;
  384. height: 20px;
  385. background: url("../../assets/Zoology/u5069.svg") no-repeat;
  386. position: relative;
  387. top: 5px;
  388. cursor: pointer;
  389. }
  390. .left-top-title-right {
  391. width: 325px;
  392. height: 26px;
  393. background: url("../../assets/BioSafety/u1718.svg") no-repeat;
  394. background-size: 100% 100%;
  395. position: relative;
  396. }
  397. .left-top-title-right::after {
  398. content: "";
  399. height: 85%;
  400. border: 2px solid #66ffff;
  401. position: absolute;
  402. top: 0;
  403. right: 0;
  404. }
  405. /* 左上 - 点击下拉按钮后的选择框 */
  406. .left-top-select {
  407. position: absolute;
  408. top: 35px;
  409. left: -340px;
  410. border: 2px solid #66ffff;
  411. border-radius: 5px;
  412. padding: 15px 10px;
  413. display: flex;
  414. z-index: 100;
  415. background-color: rgba(15, 21, 43, 0.6);
  416. }
  417. /* 左上 - 滑动 */
  418. .left-top-content {
  419. /* height: 90%; */
  420. height: calc(100% - 26px);
  421. overflow: hidden;
  422. }
  423. /* 左中 */
  424. .left-middle {
  425. width: 100%;
  426. height: 30%;
  427. }
  428. /* 左下 */
  429. .left-bottom {
  430. background-color: rgb(228, 32, 32);
  431. width: 100%;
  432. height: 26.3%;
  433. }
  434. /** 右边 */
  435. .right {
  436. width: 55%;
  437. height: 100%;
  438. }
  439. /* 右上 */
  440. .right-top {
  441. height: 70%;
  442. width: 100%;
  443. /* box-sizing: border-box; */
  444. /* background-color: red; */
  445. padding-left: 25px;
  446. }
  447. .kuang {
  448. width: 100%;
  449. height: 100%;
  450. background: url("../../assets/BioSafety/kuang.png") no-repeat;
  451. background-size: contain;
  452. box-sizing: border-box;
  453. padding: 30px 30px 45px 30px;
  454. }
  455. /* 右下 */
  456. .right-bottom {
  457. display: flex;
  458. background: rgb(3, 16, 50);
  459. height: 25%;
  460. }
  461. .right-bottom-left {
  462. width: 50%;
  463. border-right: 2px solid #66ffff;
  464. }
  465. .right-bottom-right {
  466. margin-left: 10px;
  467. width: 50%;
  468. }
  469. </style>