autodoor.vue 19 KB

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