feat: 账号数据看板/ 统一table、checkbox组件样式

This commit is contained in:
rd
2025-06-28 11:31:49 +08:00
parent 80c6b30701
commit 3b1f85c47d
16 changed files with 542 additions and 113 deletions

View File

@ -0,0 +1,153 @@
/*
* @Author: RenXiaoDong
* @Date: 2025-06-28 10:33:06
*/
export const tableColumns = [
{
title: '账号名称',
dataIndex: 'name',
width: 180,
fixed: 'left',
},
{
title: '项目分组',
dataIndex: 'group.name',
width: 180,
fixed: 'left',
},
{
title: '状态',
dataIndex: 'status',
width: 180,
fixed: 'left',
},
{
title: '运营人员',
dataIndex: 'operator.name',
width: 180,
},
{
title: 'AI评价',
dataIndex: 'ai_evaluation',
width: 260,
},
{
title: '粉丝量',
dataIndex: 'fans_number',
width: 180,
tooltip: '账号当前粉丝总数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '总赞藏数',
dataIndex: 'like_number',
width: 180,
tooltip: '账号所有内容的点赞和收藏总数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '观看量',
dataIndex: 'view_number',
width: 180,
tooltip: '账号所有内容的总观看次数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '观看量环比',
dataIndex: 'view_chain',
width: 180,
tooltip: '相比上一周期的观看量变化百分比',
align: 'right',
suffix: '%',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '点赞量',
dataIndex: 'like_number',
width: 180,
tooltip: '账号所有内容的总点赞数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '点赞量环比',
dataIndex: 'like_chain',
width: 180,
tooltip: '相比上一周期的点赞量变化百分比',
align: 'right',
suffix: '%',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '最新内容标题/日期',
dataIndex: 'like_chain1',
width: 240,
tooltip: '最新发布内容的标题和发布日期',
},
{
title: '最新作品观看数',
dataIndex: 'latest_view_number',
width: 180,
tooltip: '最新发布内容的观看次数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '最新作品日增长',
dataIndex: 'latest_daily_growth',
width: 180,
tooltip: '最新作品每日观看量的增长情况',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '次新内容标题/日期',
dataIndex: 'like_chain4',
width: 240,
},
{
title: '次新作品观看数',
dataIndex: 'second_latest_view_number',
width: 180,
tooltip: '倒数第二个发布内容的观看次数',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '次新作品日增长',
dataIndex: 'second_latest_daily_growth',
width: 180,
tooltip: '倒数第二个作品每日观看量的增长情况',
align: 'right',
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{
title: '操作',
dataIndex: 'operation',
width: 120,
fixed: 'right',
},
];

View File

@ -3,75 +3,120 @@
* @Date: 2025-06-27 18:08:04
-->
<template>
<div class="container">
<div class="action-row mb-12px flex justify-between">
<a-checkbox :model-value="checkedAll" :indeterminate="indeterminate" @change="handleChangeAll" />
<div class="flex items-center">
<a-button class="w-110px search-btn mr-12px" size="medium">
<template #icon> <icon-download /> </template>
<template #default>导出数据</template>
</a-button>
<a-button class="w-110px search-btn" size="medium">
<template #icon>
<img :src="icon1" width="14" height="14" />
</template>
<template #default>自定义列</template>
</a-button>
</div>
<div class="action-row mb-12px flex justify-between">
<a-checkbox :model-value="checkedAll" :indeterminate="indeterminate" @change="handleSelectAll">全选</a-checkbox>
<div class="flex items-center">
<a-button class="w-110px search-btn mr-12px" size="medium" @click="handleExport">
<template #icon> <icon-download /> </template>
<template #default>导出数据</template>
</a-button>
<a-button class="w-110px search-btn" size="medium">
<template #icon>
<img :src="icon1" width="14" height="14" />
</template>
<template #default>自定义列</template>
</a-button>
</div>
<a-table
:data="dataSource"
row-key="id"
:row-selection="rowSelection"
:pagination="false"
class="custom-table w-100%"
bordered
>
<template #columns>
<a-table-column title="账号名称" data-index="name" />
<a-table-column title="手机号" data-index="mobile" />
<a-table-column title="账号ID" data-index="account_id" />
<a-table-column title="持有人" data-index="holder_name" />
<a-table-column title="平台" data-index="platform">
<template #cell="{ record }">
{{ record.platform === 0 ? '抖音' : record.platform === 1 ? '小红书' : '-' }}
</template>
</a-table-column>
<a-table-column title="分组" data-index="group.name" />
<a-table-column title="运营人员" data-index="operator.name" />
<a-table-column title="粉丝数" data-index="fans_number" />
<a-table-column title="点赞数" data-index="like_number" />
<a-table-column title="收藏数" data-index="collect_number" />
<a-table-column title="观看数" data-index="view_number" />
<a-table-column title="观看环比" data-index="view_chain">
<template #cell="{ record }"> {{ record.view_chain }}% </template>
</a-table-column>
<a-table-column title="点赞环比" data-index="like_chain">
<template #cell="{ record }"> {{ record.like_chain }}% </template>
</a-table-column>
<a-table-column title="状态" data-index="status">
<template #cell="{ record }">
<span v-if="record.status === 0">未授权</span>
<span v-else-if="record.status === 1">正常</span>
<span v-else-if="record.status === 2">异常</span>
<span v-else>-</span>
<span v-if="record.is_pause === 1" class="pause-tag">暂停</span>
</template>
</a-table-column>
<a-table-column title="操作" fixed="right" width="120">
<template #cell="{ record }">
<a-button type="text" size="small" @click="handleEdit(record)">详情</a-button>
</template>
</a-table-column>
</template>
</a-table>
</div>
<a-table
:data="dataSource"
row-key="id"
:row-selection="rowSelection"
:selected-keys="selectedItems"
:pagination="false"
:scroll="{ x: '100%' }"
class="account-table w-100%"
bordered
@sorter-change="handleSorterChange"
@select="handleSelect"
@select-all="handleSelectAll"
>
<template #columns>
<a-table-column
v-for="column in tableColumns"
:key="column.dataIndex"
:data-index="column.dataIndex"
:fixed="column.fixed"
:width="column.width"
:min-width="column.minWidth"
:sortable="column.sortable"
:align="column.align"
ellipsis
tooltip
>
<template #title>
<div class="flex items-center">
<img v-if="column.dataIndex === 'ai_evaluation'" width="16" height="16" :src="icon5" class="mr-4px" />
<span class="cts mr-4px">{{ column.title }}</span>
<a-tooltip v-if="column.tooltip" :content="column.tooltip" position="top">
<icon-question-circle class="tooltip-icon color-#737478" size="16" />
</a-tooltip>
</div>
</template>
<template v-if="column.dataIndex === 'platform'" #cell="{ record }">
{{ record.platform === 0 ? '抖音' : record.platform === 1 ? '小红书' : '-' }}
</template>
<template v-else-if="column.dataIndex === 'status'" #cell="{ record }">
<div class="status-tag" :class="`status-tag-${record.status}`">
<span class="cts status-tag-text">{{
STATUS_LIST.find((item) => item.value === record.status)?.label
}}</span>
</div>
</template>
<template v-else-if="column.dataIndex === 'ai_evaluation'" #cell="{ record }">
<div class="ai-evaluation-row flex">
<img
width="16"
height="16"
:src="record.ai_evaluation?.status === 1 ? icon4 : record.ai_evaluation?.status === 2 ? icon3 : icon2"
class="mr-8px icon"
/>
<div>
<p class="cts">{{ record.ai_evaluation?.text }}</p>
<p class="cts text-12px lh-20px !color-#939499">
{{ `观看: ${record.ai_evaluation?.look_chain}% 点赞: ${record.ai_evaluation?.like_chain}%` }}
</p>
</div>
</div>
</template>
<template v-else-if="column.dataIndex === 'operation'" #cell="{ record }">
<a-button type="outline" size="small" @click="handleDetail(record)">详情</a-button>
</template>
<template v-else-if="['view_chain', 'like_chain'].includes(column.dataIndex)" #cell="{ record }">
<div class="flex items-center rate-row justify-end" :class="record[column.dataIndex] > 0 ? 'up' : 'down'">
<icon-arrow-up v-if="record[column.dataIndex] > 0" size="16" />
<icon-arrow-down v-else size="16" />
{{ formatTableField(column, record) }}
</div>
</template>
<template v-else-if="['like_chain1', 'like_chain4'].includes(column.dataIndex)" #cell="{ record }">
<p class="cts cursor-pointer hover:!color-#6D4CFE">打工人的环游世界旅行计划国内版</p>
<p class="cts text-12px lh-20px !color-#939499">2025-06-18</p>
</template>
<template v-else #cell="{ record }">
{{ formatTableField(column, record, true) }}
</template>
</a-table-column>
</template>
</a-table>
</template>
<script setup>
import { ref, computed } from 'vue';
import { STATUS_LIST } from '../../constants';
import { formatTableField } from '@/utils/tools';
import { tableColumns } from './constants';
import { useRouter } from 'vue-router';
import icon1 from '@/assets/img/media-account/icon-custom.png';
import icon2 from '@/assets/img/media-account/icon-warn.png';
import icon3 from '@/assets/img/media-account/icon-warn-1.png';
import icon4 from '@/assets/img/media-account/icon-success.png';
import icon5 from '@/assets/img/media-account/icon5.png';
const props = defineProps({
dataSource: {
@ -80,7 +125,9 @@ const props = defineProps({
},
});
const emit = defineEmits(['edit', 'delete', 'selectionChange']);
const emit = defineEmits(['selectionChange', 'sorterChange', 'export']);
const router = useRouter();
const selectedItems = ref([]);
@ -91,41 +138,39 @@ const indeterminate = computed(
() => selectedItems.value.length > 0 && selectedItems.value.length < props.dataSource.length,
);
const rowSelection = {
const rowSelection = computed(() => ({
type: 'checkbox',
selectedRowKeys: selectedItems.value,
onChange: (selectedRowKeys, selectedRows) => {
selectedItems.value = selectedRowKeys;
emit('selectionChange', selectedRows);
},
};
showCheckedAll: true,
}));
const handleChangeAll = (checked) => {
const handleSelectAll = (checked) => {
if (checked) {
selectedItems.value = props.dataSource.map((item) => item.id);
} else {
selectedItems.value = [];
}
emit('selectionChange', checked ? props.dataSource : []);
emit('selectionChange', checked ? selectedItems.value : []);
};
const handleEdit = (record) => {
emit('edit', record);
const handleDetail = (record) => {
router.push(`/media-account/detail/${record.id}`);
};
const handleDelete = (record) => {
emit('delete', record);
// 处理排序变化
const handleSorterChange = (column, order) => {
emit('sorterChange', column, order === 'ascend' ? 'asc' : 'desc');
};
const handleSelect = (selectedRowKeys, selectedRows) => {
selectedItems.value = selectedRowKeys;
emit('selectionChange', selectedRows);
};
const handleExport = () => {
emit('export');
};
</script>
<style scoped lang="scss">
@import './style.scss';
.custom-table {
:deep(.pause-tag) {
color: #f64b31;
margin-left: 4px;
font-size: 12px;
}
}
</style>

View File

@ -1,10 +1,63 @@
.container {
width: 100%;
.action-row {
:deep(.arco-btn) {
.arco-btn-icon {
line-height: 14px;
}
.action-row {
:deep(.arco-btn) {
.arco-btn-icon {
line-height: 14px;
}
}
}
.account-table {
.cts {
color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
.status-tag {
width: fit-content;
display: flex;
height: 28px;
padding: 0px 8px;
align-items: center;
border-radius: 2px;
background: var(--Functional-Red-1, #ffe9e7);
.status-tag-text {
color: var(--Functional-Red-6, #f64b31);
}
&-3 {
background: #fff7e5;
.status-tag-text {
color: var(--Functional-yellow-6, #ffae00);
}
}
&-1 {
background: var(--Functional-Green-1, #ebf7f2);
.status-tag-text {
color: var(--Functional-Green-6, #25c883);
}
}
&-0 {
background: var(--BG-200, #f2f3f5);
.status-tag-text {
color: var(--Text-2, #3c4043);
}
}
}
.ai-evaluation-row {
.icon {
position: relative;
top: 1px;
}
}
.rate-row {
&.up {
color: var(--Functional-Red-6, #f64b31);
}
&.down {
color: var(--Functional-Green-6, #25c883);
}
}
}

View File

@ -40,6 +40,8 @@ export const INITIAL_QUERY = {
operator_id: '',
group_ids: [],
date_range: '',
column: '',
order: '',
};
export enum EnumStatus {

View File

@ -21,7 +21,7 @@
<img :src="icon1" width="14" height="14" class="cursor-pointer ml-4px" />
</a-tooltip>
</div>
<span class="s1 color-#211F24 ml-28px">{{
<span class="s1 color-#211F24 ml-32px">{{
item.prop === 'total_like_number'
? formatNumberShow(overviewData.total_like_number + overviewData.total_collect_number)
: formatNumberShow(overviewData[item.prop])
@ -35,9 +35,9 @@
<div class="table-wrap bg-#fff border-radius-8px px-24px py-24px flex-1">
<AccountTable
:dataSource="dataSource"
@edit="handleEdit"
@delete="handleDelete"
@selectionChange="handleSelectionChange"
@export="handleExport"
@sorterChange="handleSorterChange"
/>
<div class="pagination-box">
<a-pagination
@ -60,7 +60,7 @@
import FilterBlock from './components/filter-block';
import AccountTable from './components/account-table';
import { getAccountBoardOverview, getAccountBoardList } from '@/api/all/propertyMarketing';
import { getAccountBoardOverview, getAccountBoardList, postAccountBoardExport } from '@/api/all/propertyMarketing';
import { formatNumberShow } from '@/utils/tools';
import { INITIAL_QUERY } from './constants';
@ -71,7 +71,7 @@ import icon1 from '@/assets/img/icon-question.png';
const query = ref(cloneDeep(INITIAL_QUERY));
const dataSource = ref([]);
const overviewData = ref({});
const selectedItems = ref([]);
const selectedRowKeys = ref([]);
const pageInfo = reactive({
page: 1,
pageSize: 20,
@ -97,6 +97,12 @@ const mockData = [
view_number: 5600000,
view_chain: 12.5,
like_chain: 8.3,
ai_evaluation: {
status: 1,
text: '表现优质 | 建议保持',
look_chain: 12.5,
like_chain: 8.3,
},
operator: {
id: 1,
name: '李运营',
@ -123,6 +129,12 @@ const mockData = [
view_number: 3200000,
view_chain: -5.2,
like_chain: 15.7,
ai_evaluation: {
status: 2,
text: '表现中等 | 建议优化',
look_chain: -12.5,
like_chain: 8.3,
},
operator: {
id: 2,
name: '王运营',
@ -149,6 +161,12 @@ const mockData = [
view_number: 0,
view_chain: 0,
like_chain: 0,
ai_evaluation: {
status: 3,
text: '表现较差 | 建议整改',
look_chain: -12.5,
like_chain: -8.3,
},
operator: {
id: 1,
name: '李运营',
@ -266,19 +284,26 @@ const handleReset = () => {
reload();
};
const handleEdit = (record) => {
console.log('编辑账号:', record);
// 这里可以打开编辑弹窗
};
const handleDelete = (record) => {
console.log('删除账号:', record);
// 这里可以打开删除确认弹窗
};
const handleSelectionChange = (selectedRows) => {
selectedItems.value = selectedRows;
console.log('选中的账号:', selectedRows);
selectedRowKeys.value = selectedRows;
console.log('选中的账号:', selectedRowKeys.value);
};
const handleExport = () => {
postAccountBoardExport({
...query.value,
}).then((res) => {
const { code, data } = res;
if (code === 200) {
console.log(data.download_url);
}
});
};
const handleSorterChange = (column, order) => {
query.value.column = column;
query.value.order = order;
reload();
};
onMounted(() => {

View File

@ -40,6 +40,7 @@
}
.table-wrap {
width: 100%;
.pagination-box {
display: flex;
width: 100%;

View File

@ -0,0 +1,32 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-28 11:21:10
-->
<template>
<div>
<h1>账号详情</h1>
</div>
</template>
<script setup>
import { getAccountBoardDetail } from '@/api/all/propertyMarketing';
const route = useRoute();
const id = route.params.id;
const detailData = ref({});
const getDetail = async () => {
const { code, data } = await getAccountBoardDetail(id);
if (code === 200) {
detailData.value = data;
}
};
onMounted(() => {
getDetail();
});
</script>
<style scoped lang="scss">
@import './style.scss';
</style>