video.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div style="padding: 10px 15px">
  3. <el-row>
  4. <el-col :span="6" style="padding-right: 10px">
  5. <el-card class="box-card" style="min-height: 80vh;">
  6. <template #header>
  7. <div class="card-header">
  8. <span>视频设备</span>
  9. <div>
  10. <el-button v-if="isvideoshow" @click="isvideoshow=false">
  11. 返回
  12. </el-button></div>
  13. </div>
  14. </template>
  15. <div class="tree">
  16. <LayTree :data="data" :tail-node-icon="false" :onlyIconControl="true" v-model:selectedKey="selectedKey"
  17. @node-click="handleClick">
  18. <template #title="{ data }">
  19. <div style="display: flex;flex-direction: row;justify-content: space-around;">
  20. <div>{{ data.name }}</div>
  21. </div>
  22. </template>
  23. </LayTree>
  24. </div>
  25. </el-card>
  26. </el-col>
  27. <el-col :span="18" v-if="isvideoshow">
  28. <div style="height: 100%;">
  29. <!-- <div id="container" style="margin-top: 0px;width:100%;height:80vh"></div> -->
  30. <!-- <iframe id="FrameID" :key="currenturl" style="width: 100%;height:100%" :src="currenturl"/> -->
  31. <div v-if="currenturl==''||currenturl==null" id="container" style="margin-top: 0px;width:100%;height:80vh"></div>
  32. <iframe v-if="currenturl!=''&&currenturl!=null" id="FrameID" :key="currenturl" style="width: 100%;height:100%" :src="currenturl"/>
  33. </div>
  34. </el-col>
  35. <el-col :span="18" v-if="!isvideoshow">
  36. <el-card class="box-card">
  37. <div style="display: flex; flex-direction: row; justify-content: space-between">
  38. <div>
  39. <div style="
  40. display: flex;
  41. flex-direction: row;
  42. flex-wrap: nowrap;
  43. align-items: center;
  44. ">
  45. <div style="font-size: 12px; width: 80px">设备名称:</div>
  46. <el-input v-model="searchform.name" placeholder="设备名称"></el-input>
  47. </div>
  48. </div>
  49. <div>
  50. <el-button type="primary" plain>重置</el-button>
  51. <el-button type="danger" @click="deleteall" style="display: none">批量删除</el-button>
  52. <el-button type="primary" @click="getVideoList">搜索</el-button>
  53. </div>
  54. </div>
  55. </el-card>
  56. <el-card class="box-card" style="margin-top: 10px;">
  57. <template #header>
  58. <div class="card-header">
  59. <span>主要设备</span>
  60. <div>
  61. <el-button type="primary" @click="goAdd()" style="display: none">添加</el-button>
  62. <el-button type="warning" style="display: none">同步</el-button>
  63. </div>
  64. </div>
  65. </template>
  66. <el-row>
  67. <el-col :span="24" style="padding-left: 10px">
  68. <el-table :data="devicetabledata" :border="true" ref="tableref" >
  69. <el-table-column type="selection" width="55"></el-table-column>
  70. <el-table-column label="设备名称" prop="name"></el-table-column>
  71. <el-table-column label="平台编码" prop="sn"></el-table-column>
  72. <el-table-column label="设备类型" prop="type"></el-table-column>
  73. <el-table-column label="主要设备协议类型" prop="protocolType"></el-table-column>
  74. <el-table-column label="设备互联编码" prop="connectCode"></el-table-column>
  75. <el-table-column label="设备型号" prop="model"></el-table-column>
  76. </el-table>
  77. </el-col>
  78. <el-col :span="24" style="margin-top: 10px;">
  79. <el-pagination style="float: right;" small background layout="prev, pager, next" :total="pagedata.total"
  80. :page-size="pagedata.size" :current-page="pagedata.current" @current-change="onchangepage" class="mt-4" />
  81. </el-col>
  82. </el-row>
  83. </el-card>
  84. </el-col>
  85. </el-row>
  86. </div>
  87. </template>
  88. <script setup lang="ts" name="Units">
  89. import { ref } from "vue";
  90. import { useRoute, useRouter } from "vue-router";
  91. import { LayTree } from "@layui/layui-vue";
  92. import "@layui/layui-vue/lib/index.css";
  93. import { listVideo, getVideo, delVideo, addVideo, updateVideo } from "@/api/data/video";
  94. import { listVideoDetail, getVideoDetail, delVideoDetail, addVideoDetail, updateVideoDetail } from "@/api/data/videoDetail";
  95. import { ElMessage, ElMessageBox } from "element-plus";
  96. const isvideoshow = ref(false);
  97. const route = useRoute();
  98. const router = useRouter();
  99. const treeList = ref([])
  100. const currenturl = ref("");
  101. // const tableref = ref(null);
  102. const vidoeParams = ref({
  103. id: null,
  104. name: "",
  105. sn: "",
  106. type: "",
  107. protocolType: '',
  108. connectCode: "",
  109. model: "",
  110. videoFormat: "",
  111. vendorType: '',
  112. serialNumber: ''
  113. })
  114. const handleClick = (node) => {
  115. if (node.videoId != null) {
  116. searchform.value.id = node.videoId
  117. } else {
  118. searchform.value.id = node.id
  119. }
  120. isvideoshow.value = true;
  121. if (node.remark != null && node.remark != "") {
  122. currenturl.value = node.remark;
  123. } else {
  124. setTimeout(() => {
  125. var $container = document.getElementById('container');
  126. jessibuca = new Jessibuca({
  127. container: $container,
  128. videoBuffer: 0.2, // 缓存时长
  129. isResize: false,
  130. text: "",
  131. decoder:"/iot/jess/decoder.js",
  132. loadingText: "",
  133. useMSE: false,
  134. debug: true,
  135. showBandwidth: true, // 显示网速
  136. operateBtns: {
  137. fullscreen: true,
  138. screenshot: false,
  139. play: true,
  140. audio: false,
  141. recorder: false
  142. },
  143. forceNoOffscreen: true,
  144. isNotMute: false,
  145. },);
  146. jessibuca.play(node.voiceOutCode);
  147. }, 1000);
  148. }
  149. };
  150. const selectedKey = ref(1);
  151. const data = ref([
  152. {
  153. title: "大华西门nvr1",
  154. id: 1,
  155. checked: true,
  156. spread: true,
  157. children: [
  158. {
  159. title: "东门立柱摄像机",
  160. id: 2,
  161. href: "https://www.layui.com/",
  162. },
  163. {
  164. title: "东门立柱摄像机",
  165. id: 3,
  166. href: "https://www.layui.com/",
  167. },
  168. {
  169. title: "东门立柱摄像机",
  170. id: 4,
  171. href: "https://www.layui.com/",
  172. },
  173. {
  174. title: "东门立柱摄像机",
  175. id: 5,
  176. href: "https://www.layui.com/",
  177. },
  178. {
  179. title: "东门立柱摄像机",
  180. id: 6,
  181. href: "https://www.layui.com/",
  182. },
  183. ],
  184. },
  185. ]);
  186. const handleClickTitle = (data) => {
  187. console.log(data)
  188. }
  189. const pagedata = ref({
  190. total: 0,
  191. size: 10,
  192. current: 1
  193. });
  194. const devicetabledata = ref([1]);
  195. const searchform = ref({
  196. name: "",
  197. id: null,
  198. });
  199. const onchangepage = (page) => {
  200. pagedata.value.current = page;
  201. getVideoList();
  202. }
  203. // const godetail = () => {
  204. // router.push("/device/camera/detail")
  205. // }
  206. const godelVideo = (item) => {
  207. console.log(item)
  208. delVideo(item.id).then(res => {
  209. if (res.code == 200) {
  210. getVideoList();
  211. }
  212. })
  213. }
  214. const getVideoDetailList = () => {
  215. listVideoDetail({ pageSize: 10000 }).then(res => {
  216. console.log(treeList.value);
  217. treeList.value.forEach(video => {
  218. video.children = [];
  219. video["spread"] = true;
  220. video["disabled"] = true;
  221. res.rows.forEach(detail => {
  222. if (video.id == detail.videoId) {
  223. detail.name = detail.cameraName
  224. video.children.push(detail);
  225. }
  226. })
  227. })
  228. console.log(treeList.value);
  229. data.value = treeList.value
  230. return res
  231. })
  232. }
  233. const tableref = ref(null);
  234. const deleteall = () => {
  235. let selected = tableref.value.getSelectionRows();
  236. if (selected.length == 0) {
  237. ElMessage.warning("请选择要删除的行");
  238. return;
  239. }
  240. if (selected.length > 0) {
  241. ElMessageBox.confirm(
  242. `是否删除${selected.length}条数据`,
  243. "警告",
  244. {
  245. confirmButtonText: "确认",
  246. cancelButtonText: "取消",
  247. type: 'warning',
  248. }
  249. ).then(() => {
  250. delVideo(selected.map(i => i.id).join(",")).then((res) => {
  251. ElMessage.success("删除成功");
  252. getVideoList();
  253. getVideoDeviceList();
  254. })
  255. });
  256. }
  257. }
  258. function getVideoDeviceList() {
  259. listVideo({ pageSize: 10000 }).then(res => {
  260. treeList.value = res.rows;
  261. getVideoDetailList()
  262. })
  263. }
  264. const goDetail = (item ) => {
  265. router.push({ path: '/device/camera/detail',query: { id: item.id } })
  266. }
  267. const getVideoList = () => {
  268. console.log(searchform.value);
  269. listVideo({ ...searchform.value, pageSize: pagedata.value.size, pageNum: pagedata.value.current }).then(res => {
  270. devicetabledata.value = res.rows
  271. })
  272. }
  273. const goAdd = () => {
  274. router.push({ path: '/device/camera/add'})
  275. }
  276. const goUpdate = (item) => {
  277. router.push({ path: '/device/camera/add', query: { id: item.id } })
  278. }
  279. getVideoDeviceList();
  280. getVideoList();
  281. // const res = videoTreeList();
  282. // console.log(res);
  283. </script>
  284. <style></style>
  285. <style lang="scss" scoped>
  286. .card-header {
  287. display: flex;
  288. flex-direction: row;
  289. justify-content: space-between;
  290. }
  291. .tree {
  292. *,
  293. *:before,
  294. *:after {
  295. box-sizing: content-box !important;
  296. }
  297. }
  298. </style>
  299. <style lang="scss">
  300. .layui-disabled{
  301. color: #000 !important;
  302. }
  303. #container {
  304. background: rgba(13, 14, 27, 0.7);
  305. width: 50vw;
  306. height: 398px;
  307. }
  308. </style>