home.vue 24 KB

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