ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<script lang="ts" setup>
import { useModal } from '@jnpf/ui/modal';
 
import bulletinImg from '#/assets/images/portal/bulletin.png';
import noticeImg from '#/assets/images/portal/notice.png';
import { getAuthMediaUrl } from '#/utils/jnpf';
import Detail from '#/views/msgCenter/notice/Detail.vue';
 
import { useTable } from '../../Design/hooks/useTable';
import CardHeader from '../CardHeader/index.vue';
 
const props = defineProps(['activeData']);
const [registerDetail, { openModal: openDetailModal }] = useModal();
const { getTableBindValues, list, getColumns, getOption, getItemStyle, getColumnsStyle, tableListRef, tableElRef, getBorder } = useTable(props.activeData);
 
function readInfo(item) {
  openDetailModal(true, { type: 1, id: item.id });
}
function getImgUrl(item) {
  const defaultImg = item.category === '公告' ? bulletinImg : noticeImg;
  return item.coverImage ? getAuthMediaUrl(item.coverImage) : defaultImg;
}
function getTypeStyle(category) {
  const backgroundColor = category === '公告' ? 'rgba(99,9,244,0.05)' : category === '通知' ? 'rgba(9,63,244,0.05)' : 'rgba(244,135,9,0.05)';
  const color = category === '公告' ? '#6309F4' : category === '通知' ? '#093FF4' : '#F48709';
  return { backgroundColor, color } as any;
}
</script>
<template>
  <a-card class="portal-card-box portal-notice-box">
    <template #title v-if="activeData.title">
      <CardHeader :title="activeData.title" :card="activeData.card" />
    </template>
    <div class="portal-card-body portal-card-table !overflow-auto" ref="tableListRef">
      <a-table
        :data-source="list"
        v-bind="getTableBindValues"
        ref="tableElRef"
        :class="{ 'custom-table': getBorder }"
        v-if="getOption.styleType == 1 && !!getTableBindValues.columns?.length">
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'fullName'">
            <span class="title" @click="readInfo(record)" :title="`【${record.category}】${record[column.key]}`">
              <span v-if="getOption.columnData.filter((o) => o.fieldName === 'classify')[0]?.show">{{ `【${record.category}】` }}</span>
              {{ record[column.key] }}
            </span>
          </template>
        </template>
      </a-table>
      <template v-else>
        <template v-if="list.length">
          <div class="item" v-for="(item, i) in list" :key="i" :style="getItemStyle(i)">
            <div class="left-box" v-if="activeData.option.showImage">
              <img :src="getImgUrl(item)" />
            </div>
            <div class="right-box">
              <div class="right-top-box">
                <span class="type-box" v-if="getColumns[0].show" :style="getTypeStyle(item.category)">{{ item.category || '其他' }}</span>
                <span class="title-box" v-if="getColumns[1].show" :style="getColumnsStyle(1)" @click="readInfo(item)">{{ item.fullName }}</span>
                <span v-if="getColumns[3].show && getOption.styleType == 2" :style="getColumnsStyle(3)">
                  {{ getColumns[3].timeClassify == 1 ? item.creatorTime : item.releaseTime }}
                </span>
              </div>
              <div class="content-box pt-[4px]" v-if="getColumns[2].show" :style="getColumnsStyle(2)">{{ item.excerpt }}</div>
              <div class="pt-[4px]" v-if="getColumns[3].show && getOption.styleType == 3" :style="getColumnsStyle(3)">
                {{ getColumns[3].timeClassify == 1 ? item.creatorTime : item.releaseTime }}
              </div>
            </div>
          </div>
        </template>
        <div class="portal-common-noData" v-else>
          <jnpf-empty />
        </div>
      </template>
    </div>
  </a-card>
  <Detail @register="registerDetail" />
</template>
<style lang="scss" scoped>
.portal-notice-box {
  .title {
    cursor: pointer;
 
    &:hover {
      color: var(primary-color);
    }
  }
 
  .item {
    display: flex;
    padding: 14px 0 12px;
    margin: 0 10px;
    border-bottom: 1px solid var(--border-color-base1);
 
    .left-box {
      flex-shrink: 0;
 
      img {
        width: 45px;
        height: 45px;
        object-fit: cover;
        border-radius: 50%;
      }
    }
 
    .right-box {
      flex: 1;
      min-width: 0;
      padding-left: 10px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      background: unset;
 
      .right-top-box {
        display: flex;
        align-items: center;
 
        .type-box {
          display: inline-block;
          width: 32px;
          height: 17px;
          font-size: 12px;
          line-height: 17px;
          color: #6309f4;
          text-align: center;
          background: rgb(99 9 244 / 4%);
          border-radius: 2px;
        }
 
        .title-box {
          flex: 1;
          min-width: 0;
          margin: 0 4px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          cursor: pointer;
 
          &:hover {
            color: var(--primary-color) !important;
          }
        }
      }
 
      .content-box {
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
</style>