firstmodel.vue 12 KB

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