firstmodel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. <img
  28. style="position: absolute; width: 35rpx; height: 35rpx"
  29. class="icon"
  30. :src="getIcon(TabCur)"
  31. alt="Icon"
  32. />
  33. <span class="title">{{ item.strinstallpos }}</span>
  34. </u-col>
  35. </u-row>
  36. <u-row gutter="5" customStyle="margin-bottom: 10px">
  37. <u-col span="3" style="margin-right: 5rpx">
  38. <div v-if="item.netStatus == 0" class="error-tag1">
  39. <img
  40. src="'../../../../static/model/connectFalse.svg "
  41. alt=""
  42. class="icon-style"
  43. />
  44. <span style="float: right">断开</span>
  45. </div>
  46. <div v-else class="success-tag">
  47. <img
  48. src="'../../../../static/model/connectTrue.svg "
  49. alt=""
  50. class="icon-style"
  51. />
  52. <span style="float: right">连接</span>
  53. </div>
  54. </u-col>
  55. <u-col span="4">
  56. <div v-if="item.warnFlag == 0" class="success-tag">
  57. <img
  58. src="'../../../../static/model/alarmTrue.svg "
  59. alt=""
  60. class="icon-style"
  61. />
  62. <span style="float: right">{{ item.warnLevel_str }}</span>
  63. </div>
  64. <div v-else class="error-tag">
  65. <img
  66. src="'../../../../static/model/alarmFalse.svg "
  67. alt=""
  68. class="icon-style"
  69. />
  70. <span style="float: right">{{ item.warnDes }}</span>
  71. </div>
  72. </u-col>
  73. <u-col span="5">
  74. <u--text class="timetext" :text="item.readTime"></u--text>
  75. </u-col>
  76. </u-row>
  77. <view v-if="colums[TabCur + '_monitor'] != null">
  78. <view
  79. class="datacard"
  80. v-for="(showitem, index) in colums[TabCur + '_monitor']"
  81. :key="index"
  82. v-show="
  83. showitem.appShow == 1 &&
  84. showitem.monitorcode != 'strinstallpos' &&
  85. showitem.monitorcode != 'netStatus' &&
  86. showitem.monitorcode != 'warnFlag' &&
  87. showitem.monitorcode != 'readTime' &&
  88. showitem.monitorcode != ''
  89. "
  90. >
  91. <view
  92. :class="TabCur"
  93. style="padding-top: 10rpx; padding-bottom: 10rpx"
  94. >
  95. <view
  96. v-if="
  97. showitem.datatype == 1 &&
  98. showitem.monitorcode == 'doorUse'
  99. "
  100. class="demo-layout bg-purple-light"
  101. style="
  102. margin-top: 10rpx;
  103. color: #3787fe;
  104. font-size: 30rpx;
  105. margin-top: 5rpx;
  106. "
  107. >
  108. {{
  109. item[showitem.monitorcode] == "2"
  110. ? "行人"
  111. : item[showitem.monitorcode] == "1"
  112. ? "行车"
  113. : "-"
  114. }}
  115. </view>
  116. <view
  117. v-else-if="showitem.datatype == 1"
  118. class="demo-layout bg-purple-light"
  119. style="
  120. margin-top: 10rpx;
  121. color: #3787fe;
  122. font-size: 30rpx;
  123. margin-top: 5rpx;
  124. "
  125. >
  126. {{
  127. item[showitem.monitorcode] == null ||
  128. item[showitem.monitorcode] == ""
  129. ? "-"
  130. : item[showitem.monitorcode]
  131. }}
  132. </view>
  133. <view
  134. v-else-if="showitem.datatype == 2"
  135. class="demo-layout bg-purple-light"
  136. style="color: #3787fe; font-size: 30rpx; margin-top: 5rpx"
  137. >
  138. {{
  139. item.readData[showitem.monitorcode] == null ||
  140. item.readData[showitem.monitorcode] == ""
  141. ? "-"
  142. : item.readData[showitem.monitorcode]
  143. }}
  144. </view>
  145. <view
  146. class="demo-layout bg-purple-light"
  147. style="
  148. margin-top: 6rpx;
  149. color: #677799;
  150. margin-bottom: 5rpx;
  151. "
  152. >
  153. {{ showitem.des }}
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </div>
  159. </u-list-item>
  160. </u-list>
  161. </view>
  162. </view>
  163. </view>
  164. </template>
  165. <script>
  166. import DeviceMenu from "./devicemenu/devicemenu.vue";
  167. import api from "@/api/api";
  168. export default {
  169. data() {
  170. return {
  171. menushow: false,
  172. TabCur: "gate",
  173. curlist: [],
  174. deviceList: {},
  175. scrollLeft: 0,
  176. currentTab: 0,
  177. colums: {},
  178. };
  179. },
  180. components: {
  181. DeviceMenu,
  182. },
  183. props: ["showColum"],
  184. watch: {
  185. showColum(data) {
  186. this.colums = data;
  187. console.log(this.colums);
  188. },
  189. },
  190. created() {
  191. this.colums = this.showColum;
  192. },
  193. mounted() {
  194. this.startTimer();
  195. },
  196. methods: {
  197. startTimer() {
  198. // 每隔一段时间执行某个操作
  199. this.timer = setInterval(() => {
  200. // 执行定时任务
  201. this.loadData(this.TabCur);
  202. console.log("定时任务执行中...");
  203. }, 5000);
  204. },
  205. stopTimer() {
  206. // 停止定时器
  207. clearInterval(this.timer);
  208. },
  209. getIcon(itemValue) {
  210. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  211. return "/static/sidebar/" + itemValue + ".svg";
  212. },
  213. getValueIcon(itemValue) {
  214. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  215. return "/static/sidebar/" + itemValue + ".svg";
  216. },
  217. loadData(type) {
  218. new Promise((resolve, reject) => {
  219. api
  220. .getDeviceMonitor({
  221. devicetype: type,
  222. pagetype: "normal",
  223. filterParams: {},
  224. })
  225. .then((response) => {
  226. if (response.data.code == 200) {
  227. this.deviceList[type] = response.data.result.msgTxt[0].datalist;
  228. this.curlist = this.deviceList[type];
  229. this.curlist.forEach((item) => {
  230. if (item.readData.frontGateOpen == 1) {
  231. item.readData.frontGateOpen = "打开";
  232. } else {
  233. item.readData.frontGateOpen = "关闭";
  234. }
  235. if (item.readData.midGateOpen == 1) {
  236. item.readData.midGateOpen = "打开";
  237. } else {
  238. item.readData.midGateOpen = "关闭";
  239. }
  240. if (item.readData.rearGateOpen == 1) {
  241. item.readData.rearGateOpen = "打开";
  242. } else {
  243. item.readData.rearGateOpen = "关闭";
  244. }
  245. if (item.readData.midGateOpen == 1) {
  246. item.readData.midGateOpen = "打开";
  247. } else {
  248. item.readData.midGateOpen = "关闭";
  249. }
  250. });
  251. } else {
  252. resolve(response);
  253. }
  254. })
  255. .catch((error) => {
  256. console.log("catch===>response", response);
  257. reject(error);
  258. });
  259. });
  260. },
  261. tabSelect(e) {
  262. this.currentTab = e.currentTarget.dataset.id;
  263. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  264. },
  265. devicemenuShow(e) {
  266. this.menushow = !this.menushow;
  267. },
  268. menuClick(id) {
  269. this.TabCur = id;
  270. // 显示该分类的数据
  271. this.curlist = this.deviceList[this.TabCur];
  272. if (this.curlist == null) {
  273. this.curlist = [];
  274. }
  275. // 选择设备分类,重新获取数据
  276. this.loadData(this.TabCur);
  277. this.menushow = false;
  278. },
  279. openNewPage(params) {
  280. this.$destroy();
  281. uni.navigateTo({
  282. url: `/pages/home/detail/autodoor/autodoor?id=${params.deviceID}&name=${params.strinstallpos}&type=${this.TabCur}`,
  283. });
  284. },
  285. },
  286. destroyed() {
  287. // 停止定时器
  288. this.stopTimer();
  289. },
  290. };
  291. </script>
  292. <style>
  293. .top-nav {
  294. height: 100rpx;
  295. line-height: 100rpx;
  296. background-color: #2aa9f3;
  297. color: #daaaa;
  298. }
  299. .top-nav2 {
  300. background-color: #ffffff;
  301. }
  302. .main {
  303. margin-top: 100rpx;
  304. display: flex;
  305. flex-direction: column;
  306. }
  307. .card {
  308. background-color: #ffffff;
  309. margin: auto;
  310. margin-top: 20rpx;
  311. width: 10%;
  312. height: 280rpx;
  313. border: 1rpx solid #000000;
  314. border-radius: 20rpx;
  315. }
  316. .menupage {
  317. position: absolute;
  318. z-index: 2;
  319. top: 40rpx;
  320. height: calc(100% - 40rpx);
  321. width: 100%;
  322. }
  323. .timetext {
  324. text-align: right;
  325. float: right;
  326. }
  327. .itemback {
  328. padding: 20rpx;
  329. background-color: #ffffff;
  330. margin-bottom: 5rpx;
  331. }
  332. .datacard .content {
  333. width: 30rpx;
  334. height: 30rpx;
  335. left: 0rpx;
  336. top: 0rpx;
  337. position: absolute;
  338. }
  339. .datacard {
  340. border-radius: 10rpx;
  341. border: rgba(55, 135, 254, 0.28);
  342. width: 30%;
  343. margin: 1%;
  344. float: left;
  345. height: 105rpx;
  346. text-align: center;
  347. background: linear-gradient(
  348. to right,
  349. rgba(55, 135, 254, 0.08),
  350. rgba(4, 184, 255, 0.08),
  351. rgba(60, 161, 237, 0.08)
  352. );
  353. }
  354. .datacard .gate {
  355. background: linear-gradient(
  356. to right,
  357. rgba(75, 135, 254, 0.08),
  358. rgba(24, 184, 255, 0.08),
  359. rgba(80, 161, 237, 0.08)
  360. );
  361. }
  362. .datacard .window {
  363. background: linear-gradient(
  364. to right,
  365. rgba(55, 125, 254, 0.08),
  366. rgba(4, 164, 255, 0.08),
  367. rgba(60, 131, 237, 0.08)
  368. );
  369. }
  370. .datacard .windrect {
  371. background: linear-gradient(
  372. to right,
  373. rgba(85, 125, 254, 0.08),
  374. rgba(34, 164, 255, 0.08),
  375. rgba(90, 131, 237, 0.08)
  376. );
  377. }
  378. .error-tag {
  379. border-radius: 10%;
  380. display: inline-block;
  381. color: #e90000;
  382. line-height: 50rpx;
  383. font-size: 14px;
  384. text-align: center;
  385. float: left;
  386. width: 180rpx;
  387. height: 50rpx;
  388. padding-right: 30rpx;
  389. background-color: rgba(233, 0, 0, 0.2);
  390. }
  391. .error-tag1 {
  392. border-radius: 10%;
  393. display: inline-block;
  394. color: #696969;
  395. line-height: 50rpx;
  396. font-size: 14px;
  397. text-align: center;
  398. margin-top: 10rpx;
  399. float: left;
  400. width: 120rpx;
  401. height: 50rpx;
  402. background-color: rgba(105, 105, 105, 0.2);
  403. }
  404. .success-tag {
  405. border-radius: 10%;
  406. color: #42c000;
  407. line-height: 50rpx;
  408. font-size: 14px;
  409. width: 120rpx;
  410. height: 50rpx;
  411. padding-right: 30rpx;
  412. background-color: rgba(226, 250, 214);
  413. }
  414. .icon-style {
  415. margin: 15rpx;
  416. width: 14px;
  417. height: 14px;
  418. }
  419. .title {
  420. margin-left: 40rpx;
  421. float: left;
  422. font-size: 28rpx;
  423. font-weight: 400;
  424. }
  425. </style>