firstmodel.vue 9.7 KB

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