Speed up lead board load and polish lead detail/list UX.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-19 12:08:45 +03:30
co-authored by Cursor
parent dbb61ff870
commit e90f9f9538
8 changed files with 225 additions and 90 deletions
+5 -4
View File
@@ -212,7 +212,8 @@ async function load() {
try {
const [board, stageRows] = await Promise.all([
api.get<LeadBoardColumnDto[]>('/leads/board'),
api.get<LeadStageDto[]>('/leads/stages'),
// بدون شمارش لید روی هر مرحله — total ستون‌ها از خود board می‌آید
api.get<LeadStageDto[]>('/leads/stages', { params: { counts: '0' } }),
]);
columns.value = board.data;
stages.value = stageRows.data;
@@ -614,7 +615,7 @@ async function confirmPendingLeadMove() {
if (!pending || moving.value) return Promise.reject();
const reason = stageMoveReason.value.trim();
if (!reason) {
stageMoveError.value = 'دلیل تغییر ستون را بنویسید.';
stageMoveError.value = 'دلیل تغییر وضعیت را بنویسید.';
return Promise.reject();
}
columns.value = pending.nextColumns;
@@ -1037,7 +1038,7 @@ onMounted(load);
<a-modal
:open="!!pendingLeadMove"
title="دلیل تغییر ستون"
title="دلیل تغییر وضعیت"
ok-text="ثبت و انتقال"
cancel-text="انصراف"
:confirm-loading="moving"
@@ -1054,7 +1055,7 @@ onMounted(load);
:rows="4"
:maxlength="1000"
show-count
placeholder="دلیل تغییر ستون را بنویسید…"
placeholder="دلیل تغییر وضعیت را بنویسید…"
/>
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
</a-flex>
+59 -47
View File
@@ -22,7 +22,7 @@ import {
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Modal,
Modal as AModal,
Row as ARow,
Select as ASelect,
Space as ASpace,
@@ -87,6 +87,18 @@ const canBehavior = computed(() => canUseBehavior(auth.user));
const copilotOpen = ref(false);
const id = computed(() => String(route.params.id));
/** برگشت به همان جایی که از آن آمده‌ایم (فهرست یا مسیر/بورد لیدها). */
function goBack() {
const back = String((window.history.state as { back?: string | null } | null)?.back ?? '');
const path = back.split('?')[0];
if (path === '/leads' || path === '/leads/board') {
router.back();
return;
}
void router.push({ name: 'leads' });
}
const loading = ref(false);
const busy = ref(false);
const error = ref('');
@@ -293,7 +305,7 @@ async function changeStage() {
}
const reason = stageMoveReason.value.trim();
if (!reason) {
stageMoveError.value = 'دلیل تغییر ستون را بنویسید.';
stageMoveError.value = 'دلیل تغییر وضعیت را بنویسید.';
return Promise.reject();
}
busy.value = true;
@@ -411,7 +423,7 @@ async function setFollowUp() {
}
function convertLead() {
Modal.confirm({
AModal.confirm({
title: 'این لید به مشتری تبدیل شود؟',
okText: 'تبدیل',
cancelText: 'انصراف',
@@ -440,7 +452,7 @@ function convertLead() {
}
function archiveLead() {
Modal.confirm({
AModal.confirm({
title: 'این لید بایگانی شود؟',
okText: 'بایگانی',
cancelText: 'انصراف',
@@ -534,11 +546,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
<a-col :span="24">
<a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM">
<a-space :size="12" align="start">
<RouterLink :to="{ name: 'leads-board' }" custom v-slot="{ navigate }">
<a-button @click="navigate">
<template #icon><ArrowLeftOutlined /></template>
</a-button>
</RouterLink>
<a-button aria-label="بازگشت" @click="goBack">
<template #icon><ArrowLeftOutlined /></template>
</a-button>
<div>
<a-typography-title :level="3" :style="{ margin: 0 }">
{{ lead?.title || 'جزئیات لید' }}
@@ -1219,45 +1229,47 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
</a-button>
</a-form>
</a-drawer>
<a-modal
v-model:open="stageMoveOpen"
title="دلیل تغییر ستون"
ok-text="ثبت و انتقال"
cancel-text="انصراف"
:confirm-loading="busy"
:ok-button-props="{ disabled: !stageMoveReason.trim() }"
@ok="changeStage"
@cancel="cancelStageMove"
>
<a-flex vertical :gap="12">
<a-typography-text type="secondary">
انتقال به «{{ stages.find((s) => s.id === stageId)?.name || '—' }}»
</a-typography-text>
<a-textarea
v-model:value="stageMoveReason"
:rows="4"
:maxlength="1000"
show-count
placeholder="دلیل تغییر ستون را بنویسید…"
/>
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
</a-flex>
</a-modal>
<SmsComposeModal
:open="smsOpen"
title="ارسال پیامک"
:endpoint="`/leads/${lead.id}/sms`"
:history-endpoint="`/leads/${lead.id}/sms-history`"
:name="lead.contactName || lead.title"
:phone="lead.mobile || lead.phone || ''"
:record-title="lead.title"
:company="lead.trade ?? ''"
@close="smsOpen = false"
/>
</template>
</template>
</a-spin>
</a-col>
</a-row>
<a-modal
v-model:open="stageMoveOpen"
title="دلیل تغییر وضعیت"
ok-text="ثبت و انتقال"
cancel-text="انصراف"
destroy-on-close
:confirm-loading="busy"
:ok-button-props="{ disabled: !stageMoveReason.trim() }"
@ok="changeStage"
@cancel="cancelStageMove"
>
<a-flex vertical :gap="12">
<a-typography-text type="secondary">
انتقال از «{{ lead?.stageName || '—' }}» به «{{ stages.find((s) => s.id === stageId)?.name || '—' }}»
</a-typography-text>
<a-textarea
v-model:value="stageMoveReason"
:rows="4"
:maxlength="1000"
show-count
placeholder="دلیل تغییر وضعیت را بنویسید…"
/>
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
</a-flex>
</a-modal>
<SmsComposeModal
v-if="lead"
:open="smsOpen"
title="ارسال پیامک"
:endpoint="`/leads/${lead.id}/sms`"
:history-endpoint="`/leads/${lead.id}/sms-history`"
:name="lead.contactName || lead.title"
:phone="lead.mobile || lead.phone || ''"
:record-title="lead.title"
:company="lead.trade ?? ''"
@close="smsOpen = false"
/>
</template>
+7 -4
View File
@@ -1293,7 +1293,7 @@ async function bulkStageSelected() {
if (!bulkStageId.value || !selectedIds.value.length) return Promise.reject();
const reason = bulkStageReason.value.trim();
if (!reason) {
bulkStageReasonError.value = 'دلیل تغییر ستون را بنویسید.';
bulkStageReasonError.value = 'دلیل تغییر وضعیت را بنویسید.';
return Promise.reject();
}
busy.value = true;
@@ -2194,7 +2194,10 @@ onBeforeUnmount(() => {
:pagination="false"
:row-key="(r: LeadDto) => r.id"
:scroll="{ x: 1100 }"
:custom-row="(record: LeadDto) => ({ onClick: () => goDetail(record.id) })"
:custom-row="(record: LeadDto) => ({
onClick: () => goDetail(record.id),
style: { cursor: 'pointer' },
})"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'select'">
@@ -2535,7 +2538,7 @@ onBeforeUnmount(() => {
<a-modal
v-model:open="bulkStageReasonOpen"
title="دلیل تغییر ستون"
title="دلیل تغییر وضعیت"
ok-text="ثبت و انتقال"
cancel-text="انصراف"
:confirm-loading="busy"
@@ -2553,7 +2556,7 @@ onBeforeUnmount(() => {
:rows="4"
:maxlength="1000"
show-count
placeholder="دلیل تغییر ستون را بنویسید…"
placeholder="دلیل تغییر وضعیت را بنویسید…"
/>
<a-alert
v-if="bulkStageReasonError"