Files
lingji-work-fe/src/views/property-marketing/put-account/account-data/index.vue

154 lines
4.0 KiB
Vue
Raw Normal View History

<!--
* @Author: RenXiaoDong
* @Date: 2025-06-28 14:13:42
-->
<template>
<div class="account-data-wrap">
<div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid pb-24px mb-16px">
<a-tabs v-model="activeTab" @tab-click="handleTabClick">
2025-07-02 17:55:20 +08:00
<a-tab-pane key="1" title="账户"></a-tab-pane>
<a-tab-pane key="2" title="计划"></a-tab-pane>
2025-07-02 16:11:51 +08:00
<template v-if="!isAccountTab" #extra>
<a-button class="w-112px mr-12px search-btn flex items-center" size="medium" @click="handleOpenGroupModal">
<template #icon>
<img :src="icon2" width="16" height="16" />
</template>
<template #default>分组管理</template>
</a-button>
</template>
</a-tabs>
2025-07-02 17:55:20 +08:00
<FilterBlock ref="filterBlockRef" v-model:query="query" @onSearch="getData" @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-07-02 17:55:20 +08:00
<BoardTable
ref="accountTableRef"
:dataSource="dataSource"
@export="handleExport"
@sorterChange="handleSorterChange"
@selectionChange="handleSelectionChange"
/>
2025-07-02 17:55:20 +08:00
<div v-if="pageInfo.total > 0" class="pagination-box">
<a-pagination
:total="pageInfo.total"
size="mini"
show-total
show-jumper
show-page-size
:current="pageInfo.page"
:page-size="pageInfo.pageSize"
@change="onPageChange"
@page-size-change="onPageSizeChange"
/>
</div>
</div>
2025-07-02 16:11:51 +08:00
<GroupManageModal ref="groupManageModalRef" @update="filterBlockRef?.getGroups" />
</div>
</template>
<script setup>
import FilterBlock from './components/filter-block';
2025-07-02 17:55:20 +08:00
import BoardTable from './components/board-table';
2025-07-02 16:11:51 +08:00
import GroupManageModal from './components/group-manage-modal';
2025-07-02 17:55:20 +08:00
import {
getPlacementAccountData,
postPlacementAccountDataExport,
getPlacementAccountDataList,
postPlacementAccountDataListExport,
} from '@/api/all/propertyMarketing';
import { INITIAL_QUERY } from './constants';
2025-07-02 16:11:51 +08:00
import icon2 from '@/assets/img/media-account/icon-group.png';
2025-07-02 17:55:20 +08:00
const selectedRowKeys = ref([]);
const activeTab = ref('1');
const accountTableRef = ref(null);
const groupManageModalRef = ref(null);
const filterBlockRef = ref(null);
const query = ref({});
const dataSource = ref([]);
2025-07-02 17:55:20 +08:00
const pageInfo = ref({
page: 1,
pageSize: 20,
total: 100,
});
2025-07-02 17:55:20 +08:00
const isAccountTab = computed(() => activeTab.value === '1');
2025-07-02 17:55:20 +08:00
const getData = async () => {
const _fn = isAccountTab.value ? getPlacementAccountData : getPlacementAccountDataList;
const { code, data } = await _fn(query.value);
if (code === 200) {
dataSource.value = data?.data ?? [];
pageInfo.value.total = data.total;
}
};
const onPageChange = (current) => {
2025-07-02 17:55:20 +08:00
pageInfo.value.page = current;
getData();
};
const onPageSizeChange = (pageSize) => {
2025-07-02 17:55:20 +08:00
pageInfo.value.pageSize = pageSize;
reload();
};
const reload = () => {
2025-07-02 17:55:20 +08:00
pageInfo.value.page = 1;
getData();
};
const handleReset = () => {
2025-07-02 17:55:20 +08:00
pageInfo.value.page = 1;
pageInfo.value.pageSize = 20;
pageInfo.value.total = 0;
selectedRowKeys.value = [];
accountTableRef.value?.resetTable();
query.value = cloneDeep(INITIAL_QUERY);
reload();
};
const handleSorterChange = (column, order) => {
query.value.column = column;
query.value.order = order;
reload();
};
const handleSelectionChange = (selectedRows) => {
selectedRowKeys.value = selectedRows;
};
2025-07-02 17:55:20 +08:00
const handleTabClick = (key) => {
activeTab.value = key;
handleReset();
};
2025-07-02 17:55:20 +08:00
const handleExport = () => {
const _fn = isAccountTab.value ? postPlacementAccountDataExport : postPlacementAccountDataListExport;
_fn({
...query.value,
}).then((res) => {
const { code, data } = res;
if (code === 200) {
window.open(data.download_url, '_blank');
}
});
};
2025-07-02 16:11:51 +08:00
const handleOpenGroupModal = () => {
groupManageModalRef.value?.open();
};
onMounted(() => {
getData();
});
</script>
<style scoped lang="scss">
@import './style.scss';
</style>