feat: 初始化投放账户管理页面

This commit is contained in:
rd
2025-06-28 17:40:36 +08:00
parent 126c0eab38
commit 12a2805528
16 changed files with 1221 additions and 114 deletions

View File

@ -54,7 +54,7 @@
</a-space>
</div>
</div>
<div class="filter-row flex mb-20px">
<div class="filter-row flex">
<div class="filter-row-item flex items-center">
<span class="label">分组</span>
<a-space class="w-200px">

View File

@ -0,0 +1,69 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-26 17:44:16
-->
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-26 17:23:52
-->
<template>
<a-modal
v-model:visible="visible"
:title="isBatch ? '批量删除账号' : '删除账号'"
width="400px"
modal-class="account-manage-modal"
@close="onClose"
>
<div class="flex items-center">
<img :src="icon1" width="20" height="20" class="mr-12px" />
<span>确认删除 {{ accountName }} 这个账号吗</span>
</div>
<template #footer>
<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
>
</template>
</a-modal>
</template>
<script setup>
import { ref } from 'vue';
import { deleteMediaAccount, batchDeleteMediaAccounts } 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 accountId = ref(null);
const accountName = ref('');
const isBatch = computed(() => Array.isArray(accountId.value));
function onClose() {
visible.value = false;
accountId.value = null;
accountName.value = '';
emits('close');
}
const open = (record) => {
const { id = null, name = '' } = record;
accountId.value = id;
accountName.value = name;
visible.value = true;
};
async function onDelete() {
const _fn = isBatch ? batchDeleteMediaAccounts : deleteMediaAccount;
const { code } = await _fn(accountId.value);
if (code === 200) {
AMessage.success('删除成功');
emits('success');
onClose();
}
}
defineExpose({ open });
</script>

View File

@ -5,14 +5,12 @@
<template>
<div class="card-container">
<div v-for="(item, index) in dataSource" :key="index" class="card-item">
<a-checkbox></a-checkbox>
<a-checkbox :model-value="isSelected(item)" :value="item.id" @change="toggleSelect(item)"></a-checkbox>
<div class="ml-8px flex-1">
<p class="name">{{ item.name }}</p>
<div class="field-row">
<span class="label">状态</span>
<div class="status-box" :class="`status-box-${item.status}`">
<span class="text">{{ STATUS_LIST.find((v) => v.value === item.status)?.label ?? '-' }}</span>
</div>
<StatusBox :status="item.status" />
</div>
<div class="field-row">
<span class="label">平台</span>
@ -37,31 +35,64 @@
<div class="field-row">
<span class="label">标签</span>
<div class="flex items-center">
<div v-for="(tag, index) in item.tags" :key="index" class="tag-box">
<a-tooltip
v-if="item.tags.length > 2"
position="bottom"
:content="
item.tags
.slice(2)
.map((v) => v.name)
.join(',')
"
>
<div class="tag-box">
<span class="text">{{ `+${item.tags.length - 2}` }}</span>
</div>
</a-tooltip>
<div v-for="(tag, index) in item.tags.slice(0, 2).reverse()" :key="index" class="tag-box">
<span class="text">{{ tag.name }}</span>
</div>
</div>
</div>
<div class="operate-row">
<img :src="icon3" width="16" height="16" class="mr-8px cursor-pointer" />
<a-button class="w-64px search-btn mr-8px" size="mini">
<img :src="icon3" width="16" height="16" class="mr-8px cursor-pointer" @click="openDelete(item)" />
<a-button
v-if="showPauseButton(item.status)"
class="w-64px search-btn mr-8px"
size="mini"
@click="handlePause(item)"
>
<template #default>暂停同步</template>
</a-button>
<a-button class="w-64px search-btn mr-8px" size="mini">
<template #default>获取凭证</template>
<a-tooltip v-if="isDisabledReauthorize(item.status)" :content="getTooltipText(item.status)">
<a-button class="w-64px search-btn mr-8px" size="mini" @click="handleReauthorize(item)">
<template #default>重新授权</template>
</a-button>
<a-button class="w-40px search-btn" size="mini">
</a-tooltip>
<template v-else>
<a-button class="w-64px search-btn mr-8px" size="mini" @click="handleReauthorize(item)">
<template #default>{{ isUnauthorizedStatus(item.status) ? '去授权' : '重新授权' }}</template>
</a-button>
</template>
<a-button class="w-40px search-btn" size="mini" @click="openEdit(item)">
<template #default>编辑</template>
</a-button>
</div>
</div>
</div>
<PauseAccountPatchModal ref="pauseAccountPatchModalRef" @success="emits('update')" />
<AuthorizedAccountModal ref="authorizedAccountModalRef" @success="emits('update')" />
</div>
</template>
<script setup>
import { defineProps } from 'vue';
import { STATUS_LIST } from '../../constants';
import { defineProps, ref, computed } from 'vue';
import { STATUS_LIST, EnumStatus } from '../../constants';
import PauseAccountPatchModal from './pause-account-patch';
import StatusBox from '../status-box';
import AuthorizedAccountModal from '../authorized-account-modal';
import icon1 from '@/assets/img/media-account/icon-dy.png';
import icon2 from '@/assets/img/media-account/icon-xhs.png';
@ -72,7 +103,66 @@ const props = defineProps({
type: Array,
default: () => [],
},
selectedItems: {
type: Array,
default: () => [],
},
});
const emits = defineEmits(['openEdit', 'update', 'selectionChange', 'delete']);
const pauseAccountPatchModalRef = ref(null);
const authorizedAccountModalRef = ref(null);
// 判断当前 item 是否被选中
const isSelected = (item) => {
return props.selectedItems.some((i) => i.id === item.id);
};
const toggleSelect = (item) => {
let newSelected;
if (isSelected(item)) {
newSelected = props.selectedItems.filter((i) => i.id !== item.id);
} else {
newSelected = [...props.selectedItems, item];
}
emits('selectionChange', newSelected);
};
const openEdit = (item) => {
emits('openEdit', item);
};
const openDelete = (item) => {
emits('delete', item);
};
const handleReauthorize = (item) => {
const isUnauthorized = isUnauthorizedStatus(item.status);
if (isUnauthorized) {
authorizedAccountModalRef.value?.open(item.id);
}
};
const handlePause = (item) => {
pauseAccountPatchModalRef.value?.open(item);
};
const showPauseButton = (status) => {
return ![EnumStatus.PAUSE, EnumStatus.UNAUTHORIZED].includes(status);
};
const isUnauthorizedStatus = (status) => {
return [EnumStatus.UNAUTHORIZED].includes(status);
};
// 三种异常情况
const isDisabledReauthorize = (status) => {
return [EnumStatus.ABNORMAL_LOGIN, EnumStatus.ABNORMAL_REQUEST, EnumStatus.ABNORMAL_FREEZE].includes(status);
};
const getTooltipText = (status) => {
return STATUS_LIST.find((v) => v.value === status)?.tooltip ?? '-';
};
</script>
<style scoped lang="scss">

