autodoor.vue 19 KB

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