firstmodel.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="container">
  3. <!-- 建议放在外层 -->
  4. <u-navbar
  5. title="设备监测"
  6. @leftClick="devicemenuShow"
  7. :safeAreaInsetTop="false"
  8. >
  9. <view class="u-nav-slot" slot="left">
  10. <u-icon name="list" size="20"> </u-icon>
  11. </view>
  12. </u-navbar>
  13. <view v-show="menushow" class="menupage">
  14. <DeviceMenu @menuClick="menuClick"></DeviceMenu>
  15. </view>
  16. <view v-show="!menushow" class="main">
  17. <view class="u-page">
  18. <u-list>
  19. <u-list-item
  20. class="itemback"
  21. v-for="(item, index) in curlist"
  22. :key="index"
  23. >
  24. <div @tap="openNewPage(item)">
  25. <u-row gutter="5" customStyle="margin-bottom: 10px">
  26. <u-col span="24">
  27. <u--text :text="item.strinstallpos"></u--text>
  28. </u-col>
  29. </u-row>
  30. <u-row gutter="5" customStyle="margin-bottom: 10px">
  31. <u-col span="2" style="margin-right: 15rpx">
  32. <div v-if="item.netStatus == 0" class="error-tag1">
  33. <img
  34. src="'../../../../static/model/connectFalse.svg "
  35. alt=""
  36. class="icon-style"
  37. />
  38. <span style="float: right">断开</span>
  39. </div>
  40. <div v-else class="success-tag">
  41. <img
  42. src="'../../../../static/model/connectTrue.svg "
  43. alt=""
  44. class="icon-style"
  45. />
  46. <span style="float: right">连接</span>
  47. </div>
  48. </u-col>
  49. <u-col span="2">
  50. <div v-if="item.warnFlag == 0" class="success-tag">
  51. <img
  52. src="'../../../../static/model/alarmTrue.svg "
  53. alt=""
  54. class="icon-style"
  55. />
  56. <span style="float: right">{{ item.warnLevel_str }}</span>
  57. </div>
  58. <div v-else class="error-tag">
  59. <img
  60. src="'../../../../static/model/alarmFalse.svg "
  61. alt=""
  62. class="icon-style"
  63. />
  64. <span style="float: right">{{ item.warnLevel_str }}</span>
  65. </div>
  66. </u-col>
  67. <u-col span="3"> </u-col>
  68. <u-col span="5">
  69. <u--text class="timetext" :text="item.readTime"></u--text>
  70. </u-col>
  71. </u-row>
  72. <view v-if="colums[TabCur + '_monitor'] != null">
  73. <view
  74. class="datacard"
  75. v-for="(showitem, index) in colums[TabCur + '_monitor']"
  76. v-show="showitem.appShow == 1"
  77. >
  78. <view
  79. class="content"
  80. :style="{
  81. backgroundImage:
  82. showitem.monitorcode === 'frontRearDP' ||
  83. showitem.monitorcode === 'frontRearDifference'
  84. ? 'url(\'../../../../static/model/Pa.png\')'
  85. : showitem.monitorcode === 'sourcePressure'
  86. ? 'url(\'../../../../static/model/MPa.png\')'
  87. : showitem.monitorcode === 'frontGateOpen'
  88. ? 'url(\'../../../../static/model/doorNet.png\')'
  89. : showitem.monitorcode === 'rearGateOpen'
  90. ? 'url(\'../../../../static/model/doorNet.png\')'
  91. : showitem.monitorcode === 'warnFlag'
  92. ? 'url(\'../../../../static/model/9432.png\')'
  93. : showitem.monitorcode === 'netStatus'
  94. ? 'url(\'../../../../static/model/9431.png\')'
  95. : showitem.monitorcode === 'm3'
  96. ? 'url(\'../../../../static/model/windM3.png\')'
  97. : showitem.monitorcode === 'fsectarea'
  98. ? 'url(\'../../../../static/model/duanArea.png\')'
  99. : showitem.monitorcode === 'incipientWindSpeed1' ||
  100. showitem.monitorcode === 'incipientWindSpeed2' ||
  101. showitem.monitorcode === 'incipientWindSpeed3' ||
  102. showitem.monitorcode === 'va'
  103. ? 'url(\'../../../../static/model/fengsu.png\')'
  104. : 'url(\'\')',
  105. backgroundSize: '100% 100%',
  106. }"
  107. >
  108. <view
  109. v-show="
  110. showitem.monitorcode != 'strinstallpos' &&
  111. showitem.monitorcode != 'netStatus' &&
  112. showitem.monitorcode != 'warnFlag' &&
  113. showitem.monitorcode != 'readTime' &&
  114. showitem.monitorcode != ''
  115. "
  116. >
  117. <view
  118. v-if="showitem.datatype == 1"
  119. class="demo-layout bg-purple-light"
  120. style="margin-top: 10rpx; color: #3787fe"
  121. >{{ item[showitem.monitorcode] }}</view
  122. >
  123. <view
  124. v-if="showitem.datatype == 2"
  125. class="demo-layout bg-purple-light"
  126. style="color: #3787fe"
  127. >{{ item.readData[showitem.monitorcode] }}</view
  128. >
  129. <view
  130. class="demo-layout bg-purple-light"
  131. style="margin-top: 10px; color: #677799"
  132. >{{ showitem.des }}</view
  133. >
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </div>
  139. </u-list-item>
  140. </u-list>
  141. </view>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import DeviceMenu from "./devicemenu/devicemenu.vue";
  147. import api from "@/api/api";
  148. export default {
  149. data() {
  150. return {
  151. menushow: false,
  152. TabCur: "gate",
  153. curlist: [],
  154. deviceList: {},
  155. scrollLeft: 0,
  156. currentTab: 0,
  157. colums: {},
  158. };
  159. },
  160. components: {
  161. DeviceMenu,
  162. },
  163. props: ["showColum"],
  164. watch: {
  165. showColum(data) {
  166. this.colums = data;
  167. console.log(this.colums);
  168. },
  169. },
  170. created() {
  171. this.colums = this.showColum;
  172. },
  173. mounted() {
  174. this.startTimer();
  175. },
  176. methods: {
  177. startTimer() {
  178. // 每隔一段时间执行某个操作
  179. this.timer = setInterval(() => {
  180. // 执行定时任务
  181. this.loadData(this.TabCur);
  182. console.log("定时任务执行中...");
  183. }, 5000);
  184. },
  185. stopTimer() {
  186. // 停止定时器
  187. clearInterval(this.timer);
  188. },
  189. loadData(type) {
  190. new Promise((resolve, reject) => {
  191. api
  192. .getDeviceMonitor({
  193. devicetype: type,
  194. pagetype: "normal",
  195. filterParams: {},
  196. })
  197. .then((response) => {
  198. if (response.data.code == 200) {
  199. this.deviceList[type] = response.data.result.msgTxt[0].datalist;
  200. this.curlist = this.deviceList[type];
  201. this.curlist.forEach((item) => {
  202. if (item.readData.frontGateOpen == 1) {
  203. item.readData.frontGateOpen = "打开";
  204. } else {
  205. item.readData.frontGateOpen = "关闭";
  206. }
  207. if (item.readData.rearGateOpen == 1) {
  208. item.readData.rearGateOpen = "打开";
  209. } else {
  210. item.readData.rearGateOpen = "关闭";
  211. }
  212. });
  213. } else {
  214. resolve(response);
  215. }
  216. })
  217. .catch((error) => {
  218. console.log("catch===>response", response);
  219. reject(error);
  220. });
  221. });
  222. },
  223. tabSelect(e) {
  224. this.currentTab = e.currentTarget.dataset.id;
  225. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  226. },
  227. devicemenuShow(e) {
  228. this.menushow = true;
  229. },
  230. menuClick(id) {
  231. this.TabCur = id;
  232. // 显示该分类的数据
  233. this.curlist = this.deviceList[this.TabCur];
  234. if (this.curlist == null) {
  235. this.curlist = [];
  236. }
  237. // 选择设备分类,重新获取数据
  238. this.loadData(this.TabCur);
  239. this.menushow = false;
  240. },
  241. openNewPage(params) {
  242. this.$destroy();
  243. uni.navigateTo({
  244. url: `/pages/home/detail/autodoor/autodoor?id=${params.deviceID}&name=${params.strinstallpos}&type=${this.TabCur}`,
  245. });
  246. },
  247. },
  248. destroyed() {
  249. // 停止定时器
  250. this.stopTimer();
  251. },
  252. };
  253. </script>
  254. <style>
  255. .top-nav {
  256. height: 100rpx;
  257. line-height: 100rpx;
  258. background-color: #2aa9f3;
  259. color: #daaaa;
  260. }
  261. .top-nav2 {
  262. background-color: #ffffff;
  263. }
  264. .main {
  265. margin-top: 100rpx;
  266. display: flex;
  267. flex-direction: column;
  268. }
  269. .card {
  270. background-color: #ffffff;
  271. margin: auto;
  272. margin-top: 20rpx;
  273. width: 90%;
  274. height: 280rpx;
  275. border: 1rpx solid #000000;
  276. border-radius: 20rpx;
  277. }
  278. .menupage {
  279. position: absolute;
  280. z-index: 2;
  281. top: 40rpx;
  282. height: calc(100% - 40rpx);
  283. width: 100%;
  284. }
  285. .timetext {
  286. text-align: right;
  287. float: right;
  288. }
  289. .itemback {
  290. padding: 20rpx;
  291. background-color: #ffffff;
  292. margin-bottom: 5rpx;
  293. }
  294. .datacard {
  295. width: 30%;
  296. margin: 1%;
  297. float: left;
  298. height: 100rpx;
  299. text-align: center;
  300. background: linear-gradient(
  301. to right,
  302. rgba(55, 135, 254, 0.08),
  303. rgba(4, 184, 255, 0.08),
  304. rgba(60, 161, 237, 0.08)
  305. );
  306. }
  307. .error-tag {
  308. border-radius: 10%;
  309. display: inline-block;
  310. color: #e90000;
  311. line-height: 50rpx;
  312. font-size: 14px;
  313. text-align: center;
  314. width: 120rpx;
  315. height: 50rpx;
  316. background-color: rgba(233, 0, 0, 0.2);
  317. }
  318. .error-tag1 {
  319. border-radius: 10%;
  320. display: inline-block;
  321. color: #696969;
  322. line-height: 50rpx;
  323. font-size: 14px;
  324. text-align: center;
  325. width: 120rpx;
  326. height: 50rpx;
  327. background-color: rgba(105, 105, 105, 0.2);
  328. }
  329. .success-tag {
  330. border-radius: 10%;
  331. color: #42c000;
  332. line-height: 50rpx;
  333. font-size: 14px;
  334. width: 120rpx;
  335. height: 50rpx;
  336. display: inline-block;
  337. background-color: rgba(226, 250, 214);
  338. }
  339. .icon-style {
  340. margin: 15rpx;
  341. width: 14px;
  342. height: 14px;
  343. }
  344. </style>