VideoMonitorEdit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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: '',
  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.setVideoPointParams({
  191. flag: true,
  192. dict_value: queryParams.dict_value
  193. });
  194. };
  195. const selectItem = (item) => {
  196. if (editVideo.value) {
  197. if (editData.value.length >= 6) {
  198. showTip.value = true;
  199. setTimeout(() => {
  200. showTip.value = false;
  201. }, 2500);
  202. } else {
  203. editData.value.push(item);
  204. }
  205. }
  206. };
  207. const deleteItem = (index) => {
  208. editData.value.splice(index, 1);
  209. };
  210. /** 表单重置 */
  211. const reset = () => {
  212. emits('update:modelValue', false);
  213. };
  214. /** 搜索按钮操作 */
  215. const handleQuery = () => {
  216. queryParams.current = 1;
  217. getList();
  218. getVideoInfoList();
  219. };
  220. /** 重置按钮操作 */
  221. const resetQuery = () => {
  222. queryFormRef.value?.resetFields();
  223. treeData.area = '';
  224. treeData.townList = [];
  225. treeData.town = '';
  226. treeData.villageList = [];
  227. treeData.village = '';
  228. queryParams.current = 1;
  229. handleQuery();
  230. };
  231. // 开启编辑视频
  232. const activeEdit = () => {
  233. editVideo.value = true;
  234. };
  235. const filterData = (data) => {
  236. data.forEach((item) => {
  237. for (let i = 0; i < dialogListData.value.length; i++) {
  238. if (item.video_code_int === dialogListData.value[i].video_code) {
  239. dialogListData.value[i].sort = true;
  240. break;
  241. }
  242. }
  243. });
  244. };
  245. // 关闭编辑
  246. const handleCancel = () => {
  247. editVideo.value = false;
  248. };
  249. // 保存编辑
  250. const handleSave = () => {
  251. const data = [];
  252. editData.value.forEach((item) => {
  253. data.push(item.video_code_int);
  254. });
  255. updateUserVideoPoints(data).then(() => {
  256. getList(true);
  257. handleCancel();
  258. });
  259. };
  260. // 区变化
  261. const handleAreaChange = () => {
  262. getAreaTreeList('townList', treeData.area);
  263. treeData.town = '';
  264. treeData.village = '';
  265. queryParams.area = treeData.area;
  266. };
  267. // 镇变化
  268. const handleTownChange = () => {
  269. getAreaTreeList('villageList', treeData.town);
  270. treeData.village = '';
  271. queryParams.area = treeData.town;
  272. };
  273. // 村变化
  274. const handleVillageChange = () => {
  275. queryParams.area = treeData.village;
  276. };
  277. // 获取区划树
  278. const getAreaTreeList = (datasource, id) => {
  279. getRegionalTree(id).then((res) => {
  280. treeData[datasource] = res.data;
  281. });
  282. };
  283. const getCheckStatus = (id) => {
  284. let flag = false;
  285. for (let i = 0; i < editData.value.length; i++) {
  286. if (editData.value[i].video_code_int === id) {
  287. flag = true;
  288. break;
  289. }
  290. }
  291. return flag;
  292. };
  293. onMounted(() => {
  294. getList();
  295. getAreaTreeList('areaList', 2);
  296. getVideoInfoList();
  297. });
  298. </script>
  299. <style lang="scss" scoped>
  300. .search-box {
  301. display: flex;
  302. width: 100%;
  303. justify-content: space-between;
  304. align-items: center;
  305. margin-top: -30px;
  306. }
  307. .video-list2 {
  308. display: flex;
  309. flex-wrap: wrap;
  310. padding: 0 20px;
  311. .video-box {
  312. width: 790px;
  313. height: 356px;
  314. margin-right: 35.06px;
  315. cursor: pointer;
  316. cursor: pointer;
  317. background: url('@/assets/images/video/videoBg.png') no-repeat;
  318. background-size: 100% 100%;
  319. padding: 14.5px 16px;
  320. position: relative;
  321. margin-bottom: 25px;
  322. position: relative;
  323. display: flex;
  324. flex-direction: column;
  325. align-items: center;
  326. &:nth-child(4),
  327. &:nth-child(8) {
  328. margin-right: 0;
  329. }
  330. .video-label {
  331. position: absolute;
  332. bottom: 17px;
  333. right: 20px;
  334. z-index: 901;
  335. display: flex;
  336. .label {
  337. width: 411px;
  338. height: 56px;
  339. line-height: 56px;
  340. font-size: 36px;
  341. white-space: nowrap;
  342. overflow: hidden;
  343. text-overflow: ellipsis;
  344. padding-left: 10px;
  345. color: #fff;
  346. background-color: rgba(0, 0, 0, 0.4);
  347. text-align: right;
  348. }
  349. &::before {
  350. content: '';
  351. width: 0;
  352. height: 0;
  353. border-bottom: 56px solid rgba(0, 0, 0, 0.4);
  354. border-left: 56px solid transparent;
  355. }
  356. }
  357. }
  358. }
  359. .img {
  360. width: 750px;
  361. height: 327px;
  362. background-color: #000;
  363. }
  364. .active-tag {
  365. position: absolute;
  366. top: 30px;
  367. left: 30px;
  368. width: 187px;
  369. height: 56px;
  370. background: url('@/assets/images/video/indexTag.png') no-repeat;
  371. background-size: 100% 100%;
  372. }
  373. .edit-box {
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. border-radius: 8px;
  378. padding: 5px 10px;
  379. width: 1348px;
  380. height: 193px;
  381. background: url('@/assets/images/video/editBg.png') no-repeat;
  382. background-size: 100% 100%;
  383. //position: absolute;
  384. //right: 45px;
  385. //top: 97px;
  386. }
  387. .box-item {
  388. position: relative;
  389. margin-left: 20px;
  390. .edit-img {
  391. width: 160px;
  392. height: 160px;
  393. background-color: #000;
  394. }
  395. .edit-title {
  396. color: #fff;
  397. display: -webkit-box;
  398. -webkit-box-orient: vertical;
  399. -webkit-line-clamp: 3; /* 设置显示的行数 */
  400. overflow: hidden;
  401. text-overflow: ellipsis;
  402. }
  403. .close-btn {
  404. position: absolute;
  405. top: 0;
  406. right: 0;
  407. cursor: pointer;
  408. width: 33px;
  409. height: 33px;
  410. background: url('@/assets/images/video/close.png') no-repeat;
  411. background-size: 100% 100%;
  412. z-index: 1;
  413. }
  414. }
  415. .footer {
  416. height: 64px;
  417. display: flex;
  418. justify-content: flex-end;
  419. margin-bottom: 30px;
  420. .pagination-container {
  421. height: 64px;
  422. margin: 0;
  423. }
  424. :deep(.el-pagination__total) {
  425. color: #a7ccdf;
  426. font-size: 32px;
  427. }
  428. :deep(.el-pagination) {
  429. .btn-next,
  430. .btn-prev {
  431. background-color: transparent;
  432. border: none;
  433. .el-icon {
  434. font-size: 22px;
  435. color: #a7ccdf;
  436. }
  437. }
  438. .btn-prev:disabled,
  439. .btn-next:disabled {
  440. background-color: transparent;
  441. border: none;
  442. }
  443. .el-pager li {
  444. width: 64px;
  445. height: 64px;
  446. line-height: 64px;
  447. text-align: center;
  448. font-size: 32px;
  449. color: #a7ccdf;
  450. background-color: #0e3064;
  451. border: 1px solid #0c57a7;
  452. margin: 0 6px;
  453. &:hover {
  454. background-color: #038dff;
  455. border: 1px solid #038dff;
  456. }
  457. }
  458. .el-pager li.is-active {
  459. background-color: #038dff;
  460. border: 1px solid #038dff;
  461. }
  462. }
  463. }
  464. .flex {
  465. display: flex;
  466. align-items: center;
  467. }
  468. .border {
  469. background-color: #15428d;
  470. width: 100%;
  471. height: 4px;
  472. margin-bottom: 15px;
  473. }
  474. .edit-icon {
  475. display: flex;
  476. align-items: center;
  477. &::before {
  478. content: '';
  479. display: inline-block;
  480. width: 41px;
  481. height: 36px;
  482. background: url('@/assets/images/video/setting.png') no-repeat;
  483. background-size: 100% 100%;
  484. margin-right: 10px;
  485. }
  486. }
  487. .common-checked,
  488. .common-checked-active {
  489. position: absolute;
  490. top: 30px;
  491. right: 30px;
  492. z-index: 9;
  493. }
  494. .dialog {
  495. :deep(.dialog-header) {
  496. min-height: 150px;
  497. }
  498. }
  499. </style>