dataScreen.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="screen">
  3. <div style="height: 10px"></div>
  4. <div class="titleImage">
  5. <el-image :src="titleUrl" />
  6. <span class="Heading">龙弛智慧隧道系统</span>
  7. <div class="titleOption" style="left: 19%" @click="jumpScreen('map')">
  8. <span>地图</span>
  9. </div>
  10. <div class="titleOption" style="left: 76%" @click="jumpScreen('model')">
  11. <span>模型</span>
  12. </div>
  13. </div>
  14. <div style="height: 10px"></div>
  15. <el-row>
  16. <el-col :span="5" style="height: 900px;">
  17. <div class="deviceBox">
  18. <img src="@/assets/main_top_left.png" alt=""/>
  19. <div class="titleIcon"></div>
  20. <div class="deviceBox_title">设备汇总</div>
  21. <div class="deviceOptionBox">
  22. <div class="deviceOption" v-for="item in deviceList">
  23. <img :src="item.url" style="width: 35px;height: 35px" alt=""/>
  24. <el-text style="padding-top: 8px;color: #ffffff" size="small">{{item.label + item.value}}</el-text>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="chartBox">
  29. <Chart/>
  30. </div>
  31. <div class="chartBox">
  32. <lightChart/>
  33. </div>
  34. </el-col>
  35. <el-col :span="14" style="display: flex;justify-content: center">
  36. <div class="centerBox">
  37. <Map @call-parent="parentMethod"/>
  38. </div>
  39. </el-col>
  40. <el-col :span="5" class="rightBox">
  41. <div style="height: 20px"></div>
  42. <div class="panel">
  43. <span class="panel-title">亮度调整</span>
  44. <el-slider
  45. v-model="transparency"
  46. :step="50"
  47. show-stops
  48. :show-tooltip="false"
  49. class="panel-slider"
  50. @change="changeTransparency"
  51. />
  52. <div class="brightness" style="margin: 90px 0 0 50px;">
  53. <span>低</span>
  54. <span>中</span>
  55. <span>高</span>
  56. </div>
  57. <el-slider
  58. v-model="transparencyTwo"
  59. :step="50"
  60. show-stops
  61. :show-tooltip="false"
  62. class="panel-slider2"
  63. @change="changeTransparencyTwo"
  64. />
  65. <div class="brightness" style="margin: 50px 0 0 50px;">
  66. <span>低</span>
  67. <span>中</span>
  68. <span>高</span>
  69. </div>
  70. <div class="panel-bottom"></div>
  71. </div>
  72. <div class="warnBox">
  73. <img :src="warn" alt="" class="warnBoxExternal" />
  74. <img :src="warnTitle" alt="" class="warnBoxTitle"/>
  75. <span>警告列表</span>
  76. </div>
  77. </el-col>
  78. </el-row>
  79. </div>
  80. </template>
  81. <script setup>
  82. // 标题图片
  83. import titleUrl from '@/assets/title_bg.png'
  84. import environments from "@/assets/icons/environment.png";
  85. import fourWays from "@/assets/icons/fourWays.png"
  86. import inductance from "@/assets/icons/inductance.png"
  87. import singleLamp from "@/assets/icons/singleLamp.png"
  88. import Chart from "./components/chart.vue";
  89. import warn from '@/assets/main_bottopm_top2.png'
  90. import Map from './components/map.vue'
  91. import warnTitle from '@/assets/warnTitle.png'
  92. import lightChart from './components/lightChart.vue'
  93. import { queryTunnelList } from '@/api/tunnel'
  94. import {reactive, onMounted, ref, watch} from 'vue'
  95. // 单灯控制
  96. import { updateTunnelLamp } from "@/api/tunnel";
  97. // 四路控制
  98. import { deviceSwitch } from "@/api/device";
  99. import {useScreenStore} from "@/pinia/modules/screen";
  100. import {ElMessage} from "element-plus";
  101. // 灯光数据
  102. const lampData = reactive({})
  103. const useScreen = useScreenStore()
  104. const deviceList = reactive([
  105. {url: environments, label: '环境:', value: '1/0'},
  106. {url: fourWays, label: '四路:', value: '1/0'},
  107. {url: inductance, label: '电感:', value: '1/0'},
  108. {url: singleLamp, label: '单灯:', value: '1/0'},
  109. ])
  110. const condition = {
  111. pageInfo: {
  112. page: 1,
  113. pageSize: 1000
  114. },
  115. name: '',
  116. regionId: 0,
  117. userId: 1
  118. }
  119. // 存储模型数据
  120. let materialOne = reactive({})
  121. let materialTwo = reactive({})
  122. // 亮度调整
  123. const transparency = ref(0)
  124. const relayList = reactive([])
  125. const changeTransparency = (e) => {
  126. let option = {
  127. 0: [0.8, 33, 1],
  128. 50: [0.5, 66, 2],
  129. 100: [0.2, 100, 3]
  130. }
  131. materialOne.opacity = option[e][0]
  132. if (lampData.switchType === '单灯控制器') {
  133. updateTunnelLamp({
  134. id: lampData.ID,
  135. tunnelSn: lampData.tunnelSn,
  136. lampValue1: option[e][1]
  137. }).then(res => {
  138. if (res.code === 0) {
  139. ElMessage.success('已发送')
  140. }
  141. })
  142. } else {
  143. let relay = relayList[0].deviceRelays
  144. console.log(relayList[0])
  145. for (let i = 0; i < relay.length; i++) {
  146. relay[i].state = i < option[e][2];
  147. }
  148. for (let j = 0; j < relay.length; j++) {
  149. deviceSwitch({
  150. tunnelSn: lampData.tunnelSn,
  151. radarId: relayList[0].radarId,
  152. relayId: relay[j].relayId,
  153. state: relay[j].state
  154. }).then(res => {
  155. if (res.code === 0) {
  156. console.log('发送成功')
  157. }
  158. })
  159. }
  160. }
  161. }
  162. const transparencyTwo = ref(0)
  163. const changeTransparencyTwo = (e) => {
  164. let option = {
  165. 0: [0.8, 33, 1],
  166. 50: [0.5, 66, 2],
  167. 100: [0.2, 100, 3]
  168. }
  169. materialTwo.opacity = option[e][0]
  170. if (lampData.switchType === '单灯控制器') {
  171. updateTunnelLamp({
  172. id: lampData.ID,
  173. tunnelSn: lampData.tunnelSn,
  174. lampValue2: option[e][1]
  175. }).then(res => {
  176. if (res.code === 0) {
  177. ElMessage.success('已发送')
  178. }
  179. })
  180. } else {
  181. let relay = relayList[1].deviceRelays
  182. for (let i = 0; i < relay.length; i++) {
  183. if (i < option[e][2]) {
  184. relay[i].state = true
  185. } else {
  186. relay[i].state = false
  187. }
  188. }
  189. for (let j = 0; j < relay.length; j++) {
  190. deviceSwitch({
  191. tunnelSn: lampData.tunnelSn,
  192. radarId: relayList[1].radarId,
  193. relayId: relay[j].relayId,
  194. state: relay[j].state
  195. }).then(res => {
  196. if (res.code === 0) {
  197. console.log('发送成功');
  198. }
  199. })
  200. }
  201. }
  202. }
  203. const parentMethod = (e) => {
  204. console.log('子组件调用了')
  205. console.log(e)
  206. }
  207. const brightness = () => {
  208. if (lampData.switchType === '单灯控制器') {
  209. let val1 = lampData.lampValue1
  210. let val2 = lampData.lampValue2
  211. let judge = {
  212. 0:[0.8,0],
  213. 33: [0.8,0],
  214. 66: [0.5,50],
  215. 100: [0.2,100],
  216. }
  217. transparency.value = judge[val1][1]
  218. transparencyTwo.value = judge[val1][1]
  219. materialOne.opacity = judge[val1][0]
  220. materialTwo.opacity = judge[val2][0]
  221. } else if(lampData.switchType === '四路控制器') {
  222. relayList.length = 0
  223. lampData.devices.forEach(item => {
  224. if (item.genre === 6) {
  225. relayList.push(item)
  226. }
  227. })
  228. let deviceLamp1 = relayList[0].deviceRelays
  229. let deviceLamp2 = relayList[1].deviceRelays
  230. let count1 = 0
  231. let count2 = 0
  232. deviceLamp1.forEach(item => {
  233. item.state ? count1++ : count1
  234. })
  235. deviceLamp2.forEach(item => {
  236. item.state ? count2++ : count2
  237. })
  238. let judgeWay = {
  239. 0: [0.8,0],
  240. 1: [0.8,0],
  241. 2: [0.5,50],
  242. 3: [0.2,100],
  243. 4: [0.2,100]
  244. }
  245. transparency.value = judgeWay[count1][1]
  246. transparencyTwo.value = judgeWay[count2][1]
  247. materialOne.opacity = judgeWay[count1][0]
  248. materialTwo.opacity = judgeWay[count2][0]
  249. }
  250. }
  251. onMounted(() => {
  252. queryTunnelList(condition).then(res => {
  253. if (res.code === 0) {
  254. useScreen.setTunnelList(res.data)
  255. Object.assign(lampData, res.data.list[0])
  256. brightness()
  257. }
  258. })
  259. })
  260. watch(() => useScreen.currentTunnel, (newValue, oldValue) => {
  261. yourMethod(newValue) // 调用你的方法
  262. })
  263. const yourMethod = (value) => {
  264. Object.assign(lampData, value)
  265. brightness()
  266. }
  267. </script>
  268. <style scoped lang="less">
  269. .horn {
  270. position: absolute;
  271. content: "";
  272. width: 10px;
  273. height: 10px;
  274. }
  275. .screen{
  276. width: 100%;
  277. height: 1000px;
  278. //background-image: url("@/assets/back.jpeg");
  279. background-size:100% 100%;
  280. background: #2d407d url("@/assets/line.png");
  281. .titleImage {
  282. width: 100%;
  283. height: 70px;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. position: relative;
  288. .Heading{
  289. position: absolute;
  290. left: 42%;
  291. top: 25%;
  292. text-align: center;
  293. font-size: 1.7vw;
  294. font-weight: bold;
  295. color: #0EFCFF;
  296. }
  297. .titleOption{
  298. position: absolute;
  299. top: 7px;
  300. width: 100px;
  301. height: 32px;
  302. border: 1px solid #0EFCFF;
  303. color: #0EFCFF;
  304. display: flex;
  305. align-items: center;
  306. justify-content: center;
  307. font-size: 16px;
  308. }
  309. }
  310. .deviceBox {
  311. width: 400px;
  312. height: 180px;
  313. margin: 20px;
  314. position: relative;
  315. pointer-events: auto;
  316. img {
  317. width: 400px;
  318. height: 180px;
  319. }
  320. .deviceBox_title {
  321. position: absolute;
  322. left: 30px;
  323. top: 15px;
  324. font-size: 20px;
  325. color: #0EFCFF;
  326. }
  327. .deviceOptionBox {
  328. position: absolute;
  329. top: 70px;
  330. width: 400px;
  331. height: 60px;
  332. display: flex;
  333. justify-content: space-around;
  334. align-items: center;
  335. .deviceOption {
  336. width: 90px;
  337. height: 60px;
  338. display: flex;
  339. flex-direction: column;
  340. align-items: center;
  341. color: #ffffff;
  342. }
  343. }
  344. }
  345. .titleIcon{
  346. width: 5px;
  347. height: 20px;
  348. background-color: #0EFCFF;
  349. position: absolute;
  350. left: 20px;
  351. top: 16px;
  352. }
  353. .chartBox{
  354. width: 450px;
  355. height: 250px;
  356. margin: 20px;
  357. position: relative;
  358. pointer-events: auto;
  359. }
  360. .rightBox{
  361. height: 900px;
  362. .warnBox{
  363. position: relative;
  364. width: 400px;
  365. height: 300px;
  366. margin: 20px 0 0 20px;
  367. .warnBoxExternal{
  368. width: 400px;
  369. height: 270px;
  370. }
  371. .warnBoxTitle{
  372. width: 200px;
  373. height: 35px;
  374. position: absolute;
  375. left: 20px;
  376. top: 30px;
  377. }
  378. span{
  379. color:#ffffff;
  380. font-size: 18px;
  381. position: absolute;
  382. left: 70px;
  383. top: 37px;
  384. }
  385. }
  386. .panel{
  387. position: relative;
  388. width: 400px;
  389. height: 200px;
  390. margin-left: 20px;
  391. border: 1px solid rgba(25,186,139,0.17);
  392. padding: 0 0.1875rem 0.5rem;
  393. margin-bottom: 0.1875rem;
  394. background: url(@/assets/line.png) rgba(255,255,255,0.04);
  395. &::before{
  396. .horn;
  397. top: 0;
  398. left: 0;
  399. border-left: 2px solid #02a6b5;
  400. border-top: 2px solid #02a6b5;
  401. }
  402. &::after{
  403. .horn;
  404. top: 0;
  405. right: 0;
  406. border-right: 2px solid #02a6b5;
  407. border-top: 2px solid #02a6b5;
  408. }
  409. .panel-bottom{
  410. &::before{
  411. .horn;
  412. bottom: 0;
  413. left: 0;
  414. border-left: 2px solid #02a6b5;
  415. border-bottom: 2px solid #02a6b5;
  416. }
  417. &::after{
  418. .horn;
  419. bottom: 0;
  420. right: 0;
  421. border-right: 2px solid #02a6b5;
  422. border-bottom: 2px solid #02a6b5;
  423. }
  424. }
  425. .panel-title{
  426. position: absolute;
  427. left: 160px;
  428. top: 10px;
  429. font-size: 20px;
  430. font-weight: bold;
  431. color: #0EFCFF;
  432. }
  433. .panelSwitchTitle{
  434. color: #ffffff;
  435. font-size: 16px;
  436. position: absolute;
  437. bottom: 30px;
  438. font-weight: bold;
  439. left:25px;
  440. }
  441. .panelSwitch{
  442. position: absolute;
  443. right: 25px;
  444. bottom: 20px;
  445. }
  446. .panel-slider{
  447. width: 300px;
  448. position: absolute;
  449. top: 60px;
  450. left: 50px;
  451. }
  452. .panel-slider2{
  453. width: 300px;
  454. position: absolute;
  455. top: 120px;
  456. left: 50px;
  457. }
  458. .brightness{
  459. width: 300px;
  460. display: flex;
  461. justify-content: space-between;
  462. color: #909399;
  463. font-size: 14px;
  464. }
  465. }
  466. }
  467. }
  468. .dataBox{
  469. width: 200px;
  470. height: 150px;
  471. background-color: #283a72;
  472. }
  473. .centerBox{
  474. width: 1150px;
  475. height: 700px;
  476. border-radius: 10px;
  477. margin-top: 20px;
  478. }
  479. </style>