home.vue 16 KB

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