autodoor.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <template>
  2. <view style="overflow: auto; height: 100%">
  3. <!-- 建议放在外层 -->
  4. <u-navbar :title="name" @leftClick="backPage" :bgImage="backPic" style="margin-top: 30px">
  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="rearGateStatus"
  81. :videoURL="viedeoUrl"
  82. :height="height"
  83. :doorcount="ndoorcount"
  84. ></doorAnimate>
  85. </div>
  86. <div class="flcard" v-if="this.TabCur == 'windrect'">
  87. <windrectAnimate
  88. :state="state"
  89. :title="title"
  90. :videoURL="viedeoUrl"
  91. :height="height"
  92. :type="deviceType"
  93. ></windrectAnimate>
  94. </div>
  95. <div class="flcard" v-if="this.TabCur == 'fanlocal'">
  96. <fanlocalAnimate
  97. :fan1State="fan1State"
  98. :fan2State="fan2State"
  99. :title="title"
  100. :videoURL="viedeoUrl"
  101. :height="height"
  102. ></fanlocalAnimate>
  103. </div>
  104. <div
  105. class="flcard"
  106. v-if="this.TabCur == 'window' && this.nwindownum == 1"
  107. >
  108. <windowAnimate
  109. :windowAngle="windowAngle"
  110. :height="height"
  111. :windowcount="nwindownum"
  112. ></windowAnimate>
  113. </div>
  114. <div
  115. class="flcard"
  116. v-if="this.TabCur == 'window' && this.nwindownum == 2"
  117. >
  118. <windowAnimate
  119. :windowAngle="windowAngle"
  120. :windowAngle1="windowAngle1"
  121. :height="height"
  122. :windowcount="nwindownum"
  123. ></windowAnimate>
  124. </div>
  125. <div class="flcard">
  126. <div class="flex-container">
  127. <div
  128. class="itemback"
  129. v-for="(item, index) in typeList"
  130. :key="index"
  131. v-show="item.appShow == 1"
  132. >
  133. <div class="datacardtime" v-if="item.monitorcode == 'readTime'">
  134. <view
  135. class="demo-layout bg-purple-light"
  136. style="margin-top: 10rpx; color: #3787fe"
  137. >
  138. {{ tableData[item.monitorcode] }}
  139. </view>
  140. </div>
  141. <div class="datacard" v-if="item.monitorcode !== 'readTime'">
  142. <div class="left-content">
  143. <view v-if="item.monitorcode == 'ndoortype'"
  144. class="demo-layout bg-purple-light"
  145. style="margin-top: 10rpx; color: #3787fe"
  146. >
  147. {{ tableData[item.monitorcode] == '1'?'行人':tableData[item.monitorcode] == '2'?'行车':'-' }}
  148. </view>
  149. <view v-else
  150. class="demo-layout bg-purple-light"
  151. style="margin-top: 10rpx; color: #3787fe"
  152. >
  153. {{ tableData[item.monitorcode] == null || tableData[item.monitorcode] == ''?'-':tableData[item.monitorcode]}}
  154. </view>
  155. <div class="spacer"></div>
  156. <!-- 间距 -->
  157. <view
  158. class="demo-layout bg-purple-light"
  159. style="color: #677799"
  160. >
  161. {{ item.des }}
  162. </view>
  163. </div>
  164. <div
  165. class="right-content"
  166. :style="{
  167. backgroundImage:
  168. item.monitorcode === 'frontRearDP' ||
  169. item.monitorcode === 'frontRearDifference'
  170. ? 'url(\'/static/model/Pa.png\')'
  171. : item.monitorcode === 'sourcePressure'
  172. ? 'url(\'/static/model/MPa.png\')'
  173. : item.monitorcode === 'frontGateOpen'
  174. ? 'url(\'/static/model/doorNet.png\')'
  175. : item.monitorcode === 'rearGateOpen'
  176. ? 'url(\'/static/model/doorNet.png\')'
  177. : item.monitorcode === 'midGateOpen'
  178. ? 'url(\'/static/model/doorNet.png\')'
  179. : item.monitorcode === 'warnFlag'
  180. ? 'url(\'/static/model/9432.png\')'
  181. : item.monitorcode === 'netStatus'
  182. ? 'url(\'/static/model/9431.png\')'
  183. : item.monitorcode === 'm3'
  184. ? 'url(\'/static/model/windM3.png\')'
  185. : item.monitorcode === 'fsectarea'
  186. ? 'url(\'/static/model/duanArea.png\')'
  187. : item.monitorcode === 'incipientWindSpeed1' ||
  188. item.monitorcode === 'incipientWindSpeed2' ||
  189. item.monitorcode === 'incipientWindSpeed3' ||
  190. item.monitorcode === 'va'
  191. ? 'url(\'/static/model/fengsu.png\')'
  192. : 'url(\'\')',
  193. backgroundSize: '100% 100%',
  194. }"
  195. ></div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </view>
  201. </view>
  202. <view class="passwordPopup">
  203. <u-popup
  204. :show="show"
  205. mode="bottom"
  206. :round="14"
  207. :safeAreaInsetBottom="false"
  208. >
  209. <view style="margin-top: 15px" v-if="this.TabCur == 'window'"
  210. >风窗面积:</view
  211. >
  212. <u-input
  213. style="margin-top: 15px"
  214. v-model="windowArea"
  215. v-if="this.TabCur == 'window'"
  216. ></u-input>
  217. <view style="margin-top: 15px">请输入密码:</view>
  218. <u-input
  219. style="margin-top: 15px"
  220. v-model="password"
  221. type="password"
  222. ></u-input>
  223. <view class="btns">
  224. <u-button type="primary" shape="circle" @click="confirmPassword()"
  225. >确认</u-button
  226. >
  227. <u-button shape="circle" @click="cancelPassword()">取消</u-button>
  228. </view>
  229. </u-popup>
  230. </view>
  231. </view>
  232. </template>
  233. <script>
  234. import api from "@/api/api";
  235. import initDictOptions from "@/common/util/dictUtil.js";
  236. import doorAnimate from "../doorAnimate/doorAnimate.vue";
  237. import windowAnimate from "../windowAnimate/windowAnimate.vue";
  238. import windrectAnimate from "../windrectAnimate/windrectAnimate.vue";
  239. import fanlocalAnimate from "../fanlocalAnimate/fanlocalAnimate2.vue";
  240. export default {
  241. data() {
  242. return {
  243. timer: undefined,
  244. tableData: [], //监测数据
  245. typeList: [], //展示字段
  246. itemId: "", // 初始化 itemId
  247. name: "", // 初始化 name
  248. deviceid: "", //初始化设备id
  249. TabCur: "",
  250. checked: [],
  251. backPic: "url(../../../../static/topnavbar.png)",
  252. frontAngle: "", //风窗打开角度
  253. nwindownum: "", //风窗道数
  254. ndoorcount: "", //风门道数
  255. deviceType: "", //设备类型
  256. show: false, //密码弹窗是否显示
  257. password: "", //控制设备密码
  258. paramcode: "", //控制字段
  259. height: "200px",
  260. popupStyle: {
  261. // 弹窗样式
  262. "background-color": "#fff",
  263. padding: "20px",
  264. "box-shadow": "0 2px 4px rgba(0, 0, 0, 0.1)",
  265. },
  266. frontGateStatus: "", //前门状态
  267. rearGateStatus: "", //后门状态
  268. windowAngle: 0, //前窗打开角度
  269. windowAngle1: 0, //后窗打开角度
  270. windowArea: "", //风窗面积设定值
  271. viedeoUrl: "", //监控url
  272. sign:"",
  273. title:"测风设备",
  274. fan1State:'',
  275. fan2State:''
  276. };
  277. },
  278. onLoad(options) {
  279. // 通过 options 对象获取传递过来的参数
  280. const id = options.id;
  281. const name = options.name;
  282. const type = options.type;
  283. this.itemId = id;
  284. this.name = name;
  285. this.TabCur = type;
  286. this.ndoorcount = 2;
  287. },
  288. components: { doorAnimate, windowAnimate,windrectAnimate,fanlocalAnimate },
  289. async created() {
  290. await this.getShowList(this.TabCur);
  291. await this.getDeviceInfo(this.itemId);
  292. await this.getVideoUrlById(this.itemId);
  293. },
  294. mounted() {
  295. this.startTimer(false);
  296. },
  297. methods: {
  298. startTimer(flag = true) {
  299. this.timer = setTimeout(async() => {
  300. // 执行定时任务
  301. await this.getShowList(this.TabCur);
  302. await this.getDeviceInfo(this.itemId);
  303. if(this.timer){
  304. this.startTimer()
  305. }
  306. }, !flag ? 0 : 2000);
  307. },
  308. stopTimer() {
  309. // 停止定时器
  310. clearTimeout(this.timer);
  311. this.timer = undefined
  312. },
  313. // 返回上一个页面
  314. backPage() {
  315. this.$destroy();
  316. uni.navigateBack({
  317. delta: 1,
  318. });
  319. },
  320. //获取app展示字段数据
  321. getShowList(type) {
  322. const params = {
  323. devicekind: type,
  324. pagetype: "detail",
  325. pageNo: 1,
  326. pageSize: 100,
  327. };
  328. return new Promise((resolve, reject) => {
  329. api
  330. .getShowColumList(params)
  331. .then((response) => {
  332. if (response.data.code == 200) {
  333. this.typeList = response.data.result.records;
  334. } else {
  335. resolve(response);
  336. }
  337. })
  338. .catch((error) => {
  339. reject(error);
  340. });
  341. });
  342. },
  343. //获取详情数据
  344. getDeviceInfo(ID) {
  345. let IDString = String(ID); // 将 ID 转换为字符串
  346. return new Promise((resolve, reject) => {
  347. api
  348. .getDeviceMonitor({ devicetype: this.TabCur, ids: IDString })
  349. .then((response) => {
  350. if (response.data.code == 200 && response.data.result.msgTxt[0].datalist.length>0) {
  351. var result = response.data.result.msgTxt[0].datalist[0];
  352. this.tableData =
  353. result.readData;
  354. console.log('监测数据------------>', result)
  355. if (this.tableData.frontGateOpen == "1") {
  356. this.tableData.frontGateOpen = "打开";
  357. } else {
  358. this.tableData.frontGateOpen = "关闭";
  359. }
  360. if (this.tableData.midGateOpen == "1") {
  361. this.tableData.midGateOpen = "打开";
  362. } else {
  363. this.tableData.midGateOpen = "关闭";
  364. }
  365. if (this.tableData.rearGateOpen == "1") {
  366. this.tableData.rearGateOpen = "打开";
  367. } else {
  368. this.tableData.rearGateOpen = "关闭";
  369. }
  370. this.fan1State = result.readData.Fan1StartStatus
  371. this.fan2State = result.readData.Fan2StartStatus
  372. this.nwindownum =
  373. result.nwindownum;
  374. this.ndoorcount =
  375. result.ndoorcount;
  376. this.deviceType =
  377. result.deviceType;
  378. this.state =
  379. result.readData.sign;
  380. this.frontGateStatus = this.tableData.frontGateOpen;
  381. this.rearGateStatus = this.tableData.rearGateOpen;
  382. var maxarea = result.maxarea;
  383. this.windowAngle =
  384. (this.tableData.forntArea / maxarea) * 100 * 0.9;
  385. this.windowAngle1 =
  386. (this.tableData.rearArea / maxarea) * 100 * 0.9;
  387. this.$forceUpdate()
  388. resolve(null)
  389. } else {
  390. resolve(response);
  391. }
  392. })
  393. .catch((error) => {
  394. reject(error);
  395. });
  396. });
  397. },
  398. //获取监控URL 通过ID获取
  399. getVideoUrlById(ID) {
  400. let IDString = String(ID); // 将 ID 转换为字符串
  401. return new Promise((resolve, reject) => {
  402. api
  403. .getCameraById({ deviceid: IDString })
  404. .then((response) => {
  405. if (response.data.code == 200) {
  406. if(response.data.result.records.length>0){
  407. this.viedeoUrl = response.data.result.records[0].addr;
  408. }
  409. } else {
  410. resolve(response);
  411. }
  412. })
  413. .catch((error) => {
  414. reject(error);
  415. });
  416. });
  417. },
  418. //设备控制
  419. ctrlDevice(pass) {
  420. let IDString = String(this.itemId); // 将 ID 转换为字符串
  421. const params = {
  422. deviceid: IDString,
  423. devicetype: this.deviceType,
  424. paramcode: this.paramcode,
  425. password: pass,
  426. value: this.windowArea,
  427. };
  428. new Promise((resolve, reject) => {
  429. api
  430. .controlDevice(params)
  431. .then((response) => {
  432. if (response.data.code == 200) {
  433. this.getDeviceInfo(IDString);
  434. // console.log("操作成功");
  435. } else {
  436. resolve(response);
  437. }
  438. })
  439. .catch((error) => {
  440. reject(error);
  441. });
  442. });
  443. },
  444. // 显示密码输入弹窗
  445. showPasswordDialog(controlCode) {
  446. this.paramcode = controlCode;
  447. this.show = true;
  448. },
  449. // 取消密码输入
  450. cancelPassword() {
  451. this.show = false;
  452. },
  453. confirmPassword() {
  454. this.ctrlDevice(this.password);
  455. // 发起请求后关闭密码输入弹窗
  456. this.show = false;
  457. }
  458. },
  459. destroyed() {
  460. // 停止定时器
  461. this.stopTimer();
  462. },
  463. };
  464. </script>
  465. <style lang="scss">
  466. >>> .u-navbar--fixed {
  467. margin-top: 20px;
  468. }
  469. passwordPopup {
  470. height: 300rpx;
  471. background-color: #fff;
  472. }
  473. .top-nav {
  474. background-image: url(/static/topnavbar.png);
  475. background-size: cover; /* 背景图片大小适应 */
  476. height: 100%;
  477. }
  478. .top-nav2 {
  479. background-color: #ffffff;
  480. }
  481. .main {
  482. margin-top: 100rpx;
  483. }
  484. .container {
  485. display: flex;
  486. flex-direction: column;
  487. }
  488. .button-grid {
  489. display: grid;
  490. grid-template-columns: repeat(4, 1fr);
  491. gap: 5px; /* 可以根据需要调整行列之间的间距 */
  492. }
  493. .flcard {
  494. padding: 20rpx;
  495. background-color: #ffffff;
  496. margin-bottom: 5rpx;
  497. }
  498. .additional-div {
  499. grid-column: span 2; /* 让附加内容跨越三列 */
  500. display: flex;
  501. align-items: center;
  502. }
  503. .checkbox-group {
  504. margin-left: 10px; /* 可以根据需要调整间距 */
  505. }
  506. .card {
  507. background-color: #ffffff;
  508. margin: auto;
  509. margin-top: 20rpx;
  510. width: 90%;
  511. height: 280rpx;
  512. border: 1rpx solid #000000;
  513. border-radius: 20rpx;
  514. }
  515. .flex-container {
  516. display: flex;
  517. flex-direction: row;
  518. flex-wrap: wrap;
  519. }
  520. .itemback {
  521. width: calc(48% - 5px);
  522. // flex: 0 0 calc(33.33% - 10px); /* 使用calc函数计算每个项目的宽度,减去间距 */
  523. margin: 5px; /* 间距设置为5px */
  524. }
  525. .datacardtime {
  526. display: flex;
  527. width: 100%;
  528. flex: 1;
  529. margin: 1%;
  530. float: left;
  531. height: 50rpx;
  532. text-align: center;
  533. background: linear-gradient(
  534. to right,
  535. rgba(55, 135, 254, 0.08),
  536. rgba(4, 184, 255, 0.08),
  537. rgba(60, 161, 237, 0.08)
  538. );
  539. }
  540. .datacard {
  541. display: flex;
  542. /* width: 48%; */
  543. flex: 1;
  544. margin: 1%;
  545. /* float: left; */
  546. height: 100rpx;
  547. text-align: center;
  548. background: linear-gradient(
  549. to right,
  550. rgba(55, 135, 254, 0.08),
  551. rgba(4, 184, 255, 0.08),
  552. rgba(60, 161, 237, 0.08)
  553. );
  554. }
  555. .left-content {
  556. width: 50%;
  557. display: flex;
  558. flex-direction: column;
  559. }
  560. .spacer {
  561. height: 10rpx;
  562. }
  563. .right-content {
  564. width: 50%; /* 右侧内容占据50%宽度 */
  565. background-image: url(/static/model/Pa.png);
  566. background-size: 100% 125%;
  567. }
  568. .btns {
  569. display: flex;
  570. margin-top: 15px;
  571. }
  572. </style>