work on moving customers from tahesab

This commit is contained in:
2026-06-28 23:41:46 +03:30
parent 218d3e9f5e
commit ec535d4576
5 changed files with 898 additions and 5 deletions
@@ -205,11 +205,11 @@
</a-button>
<a-button
size="small"
:loading="syncingTahesab"
:loading="importStore.active"
:disabled="!tahesabOnlyList.length"
@click="importAll"
>
وارد کردن همه ({{ status?.tahesab_only_count ?? 0 }})
{{ importStore.active ? 'در حال وارد کردن…' : `وارد کردن همه (${status?.tahesab_only_count ?? 0})` }}
</a-button>
</div>
</div>
@@ -308,7 +308,7 @@
</template>
<script setup lang="ts">
import { ref, computed, onMounted, reactive } from 'vue'
import { ref, computed, onMounted, reactive, watch } from 'vue'
import { message } from 'ant-design-vue/es'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
import { toJalali } from '@core/utils/useDataTime'
@@ -322,6 +322,9 @@ import {
type TahesabOnlyCustomer,
type SyncPanelResult,
} from '@/api/tahesab'
import { useCustomerImportStore } from '@/store/customerImportStore'
const importStore = useCustomerImportStore()
// ─── state ───
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
@@ -507,9 +510,36 @@ async function doImport(customers: TahesabOnlyCustomer[]) {
async function importOne(customer: TahesabOnlyCustomer) { await doImport([customer]) }
async function importSelected() { await doImport(tahesabOnlyList.value.filter(c => selectedTahesab.has(c.code))) }
async function importAll() { await doImport(tahesabOnlyList.value) }
onMounted(() => load(1))
// «وارد کردن همه» با پروگرس‌بار سراسری و قابل مینیمایز (پس‌زمینه‌ای)
async function importAll() {
const pending = tahesabOnlyList.value.filter(c => !tahesabDone.has(c.code))
if (!pending.length) return
if (importStore.active) {
importStore.expand()
return
}
await importStore.start(pending)
}
// با پیشرفت عملیات سراسری، ردیف‌های وارد شده را همین‌جا هم تیک بزن
watch(() => importStore.doneCodes.length, () => {
importStore.doneCodes.forEach(code => tahesabDone.add(code))
})
// پس از پایان کامل، آمار و لیست را تازه کن
watch(() => importStore.status, async (s, prev) => {
if (prev === 'running' && (s === 'done' || s === 'canceled')) {
selectedTahesab.clear()
await load(panelPagination.value.page)
}
})
onMounted(() => {
load(1)
// اگر عملیات سراسری در حال اجراست، ردیف‌های انجام‌شده را همگام کن
importStore.doneCodes.forEach(code => tahesabDone.add(code))
})
</script>
<style lang="less" scoped>