to-do-card.vue
2.75 KB
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
<template>
<a-card class="general-card" title="待处理事项" :body-style="{ paddingBottom: '10px', height: '160px' }">
<a-table
row-key="id"
:loading="loading"
:data="source"
:pagination="pagination"
:show-header="false"
:bordered="false"
size="small"
:table-layout-fixed="true"
@page-change="onPageChange"
>
<template #columns>
<a-table-column data-index="id" :width="36">
<template #cell="{ rowIndex }">{{ getIndex(rowIndex) }}</template>
</a-table-column>
<a-table-column data-index="activity_id" :width="260" :ellipsis="true" :tooltip="true">
<template #cell="{ record }">{{ getTitle(record) }}</template>
</a-table-column>
<a-table-column data-index="msg" :width="200" :ellipsis="true" :tooltip="true" />
<a-table-column data-index="option" :width="50">
<template #cell>
<a-button type="text" @click="onClick()">处理</a-button>
</template>
</a-table-column>
</template>
</a-table>
</a-card>
</template>
<script lang="ts" setup>
import useLoading from '@/hooks/loading';
import { onMounted, ref } from 'vue';
import usePagination from '@/hooks/pagination';
import { add, multiply } from 'lodash';
import { useRouter } from 'vue-router';
import useDashboardApi from '@/api/dashboard';
type ToDoType = {
id: number;
project?: { id: number; name: string };
song_name: string;
msg: string;
};
const { loading, setLoading } = useLoading(false);
const { pagination, setPage, setPageSize, setTotal } = usePagination({ pageSize: 3, showPageSize: false, size: 'mini' });
const source = ref<ToDoType[]>([]);
const router = useRouter();
const getIndex = (index: number) => {
return add(index + 1, multiply(pagination.value.current - 1, pagination.value.pageSize));
};
const getTitle = (record: ToDoType) => {
return `厂牌【${record.project?.name || '无'}】提交的歌曲【${record.song_name}】未通过审核`;
};
const onClick = () => {
router.push({ name: 'audition-apply', query: { auditStatus: 2 } });
};
const onQuery = () => {
setLoading(true);
useDashboardApi
.todo({ page: pagination.value.current, pageSize: pagination.value.pageSize })
.then(({ data, meta }) => {
source.value = data as ToDoType[];
setPage(meta.current);
setPageSize(meta.limit);
setTotal(meta.total);
})
.finally(() => {
setLoading(false);
});
};
const onPageChange = (page: number) => {
pagination.value.current = page;
onQuery();
};
onMounted(() => onPageChange(1));
</script>
<style lang="less" scoped>
:deep(.arco-table-cell) {
padding: 5px 8px !important;
& > .arco-table-td-content .arco-btn-size-small {
padding: 5px !important;
}
}
</style>