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:
@@ -2,6 +2,7 @@
|
||||
<AConfigProvider direction="rtl">
|
||||
<RouterView />
|
||||
<CustomerImportProgress />
|
||||
<TahesabDocSyncProgress />
|
||||
<GroupSmsSendProgress />
|
||||
</AConfigProvider>
|
||||
</template>
|
||||
@@ -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'
|
||||
|
||||
@@ -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?: {
|
||||
|
||||
@@ -0,0 +1,658 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="cip-fade">
|
||||
<div
|
||||
v-if="store.visible && !store.minimized"
|
||||
class="cip-overlay"
|
||||
@click.self="store.active ? store.minimize() : null"
|
||||
>
|
||||
<div class="cip-modal" :class="store.finished ? `cip-modal--${outcomeInfo.tone}` : null">
|
||||
<div class="cip-modal__head">
|
||||
<div class="cip-modal__title">
|
||||
<Icon :icon="headIcon" :size="18" />
|
||||
<span>{{ headTitle }}</span>
|
||||
</div>
|
||||
<div class="cip-modal__head-actions">
|
||||
<button
|
||||
v-if="store.active"
|
||||
class="cip-icon-btn"
|
||||
title="کوچک کردن"
|
||||
@click="store.minimize()"
|
||||
>
|
||||
<Icon icon="vuesax-linear:minus" :size="18" />
|
||||
</button>
|
||||
<button v-else class="cip-icon-btn" title="بستن" @click="store.dismiss()">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="store.active" class="cip-modal__body">
|
||||
<div class="cip-counter">
|
||||
<span class="cip-counter__done">{{ store.state.processed }}</span>
|
||||
<span class="cip-counter__sep">/</span>
|
||||
<span class="cip-counter__total">{{ store.state.total }}</span>
|
||||
</div>
|
||||
<div class="cip-counter__label">در حال ارسال سندها به تهحساب…</div>
|
||||
<div class="cip-track">
|
||||
<div class="cip-track__fill" :style="{ width: store.percent + '%' }" />
|
||||
</div>
|
||||
<div class="cip-percent">{{ store.percent }}٪</div>
|
||||
<div class="cip-current">
|
||||
<a-spin size="small" />
|
||||
<span class="cip-current__name">{{ store.state.current || '...' }}</span>
|
||||
</div>
|
||||
<div class="cip-stats">
|
||||
<div class="cip-stat cip-stat--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="14" />
|
||||
{{ store.state.success }} موفق
|
||||
</div>
|
||||
<div v-if="store.state.failed" class="cip-stat cip-stat--fail">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
{{ store.state.failed }} ناموفق
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="cip-modal__body cip-report">
|
||||
<div class="cip-report__hero" :class="`cip-report__hero--${outcomeInfo.tone}`">
|
||||
<Icon :icon="outcomeInfo.icon" :size="34" />
|
||||
</div>
|
||||
<div class="cip-report__title">{{ outcomeInfo.text }}</div>
|
||||
<div class="cip-report__subtitle">
|
||||
از {{ store.state.total }} سند، {{ store.state.processed }} مورد پردازش شد
|
||||
</div>
|
||||
<div class="cip-report__cards">
|
||||
<div class="cip-rcard cip-rcard--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.success }}</div>
|
||||
<div class="cip-rcard__label">ارسال شد</div>
|
||||
</div>
|
||||
<div class="cip-rcard" :class="store.state.failed ? 'cip-rcard--fail' : 'cip-rcard--muted'">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.failed }}</div>
|
||||
<div class="cip-rcard__label">به خطا خورد</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="store.state.errors.length" class="cip-report__errors">
|
||||
<div class="cip-report__errors-head">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
جزئیات خطا ({{ store.state.errors.length }})
|
||||
</div>
|
||||
<div class="cip-report__errors-list">
|
||||
<div v-for="(e, i) in store.state.errors" :key="i" class="cip-erow">
|
||||
<span class="cip-erow__name">{{ e.label }}</span>
|
||||
<span class="cip-erow__msg">{{ e.error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cip-modal__foot">
|
||||
<a-button v-if="store.active" danger size="small" @click="store.stop()">توقف</a-button>
|
||||
<a-button v-if="store.active" size="small" @click="store.minimize()">کوچک کردن</a-button>
|
||||
<a-button v-if="store.finished" type="primary" size="small" @click="store.dismiss()">
|
||||
بستن گزارش
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<Transition name="cip-slide">
|
||||
<button
|
||||
v-if="store.visible && store.minimized"
|
||||
class="cip-mini tds-mini"
|
||||
:class="store.finished ? `cip-mini--${outcomeInfo.tone}` : null"
|
||||
@click="store.expand()"
|
||||
>
|
||||
<span class="cip-mini__ring">
|
||||
<svg viewBox="0 0 36 36" class="cip-mini__svg">
|
||||
<circle class="cip-mini__bg" cx="18" cy="18" r="15.5" />
|
||||
<circle class="cip-mini__fg" cx="18" cy="18" r="15.5" :style="ringStyle" />
|
||||
</svg>
|
||||
<span class="cip-mini__pct">
|
||||
<template v-if="store.finished">
|
||||
<Icon :icon="outcomeInfo.icon" :size="16" />
|
||||
</template>
|
||||
<template v-else>{{ store.percent }}</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="cip-mini__text">
|
||||
<span class="cip-mini__title">
|
||||
<template v-if="store.finished">{{ outcomeInfo.text }}</template>
|
||||
<template v-else>ارسال سند به تهحساب</template>
|
||||
</span>
|
||||
<span class="cip-mini__count">
|
||||
<template v-if="store.finished">
|
||||
{{ store.state.success }} موفق · {{ store.state.failed }} خطا
|
||||
</template>
|
||||
<template v-else>{{ store.state.processed }} از {{ store.state.total }}</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="cip-mini__bar">
|
||||
<span class="cip-mini__bar-fill" :style="{ width: store.percent + '%' }" />
|
||||
</span>
|
||||
</button>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from 'vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
|
||||
const store = useTahesabDocSyncStore()
|
||||
|
||||
const OUTCOME_MAP = {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ارسال سندها تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ارسال سندها ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی سندها به خطا خورد', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ارسال متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:document-upload', text: 'ارسال سند به تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
|
||||
const outcomeInfo = computed(() => OUTCOME_MAP[store.outcome])
|
||||
const headIcon = computed(() =>
|
||||
store.finished ? outcomeInfo.value.icon : 'vuesax-linear:document-upload',
|
||||
)
|
||||
const headTitle = computed(() =>
|
||||
store.finished ? 'گزارش ارسال سندها' : 'ارسال سندها به تهحساب',
|
||||
)
|
||||
const RING_CIRC = 2 * Math.PI * 15.5
|
||||
const ringStyle = computed(() => ({
|
||||
strokeDasharray: `${RING_CIRC}`,
|
||||
strokeDashoffset: `${RING_CIRC * (1 - store.percent / 100)}`,
|
||||
}))
|
||||
|
||||
onMounted(() => {
|
||||
void store.hydrate()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
/* ─── مدال ─── */
|
||||
.cip-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2200;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
background: rgba(15, 23, 42, 0.55);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.cip-modal {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
border-radius: 16px;
|
||||
background: var(--admin-bg-surface);
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
|
||||
overflow: hidden;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 16px;
|
||||
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0ea5e9 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--ok .cip-modal__head {
|
||||
background: linear-gradient(135deg, #059669 0%, #10b981 100%);
|
||||
}
|
||||
|
||||
&--warn .cip-modal__head {
|
||||
background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
|
||||
}
|
||||
|
||||
&--fail .cip-modal__head {
|
||||
background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&__head-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 20px 18px 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 12px 16px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.32);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
|
||||
&__done {
|
||||
font-size: 38px;
|
||||
color: #7c3aed;
|
||||
}
|
||||
&__sep {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
&__total {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter__label {
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-track {
|
||||
width: 100%;
|
||||
height: 9px;
|
||||
margin-top: 16px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
|
||||
&__fill {
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: linear-gradient(90deg, #7c3aed, #0ea5e9);
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-percent {
|
||||
align-self: flex-end;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-current {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
max-width: 100%;
|
||||
|
||||
&__name {
|
||||
font-size: 12px;
|
||||
color: var(--admin-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-stats {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.cip-stat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
padding: 3px 12px;
|
||||
border-radius: 99px;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── گزارش پایانی ─── */
|
||||
.cip-report {
|
||||
padding-top: 22px;
|
||||
|
||||
&__hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.14);
|
||||
color: #059669;
|
||||
}
|
||||
&--warn {
|
||||
background: rgba(245, 158, 11, 0.16);
|
||||
color: #d97706;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.13);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin-top: 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: var(--admin-text);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--admin-text-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
&__errors {
|
||||
width: 100%;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
&__errors-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #dc2626;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
&__errors-list {
|
||||
max-height: 160px;
|
||||
overflow-y: auto;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--admin-border);
|
||||
background: var(--admin-bg-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-rcard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 14px 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&__num {
|
||||
font-size: 26px;
|
||||
font-weight: 800;
|
||||
line-height: 1.1;
|
||||
}
|
||||
&__label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
border-color: rgba(16, 185, 129, 0.25);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.09);
|
||||
border-color: rgba(239, 68, 68, 0.22);
|
||||
color: #dc2626;
|
||||
}
|
||||
&--muted {
|
||||
background: var(--admin-bg-muted);
|
||||
border-color: var(--admin-border);
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-erow {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid var(--admin-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
&__msg {
|
||||
color: #dc2626;
|
||||
text-align: left;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── کوچکشده ─── */
|
||||
.cip-mini {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 2100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 16px 8px 10px;
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-surface);
|
||||
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s, box-shadow 0.15s;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 58px;
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateX(-50%) translateY(1px);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
&__ring {
|
||||
position: relative;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
&__bg {
|
||||
fill: none;
|
||||
stroke: var(--admin-bg-muted);
|
||||
stroke-width: 3.5;
|
||||
}
|
||||
|
||||
&__fg {
|
||||
fill: none;
|
||||
stroke: #7c3aed;
|
||||
stroke-width: 3.5;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.35s ease;
|
||||
}
|
||||
|
||||
&__pct {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
&__text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.3;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-size: 11px;
|
||||
color: var(--admin-text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__bar {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
bottom: 3px;
|
||||
height: 2px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__bar-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: #7c3aed;
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
|
||||
/* رنگ بر اساس نتیجه */
|
||||
&--ok {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #10b981;
|
||||
background: #10b981;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
&--warn {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #f59e0b;
|
||||
background: #f59e0b;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
|
||||
&--fail {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #ef4444;
|
||||
background: #ef4444;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tds-mini.cip-mini {
|
||||
top: 112px;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 106px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── انیمیشنها ─── */
|
||||
.cip-fade-enter-active,
|
||||
.cip-fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.cip-fade-enter-from,
|
||||
.cip-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.cip-slide-enter-active,
|
||||
.cip-slide-leave-active {
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
.cip-slide-enter-from,
|
||||
.cip-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(-12px);
|
||||
}
|
||||
</style>
|
||||
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import {
|
||||
getTahesabPendingSummary,
|
||||
startTahesabDocSync,
|
||||
stopTahesabDocSync,
|
||||
type TahesabDocSyncState,
|
||||
} from '@/api/tahesab'
|
||||
|
||||
export type DocSyncOutcome = 'running' | 'success' | 'error' | 'partial' | 'canceled'
|
||||
|
||||
const POLL_MS = 10_000
|
||||
|
||||
function emptyState(): TahesabDocSyncState {
|
||||
return {
|
||||
running: false,
|
||||
finished: false,
|
||||
stopped: false,
|
||||
percent: 0,
|
||||
total: 0,
|
||||
processed: 0,
|
||||
success: 0,
|
||||
failed: 0,
|
||||
current: '',
|
||||
errors: [],
|
||||
}
|
||||
}
|
||||
|
||||
export const useTahesabDocSyncStore = defineStore('tahesabDocSync', () => {
|
||||
const state = ref<TahesabDocSyncState>(emptyState())
|
||||
const visible = ref(false)
|
||||
const minimized = ref(false)
|
||||
const starting = ref(false)
|
||||
const message = ref('')
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const active = computed(() => state.value.running)
|
||||
const finished = computed(() => state.value.finished && !state.value.running)
|
||||
const percent = computed(() => state.value.percent)
|
||||
const outcome = computed<DocSyncOutcome>(() => {
|
||||
if (state.value.running) return 'running'
|
||||
if (state.value.stopped) return 'canceled'
|
||||
if (state.value.failed === 0) return 'success'
|
||||
if (state.value.success === 0 && state.value.failed > 0) return 'error'
|
||||
return 'partial'
|
||||
})
|
||||
|
||||
function apply(snapshot?: TahesabDocSyncState | null) {
|
||||
if (!snapshot) return
|
||||
const wasVisible = visible.value
|
||||
state.value = { ...emptyState(), ...snapshot }
|
||||
if (snapshot.running) {
|
||||
visible.value = true
|
||||
startPoll()
|
||||
return
|
||||
}
|
||||
stopPoll()
|
||||
if (snapshot.finished && wasVisible) {
|
||||
visible.value = true
|
||||
}
|
||||
}
|
||||
|
||||
function startPoll() {
|
||||
if (timer) return
|
||||
timer = setInterval(() => {
|
||||
void hydrate()
|
||||
}, POLL_MS)
|
||||
}
|
||||
|
||||
function stopPoll() {
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
async function hydrate() {
|
||||
try {
|
||||
const summary = await getTahesabPendingSummary()
|
||||
apply(summary.doc_sync)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
async function start() {
|
||||
if (starting.value) return
|
||||
if (state.value.running) {
|
||||
visible.value = true
|
||||
minimized.value = false
|
||||
startPoll()
|
||||
return
|
||||
}
|
||||
starting.value = true
|
||||
try {
|
||||
const res = await startTahesabDocSync()
|
||||
message.value = res.message || ''
|
||||
apply(res.doc_sync)
|
||||
visible.value = true
|
||||
minimized.value = false
|
||||
} finally {
|
||||
starting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function stop() {
|
||||
const res = await stopTahesabDocSync()
|
||||
message.value = res.message || ''
|
||||
apply(res.doc_sync)
|
||||
window.setTimeout(() => {
|
||||
void hydrate()
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
function minimize() {
|
||||
minimized.value = true
|
||||
}
|
||||
|
||||
function expand() {
|
||||
minimized.value = false
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
if (state.value.running) return
|
||||
visible.value = false
|
||||
minimized.value = false
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
visible,
|
||||
minimized,
|
||||
starting,
|
||||
message,
|
||||
active,
|
||||
finished,
|
||||
percent,
|
||||
outcome,
|
||||
apply,
|
||||
hydrate,
|
||||
start,
|
||||
stop,
|
||||
minimize,
|
||||
expand,
|
||||
dismiss,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user