home.vue 24 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. "
  79. >
  80. <view
  81. :class="TabCur"
  82. style="
  83. padding-top: 10rpx;
  84. padding-bottom: 10rpx;
  85. display: flex;
  86. flex-direction: column;
  87. align-items: center;
  88. height: 100%;
  89. "
  90. >
  91. <view
  92. v-if="
  93. showitem.datatype == 1 &&
  94. showitem.monitorcode == 'doorUse'
  95. "
  96. class="demo-layout bg-purple-light"
  97. style="
  98. margin-top: 10rpx;
  99. color: #3787fe;
  100. font-size: 30rpx;
  101. margin-top: 20rpx;
  102. "
  103. >
  104. {{
  105. item[showitem.monitorcode] == "2"
  106. ? "行人"
  107. : item[showitem.monitorcode] == "1"
  108. ? "行车"
  109. : "-"
  110. }}
  111. </view>
  112. <view
  113. v-else-if="showitem.datatype == 1"
  114. class="demo-layout bg-purple-light"
  115. style="
  116. margin-top: 10rpx;
  117. color: #3787fe;
  118. font-size: 30rpx;
  119. margin-top: 20rpx;
  120. "
  121. >
  122. {{
  123. item[showitem.monitorcode] == null ||
  124. item[showitem.monitorcode] == ""
  125. ? "-"
  126. : item[showitem.monitorcode]
  127. }}
  128. </view>
  129. <view
  130. v-else-if="showitem.datatype == 2"
  131. class="demo-layout bg-purple-light"
  132. style="
  133. color: #3787fe;
  134. font-size: 30rpx;
  135. margin-top: 20rpx;
  136. "
  137. >
  138. {{
  139. item.readData[showitem.monitorcode] == null ||
  140. item.readData[showitem.monitorcode] == ""
  141. ? "-"
  142. : item.readData[showitem.monitorcode]
  143. }}
  144. </view>
  145. <view
  146. class="demo-layout bg-purple-light"
  147. style="
  148. margin-top: 20rpx;
  149. color: #677799;
  150. margin-top: 20rpx;
  151. "
  152. >
  153. {{ showitem.des }}
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. <div class="fanContent" v-else>
  159. <div class="top">
  160. <view>主机</view>
  161. <view
  162. class="datacard"
  163. v-for="(showitem, index) in deviceShowList"
  164. :key="index"
  165. v-show="
  166. showitem.appShow == 1 &&
  167. showitem.monitorcode != 'strinstallpos' &&
  168. showitem.monitorcode != 'netStatus' &&
  169. showitem.monitorcode != 'warnFlag' &&
  170. showitem.monitorcode != 'readTime' &&
  171. showitem.monitorcode != ''
  172. "
  173. >
  174. <view
  175. :class="TabCur"
  176. style="
  177. padding-top: 10rpx;
  178. padding-bottom: 10rpx;
  179. display: flex;
  180. flex-direction: column;
  181. align-items: center;
  182. height: 100%;
  183. "
  184. >
  185. <view
  186. v-if="
  187. showitem.datatype == 1 &&
  188. showitem.monitorcode == 'doorUse'
  189. "
  190. class="demo-layout bg-purple-light"
  191. style="
  192. margin-top: 10rpx;
  193. color: #3787fe;
  194. font-size: 30rpx;
  195. margin-top: 20rpx;
  196. "
  197. >
  198. {{
  199. item[showitem.monitorcode] == "2"
  200. ? "行人"
  201. : item[showitem.monitorcode] == "1"
  202. ? "行车"
  203. : "-"
  204. }}
  205. </view>
  206. <view
  207. v-else-if="showitem.datatype == 1"
  208. class="demo-layout bg-purple-light"
  209. style="
  210. margin-top: 10rpx;
  211. color: #3787fe;
  212. font-size: 30rpx;
  213. margin-top: 20rpx;
  214. "
  215. >
  216. {{
  217. item[
  218. showitem.monitorcode.startsWith("Fan")
  219. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  220. : showitem.monitorcode
  221. ] !== undefined &&
  222. item[
  223. showitem.monitorcode.startsWith("Fan")
  224. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  225. : showitem.monitorcode
  226. ] !== null
  227. ? item[
  228. showitem.monitorcode.startsWith("Fan")
  229. ? showitem.monitorcode.replace(
  230. /^Fan/,
  231. "Fan1"
  232. )
  233. : showitem.monitorcode
  234. ]
  235. : "-"
  236. }}
  237. </view>
  238. <view
  239. v-else-if="showitem.datatype == 2"
  240. class="demo-layout bg-purple-light"
  241. style="
  242. color: #3787fe;
  243. font-size: 30rpx;
  244. margin-top: 20rpx;
  245. "
  246. >
  247. {{
  248. item.readData[
  249. showitem.monitorcode.startsWith("Fan")
  250. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  251. : showitem.monitorcode
  252. ] !== undefined &&
  253. item.readData[
  254. showitem.monitorcode.startsWith("Fan")
  255. ? showitem.monitorcode.replace(/^Fan/, "Fan1")
  256. : showitem.monitorcode
  257. ] !== null
  258. ? item.readData[
  259. showitem.monitorcode.startsWith("Fan")
  260. ? showitem.monitorcode.replace(
  261. /^Fan/,
  262. "Fan1"
  263. )
  264. : showitem.monitorcode
  265. ]
  266. : "-"
  267. }}
  268. </view>
  269. <view
  270. class="demo-layout bg-purple-light"
  271. style="
  272. margin-top: 20rpx;
  273. color: #677799;
  274. margin-top: 20rpx;
  275. "
  276. >
  277. {{ showitem.des }}
  278. </view>
  279. </view>
  280. </view>
  281. </div>
  282. <div class="bottom">
  283. <view>备机</view>
  284. <view
  285. class="datacard"
  286. v-for="(showitem, index) in deviceShowList"
  287. :key="index"
  288. v-show="
  289. showitem.appShow == 1 &&
  290. showitem.monitorcode != 'strinstallpos' &&
  291. showitem.monitorcode != 'netStatus' &&
  292. showitem.monitorcode != 'warnFlag' &&
  293. showitem.monitorcode != 'readTime' &&
  294. showitem.monitorcode != ''
  295. "
  296. >
  297. <view
  298. :class="TabCur"
  299. style="
  300. padding-top: 10rpx;
  301. padding-bottom: 10rpx;
  302. display: flex;
  303. flex-direction: column;
  304. align-items: center;
  305. height: 100%;
  306. "
  307. >
  308. <view
  309. v-if="
  310. showitem.datatype == 1 &&
  311. showitem.monitorcode == 'doorUse'
  312. "
  313. class="demo-layout bg-purple-light"
  314. style="
  315. margin-top: 10rpx;
  316. color: #3787fe;
  317. font-size: 30rpx;
  318. margin-top: 20rpx;
  319. "
  320. >
  321. {{
  322. item[showitem.monitorcode] == "2"
  323. ? "行人"
  324. : item[showitem.monitorcode] == "1"
  325. ? "行车"
  326. : "-"
  327. }}
  328. </view>
  329. <view
  330. v-else-if="showitem.datatype == 1"
  331. class="demo-layout bg-purple-light"
  332. style="
  333. margin-top: 10rpx;
  334. color: #3787fe;
  335. font-size: 30rpx;
  336. margin-top: 20rpx;
  337. "
  338. >
  339. {{
  340. item[
  341. showitem.monitorcode.startsWith("Fan")
  342. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  343. : showitem.monitorcode
  344. ] !== undefined &&
  345. item[
  346. showitem.monitorcode.startsWith("Fan")
  347. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  348. : showitem.monitorcode
  349. ] !== null
  350. ? item[
  351. showitem.monitorcode.startsWith("Fan")
  352. ? showitem.monitorcode.replace(
  353. /^Fan/,
  354. "Fan2"
  355. )
  356. : showitem.monitorcode
  357. ]
  358. : "-"
  359. }}
  360. </view>
  361. <view
  362. v-else-if="showitem.datatype == 2"
  363. class="demo-layout bg-purple-light"
  364. style="
  365. color: #3787fe;
  366. font-size: 30rpx;
  367. margin-top: 20rpx;
  368. "
  369. >
  370. {{
  371. item.readData[
  372. showitem.monitorcode.startsWith("Fan")
  373. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  374. : showitem.monitorcode
  375. ] !== undefined &&
  376. item.readData[
  377. showitem.monitorcode.startsWith("Fan")
  378. ? showitem.monitorcode.replace(/^Fan/, "Fan2")
  379. : showitem.monitorcode
  380. ] !== null
  381. ? item.readData[
  382. showitem.monitorcode.startsWith("Fan")
  383. ? showitem.monitorcode.replace(
  384. /^Fan/,
  385. "Fan2"
  386. )
  387. : showitem.monitorcode
  388. ]
  389. : "-"
  390. }}
  391. </view>
  392. <view
  393. class="demo-layout bg-purple-light"
  394. style="
  395. margin-top: 20rpx;
  396. color: #677799;
  397. margin-top: 20rpx;
  398. "
  399. >
  400. {{ showitem.des }}
  401. </view>
  402. </view>
  403. </view>
  404. </div>
  405. </div>
  406. </div>
  407. </u-list-item>
  408. </template>
  409. <template v-else>
  410. <div class="empty-message">数据为空</div>
  411. </template>
  412. </u-list>
  413. </view>
  414. </view>
  415. </view>
  416. </template>
  417. <script>
  418. import api from "@/api/api";
  419. import { computed } from "vue";
  420. export default {
  421. data() {
  422. return {
  423. menushow: false,
  424. TabCur: "gate",
  425. curlist: [],
  426. deviceList: {},
  427. colums: {},
  428. typeList: [], //详情页展示数据
  429. deviceShowList: [], //设备展示字段
  430. };
  431. },
  432. props: ["showColum", "deviceType"],
  433. watch: {
  434. showColum(data) {
  435. this.colums = data;
  436. },
  437. deviceType: {
  438. async handler(data) {
  439. if (data) {
  440. this.TabCur = data;
  441. this.curlist = this.deviceList[this.TabCur];
  442. if (this.curlist == null) {
  443. this.curlist = [];
  444. }
  445. // 选择设备分类,重新获取数据
  446. await this.loadData(this.TabCur);
  447. this.$emit("setMenushow", {
  448. menushow: false,
  449. });
  450. }
  451. },
  452. immediate: true,
  453. },
  454. },
  455. created() {
  456. this.colums = this.showColum;
  457. const key = this.TabCur + "_monitor";
  458. this.deviceShowList = this.colums[key];
  459. this.loadData("gate");
  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>