perf: 投放账号-同步数据
This commit is contained in:
@ -285,7 +285,6 @@ export const getPlacementAccountsTrend = (params = {}) => {
|
|||||||
return Http.get(`/v1/placement-accounts/trend`, params);
|
return Http.get(`/v1/placement-accounts/trend`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 投放账号计划数据-趋势
|
// 投放账号计划数据-趋势
|
||||||
export const getPlacementAccountProjectsTrend = (params = {}) => {
|
export const getPlacementAccountProjectsTrend = (params = {}) => {
|
||||||
return Http.get(`/v1/placement-account-projects/trend`, params);
|
return Http.get(`/v1/placement-account-projects/trend`, params);
|
||||||
@ -293,7 +292,7 @@ export const getPlacementAccountProjectsTrend = (params = {}) => {
|
|||||||
|
|
||||||
// 投放指南查询
|
// 投放指南查询
|
||||||
export const getPlacementGuide = (params: {}) => {
|
export const getPlacementGuide = (params: {}) => {
|
||||||
return Http.get(`/v1/placement-account-projects/getGuideList`,params);
|
return Http.get(`/v1/placement-account-projects/getGuideList`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 前端定时轮询获取ai检测结果
|
// 前端定时轮询获取ai检测结果
|
||||||
@ -305,3 +304,8 @@ export const getAiResult = (params: {}) => {
|
|||||||
export const getPlacementAccountsList = (params = {}) => {
|
export const getPlacementAccountsList = (params = {}) => {
|
||||||
return Http.get('/v1/placement-accounts/list', params);
|
return Http.get('/v1/placement-accounts/list', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 投放账号-同步数据
|
||||||
|
export const postPlacementAccountsSync = (id: string) => {
|
||||||
|
return Http.post(`/v1/placement-accounts/${id}/sync-data`);
|
||||||
|
};
|
||||||
|
|||||||
@ -16,9 +16,9 @@
|
|||||||
<div class="flex items-center mb-20px">
|
<div class="flex items-center mb-20px">
|
||||||
<img :src="icon1" width="16" height="16" class="mr-16px" />
|
<img :src="icon1" width="16" height="16" class="mr-16px" />
|
||||||
<p class="s2">
|
<p class="s2">
|
||||||
检测到该账户最后更新日期为{{ exactFormatTime(lastSyncedAt, 'MM-DD', 'YYYY-MM-DD') }},已有{{
|
检测到该账户最后更新日期为{{ exactFormatTime(lastSyncedAt, 'MM月DD日HH:mm', 'YYYY年MM月DD日 HH:mm') }},已有{{
|
||||||
dayjs().diff(dayjs(lastSyncedAt * 1000), 'day')
|
getDaysDiffText(lastSyncedAt)
|
||||||
}}天未同步最新数据。
|
}}未同步最新数据。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<a-radio-group v-model="syncType" class="ml-32px">
|
<a-radio-group v-model="syncType" class="ml-32px">
|
||||||
@ -65,14 +65,18 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { defineExpose, ref, computed, defineEmits } from 'vue';
|
import { defineExpose, ref, computed, defineEmits } from 'vue';
|
||||||
import { exactFormatTime } from '@/utils/tools';
|
import { exactFormatTime } from '@/utils/tools';
|
||||||
import { putPlacementAccountsAuthorized, getPlacementAccountsAuthorizedStatus } from '@/api/all/propertyMarketing';
|
import {
|
||||||
|
putPlacementAccountsAuthorized,
|
||||||
|
getPlacementAccountsAuthorizedStatus,
|
||||||
|
postPlacementAccountsSync,
|
||||||
|
} from '@/api/all/propertyMarketing';
|
||||||
|
|
||||||
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
|
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
|
||||||
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
|
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
|
||||||
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
|
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
|
||||||
|
|
||||||
const emits = defineEmits(['update']);
|
const emits = defineEmits(['update']);
|
||||||
|
const INITIAL_SYNC_TYPE = 'sync';
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const isCompleted = ref(false);
|
const isCompleted = ref(false);
|
||||||
@ -81,9 +85,10 @@ const formRef = ref(null);
|
|||||||
const failReason = ref('');
|
const failReason = ref('');
|
||||||
const progress = ref(0);
|
const progress = ref(0);
|
||||||
const id = ref('');
|
const id = ref('');
|
||||||
const lastSyncedAt = ref(null);
|
|
||||||
const syncType = ref('sync'); // sync | no_sync
|
const lastSyncedAt = ref(null); // 上次同步时间戳
|
||||||
const showSyncTip = ref(false);
|
const showSyncTip = ref(false);
|
||||||
|
const syncType = ref(INITIAL_SYNC_TYPE); // sync | no_sync
|
||||||
|
|
||||||
const INITIAL_FORM = {
|
const INITIAL_FORM = {
|
||||||
account: '',
|
account: '',
|
||||||
@ -111,6 +116,15 @@ const confirmBtnText = computed(() => {
|
|||||||
return isSuccess.value ? '继续添加' : '重试';
|
return isSuccess.value ? '继续添加' : '重试';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getDaysDiffText = (lastSyncedAt) => {
|
||||||
|
if (!lastSyncedAt) return '0天';
|
||||||
|
|
||||||
|
const daysDiff = dayjs().diff(dayjs(lastSyncedAt * 1000), 'day');
|
||||||
|
|
||||||
|
if (daysDiff === 0) return '不到1天';
|
||||||
|
return `${daysDiff}天`;
|
||||||
|
};
|
||||||
|
|
||||||
const open = (accountId, last_synced_at = null) => {
|
const open = (accountId, last_synced_at = null) => {
|
||||||
id.value = accountId;
|
id.value = accountId;
|
||||||
lastSyncedAt.value = last_synced_at;
|
lastSyncedAt.value = last_synced_at;
|
||||||
@ -129,7 +143,7 @@ const close = () => {
|
|||||||
progress.value = 0;
|
progress.value = 0;
|
||||||
id.value = '';
|
id.value = '';
|
||||||
lastSyncedAt.value = null;
|
lastSyncedAt.value = null;
|
||||||
syncType.value = 'sync';
|
syncType.value = INITIAL_SYNC_TYPE;
|
||||||
showSyncTip.value = false;
|
showSyncTip.value = false;
|
||||||
clearFakeProgressTimer();
|
clearFakeProgressTimer();
|
||||||
clearStatusPollingTimer();
|
clearStatusPollingTimer();
|
||||||
@ -206,8 +220,8 @@ const clearFakeProgressTimer = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOk = () => {
|
const handleSyncData = () => {
|
||||||
if (lastSyncedAt.value) {
|
if (!showSyncTip.value) {
|
||||||
formRef.value.validate(async (errors) => {
|
formRef.value.validate(async (errors) => {
|
||||||
if (!errors) {
|
if (!errors) {
|
||||||
showSyncTip.value = true;
|
showSyncTip.value = true;
|
||||||
@ -216,6 +230,23 @@ const handleOk = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (syncType.value === INITIAL_SYNC_TYPE) {
|
||||||
|
postPlacementAccountsSync(id.value).then((res) => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleOk = () => {
|
||||||
|
if (lastSyncedAt.value && lastSyncedAt.value < dayjs().startOf('day').valueOf()) {
|
||||||
|
handleSyncData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isCompleted.value) {
|
if (isCompleted.value) {
|
||||||
if (isSuccess.value) {
|
if (isSuccess.value) {
|
||||||
emits('update');
|
emits('update');
|
||||||
|
|||||||
Reference in New Issue
Block a user