View File

@ -0,0 +1,54 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-27 14:41:20
-->
<template>
<a-modal v-model:visible="visible" title="暂停同步" width="400px" modal-class="account-manage-modal" @close="onClose">
<div class="flex items-center">
<img :src="icon1" width="20" height="20" class="mr-12px" />
<span>确认暂停同步 {{ accountName }} 这个账号的数据吗</span>
</div>
<template #footer>
<a-button class="cancel-btn" size="large" @click="onClose">取消</a-button>
<a-button type="primary" class="ml-16px" size="large" @click="onConfirm">确定</a-button>
</template>
</a-modal>
</template>
<script setup>
import { ref } from 'vue';
import { pausePatchAccount } 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 accountId = ref(null);
const accountName = ref('');
function onClose() {
visible.value = false;
accountId.value = null;
accountName.value = '';
emits('close');
}
const open = (record) => {
const { id = null, name = '' } = record;
accountId.value = id;
accountName.value = name;
visible.value = true;
};
async function onConfirm() {
const { code } = await pausePatchAccount(accountId.value);
if (code === 200) {
AMessage.success('暂停成功');
emits('success');
onClose();
}
}
defineExpose({ open });
</script>

View File

@ -1,7 +1,13 @@
@mixin ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card-container {
flex: 1;
display: grid;
grid-template-rows: repeat(2, 1fr); /* 2行 */
// grid-template-rows: repeat(2, 1fr); /* 2行 */
grid-template-columns: repeat(4, 1fr); /* 4列 */
gap: 20px;
.card-item {
@ -21,6 +27,8 @@
// line-height: 22px; /* 157.143% */
}
.label {
margin-right: 20px;
flex-shrink: 0;
color: var(--Text-3, #737478);
font-family: 'Alibaba PuHuiTi';
font-size: 12px;
@ -34,6 +42,7 @@
display: flex;
justify-content: space-between;
.cts {
@include ellipsis;
color: var(--Text-2, #3c4043);
font-family: 'Alibaba PuHuiTi';
font-size: 12px;
@ -41,42 +50,16 @@
font-weight: 400;
line-height: 20px; /* 166.667% */
}
.status-box {
display: flex;
padding: 0px 8px;
align-items: center;
border-radius: 2px;
background: #f2f3f5;
.text {
color: var(--BG-700, #737478);
font-family: 'Alibaba PuHuiTi';
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 166.667% */
}
&-1 {
background: #ebf7f2;
.text {
color: #25c883;
}
}
&-2 {
background: #ffe7e4;
.text {
color: #f64b31;
}
}
}
.tag-box {
display: flex;
height: 16px;
height: 20px;
padding: 0px 4px;
align-items: center;
border-radius: 2px;
background: var(--BG-200, #f2f3f5);
max-width: 100px;
.text {
@include ellipsis();
color: var(--Text-2, #3c4043);
font-family: 'Alibaba PuHuiTi';
font-size: 10px;

View File

@ -0,0 +1,263 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 17:51:46
-->
<template>
<a-modal
v-model:visible="visible"
:title="isEdit ? '编辑账号' : '添加账号'"
modal-class="add-put-account-modal"
width="500px"
:mask-closable="false"
@close="onClose"
>
<a-form ref="formRef" :model="form" :rules="rules" layout="horizontal" auto-label-width>
<a-form-item v-if="!isEdit" label="上传方式" required>
<a-radio-group v-model="uploadType">
<a-radio value="manual">手动添加账号</a-radio>
<a-radio value="batch">批量导入账号</a-radio>
</a-radio-group>
</a-form-item>
<!-- 批量导入账号模式下的内容 -->
<template v-if="isBatchImport">
<a-form-item label="账号文件" required>
<!-- 默认状态 -->
<div class="upload-block">
<template v-if="uploadStatus === 'default'">
<a-upload draggable :custom-request="handleUpload" />
</template>
<template v-else>
<div class="flex items-center">
<div
class="flex items-center justify-between py-9px px-12px flex-1 import-row"
:class="{
error: uploadStatus === 'error',
}"
>
<div class="flex items-center">
<icon-file size="16" />
<span class="name ml-8px">{{ fileName }}</span>
</div>
<span v-if="uploadStatus === 'error'" class="upload-error" @click="retryUpload">点击重试</span>
</div>
<img :src="icon2" width="16" height="16" class="cursor-pointer ml-12px" @click="removeFile" />
</div>
</template>
<div class="flex items-center cursor-pointer mt-8px" @click="handleDownloadTemplate">
<img :src="icon1" width="16" height="16" class="mr-4px" />
<span class="dt">下载账号导入模板.xlsx</span>
</div>
</div>
</a-form-item>
</template>
<!-- 手动添加账号 -->
<template v-else>
<template v-if="isEdit">
<a-form-item label="账号名称" field="name">
<a-input v-model="form.name" placeholder="请输入..." size="large" disabled />
</a-form-item>
<a-form-item label="账号ID" field="account_id">
<a-input v-model="form.account_id" placeholder="请输入..." size="large" disabled />
</a-form-item>
<a-form-item label="状态" field="status">
<StatusBox :status="form.status" />
</a-form-item>
</template>
<a-form-item label="手机号" field="mobile" required>
<a-input v-model="form.mobile" placeholder="请输入..." size="large" />
</a-form-item>
<a-form-item label="运营人员" field="operator_name" required>
<a-input v-model="form.operator_name" placeholder="请输入..." class="w-240px" size="large" />
</a-form-item>
<a-form-item label="号码持有人" field="holder_name" required>
<a-input v-model="form.holder_name" placeholder="请输入..." class="w-240px" size="large" />
</a-form-item>
<a-form-item label="运营平台" :required="!isEdit">
<img v-if="isEdit" :src="form.platform === 0 ? icon3 : icon4" width="24" height="24" />
<a-radio-group v-else v-model="form.platform">
<a-radio :value="0">抖音</a-radio>
<a-radio :value="1">小红书</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="同步项目数据" field="sync_project_data">
<template #label>
<span class="label">同步项目数据</span>
<icon-question-circle size="14" class="ml-4px color-#737478" />
</template>
<a-switch v-model="form.sync_project_data" size="medium" />
</a-form-item>
</template>
</a-form>
<template #footer>
<a-button size="large" class="cancel-btn" @click="onClose">取消</a-button>
<a-button type="primary" size="large" @click="onSubmit">
{{ confirmBtnText }}
</a-button>
</template>
<AuthorizedAccountModal ref="authorizedAccountModalRef" />
<ImportPromptModal ref="importPromptModalRef" />
</a-modal>
</template>
<script setup>
import { ref, reactive } from 'vue';
import AuthorizedAccountModal from '../authorized-account-modal';
import ImportPromptModal from '../import-prompt-modal';
import StatusBox from '../status-box';
import {
postMediaAccounts,
getMediaAccountsDetail,
putMediaAccounts,
getTemplateUrl,
} from '@/api/all/propertyMarketing';
import icon1 from '@/assets/img/media-account/icon-download.png';
import icon2 from '@/assets/img/media-account/icon-delete.png';
import icon3 from '@/assets/img/media-account/icon-dy.png';
import icon4 from '@/assets/img/media-account/icon-xhs.png';
const visible = ref(false);
const uploadType = ref('manual');
const uploadStatus = ref('default');
const id = ref('');
const isEdit = ref(false);
const fileName = ref('账号导入模板.xlsx');
const formRef = ref();
const authorizedAccountModalRef = ref(null);
const importPromptModalRef = ref(null);
const form = reactive({
mobile: '',
operator_name: '',
holder_name: '',
platform: 0,
});
const isBatchImport = computed(() => uploadType.value === 'batch');
const confirmBtnText = computed(() => {
if (isBatchImport.value) return '确定导入';
return isEdit.value ? '确定' : '下一步';
});
const rules = {
mobile: [
{
required: true,
message: '请填写手机号',
trigger: ['blur', 'change'],
},
{
validator: (value, callback) => {
if (!/^1[3-9]\d{9}$/.test(value)) {
callback('手机号格式不正确');
} else {
callback();
}
},
trigger: ['blur', 'change'],
},
],
operator_name: [{ required: true, message: '请输入运营人员' }],
holder_name: [{ required: true, message: '请输入号码持有人' }],
};
function handleUpload({ file, onSuccess, onError }) {
// 模拟上传
uploadStatus.value = 'error';
}
function removeFile() {
fileName.value = '';
uploadStatus.value = 'default';
}
function retryUpload() {
handleUpload();
// uploadStatus.value = 'default';
}
const reset = () => {
formRef.value.resetFields();
formRef.value.clearValidate();
fileName.value = '';
isEdit.value = false;
uploadStatus.value = 'default';
uploadType.value = 'manual';
};
function onClose() {
reset();
visible.value = false;
}
const open = (accountId = '') => {
id.value = accountId;
isEdit.value = !!accountId;
if (accountId) {
getAccountDetail();
}
visible.value = true;
};
const getAccountDetail = async () => {
const { code, data } = await getMediaAccountsDetail(id.value);
if (code === 200) {
form.value = data;
}
};
const handleBatchImport = () => {
onClose();
importPromptModalRef.value.open();
};
async function onSubmit() {
if (isBatchImport.value) {
handleBatchImport();
return;
}
handleSuccess();
formRef.value.validate(async (errors) => {
if (!errors) {
const _fn = id.value ? putMediaAccounts : postMediaAccounts;
const _params = id.value ? { id: id.value, ...form.value } : form;
const { code, data } = await _fn(_params);
if (code === 200) {
AMessage.success(isEdit.value ? '修改成功' : '添加成功');
if (isEdit.value) {
visible.value = false;
} else {
handleSuccess(data?.id);
}
}
}
});
}
const handleSuccess = (id) => {
authorizedAccountModalRef.value.open(id);
};
const handleDownloadTemplate = async () => {
const { code, data } = await getTemplateUrl();
if (code === 200) {
window.open(data.url, '_blank');
}
};
// 对外暴露打开弹窗方法
defineExpose({ open });
</script>
<style lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,63 @@
@import "@/views/property-marketing/component.scss";
.add-put-account-modal {
border-radius: 8px;
.w-240px {
width: 240px !important;
}
.arco-modal-body {
.upload-block {
width: 100%;
.dt {
color: var(--Brand-Brand-6, #6d4cfe);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
.import-row {
border-radius: 4px;
border: 1px solid var(--BG-400, #d7d7d9);
background: var(--BG-200, #f2f3f5);
.name {
color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
&.error {
background: #ffe7e4;
color: #f64b31;
border: none;
.name {
color: #f64b31;
}
}
}
.arco-upload-drag {
height: 120px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.arco-icon {
margin-bottom: 16px;
}
}
}
.upload-dragger {
border: 1px dashed #d9d9d9;
padding: 24px 0;
text-align: center;
background: #fafafa;
cursor: pointer;
}
.upload-error {
color: #f53f3f;
margin-left: 8px;
cursor: pointer;
}
}
}

View File

@ -0,0 +1,177 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 17:51:46
-->
<template>
<a-modal
v-model:visible="visible"
width="480px"
title="授权账号"
modal-class="authorized-account-modal"
:mask-closable="false"
:footer="!isLoading"
@close="close"
>
<div class="flex flex-col items-center">
<template v-if="isLoading">
<a-progress
:percent="progress"
color="#6D4CFE"
trackColor="#E6E6E8"
size="large"
:stroke-width="4"
type="circle"
/>
<p class="s2 mt-16px">数据同步和初始化中请勿关闭窗口</p>
</template>
<template v-else>
<template v-if="isCompleted">
<img :src="isSuccess ? icon2 : icon3" width="80" height="80" class="mb-16px" />
<p class="s2">{{ `数据初始化${isSuccess ? '成功' : '失败'}` }}</p>
<p v-if="!isSuccess" class="red-text">失败原因{{ failReason || '-' }}</p>
</template>
<template v-else>
<!-- <div class="flex items-center mb-16px">
<img :src="icon1" width="16" height="16" />
<span class="ml-8px red-text">未识别到有效二维码</span>
</div> -->
<div class="img-box">
<img :src="imgUrl" width="160" height="160" class="mb-16px" />
<div v-if="isOverdue" class="mask" @click="getAuthorizedQrCode">
<icon-refresh size="24" class="mb-13px" />
<p class="s1">二维码失效</p>
<p class="s1">请点击刷新</p>
</div>
</div>
<span> 请使用抖音扫码将公司账号绑定至灵机平台 </span>
</template>
</template>
</div>
<template #footer>
<a-button v-if="isCompleted" size="large" class="cancel-btn" @click="close">取消</a-button>
<a-button type="primary" size="large" @click="handleOk">{{ confirmBtnText }} </a-button>
</template>
</a-modal>
</template>
<script setup>
import { defineExpose, ref, onUnmounted } from 'vue';
import { startPatchAccount, getAuthorizedImage } from '@/api/all/propertyMarketing';
import icon1 from '@/assets/img/media-account/icon-warn.png';
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
const OVERDUE_TIME = 30000; // 失效时间
const visible = ref(false);
const isOverdue = ref(false); // 二维码失效
const isLoading = ref(false);
const isCompleted = ref(false);
const isSuccess = ref(false);
const failReason = ref('');
const progress = ref(0);
const id = ref('');
const imgUrl = ref('');
let progressTimer = null;
let overdueTimer = null;
const notCompleted = computed(() => {
return !isCompleted.value;
});
const confirmBtnText = computed(() => {
if (notCompleted.value) return '完成扫码';
return isSuccess.value ? '继续添加' : '重新扫码';
});
const open = (accountId) => {
id.value = accountId;
getAuthorizedQrCode();
visible.value = true;
};
const close = () => {
isOverdue.value = false;
isLoading.value = false;
isCompleted.value = false;
isSuccess.value = false;
failReason.value = '';
progress.value = 0;
id.value = '';
clearFakeProgressTimer();
clearOverdueTimer();
visible.value = false;
};
const getAuthorizedQrCode = async () => {
const { code, data } = await getAuthorizedImage(id.value);
if (code === 200) {
imgUrl.value = data.url;
overdueTimer = null;
// 约定后端限制40s内必须扫码前端定30s后失效
overdueTimer = setTimeout(() => {
isOverdue.value = true;
}, OVERDUE_TIME);
}
};
const startLoading = async () => {
isLoading.value = true;
progress.value = 0;
startFakeProgressPolling();
// const { code } = await startPatchAccount(id.value);
// if (code === 200) {
// isLoading.value = true;
// progress.value = 0;
// startFakeProgressPolling();
// }
};
const startFakeProgressPolling = () => {
clearFakeProgressTimer();
progressTimer = setInterval(() => {
if (progress.value < 0.99) {
const step = Math.random() * 0.04 + 0.01;
progress.value = Math.min(progress.value + step, 0.99);
progress.value = Number(progress.value.toFixed(2));
} else {
clearFakeProgressTimer();
}
}, 1000);
};
const clearFakeProgressTimer = () => {
if (progressTimer) {
clearInterval(progressTimer);
progressTimer = null;
}
};
const clearOverdueTimer = () => {
if (overdueTimer) {
clearTimeout(overdueTimer);
overdueTimer = null;
}
};
const handleOk = () => {
if (notCompleted.value) {
clearOverdueTimer();
if (isOverdue.value) {
AMessage.error('二维码已失效,请重新扫码');
return;
}
startLoading();
return;
}
};
defineExpose({
open,
});
</script>
<style lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,49 @@
@import '@/views/property-marketing/component.scss';
.authorized-account-modal {
border-radius: 8px;
.img-box {
position: relative;
.mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.8;
background: #000;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
.s1 {
color: var(--BG-White, #fff);
text-align: center;
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
}
}
.s2 {
color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
.red-text {
overflow: hidden;
color: var(--Functional-Red-6, #f64b31);
text-overflow: ellipsis;
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px;
}
}

View File

@ -1,3 +1,4 @@
<!-- eslint-disable vue/no-mutating-props -->
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 14:02:40
@ -24,10 +25,10 @@
</div>
<div class="filter-row-item flex items-center">
<span class="label">状态</span>
<a-space class="w-160px">
<a-space class="w-180px">
<a-select v-model="query.status" size="medium" placeholder="全部" allow-clear @change="handleSearch">
<a-option v-for="(item, index) in STATUS_LIST" :key="index" :value="item.value" :label="item.label">{{
item.label
<a-option v-for="(item, index) in STATUS_LIST" :key="index" :value="item.value" :label="item.text">{{
item.text
}}</a-option>
</a-select>
</a-space>
@ -46,13 +47,15 @@
<span class="label">运营人员</span>
<a-space class="w-160px">
<a-select v-model="query.operator_id" size="medium" placeholder="全部" allow-clear @change="handleSearch">
<a-option value="Beijing" label="Beijing">Beijing</a-option>
<a-option v-for="(item, index) in operators" :key="index" :value="item.id" :label="item.name">{{
item.name
}}</a-option>
</a-select>
</a-space>
</div>
</div>
<a-space class="flex items-center">
<a-button class="w-84px search-btn" size="medium" @click="handleSearch">
<div class="filter-row flex">
<a-button class="w-84px search-btn mr-12px" size="medium" @click="handleSearch">
<template #icon>
<icon-search />
</template>
@ -64,29 +67,47 @@
</template>
<template #default>重置</template>
</a-button>
</a-space>
</div>
</div>
</template>
<script setup>
import { reactive, defineEmits, defineProps } from 'vue';
import { defineEmits, defineProps } from 'vue';
import { fetchAccountOperators } from '@/api/all/propertyMarketing';
import {
INITIAL_QUERY,
PLATFORM_LIST,
STATUS_LIST,
} from '@/views/property-marketing/media-account/account-manage/constants';
} from '@/views/property-marketing/put-account/account-manage/constants';
const emits = defineEmits('onSearch', 'onReset');
const props = defineProps({
query: {
type: Object,
required: true,
},
});
const query = ref(cloneDeep(INITIAL_QUERY));
const emits = defineEmits('onSearch', 'onReset', 'update:query');
const operators = ref([]);
const handleSearch = () => {
emits('onSearch', query);
emits('onSearch', props.query);
};
const handleReset = () => {
query.value = cloneDeep(INITIAL_QUERY);
emits('onReset');
};
const getOperators = async () => {
const { code, data } = await fetchAccountOperators();
if (code === 200) {
operators.value = data;
}
};
onMounted(() => {
// getOperators();
});
</script>
<style scoped lang="scss">

View File

@ -0,0 +1,49 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 17:51:46
-->
<template>
<a-modal
v-model:visible="visible"
width="480px"
title="导入提示"
modal-class="import-prompt-modal"
:mask-closable="false"
@close="close"
>
<div class="flex flex-col items-center">
<div class="flex items-center">
<img :src="icon1" width="20" height="20" class="mr-12px" />
<span class="tip"> 账号已成功导入当前为未授权状态请前往卡片列表手动授权完成授权后账号可正常使用 </span>
</div>
</div>
<template #footer>
<a-button size="large" class="mr-16px cancel-btn" @click="close">取消</a-button>
<a-button type="primary" size="large" @click="handleOk"> 去授权 </a-button>
</template>
</a-modal>
</template>
<script setup>
import { defineExpose } from 'vue';
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
const visible = ref(false);
const open = () => {
visible.value = true;
};
const close = () => {
visible.value = false;
};
const handleOk = () => {
close();
};
defineExpose({
open,
});
</script>
<style lang="scss">
@import './style.scss';
</style>

View File

@ -0,0 +1,14 @@
@import "@/views/property-marketing/component.scss";
.import-prompt-modal {
border-radius: 8px;
.arco-modal-body {
.tip {
color: var(--Text-1, #211f24);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
}
}
}

View File

@ -0,0 +1,96 @@
<!--
* @Author: RenXiaoDong
* @Date: 2025-06-25 15:31:15
-->
<template>
<div class="status-box" :class="`status-box-${status}`">
<span class="text">{{ statusText }}</span>
<a-tooltip v-if="showTooltip" :content="tooltipText">
<img v-if="showIcon" :src="iconSrc" width="12" height="12" class="ml-4px" />
</a-tooltip>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { STATUS_LIST, EnumStatus } from '../../constants';
import iconWarn1 from '@/assets/img/media-account/icon-warn-1.png';
import iconWarn2 from '@/assets/img/media-account/icon-warn-2.png';
const props = defineProps({
status: {
type: Number,
required: true,
},
});
const statusText = computed(() => {
return STATUS_LIST.find((v) => v.value === props.status)?.label ?? '-';
});
const showTooltip = computed(() => {
return isDisabledReauthorize(props.status);
});
const tooltipText = computed(() => {
return STATUS_LIST.find((v) => v.value === props.status)?.tooltip ?? '-';
});
const showIcon = computed(() => {
return ![EnumStatus.NORMAL, EnumStatus.UNAUTHORIZED].includes(props.status);
});
const iconSrc = computed(() => {
return props.status === EnumStatus.PAUSE ? iconWarn1 : iconWarn2;
});
// 判断是否为禁用重新授权的状态
const isDisabledReauthorize = (status) => {
return [EnumStatus.ABNORMAL_LOGIN, EnumStatus.ABNORMAL_REQUEST, EnumStatus.ABNORMAL_FREEZE].includes(status);
};
</script>
<style scoped lang="scss">
.status-box {
display: flex;
padding: 0px 8px;
align-items: center;
border-radius: 2px;
background: #f2f3f5;
.text {
color: var(--BG-700, #737478);
font-family: 'Alibaba PuHuiTi';
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 166.667% */
}
&-1 {
background: #ebf7f2;
.text {
color: #25c883;
}
}
&-2,
&-4,
&-5,
&-6 {
background: #ffe7e4;
.text {
color: #f64b31;
}
}
&-3 {
background: #fff7e5;
color: #ffae00;
.text {
color: #ffae00;
}
}
}
</style>

View File

@ -20,17 +20,53 @@ export const PLATFORM_LIST = [
},
];
export enum EnumStatus {
NORMAL = 1,
PAUSE = 3,
UNAUTHORIZED = 0,
ABNORMAL = 2,
ABNORMAL_LOGIN = 4,
ABNORMAL_REQUEST = 5,
ABNORMAL_FREEZE = 6,
}
export const STATUS_LIST = [
{
label: '未授权',
value: 0,
},
{
text: '正常',
label: '正常',
value: 1,
value: EnumStatus.NORMAL,
},
{
text: '暂停同步',
label: '暂停同步',
value: EnumStatus.PAUSE,
},
{
text: '未授权',
label: '未授权',
value: EnumStatus.UNAUTHORIZED,
},
{
text: '异常',
label: '异常',
value: 2,
value: EnumStatus.ABNORMAL,
},
{
text: '异常-登录状态失效',
label: '异常',
value: EnumStatus.ABNORMAL_LOGIN,
tooltip: '登录状态失效,需重新扫码授权',
},
{
text: '异常-请求过于频繁',
label: '异常',
value: EnumStatus.ABNORMAL_REQUEST,
tooltip: '请求过于频繁需等待24小时后重试',
},
{
text: '异常-账号被冻结/封禁',
label: '异常',
value: EnumStatus.ABNORMAL_FREEZE,
tooltip: '账号被冻结/封禁',
},
];

View File

@ -4,30 +4,43 @@
-->
<template>
<div class="account-manage-wrap">
<div class="filter-wrap bg-#fff border-radius-8px">
<div class="filter-wrap bg-#fff rounded-8px border-1px border-#D7D7D9 border-solid">
<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-139px search-btn" size="medium">
<a-button type="primary" class="w-112px search-btn" size="medium" @click="handleOpenAccountModal">
<template #icon>
<img :src="icon1" width="16" height="16" />
</template>
<template #default>添加投放账号</template>
<template #default>添加账户</template>
</a-button>
</div>
</div>
<FilterBlock @onSearch="handleSearch" @onReset="handleReset" />
<FilterBlock v-model:query="query" @onSearch="handleSearch" @onReset="handleReset" />
</div>
<div
class="tip-row flex justify-between px-16px py-10px w-100% my-12px h-42px"
:class="{
normal: isNormalStatus,
abnormal: isAbnormalStatus,
}"
:class="selectedItems.length > 0 ? 'selected' : isNormalStatus ? 'normal' : 'abnormal'"
>
<div class="flex items-center">
<template v-if="isNormalStatus || isAbnormalStatus">
<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>
<img :src="isNormalStatus ? icon4 : icon5" width="16" height="16" class="mr-8px" />
<span class="label">
{{
@ -38,16 +51,27 @@
</span>
</template>
</div>
<div>
</div>
<template v-if="selectedItems.length > 0">
<img :src="icon6" width="16" height="16" class="cursor-pointer" @click="handleCloseTip" />
</template>
<div v-else>
<a-space v-if="isAbnormalStatus" class="flex items-center">
<a-button class="w-96px err-btn" size="mini">
<a-button class="w-96px err-btn" size="mini" @click="handleOpenAbnormalAccount">
<template #default>查看异常账号</template>
</a-button>
</a-space>
</div>
</div>
<div class="card-wrap">
<AccountTable :dataSource="dataSource" />
<AccountTable
:dataSource="dataSource"
:selectedItems="selectedItems"
@selectionChange="handleSelectionChange"
@delete="handleDelete"
@openEdit="handleOpenEdit"
/>
<div class="pagination-box">
<a-pagination
:total="pageInfo.total"
@ -62,6 +86,9 @@
/>
</div>
</div>
<AddAccountModal ref="addAccountModalRef" />
<DeleteAccountModal ref="deleteAccountRef" @update="getData" />
</div>
</template>
@ -70,11 +97,21 @@ 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';
import { INITIAL_QUERY } from './constants';
import { getMediaAccounts } from '@/api/all/propertyMarketing';
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);
const tipStatus = ref(2);
const pageInfo = reactive({
@ -82,25 +119,71 @@ const pageInfo = reactive({
pageSize: 20,
total: 100,
});
const query = ref(cloneDeep(INITIAL_QUERY));
const dataSource = ref([]);
const selectedItems = ref([]);
const isNormalStatus = computed(() => tipStatus.value === 1);
const isAbnormalStatus = computed(() => tipStatus.value === 2);
const checkedAll = computed(() => selectedItems.value.length === dataSource.value.length);
const indeterminate = computed(
() => selectedItems.value.length > 0 && selectedItems.value.length < dataSource.value.length,
);
onMounted(() => {
getData();
});
const getData = () => {
console.log('getData', query.value, pageInfo);
dataSource.value = new Array(8).fill({
const getData = async () => {
console.log('getData');
// const { page, pageSize } = pageInfo;
// const { code, data, total } = await getMediaAccounts({
// page,
// page_size: pageSize,
// ...query.value,
// });
// if (code === 200) {
// dataSource.value = data.data;
// pageInfo.total = total;
// }
dataSource.value = [
{
id: 1,
name: '全球',
account_id: 1,
mobile: 1777777,
status: 1,
status: 0,
platform: 0,
operator: {
name: '小周',
},
group: {
name: '美团组',
},
tags: [
{
name: '标签1',
},
{
name: '标签2',
},
{
name: '标签3',
},
{
name: '标签4',
},
{
name: '标签5',
},
],
},
{
id: 2,
name: '全球2',
account_id: 1,
mobile: 1777777,
status: 4,
platform: 0,
operator: {
name: '小周',
@ -116,15 +199,23 @@ const getData = () => {
name: '标签2',
},
],
});
},
];
};
const handleSearch = (newQuery) => {
query.value = { ...newQuery };
const reload = () => {
pageInfo.page = 1;
getData();
};
const handleSearch = () => {
getData();
};
const handleReset = () => {
pageInfo.page = 1;
pageInfo.pageSize = 20;
pageInfo.total = 0;
selectedItems.value = [];
query.value = cloneDeep(INITIAL_QUERY);
getData();
reload();
};
const onPageChange = (current) => {
@ -133,8 +224,45 @@ const onPageChange = (current) => {
};
const onPageSizeChange = (pageSize) => {
pageInfo.pageSize = pageSize;
pageInfo.page = 1;
getData();
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 = [];
};
const handleOpenAbnormalAccount = () => {
query.value.status = 2;
reload();
};
</script>

View File

@ -13,8 +13,6 @@
background: var(--BG-white, #fff);
}
.filter-wrap {
border-radius: 8px;
border: 1px solid #e6e6e8;
.top {
.title {
font-family: 'Alibaba PuHuiTi';
@ -58,6 +56,22 @@
font-weight: 400;
line-height: 20px; /* 166.667% */
}
.operation-btn {
padding: 0;
cursor: pointer;
color: var(--Brand-Brand-6, #6d4cfe);
font-family: 'Alibaba PuHuiTi';
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 22px; /* 157.143% */
&:not(:last-child) {
margin-right: 16px;
}
&.red {
color: #F64B31;
}
}
}
.card-wrap {
display: flex;
@ -68,6 +82,7 @@
padding: 16px 24px;
justify-content: flex-end;
align-items: center;
}
}
}