fix(web): restore page header bindings so typecheck can pass.

The form builder, activities, contacts, and lead screens referenced header actions that were no longer in script, which blocked the push check.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-26 20:00:10 +03:30
co-authored by Cursor
parent 41fd7f7b2e
commit 9961a4c383
6 changed files with 165 additions and 180 deletions
+73 -5
View File
@@ -21,8 +21,14 @@ import {
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import type { PageHeaderMenuItem, PageHeaderTab, PageHeaderViewOption } from '@/components/page';
import {
AppstoreOutlined,
FileExcelOutlined,
ScheduleOutlined,
UnorderedListOutlined,
} from '@/icons/ant-bridge';
import ActivitiesKanban from '@/components/activities/ActivitiesKanban.vue';
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
import ActivityDeskFilters from '@/components/activities/ActivityDeskFilters.vue';
import ActivityStagesManager from '@/components/activities/ActivityStagesManager.vue';
import ActivityTypesManager from '@/components/activities/ActivityTypesManager.vue';
@@ -201,8 +207,6 @@ const stagesQuery = useQuery({
});
const stages = computed(() => stagesQuery.data.value ?? []);
const currentBoard = computed(() => boards.value.find((b) => b.id === board.value) ?? null);
const boardMenuOpen = ref(false);
const actionsMenuOpen = ref(false);
const importBtn = ref<HTMLButtonElement | null>(null);
function triggerImport() {
@@ -802,6 +806,70 @@ function onSearch() {
});
}
function onSearchInput(value: string) {
q.value = value;
}
const headerMenuItems = computed<PageHeaderMenuItem[]>(() => [
{ key: 'export', label: 'خروجی اکسل', icon: FileExcelOutlined },
{ key: 'import', label: 'ورود از اکسل', icon: FileExcelOutlined },
]);
function onHeaderMenu(key: string) {
if (key === 'export') void exportExcel();
else if (key === 'import') triggerImport();
}
const stageTabs = computed<PageHeaderTab[]>(() => [
{ key: 'all', label: 'همه', count: stageCounts.value.total },
...stages.value.map((s) => ({
key: s.id,
label: s.name,
count: stageCounts.value.counts[s.id] ?? 0,
})),
]);
const viewOptions: PageHeaderViewOption[] = [
{ value: 'tabs', label: 'فهرست', icon: UnorderedListOutlined },
{ value: 'board', label: 'بورد', icon: AppstoreOutlined },
];
function onHeaderTab(key: string | undefined) {
setStage(key || 'all');
}
function onHeaderView(value: string | undefined) {
setViewMode(value === 'board' ? 'board' : 'tabs');
}
const deskOptions = computed(() =>
DESK_TABS.map((tab) => ({ value: tab.key, label: tab.label })),
);
function onDeskChips(values: DeskScope[] | undefined) {
const next = values?.[0];
if (next === 'mine' || next === 'team') setDesk(next);
}
const timeOptions = computed(() =>
TIME_TABS.map((tab) => ({
value: tab.key,
label: `${tab.label} (${toFaDigits(counts.value[tab.key])})`,
})),
);
function onTimeChips(values: TimeFilter[] | undefined) {
const next = values?.[0];
if (next && TIME_KEYS.includes(next)) setFilter(next);
}
function onBoardMenuClick(info: { key: string | number }) {
const key = String(info.key);
if (key === '__create') openCreateBoard();
else if (key === '__edit') openEditBoard();
else setBoard(key);
}
function patchFacetQuery(patch: Record<string, string | undefined>) {
void router.replace({
name: 'activities',
@@ -1250,10 +1318,10 @@ onUnmounted(() => {
:view="viewMode"
@primary="activityModal = {}"
@menu="onHeaderMenu"
@update:active-tab="(k) => setStage(k ?? 'all')"
@update:active-tab="onHeaderTab"
@update:search="onSearchInput"
@search-submit="onSearch"
@update:view="(v) => setViewMode(v === 'board' ? 'board' : 'tabs')"
@update:view="onHeaderView"
>
<template #actions>
<a-button aria-label="تقویم" title="تقویم" @click="router.push({ name: 'activities-calendar' })">
+1 -16
View File
@@ -17,8 +17,8 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
import ActivityPostponeSheet from '@/components/activities/ActivityPostponeSheet.vue';
import ActivityFieldsView from '@/components/activities/ActivityFieldsView.vue';
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
import StagePathStrip from '@/components/StagePathStrip.vue';
import { ScheduleOutlined } from '@/icons/ant-bridge';
import { Button as AButton, message, Modal } from 'ant-design-vue';
import type {
ActivityChecklistItem,
@@ -891,21 +891,6 @@ async function loadActivityImages(row: ActivityDto) {
imageUrls.value = next;
}
function viewMedia(item: NoteMedia) {
window.open(item.url, '_blank', 'noopener,noreferrer');
}
function downloadMedia(item: NoteMedia) {
const link = document.createElement('a');
link.href = item.url;
link.download = item.name || 'file';
link.rel = 'noopener';
document.body.appendChild(link);
link.click();
link.remove();
}
async function loadUsers() {
try {
const [usersRes, teamsRes] = await Promise.all([
+2 -56
View File
@@ -73,7 +73,6 @@ import { canUseBehavior } from '@/lib/behavior-access';
import DiscBadge from '@/components/behavior/DiscBadge.vue';
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
import { useCustomerGroups } from '@/lib/customer-groups';
import { type ContactsFilterValue } from '@/components/ContactsFilterPanel.vue';
import { canManageSettings } from '@/lib/roles';
import { contactKeys } from '@/queries/keys';
import {
@@ -130,14 +129,6 @@ const { groups: customerGroups } = useCustomerGroups();
const canManageGroups = computed(() => canManageSettings(auth.user?.role));
const groupsManagerOpen = ref(false);
const filterValue = computed<ContactsFilterValue>(() => ({
groups: groupFilters.value,
sources: sourceFilters.value,
moods: moodFilters.value,
disc: discFilter.value,
activityExperiences: activityExperienceFilters.value,
}));
type FilterTag = {
kind: 'group' | 'source' | 'mood' | 'disc' | 'activityExperience';
value: string;
@@ -190,11 +181,6 @@ function onMobileChange(e: MediaQueryListEvent) {
onMounted(() => mobileMq?.addEventListener('change', onMobileChange));
onBeforeUnmount(() => mobileMq?.removeEventListener('change', onMobileChange));
const SORT_OPTIONS = [
{ value: 'name', label: 'نام' },
{ value: 'newest', label: 'جدیدترین' },
];
const peopleParams = computed(() => ({
q: q.value || undefined,
page: page.value,
@@ -484,42 +470,6 @@ function setSort(next: SortKey) {
patchQuery({ sort: next === 'name' ? undefined : next, page: undefined });
}
function applyFilters(next: ContactsFilterValue, nextSort?: string) {
filterOpen.value = false;
const people = tab.value === 'people';
patchQuery({
group: csv(next.groups),
...(people
? {
source: csv(next.sources),
mood: csv(next.moods),
activityExperience: csv(next.activityExperiences),
disc: next.disc || undefined,
}
: {}),
// در موبایل مرتب‌سازی داخل همان شیت فیلتر است؛ یک patch تا query قبلی overwrite نشود
...(nextSort !== undefined
? { sort: nextSort === 'newest' ? 'newest' : undefined }
: {}),
page: undefined,
});
}
/** شمارنده روی دکمه فیلتر موبایل (فیلترها + مرتب‌سازی غیرپیش‌فرض) */
const mobileFilterCount = computed(
() => activeTags.value.length + (sort.value !== 'name' ? 1 : 0),
);
function openSavedSheet() {
moreOpen.value = false;
savedSheetOpen.value = true;
}
function applySavedFromSheet(filters: Record<string, unknown>) {
savedSheetOpen.value = false;
applyPeopleSavedFilters(filters);
}
function removeTag(tag: FilterTag) {
const without = (list: string[]) => csv(list.filter((v) => v !== tag.value));
if (tag.kind === 'group') patchQuery({ group: without(groupFilters.value), page: undefined });
@@ -548,10 +498,6 @@ function clearFilters() {
});
}
async function onGroupsChanged() {
await load();
}
function setPage(next: number) {
if (next < 1 || next > pageCount.value) return;
patchQuery({ page: next === 1 ? undefined : String(next) });
@@ -731,8 +677,8 @@ function onHeaderMenu(key: string) {
else if (key === 'groups') groupsManagerOpen.value = true;
}
function onHeaderTab(key: string | number) {
setTab(String(key) === 'companies' ? 'companies' : 'people');
function onHeaderTab(key: string | undefined) {
setTab(key === 'companies' ? 'companies' : 'people');
}
function onSearchInput(value: string) {
+13 -43
View File
@@ -31,12 +31,10 @@ import {
Textarea as ATextarea,
Timeline as ATimeline,
TimelineItem as ATimelineItem,
Typography,
message,
theme,
} from 'ant-design-vue';
import {
ArrowLeftOutlined,
CopyOutlined,
EditOutlined,
MessageOutlined,
@@ -52,7 +50,6 @@ import {
leadNoteFileIsImage,
parseLeadFormNotes,
} from '@/lib/lead-form-notes';
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
import {
formatClockFa,
formatJalaliNumeric,
@@ -79,8 +76,6 @@ import { ACTIVITY_TYPE_LABELS, PERSON_GENDERS, PERSON_GENDER_LABELS, splitPerson
import { canUseBehavior } from '@/lib/behavior-access';
import SalesCopilotPanel from '@/components/behavior/SalesCopilotPanel.vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const { token } = theme.useToken();
type LeadDetail = LeadDto & { events: LeadEventDto[] };
@@ -94,17 +89,6 @@ 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('');
@@ -150,11 +134,6 @@ const editForm = ref({
notes: '',
});
const activityExperienceOptions = [
{ value: '', label: '—' },
...ACTIVITY_EXPERIENCE_OPTIONS.map((value) => ({ value, label: value })),
];
function formatDate(value: string | null | undefined) {
if (!value) return '—';
try {
@@ -172,14 +151,6 @@ const shownBirthDate = computed(() => {
if (lead.value?.birthDate) return formatDate(lead.value.birthDate);
return formBirthDate.value || '—';
});
const formActivityExperience = computed(
() =>
noteView.value.rows.find((row) => isActivityExperienceAnswer(row.label) && !row.file)?.text ??
'',
);
const shownActivityExperience = computed(
() => lead.value?.activityExperience || formActivityExperience.value || '—',
);
const answerRows = computed(() =>
noteView.value.rows.filter(
(row) => !isBirthDateAnswer(row.label) && !isActivityExperienceAnswer(row.label),
@@ -309,20 +280,6 @@ async function saveEdit() {
}
}
function openStageMove() {
if (!stageId.value || stageId.value === lead.value?.stageId) return;
stageMoveReason.value = '';
stageMoveError.value = '';
stageMoveOpen.value = true;
}
function cancelStageMove() {
stageMoveOpen.value = false;
stageMoveReason.value = '';
stageMoveError.value = '';
if (lead.value) stageId.value = lead.value.stageId;
}
async function changeStage() {
if (!stageId.value || stageId.value === lead.value?.stageId) {
return Promise.reject();
@@ -475,6 +432,19 @@ function convertLead() {
});
}
const leadMenuItems = computed(() => [
{
key: 'archive',
label: 'بایگانی',
danger: true,
disabled: busy.value || !lead.value,
},
]);
function onLeadMenu(key: string) {
if (key === 'archive') archiveLead();
}
function archiveLead() {
AModal.confirm({
title: 'این لید بایگانی شود؟',
+73 -7
View File
@@ -1,8 +1,25 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { computed, nextTick, onMounted, ref, watch, type Component } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import { theme, type UploadProps } from 'ant-design-vue';
import { api } from '@/lib/api';
import {
AppstoreOutlined,
BarChartOutlined,
CalendarOutlined,
CheckOutlined,
CommentOutlined,
FileOutlined,
FileTextOutlined,
MailOutlined,
NotificationOutlined,
PhoneOutlined,
SaveOutlined,
StarOutlined,
UnorderedListOutlined,
UserOutlined,
} from '@/icons/ant-bridge';
import type {
LeadFormDto,
LeadFormDuplicateMode,
@@ -21,11 +38,29 @@ import { toFaDigits } from '@/lib/jalali';
import { prepareFormCover } from '@/lib/form-cover';
import { useEscClose } from '@/lib/modal-stack';
const { token } = theme.useToken();
type Tab = 'edit' | 'settings' | 'share' | 'responses';
type IconName =
| 'user' | 'chat' | 'mail' | 'phone' | 'list' | 'layers' | 'calendar'
| 'check' | 'chart' | 'document' | 'star' | 'megaphone' | 'building';
const ICON_MAP: Record<IconName, Component> = {
user: UserOutlined,
chat: CommentOutlined,
mail: MailOutlined,
phone: PhoneOutlined,
list: UnorderedListOutlined,
layers: AppstoreOutlined,
calendar: CalendarOutlined,
check: CheckOutlined,
chart: BarChartOutlined,
document: FileOutlined,
star: StarOutlined,
megaphone: NotificationOutlined,
building: AppstoreOutlined,
};
const route = useRoute();
const router = useRouter();
const id = computed(() => String(route.params.id || ''));
@@ -63,7 +98,6 @@ const users = ref<OrgUserDto[]>([]);
const pipelines = ref<PipelineDto[]>([]);
const leadStages = ref<LeadStageDto[]>([]);
const submissions = ref<LeadFormSubmissionDto[]>([]);
const coverInput = ref<HTMLInputElement | null>(null);
const toolbox: Array<{ type: LeadFormFieldType; label: string; icon: IconName }> = [
{ type: 'text', label: 'متن کوتاه', icon: 'user' },
@@ -260,6 +294,28 @@ const crmSummary = computed(() => {
return parts.join(' · ') || 'اتصال CRM تنظیم نشده';
});
const leadStageOptions = computed(() => [
{ value: '', label: 'اولین مرحله فعال' },
...leadStages.value.map((s) => ({ value: s.id, label: s.name })),
]);
const pipelineOptions = computed(() => [
{ value: '', label: 'پیش‌فرض سازمان' },
...pipelines.value.map((p) => ({ value: p.id, label: p.name })),
]);
const duplicateOptions: { value: LeadFormDuplicateMode; label: string }[] = [
{ value: 'update', label: 'به‌روزرسانی لید موجود' },
{ value: 'skip', label: 'رد کردن (ثبت نشود)' },
{ value: 'activity', label: 'فقط ثبت رویداد روی لید موجود' },
];
const settingsSummaryItems = computed(() => [
{ label: 'وضعیت', value: isActive.value ? 'فعال' : 'غیرفعال' },
{ label: 'ثبت لید', value: createLead.value ? 'بله' : 'خیر' },
{ label: 'ساخت شخص', value: createPerson.value ? 'بله' : 'خیر' },
{ label: 'ساخت معامله', value: createDeal.value ? 'بله' : 'خیر' },
{ label: 'منبع', value: source.value || '—' },
{ label: 'مسئولان', value: toFaDigits(assigneeIds.value.length) },
]);
function newKey(label: string) {
const base = label.replace(/\s+/g, '_').slice(0, 24) || 'field';
let key = `${base}_${Math.random().toString(36).slice(2, 6)}`;
@@ -461,11 +517,7 @@ async function save() {
}
}
async function uploadCover(ev: Event) {
const input = ev.target as HTMLInputElement;
const file = input.files?.[0];
input.value = '';
if (!file) return;
async function handleCoverFile(file: File) {
error.value = '';
coverUploading.value = true;
try {
@@ -482,6 +534,11 @@ async function uploadCover(ev: Event) {
}
}
const beforeCoverUpload: UploadProps['beforeUpload'] = (file) => {
void handleCoverFile(file as File);
return false;
};
async function clearCover() {
try {
const { data } = await api.delete<LeadFormDto>(`/lead-forms/${id.value}/cover`);
@@ -551,6 +608,15 @@ function toggleAssignee(uid: string) {
: [...assigneeIds.value, uid];
}
function onTabChange(key: string | number) {
const next = String(key) as Tab;
if (next === 'responses') {
void loadResponses();
return;
}
tab.value = next;
}
onMounted(load);
</script>
+3 -53
View File
@@ -16,22 +16,17 @@ import {
FormItem as AFormItem,
Grid,
Input as AInput,
InputSearch as AInputSearch,
Menu as AMenu,
MenuItem as AMenuItem,
Modal,
Modal as AModal,
Pagination as APagination,
RadioButton as ARadioButton,
RadioGroup as ARadioGroup,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Table as ATable,
Tag as ATag,
Textarea as ATextarea,
Typography,
Upload as AUpload,
message,
theme,
@@ -40,14 +35,11 @@ import type { TableColumnsType, UploadProps } from 'ant-design-vue';
import {
AppstoreOutlined,
DeleteOutlined,
DownOutlined,
EditOutlined,
ExportOutlined,
FileExcelOutlined,
FilterOutlined,
MoreOutlined,
PhoneOutlined,
PlusOutlined,
SearchOutlined,
UnorderedListOutlined,
UserAddOutlined,
@@ -100,8 +92,6 @@ import {
splitPersonHonorific,
} from '@mento/shared';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const { token } = theme.useToken();
const screens = Grid.useBreakpoint();
const isMobile = computed(() => !screens.value.md);
@@ -296,11 +286,6 @@ const mobileFilterBadgeCount = computed(() =>
convertedFilter.value ? '1' : '',
].filter(Boolean).length,
);
const filterBtnLabel = computed(() =>
mobileFilterBadgeCount.value
? `فیلتر (${toFaDigits(mobileFilterBadgeCount.value)})`
: 'فیلتر',
);
type LeadFacetKey =
| 'assignee'
@@ -580,13 +565,6 @@ const rangeTo = computed(() =>
);
const selectedIds = computed(() => [...selected.value]);
const sortLabels: Record<SortKey, string> = {
newest: 'تاریخ جدیدترین',
updated: 'آخرین به‌روزرسانی',
follow_up: 'پیگیری بعدی',
last_contact: 'آخرین تماس',
};
/** چیپ‌های فیلتر = ستون‌های واقعی سازمان (نه نام‌های ثابت قدیمی) */
const stageCards = computed((): LeadStatCard[] => {
return stages.value.map((s) => ({
@@ -656,9 +634,9 @@ function onHeaderMenu(key: string) {
else if (key === 'phone') phoneImportTrigger.value?.click();
}
function onHeaderTab(key: string | number) {
const value = String(key);
setStageFilter(value === 'all' ? '' : value);
function onHeaderTab(key: string | undefined) {
if (!key) return;
setStageFilter(key === 'all' ? '' : key);
}
function onSearchInput(value: string) {
@@ -689,27 +667,6 @@ function onRemoveFilter(key: string) {
else if (key === 'archived') setArchivedFilter(false);
}
/** گزینه‌های سلکت موبایل — برچسب + تعداد */
const stageFilterOptions = computed(() => [
{
value: '',
label: `همه لیدها (${formatCount(totalLeadsCount.value)})`,
},
...stageCards.value.map((card) => ({
value: card.stageId,
label: `${card.label} (${formatCount(card.count)})`,
})),
]);
function isStatActive(card: LeadStatCard) {
return Boolean(card.stageId && stageId.value === card.stageId);
}
function selectStatCard(card: LeadStatCard) {
if (!card.stageId) return;
setStageFilter(isStatActive(card) ? '' : card.stageId);
}
function stageTint(color: string | null | undefined): StageTint {
const c = (color || '').toLowerCase();
if (c === 'amber' || c === 'yellow' || c === 'orange') return 'amber';
@@ -1427,13 +1384,6 @@ async function assignSelected() {
}
}
function openBulkStageReason() {
if (!bulkStageId.value || !selectedIds.value.length) return;
bulkStageReason.value = '';
bulkStageReasonError.value = '';
bulkStageReasonOpen.value = true;
}
function cancelBulkStageReason() {
bulkStageReasonOpen.value = false;
bulkStageReason.value = '';