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 <cursoragent@cursor.com>
This commit is contained in:
2026-09-02 20:48:14 +03:30
co-authored by Cursor
parent 4d8d35c37d
commit ba12569b97
7 changed files with 888 additions and 1 deletions
@@ -63,6 +63,8 @@
</div>
</div>
<TahesabDocSyncBox />
<!-- ─── تب‌ها ─── -->
<div class="cs-tabs">
<button
@@ -373,11 +375,14 @@ import {
type SyncPanelResult,
} from '@/api/tahesab'
import { useCustomerImportStore } from '@/store/customerImportStore'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
import ColleagueAccountingAccounts from '@/pages/menuPages/colleagueOrders/components/ColleagueAccountingAccounts.vue'
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
import { accountingTahesabCustomerSyncIntro } from '@/utils/adminHelpCopy'
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
const importStore = useCustomerImportStore()
const docSyncStore = useTahesabDocSyncStore()
// ─── state ───
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
@@ -505,6 +510,7 @@ async function load(panelPage = 1) {
} else {
status.value = res
}
docSyncStore.apply(res.doc_sync)
panelList.value = res.panel_only_list.data
panelPagination.value = {
page: res.panel_only_list.current_page,
@@ -534,6 +540,7 @@ async function loadTahesab() {
} else {
status.value = res
}
docSyncStore.apply(res.doc_sync)
tahesabOnlyList.value = res.tahesab_only_list?.data ?? []
mandeFetched.clear()
tahesabFetched.value = true
@@ -556,6 +563,7 @@ async function loadPanel(page = 1) {
status.value.panel_registered = res.panel_registered
status.value.panel_only = res.panel_only
}
docSyncStore.apply(res.doc_sync)
panelList.value = res.panel_only_list.data
panelPagination.value = {
page: res.panel_only_list.current_page,
@@ -0,0 +1,37 @@
<template>
<div
class="mb-3 flex w-full flex-col gap-2.5 rounded-xl border border-gray-200 bg-gray-50 px-3.5 py-3 sm:flex-row sm:items-center sm:gap-3"
>
<div class="min-w-0 flex-1">
<p class="m-0 text-sm font-800 text-gray-800">ارسال سندها به ته‌حساب</p>
<p class="mb-0 mt-1 text-xs leading-relaxed text-gray-500">
با یک کلیک همهٔ سفارش‌ها و شارژهای جاافتاده یکی‌یکی و با فاصله به ته‌حساب می‌روند.
سندهایی که قبلاً رفته‌اند دوباره ارسال نمی‌شوند؛ می‌توانید پیشرفت را کوچک کنید.
</p>
</div>
<a-button
type="primary"
class="!w-full shrink-0 sm:!w-auto"
:loading="store.starting || store.active"
:disabled="store.active"
@click="onStart"
>
{{ store.active ? 'در حال ارسال…' : 'ارسال همه سندها' }}
</a-button>
</div>
</template>
<script setup lang="ts">
import { message } from 'ant-design-vue'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
const store = useTahesabDocSyncStore()
async function onStart() {
try {
await store.start()
} catch (e: any) {
message.error(e?.response?.data?.message || e?.message || 'شروع ارسال ناموفق بود')
}
}
</script>
@@ -6,7 +6,7 @@
>
<template #extra>
<a-button
v-if="(pending?.total ?? 0) > 0"
v-if="customerId && (pending?.total ?? 0) > 0"
type="primary"
size="small"
:loading="syncing"
@@ -16,6 +16,8 @@
</a-button>
</template>
<TahesabDocSyncBox v-if="!customerId" />
<div
v-if="(pending?.total ?? 0) > 0"
class="mb-3 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900"
@@ -207,6 +209,7 @@ import { isMobile } from '@core/utils/is'
import BasicModal from '@/components/BasicModal.vue'
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
import {
tahesabIssueKindLabel,
tahesabStatusLabel
@@ -217,6 +220,9 @@ import {
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
import { toJalali } from '@core/utils/useDataTime'
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
const docSyncStore = useTahesabDocSyncStore()
const props = defineProps<{
customerId?: number
@@ -386,6 +392,7 @@ function openRegister(record: TahesabRecord) {
async function loadPending() {
try {
pending.value = await getTahesabPendingSummary(props.customerId)
docSyncStore.apply(pending.value?.doc_sync)
} catch {
pending.value = null
}
@@ -397,6 +404,7 @@ async function loadFailedDocs() {
const res = await getTahesabPendingDocs(props.customerId, 200)
failedRows.value = res.rows || []
pending.value = res.summary
docSyncStore.apply(res.summary?.doc_sync)
} catch {
failedRows.value = []
} finally {