firstmodel.vue 9.5 KB

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