home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <!-- <div class="container" > -->
  3. <Header />
  4. <!-- <div @click="isShowLeftAndRight =!isShowLeftAndRight" style="position:fixed;top:10px;left:10px;width:50px;height:50px;background-color:red;z-index:99999"></div> -->
  5. <img class="bg-shadow" :src="bgShadow" alt="" srcset="">
  6. <div v-show="isShowLeftAndRight">
  7. <Left ref="childRef" @childMethod="childMethod" :isShow="isShowLeftAndRight"></Left>
  8. </div>
  9. <right v-if="isShowLeftAndRight"></right>
  10. <div ref="linedomRef" style="
  11. width: 1px;
  12. height: 1px;
  13. position: absolute;
  14. z-index: 228;
  15. background: #ccc;
  16. "></div>
  17. <!-- </el-container> -->
  18. <div ref="popoverRef" id="popoverRef" class="modelInfo">
  19. <div v-if="orientation == 'Left' || orientation == 'Right'" class="model-detail">
  20. <div v-for="item in classDeviceInfo" class="listbox">
  21. <div class="list">
  22. {{ item[0].value }}
  23. </div>
  24. <div v-for="item2 in item" class="listtitle">
  25. <div v-if="item2.name !== '设备名称'" style="height: 30px; display: flex; align-items: center">
  26. <span class="name"> {{ item2.name }} :</span>
  27. <span v-if="item2.value != '在线'" class="value">{{
  28. item2.value
  29. }}</span>
  30. <span v-else style="font-family: 100; margin-left: 5px; color: #10c383">{{ item2.value }}</span>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <div v-else class="model-detail2">
  36. <div style="display: flex">
  37. <div v-for="item in classDeviceInfo" class="listbox2">
  38. <div class="list" style="text-align: center; width: 100%">
  39. {{ item[0].value }}
  40. </div>
  41. <div class="listtitlebox">
  42. <div v-for="item2 in item" class="listtitle">
  43. <div v-if="item2.name !== '设备名称'">
  44. <span class="name"> {{ item2.name }} :</span>
  45. <span v-if="item2.value != '在线'" class="value" style="font-weight: 400">{{ item2.value }}</span>
  46. <span v-else style="font-family: 100; margin-left: 5px; color: #10c383">{{ item2.value }}</span>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- 视频播放弹框 -->
  55. <el-dialog class="videoDialog" v-model="videoDialog" :title="titleDialog" width="62%" align="center" top="7%"
  56. style="padding: 0">
  57. <videoPlay v-bind="videoData" @play="onPlay" />
  58. </el-dialog>
  59. <el-dialog class="deviceDialog" v-model="deviceDialog" title="设备明细" width="40%" align="left" top="30vh"
  60. style="z-index: 2015; background: rgba(0, 0, 0, 0); padding: 0px">
  61. <el-table :data="deviceDetailsList" border :resizable="false" height="350px"
  62. style="width: 100%; background: rgba(0, 0, 0, 0)">
  63. <el-table-column align="center" type="index" label="序号" width="100px"></el-table-column>
  64. <el-table-column align="center" prop="device_name" label="设备名称"></el-table-column>
  65. <el-table-column align="center" prop="heart_status" label="设备状态">
  66. <template #default="scope">
  67. <div :class="{
  68. normal: scope.row.heart_status == 1,
  69. error: scope.row.heart_status == 0,
  70. }">
  71. <div>{{ scope.row.heart_status == 1 ? "在线" : "异常" }}</div>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" align="center">
  76. <template #default="scope">
  77. <el-button type="primary" size="mini" @click="lookDetails(scope.row)">详情</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. <el-dialog class="deviceDetailsDialog" v-model="isShowDeviceDetails" title="详情" width="15%" align="left" top="40vh"
  82. style="z-index: 2019; background: rgba(0, 0, 0, 0); padding: 0px" :modal="false">
  83. <div class="details-container">
  84. <div>设备名称:{{ deviceDetails.device_name }}</div>
  85. <div>
  86. 设备状态:<span :style="{
  87. color: deviceDetails.heart_status == 1 ? '#30fcaa' : '#ff352e',
  88. }">{{ deviceDetails.heart_status == 1 ? "在线" : "异常" }}</span>
  89. </div>
  90. <div>位置:{{ deviceDetails.teach_name }}</div>
  91. <div>型号:{{ deviceDetails.device_type_name }}</div>
  92. <!-- <div>质保期:5年</div> -->
  93. </div>
  94. </el-dialog>
  95. </el-dialog>
  96. <!-- </div> -->
  97. </template>
  98. <script>
  99. import {
  100. reactive,
  101. onMounted,
  102. ref,
  103. toRefs,
  104. onBeforeUnmount,
  105. getCurrentInstance,
  106. nextTick,
  107. } from "vue";
  108. import {
  109. ElScrollbar,
  110. ElPagination,
  111. ElDialog,
  112. ElCarousel,
  113. ElCarouselItem,
  114. ElMessage,
  115. } from "element-plus";
  116. import "vue3-video-play/dist/style.css";
  117. // import { addResponseEventListener } from "../webrtcVideo.js";
  118. import { videoPlay } from "vue3-video-play";
  119. import CircleProgress from "./CircleProgress.vue";
  120. import Left from "./left.vue";
  121. import Right from "./right.vue";
  122. import Login from "./Login.vue";
  123. import LeaderLine from "../../public/js/leaderline.js";
  124. import { getClassDetail } from "../request/api.js";
  125. import Header from "./Header.vue";
  126. // import {
  127. // callUIInteraction,
  128. // } from "../webrtcVideo";
  129. import { getVideoUrl, equipmentDetailsApi } from "../request/api";
  130. export default {
  131. name: "Histogram",
  132. components: {
  133. Login,
  134. Left,
  135. Right,
  136. ElScrollbar,
  137. ElPagination,
  138. ElDialog,
  139. videoPlay,
  140. ElCarousel,
  141. ElCarouselItem,
  142. CircleProgress,
  143. Header,
  144. },
  145. setup() {
  146. const titleDialog = ref("");
  147. const orientation = ref("");
  148. // const isShowLeft = ref(true);
  149. // const isShowRight = ref(true);
  150. const isShowLeftAndRight = ref(true);
  151. // const isShowLeftAndRight = ref(true);
  152. // 视频数据
  153. const videoData = reactive({
  154. width: "100%", //播放器高度
  155. height: "66.5vh", //播放器高度
  156. color: "red", //主题色
  157. title: "互动教室", //视频名称
  158. // src: "https://cdn.jsdelivr.net/gh/xdlumia/files/video-play/IronMan.mp4", //视频源
  159. type: "m3u8",
  160. src: "",
  161. muted: false, //静音
  162. webFullScreen: false,
  163. // speedRate: ["0.75", "1.0", "1.25", "1.5", "2.0"], //播放倍速
  164. autoPlay: false, //自动播放
  165. loop: false, //循环播放
  166. mirror: false, //镜像画面
  167. ligthOff: false, //关灯模式
  168. volume: 0.3, //默认音量大小
  169. control: true, //是否显示控制
  170. currentTime: 0, //跳转到固定播放时间
  171. controlBtns: [
  172. "audioTrack",
  173. "quality",
  174. "speedRate",
  175. "volume",
  176. "setting",
  177. "pip",
  178. "pageFullScreen",
  179. "fullScreen",
  180. ], //显示所有按钮,
  181. });
  182. // 物联设备类型统计
  183. const interDevice = ref([]);
  184. // 位置弹框
  185. let centerDialogVisible = ref(false);
  186. // 获取点击点数据
  187. let clickData = reactive({});
  188. const triggerRef = ref({
  189. getBoundingClientRect() {
  190. // console.log("positon----方法返回元素的大小及其相对于视口的位置", position.value)
  191. return position.value;
  192. },
  193. });
  194. const position = ref({
  195. top: 0,
  196. left: 0,
  197. bottom: 0,
  198. right: 0,
  199. });
  200. // 点击某个模型跟随移动
  201. const mousemoveHandler = (x, y) => {
  202. position.value = DOMRect.fromRect({
  203. width: 0,
  204. height: 0,
  205. x: x,
  206. y: y,
  207. });
  208. };
  209. //视频播放弹框
  210. const videoDialog = ref(false);
  211. // 播放视频
  212. const lookVideo = function () {
  213. videoDialog.value = true;
  214. console.log("点击了播放视频", 12312312);
  215. };
  216. // 播放视频
  217. const onPlay = function () {
  218. console.log("播放视频");
  219. };
  220. const linedomRef = ref(null);
  221. let lineContainer = ref(null);
  222. const popoverRef = ref(null);
  223. const lineStyleOption = ref({
  224. startPlug: "disc",
  225. endPlug: "disc",
  226. dash: true,
  227. color: "#2AC367",
  228. startPlugColor: "#fff",
  229. startPlugOutlineColor: "#2AC367",
  230. endPlugColor: "#fff", // translucent
  231. endPlugOutlineColor: "#2AC367",
  232. size: 3,
  233. startPlugSize: 1.5,
  234. startPlugOutlineSize: 2,
  235. endPlugSize: 1.5,
  236. endPlugOutlineSize: 2,
  237. });
  238. const classDeviceInfo = ref([]);
  239. const classDataLoaded = ref(false);
  240. // const classDevice = async function (deviceCode) {
  241. // let res = await getClassDetail(deviceCode)
  242. // console.log("获取到了当前点击物体得详情", res)
  243. // classDeviceInfo.value = res.data;
  244. // classDataLoaded.value = true
  245. // }
  246. const clickData1 = ref({});
  247. const mouseClick = function (e) {
  248. // console.log("屏幕点击位置看", e)
  249. clickData1.value.x = e.clientX;
  250. clickData1.value.y = e.clientY;
  251. };
  252. //消失线的方法
  253. const childMethod = () => {
  254. if (lineContainer.value) {
  255. lineContainer.value.remove();
  256. lineContainer.value = null;
  257. }
  258. };
  259. const childRef = ref(null);
  260. let isShowDeviceDetails = ref(false);
  261. let deviceDialog = ref(false);
  262. let deviceDetailsList = ref([
  263. ]);
  264. let deviceDetails = ref({});
  265. const lookDetails = (data) => {
  266. console.log("darta", data);
  267. isShowDeviceDetails.value = true;
  268. deviceDetails.value = data;
  269. };
  270. const handleResponseFunction = (data) => {
  271. console.log("从UE返回过来的值", data);
  272. popoverRef.value.style.display = "none";
  273. if (lineContainer.value) {
  274. lineContainer.value.remove();
  275. lineContainer.value = null;
  276. }
  277. //如果退出教室
  278. if (data == "quit_class") {
  279. //消失线
  280. if (lineContainer.value) {
  281. lineContainer.value.remove();
  282. lineContainer.value = null;
  283. }
  284. //消失点击详情
  285. popoverRef.value.style.display = "none";
  286. //消失面板
  287. if (childRef.value) {
  288. childRef.value.clearPanel();
  289. }
  290. return;
  291. }
  292. if (data == "{isrotate}") {
  293. // console.log("旋转场景了", lineContainer, lineContainer.value);
  294. if (lineContainer.value) {
  295. lineContainer.value.remove();
  296. lineContainer.value = null;
  297. }
  298. popoverRef.value.style.display = "none";
  299. return;
  300. }
  301. let json = eval("(" + data + ")"); //转对象
  302. console.log("clickData---点击的数据", json);
  303. if (json.url) {
  304. videoDialog.value = true;
  305. titleDialog.value = json.name;
  306. getVideoUrl({ rtsp: json.url }).then((res) => {
  307. videoData.src = res.data.httpFlv;
  308. console.log("32424", videoData.src);
  309. });
  310. return;
  311. }
  312. clickData.value = json;
  313. orientation.value = clickData.value.direction;
  314. console.log("看看这个", clickData.value.direction);
  315. if (json.deviceCode) {
  316. console.log("sadasd", json.deviceCode);
  317. let replacedStr = json.deviceCode.replace(/\//g, "A");
  318. // let replacedStr = replacedStr2.replace("/", "A");
  319. console.log("replacedStr", replacedStr);
  320. getClassDetail(replacedStr).then((res) => {
  321. console.log("sad21312", res);
  322. classDeviceInfo.value = res.data;
  323. console.log("asd2121", classDeviceInfo.value);
  324. // classDeviceInfo.value.map(i => {
  325. // if (i.value == "在线") {
  326. // i.online = true
  327. // }
  328. // if (i.value == "离线") {
  329. // i.online = false
  330. // }
  331. // })
  332. console.log("json.y ", json);
  333. linedomRef.value.style.top = clickData.value.y + "px";
  334. linedomRef.value.style.left = clickData.value.x + "px";
  335. console.log("可以开始移动");
  336. console.log("看一下---小圆点的值--top", linedomRef.value.style.top);
  337. console.log("看一下---小圆点的值--left", linedomRef.value.style.left);
  338. // 弹出框位置
  339. popoverRef.value.style.display = "block";
  340. switch (json.direction) {
  341. case "Left":
  342. popoverRef.value.style.top = json.y - 30 + "px";
  343. popoverRef.value.style.left = json.x - 320 + "px";
  344. break;
  345. case "Up":
  346. popoverRef.value.style.top = json.y - 300 + "px";
  347. popoverRef.value.style.left = json.x - 120 + "px";
  348. break;
  349. case "Right":
  350. popoverRef.value.style.top = Number(json.y) - 150 + "px";
  351. popoverRef.value.style.left = Number(json.x) + 100 + "px";
  352. break;
  353. case "Down":
  354. popoverRef.value.style.top = Number(json.y) + 100 + "px";
  355. popoverRef.value.style.left = Number(json.x) + "px";
  356. break;
  357. default:
  358. popoverRef.value.style.top = json.y - 60 + "px";
  359. popoverRef.value.style.left = json.x + "px";
  360. break;
  361. }
  362. if (lineContainer.value) {
  363. lineContainer.value.remove();
  364. }
  365. lineContainer.value = new LeaderLine(
  366. linedomRef.value,
  367. popoverRef.value,
  368. lineStyleOption.value
  369. );
  370. lineContainer.value.show("draw", {
  371. duration: 100, //持续时长
  372. timing: "ease-in", // 动画函数
  373. });
  374. lineContainer.value.endPlugOutline = true;
  375. lineContainer.value.startPlugOutline = true;
  376. lineContainer.value.position();
  377. });
  378. }
  379. console.log("data---------------------", JSON.parse(data));
  380. if (JSON.parse(data).MainServiceName == "JianKong") {
  381. getVideoUrl({ rtsp: JSON.parse(data).MonitorURL }).then((res) => {
  382. videoData.src = res.data.httpFlv;
  383. // videoData.src =
  384. // "https://weizhi.huanghuai.edu.cn/jk/hls/9159eba9-b4c6-4a4b-a8ff-a1dd94c88bae.m3u8";
  385. videoDialog.value = true;
  386. });
  387. }
  388. if (JSON.parse(data).MainServiceName == "SheBeiLieBiao") {
  389. equipmentDetailsApi(JSON.parse(data).ClassroomCode).then((res) => {
  390. deviceDialog.value = true;
  391. deviceDetailsList.value = res.data;
  392. });
  393. }
  394. if (JSON.parse(data).MainServiceName == "KanBanShouQi") {
  395. console.log("看板收起展开", JSON.parse(data));
  396. let isShow = JSON.parse(data).PutAwayState == "true" ? true : false;
  397. //localStorage.setItem("isShow-left-Right", isShow);
  398. isShowLeftAndRight.value = isShow;
  399. // isShowLeftAndRight = isShow;
  400. // isShowLeft.value = JSON.parse(data).PutAwayState == "true" ? true : false;
  401. // isShowRight.value = JSON.parse(data).PutAwayState == "true" ? true : false;
  402. }
  403. };
  404. const windowSize = function () {
  405. // console.log("监听一下窗口是不是改了--click", lineContainer);
  406. callUIInteraction("windowSize");
  407. };
  408. onMounted(() => {
  409. setTimeout(() => {
  410. addResponseEventListener("444", handleResponseFunction);
  411. }, 500)
  412. // isShowLeftAndRight.value = localStorage.getItem("isShow-left-Right") == "true" ? true : false;
  413. // window.addEventListener("resize", windowSize);
  414. // addResponseEventListener("jiankong", openVideo);
  415. // window.addEventListener('click', windowSize);
  416. // addResponseEventListener("widowSizeChange", windoChangeFunction);
  417. });
  418. const headImg = ref("./img/head.png");
  419. const bgShadow = ref("./img/bg-shadow.png");
  420. return {
  421. centerDialogVisible,
  422. interDevice,
  423. clickData,
  424. triggerRef,
  425. videoData,
  426. onPlay,
  427. videoDialog,
  428. lookVideo,
  429. linedomRef,
  430. popoverRef,
  431. lineContainer,
  432. classDeviceInfo,
  433. mouseClick,
  434. headImg,
  435. titleDialog,
  436. orientation,
  437. childMethod,
  438. childRef,
  439. bgShadow,
  440. isShowDeviceDetails,
  441. lookDetails,
  442. deviceDetailsList,
  443. deviceDialog,
  444. deviceDetails,
  445. isShowLeftAndRight
  446. };
  447. },
  448. };
  449. </script>
  450. <style scoped lang="scss">
  451. @import "../assets/css/home.scss";
  452. :deep(.el-dialog__header) {
  453. height: 49px;
  454. line-height: 49px;
  455. padding: 0;
  456. background-color: #1b67d9;
  457. margin-right: 0;
  458. }
  459. </style>