index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div
  3. v-if="modelValue || customShow"
  4. v-drag="{ draggable: draggable, position: 'fixed', scale: containerScale, handle: headerType === 'header2' ? '.dialog-header2' : '.dialog-header' }"
  5. class="common-dialog"
  6. :class="customClass"
  7. :style="{ width: computedWidth, height: computedHeight, zIndex: zIndex }"
  8. >
  9. <div :class="type === 'xs' || headerType === 'header2' ? 'dialog-header2' : 'dialog-header'">
  10. <div class="header-left">
  11. <div v-if="!hideTitle" class="dialog-title" :title="title ? title : '弹窗'">
  12. {{ title ? title : '弹窗' }}
  13. </div>
  14. <div v-if="!!getTagId" class="tags">
  15. <div v-for="(item, index) in tags" :key="index" class="tag">{{ item.dict_label }}</div>
  16. <i :class="tags && tags.length > 0 ? 'collectFill' : 'collect'" @click="handleShowAddTag" />
  17. </div>
  18. </div>
  19. <i class="decoration" />
  20. <i class="dialog-close" @click="closeDialog" />
  21. </div>
  22. <div class="dialog-content">
  23. <slot />
  24. </div>
  25. <template v-if="!hideFooter">
  26. <slot v-if="$slots.footer" name="footer" />
  27. <div v-else class="dialog-footer">
  28. <div :class="cancelClass ? cancelClass + ' common-btn' : 'common-btn'" @click="closeDialog">{{ cancelText }}</div>
  29. <div :class="confirmClass ? confirmClass + ' common-btn-primary' : 'common-btn-primary'" @click="confirm">{{ confirmText }}</div>
  30. </div>
  31. </template>
  32. <i class="triangle1" />
  33. <i class="triangle2" />
  34. <i class="triangle3" />
  35. <i class="triangle4" />
  36. </div>
  37. <VideoTagEdit v-if="showAddTag" v-model="showAddTag" :tags="tags" :id="getTagId" @updateVideoTag="getData2" />
  38. </template>
  39. <script lang="ts" setup name="Dialog">
  40. import { getVideoTagInfo } from '@/api/videoMonitor';
  41. import useAppStore from '@/store/modules/app';
  42. interface Tag {
  43. dict_label: string;
  44. dict_value: string;
  45. }
  46. // type: xs、sm、md、lg、xl
  47. interface Props {
  48. modelValue?: boolean;
  49. type?: string;
  50. title?: string;
  51. hideTitle?: boolean;
  52. width?: string;
  53. height?: string;
  54. cancelText?: string;
  55. cancelClass?: string;
  56. confirmText?: string;
  57. confirmClass?: string;
  58. hideFooter?: boolean;
  59. customShow?: boolean;
  60. headerType?: string;
  61. getTagId?: string;
  62. draggable?: boolean;
  63. customClass?: string;
  64. }
  65. const containerScale = inject('containerScale');
  66. const props = withDefaults(defineProps<Props>(), {
  67. modelValue: false,
  68. type: 'md',
  69. cancelText: '取消',
  70. confirmText: '确定',
  71. hideFooter: false
  72. });
  73. const emit = defineEmits(['update:modelValue', 'close', 'confirm', 'changeTagsData']);
  74. const computedWidth = computed(() => {
  75. if (!!props.width) {
  76. return props.width;
  77. } else if (!!props.width) {
  78. return props.width;
  79. } else if (props.type === 'xs') {
  80. return '404px';
  81. } else if (props.type === 'sm') {
  82. return '584px';
  83. } else if (props.type === 'lg') {
  84. return '1024px';
  85. } else if (props.type === 'xl') {
  86. return '1270px';
  87. } else {
  88. return '744px';
  89. }
  90. });
  91. const computedHeight = computed(() => {
  92. if (!!props.height) {
  93. return props.height;
  94. } else {
  95. return 'auto';
  96. }
  97. // else if (props.type === 'xs') {
  98. // return '150px';
  99. // } else if (props.type === 'sm') {
  100. // return '720px';
  101. // } else if (props.type === 'lg') {
  102. // return '720px';
  103. // } else if (props.type === 'xl') {
  104. // return '720px';
  105. // } else {
  106. // return '760px';
  107. // }
  108. });
  109. const appStore = useAppStore();
  110. let zIndex = ref(999);
  111. watch(
  112. () => props.modelValue,
  113. () => {
  114. if (props.modelValue && !props.customShow) {
  115. zIndex.value = appStore.getZIndex();
  116. }
  117. },
  118. { immediate: true }
  119. );
  120. let tags = ref<Tag[]>([]);
  121. // 关闭弹窗
  122. const closeDialog = () => {
  123. emit('close');
  124. if (!props.customShow) {
  125. emit('update:modelValue', false);
  126. }
  127. };
  128. // 确认按钮
  129. const confirm = () => {
  130. emit('confirm');
  131. if (!props.customShow) {
  132. emit('update:modelValue', false);
  133. }
  134. };
  135. // 显示添加标签
  136. let showAddTag = ref(false);
  137. const handleShowAddTag = () => {
  138. showAddTag.value = true;
  139. };
  140. const getData = (needUpdate?: boolean) => {
  141. getVideoTagInfo({ video_code: props.getTagId }).then((res) => {
  142. tags.value = res.data;
  143. if (!!needUpdate) {
  144. emit('changeTagsData', res.data);
  145. }
  146. });
  147. };
  148. const getData2 = () => {
  149. getData(true);
  150. showAddTag.value = false;
  151. };
  152. onMounted(() => {
  153. if (props.customShow) {
  154. zIndex.value = appStore.getZIndex();
  155. }
  156. if (props.getTagId) {
  157. getData();
  158. }
  159. });
  160. </script>
  161. <style lang="scss" scoped>
  162. .common-dialog {
  163. border: 4px solid #2c81ff;
  164. padding-bottom: 10px;
  165. color: #ffffff;
  166. background-color: rgba(5, 18, 53, 0.85);
  167. box-shadow: inset 0 0 40px 10px rgba(26, 144, 255, 0.5);
  168. position: fixed;
  169. top: 50%;
  170. left: 50%;
  171. transform: translate(-50%, -50%);
  172. max-height: calc(100% - 100px);
  173. z-index: 99;
  174. font-size: 14px;
  175. display: flex;
  176. flex-direction: column;
  177. .dialog-header,
  178. .dialog-header2 {
  179. position: relative;
  180. min-height: 50px;
  181. line-height: 28px;
  182. padding-bottom: 15px;
  183. .dialog-title {
  184. width: 500px;
  185. color: transparent;
  186. background-image: linear-gradient(to bottom, #ffffff 30%, #edf7fe 50%, #5cc4fa 70%, #40a2e7 100%);
  187. -webkit-background-clip: text;
  188. background-clip: text;
  189. display: inline-block;
  190. font-family: 'YouSheBiaoTiHei';
  191. font-size: 24px;
  192. padding-left: 25px;
  193. white-space: nowrap;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. }
  197. .dialog-close {
  198. position: absolute;
  199. top: 6px;
  200. right: 10px;
  201. width: 12px;
  202. height: 12px;
  203. background: url('@/assets/images/common/close.png') no-repeat;
  204. background-size: 100% 100%;
  205. cursor: pointer;
  206. display: block;
  207. }
  208. .decoration {
  209. position: absolute;
  210. top: 6px;
  211. right: 26px;
  212. width: 46px;
  213. height: 10px;
  214. background: url('@/assets/images/common/decoration.png') no-repeat;
  215. background-size: 100% 100%;
  216. cursor: pointer;
  217. display: block;
  218. }
  219. }
  220. .dialog-header {
  221. padding-top: 6px;
  222. &::before {
  223. content: '';
  224. position: absolute;
  225. bottom: 0;
  226. left: 0;
  227. width: 287px;
  228. height: 47px;
  229. background: url('@/assets/images/common/line1.png') no-repeat;
  230. background-size: 100% 100%;
  231. }
  232. &::after {
  233. content: '';
  234. position: absolute;
  235. bottom: 24.5px;
  236. left: 286px;
  237. width: calc(100% - 280px);
  238. height: 2.1px;
  239. background-image: linear-gradient(to right, rgba(10, 154, 196, 1) 0%, rgba(10, 154, 196, 0) 100%);
  240. background-size: 100% 100%;
  241. }
  242. }
  243. .dialog-header2 {
  244. display: flex;
  245. .dialog-title {
  246. width: auto;
  247. }
  248. .header-left {
  249. position: relative;
  250. &::before {
  251. content: '';
  252. position: absolute;
  253. bottom: 6px;
  254. left: 0;
  255. width: 47px;
  256. height: 20px;
  257. background: url('@/assets/images/line.png') no-repeat;
  258. background-size: 100% 100%;
  259. }
  260. &::after {
  261. content: '';
  262. position: absolute;
  263. bottom: 15px;
  264. left: 52px;
  265. width: calc(100% - 47px);
  266. height: 2px;
  267. background-image: linear-gradient(to right, rgba(10, 154, 196, 1) 0%, rgba(10, 154, 196, 0) 100%);
  268. background-size: 100% 100%;
  269. }
  270. }
  271. .tags {
  272. display: flex;
  273. align-items: center;
  274. margin-top: -18px;
  275. .tag {
  276. width: 126px;
  277. height: 26px;
  278. background: url('@/assets/images/map/tag.png') no-repeat;
  279. background-size: 100% 100%;
  280. flex-shrink: 0;
  281. color: #ffffff;
  282. font-size: 14px;
  283. display: flex;
  284. justify-content: center;
  285. align-items: center;
  286. }
  287. .collect {
  288. background: url('@/assets/images/video/collect.png') no-repeat;
  289. }
  290. .collectFill {
  291. background: url('@/assets/images/video/collectFill.png') no-repeat;
  292. }
  293. .collect,
  294. .collectFill {
  295. width: 20px;
  296. height: 20px;
  297. cursor: pointer;
  298. background-size: 100% 100%;
  299. cursor: pointer;
  300. margin-left: 6px;
  301. }
  302. }
  303. }
  304. .el-form-item__label {
  305. font-size: 38px;
  306. color: #fff;
  307. }
  308. }
  309. .common-dialog {
  310. .dialog-content {
  311. width: 100%;
  312. overflow-y: auto;
  313. overflow-x: hidden;
  314. flex: 1;
  315. padding: 0 10px;
  316. }
  317. .dialog-footer {
  318. padding: 0 10px;
  319. height: 50px;
  320. display: flex;
  321. justify-content: flex-end;
  322. align-items: center;
  323. border-top: none;
  324. }
  325. }
  326. .triangle1,
  327. .triangle2,
  328. .triangle3,
  329. .triangle4 {
  330. width: 12px;
  331. height: 12px;
  332. background-size: 100% 100%;
  333. background-repeat: no-repeat;
  334. display: block;
  335. position: absolute;
  336. }
  337. .triangle1 {
  338. top: 6px;
  339. left: 6px;
  340. background-image: url('@/assets/images/common/triangle1.png');
  341. }
  342. .triangle2 {
  343. top: 6px;
  344. right: 6px;
  345. background-image: url('@/assets/images/common/triangle2.png');
  346. }
  347. .triangle3 {
  348. bottom: 6px;
  349. left: 6px;
  350. background-image: url('@/assets/images/common/triangle3.png');
  351. }
  352. .triangle4 {
  353. bottom: 6px;
  354. right: 6px;
  355. background-image: url('@/assets/images/common/triangle4.png');
  356. }
  357. .common-btn-danger {
  358. margin-left: 20px;
  359. }
  360. .header-left {
  361. display: flex;
  362. flex-wrap: wrap;
  363. }
  364. </style>