feat: filter Tahesab sync results to customers not yet imported
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
@@ -85,12 +85,21 @@ const syncCodeTotalPages = computed(() => {
|
||||
? syncListPage.value + 1
|
||||
: Math.max(1, syncListPage.value);
|
||||
});
|
||||
const syncOnlyNew = ref(false);
|
||||
const syncVisibleResults = computed(() =>
|
||||
syncOnlyNew.value
|
||||
? syncResults.value.filter((r) => !r.alreadyLinked)
|
||||
: syncResults.value,
|
||||
);
|
||||
const syncTableTotalPages = computed(() =>
|
||||
Math.max(1, Math.ceil(syncResults.value.length / SYNC_TABLE_PAGE_SIZE)),
|
||||
Math.max(1, Math.ceil(syncVisibleResults.value.length / SYNC_TABLE_PAGE_SIZE)),
|
||||
);
|
||||
const syncPagedResults = computed(() => {
|
||||
const start = (syncTablePage.value - 1) * SYNC_TABLE_PAGE_SIZE;
|
||||
return syncResults.value.slice(start, start + SYNC_TABLE_PAGE_SIZE);
|
||||
return syncVisibleResults.value.slice(start, start + SYNC_TABLE_PAGE_SIZE);
|
||||
});
|
||||
watch(syncOnlyNew, () => {
|
||||
syncTablePage.value = 1;
|
||||
});
|
||||
|
||||
const productSync = reactive({
|
||||
@@ -835,6 +844,10 @@ onMounted(load);
|
||||
وارد کردن این صفحه / بازه
|
||||
</UiButton>
|
||||
</div>
|
||||
<label class="custom-check">
|
||||
<input v-model="syncOnlyNew" type="checkbox" />
|
||||
<span>فقط مشتریانی که وارد نشدهاند</span>
|
||||
</label>
|
||||
<UiPagination
|
||||
v-if="syncListMode === 'listAll' && (syncResults.length || syncListPage > 1)"
|
||||
:page="syncListPage"
|
||||
@@ -876,7 +889,9 @@ onMounted(load);
|
||||
</div>
|
||||
|
||||
<div v-if="syncResults.length" class="sync-results-box">
|
||||
<h4 class="sync-results-title">نتایج جستجو ({{ syncResults.length }})</h4>
|
||||
<h4 class="sync-results-title">
|
||||
نتایج جستجو ({{ syncVisibleResults.length }}<template v-if="syncOnlyNew"> از {{ syncResults.length }}</template>)
|
||||
</h4>
|
||||
<div class="tc-row">
|
||||
<TableColumnsMenu table-key="tahesab.customers" align="end" />
|
||||
</div>
|
||||
@@ -896,6 +911,9 @@ onMounted(load);
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="!syncPagedResults.length">
|
||||
<td colspan="5" class="sync-empty-row">همهٔ مشتریان این نتایج قبلاً وارد شدهاند.</td>
|
||||
</tr>
|
||||
<tr v-for="r in syncPagedResults" :key="String(r.moshtariCode)">
|
||||
<td class="font-mono">{{ r.moshtariCode }}</td>
|
||||
<td class="font-bold">{{ r.name || 'بدون نام' }}</td>
|
||||
@@ -932,7 +950,7 @@ onMounted(load);
|
||||
v-if="syncTableTotalPages > 1"
|
||||
:page="syncTablePage"
|
||||
:total-pages="syncTableTotalPages"
|
||||
:total-items="syncResults.length"
|
||||
:total-items="syncVisibleResults.length"
|
||||
:page-size="SYNC_TABLE_PAGE_SIZE"
|
||||
class="sync-table-pagination"
|
||||
@update:page="onSyncTablePageChange"
|
||||
@@ -1181,6 +1199,12 @@ onMounted(load);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.sync-empty-row {
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
padding: var(--sp-4) var(--sp-3);
|
||||
}
|
||||
|
||||
.custom-check.highlight {
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
Reference in New Issue
Block a user