Files
lingji-work-fe/src/views/property-marketing/media-account/account-dashboard/index.vue

162 lines
4.4 KiB
Vue
Raw Normal View History

2025-06-25 18:26:03 +08:00
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 10:02:20
-->
2025-06-27 18:37:42 +08:00
<template>
<div class="account-dashboard-wrap">
<div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid px-24px pb-20px mb-16px">
2025-07-02 17:55:20 +08:00
<div class="top flex h-64px py-10px justify-between items-center">
2025-06-27 18:37:42 +08:00
<div class="flex items-center">
<p class="text-18px font-400 lh-26px color-#211F24 title">数据总览</p>
2025-07-02 17:55:20 +08:00
<a-tooltip content="数据纵览">
<img :src="icon1" width="14" height="14" class="ml-4px" />
</a-tooltip>
2025-06-27 18:37:42 +08:00
</div>
</div>
<div class="overview-row flex">
<div v-for="item in CARD_FIELDS" :key="item.prop" class="overview-item flex-1">
<div class="flex items-center mb-8px">
<img :src="item.icon" width="20" height="20" class="mr-8px" />
<p class="label color-#211F24">{{ item.label }}</p>
2025-06-27 18:37:42 +08:00
<a-tooltip v-if="item.tooltip" :content="item.tooltip" position="bottom">
<img :src="icon1" width="14" height="14" class="cursor-pointer ml-4px" />
</a-tooltip>
</div>
<span class="value color-#211F24 ml-32px">{{ formatNumberShow(overviewData[item.prop]) }}</span>
2025-06-27 18:37:42 +08:00
</div>
</div>
</div>
<div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid px-24px py-24px mb-16px">
2025-06-27 18:37:42 +08:00
<FilterBlock v-model:query="query" @onSearch="handleSearch" @onReset="handleReset" />
</div>
<div
class="table-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid px-24px py-24px flex-1 flex flex-col"
>
2025-06-27 18:37:42 +08:00
<AccountTable
ref="accountTableRef"
2025-06-27 18:37:42 +08:00
:dataSource="dataSource"
:query="query"
2025-06-27 18:37:42 +08:00
@selectionChange="handleSelectionChange"
@export="handleExport"
@sorterChange="handleSorterChange"
2025-06-27 18:37:42 +08:00
/>
2025-07-02 17:55:20 +08:00
<div v-if="pageInfo.total > 0" class="pagination-box">
2025-06-27 18:37:42 +08:00
<a-pagination
:total="pageInfo.total"
size="mini"
show-total
show-jumper
show-page-size
:current="pageInfo.page"
2025-07-05 09:48:15 +08:00
:page-size="pageInfo.page_size"
2025-06-27 18:37:42 +08:00
@change="onPageChange"
@page-size-change="onPageSizeChange"
/>
</div>
</div>
</div>
</template>
2025-06-25 18:26:03 +08:00
2025-06-27 18:37:42 +08:00
<script setup>
import FilterBlock from './components/filter-block';
import AccountTable from './components/account-table';
import { getAccountBoardOverview, getAccountBoardList, postAccountBoardExport } from '@/api/all/propertyMarketing';
2025-06-27 18:37:42 +08:00
import { formatNumberShow } from '@/utils/tools';
2025-07-02 15:30:13 +08:00
import { INITIAL_QUERY, CARD_FIELDS } from './constants';
import { downloadByUrl } from '@/utils/tools';
2025-06-27 18:37:42 +08:00
import icon1 from '@/assets/img/icon-question.png';
const query = ref(cloneDeep(INITIAL_QUERY));
const dataSource = ref([]);
const overviewData = ref({});
const selectedRowKeys = ref([]);
const accountTableRef = ref(null);
2025-07-02 17:55:20 +08:00
const pageInfo = ref({
2025-06-27 18:37:42 +08:00
page: 1,
2025-07-05 09:48:15 +08:00
page_size: 20,
2025-07-02 17:55:20 +08:00
total: 0,
2025-06-27 18:37:42 +08:00
});
const getOverviewData = async () => {
2025-07-02 17:55:20 +08:00
const { code, data } = await getAccountBoardOverview();
if (code === 200) {
overviewData.value = data;
}
2025-06-27 18:37:42 +08:00
};
const getData = async () => {
2025-07-05 09:48:15 +08:00
const { page, page_size } = pageInfo.value;
const { code, data } = await getAccountBoardList({
...query.value,
page,
page_size,
});
2025-07-02 17:55:20 +08:00
if (code === 200) {
dataSource.value = data?.data ?? [];
pageInfo.value.total = data.total;
}
2025-06-27 18:37:42 +08:00
};
const onPageChange = (current) => {
2025-07-02 17:55:20 +08:00
pageInfo.value.page = current;
2025-06-27 18:37:42 +08:00
getData();
};
const onPageSizeChange = (pageSize) => {
2025-07-05 09:48:15 +08:00
pageInfo.value.page_size = pageSize;
2025-06-27 18:37:42 +08:00
reload();
};
const handleSearch = () => {
2025-07-05 09:48:15 +08:00
reload();
2025-06-27 18:37:42 +08:00
};
const reload = () => {
2025-07-02 17:55:20 +08:00
pageInfo.value.page = 1;
2025-06-27 18:37:42 +08:00
getData();
};
const handleReset = () => {
selectedRowKeys.value = [];
2025-07-02 17:55:20 +08:00
pageInfo.value.page = 1;
2025-07-05 09:48:15 +08:00
pageInfo.value.page_size = 20;
2025-07-02 17:55:20 +08:00
pageInfo.value.total = 0;
2025-06-27 18:37:42 +08:00
query.value = cloneDeep(INITIAL_QUERY);
accountTableRef.value?.resetTable();
2025-06-27 18:37:42 +08:00
reload();
};
const handleSelectionChange = (selectedRows) => {
selectedRowKeys.value = selectedRows;
2025-06-27 18:37:42 +08:00
};
const handleExport = () => {
postAccountBoardExport({
...query.value,
}).then((res) => {
const { code, data } = res;
if (code === 200) {
downloadByUrl(data.download_url);
}
});
2025-06-27 18:37:42 +08:00
};
const handleSorterChange = (column, order) => {
query.value.column = column;
query.value.order = order;
reload();
2025-06-27 18:37:42 +08:00
};
onMounted(() => {
getOverviewData();
getData();
});
</script>
2025-06-25 18:26:03 +08:00
<style scoped lang="scss">
@import './style.scss';
</style>