autodoor.vue 20 KB

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