VideoMonitor.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <div class="video-card">
  3. <div class="common-title gradient-text">视频监控</div>
  4. <div class="more-btn" @click="showVideoMonitorList">{{ '查看更多>>' }}</div>
  5. <div class="card-content video-list">
  6. <div v-for="(item, index) in listData" :key="index" class="video-box">
  7. <HKVideo :dot_data="item" autoplay />
  8. <div class="video-label">
  9. <span class="label">{{ item.name }}</span>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. <Dialog v-if="showListDialog" v-model="showListDialog" type="xl" title="视频监控" class="dialog" hide-footer @close="reset">
  15. <div class="search-box">
  16. <div class="box-left">
  17. <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="70px" label-position="left">
  18. <!-- <el-form-item label="实景视频" prop="eventType">-->
  19. <!-- <el-select-->
  20. <!-- v-model="queryParams.realisticVideoType"-->
  21. <!-- class="custom-select"-->
  22. <!-- popper-class="custom-select
  23. <!-- :teleported="false"-->
  24. <!-- placeholder="全部"-->
  25. <!-- >-->
  26. <!-- <el-option label="全部" value=""></el-option>-->
  27. <!-- <el-option v-for="item in realistic_video" key="item.value" :label="item.label" :value="item.value" />-->
  28. <!-- </el-select>-->
  29. <!-- </el-form-item>-->
  30. <el-form-item prop="name">
  31. <el-input v-model="queryParams.name" class="custom-input2" placeholder="请输入摄像头名称" style="width: 200px" @input="getList" />
  32. </el-form-item>
  33. <el-form-item>
  34. <div class="common-btn-primary" @click="handleQuery">搜索</div>
  35. <div class="common-btn" @click="resetQuery">重置</div>
  36. </el-form-item>
  37. </el-form>
  38. </div>
  39. <div v-show="!editVideo" class="common-btn-primary2 edit-icon" style="margin-top: -20px" @click="activeEdit">编辑首页视频</div>
  40. <div v-show="editVideo" class="edit-box">
  41. <div class="flex">
  42. <div v-for="(item, index) in editData" :key="index" class="box-item">
  43. <div class="edit-img" :title="item.name">
  44. <span class="edit-title">{{ item.name }}</span>
  45. <div class="close-btn" @click="deleteItem(index)"></div>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="flex" style="flex-direction: column; align-items: center">
  50. <div class="common-btn-primary3" @click="handleSave">保存</div>
  51. <div class="common-btn-danger2" @click="handleCancel">取消</div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="border"></div>
  56. <div class="video-list2">
  57. <div v-for="(item, index) in dialogListData" :key="index" class="video-box" @click="selectItem(item)">
  58. <div class="video-label">
  59. <span class="label">{{ item.name }}</span>
  60. </div>
  61. <div style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center">
  62. <div v-if="editVideo">
  63. <div v-if="item.sort" class="active-tag"></div>
  64. <div :class="item.sort ? 'common-checked-active' : 'common-checked'"></div>
  65. <div class="img"></div>
  66. </div>
  67. <HKVideo v-else autoplay :dot_data="item" />
  68. </div>
  69. </div>
  70. </div>
  71. <div class="footer">
  72. <pagination
  73. v-show="total > queryParams.size"
  74. v-model:page="queryParams.current"
  75. v-model:limit="queryParams.size"
  76. :total="total"
  77. layout="total, prev, pager, next"
  78. @pagination="getList"
  79. />
  80. </div>
  81. <div id="container" style="display: none"></div>
  82. </Dialog>
  83. <div v-if="showTip" class="danger-tip" :style="{ zIndex: zIndex }">首页视频数量已达4个上限,如需继续操作请先取消已选择视频。</div>
  84. </template>
  85. <script lang="ts" setup name="VideoMonitor">
  86. import { getEmergencyVideoCata, getUserVideoPoints, getVideoListByUser, updateUserVideoPoints } from '@/api/videoMonitor';
  87. import { deepClone } from '@/utils';
  88. import AMapLoader from '@amap/amap-jsapi-loader';
  89. import useAppStore from '@/store/modules/app';
  90. const props = defineProps({
  91. longitude: String,
  92. latitude: String
  93. });
  94. const proxy = getCurrentInstance()?.proxy;
  95. const { realistic_video } = toRefs<any>(proxy?.useDict('realistic_video'));
  96. let listData = ref([]);
  97. let map;
  98. const initData = () => {
  99. const longitude = props.longitude ? props.longitude : 110.925176;
  100. const latitude = props.latitude ? props.latitude : 21.678993;
  101. queryParams.longitude = longitude;
  102. queryParams.latitude = latitude;
  103. getVideoListByUser({
  104. longitude: longitude,
  105. latitude: latitude,
  106. page: 1,
  107. pageSize: 4
  108. }).then((res) => {
  109. listData.value = res.rows;
  110. });
  111. };
  112. //查看更多数据
  113. const queryFormRef = ref();
  114. const queryParams = reactive({
  115. latitude: '',
  116. longitude: '',
  117. current: 1,
  118. size: 8,
  119. realisticVideoType: '',
  120. name: ''
  121. });
  122. let showListDialog = ref(false);
  123. let total = ref(0);
  124. let editVideo = ref(false);
  125. // 选中的视频
  126. let selectData = ref([]);
  127. let editData = ref([]);
  128. let dialogListData = ref([]);
  129. let showTip = ref(false);
  130. const appStore = useAppStore();
  131. let zIndex = ref(999);
  132. watch(
  133. showTip,
  134. () => {
  135. if (showTip.value) {
  136. zIndex.value = appStore.getZIndex();
  137. }
  138. },
  139. { immediate: true }
  140. );
  141. const showVideoMonitorList = () => {
  142. getList();
  143. showListDialog.value = true;
  144. };
  145. const getList = async () => {
  146. await getUserVideoPoints().then((res) => {
  147. selectData.value = res.data.videoInfos;
  148. });
  149. let newParams = {
  150. latitude: queryParams.latitude,
  151. longitude: queryParams.longitude,
  152. current: queryParams.current,
  153. size: queryParams.size,
  154. query: {
  155. name: queryParams.name,
  156. realisticVideoType: queryParams.realisticVideoType
  157. }
  158. };
  159. getEmergencyVideoCata(newParams).then((res) => {
  160. selectData.value.forEach((item) => {
  161. for (let i = 0; i < res.rows.length; i++) {
  162. if (item.video_code_int === res.rows[i].video_code) {
  163. res.rows[i].sort = true;
  164. break;
  165. }
  166. }
  167. });
  168. dialogListData.value = res.rows;
  169. total.value = res.total;
  170. });
  171. };
  172. const selectItem = (item) => {
  173. if (editVideo.value) {
  174. if (editData.value.length >= 4) {
  175. showTip.value = true;
  176. setTimeout(() => {
  177. showTip.value = false;
  178. }, 2500);
  179. } else {
  180. editData.value.push(item);
  181. }
  182. }
  183. };
  184. const deleteItem = (index) => {
  185. editData.value.splice(index, 1);
  186. };
  187. /** 表单重置 */
  188. const reset = () => {
  189. queryParams.current = 1;
  190. queryParams.realisticVideoType = '';
  191. queryParams.name = '';
  192. };
  193. /** 搜索按钮操作 */
  194. const handleQuery = () => {
  195. queryParams.current = 1;
  196. getList();
  197. };
  198. /** 重置按钮操作 */
  199. const resetQuery = () => {
  200. queryFormRef.value?.resetFields();
  201. handleQuery();
  202. };
  203. // 开启编辑视频
  204. const activeEdit = () => {
  205. editData.value = deepClone(selectData.value);
  206. editVideo.value = true;
  207. };
  208. // 关闭编辑
  209. const handleCancel = () => {
  210. editVideo.value = false;
  211. };
  212. // 保存编辑
  213. const handleSave = () => {
  214. const data = [];
  215. editData.value.forEach((item) => {
  216. data.push(item.video_code_int);
  217. });
  218. updateUserVideoPoints(data).then(() => {
  219. getList();
  220. handleCancel();
  221. });
  222. };
  223. initData();
  224. </script>
  225. <style lang="scss" scoped>
  226. .video-card {
  227. width: 526px;
  228. height: 309px;
  229. background: url('@/assets/images/video/videoBox1.png') no-repeat;
  230. background-size: 100% 100%;
  231. position: relative;
  232. animation-name: slideLeft;
  233. animation-duration: 1.5s;
  234. .video-list {
  235. display: flex;
  236. flex-wrap: wrap;
  237. padding-top: 47px;
  238. padding-left: 25px;
  239. .video-box {
  240. width: 237px;
  241. height: 116px;
  242. margin-right: 13px;
  243. cursor: pointer;
  244. background: url('@/assets/images/video/videoBg.png') no-repeat;
  245. background-size: 100% 100%;
  246. position: relative;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. padding: 5px 4px 5px 5px;
  251. &:nth-child(1),
  252. &:nth-child(2) {
  253. margin-bottom: 10px;
  254. }
  255. &:nth-child(2),
  256. &:nth-child(4) {
  257. margin-right: 0;
  258. }
  259. .video-label {
  260. position: absolute;
  261. bottom: 5px;
  262. right: 3px;
  263. z-index: 901;
  264. display: flex;
  265. .label {
  266. width: 186px;
  267. height: 22px;
  268. line-height: 22px;
  269. font-size: 14px;
  270. white-space: nowrap;
  271. overflow: hidden;
  272. text-overflow: ellipsis;
  273. padding: 0 5px 0 10px;
  274. color: #fff;
  275. background-color: rgba(18, 107, 248, 0.4);
  276. text-align: right;
  277. }
  278. &::before {
  279. content: '';
  280. width: 0;
  281. height: 0;
  282. border-bottom: 22px solid rgba(18, 107, 248, 0.4);
  283. border-left: 22px solid transparent;
  284. }
  285. }
  286. }
  287. :deep(.err_box) {
  288. align-items: flex-start;
  289. padding-top: 15px;
  290. }
  291. }
  292. }
  293. .search-box {
  294. display: flex;
  295. width: 100%;
  296. justify-content: space-between;
  297. align-items: center;
  298. .el-form--inline .el-form-item {
  299. margin-right: 15px;
  300. }
  301. }
  302. .more-btn {
  303. position: absolute;
  304. top: 22px;
  305. right: 8px;
  306. color: #00e8ff;
  307. font-size: 13px;
  308. cursor: pointer;
  309. z-index: 2;
  310. }
  311. .video-list2 {
  312. display: flex;
  313. flex-wrap: wrap;
  314. padding: 0 10px;
  315. .video-box {
  316. width: 288px;
  317. height: 200px;
  318. margin-right: 15px;
  319. cursor: pointer;
  320. cursor: pointer;
  321. background: url('@/assets/images/video/videoBg.png') no-repeat;
  322. background-size: 100% 100%;
  323. padding: 9.5px 3.8px 9px 5.5px;
  324. position: relative;
  325. margin-bottom: 15px;
  326. position: relative;
  327. display: flex;
  328. flex-direction: column;
  329. align-items: center;
  330. &:nth-child(4),
  331. &:nth-child(8) {
  332. margin-right: 0;
  333. }
  334. .video-label {
  335. position: absolute;
  336. bottom: 8px;
  337. right: 4px;
  338. z-index: 901;
  339. display: flex;
  340. .label {
  341. width: 186px;
  342. height: 24px;
  343. padding-right: 5px;
  344. line-height: 24px;
  345. font-size: 14px;
  346. white-space: nowrap;
  347. overflow: hidden;
  348. text-overflow: ellipsis;
  349. padding-left: 10px;
  350. color: #fff;
  351. background-color: rgba(0, 0, 0, 0.4);
  352. text-align: right;
  353. }
  354. &::before {
  355. content: '';
  356. width: 0;
  357. height: 0;
  358. border-bottom: 24px solid rgba(0, 0, 0, 0.4);
  359. border-left: 24px solid transparent;
  360. }
  361. }
  362. }
  363. }
  364. .img {
  365. width: 278.5px;
  366. height: 183px;
  367. margin-left: 1px;
  368. background-color: #000;
  369. }
  370. .active-tag {
  371. position: absolute;
  372. top: 13px;
  373. left: 10px;
  374. width: 83px;
  375. height: 25px;
  376. background: url('@/assets/images/video/indexTag.png') no-repeat;
  377. background-size: 100% 100%;
  378. }
  379. .edit-box {
  380. display: flex;
  381. justify-content: space-between;
  382. align-items: center;
  383. border-radius: 8px;
  384. padding: 3px 5px;
  385. width: 545px;
  386. height: 83px;
  387. background: url('@/assets/images/video/editBg.png') no-repeat;
  388. background-size: 100% 100%;
  389. position: absolute;
  390. right: 20px;
  391. top: 27px;
  392. }
  393. .box-item {
  394. position: relative;
  395. margin-left: 8px;
  396. &:first-child {
  397. margin-left: 0;
  398. }
  399. .edit-img {
  400. width: 65px;
  401. height: 65px;
  402. background-color: #000;
  403. }
  404. .edit-title {
  405. color: #fff;
  406. display: -webkit-box;
  407. -webkit-box-orient: vertical;
  408. -webkit-line-clamp: 3; /* 设置显示的行数 */
  409. overflow: hidden;
  410. text-overflow: ellipsis;
  411. }
  412. .close-btn {
  413. position: absolute;
  414. top: 0;
  415. right: 0;
  416. cursor: pointer;
  417. width: 15px;
  418. height: 15px;
  419. background: url('@/assets/images/video/close.png') no-repeat;
  420. background-size: 100% 100%;
  421. z-index: 1;
  422. }
  423. }
  424. .footer {
  425. height: 30px;
  426. display: flex;
  427. justify-content: flex-end;
  428. margin-bottom: 30px;
  429. .pagination-container {
  430. margin: 0;
  431. }
  432. :deep(.el-pagination__total) {
  433. color: #a7ccdf !important;
  434. }
  435. :deep(.el-pagination) {
  436. .btn-next,
  437. .btn-prev {
  438. background-color: transparent !important;
  439. border: none !important;
  440. .el-icon {
  441. color: #a7ccdf !important;
  442. }
  443. }
  444. .btn-prev:disabled,
  445. .btn-next:disabled {
  446. background-color: transparent !important;
  447. border: none !important;
  448. }
  449. .el-pager li {
  450. text-align: center;
  451. color: #a7ccdf !important;
  452. background-color: #0e3064 !important;
  453. border: 1px solid #0c57a7 !important;
  454. &:hover {
  455. background-color: #038dff !important;
  456. border: 1px solid #038dff !important;
  457. }
  458. }
  459. .el-pager li.is-active {
  460. background-color: #038dff !important;
  461. border: 1px solid #038dff !important;
  462. }
  463. }
  464. }
  465. .flex {
  466. display: flex;
  467. align-items: center;
  468. }
  469. .border {
  470. background-color: #15428d;
  471. width: 100%;
  472. height: 1px;
  473. margin-bottom: 30px;
  474. }
  475. .edit-icon {
  476. display: flex;
  477. align-items: center;
  478. &::before {
  479. content: '';
  480. display: inline-block;
  481. width: 18px;
  482. height: 16px;
  483. background: url('@/assets/images/video/setting.png') no-repeat;
  484. background-size: 100% 100%;
  485. margin-right: 10px;
  486. }
  487. }
  488. .common-checked,
  489. .common-checked-active {
  490. position: absolute;
  491. top: 13px;
  492. right: 12px;
  493. z-index: 9;
  494. }
  495. :deep(.el-form) {
  496. .el-form-item__label {
  497. color: #ffffff !important;
  498. }
  499. }
  500. //.dialog {
  501. // :deep(.dialog-header) {
  502. // min-height: 150px;
  503. // }
  504. //}
  505. .common-btn-primary {
  506. width: 94px;
  507. height: 60px;
  508. }
  509. .common-btn {
  510. width: 66px;
  511. height: 32px;
  512. }
  513. </style>