home.vue 25 KB

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