diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncDrawer.vue similarity index 92% rename from ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncModal.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncDrawer.vue index 8734eadf..a2e7ee5a 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/components/PddOrderSyncDrawer.vue @@ -5,11 +5,10 @@ import type { Dayjs } from 'dayjs'; import { computed, onBeforeUnmount, ref } from 'vue'; -import { useVbenModal } from '@vben/common-ui'; - import { Button, DatePicker, + Drawer, Form, message, Progress, @@ -32,14 +31,18 @@ import { togglePddIncrementalSyncApi, } from '#/api/ecommerce/pdd/order-sync'; +defineOptions({ name: 'PddOrderSyncDrawer' }); + interface Emits { (e: 'success'): void; } const emit = defineEmits(); +const openFlag = ref(false); const shop = ref(null); const loading = ref(false); +const submitting = ref(false); const mode = ref<'day' | 'full' | 'incremental'>('full'); const confirmDate = ref(dayjs().subtract(1, 'day')); const range = ref<[Dayjs, Dayjs]>([ @@ -50,19 +53,7 @@ const incremental = ref(null); const fullTask = ref(null); let pollTimer: null | ReturnType = null; -const [Modal, modalApi] = useVbenModal({ - draggable: true, - class: 'w-[560px]', - onCancel() { - stopPoll(); - modalApi.close(); - }, - onConfirm() { - handleSubmit(); - }, -}); - -const modalTitle = computed(() => +const drawerTitle = computed(() => shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单', ); @@ -166,7 +157,7 @@ async function pollFullTask(taskId: number) { task.status === 'CANCELLED' ) { stopPoll(); - modalApi.setState({ confirmLoading: false }); + submitting.value = false; loading.value = false; if (task.status === 'SUCCESS') { message.success( @@ -207,7 +198,7 @@ async function handleResumeFull() { if (!fullTask.value) return; try { loading.value = true; - modalApi.setState({ confirmLoading: true }); + submitting.value = true; const task = await resumePddFullSyncTaskApi(fullTask.value.id); fullTask.value = task; message.success('已续跑入队'); @@ -216,7 +207,7 @@ async function handleResumeFull() { console.error('续跑全量任务失败:', error); message.error('续跑全量任务失败'); loading.value = false; - modalApi.setState({ confirmLoading: false }); + submitting.value = false; } } @@ -236,7 +227,7 @@ async function handleSubmit() { } try { loading.value = true; - modalApi.setState({ confirmLoading: true }); + submitting.value = true; if (mode.value === 'full') { const task = await createPddFullSyncTaskApi({ @@ -269,11 +260,16 @@ async function handleSubmit() { } finally { if (mode.value !== 'full') { loading.value = false; - modalApi.setState({ confirmLoading: false }); + submitting.value = false; } } } +function handleClose() { + stopPoll(); + openFlag.value = false; +} + async function open(record: ShopVO.Info) { shop.value = record; mode.value = 'full'; @@ -281,18 +277,27 @@ async function open(record: ShopVO.Info) { range.value = [dayjs().subtract(90, 'day'), dayjs().subtract(1, 'day')]; fullTask.value = null; incremental.value = null; + submitting.value = false; + loading.value = false; stopPoll(); - modalApi.open(); + openFlag.value = true; await Promise.all([loadIncrementalStatus(), loadLatestFullTask()]); } onBeforeUnmount(() => stopPoll()); -defineExpose({ open }); +defineExpose({ open, close: handleClose }); diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue index 97407c8a..3946da3b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue @@ -19,7 +19,7 @@ import { batchPddOrderSyncStatusApi } from '#/api/ecommerce/pdd/order-sync'; import { getPlatformListApi } from '#/api/ecommerce/platform'; 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 ShopFormModal from './components/ShopFormModal.vue'; @@ -33,7 +33,7 @@ const loading = ref(false); const authorizing = ref(false); const shopFormModalRef = ref(); const pddShopDetailModalRef = ref(); -const pddOrderSyncModalRef = ref(); +const pddOrderSyncDrawerRef = ref(); /** shopId -> 同步摘要 */ const syncStatusMap = ref>({}); @@ -367,7 +367,7 @@ function handleSyncPddOrders(record: ShopVO.Info) { message.warning('请先完成拼多多授权绑定后再同步订单'); return; } - pddOrderSyncModalRef.value?.open(record); + pddOrderSyncDrawerRef.value?.open(record); } function clearAuthPoll() { @@ -526,7 +526,7 @@ onUnmounted(() => { - +