|
|
@ -34,13 +34,15 @@ |
|
|
<div> |
|
|
<div> |
|
|
<div class="description" v-if="item.description"> |
|
|
<div class="description" v-if="item.description"> |
|
|
<a-typography-paragraph |
|
|
<a-typography-paragraph |
|
|
|
|
|
@click="handleContentClick(item)" |
|
|
style="width: 100%; margin-bottom: 0 !important" |
|
|
style="width: 100%; margin-bottom: 0 !important" |
|
|
|
|
|
:style="{ cursor: isContentClickable ? 'pointer' : '' }" |
|
|
:ellipsis=" |
|
|
:ellipsis=" |
|
|
$props.descRows && $props.descRows > 0 |
|
|
$props.descRows && $props.descRows > 0 |
|
|
? { rows: $props.descRows, tooltip: !!item.description } |
|
|
? { rows: $props.descRows, tooltip: !!item.description } |
|
|
: false |
|
|
: false |
|
|
" |
|
|
" |
|
|
:content="item.description" |
|
|
:content="getContent(item)" |
|
|
/> |
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
<div class="datetime"> |
|
|
<div class="datetime"> |
|
|
@ -61,6 +63,7 @@ |
|
|
import { ListItem } from './data'; |
|
|
import { ListItem } from './data'; |
|
|
import { useDesign } from '/@/hooks/web/useDesign'; |
|
|
import { useDesign } from '/@/hooks/web/useDesign'; |
|
|
import { List, Avatar, Tag, Typography } from 'ant-design-vue'; |
|
|
import { List, Avatar, Tag, Typography } from 'ant-design-vue'; |
|
|
|
|
|
import { NotificationContentType } from "/@/api/messages/model/notificationsModel"; |
|
|
import { isNumber } from '/@/utils/is'; |
|
|
import { isNumber } from '/@/utils/is'; |
|
|
export default defineComponent({ |
|
|
export default defineComponent({ |
|
|
components: { |
|
|
components: { |
|
|
@ -95,6 +98,9 @@ |
|
|
onTitleClick: { |
|
|
onTitleClick: { |
|
|
type: Function as PropType<(Recordable) => void>, |
|
|
type: Function as PropType<(Recordable) => void>, |
|
|
}, |
|
|
}, |
|
|
|
|
|
onContentClick: { |
|
|
|
|
|
type: Function as PropType<(Recordable) => void>, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
emits: ['update:currentPage'], |
|
|
emits: ['update:currentPage'], |
|
|
setup(props, { emit }) { |
|
|
setup(props, { emit }) { |
|
|
@ -103,9 +109,22 @@ |
|
|
const getData = computed(() => { |
|
|
const getData = computed(() => { |
|
|
const { pageSize, list } = props; |
|
|
const { pageSize, list } = props; |
|
|
if (pageSize === false) return []; |
|
|
if (pageSize === false) return []; |
|
|
let size = isNumber(pageSize) ? pageSize : 5; |
|
|
let size = isNumber(pageSize) ? pageSize : 10; |
|
|
return list.slice(size * (unref(current) - 1), size * unref(current)); |
|
|
return list.slice(size * (unref(current) - 1), size * unref(current)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
const getContent = computed(() => { |
|
|
|
|
|
return (item: ListItem) => { |
|
|
|
|
|
switch (item.contentType) { |
|
|
|
|
|
default: |
|
|
|
|
|
case NotificationContentType.Text: |
|
|
|
|
|
return item.description; |
|
|
|
|
|
case NotificationContentType.Html: |
|
|
|
|
|
case NotificationContentType.Json: |
|
|
|
|
|
case NotificationContentType.Markdown: |
|
|
|
|
|
return item.title; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
watch( |
|
|
watch( |
|
|
() => props.currentPage, |
|
|
() => props.currentPage, |
|
|
(v) => { |
|
|
(v) => { |
|
|
@ -113,12 +132,15 @@ |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
|
const isTitleClickable = computed(() => !!props.onTitleClick); |
|
|
const isTitleClickable = computed(() => !!props.onTitleClick); |
|
|
|
|
|
const isContentClickable = computed(() => !!props.onContentClick); |
|
|
const getPagination = computed(() => { |
|
|
const getPagination = computed(() => { |
|
|
const { list, pageSize } = props; |
|
|
const { list, pageSize } = props; |
|
|
if (pageSize > 0 && list && list.length > pageSize) { |
|
|
if (pageSize === false) return false; |
|
|
|
|
|
const size = isNumber(pageSize) ? pageSize : 5; |
|
|
|
|
|
if (size > 0 && list && list.length > size) { |
|
|
return { |
|
|
return { |
|
|
total: list.length, |
|
|
total: list.length, |
|
|
pageSize, |
|
|
pageSize: size, |
|
|
//size: 'small', |
|
|
//size: 'small', |
|
|
current: unref(current), |
|
|
current: unref(current), |
|
|
onChange(page) { |
|
|
onChange(page) { |
|
|
@ -135,7 +157,20 @@ |
|
|
props.onTitleClick && props.onTitleClick(item); |
|
|
props.onTitleClick && props.onTitleClick(item); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return { prefixCls, getPagination, getData, handleTitleClick, isTitleClickable }; |
|
|
function handleContentClick(item: ListItem) { |
|
|
|
|
|
props.onContentClick && props.onContentClick(item); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
prefixCls, |
|
|
|
|
|
getPagination, |
|
|
|
|
|
getData, |
|
|
|
|
|
getContent, |
|
|
|
|
|
handleTitleClick, |
|
|
|
|
|
isTitleClickable, |
|
|
|
|
|
handleContentClick, |
|
|
|
|
|
isContentClickable, |
|
|
|
|
|
}; |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
</script> |
|
|
</script> |
|
|
|