feat: 分组管理

This commit is contained in:
rd
2025-06-26 17:10:53 +08:00
parent ace3d9b574
commit b81f61901f
10 changed files with 432 additions and 81 deletions

View File

@ -48,3 +48,24 @@ export const deleteMediaAccounts = (id: string) => {
export const getTemplateUrl = (params = {}) => { export const getTemplateUrl = (params = {}) => {
return Http.get('/v1/media-accounts/template', params); return Http.get('/v1/media-accounts/template', params);
}; };
// 媒体账号分组-分页
export const getGroupList = (params = {}) => {
return Http.get('/v1/media-account-groups/list', params);
};
// 媒体账号分组 -添加
export const postAccountGroups = (params = {}) => {
return Http.post('/v1/media-account-groups', params);
};
// 媒体账号分组-编辑
export const putGroupList = (params = {}) => {
const { id, ...rest } = params as { id: string; [key: string]: any };
return Http.put(`/v1/media-account-groups/${id}`, rest);
};
// 媒体账号分组-删除
export const deleteGroup = (id: string) => {
return Http.delete(`/v1/media-account-groups/${id}`);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,48 @@
.arco-input-wrapper,
.arco-select-view-single,
.arco-select-view-multiple {
border-radius: 4px;
border-color: #d7d7d9;
background-color: #fff;
&:focus-within,
&.arco-input-focus {
background-color: var(--color-bg-2);
border-color: rgb(var(--primary-6));
box-shadow: 0 0 0 0 var(--color-primary-light-2);
}
}
.arco-modal {
.arco-modal-header {
border-bottom: none;
height: 56px;
padding: 22px 24px 16px 24px;
.arco-modal-title {
justify-content: flex-start;
}
}
.arco-modal-body {
padding: 24px 24px 20px;
.arco-form-item {
margin-bottom: 16px;
.arco-form-item-label {
color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
}
.cancel-btn {
border-radius: 4px;
border: 1px solid var(--BG-500, #b1b2b5);
background: var(--BG-white, #fff);
}
}
.arco-modal-footer {
border-top: none;
padding: 0;
}
}

View File

@ -247,7 +247,7 @@ async function onSubmit() {
formRef.value.validate(async (errors) => { formRef.value.validate(async (errors) => {
if (!errors) { if (!errors) {
const _fn = id.value ? putMediaAccounts : postMediaAccounts; const _fn = id.value ? putMediaAccounts : postMediaAccounts;
const _params = id.value ? { id: id.value } : form; const _params = id.value ? { id: id.value, ...form.value } : form;
const { code } = await _fn(_params); const { code } = await _fn(_params);
if (code === 200) { if (code === 200) {
AMessage.success(isEdit.value ? '修改成功' : '生成授权码成功'); AMessage.success(isEdit.value ? '修改成功' : '生成授权码成功');

View File

@ -1,39 +1,10 @@
@import "@/views/property-marketing/component.scss";
.add-account-modal { .add-account-modal {
border-radius: 8px; border-radius: 8px;
.arco-input-wrapper,
.arco-select-view-single,
.arco-select-view-multiple {
border-radius: 4px;
border-color: #d7d7d9;
background-color: #fff;
&:focus-within,
&.arco-input-focus {
background-color: var(--color-bg-2);
border-color: rgb(var(--primary-6));
box-shadow: 0 0 0 0 var(--color-primary-light-2);
}
}
.w-240px { .w-240px {
width: 240px !important; width: 240px !important;
} }
.arco-modal-header {
border-bottom: none;
height: 56px;
padding: 22px 24px 16px 24px;
.arco-modal-title {
justify-content: flex-start;
}
}
.arco-modal-body { .arco-modal-body {
padding: 24px 24px 20px;
.arco-form-item {
margin-bottom: 16px;
}
.cancel-btn {
border-radius: 4px;
border: 1px solid var(--BG-500, #b1b2b5);
background: var(--BG-white, #fff);
}
.upload-block { .upload-block {
width: 100%; width: 100%;
.dt { .dt {
@ -89,8 +60,4 @@
cursor: pointer; cursor: pointer;
} }
} }
.arco-modal-footer {
border-top: none;
padding: 0;
}
} }

View File

@ -0,0 +1,80 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-26 11:44:17
-->
<template>
<a-modal
v-model:visible="visible"
:title="isEdit ? '编辑分组' : '添加新分组'"
modal-class="account-manage-modal"
width="400px"
:footer="false"
@close="onClose"
>
<a-form ref="formRef" :model="form" :rules="rules" layout="horizontal" auto-label-width>
<a-form-item :label="isEdit ? '分组名称' : '新分组名称'" field="name" required>
<a-input v-model="form.name" placeholder="请输入…" />
</a-form-item>
<div class="text-right">
<a-button class="cancel-btn" @click="onClose">取消</a-button>
<a-button type="primary" class="ml-16px" @click="onSubmit">确认</a-button>
</div>
</a-form>
</a-modal>
</template>
<script setup>
import { ref, watch, nextTick } from 'vue';
import { postAccountGroups, putGroupList } from '@/api/all/propertyMarketing';
const emits = defineEmits(['success', 'close']);
const visible = ref(false);
const isEdit = ref(false);
const formRef = ref();
const form = ref({ name: '' });
const groupId = ref('');
const rules = {
name: [{ required: true, message: '请输入分组名称' }],
};
function resetForm() {
nextTick(() => {
formRef.value?.clearValidate();
});
}
function onClose() {
visible.value = false;
form.value.name = '';
groupId.value = '';
isEdit.value = false;
resetForm();
}
const open = (record = {}) => {
const { id = '', name = '' } = record;
groupId.value = id;
isEdit.value = !!id;
form.value.name = name;
visible.value = true;
};
async function onSubmit() {
formRef.value.validate(async (errors) => {
if (!errors) {
const _fn = isEdit.value ? putGroupList : postAccountGroups;
const _params = isEdit.value ? { id: groupId.value, ...form.value } : form.value;
const { code } = await _fn(_params);
if (code === 200) {
AMessage.success(isEdit.value ? '编辑成功' : '添加成功');
emits('success');
onClose();
}
}
});
}
defineExpose({ open });
</script>

View File

@ -0,0 +1,63 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-26 11:45:05
-->
<template>
<a-modal
v-model:visible="visible"
title="删除分组"
width="400px"
:footer="false"
modal-class="account-manage-modal"
@close="onClose"
>
<div class="flex items-center mb-24px">
<img :src="icon1" width="20" height="20" class="mr-12px" />
<span>确认删除"{{ groupName }}"这个分组吗</span>
</div>
<div class="text-right">
<a-button class="cancel-btn" size="large" @click="onClose">取消</a-button>
<a-button type="primary" class="ml-16px danger-btn" status="danger" size="large" @click="onDelete"
>确认删除</a-button
>
</div>
</a-modal>
</template>
<script setup>
import { ref } from 'vue';
import { deleteGroup } from '@/api/all/propertyMarketing';
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
const emits = defineEmits(['success', 'close']);
const visible = ref(false);
const groupId = ref('');
const groupName = ref('');
function onClose() {
visible.value = false;
groupId.value = '';
groupName.value = '';
emits('close');
}
const open = (record) => {
const { id = '', name = '' } = record;
groupId.value = id;
groupName.value = name;
visible.value = true;
};
async function onDelete() {
const { code } = await deleteGroup(groupId.value);
if (code === 200) {
AMessage.success('删除成功');
emits('success');
onClose();
}
}
defineExpose({ open });
</script>

View File

@ -5,33 +5,179 @@
<template> <template>
<a-modal <a-modal
v-model:visible="visible" v-model:visible="visible"
width="800px" width="900px"
modal-class="account-manage-modal" modal-class="account-manage-modal"
:footer="false" :footer="false"
title="分组管理"
:mask-closable="false" :mask-closable="false"
@close="close" @close="close"
> >
<template #title> 分组管理 </template> <template v-if="!list.length">
<template #footer> </template> <div class="flex items-center justify-center flex-col">
<div class="w-120px h-120px flex items-center justify-center mb-32px">
<img :src="icon2" width="106" height="72" />
</div>
<span class="s1 mb-16px">暂无分组</span>
<a-button type="primary" class="mb-16px" size="medium" @click="openAdd"
><template #icon>
<img :src="icon3" width="16" height="16" />
</template>
<template #default>去添加</template>
</a-button>
</div>
</template>
<template v-else>
<a-button type="primary" class="mb-16px" size="medium" @click="openAdd"
><template #icon>
<img :src="icon3" width="16" height="16" />
</template>
<template #default>添加新分组</template>
</a-button>
<a-table
:columns="columns"
:data="list"
row-key="id"
:loading="loading"
:scroll="{ y: 500 }"
:pagination="false"
@change="onTableChange"
>
<template #action="{ record }">
<div class="flex items-center">
<img :src="icon1" width="16" height="16" class="mr-8px cursor-pointer" @click="openDelete(record)" />
<a-button type="primary" @click="openEdit(record)">编辑</a-button>
</div>
</template>
</a-table>
<div 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>
</template>
<AddGroup ref="addGroupRef" @success="getData" />
<DeleteGroup ref="deleteGroupRef" @success="getData" />
</a-modal> </a-modal>
</template> </template>
<script setup> <script setup>
import { defineExpose } from 'vue'; import { ref, reactive, onMounted } from 'vue';
import { getGroupList } from '@/api/all/propertyMarketing';
import AddGroup from './add-group.vue';
import DeleteGroup from './delete-group.vue';
import icon1 from '@/assets/img/media-account/icon-delete.png';
import icon2 from '@/assets/img/media-account/icon-empty.png';
import icon3 from '@/assets/img/media-account/icon-add.png';
const visible = ref(false); const visible = ref(false);
const open = () => { const isEdit = ref(false);
visible.value = true; const addGroupRef = ref(null);
}; const deleteGroupRef = ref(null);
const close = () => {
visible.value = false; const currentGroup = ref(null);
};
const handleOk = () => { const list = ref([]);
console.log('handleOk'); const loading = ref(false);
}; const pageInfo = reactive({
defineExpose({ page: 1,
open, pageSize: 20,
total: 0,
}); });
const sortInfo = ref({
field: '',
direction: '',
});
const columns = [
{ title: '分组名称', dataIndex: 'name' },
{
title: '创建人',
dataIndex: 'creator',
render: ({ record }) => record.creator?.name || '-',
},
{
title: '创建日期',
dataIndex: 'created_at',
width: 160,
sortable: {
sortDirections: ['ascend', 'descend'],
},
},
{ title: '操作', slotName: 'action', align: 'center', width: 120 },
];
function open() {
visible.value = true;
getData();
}
function openAdd() {
addGroupRef.value.open();
}
function openEdit(record) {
addGroupRef.value.open(record);
}
function openDelete(record) {
deleteGroupRef.value.open(record);
}
async function getData() {
try {
loading.value = true;
const { page, pageSize } = pageInfo;
const params = {
page,
pageSize,
};
if (sortInfo.value.field && sortInfo.value.direction) {
params.orderField = sortInfo.value.field;
params.orderType = sortInfo.value.direction === 'ascend' ? 'asc' : 'desc';
}
const { code, data } = await getGroupList(params);
if (code === 200) {
list.value = data.list;
pageInfo.total = data.total;
}
} finally {
loading.value = false;
}
}
const onTableChange = (pagination, filters, sorter) => {
if (sorter && sorter.field) {
sortInfo.value.field = sorter.field;
sortInfo.value.direction = sorter.order;
} else {
sortInfo.value.field = '';
sortInfo.value.direction = '';
}
getData();
};
const onPageChange = (current) => {
pageInfo.page = current;
getData();
};
const onPageSizeChange = (pageSize) => {
pageInfo.pageSize = pageSize;
pageInfo.page = 1;
getData();
};
defineExpose({ open });
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -1,18 +1,62 @@
@import '@/views/property-marketing/component.scss';
.account-manage-modal { .account-manage-modal {
border-radius: 8px; border-radius: 8px;
.arco-modal-header { .arco-modal-body {
border-bottom: none; .arco-btn {
height: 56px; .arco-btn-icon {
padding: 22px 24px 16px 24px; line-height: 16px;
.arco-modal-title { }
justify-content: flex-start; }
.s1 {
color: var(--Text-3, #737478);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
.pagination-box {
display: flex;
width: 100%;
padding: 16px 24px;
justify-content: flex-end;
align-items: center;
.arco-pagination {
.arco-pagination-list {
.arco-pagination-item {
border-radius: 4px;
border: 1px solid var(--BG-300, #e6e6e8);
&.arco-pagination-item-ellipsis {
border: none;
}
&.arco-pagination-item-active {
background-color: transparent;
border: 1px solid var(--Brand-Brand-6, #6d4cfe);
}
}
}
.arco-pagination-jumper-prepend {
color: var(--Text-2, #3c4043);
text-align: right;
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
.arco-select-view-single,
.arco-pagination-jumper-input {
border-radius: 4px;
border: 1px solid var(--BG-300, #e6e6e8);
background-color: #fff;
}
}
} }
} }
.arco-modal-body { .danger-btn {
padding: 16px 24px 20px; border: none !important;
} background-color: #f64b31 !important;
.arco-modal-footer {
border-top: none;
padding: 0;
} }
} }

View File

@ -1,21 +1,7 @@
@import "@/views/property-marketing/component.scss";
.import-prompt-modal { .import-prompt-modal {
border-radius: 8px; border-radius: 8px;
.arco-modal-header {
border-bottom: none;
height: 56px;
padding: 22px 24px 16px 24px;
.arco-modal-title {
justify-content: flex-start;
}
}
.arco-modal-body { .arco-modal-body {
padding: 20px 24px 20px;
.cancel-btn {
border-radius: 4px;
border: 1px solid var(--BG-500, #b1b2b5);
background: var(--BG-white, #fff);
}
.tip { .tip {
color: var(--Text-1, #211f24); color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi'; font-family: 'Alibaba PuHuiTi';
@ -25,8 +11,4 @@
line-height: 22px; /* 157.143% */ line-height: 22px; /* 157.143% */
} }
} }
.arco-modal-footer {
border-top: none;
padding: 0;
}
} }