index.vue 8.6 KB

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