autodoor.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view style="overflow: auto; height: 100%">
  3. <!-- 建议放在外层 -->
  4. <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic">
  5. <view class="u-nav-slot" slot="left">
  6. <u-icon name="arrow-left" size="20"> </u-icon>
  7. </view>
  8. </u-navbar>
  9. <view class="main">
  10. <view class="u-page container">
  11. <div class="button-grid flcard" v-if="this.TabCur == 'gate'">
  12. <u-button
  13. type="primary"
  14. shape="circle"
  15. text="打开前门"
  16. @click="showPasswordDialog('frontGateOpen_S')"
  17. ></u-button>
  18. <u-button
  19. type="primary"
  20. shape="circle"
  21. text="关闭前门"
  22. @click="showPasswordDialog('frontGateClose_S')"
  23. ></u-button>
  24. <u-button
  25. type="primary"
  26. shape="circle"
  27. text="打开后门"
  28. @click="showPasswordDialog('rearGateOpen_S')"
  29. ></u-button>
  30. <u-button
  31. type="primary"
  32. shape="circle"
  33. text="关闭后门"
  34. @click="showPasswordDialog('rearGateClose_S')"
  35. ></u-button>
  36. <u-button
  37. type="primary"
  38. shape="circle"
  39. text="打开前后门"
  40. @click="showPasswordDialog('sameTimeOpen')"
  41. ></u-button>
  42. <u-button
  43. type="primary"
  44. shape="circle"
  45. text="关闭前后门"
  46. @click="showPasswordDialog('sameTimeClose')"
  47. ></u-button>
  48. </div>
  49. <div
  50. class="button-grid flcard"
  51. v-if="this.TabCur == 'window' && this.nwindownum == 1"
  52. >
  53. <u-button
  54. type="primary"
  55. shape="circle"
  56. text="设定面积"
  57. @click="showPasswordDialog('frontSetValue')"
  58. ></u-button>
  59. </div>
  60. <div
  61. class="button-grid flcard"
  62. v-if="this.TabCur == 'window' && this.nwindownum == 2"
  63. >
  64. <u-button
  65. type="primary"
  66. shape="circle"
  67. text="设定前窗面积"
  68. @click="showPasswordDialog('frontSetValue')"
  69. ></u-button>
  70. <u-button
  71. type="primary"
  72. shape="circle"
  73. text="设定后窗面积"
  74. @click="showPasswordDialog('rearSetValue')"
  75. ></u-button>
  76. </div>
  77. <div class="flcard" v-if="this.TabCur == 'gate'">
  78. <doorAnimate
  79. :gatestate1="frontGateStatus"
  80. :gatestate2="midGateStatus"
  81. :gatestate3="rearGateStatus"
  82. :cameralist="cameralist"
  83. :height="height"
  84. :doorcount="ndoorcount"
  85. ></doorAnimate>
  86. </div>
  87. <div class="flcard" v-if="this.TabCur == 'windrect'">
  88. <windrectAnimate
  89. :state="state"
  90. :title="title"
  91. :videoURL="viedeoUrl"
  92. :height="height"
  93. :type="deviceType"
  94. ></windrectAnimate>
  95. </div>
  96. <div class="flcard" v-if="this.TabCur == 'fanlocal'">
  97. <fanlocalAnimate
  98. :fan1State="fan1State"
  99. :fan2State="fan2State"
  100. :title="title"
  101. :videoURL="viedeoUrl"
  102. :height="height"
  103. ></fanlocalAnimate>
  104. </div>
  105. <div
  106. class="flcard"
  107. v-if="this.TabCur == 'window' && this.nwindownum == 1"
  108. >
  109. <windowAnimate
  110. :windowAngle="windowAngle"
  111. :height="height"
  112. :windowcount="nwindownum"
  113. ></windowAnimate>
  114. </div>
  115. <div
  116. class="flcard"
  117. v-if="this.TabCur == 'window' && this.nwindownum == 2"
  118. >
  119. <windowAnimate
  120. :windowAngle="windowAngle"
  121. :windowAngle1="windowAngle1"
  122. :height="height"
  123. :windowcount="nwindownum"
  124. ></windowAnimate>
  125. </div>
  126. <div class="flcard">
  127. <div class="flex-container">
  128. <div
  129. class="itemback"
  130. v-for="(item, index) in typeList"
  131. :key="index"
  132. v-show="item.appShow == 1"
  133. >
  134. <div class="datacardtime" v-if="item.monitorcode == 'readTime'">
  135. <view
  136. class="demo-layout bg-purple-light"
  137. style="padding: 20rpx; color: #3787fe"
  138. >
  139. {{ readTime }}
  140. </view>
  141. </div>
  142. <div class="datacard" v-if="item.monitorcode !== 'readTime'">
  143. <div class="left-content">
  144. <view
  145. v-if="item.monitorcode == 'ndoortype'"
  146. class="demo-layout bg-purple-light"
  147. style="margin-top: 10rpx; color: #3787fe"
  148. >
  149. {{
  150. tableData[item.monitorcode] == "1"
  151. ? "行人"
  152. : tableData[item.monitorcode] == "2"
  153. ? "行车"
  154. : "-"
  155. }}
  156. </view>
  157. <view
  158. v-else-if="item.monitorcode == 'netStatus'"
  159. class="demo-layout bg-purple-light"
  160. style="margin-top: 10rpx; color: #3787fe"
  161. >
  162. {{ doorNetStatus == "1" ? "正常" : "异常" }}
  163. </view>
  164. <view
  165. v-else-if="item.monitorcode == 'warnFlag'"
  166. class="demo-layout bg-purple-light"
  167. style="margin-top: 10rpx; color: #3787fe"
  168. >
  169. {{ warnFlag == "1" ? "正常" : "异常" }}
  170. </view>
  171. <view
  172. v-else
  173. class="demo-layout bg-purple-light"
  174. style="margin-top: 10rpx; color: #3787fe"
  175. >
  176. {{
  177. tableData[item.monitorcode] == null ||
  178. tableData[item.monitorcode] == ""
  179. ? "-"
  180. : tableData[item.monitorcode]
  181. }}
  182. </view>
  183. <div class="spacer"></div>
  184. <!-- 间距 -->
  185. <view
  186. class="demo-layout bg-purple-light"
  187. style="color: #677799"
  188. >
  189. {{ item.des }}
  190. </view>
  191. </div>
  192. <div
  193. class="right-content"
  194. :style="{
  195. backgroundImage:
  196. item.monitorcode === 'frontRearDP' ||
  197. item.monitorcode === 'frontRearDifference'
  198. ? 'url(\'../../../../static/model/Pa.png\')'
  199. : item.monitorcode === 'sourcePressure'
  200. ? 'url(\'../../../../static/model/MPa.png\')'
  201. : item.monitorcode === 'frontGateOpen'
  202. ? 'url(\'../../../../static/model/doorNet.png\')'
  203. : item.monitorcode === 'rearGateOpen'
  204. ? 'url(\'../../../../static/model/doorNet.png\')'
  205. : item.monitorcode === 'midGateOpen'
  206. ? 'url(\'../../../../static/model/doorNet.png\')'
  207. : item.monitorcode === 'warnFlag'
  208. ? 'url(\'../../../../static/model/9432.png\')'
  209. : item.monitorcode === 'netStatus'
  210. ? 'url(\'../../../../static/model/9431.png\')'
  211. : item.monitorcode === 'm3'
  212. ? 'url(\'../../../../static/model/windM3.png\')'
  213. : item.monitorcode === 'fsectarea'
  214. ? 'url(\'../../../../static/model/duanArea.png\')'
  215. : item.monitorcode === 'incipientWindSpeed1' ||
  216. item.monitorcode === 'incipientWindSpeed2' ||
  217. item.monitorcode === 'incipientWindSpeed3' ||
  218. item.monitorcode === 'va'
  219. ? 'url(\'../../../../static/model/fengsu.png\')'
  220. : 'url(\'\')',
  221. backgroundSize: '100% 100%',
  222. }"
  223. ></div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </view>
  229. </view>
  230. <view class="passwordPopup">
  231. <u-popup
  232. :show="show"
  233. mode="bottom"
  234. :round="14"
  235. :safeAreaInsetBottom="false"
  236. >
  237. <view style="margin-top: 15px" v-if="this.TabCur == 'window'"
  238. >风窗面积:</view
  239. >
  240. <u-input
  241. style="margin-top: 15px"
  242. v-model="windowArea"
  243. v-if="this.TabCur == 'window'"
  244. ></u-input>
  245. <view style="margin-top: 15px">请输入密码:</view>
  246. <u-input
  247. style="margin-top: 15px"
  248. v-model="password"
  249. type="password"
  250. ></u-input>
  251. <view class="btns">
  252. <u-button type="primary" shape="circle" @click="confirmPassword()"
  253. >确认</u-button
  254. >
  255. <u-button shape="circle" @click="cancelPassword()">取消</u-button>
  256. </view>
  257. </u-popup>
  258. </view>
  259. </view>
  260. </template>
  261. <script>
  262. import api from "@/api/api";
  263. import initDictOptions from "@/common/util/dictUtil.js";
  264. import doorAnimate from "../doorAnimate/doorAnimate.vue";
  265. import windowAnimate from "../windowAnimate/windowAnimate.vue";
  266. import windrectAnimate from "../windrectAnimate/windrectAnimate.vue";
  267. import fanlocalAnimate from "../fanlocalAnimate/fanlocalAnimate2.vue";
  268. export default {
  269. data() {
  270. return {
  271. tableData: [], //监测数据
  272. typeList: [], //展示字段
  273. itemId: "", // 初始化 itemId
  274. name: "", // 初始化 name
  275. deviceid: "", //初始化设备id
  276. TabCur: "",
  277. checked: [],
  278. backPic: "url(../../../../static/topnavbar.png)",
  279. frontAngle: "", //风窗打开角度
  280. nwindownum: "", //风窗道数
  281. ndoorcount: "", //风门道数
  282. deviceType: "", //设备类型
  283. show: false, //密码弹窗是否显示
  284. password: "", //控制设备密码
  285. paramcode: "", //控制字段
  286. height: "200px",
  287. popupStyle: {
  288. // 弹窗样式
  289. "background-color": "#fff",
  290. padding: "20px",
  291. "box-shadow": "0 2px 4px rgba(0, 0, 0, 0.1)",
  292. },
  293. frontGateStatus: "", //前门状态
  294. rearGateStatus: "", //后门状态
  295. midGateStatus: "", //状态
  296. doorNetStatus: "", //风门通信状态
  297. warnFlag: "", //风门报警
  298. readTime: "", //时间
  299. windowAngle: 0, //前窗打开角度
  300. windowAngle1: 0, //后窗打开角度
  301. windowArea: "", //风窗面积设定值
  302. viedeoUrl: "", //监控url
  303. sign: "",
  304. title: "测风设备",
  305. fan1State: "",
  306. fan2State: "",
  307. deviceid: "", //ID
  308. cameralist: [], //摄像数据
  309. };
  310. },
  311. onLoad(query) {
  312. //保存id到 data 中 可以在整个页面中使用
  313. this.itemId = query.id;
  314. this.name = query.name;
  315. this.TabCur = query.type;
  316. this.ndoorcount = 2;
  317. },
  318. components: { doorAnimate, windowAnimate, windrectAnimate, fanlocalAnimate },
  319. created() {
  320. this.getShowList(this.TabCur);
  321. this.getDeviceInfo(this.itemId);
  322. this.getVideoUrlById(this.itemId);
  323. },
  324. mounted() {
  325. this.startTimer();
  326. },
  327. methods: {
  328. startTimer() {
  329. this.timer = setInterval(() => {
  330. // 执行定时任务
  331. this.getDeviceInfo(this.itemId);
  332. }, 5000);
  333. },
  334. stopTimer() {
  335. // 停止定时器
  336. clearInterval(this.timer);
  337. },
  338. // 返回上一个页面
  339. backPage() {
  340. this.$destroy();
  341. uni.navigateBack({
  342. delta: 1,
  343. });
  344. },
  345. //获取app展示字段数据
  346. getShowList(type) {
  347. const params = {
  348. devicekind: type,
  349. pagetype: "detail",
  350. pageNo: 1,
  351. pageSize: 100,
  352. };
  353. new Promise((resolve, reject) => {
  354. api
  355. .getShowColumList(params)
  356. .then((response) => {
  357. if (response.data.code == 200) {
  358. this.typeList = response.data.result.records;
  359. } else {
  360. resolve(response);
  361. }
  362. })
  363. .catch((error) => {
  364. reject(error);
  365. });
  366. });
  367. },
  368. //获取详情数据
  369. getDeviceInfo(ID) {
  370. let IDString = String(ID); // 将 ID 转换为字符串
  371. new Promise((resolve, reject) => {
  372. api
  373. .getDeviceMonitor({ devicetype: this.TabCur, ids: IDString })
  374. .then((response) => {
  375. if (
  376. response.data.code == 200 &&
  377. response.data.result.msgTxt[0].datalist.length > 0
  378. ) {
  379. var result = response.data.result.msgTxt[0].datalist[0];
  380. this.tableData = result.readData;
  381. if (this.tableData.frontGateOpen == "1") {
  382. this.tableData.frontGateOpen = "打开";
  383. } else {
  384. this.tableData.frontGateOpen = "关闭";
  385. }
  386. if (this.tableData.midGateOpen == "1") {
  387. this.tableData.midGateOpen = "打开";
  388. } else {
  389. this.tableData.midGateOpen = "关闭";
  390. }
  391. if (this.tableData.rearGateOpen == "1") {
  392. this.tableData.rearGateOpen = "打开";
  393. } else {
  394. this.tableData.rearGateOpen = "关闭";
  395. }
  396. this.fan1State = result.readData.Fan1StartStatus;
  397. this.fan2State = result.readData.Fan2StartStatus;
  398. this.nwindownum = result.nwindownum;
  399. this.ndoorcount = result.ndoorcount;
  400. this.deviceType = result.deviceType;
  401. this.state = result.readData.sign;
  402. this.frontGateStatus = this.tableData.frontGateOpen;
  403. this.midGateStatus = this.tableData.midGateOpen;
  404. this.rearGateStatus = this.tableData.rearGateOpen;
  405. this.doorNetStatus = result.netStatus;
  406. this.warnFlag = result.warnLevel_str;
  407. this.readTime = result.readTime;
  408. var maxarea = result.maxarea;
  409. this.windowAngle =
  410. (this.tableData.forntArea / maxarea) * 100 * 0.9;
  411. this.windowAngle1 =
  412. (this.tableData.rearArea / maxarea) * 100 * 0.9;
  413. this.deviceid = result.deviceID;
  414. this.$forceUpdate();
  415. } else {
  416. resolve(response);
  417. }
  418. })
  419. .catch((error) => {
  420. reject(error);
  421. });
  422. });
  423. },
  424. //获取监控URL 通过ID获取
  425. getVideoUrlById(ID) {
  426. let IDString = String(ID); // 将 ID 转换为字符串
  427. new Promise((resolve, reject) => {
  428. api
  429. .getCameraById({ deviceid: IDString })
  430. .then((response) => {
  431. if (response.data.code == 200) {
  432. if (response.data.result.records.length > 0) {
  433. this.cameralist = response.data.result.records[0];
  434. }
  435. } else {
  436. resolve(response);
  437. }
  438. })
  439. .catch((error) => {
  440. reject(error);
  441. });
  442. });
  443. },
  444. //设备控制
  445. ctrlDevice(pass) {
  446. let IDString = String(this.itemId); // 将 ID 转换为字符串
  447. const params = {
  448. deviceid: IDString,
  449. devicetype: this.deviceType,
  450. paramcode: this.paramcode,
  451. password: pass,
  452. value: this.windowArea,
  453. };
  454. new Promise((resolve, reject) => {
  455. api
  456. .controlDevice(params)
  457. .then((response) => {
  458. if (response.data.code == 200) {
  459. this.getDeviceInfo(IDString);
  460. // console.log("操作成功");
  461. } else {
  462. resolve(response);
  463. }
  464. })
  465. .catch((error) => {
  466. reject(error);
  467. });
  468. });
  469. },
  470. // 显示密码输入弹窗
  471. showPasswordDialog(controlCode) {
  472. this.paramcode = controlCode;
  473. this.show = true;
  474. },
  475. // 取消密码输入
  476. cancelPassword() {
  477. this.show = false;
  478. },
  479. confirmPassword() {
  480. this.ctrlDevice(this.password);
  481. // 发起请求后关闭密码输入弹窗
  482. this.show = false;
  483. },
  484. },
  485. destroyed() {
  486. // 停止定时器
  487. this.stopTimer();
  488. },
  489. };
  490. </script>
  491. <style lang="scss" scoped>
  492. passwordPopup {
  493. height: 300rpx;
  494. background-color: #fff;
  495. }
  496. .top-nav {
  497. background-image: url(../../../../static/topnavbar.png);
  498. background-size: cover; /* 背景图片大小适应 */
  499. height: 100%;
  500. }
  501. .top-nav2 {
  502. background-color: #ffffff;
  503. }
  504. .main {
  505. margin-top: 80px;
  506. }
  507. .container {
  508. display: flex;
  509. flex-direction: column;
  510. }
  511. .button-grid {
  512. display: grid;
  513. grid-template-columns: repeat(4, 1fr);
  514. gap: 5px; /* 可以根据需要调整行列之间的间距 */
  515. }
  516. .flcard {
  517. padding: 20rpx;
  518. background-color: #ffffff;
  519. margin-bottom: 5rpx;
  520. }
  521. .additional-div {
  522. grid-column: span 2; /* 让附加内容跨越三列 */
  523. display: flex;
  524. align-items: center;
  525. }
  526. .checkbox-group {
  527. margin-left: 10px; /* 可以根据需要调整间距 */
  528. }
  529. .card {
  530. background-color: #ffffff;
  531. margin: auto;
  532. margin-top: 20rpx;
  533. width: 90%;
  534. height: 280rpx;
  535. border: 1rpx solid #000000;
  536. border-radius: 20rpx;
  537. }
  538. .flex-containe {
  539. display: flex;
  540. flex-direction: row;
  541. flex-wrap: wrap;
  542. }
  543. .itemback {
  544. flex: 0 0 calc(33.33% - 10px); /* 使用calc函数计算每个项目的宽度,减去间距 */
  545. margin: 5px; /* 间距设置为5px */
  546. }
  547. .datacardtime {
  548. display: flex;
  549. width: 100%;
  550. flex: 1;
  551. margin: 1%;
  552. float: left;
  553. height: 50rpx;
  554. text-align: center;
  555. background: linear-gradient(
  556. to right,
  557. rgba(55, 135, 254, 0.08),
  558. rgba(4, 184, 255, 0.08),
  559. rgba(60, 161, 237, 0.08)
  560. );
  561. }
  562. .datacard {
  563. display: flex;
  564. width: 48%;
  565. flex: 1;
  566. margin: 1%;
  567. float: left;
  568. height: 100rpx;
  569. text-align: center;
  570. background: linear-gradient(
  571. to right,
  572. rgba(55, 135, 254, 0.08),
  573. rgba(4, 184, 255, 0.08),
  574. rgba(60, 161, 237, 0.08)
  575. );
  576. }
  577. .left-content {
  578. width: 50%;
  579. display: flex;
  580. flex-direction: column;
  581. }
  582. .spacer {
  583. height: 10rpx;
  584. }
  585. .right-content {
  586. width: 50%; /* 右侧内容占据50%宽度 */
  587. background-image: url(../../../../static/model/Pa.png);
  588. background-size: 100% 125%;
  589. }
  590. /*风窗样式*/
  591. div.autowindow_new {
  592. width: 200px;
  593. height: 200px;
  594. background-image: url(../../../../static/window/window-bk.png);
  595. background-size: 100% 100%;
  596. perspective: 800px;
  597. }
  598. /*风窗1 2 3 4*/
  599. div.window_new_1 {
  600. margin-top: 12px;
  601. margin-left: 15px;
  602. width: 170px;
  603. height: 30px;
  604. background-color: crimson;
  605. box-sizing: border-box;
  606. float: left;
  607. z-index: 1;
  608. /* transition: all 2s; */
  609. background-image: url(../../../../static/window/window_new1.png);
  610. background-size: 100% 100%;
  611. }
  612. div.window_new_2 {
  613. margin-top: 2px;
  614. margin-left: 15px;
  615. width: 170px;
  616. height: 29px;
  617. background-color: crimson;
  618. box-sizing: border-box;
  619. float: left;
  620. z-index: 1;
  621. /* transition: all 2s; */
  622. background-image: url(../../../../static/window/window_new1.png);
  623. background-size: 100% 100%;
  624. }
  625. div.window_new_3 {
  626. margin-top: 2px;
  627. margin-left: 15px;
  628. width: 170px;
  629. height: 29px;
  630. background-color: crimson;
  631. box-sizing: border-box;
  632. float: left;
  633. z-index: 1;
  634. /* transition: all 2s; */
  635. background-image: url(../../../../static/window/window_new1.png);
  636. background-size: 100% 100%;
  637. }
  638. div.window_new_4 {
  639. margin-top: 2px;
  640. margin-left: 15px;
  641. width: 170px;
  642. height: 29px;
  643. background-color: crimson;
  644. box-sizing: border-box;
  645. float: left;
  646. z-index: 1;
  647. /* transition: all 2s; */
  648. background-image: url(../../../../static/window/window_new1.png);
  649. background-size: 100% 100%;
  650. }
  651. div.window_new_5 {
  652. margin-top: 2px;
  653. margin-left: 15px;
  654. width: 170px;
  655. height: 29px;
  656. background-color: crimson;
  657. box-sizing: border-box;
  658. float: left;
  659. z-index: 1;
  660. /* transition: all 2s; */
  661. background-image: url(../../../../static/window/window_new1.png);
  662. background-size: 100% 100%;
  663. }
  664. div.window_new_1 {
  665. transition: all 2s ease;
  666. transform-origin: center center;
  667. }
  668. div.window_new_2 {
  669. transition: all 2s ease;
  670. transform-origin: center center;
  671. }
  672. div.window_new_3 {
  673. transition: all 2s ease;
  674. transform-origin: center center;
  675. }
  676. div.window_new_4 {
  677. transition: all 2s ease;
  678. transform-origin: center center;
  679. }
  680. div.window_new_5 {
  681. transition: all 2s ease;
  682. transform-origin: center center;
  683. }
  684. .btns {
  685. display: flex;
  686. margin-top: 15px;
  687. }
  688. </style>