mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 调整店铺同步交互改用抽屉
This commit is contained in:
+38
-24
@@ -5,11 +5,10 @@ import type { Dayjs } from 'dayjs';
|
|||||||
|
|
||||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
message,
|
message,
|
||||||
Progress,
|
Progress,
|
||||||
@@ -32,14 +31,18 @@ import {
|
|||||||
togglePddIncrementalSyncApi,
|
togglePddIncrementalSyncApi,
|
||||||
} from '#/api/ecommerce/pdd/order-sync';
|
} from '#/api/ecommerce/pdd/order-sync';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddOrderSyncDrawer' });
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'success'): void;
|
(e: 'success'): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const openFlag = ref(false);
|
||||||
const shop = ref<null | ShopVO.Info>(null);
|
const shop = ref<null | ShopVO.Info>(null);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const submitting = ref(false);
|
||||||
const mode = ref<'day' | 'full' | 'incremental'>('full');
|
const mode = ref<'day' | 'full' | 'incremental'>('full');
|
||||||
const confirmDate = ref<Dayjs>(dayjs().subtract(1, 'day'));
|
const confirmDate = ref<Dayjs>(dayjs().subtract(1, 'day'));
|
||||||
const range = ref<[Dayjs, Dayjs]>([
|
const range = ref<[Dayjs, Dayjs]>([
|
||||||
@@ -50,19 +53,7 @@ const incremental = ref<null | PddOrderSyncVO.IncrementalStatus>(null);
|
|||||||
const fullTask = ref<null | PddOrderSyncVO.FullTask>(null);
|
const fullTask = ref<null | PddOrderSyncVO.FullTask>(null);
|
||||||
let pollTimer: null | ReturnType<typeof setInterval> = null;
|
let pollTimer: null | ReturnType<typeof setInterval> = null;
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const drawerTitle = computed(() =>
|
||||||
draggable: true,
|
|
||||||
class: 'w-[560px]',
|
|
||||||
onCancel() {
|
|
||||||
stopPoll();
|
|
||||||
modalApi.close();
|
|
||||||
},
|
|
||||||
onConfirm() {
|
|
||||||
handleSubmit();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const modalTitle = computed(() =>
|
|
||||||
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -166,7 +157,7 @@ async function pollFullTask(taskId: number) {
|
|||||||
task.status === 'CANCELLED'
|
task.status === 'CANCELLED'
|
||||||
) {
|
) {
|
||||||
stopPoll();
|
stopPoll();
|
||||||
modalApi.setState({ confirmLoading: false });
|
submitting.value = false;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (task.status === 'SUCCESS') {
|
if (task.status === 'SUCCESS') {
|
||||||
message.success(
|
message.success(
|
||||||
@@ -207,7 +198,7 @@ async function handleResumeFull() {
|
|||||||
if (!fullTask.value) return;
|
if (!fullTask.value) return;
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
modalApi.setState({ confirmLoading: true });
|
submitting.value = true;
|
||||||
const task = await resumePddFullSyncTaskApi(fullTask.value.id);
|
const task = await resumePddFullSyncTaskApi(fullTask.value.id);
|
||||||
fullTask.value = task;
|
fullTask.value = task;
|
||||||
message.success('已续跑入队');
|
message.success('已续跑入队');
|
||||||
@@ -216,7 +207,7 @@ async function handleResumeFull() {
|
|||||||
console.error('续跑全量任务失败:', error);
|
console.error('续跑全量任务失败:', error);
|
||||||
message.error('续跑全量任务失败');
|
message.error('续跑全量任务失败');
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
modalApi.setState({ confirmLoading: false });
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +227,7 @@ async function handleSubmit() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
modalApi.setState({ confirmLoading: true });
|
submitting.value = true;
|
||||||
|
|
||||||
if (mode.value === 'full') {
|
if (mode.value === 'full') {
|
||||||
const task = await createPddFullSyncTaskApi({
|
const task = await createPddFullSyncTaskApi({
|
||||||
@@ -269,11 +260,16 @@ async function handleSubmit() {
|
|||||||
} finally {
|
} finally {
|
||||||
if (mode.value !== 'full') {
|
if (mode.value !== 'full') {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
modalApi.setState({ confirmLoading: false });
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
stopPoll();
|
||||||
|
openFlag.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
async function open(record: ShopVO.Info) {
|
async function open(record: ShopVO.Info) {
|
||||||
shop.value = record;
|
shop.value = record;
|
||||||
mode.value = 'full';
|
mode.value = 'full';
|
||||||
@@ -281,18 +277,27 @@ async function open(record: ShopVO.Info) {
|
|||||||
range.value = [dayjs().subtract(90, 'day'), dayjs().subtract(1, 'day')];
|
range.value = [dayjs().subtract(90, 'day'), dayjs().subtract(1, 'day')];
|
||||||
fullTask.value = null;
|
fullTask.value = null;
|
||||||
incremental.value = null;
|
incremental.value = null;
|
||||||
|
submitting.value = false;
|
||||||
|
loading.value = false;
|
||||||
stopPoll();
|
stopPoll();
|
||||||
modalApi.open();
|
openFlag.value = true;
|
||||||
await Promise.all([loadIncrementalStatus(), loadLatestFullTask()]);
|
await Promise.all([loadIncrementalStatus(), loadLatestFullTask()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeUnmount(() => stopPoll());
|
onBeforeUnmount(() => stopPoll());
|
||||||
|
|
||||||
defineExpose({ open });
|
defineExpose({ open, close: handleClose });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="modalTitle" content-class="px-5 py-4">
|
<Drawer
|
||||||
|
v-model:open="openFlag"
|
||||||
|
:title="drawerTitle"
|
||||||
|
width="560"
|
||||||
|
destroy-on-close
|
||||||
|
:mask-closable="!isFullActive"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
<!-- 状态面板 -->
|
<!-- 状态面板 -->
|
||||||
<div class="mb-4 space-y-3">
|
<div class="mb-4 space-y-3">
|
||||||
<div class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]">
|
<div class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]">
|
||||||
@@ -401,5 +406,14 @@ defineExpose({ open });
|
|||||||
按订单更新时间拉取自上次游标以来的变更,用于发货/售后等状态同步。
|
按订单更新时间拉取自上次游标以来的变更,用于发货/售后等状态同步。
|
||||||
</p>
|
</p>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex justify-end gap-2">
|
||||||
|
<Button @click="handleClose">关闭</Button>
|
||||||
|
<Button type="primary" :loading="submitting" @click="handleSubmit">
|
||||||
|
开始同步
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Drawer>
|
||||||
</template>
|
</template>
|
||||||
@@ -19,7 +19,7 @@ import { batchPddOrderSyncStatusApi } from '#/api/ecommerce/pdd/order-sync';
|
|||||||
import { getPlatformListApi } from '#/api/ecommerce/platform';
|
import { getPlatformListApi } from '#/api/ecommerce/platform';
|
||||||
import { deleteShopApi, getShopPageApi } from '#/api/ecommerce/shop';
|
import { deleteShopApi, getShopPageApi } from '#/api/ecommerce/shop';
|
||||||
|
|
||||||
import PddOrderSyncModal from './components/PddOrderSyncModal.vue';
|
import PddOrderSyncDrawer from './components/PddOrderSyncDrawer.vue';
|
||||||
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
import PddShopDetailModal from './components/PddShopDetailModal.vue';
|
||||||
import ShopFormModal from './components/ShopFormModal.vue';
|
import ShopFormModal from './components/ShopFormModal.vue';
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const loading = ref(false);
|
|||||||
const authorizing = ref(false);
|
const authorizing = ref(false);
|
||||||
const shopFormModalRef = ref();
|
const shopFormModalRef = ref();
|
||||||
const pddShopDetailModalRef = ref();
|
const pddShopDetailModalRef = ref();
|
||||||
const pddOrderSyncModalRef = ref();
|
const pddOrderSyncDrawerRef = ref();
|
||||||
|
|
||||||
/** shopId -> 同步摘要 */
|
/** shopId -> 同步摘要 */
|
||||||
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
||||||
@@ -367,7 +367,7 @@ function handleSyncPddOrders(record: ShopVO.Info) {
|
|||||||
message.warning('请先完成拼多多授权绑定后再同步订单');
|
message.warning('请先完成拼多多授权绑定后再同步订单');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pddOrderSyncModalRef.value?.open(record);
|
pddOrderSyncDrawerRef.value?.open(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAuthPoll() {
|
function clearAuthPoll() {
|
||||||
@@ -526,7 +526,7 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<ShopFormModal ref="shopFormModalRef" @success="handleModalSuccess" />
|
<ShopFormModal ref="shopFormModalRef" @success="handleModalSuccess" />
|
||||||
<PddShopDetailModal ref="pddShopDetailModalRef" />
|
<PddShopDetailModal ref="pddShopDetailModalRef" />
|
||||||
<PddOrderSyncModal ref="pddOrderSyncModalRef" @success="handleModalSuccess" />
|
<PddOrderSyncDrawer ref="pddOrderSyncDrawerRef" @success="handleModalSuccess" />
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user