NewsDialog.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <el-dialog v-model="show" top="10vh" class="news-dialog" width="1174px">
  3. <template #header>
  4. <div class="news-dialog-header">
  5. <h3>{{ item?.name }}</h3>
  6. <div class="news-dialog-header-info">
  7. <p>
  8. <svg-icon
  9. name="icon_time"
  10. width="23px"
  11. height="23px"
  12. color="var(--el-color-primary)"
  13. />{{ date }}
  14. </p>
  15. <p>
  16. <svg-icon
  17. name="icon_eyes"
  18. width="23px"
  19. height="23px"
  20. color="var(--el-color-primary)"
  21. />{{ item.pcsVisit }}次阅读
  22. </p>
  23. </div>
  24. </div>
  25. </template>
  26. <el-scrollbar max-height="600px">
  27. <div v-for="c in content" class="news-dialog-inner" v-html="c.txt" />
  28. </el-scrollbar>
  29. </el-dialog>
  30. </template>
  31. <script setup>
  32. import { computed, watch } from "vue";
  33. import { formatDate } from "@dage/utils";
  34. import { addNoticeVisitApi } from "@/api";
  35. const props = defineProps({
  36. visible: {
  37. type: Boolean,
  38. required: true,
  39. },
  40. item: {
  41. type: Object,
  42. required: false,
  43. },
  44. });
  45. const emits = defineEmits(["update:visible"]);
  46. const show = computed({
  47. get() {
  48. return props.visible;
  49. },
  50. set(v) {
  51. emits("update:visible", v);
  52. },
  53. });
  54. const date = computed(() =>
  55. formatDate(props.item?.createTime, "YYYY年MM月DD日 HH:MM")
  56. );
  57. const content = computed(() => {
  58. if (!props.item || !props.item.description) return [];
  59. const res = JSON.parse(props.item.description);
  60. return res.txtArr;
  61. });
  62. watch(show, (v) => {
  63. if (v && props.item) {
  64. addNoticeVisitApi(props.item.id);
  65. }
  66. });
  67. </script>
  68. <style lang="scss">
  69. .news-dialog {
  70. --el-message-close-size: 30px;
  71. padding: 28px 45px;
  72. &-header {
  73. text-align: center;
  74. border-bottom: 1px solid var(--el-color-primary);
  75. h3 {
  76. font-size: 24px;
  77. line-height: 42px;
  78. font-family: "Source Han Serif CN-Bold";
  79. }
  80. &-info {
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. margin: 5px 0 25px;
  85. gap: 100px;
  86. color: #a99271;
  87. font-size: 16px;
  88. p {
  89. display: flex;
  90. align-items: center;
  91. gap: 10px;
  92. }
  93. }
  94. }
  95. &-inner {
  96. padding: 0 25px;
  97. font-size: 18px;
  98. }
  99. .el-dialog__headerbtn {
  100. top: 30px;
  101. right: 30px;
  102. }
  103. }
  104. </style>