autodoor.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <view style="overflow: auto; height: 100%">
  3. <!-- 建议放在外层 -->
  4. <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic" :bgStatusImage="backPic0">
  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. backPic0: "url(/static/topnavbar0.png)",
  279. backPic: "url(/static/topnavbar.png)",
  280. frontAngle: "", //风窗打开角度
  281. nwindownum: "", //风窗道数
  282. ndoorcount: "", //风门道数
  283. deviceType: "", //设备类型
  284. show: false, //密码弹窗是否显示
  285. password: "", //控制设备密码
  286. paramcode: "", //控制字段
  287. height: "200px",
  288. popupStyle: {
  289. // 弹窗样式
  290. "background-color": "#fff",
  291. padding: "20px",
  292. "box-shadow": "0 2px 4px rgba(0, 0, 0, 0.1)",
  293. },
  294. frontGateStatus: "", //前门状态
  295. rearGateStatus: "", //后门状态
  296. midGateStatus: "", //状态
  297. doorNetStatus: "", //风门通信状态
  298. warnFlag: "", //风门报警
  299. readTime: "", //时间
  300. windowAngle: 0, //前窗打开角度
  301. windowAngle1: 0, //后窗打开角度
  302. windowArea: "", //风窗面积设定值
  303. viedeoUrl: "", //监控url
  304. sign: "",
  305. title: "测风设备",
  306. fan1State: "",
  307. fan2State: "",
  308. deviceid: "", //ID
  309. cameralist: [], //摄像数据
  310. };
  311. },
  312. onLoad(query) {
  313. //保存id到 data 中 可以在整个页面中使用
  314. this.itemId = query.id;
  315. this.name = query.name;
  316. this.TabCur = query.type;
  317. this.ndoorcount = 2;
  318. },
  319. components: { doorAnimate, windowAnimate, windrectAnimate, fanlocalAnimate },
  320. created() {
  321. this.getShowList(this.TabCur);
  322. this.getDeviceInfo(this.itemId);
  323. this.getVideoUrlById(this.itemId);
  324. },
  325. mounted() {
  326. this.startTimer();
  327. },
  328. methods: {
  329. startTimer() {
  330. this.timer = setInterval(() => {
  331. // 执行定时任务
  332. this.getDeviceInfo(this.itemId);
  333. }, 5000);
  334. },
  335. stopTimer() {
  336. // 停止定时器
  337. clearInterval(this.timer);
  338. },
  339. // 返回上一个页面
  340. backPage() {
  341. this.$destroy();
  342. uni.navigateBack({
  343. delta: 1,
  344. });
  345. },
  346. //获取app展示字段数据
  347. getShowList(type) {
  348. const params = {
  349. devicekind: type,
  350. pagetype: "detail",
  351. pageNo: 1,
  352. pageSize: 100,
  353. };
  354. new Promise((resolve, reject) => {
  355. api
  356. .getShowColumList(params)
  357. .then((response) => {
  358. if (response.data.code == 200) {
  359. this.typeList = response.data.result.records;
  360. } else {
  361. resolve(response);
  362. }
  363. })
  364. .catch((error) => {
  365. reject(error);
  366. });
  367. });
  368. },
  369. //获取详情数据
  370. getDeviceInfo(ID) {
  371. let IDString = String(ID); // 将 ID 转换为字符串
  372. new Promise((resolve, reject) => {
  373. api
  374. .getDeviceMonitor({ devicetype: this.TabCur, ids: IDString })
  375. .then((response) => {
  376. if (
  377. response.data.code == 200 &&
  378. response.data.result.msgTxt[0].datalist.length > 0
  379. ) {
  380. var result = response.data.result.msgTxt[0].datalist[0];
  381. this.tableData = result.readData;
  382. if (this.tableData.frontGateOpen == "1") {
  383. this.tableData.frontGateOpen = "打开";
  384. } else {
  385. this.tableData.frontGateOpen = "关闭";
  386. }
  387. if (this.tableData.midGateOpen == "1") {
  388. this.tableData.midGateOpen = "打开";
  389. } else {
  390. this.tableData.midGateOpen = "关闭";
  391. }
  392. if (this.tableData.rearGateOpen == "1") {
  393. this.tableData.rearGateOpen = "打开";
  394. } else {
  395. this.tableData.rearGateOpen = "关闭";
  396. }
  397. this.fan1State = result.readData.Fan1StartStatus;
  398. this.fan2State = result.readData.Fan2StartStatus;
  399. this.nwindownum = result.nwindownum;
  400. this.ndoorcount = result.ndoorcount;
  401. this.deviceType = result.deviceType;
  402. this.state = result.readData.sign;
  403. this.frontGateStatus = this.tableData.frontGateOpen;
  404. this.midGateStatus = this.tableData.midGateOpen;
  405. this.rearGateStatus = this.tableData.rearGateOpen;
  406. this.doorNetStatus = result.netStatus;
  407. this.warnFlag = result.warnLevel_str;
  408. this.readTime = result.readTime;
  409. var maxarea = result.maxarea;
  410. this.windowAngle =
  411. (this.tableData.forntArea / maxarea) * 100 * 0.9;
  412. this.windowAngle1 =
  413. (this.tableData.rearArea / maxarea) * 100 * 0.9;
  414. this.deviceid = result.deviceID;
  415. this.$forceUpdate();
  416. } else {
  417. resolve(response);
  418. }
  419. })
  420. .catch((error) => {
  421. reject(error);
  422. });
  423. });
  424. },
  425. //获取监控URL 通过ID获取
  426. getVideoUrlById(ID) {
  427. let IDString = String(ID); // 将 ID 转换为字符串
  428. new Promise((resolve, reject) => {
  429. api
  430. .getCameraById({ deviceid: IDString })
  431. .then((response) => {
  432. if (response.data.code == 200) {
  433. if (response.data.result.records.length > 0) {
  434. this.cameralist = response.data.result.records[0];
  435. }
  436. } else {
  437. resolve(response);
  438. }
  439. })
  440. .catch((error) => {
  441. reject(error);
  442. });
  443. });
  444. },
  445. //设备控制
  446. ctrlDevice(pass) {
  447. let IDString = String(this.itemId); // 将 ID 转换为字符串
  448. const params = {
  449. deviceid: IDString,
  450. devicetype: this.deviceType,
  451. paramcode: this.paramcode,
  452. password: pass,
  453. value: this.windowArea,
  454. };
  455. new Promise((resolve, reject) => {
  456. api
  457. .controlDevice(params)
  458. .then((response) => {
  459. if (response.data.code == 200) {
  460. this.getDeviceInfo(IDString);
  461. // console.log("操作成功");
  462. } else {
  463. resolve(response);
  464. }
  465. })
  466. .catch((error) => {
  467. reject(error);
  468. });
  469. });
  470. },
  471. // 显示密码输入弹窗
  472. showPasswordDialog(controlCode) {
  473. this.paramcode = controlCode;
  474. this.show = true;
  475. },
  476. // 取消密码输入
  477. cancelPassword() {
  478. this.show = false;
  479. },
  480. confirmPassword() {
  481. this.ctrlDevice(this.password);
  482. // 发起请求后关闭密码输入弹窗
  483. this.show = false;
  484. },
  485. },
  486. destroyed() {
  487. // 停止定时器
  488. this.stopTimer();
  489. },
  490. };
  491. </script>
  492. <style lang="scss" scoped>
  493. passwordPopup {
  494. height: 300rpx;
  495. background-color: #fff;
  496. }
  497. .top-nav {
  498. background-image: url(../../../../static/topnavbar.png);
  499. background-size: cover; /* 背景图片大小适应 */
  500. height: 100%;
  501. }
  502. .top-nav2 {
  503. background-color: #ffffff;
  504. }
  505. .main {
  506. margin-top: 80px;
  507. }
  508. .container {
  509. display: flex;
  510. flex-direction: column;
  511. }
  512. .button-grid {
  513. display: grid;
  514. grid-template-columns: repeat(4, 1fr);
  515. gap: 5px; /* 可以根据需要调整行列之间的间距 */
  516. }
  517. .flcard {
  518. padding: 20rpx;
  519. background-color: #ffffff;
  520. margin-bottom: 5rpx;
  521. }
  522. .additional-div {
  523. grid-column: span 2; /* 让附加内容跨越三列 */
  524. display: flex;
  525. align-items: center;
  526. }
  527. .checkbox-group {
  528. margin-left: 10px; /* 可以根据需要调整间距 */
  529. }
  530. .card {
  531. background-color: #ffffff;
  532. margin: auto;
  533. margin-top: 20rpx;
  534. width: 90%;
  535. height: 280rpx;
  536. border: 1rpx solid #000000;
  537. border-radius: 20rpx;
  538. }
  539. .flex-containe {
  540. display: flex;
  541. flex-direction: row;
  542. flex-wrap: wrap;
  543. }
  544. .itemback {
  545. flex: 0 0 calc(33.33% - 10px); /* 使用calc函数计算每个项目的宽度,减去间距 */
  546. margin: 5px; /* 间距设置为5px */
  547. }
  548. .datacardtime {
  549. display: flex;
  550. width: 100%;
  551. flex: 1;
  552. margin: 1%;
  553. float: left;
  554. height: 50rpx;
  555. text-align: center;
  556. background: linear-gradient(
  557. to right,
  558. rgba(55, 135, 254, 0.08),
  559. rgba(4, 184, 255, 0.08),
  560. rgba(60, 161, 237, 0.08)
  561. );
  562. }
  563. .datacard {
  564. display: flex;
  565. width: 48%;
  566. flex: 1;
  567. margin: 1%;
  568. float: left;
  569. height: 100rpx;
  570. text-align: center;
  571. background: linear-gradient(
  572. to right,
  573. rgba(55, 135, 254, 0.08),
  574. rgba(4, 184, 255, 0.08),
  575. rgba(60, 161, 237, 0.08)
  576. );
  577. }
  578. .left-content {
  579. width: 50%;
  580. display: flex;
  581. flex-direction: column;
  582. }
  583. .spacer {
  584. height: 10rpx;
  585. }
  586. .right-content {
  587. width: 50%; /* 右侧内容占据50%宽度 */
  588. background-image: url(../../../../static/model/Pa.png);
  589. background-size: 100% 125%;
  590. }
  591. /*风窗样式*/
  592. div.autowindow_new {
  593. width: 200px;
  594. height: 200px;
  595. background-image: url(../../../../static/window/window-bk.png);
  596. background-size: 100% 100%;
  597. perspective: 800px;
  598. }
  599. /*风窗1 2 3 4*/
  600. div.window_new_1 {
  601. margin-top: 12px;
  602. margin-left: 15px;
  603. width: 170px;
  604. height: 30px;
  605. background-color: crimson;
  606. box-sizing: border-box;
  607. float: left;
  608. z-index: 1;
  609. /* transition: all 2s; */
  610. background-image: url(../../../../static/window/window_new1.png);
  611. background-size: 100% 100%;
  612. }
  613. div.window_new_2 {
  614. margin-top: 2px;
  615. margin-left: 15px;
  616. width: 170px;
  617. height: 29px;
  618. background-color: crimson;
  619. box-sizing: border-box;
  620. float: left;
  621. z-index: 1;
  622. /* transition: all 2s; */
  623. background-image: url(../../../../static/window/window_new1.png);
  624. background-size: 100% 100%;
  625. }
  626. div.window_new_3 {
  627. margin-top: 2px;
  628. margin-left: 15px;
  629. width: 170px;
  630. height: 29px;
  631. background-color: crimson;
  632. box-sizing: border-box;
  633. float: left;
  634. z-index: 1;
  635. /* transition: all 2s; */
  636. background-image: url(../../../../static/window/window_new1.png);
  637. background-size: 100% 100%;
  638. }
  639. div.window_new_4 {
  640. margin-top: 2px;
  641. margin-left: 15px;
  642. width: 170px;
  643. height: 29px;
  644. background-color: crimson;
  645. box-sizing: border-box;
  646. float: left;
  647. z-index: 1;
  648. /* transition: all 2s; */
  649. background-image: url(../../../../static/window/window_new1.png);
  650. background-size: 100% 100%;
  651. }
  652. div.window_new_5 {
  653. margin-top: 2px;
  654. margin-left: 15px;
  655. width: 170px;
  656. height: 29px;
  657. background-color: crimson;
  658. box-sizing: border-box;
  659. float: left;
  660. z-index: 1;
  661. /* transition: all 2s; */
  662. background-image: url(../../../../static/window/window_new1.png);
  663. background-size: 100% 100%;
  664. }
  665. div.window_new_1 {
  666. transition: all 2s ease;
  667. transform-origin: center center;
  668. }
  669. div.window_new_2 {
  670. transition: all 2s ease;
  671. transform-origin: center center;
  672. }
  673. div.window_new_3 {
  674. transition: all 2s ease;
  675. transform-origin: center center;
  676. }
  677. div.window_new_4 {
  678. transition: all 2s ease;
  679. transform-origin: center center;
  680. }
  681. div.window_new_5 {
  682. transition: all 2s ease;
  683. transform-origin: center center;
  684. }
  685. .btns {
  686. display: flex;
  687. margin-top: 15px;
  688. }
  689. </style>