VideoMonitor.vue 12 KB

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