firstmodel.vue 11 KB

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