feat(web): add Ant workspace tabs and harden page chrome

Persist workspace tabs in the app shell with Ant Design styling aligned to the desktop top bar, and fix tab bar layout flicker on select. Add shared PageHeader components, query helpers, and missing header state across CRM views; improve mobile shell layout and Vite HMR stability on Windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-25 16:53:04 +03:30
co-authored by Cursor
parent 1992474273
commit cc68b2d9f3
86 changed files with 5446 additions and 3885 deletions
+87 -58
View File
@@ -3,6 +3,7 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import { api } from '@/lib/api';
import { useFeedback } from '@/composables/useFeedback';
import { formatRelativeDayLabel, toFaDigits } from '@/lib/jalali';
import PipelineToolbar from '@/components/pipeline/PipelineToolbar.vue';
import type { PipelineViewMode } from '@/components/pipeline/PipelineToolbar.vue';
@@ -19,6 +20,7 @@ import {
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import DealFormView from '@/views/DealFormView.vue';
import SavedFiltersBar from '@/components/SavedFiltersBar.vue';
import type { PageHeaderMenuItem } from '@/components/page';
import {
DeleteOutlined,
DownloadOutlined,
@@ -80,6 +82,7 @@ const pageStyle = {
const route = useRoute();
const router = useRouter();
const feedback = useFeedback();
const auth = useAuthStore();
const canCreatePipeline = computed(() => canManageSettings(auth.user?.role));
@@ -98,8 +101,6 @@ const newName = ref('');
const dealModal = ref<{ dealId?: string; stageId?: string } | null>(null);
const stageBusy = ref(false);
const busy = ref(false);
const importMsg = ref('');
const draggingId = ref<string | null>(null);
const draggingColumnId = ref<string | null>(null);
const dropStageId = ref<string | null>(null);
@@ -229,9 +230,10 @@ async function createPipeline() {
const { data } = await api.post<PipelineDto>('/pipelines', { name });
newName.value = '';
showCreate.value = false;
feedback.success('مسیر فروش ساخته شد.');
await router.replace({ name: 'pipeline', query: { pipelineId: data.id } });
} catch {
error.value = 'ساخت مسیر فروش ناموفق بود.';
} catch (e) {
feedback.fromError(e, 'ساخت مسیر فروش ناموفق بود.');
} finally {
saving.value = false;
}
@@ -306,9 +308,9 @@ async function applyUpdateDealStage(
stageId,
position: position ?? undefined,
});
} catch {
} catch (e) {
stages.value = prev;
error.value = 'جابه‌جایی معامله ناموفق بود.';
feedback.fromError(e, 'جابه‌جایی معامله ناموفق بود.');
} finally {
moving.value = false;
}
@@ -357,15 +359,6 @@ async function onDrop(stageId: string, event: DragEvent, index?: number) {
}
}
function apiMessage(e: unknown, fallback: string) {
if (axios.isAxiosError(e)) {
const msg = (e.response?.data as { message?: string | string[] })?.message;
if (typeof msg === 'string' && msg) return msg;
if (Array.isArray(msg) && msg[0]) return String(msg[0]);
}
return fallback;
}
function onAddDeal(stageId: string) {
dealModal.value = { stageId };
}
@@ -392,7 +385,7 @@ async function persistStageOrder(next: PipelineStage[], prev: PipelineStage[]) {
});
} catch (e) {
stages.value = prev;
error.value = apiMessage(e, 'جابه‌جایی ستون ناموفق بود.');
feedback.fromError(e, 'جابه‌جایی ستون ناموفق بود.');
} finally {
stageBusy.value = false;
}
@@ -431,9 +424,10 @@ async function onRenameStage(stageId: string, title: string) {
await api.patch(`/pipelines/${boardPipelineId.value}/stages/${stageId}`, {
name: title,
});
feedback.success('نام ستون به‌روز شد.');
} catch (e) {
stages.value = prev;
error.value = apiMessage(e, 'تغییر نام ستون ناموفق بود.');
feedback.fromError(e, 'تغییر نام ستون ناموفق بود.');
} finally {
stageBusy.value = false;
}
@@ -445,9 +439,10 @@ async function onAddStage(name: string) {
error.value = '';
try {
await api.post(`/pipelines/${boardPipelineId.value}/stages`, { name });
feedback.success('ستون اضافه شد.');
await load();
} catch (e) {
error.value = apiMessage(e, 'افزودن ستون ناموفق بود.');
feedback.fromError(e, 'افزودن ستون ناموفق بود.');
} finally {
stageBusy.value = false;
}
@@ -467,9 +462,10 @@ function onDeleteStage(stageId: string) {
error.value = '';
try {
await api.delete(`/pipelines/${boardPipelineId.value}/stages/${stageId}`);
feedback.success('ستون حذف شد.');
await load();
} catch (e) {
error.value = apiMessage(e, 'حذف ستون ناموفق بود.');
feedback.fromError(e, 'حذف ستون ناموفق بود.');
throw e;
} finally {
stageBusy.value = false;
@@ -543,13 +539,18 @@ function confirmDeleteDeals(ids: string[]) {
clearSelect();
await load();
if (failed) {
error.value =
feedback.error(
failed === ids.length
? 'حذف معامله‌ها ناموفق بود.'
: `${toFaDigits(failed)} مورد حذف نشد.`;
: `${toFaDigits(failed)} مورد حذف نشد.`,
);
} else {
feedback.success(
ids.length > 1 ? 'معامله‌ها حذف شدند.' : 'معامله حذف شد.',
);
}
} catch (e) {
error.value = apiMessage(e, 'حذف معامله ناموفق بود.');
feedback.fromError(e, 'حذف معامله ناموفق بود.');
throw e;
} finally {
dealDeleting.value = false;
@@ -589,9 +590,10 @@ async function promotePriorDeal(dealId: string) {
error.value = '';
try {
await api.post(`/deals/${dealId}/promote-from-prior`);
feedback.success('معامله به کار جاری منتقل شد.');
await load();
} catch (e) {
error.value = apiMessage(e, 'انتقال معامله به کار جاری ناموفق بود.');
feedback.fromError(e, 'انتقال معامله به کار جاری ناموفق بود.');
}
}
@@ -602,7 +604,6 @@ async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
const { data } = await api.get<Blob>('/deals/export', { responseType: 'blob' });
@@ -612,8 +613,9 @@ async function exportExcel() {
a.download = `${brand.filePrefix}-deals.xlsx`;
a.click();
URL.revokeObjectURL(url);
} catch {
error.value = 'خروجی اکسل ناموفق بود.';
feedback.success('خروجی اکسل آماده شد.');
} catch (e) {
feedback.fromError(e, 'خروجی اکسل ناموفق بود.');
} finally {
busy.value = false;
pageBusy.value = false;
@@ -623,19 +625,23 @@ async function exportExcel() {
function onImportStart() {
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
async function onImportDone(data: ImportContactsResult) {
importMsg.value = `وارد شد: ${data.created} · تکراری رد شد: ${data.skipped}${
const summary = `وارد شد: ${data.created} · تکراری رد شد: ${data.skipped}${
data.errors.length ? ` · خطا: ${data.errors.length}` : ''
}${data.boards?.length ? ` · مسیر فروش: ${data.boards.join('، ')}` : ''}`;
if (data.errors.length) {
error.value = data.errors
.slice(0, 3)
.map((e) => `ردیف ${e.row}: ${e.message}`)
.join(' | ');
feedback.warning(summary);
feedback.error(
data.errors
.slice(0, 3)
.map((e) => `ردیف ${e.row}: ${e.message}`)
.join(' | '),
);
} else {
feedback.success(summary);
}
if (data.boardId && data.boardId !== selectedPipelineId.value) {
await router.replace({ name: 'pipeline', query: { pipelineId: data.boardId } });
@@ -645,7 +651,7 @@ async function onImportDone(data: ImportContactsResult) {
}
function onImportFail(message: string) {
error.value = message;
feedback.error(message);
}
function onImportSettled() {
@@ -708,6 +714,29 @@ onBeforeUnmount(() => {
});
defineExpose({ updateDealStage: applyUpdateDealStage });
/* ---------- هدر صفحه ---------- */
const importTrigger = ref<HTMLElement | null>(null);
const dealCount = computed(() =>
stages.value.reduce((sum, stage) => sum + (stage.total ?? stage.deals.length), 0),
);
const headerMenuItems = computed<PageHeaderMenuItem[]>(() => [
{ key: 'export', label: 'خروجی اکسل', icon: DownloadOutlined, disabled: loading.value || busy.value },
{ key: 'import', label: 'ورود از اکسل', icon: UploadOutlined, disabled: loading.value || busy.value },
]);
function onHeaderMenu(key: string) {
if (key === 'export') void exportExcel();
// تریگر مخفی؛ کلیک کاربر روی منو activation را نگه می‌دارد
else if (key === 'import') importTrigger.value?.click();
}
/** معامله جدید از هدر ← اولین مرحلهٔ مسیر انتخاب‌شده */
function onNewDeal() {
onAddDeal(stages.value[0]?.id ?? '');
}
</script>
<template>
@@ -715,6 +744,10 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
<a-flex vertical :gap="GAP" :style="{ flexShrink: 0 }">
<PipelineToolbar
pipeline-name="مسیر فروش"
subtitle="معاملات را بین مراحل بکشید تا وضعیتشان عوض شود"
:count="loading && !stages.length ? undefined : dealCount"
primary-label="معامله جدید"
:menu-items="headerMenuItems"
:pipeline-options="pipelineOptions"
v-model:selected-pipeline-id="selectedPipelineId"
v-model:view-mode="viewMode"
@@ -723,31 +756,9 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
v-model:amount-max="amountMax"
:can-create="canCreatePipeline"
@create="showCreate = true"
@primary="onNewDeal"
@menu="onHeaderMenu"
>
<template #excel>
<a-button :disabled="loading || busy" @click="exportExcel">
<template #icon><DownloadOutlined /></template>
خروجی اکسل
</a-button>
<ExcelImportFlow
preview-path="/deals/import/preview"
import-path="/deals/import"
rows-import-path="/deals/import/rows"
:client-aliases="DEAL_EXCEL_ALIASES"
:client-fields="dealExcelFields"
:client-read-options="dealClientReadOptions"
:disabled="loading || busy"
@start="onImportStart"
@done="onImportDone"
@fail="onImportFail"
@settled="onImportSettled"
>
<a-button :disabled="loading || busy">
<template #icon><UploadOutlined /></template>
ورود از اکسل
</a-button>
</ExcelImportFlow>
</template>
<template #filters>
<SavedFiltersBar
compact
@@ -758,8 +769,26 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
</template>
</PipelineToolbar>
<!-- تریگر ورود از اکسل؛ از منوی «⋯» هدر کلیک می‌شود (مودالش به body تلپورت می‌شود) -->
<div hidden>
<ExcelImportFlow
preview-path="/deals/import/preview"
import-path="/deals/import"
rows-import-path="/deals/import/rows"
:client-aliases="DEAL_EXCEL_ALIASES"
:client-fields="dealExcelFields"
:client-read-options="dealClientReadOptions"
:disabled="loading || busy"
@start="onImportStart"
@done="onImportDone"
@fail="onImportFail"
@settled="onImportSettled"
>
<span ref="importTrigger"></span>
</ExcelImportFlow>
</div>
<a-alert v-if="error" type="error" show-icon :message="error" />
<a-alert v-if="importMsg" type="success" show-icon :message="importMsg" />
<a-spin v-if="loading && !stages.length" tip="در حال بارگذاری مسیر فروش…" />
<a-alert