VideoMonitorEdit.vue 13 KB

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