home.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <template>
  2. <view class="container">
  3. <view v-if="!menushow" class="main">
  4. <view class="u-page">
  5. <u-list :class="{ empty: curlist.length === 0 }">
  6. <template v-if="curlist.length > 0">
  7. <u-list-item
  8. class="itemback"
  9. v-for="(item, index) in curlist"
  10. :key="index"
  11. >
  12. <div @tap="openNewPage(item)">
  13. <u-row gutter="5" customStyle="margin-bottom: 10px">
  14. <u-col span="24">
  15. <image
  16. style="position: absolute; width: 18px; height: 18px"
  17. class="icon"
  18. :src="getIcon(TabCur)"
  19. alt="Icon"
  20. />
  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. <image
  28. src="/static/model/connectFalse.svg"
  29. alt=""
  30. class="icon-style"
  31. />
  32. <span style="float: right">断开</span>
  33. </div>
  34. <div v-else class="success-tag">
  35. <image
  36. src="/static/model/connectTrue.svg"
  37. alt=""
  38. class="icon-style"
  39. />
  40. <span style="float: right">连接</span>
  41. </div>
  42. </u-col>
  43. <u-col span="6">
  44. <div v-if="item.warnFlag == 0" class="success-tag">
  45. <image
  46. src="/static/model/alarmTrue.svg"
  47. alt=""
  48. class="icon-style"
  49. />
  50. <span style="float: right">正常</span>
  51. </div>
  52. <div v-else class="error-tag">
  53. <image
  54. src="/static/model/alarmFalse.svg"
  55. alt=""
  56. class="icon-style"
  57. />
  58. <span style="float: right; text-overflow: ellipsis">{{
  59. item.warnDes
  60. }}</span>
  61. </div>
  62. </u-col>
  63. <u-col span="3">
  64. <u--text class="timetext" :text="item.readTime"></u--text>
  65. </u-col>
  66. </u-row>
  67. <view v-if="TabCur != 'fanmain' && TabCur != 'fanlocal'">
  68. <view
  69. class="datacard"
  70. v-for="(showitem, index) in deviceShowList"
  71. :key="index"
  72. v-show="
  73. showitem.appShow == 1 &&
  74. showitem.monitorcode != 'strinstallpos' &&
  75. showitem.monitorcode != 'netStatus' &&
  76. showitem.monitorcode != 'warnFlag' &&
  77. showitem.monitorcode != 'readTime' &&
  78. showitem.monitorcode != ''
  79. "
  80. >
  81. <view
  82. :class="TabCur"
  83. style="
  84. padding-top: 10rpx;
  85. padding-bottom: 10rpx;
  86. display: flex;
  87. flex-direction: column;
  88. align-items: center;
  89. height: 100%;
  90. "
  91. >
  92. <view
  93. v-if="
  94. showitem.datatype == 1 &&
  95. showitem.monitorcode == 'doorUse'
  96. "
  97. class="demo-layout bg-purple-light"
  98. style="
  99. margin-top: 10rpx;
  100. color: #3787fe;
  101. font-size: 30rpx;
  102. margin-top: 20rpx;
  103. "
  104. >
  105. {{
  106. item[showitem.monitorcode] == "2"
  107. ? "行人"
  108. : item[showitem.monitorcode] == "1"
  109. ? "行车"
  110. : "-"
  111. }}
  112. </view>
  113. <view
  114. v-else-if="showitem.datatype == 1"
  115. class="demo-layout bg-purple-light"
  116. style="
  117. margin-top: 10rpx;
  118. color: #3787fe;
  119. font-size: 30rpx;
  120. margin-top: 20rpx;
  121. "
  122. >
  123. {{
  124. item[showitem.monitorcode] == null ||
  125. item[showitem.monitorcode] == ""
  126. ? "-"
  127. : item[showitem.monitorcode]
  128. }}
  129. </view>
  130. <view
  131. v-else-if="showitem.datatype == 2"
  132. class="demo-layout bg-purple-light"
  133. style="
  134. color: #3787fe;
  135. font-size: 30rpx;
  136. margin-top: 20rpx;
  137. "
  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: 20rpx;
  150. color: #677799;
  151. margin-top: 20rpx;
  152. "
  153. >
  154. {{ showitem.des }}
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. <div class="fanContent" v-else>
  160. <div class="top">
  161. <view>主机</view>
  162. <view
  163. class="datacard"
  164. v-for="(showitem, index) in deviceShowList"
  165. :key="index"
  166. v-show="
  167. showitem.appShow == 1 &&
  168. showitem.monitorcode != 'strinstallpos' &&
  169. showitem.monitorcode != 'netStatus' &&
  170. showitem.monitorcode != 'warnFlag' &&
  171. showitem.monitorcode != 'readTime' &&
  172. showitem.monitorcode != ''
  173. "
  174. >
  175. <view
  176. :class="TabCur"
  177. style="
  178. padding-top: 10rpx;
  179. padding-bottom: 10rpx;
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. height: 100%;
  184. "
  185. >
  186. <view
  187. v-if="
  188. showitem.datatype == 1 &&
  189. showitem.monitorcode == 'doorUse'
  190. "
  191. class="demo-layout bg-purple-light"
  192. style="
  193. margin-top: 10rpx;
  194. color: #3787fe;
  195. font-size: 30rpx;
  196. margin-top: 20rpx;
  197. "
  198. >
  199. {{
  200. item[showitem.monitorcode] == "2"
  201. ? "行人"
  202. : item[showitem.monitorcode] == "1"
  203. ? "行车"
  204. : "-"
  205. }}
  206. </view>
  207. <view
  208. v-else-if="showitem.datatype == 1"
  209. class="demo-layout bg-purple-light"
  210. style="
  211. margin-top: 10rpx;
  212. color: #3787fe;
  213. font-size: 30rpx;
  214. margin-top: 20rpx;
  215. "
  216. >
  217. {{
  218. item[
  219. showitem.monitorcode.startsWith("Fan")
  220. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  221. : showitem.monitorcode
  222. ] !== undefined &&
  223. item[
  224. showitem.monitorcode.startsWith("Fan")
  225. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  226. : showitem.monitorcode
  227. ] !== null
  228. ? item[
  229. showitem.monitorcode.startsWith("Fan")
  230. ? showitem.monitorcode.replace(
  231. /^Fan/,
  232. "Fan1"
  233. )
  234. : showitem.monitorcode
  235. ]
  236. : "-"
  237. }}
  238. </view>
  239. <view
  240. v-else-if="showitem.datatype == 2"
  241. class="demo-layout bg-purple-light"
  242. style="
  243. color: #3787fe;
  244. font-size: 30rpx;
  245. margin-top: 20rpx;
  246. "
  247. >
  248. {{
  249. item.readData[
  250. showitem.monitorcode.startsWith("Fan")
  251. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  252. : showitem.monitorcode
  253. ] !== undefined &&
  254. item.readData[
  255. showitem.monitorcode.startsWith("Fan")
  256. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  257. : showitem.monitorcode
  258. ] !== null
  259. ? item.readData[
  260. showitem.monitorcode.startsWith("Fan")
  261. ? showitem.monitorcode.replace(
  262. /^Fan/,
  263. "Fan1"
  264. )
  265. : showitem.monitorcode
  266. ]
  267. : "-"
  268. }}
  269. </view>
  270. <view
  271. class="demo-layout bg-purple-light"
  272. style="
  273. margin-top: 20rpx;
  274. color: #677799;
  275. margin-top: 20rpx;
  276. "
  277. >
  278. {{ showitem.des }}
  279. </view>
  280. </view>
  281. </view>
  282. </div>
  283. <div class="bottom">
  284. <view>备机</view>
  285. <view
  286. class="datacard"
  287. v-for="(showitem, index) in deviceShowList"
  288. :key="index"
  289. v-show="
  290. showitem.appShow == 1 &&
  291. showitem.monitorcode != 'strinstallpos' &&
  292. showitem.monitorcode != 'netStatus' &&
  293. showitem.monitorcode != 'warnFlag' &&
  294. showitem.monitorcode != 'readTime' &&
  295. showitem.monitorcode != ''
  296. "
  297. >
  298. <view
  299. :class="TabCur"
  300. style="
  301. padding-top: 10rpx;
  302. padding-bottom: 10rpx;
  303. display: flex;
  304. flex-direction: column;
  305. align-items: center;
  306. height: 100%;
  307. "
  308. >
  309. <view
  310. v-if="
  311. showitem.datatype == 1 &&
  312. showitem.monitorcode == 'doorUse'
  313. "
  314. class="demo-layout bg-purple-light"
  315. style="
  316. margin-top: 10rpx;
  317. color: #3787fe;
  318. font-size: 30rpx;
  319. margin-top: 20rpx;
  320. "
  321. >
  322. {{
  323. item[showitem.monitorcode] == "2"
  324. ? "行人"
  325. : item[showitem.monitorcode] == "1"
  326. ? "行车"
  327. : "-"
  328. }}
  329. </view>
  330. <view
  331. v-else-if="showitem.datatype == 1"
  332. class="demo-layout bg-purple-light"
  333. style="
  334. margin-top: 10rpx;
  335. color: #3787fe;
  336. font-size: 30rpx;
  337. margin-top: 20rpx;
  338. "
  339. >
  340. {{
  341. item[
  342. showitem.monitorcode.startsWith("Fan")
  343. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  344. : showitem.monitorcode
  345. ] !== undefined &&
  346. item[
  347. showitem.monitorcode.startsWith("Fan")
  348. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  349. : showitem.monitorcode
  350. ] !== null
  351. ? item[
  352. showitem.monitorcode.startsWith("Fan")
  353. ? showitem.monitorcode.replace(
  354. /^Fan/,
  355. "Fan2"
  356. )
  357. : showitem.monitorcode
  358. ]
  359. : "-"
  360. }}
  361. </view>
  362. <view
  363. v-else-if="showitem.datatype == 2"
  364. class="demo-layout bg-purple-light"
  365. style="
  366. color: #3787fe;
  367. font-size: 30rpx;
  368. margin-top: 20rpx;
  369. "
  370. >
  371. {{
  372. item.readData[
  373. showitem.monitorcode.startsWith("Fan")
  374. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  375. : showitem.monitorcode
  376. ] !== undefined &&
  377. item.readData[
  378. showitem.monitorcode.startsWith("Fan")
  379. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  380. : showitem.monitorcode
  381. ] !== null
  382. ? item.readData[
  383. showitem.monitorcode.startsWith("Fan")
  384. ? showitem.monitorcode.replace(
  385. /^Fan/,
  386. "Fan2"
  387. )
  388. : showitem.monitorcode
  389. ]
  390. : "-"
  391. }}
  392. </view>
  393. <view
  394. class="demo-layout bg-purple-light"
  395. style="
  396. margin-top: 20rpx;
  397. color: #677799;
  398. margin-top: 20rpx;
  399. "
  400. >
  401. {{ showitem.des }}
  402. </view>
  403. </view>
  404. </view>
  405. </div>
  406. </div>
  407. </div>
  408. </u-list-item>
  409. </template>
  410. <template v-else>
  411. <div class="empty-message">数据为空</div>
  412. </template>
  413. </u-list>
  414. </view>
  415. </view>
  416. </view>
  417. </template>
  418. <script>
  419. import api from "@/api/api";
  420. import { computed } from "vue";
  421. export default {
  422. data() {
  423. return {
  424. menushow: false,
  425. TabCur: "gate",
  426. curlist: [],
  427. deviceList: {},
  428. colums: {},
  429. typeList: [], //详情页展示数据
  430. deviceShowList: [], //设备展示字段
  431. };
  432. },
  433. props: ["showColum", "deviceType"],
  434. watch: {
  435. showColum(data) {
  436. this.colums = data;
  437. },
  438. deviceType: {
  439. async handler(data) {
  440. if (data) {
  441. this.TabCur = data;
  442. this.curlist = this.deviceList[this.TabCur];
  443. if (this.curlist == null) {
  444. this.curlist = [];
  445. }
  446. // 选择设备分类,重新获取数据
  447. await this.loadData(this.TabCur);
  448. this.$emit("setMenushow", {
  449. menushow: false,
  450. });
  451. }
  452. },
  453. immediate: true,
  454. },
  455. },
  456. created() {
  457. this.colums = this.showColum;
  458. const key = this.TabCur + "_monitor";
  459. this.deviceShowList = this.colums[key];
  460. },
  461. async mounted() {
  462. await this.loadData(this.TabCur);
  463. this.startTimer();
  464. },
  465. methods: {
  466. startTimer() {
  467. // 每隔一段时间执行某个操作
  468. this.timer = setInterval(async () => {
  469. // 执行定时任务
  470. await this.loadData(this.deviceType);
  471. console.log("定时任务执行中...");
  472. }, 5000);
  473. },
  474. stopTimer() {
  475. // 停止定时器
  476. clearInterval(this.timer);
  477. },
  478. getIcon(itemValue) {
  479. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  480. return "/static/sidebar/" + itemValue + ".svg";
  481. },
  482. getValueIcon(itemValue) {
  483. // 根据itemValue获取对应的图标路径,如果找不到对应关系则返回默认图标
  484. return "/static/sidebar/" + itemValue + ".svg";
  485. },
  486. loadData(type) {
  487. return new Promise((resolve, reject) => {
  488. api
  489. .getDeviceMonitor({
  490. devicetype: type,
  491. pagetype: "normal",
  492. })
  493. .then((response) => {
  494. if (response.data.code == 200) {
  495. this.deviceList[type] = response.data.result.msgTxt[0].datalist;
  496. this.curlist = this.deviceList[type];
  497. this.curlist.forEach((item) => {
  498. if (item.readData.frontGateOpen == 1) {
  499. item.readData.frontGateOpen = "打开";
  500. } else {
  501. item.readData.frontGateOpen = "关闭";
  502. }
  503. if (item.readData.midGateOpen == 1) {
  504. item.readData.midGateOpen = "打开";
  505. } else {
  506. item.readData.midGateOpen = "关闭";
  507. }
  508. if (item.readData.rearGateOpen == 1) {
  509. item.readData.rearGateOpen = "打开";
  510. } else {
  511. item.readData.rearGateOpen = "关闭";
  512. }
  513. if (item.readData.midGateOpen == 1) {
  514. item.readData.midGateOpen = "打开";
  515. } else {
  516. item.readData.midGateOpen = "关闭";
  517. }
  518. });
  519. } else {
  520. resolve(response);
  521. }
  522. })
  523. .catch((error) => {
  524. console.log("catch===>response", response);
  525. reject(error);
  526. });
  527. });
  528. },
  529. devicemenuShow(e) {
  530. this.menushow = !this.menushow;
  531. },
  532. //获取app展示字段数据
  533. getShowList(type) {
  534. const params = {
  535. devicekind: type,
  536. pagetype: "detail",
  537. pageNo: 1,
  538. pageSize: 100,
  539. };
  540. return new Promise((resolve, reject) => {
  541. api
  542. .getShowColumList(params)
  543. .then((response) => {
  544. if (response.data.code == 200) {
  545. this.typeList = response.data.result.records;
  546. resolve(response);
  547. } else {
  548. resolve(response);
  549. }
  550. })
  551. .catch((error) => {
  552. reject(error);
  553. });
  554. });
  555. },
  556. openNewPage(params) {
  557. const reqData = {
  558. id: params.deviceID,
  559. name: params.strinstallpos,
  560. type: this.TabCur,
  561. };
  562. const reqparams = uni.$u.queryParams(reqData);
  563. this.getShowList(this.TabCur).then(() => {
  564. if (this.typeList.length > 0) {
  565. this.$destroy();
  566. uni.navigateTo({
  567. url: `/pages/home/detail/autodoor/autodoor${reqparams}`,
  568. });
  569. }
  570. });
  571. // this.$destroy();
  572. // uni.navigateTo({
  573. // url: `/pages/home/detail/autodoor/autodoor?id=${params.deviceID}&name=${params.strinstallpos}&type=${this.TabCur}`,
  574. // });
  575. // },
  576. },
  577. },
  578. destroyed() {
  579. // 停止定时器
  580. this.stopTimer();
  581. },
  582. };
  583. </script>
  584. <style>
  585. .empty {
  586. background: url("/static/empty.png") no-repeat;
  587. background-size: 100% 50%;
  588. }
  589. .empty-message {
  590. display: flex;
  591. justify-content: center;
  592. align-items: center;
  593. font-size: 16px;
  594. line-height: 80vh;
  595. color: #333;
  596. }
  597. >>> .u-navbar--fixed {
  598. /* margin-top: 20px; */
  599. }
  600. .main {
  601. /* margin-top: 100rpx; */
  602. display: flex;
  603. flex-direction: column;
  604. }
  605. .card {
  606. background-color: #ffffff;
  607. margin: auto;
  608. margin-top: 20rpx;
  609. width: 10%;
  610. height: 280rpx;
  611. border: 1rpx solid #000000;
  612. border-radius: 20rpx;
  613. }
  614. .menupage {
  615. position: absolute;
  616. z-index: 2;
  617. width: 100%;
  618. }
  619. .timetext {
  620. text-align: right;
  621. float: right;
  622. }
  623. .itemback {
  624. padding: 20rpx;
  625. background-color: #ffffff;
  626. margin-bottom: 5rpx;
  627. }
  628. .fanContent {
  629. display: flex;
  630. flex-direction: column;
  631. margin-top: 10rpx;
  632. margin-bottom: 10rpx;
  633. }
  634. .top,
  635. .bottom {
  636. flex: 1; /* 各占 50% */
  637. }
  638. .datacard .content {
  639. width: 30rpx;
  640. height: 30rpx;
  641. left: 0rpx;
  642. top: 0rpx;
  643. position: absolute;
  644. }
  645. .datacard {
  646. border-radius: 10rpx;
  647. border: rgba(55, 135, 254, 0.28);
  648. width: 30%;
  649. margin: 1%;
  650. float: left;
  651. height: 190rpx;
  652. text-align: center;
  653. background: linear-gradient(
  654. to right,
  655. rgba(55, 135, 254, 0.08),
  656. rgba(4, 184, 255, 0.08),
  657. rgba(60, 161, 237, 0.08)
  658. );
  659. }
  660. .datacard .gate {
  661. background: linear-gradient(
  662. to right,
  663. rgba(75, 135, 254, 0.08),
  664. rgba(24, 184, 255, 0.08),
  665. rgba(80, 161, 237, 0.08)
  666. );
  667. }
  668. .datacard .window {
  669. background: linear-gradient(
  670. to right,
  671. rgba(55, 125, 254, 0.08),
  672. rgba(4, 164, 255, 0.08),
  673. rgba(60, 131, 237, 0.08)
  674. );
  675. }
  676. .datacard .windrect {
  677. background: linear-gradient(
  678. to right,
  679. rgba(85, 125, 254, 0.08),
  680. rgba(34, 164, 255, 0.08),
  681. rgba(90, 131, 237, 0.08)
  682. );
  683. }
  684. .error-tag {
  685. border-radius: 10%;
  686. display: inline-block;
  687. color: #e90000;
  688. line-height: 50rpx;
  689. font-size: 14px;
  690. text-align: center;
  691. width: 240rpx;
  692. height: 50rpx;
  693. padding-right: 30rpx;
  694. background-color: rgba(233, 0, 0, 0.2);
  695. }
  696. .error-tag1 {
  697. border-radius: 10%;
  698. display: inline-block;
  699. color: #696969;
  700. line-height: 50rpx;
  701. font-size: 14px;
  702. text-align: center;
  703. margin-top: 10rpx;
  704. width: 120rpx;
  705. height: 50rpx;
  706. background-color: rgba(105, 105, 105, 0.2);
  707. }
  708. .success-tag {
  709. border-radius: 10%;
  710. color: #42c000;
  711. line-height: 25px;
  712. font-size: 14px;
  713. width: 60px;
  714. height: 26px;
  715. padding-right: 15px;
  716. background-color: rgba(226, 250, 214);
  717. }
  718. .icon-style {
  719. margin: 7px;
  720. width: 14px;
  721. height: 14px;
  722. }
  723. .title {
  724. margin-left: 40rpx;
  725. float: left;
  726. font-size: 28rpx;
  727. font-weight: 400;
  728. }
  729. </style>