swiperMulti.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="swiperMulti" @mouseenter="mouseenter" @mouseleave="mouseleave">
  3. <div class="el-toLeft guide" v-show="guideShow" @click.stop="toLeft">
  4. <i class="el-icon-arrow-right icon"></i>
  5. </div>
  6. <div class="el-toRight guide" v-show="guideShow" @click.stop="toRight">
  7. <i class="el-icon-arrow-left icon"></i>
  8. </div>
  9. <ul>
  10. <li
  11. v-for="(item, index) in data"
  12. :key="item.lqid"
  13. :style="`left:${(index - 1) * itemPositionInterval}px`"
  14. :ref="'item' + index"
  15. :data-position-left="(index - 1) * itemPositionInterval"
  16. >
  17. <template v-if="item.isQk">
  18. <h3 class="h3_type_1">{{item.position}}</h3>
  19. <div class="warp">
  20. <div class="gutter" @click="openItem(item, 1)">
  21. <el-row>
  22. <el-col :span="10" class="temp-line">
  23. <span >水量:</span>
  24. </el-col>
  25. <el-col :span="14" style="text-align: left;">
  26. <span v-if="item.sl === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
  27. <span v-else class="text-green" >{{item.sl}}吨</span>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. <div class="gutter" @click="openItem(item, 2)">
  32. <el-row>
  33. <el-col :span="10" class="humidity-line">
  34. <span >电量:</span>
  35. </el-col>
  36. <el-col :span="14" class="gutter_text" style="text-align: left;">
  37. <span v-if="item.dl === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
  38. <span v-else class="text-green" >{{item.dl}}kwh</span>
  39. </el-col>
  40. </el-row>
  41. </div>
  42. <div class="gutter" @click="openItem(item, 3)">
  43. <el-row>
  44. <el-col :span="10" class="ammonia-line">
  45. <span >ph:</span>
  46. </el-col>
  47. <el-col :span="14" style="text-align: left;">
  48. <span v-if="item.ph === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
  49. <span v-else class="text-green" >{{item.ph}}</span>
  50. </el-col>
  51. </el-row>
  52. </div>
  53. <div class="gutter" @click="openItem(item, 4)">
  54. <el-row>
  55. <el-col :span="10" class="ammonia-line">
  56. <span >水压:</span>
  57. </el-col>
  58. <el-col :span="14" style="text-align: left;">
  59. <span v-if="item.sy === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
  60. <span v-else class="text-green" >{{item.sy}}Mpa</span>
  61. </el-col>
  62. </el-row>
  63. </div>
  64. </div>
  65. </template>
  66. <template v-else>
  67. <!-- {{ item.id }} -->
  68. <h3 class="h3_type_1">{{item.position}}</h3>
  69. <div class="warp" @click="onOpen(item)">
  70. <div class="gutter">
  71. <el-row>
  72. <el-col :span="14" class="temp-line">
  73. <i class="icon_temp"></i>
  74. <span class="temp_text">温度:</span>
  75. </el-col>
  76. <el-col :span="10" style="text-align: left;">
  77. <span v-if="item.temp === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
  78. <span v-else :class="item.temp > 35 ? 'text-red' : 'text-green'" >{{item.temp}}℃</span>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. <div class="gutter" @click="onOpen(item)">
  83. <el-row>
  84. <el-col :span="14" class="humidity-line">
  85. <i class="icon_humidity"></i>
  86. <span class="humidity_text">湿度:</span>
  87. </el-col>
  88. <el-col :span="10" class="gutter_text" style="text-align: left;">
  89. <span v-if="item.humidity === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
  90. <span v-else :class="item.humidity > 93 ? 'text-red' : 'text-green'" >{{item.humidity}}RH</span>
  91. </el-col>
  92. </el-row>
  93. </div>
  94. <div class="gutter" @click="onOpen(item)">
  95. <el-row>
  96. <el-col :span="14" class="ammonia-line">
  97. <i class="icon_ammonia"></i>
  98. <span class="ammonia_text">氨气:</span>
  99. </el-col>
  100. <el-col :span="10" style="text-align: left;">
  101. <span v-if="item.ammonia === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
  102. <span v-else :class="item.ammonia > 3 ? 'text-red' : 'text-green'" >{{item.ammonia}}mg/m³</span>
  103. </el-col>
  104. </el-row>
  105. </div>
  106. </div>
  107. </template>
  108. </li>
  109. </ul>
  110. </div>
  111. </template>
  112. <script>
  113. let timer, timer1;
  114. export default {
  115. data() {
  116. return {
  117. active: 1,
  118. guideShow: false,
  119. itemPositionInterval: 240, // 定位间隔
  120. data: [],
  121. };
  122. },
  123. created() {},
  124. mounted() {
  125. this.init();
  126. this.setInit();
  127. },
  128. destroyed() {
  129. clearInterval(timer);
  130. clearInterval(timer1);
  131. },
  132. methods: {
  133. toRight() {
  134. let firstItemPositionLift = this.$refs.item0[0].getAttribute("data-position-left");
  135. if (Number(firstItemPositionLift) <= -this.itemPositionInterval) {
  136. this.data.unshift(this.data.pop());
  137. }
  138. },
  139. toLeft() {
  140. let firstItemPositionLift = this.$refs.item0[0].getAttribute("data-position-left");
  141. if (Number(firstItemPositionLift) >= -this.itemPositionInterval) {
  142. this.data.push(this.data.shift());
  143. }
  144. },
  145. setInterval() {
  146. clearInterval(timer)
  147. let that = this;
  148. timer = setInterval(() => {
  149. that.toLeft();
  150. }, 2000);
  151. },
  152. mouseenter(e) {
  153. this.guideShow = true;
  154. clearInterval(timer);
  155. },
  156. mouseleave() {
  157. this.guideShow = false;
  158. this.setInterval()
  159. },
  160. onOpen(item) {
  161. this.$emit('onOpen', item);
  162. },
  163. openItem(item, i) {
  164. this.$emit('openItem', {item: item, index: i});
  165. },
  166. init() {
  167. console.log('++++++++++++++++++++++++++++');
  168. this.$http.get('/environment/getZsda', {mcid: 39})
  169. .then(res => {
  170. // loading.close();
  171. if(res.code === 10000) {
  172. // this.data = res.data;
  173. this.data = [];
  174. let arr1 = [];
  175. let arr2 = [];
  176. res.data.forEach(item => {
  177. if(item.isQuanKong) {
  178. this.$http.post('http://122.112.252.100:8088/allDataController/findByZSID', {ZSID: item.zsid, lqid: item.lqid})
  179. .then(res => {
  180. let slList = [];
  181. let dlList = [];
  182. let phList = [];
  183. let syList = [];
  184. Object.values(res.data.sl).forEach(key => {
  185. slList.push(key);
  186. });
  187. let sl = Math.max(...slList);
  188. Object.values(res.data.dl).forEach(key => {
  189. dlList.push(key);
  190. });
  191. let dl = Math.max(...dlList);
  192. Object.values(res.data.ph).forEach(key => {
  193. phList.push(key);
  194. });
  195. Object.values(res.data.sy).forEach(key => {
  196. syList.push(key);
  197. });
  198. let ph = Math.max(...phList);
  199. let sy = Math.max(...syList);
  200. if(res.data.zsid === item.zsid) {
  201. arr1.push({
  202. sl: sl,
  203. dl: dl,
  204. ph: ph,
  205. sy: sy,
  206. isQk: true,
  207. position: item.zsmc,
  208. lqid: res.data.lqid,
  209. zsid: res.data.zsid,
  210. dlLists: res.data.dl,
  211. phLists: res.data.ph,
  212. slLists: res.data.sl,
  213. syLists: res.data.sy
  214. });
  215. }
  216. this.data = arr1.concat(arr2);
  217. })
  218. } else {
  219. this.$http.get('/environment/getLastEnvByLq', {lqid: item.lqid})
  220. .then(res => {
  221. if(res.data.lqid === item.lqid) {
  222. res.data.position = item.zsmc;
  223. res.data.isQk = false;
  224. }
  225. arr2.push(res.data);
  226. this.data = arr1.concat(arr2);
  227. })
  228. }
  229. });
  230. // 数组排序
  231. this.data.sort(function(a, b){a.lqid - b.lqid});
  232. this.setInterval();
  233. }
  234. })
  235. .catch(err => {
  236. // this.loading = false;
  237. // loading.close();
  238. })
  239. },
  240. setInit() {
  241. let that = this;
  242. timer1 = setInterval(() => {
  243. that.init();
  244. }, 1800000)
  245. }
  246. },
  247. // beforeUpdate() {
  248. // console.log('==========================');
  249. // clearInterval(timer)
  250. // }
  251. };
  252. </script>
  253. <style lang="scss" scope>
  254. .swiperMulti {
  255. box-sizing: border-box;
  256. width: 100%;
  257. height: 100%;
  258. position: relative;
  259. cursor: pointer;
  260. > .guide{
  261. position: absolute;
  262. font-size: 60px;
  263. height: 100%;
  264. display: flex;
  265. align-items: center;
  266. z-index: 1;
  267. background-color: #4441;
  268. &:hover{
  269. background-color: #9991;
  270. }
  271. .icon{
  272. transition: all 1s ease-in-out;
  273. }
  274. }
  275. > .el-toRight {
  276. left: 0;
  277. }
  278. > .el-toLeft {
  279. right: 0;
  280. }
  281. ul {
  282. width: 100%;
  283. height: 100%;
  284. li {
  285. // border: 1px solid rgb(60, 206, 16);
  286. background-color: #0D1943;
  287. width: 220px;
  288. height: 100%;
  289. position: absolute;
  290. transition: all 0.5s ease;
  291. display: flex;
  292. flex-direction: column;
  293. > h3{
  294. text-align: center;
  295. font-size: 1.3rem;
  296. font-weight: normal;
  297. }
  298. > .h3_type_1{
  299. background-color: #207BC4;
  300. }
  301. > .h3_type_2{
  302. background-color: #0E1E51;
  303. }
  304. > .warp {
  305. flex-grow: 1;
  306. // border: 1px solid rgb(221, 218, 16);
  307. .gutter {
  308. padding: 30px 0 20px 0;
  309. text-align: center;
  310. font-size: 22px;
  311. .text-red {
  312. color: #F56C6C;
  313. }
  314. .text-green {
  315. color: #67C23A;
  316. }
  317. .temp-line {
  318. position: relative;
  319. .icon_temp {
  320. display: inline-block;
  321. width: 28px;
  322. height: 28px;
  323. background-image: url("../../assets/icon_T.png");
  324. background-size: 100% 100%;
  325. position: absolute;
  326. top: 0;
  327. left: 15px;
  328. }
  329. .temp_text {
  330. padding-left: 44px;
  331. }
  332. }
  333. .humidity-line {
  334. position: relative;
  335. .icon_humidity {
  336. display: inline-block;
  337. width: 28px;
  338. height: 28px;
  339. background-image: url("../../assets/icon_humidity.png");
  340. background-size: 100% 100%;
  341. position: absolute;
  342. top: 0;
  343. left: 15px;
  344. }
  345. .humidity_text {
  346. padding-left: 44px;
  347. }
  348. }
  349. .ammonia-line {
  350. .icon_ammonia {
  351. display: inline-block;
  352. width: 28px;
  353. height: 28px;
  354. background-image: url("../../assets/icon_meter.png");
  355. background-size: 100% 100%;
  356. position: absolute;
  357. top: 0;
  358. left: 15px;
  359. }
  360. .ammonia_text {
  361. padding-left: 44px;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. </style>