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

210 lines
6.0 KiB
Vue
Raw Normal View History

2025-06-25 18:26:03 +08:00
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 10:00:50
-->
<template>
<div class="account-manage-wrap">
<div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid">
2025-06-25 18:26:03 +08:00
<div class="top flex h-64px px-24px py-10px justify-between items-center">
<p class="text-18px font-400 lh-26px color-#211F24 title">账户管理</p>
<div class="flex items-center">
<a-button type="primary" class="w-112px search-btn" size="medium" @click="handleOpenAccountModal">
2025-06-25 18:26:03 +08:00
<template #icon>
<img :src="icon1" width="16" height="16" />
</template>
<template #default>添加账户</template>
2025-06-25 18:26:03 +08:00
</a-button>
</div>
</div>
<FilterBlock v-model:query="query" @onSearch="handleSearch" @onReset="handleReset" />
2025-06-25 18:26:03 +08:00
</div>
<div
2025-07-02 15:30:13 +08:00
v-if="dataSource.length > 0"
2025-06-25 18:26:03 +08:00
class="tip-row flex justify-between px-16px py-10px w-100% my-12px h-42px"
2025-07-02 15:30:13 +08:00
:class="selectedItems.length > 0 ? 'selected' : 'normal'"
2025-06-25 18:26:03 +08:00
>
<div class="flex items-center">
<div class="flex items-center">
<template v-if="selectedItems.length > 0">
<a-checkbox
:model-value="checkedAll"
:indeterminate="indeterminate"
class="mr-8px"
@change="handleChangeAll"
/>
<span class="label mr-24px">
已选
<span class="color-#6D4CFE">{{ selectedItems.length }}</span>
个账号
</span>
<span class="operation-btn red" @click="handleBatchDelete"> 批量删除 </span>
</template>
<template v-else>
2025-07-02 15:30:13 +08:00
<img :src="icon4" width="16" height="16" class="mr-8px" />
<span class="label"> 太棒啦所有账号都在正常运行 </span>
</template>
</div>
2025-06-25 18:26:03 +08:00
</div>
<template v-if="selectedItems.length > 0">
<img :src="icon6" width="16" height="16" class="cursor-pointer" @click="handleCloseTip" />
</template>
2025-06-25 18:26:03 +08:00
</div>
<div class="card-wrap">
<AccountTable
2025-07-02 15:30:13 +08:00
v-if="dataSource.length > 0"
:dataSource="dataSource"
:selectedItems="selectedItems"
@selectionChange="handleSelectionChange"
@delete="handleDelete"
@openEdit="handleOpenEdit"
2025-07-02 15:30:13 +08:00
@update="getData"
/>
2025-07-02 15:30:13 +08:00
<NoData v-else />
<div v-if="pageInfo.total > 0" class="pagination-box">
2025-06-25 18:26:03 +08:00
<a-pagination
:total="pageInfo.total"
size="mini"
show-total
show-jumper
2025-07-02 15:30:13 +08:00
:show-page-size="false"
2025-06-25 18:26:03 +08:00
:current="pageInfo.page"
:page-size="pageInfo.pageSize"
@change="onPageChange"
@page-size-change="onPageSizeChange"
/>
</div>
</div>
2025-07-02 15:30:13 +08:00
<AddAccountModal ref="addAccountModalRef" @update="getData" />
<DeleteAccountModal ref="deleteAccountRef" @update="onDeleteSuccess" />
2025-06-25 18:26:03 +08:00
</div>
</template>
<script setup>
import { ref } from 'vue';
import FilterBlock from './components/filter-block';
import AccountTable from './components/account-table';
import AddAccountModal from './components/add-account-modal';
import DeleteAccountModal from './components/account-table/delete-account';
2025-06-25 18:26:03 +08:00
import { INITIAL_QUERY } from './constants';
2025-07-02 15:30:13 +08:00
import { getPlacementAccounts } from '@/api/all/propertyMarketing';
2025-06-25 18:26:03 +08:00
import icon1 from '@/assets/img/media-account/icon-add.png';
import icon4 from '@/assets/img/media-account/icon-success.png';
import icon5 from '@/assets/img/media-account/icon-warn.png';
import icon6 from '@/assets/img/media-account/icon-close.png';
const groupManageModalRef = ref(null);
const tagsManageModalRef = ref(null);
const addAccountModalRef = ref(null);
const deleteAccountRef = ref(null);
2025-06-25 18:26:03 +08:00
const pageInfo = reactive({
page: 1,
2025-07-02 15:30:13 +08:00
pageSize: 8,
total: 0,
2025-06-25 18:26:03 +08:00
});
const query = ref(cloneDeep(INITIAL_QUERY));
const dataSource = ref([]);
const selectedItems = ref([]);
2025-06-25 18:26:03 +08:00
const checkedAll = computed(() => selectedItems.value.length === dataSource.value.length);
const indeterminate = computed(
() => selectedItems.value.length > 0 && selectedItems.value.length < dataSource.value.length,
);
2025-06-25 18:26:03 +08:00
onMounted(() => {
getData();
});
const getData = async () => {
2025-07-02 15:30:13 +08:00
const { page, pageSize } = pageInfo;
const { code, data, total } = await getPlacementAccounts({
page,
page_size: pageSize,
...query.value,
});
if (code === 200) {
dataSource.value = data?.data ?? [];
pageInfo.total = data?.total ?? 0;
}
2025-06-25 18:26:03 +08:00
};
const reload = () => {
pageInfo.page = 1;
getData();
};
const handleSearch = () => {
2025-06-25 18:26:03 +08:00
getData();
};
const handleReset = () => {
pageInfo.page = 1;
pageInfo.pageSize = 20;
pageInfo.total = 0;
selectedItems.value = [];
2025-06-25 18:26:03 +08:00
query.value = cloneDeep(INITIAL_QUERY);
reload();
2025-06-25 18:26:03 +08:00
};
const onPageChange = (current) => {
pageInfo.page = current;
getData();
};
const onPageSizeChange = (pageSize) => {
pageInfo.pageSize = pageSize;
reload();
};
const handleOpenGroupModal = () => {
groupManageModalRef.value?.open();
};
const handleOpenAccountModal = () => {
addAccountModalRef.value?.open();
};
const handleOpenEdit = (item) => {
addAccountModalRef.value?.open(item.id);
};
const handleSelectionChange = (val) => {
selectedItems.value = val;
};
const handleChangeAll = (val) => {
if (val) {
selectedItems.value = cloneDeep(dataSource.value);
} else {
selectedItems.value = [];
}
};
const handleBatchDelete = () => {
const ids = selectedItems.value.map((item) => item.id);
const names = selectedItems.value.map((item) => `"${item.name}"`).join(',');
deleteAccountRef.value?.open({ id: ids, name: names });
};
const handleDelete = (item) => {
const { id, name } = item;
deleteAccountRef.value?.open({ id, name: `"${name}"` });
};
const handleCloseTip = () => {
selectedItems.value = [];
};
2025-07-02 15:30:13 +08:00
// const handleOpenAbnormalAccount = () => {
// query.value.status = 2;
// reload();
// };
const onDeleteSuccess = (ids) => {
selectedItems.value = selectedItems.value.filter((item) => !ids.includes(item.id));
getData();
2025-06-25 18:26:03 +08:00
};
</script>
<style scoped lang="scss">
@import './style.scss';
</style>