feat: 账号批量操作

This commit is contained in:
rd
2025-07-03 17:35:22 +08:00
parent 8070350836
commit 0966252280
5 changed files with 20 additions and 34 deletions

View File

@ -16,7 +16,7 @@
> >
<div class="flex items-center"> <div class="flex items-center">
<img :src="icon1" width="20" height="20" class="mr-12px" /> <img :src="icon1" width="20" height="20" class="mr-12px" />
<span>确认删除 {{ accountName || '-' }} 这个账号吗</span> <span>确认删除 {{ accountName }} 这个账号吗</span>
</div> </div>
<template #footer> <template #footer>
<a-button class="cancel-btn" size="large" @click="onClose">取消</a-button> <a-button class="cancel-btn" size="large" @click="onClose">取消</a-button>
@ -51,7 +51,7 @@ const open = (record) => {
const { id = null, name = '' } = record; const { id = null, name = '' } = record;
accountId.value = id; accountId.value = id;
accountName.value = name; accountName.value = name;
console.log({ name });
visible.value = true; visible.value = true;
}; };

View File

@ -21,7 +21,7 @@
</div> </div>
<div class="field-row"> <div class="field-row">
<span class="label">平台</span> <span class="label">平台</span>
<img :src="item.platform === 0 ? icon1 : icon2" width="20" height="19" /> <img :src="item.platform === 0 ? icon1 : icon2" width="16" height="16" />
</div> </div>
<div class="field-row"> <div class="field-row">
<span class="label">账号ID</span> <span class="label">账号ID</span>
@ -41,7 +41,8 @@
</div> </div>
<div class="field-row"> <div class="field-row">
<span class="label">标签</span> <span class="label">标签</span>
<div class="flex items-center"> <span v-if="!item.tags.length" class="cts">-</span>
<div v-else class="flex items-center">
<a-tooltip <a-tooltip
v-if="item.tags.length > 2" v-if="item.tags.length > 2"
position="bottom" position="bottom"

View File

@ -39,7 +39,11 @@
<template v-if="editType === 'each'"> <template v-if="editType === 'each'">
<a-table :data="accountGroupList" :pagination="false" row-key="id" class="w-100%"> <a-table :data="accountGroupList" :pagination="false" row-key="id" class="w-100%">
<template #columns> <template #columns>
<a-table-column title="账号名称" data-index="name" width="200" /> <a-table-column title="账号名称" data-index="name" width="200">
<template #cell="{ record }">
<span>{{ record.name || '-' }}</span>
</template>
</a-table-column>
<a-table-column title="选择分组" data-index="group_id"> <a-table-column title="选择分组" data-index="group_id">
<template #cell="{ record }"> <template #cell="{ record }">
<div class="flex items-center w-100%"> <div class="flex items-center w-100%">
@ -75,33 +79,20 @@ const form = reactive({
group_id: null, group_id: null,
}); });
const accountGroupList = ref([]); // [{id, name, group_id: null}] const accountGroupList = ref([]);
const isAllEdit = computed(() => editType.value === 'all'); const isAllEdit = computed(() => editType.value === 'all');
const open = (accountList = []) => { const open = (accountList = []) => {
editType.value = 'all'; editType.value = 'all';
groupOptions.value = []; groupOptions.value = [];
form.group_id = null; form.group_id = null;
accountGroupList.value = accountList.map((acc) => ({ accountGroupList.value = accountList;
...acc,
group_id: null,
}));
visible.value = true; visible.value = true;
getTags(); getTags();
}; };
const getTags = async () => { const getTags = async () => {
groupOptions.value = [
{
label: '测试',
value: '1',
},
{
label: 'ceshi2',
value: 2,
},
];
const { code, data } = await fetchAccountGroups(); const { code, data } = await fetchAccountGroups();
if (code === 200) { if (code === 200) {
groupOptions.value = data.map((item) => ({ groupOptions.value = data.map((item) => ({

View File

@ -49,7 +49,11 @@
<template v-if="editType === 'each'"> <template v-if="editType === 'each'">
<a-table :data="accountTagList" :pagination="false" row-key="id" class="w-100%"> <a-table :data="accountTagList" :pagination="false" row-key="id" class="w-100%">
<template #columns> <template #columns>
<a-table-column title="账号名称" data-index="name" width="200" /> <a-table-column title="账号名称" data-index="name" width="200">
<template #cell="{ record }">
<span>{{ record.name || '-' }}</span>
</template>
</a-table-column>
<a-table-column title="选择标签" data-index="tags"> <a-table-column title="选择标签" data-index="tags">
<template #cell="{ record, rowIndex }"> <template #cell="{ record, rowIndex }">
<div class="flex items-center w-100%"> <div class="flex items-center w-100%">
@ -103,7 +107,7 @@ const open = (accountList = []) => {
form.tags = []; form.tags = [];
accountTagList.value = accountList.map((acc) => ({ accountTagList.value = accountList.map((acc) => ({
...acc, ...acc,
tags: [], tags: acc.tags.map((tag) => tag.name),
})); }));
visible.value = true; visible.value = true;
@ -111,16 +115,6 @@ const open = (accountList = []) => {
}; };
const getTags = async () => { const getTags = async () => {
tagOptions.value = [
{
label: '测试1',
value: '测试1',
},
{
label: '测试2',
value: '测试2',
},
];
const { code, data } = await fetchAccountTags(); const { code, data } = await fetchAccountTags();
if (code === 200) { if (code === 200) {
tagOptions.value = data.map((item) => ({ tagOptions.value = data.map((item) => ({

View File

@ -221,12 +221,12 @@ const handleChangeAll = (val) => {
}; };
const handleBatchDelete = () => { const handleBatchDelete = () => {
const ids = selectedItems.value.map((item) => item.id); const ids = selectedItems.value.map((item) => item.id);
const names = selectedItems.value.map((item) => `"${item.name}"`).join(','); const names = selectedItems.value.map((item) => `${item.name || '-'}`).join('');
deleteAccountRef.value?.open({ id: ids, name: names }); deleteAccountRef.value?.open({ id: ids, name: names });
}; };
const handleDelete = (item) => { const handleDelete = (item) => {
const { id, name } = item; const { id, name } = item;
deleteAccountRef.value?.open({ id, name: `"${name}"` }); deleteAccountRef.value?.open({ id, name: `${name || '-'}` });
}; };
const handleCloseTip = () => { const handleCloseTip = () => {
selectedItems.value = []; selectedItems.value = [];