Qxz.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div
  3. class="qxz screen-content-box"
  4. v-loading="loading"
  5. element-loading-text="加载中"
  6. element-loading-spinner="el-icon-loading"
  7. element-loading-background="rgba(0, 0, 0, 0.6)"
  8. >
  9. <p class="title">
  10. 气象监测
  11. <el-select
  12. style="width: 125px; float: right"
  13. v-model="selId"
  14. size="mini"
  15. filterable
  16. popper-class="deviceDevNew_faultSelect"
  17. @change="baseChange"
  18. >
  19. <el-option
  20. v-for="device in equipList"
  21. :key="device.equip_id"
  22. :label="device.equip_name"
  23. :value="device.equip_id"
  24. ></el-option>
  25. </el-select>
  26. </p>
  27. <div class="screen-container">
  28. <!-- <vue-seamless-scroll :data="equipStatus" class="scrollwarp" :class-option="optionHover"> -->
  29. <div class="status-box" v-for="(item, index) in equipStatus" :key="index">
  30. <div class="status-item" v-for="(base, j) in item" :key="j">
  31. <img class="float-left" :src="require('../assets/' + base.num + '.svg')" alt="" />
  32. <p class="clearfix">
  33. <span class="text float-left">{{ base.name }}</span>
  34. <span class="num float-right"
  35. >{{ base.value }}
  36. <span class="unit">{{ base.unit }}</span>
  37. </span>
  38. </p>
  39. </div>
  40. </div>
  41. <!-- </vue-seamless-scroll> -->
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. props: {
  48. height: {
  49. type: Number,
  50. default: 200
  51. }
  52. },
  53. data() {
  54. return {
  55. selId: '',
  56. equipList: [],
  57. equipStatus: [],
  58. loading: false
  59. }
  60. },
  61. computed: {
  62. optionHover() {
  63. return {
  64. step: 0.4, // 数值越大速度滚动越快
  65. // limitMoveNum: 2, // 开始无缝滚动的数据量 this.dataList.length
  66. limitMoveNum: this.equipStatus.length > 3 ? 3 : this.equipStatus.length,
  67. hoverStop: true, // 是否开启鼠标悬停stop
  68. direction: 1, // 0向下 1向上 2向左 3向右
  69. openWatch: true, // 开启数据实时监控刷新dom
  70. singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
  71. singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
  72. waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
  73. }
  74. },
  75. len() {
  76. return Math.ceil(this.equipStatus.length / 2)
  77. },
  78. emptyStyle() {
  79. return {
  80. height: this.height + 'px'
  81. }
  82. }
  83. },
  84. created() {},
  85. mounted() {
  86. this.getList()
  87. },
  88. watch: {},
  89. methods: {
  90. baseChange() {
  91. this.getDeviceConfig()
  92. },
  93. formateArray(row, col, array) {
  94. let newArray = []
  95. for (let i = 0; i < row; i++) {
  96. let temp = []
  97. for (let j = 0; j < col; j++) {
  98. if (i * col + j >= array.length) {
  99. break
  100. }
  101. temp.push(array[i * col + j])
  102. }
  103. newArray.push(temp)
  104. }
  105. return newArray
  106. },
  107. // 获取列表
  108. getList() {
  109. this.$axios({
  110. method: 'POST',
  111. url: '/api/api_gateway?method=weather.weather.qxz_page',
  112. data: this.qs.stringify({
  113. page: 1
  114. })
  115. }).then((res) => {
  116. if (res.data.message == '') {
  117. const equipList = res.data.data.ids
  118. this.equipList = equipList
  119. if (equipList.length > 0) {
  120. this.selId = equipList[0].equip_id
  121. // const listItem = equipList.filter((item) => item.equip_id === '860048073313361')
  122. this.getDeviceConfig()
  123. }
  124. }
  125. })
  126. },
  127. getDeviceConfig() {
  128. this.loading = true
  129. this.$axios({
  130. method: 'POST',
  131. url: '/api/api_gateway?method=weather.weather.qxz_status',
  132. data: this.qs.stringify({
  133. device_id: this.selId
  134. })
  135. })
  136. .then((res) => {
  137. this.loading = false
  138. if (res.data.message === '') {
  139. const { dat, conf } = res.data.data
  140. // console.log(dat, conf, 'resent, compare')
  141. let recent = []
  142. Object.keys(conf).forEach((key) => {
  143. if (conf[key]) {
  144. let item = conf[key].split('#')
  145. let val = dat[key].split('#')
  146. recent.push({
  147. num: val[1],
  148. value: val[0] || '--',
  149. unit: item[1],
  150. name: item[0]
  151. })
  152. }
  153. })
  154. this.equipStatus = this.formateArray(Math.ceil(recent.length / 2), 2, recent)
  155. } else {
  156. this.$message.error(res.data.message)
  157. }
  158. })
  159. .catch((err) => {
  160. this.loading = false
  161. console.log(err)
  162. })
  163. }
  164. },
  165. components: {}
  166. }
  167. </script>
  168. <style scoped lang="less">
  169. .screen-content-box {
  170. border-radius: 4px;
  171. height: 100%;
  172. width: 440px;
  173. .title {
  174. img {
  175. }
  176. padding-left: 60px;
  177. box-sizing: border-box;
  178. height: 40px;
  179. line-height: 40px;
  180. background-image: url('../assets/title-bg.png');
  181. font-size: 18px;
  182. color: #ffffff;
  183. /deep/ .el-input {
  184. .el-input__inner {
  185. border: 1px solid rgba(0, 133, 255, 0.6);
  186. background: rgba(0, 133, 255, 0.3);
  187. color: #fff;
  188. }
  189. }
  190. /deep/ .el-input.is-focus .el-input__inner,
  191. /deep/ .el-textarea__inner:focus,
  192. /deep/ .el-input__inner:focus {
  193. border-color: rgba(0, 133, 255, 0.6) !important;
  194. }
  195. }
  196. .screen-container {
  197. height: calc(100% - 40px);
  198. background: rgba(0, 0, 0, 0.32);
  199. padding: 16px 14px;
  200. box-sizing: border-box;
  201. width: 100%;
  202. backdrop-filter: blur(8.8px);
  203. color: #fff;
  204. overflow: hidden;
  205. }
  206. }
  207. .status-box {
  208. width: 100%;
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. box-sizing: border-box;
  213. // padding: 0 16px;
  214. flex-wrap: wrap;
  215. // animation: vertical-scroll 8s linear infinite;
  216. .status-item {
  217. width: 50%;
  218. height: 35px;
  219. // background-image: url('../assets/qx-bg.png');
  220. background-size: auto 100%;
  221. background-repeat: no-repeat;
  222. display: flex;
  223. align-items: center;
  224. justify-content: space-between;
  225. margin-bottom: 14px;
  226. p {
  227. flex: 1;
  228. padding: 0 4px;
  229. height: 35px;
  230. line-height: 35px;
  231. border-radius: 1.81px;
  232. border: 0.45px solid #1671f8;
  233. }
  234. img {
  235. width: 56px;
  236. height: 41px;
  237. vertical-align: middle;
  238. // margin: 0 8px 0 8px;
  239. }
  240. span {
  241. color: #fff;
  242. font-size: 14px;
  243. vertical-align: middle;
  244. }
  245. .unit {
  246. font-size: 12px;
  247. color: #d0deee;
  248. }
  249. .text {
  250. font-size: 14px;
  251. color: rgba(255, 255, 255);
  252. }
  253. .num {
  254. font-size: 16px;
  255. color: #d0deee;
  256. font-weight: bold;
  257. // line-height: 23px;
  258. }
  259. }
  260. &:hover {
  261. animation-play-state: paused;
  262. }
  263. }
  264. @keyframes vertical-scroll {
  265. 0% {
  266. transform: translateY(0);
  267. }
  268. 100% {
  269. transform: translateY(-100%);
  270. }
  271. }
  272. </style>