新增前端vue
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<a-list :class="prefixCls" bordered :pagination="getPagination">
|
||||
<template v-for="item in getData" :key="item.id">
|
||||
<a-list-item class="list-item" v-if="!item.titleDelete">
|
||||
<a-list-item class="list-item" v-if="item.titleDelete !== '1'">
|
||||
<a-list-item-meta @click="handleTitleClick(item)">
|
||||
<template #title>
|
||||
<div class="title">
|
||||
<a-typography-paragraph
|
||||
style="width: 100%; margin-bottom: 0 !important"
|
||||
:style="{ cursor: isTitleClickable ? 'pointer' : '' }"
|
||||
:delete="!!item.titleDelete"
|
||||
:delete="item.titleDelete === '1'"
|
||||
:ellipsis="
|
||||
$props.titleRows && $props.titleRows > 0 ? { rows: $props.titleRows, tooltip: !!item.title } : false
|
||||
"
|
||||
@@ -61,6 +61,10 @@
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { isNumber } from '@jeesite/core/utils/is';
|
||||
|
||||
interface ExtendedBizListItem extends BizListItem {
|
||||
titleDelete?: '0' | '1' | string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
[Avatar.name as string]: Avatar,
|
||||
@@ -73,7 +77,8 @@
|
||||
},
|
||||
props: {
|
||||
list: {
|
||||
type: Array as PropType<BizListItem[]>,
|
||||
// 更新列表项类型为扩展后的字符串版本
|
||||
type: Array as PropType<ExtendedBizListItem[]>,
|
||||
default: () => [],
|
||||
},
|
||||
pageSize: {
|
||||
@@ -100,19 +105,23 @@
|
||||
setup(props, { emit }) {
|
||||
const { prefixCls } = useDesign('header-notify-list');
|
||||
const current = ref(props.currentPage || 1);
|
||||
const getData = computed<BizListItem[]>(() => {
|
||||
|
||||
const getData = computed<ExtendedBizListItem[]>(() => {
|
||||
const { pageSize, list } = props;
|
||||
if (pageSize === false) return [];
|
||||
let size = isNumber(pageSize) ? pageSize : 5;
|
||||
return list.slice(size * (unref(current) - 1), size * unref(current));
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.currentPage,
|
||||
(v) => {
|
||||
current.value = v;
|
||||
},
|
||||
);
|
||||
|
||||
const isTitleClickable = computed(() => !!props.onTitleClick);
|
||||
|
||||
const getPagination = computed(() => {
|
||||
const { list, pageSize } = props;
|
||||
if ((pageSize as number) > 0 && list && list.length > (pageSize as number)) {
|
||||
@@ -121,7 +130,7 @@
|
||||
pageSize,
|
||||
size: 'small',
|
||||
current: unref(current),
|
||||
onChange(page) {
|
||||
onChange(page: number) {
|
||||
current.value = page;
|
||||
emit('update:currentPage', page);
|
||||
},
|
||||
@@ -131,7 +140,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
function handleTitleClick(item: BizListItem) {
|
||||
// 更新函数参数类型
|
||||
function handleTitleClick(item: ExtendedBizListItem) {
|
||||
props.onTitleClick && props.onTitleClick(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{ item.name }}
|
||||
<span v-if="item.list.length !== 0">({{ item.list.length }})</span>
|
||||
</template>
|
||||
<NoticeList :list="item.list" v-if="item.list.length > 0" @click="openModal(true, item.list)" />
|
||||
<NoticeList :list="item.list" v-if="item.list.length > 0" @click="openModal(true, item.list)" />
|
||||
</TabPane>
|
||||
</template>
|
||||
</Tabs>
|
||||
@@ -65,10 +65,10 @@
|
||||
prefixCls,
|
||||
listData,
|
||||
count,
|
||||
register,
|
||||
openModal,
|
||||
register,
|
||||
openModal,
|
||||
numberStyle: {},
|
||||
getDataList,
|
||||
getDataList,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user