From ba12569b97459a8ecd7dae89f1c188c6c8005310 Mon Sep 17 00:00:00 2001 From: adonis Date: Wed, 2 Sep 2026 20:48:14 +0330 Subject: [PATCH] feat(tahesab): minimizable modal for bulk document sync progress One-click start on customer-sync and documents tabs; poll every 10s, restore the modal after refresh if the server job is still running, and show failed counts with stop. Co-authored-by: Cursor --- src/App.vue | 2 + src/api/tahesab.ts | 27 + src/components/TahesabDocSyncProgress.vue | 658 ++++++++++++++++++ .../components/TahesabCustomerSync.vue | 8 + .../components/TahesabDocSyncBox.vue | 37 + .../accounting/components/tahesabTable.vue | 10 +- src/store/tahesabDocSyncStore.ts | 147 ++++ 7 files changed, 888 insertions(+), 1 deletion(-) create mode 100644 src/components/TahesabDocSyncProgress.vue create mode 100644 src/pages/menuPages/accounting/components/TahesabDocSyncBox.vue create mode 100644 src/store/tahesabDocSyncStore.ts diff --git a/src/App.vue b/src/App.vue index d50c623..ad52768 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,6 +2,7 @@ + @@ -12,6 +13,7 @@ import { message } from 'ant-design-vue' import { useConfigStore } from '@/store/configStore' import { initDarkmode } from '@core/stores/darkmode' import CustomerImportProgress from '@/components/CustomerImportProgress.vue' +import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue' import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue' import { useUserStore } from '@/store/userStore' import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat' diff --git a/src/api/tahesab.ts b/src/api/tahesab.ts index b3c4224..0a2f943 100644 --- a/src/api/tahesab.ts +++ b/src/api/tahesab.ts @@ -34,11 +34,27 @@ export const getTahesabDetail = async (id: number) => export const retryTahesabSanad = async (id: number) => await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`) +export interface TahesabDocSyncState { + running: boolean + finished: boolean + stopped: boolean + percent: number + total: number + processed: number + success: number + failed: number + current: string + errors: { label?: string; error?: string }[] + started_at?: string | null + finished_at?: string | null +} + export interface TahesabPendingSummary { failed_rows: number missing_withdraws: number missing_orders: number total: number + doc_sync?: TahesabDocSyncState } export interface TahesabSyncAllResult { @@ -71,6 +87,16 @@ export const syncAllTahesabPending = async (limit = 80, customerId?: number) => ...(customerId ? { customer_id: customerId } : {}) }) +export const startTahesabDocSync = async () => + await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>( + '/admin/tahesab/doc-sync/start' + ) + +export const stopTahesabDocSync = async () => + await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>( + '/admin/tahesab/doc-sync/stop' + ) + export const registerCustomerInTahesab = async (customerId: number) => await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>( `/admin/customer/${customerId}/tahesab/register` @@ -129,6 +155,7 @@ export interface CustomerSyncStatus { last_page: number total: number } + doc_sync?: TahesabDocSyncState } export const getCustomerSyncStatus = async (params?: { diff --git a/src/components/TahesabDocSyncProgress.vue b/src/components/TahesabDocSyncProgress.vue new file mode 100644 index 0000000..469b7be --- /dev/null +++ b/src/components/TahesabDocSyncProgress.vue @@ -0,0 +1,658 @@ + + + + + diff --git a/src/pages/menuPages/accounting/components/TahesabCustomerSync.vue b/src/pages/menuPages/accounting/components/TahesabCustomerSync.vue index ef12dfb..c3f08a0 100644 --- a/src/pages/menuPages/accounting/components/TahesabCustomerSync.vue +++ b/src/pages/menuPages/accounting/components/TahesabCustomerSync.vue @@ -63,6 +63,8 @@ + +