Adding registration date and multiple addresses for contacts and leads.

This commit is contained in:
2026-10-03 12:29:11 +03:30
parent 989c03b381
commit 1309da2281
22 changed files with 699 additions and 32 deletions
@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "instagram" TEXT;
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "addresses" JSONB NOT NULL DEFAULT '[]';
-- AlterTable
ALTER TABLE "Lead" ADD COLUMN IF NOT EXISTS "instagram" TEXT;
ALTER TABLE "Lead" ADD COLUMN IF NOT EXISTS "addresses" JSONB NOT NULL DEFAULT '[]';
+8
View File
@@ -432,8 +432,12 @@ model Person {
position String?
/// آدرس وب‌سایت
website String?
/// پیج اینستاگرام
instagram String?
/// نام معرف
referrer String?
/// لیست آدرس‌ها (JSON array of strings)
addresses Json @default("[]")
notes String?
mood PersonMood @default(newcomer)
tags String[] @default([])
@@ -2064,6 +2068,10 @@ model Lead {
phone String?
city String?
region String?
/// پیج اینستاگرام
instagram String?
/// لیست آدرس‌ها (JSON array of strings)
addresses Json @default("[]")
/// صنف
trade String?
source String?
+20
View File
@@ -12,3 +12,23 @@ export function toJsonCustomFields(
): Prisma.InputJsonValue {
return (value ?? {}) as Prisma.InputJsonValue;
}
export function asAddresses(value: unknown): string[] {
if (!Array.isArray(value)) return [];
const out: string[] = [];
for (const item of value) {
const text = String(item ?? '').trim();
if (text && !out.includes(text)) out.push(text);
if (out.length >= 20) break;
}
return out;
}
export function toJsonAddresses(value?: string[] | null): Prisma.InputJsonValue {
return asAddresses(value ?? []);
}
/** Collect address-like cells from an excel row into a unique list. */
export function collectAddresses(...parts: Array<string | undefined | null>): string[] {
return asAddresses(parts.map((p) => (p ?? '').trim()).filter(Boolean));
}
@@ -4,9 +4,13 @@ import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@mento/shared';
import { PrismaService } from '../prisma/prisma.service';
import type { Actor } from '../common/record-scope';
import { ownerWhere, resolveOwnerId } from '../common/record-scope';
import {
collectAddresses,
} from '../common/custom-fields';
import {
formatJalaliDate,
parseExcelMapping,
parseJalaliDateTime,
previewExcel,
readMappedRows,
writeXlsx,
@@ -73,8 +77,17 @@ const PERSON_ALIASES: Record<string, string> = {
گروهمشتری: 'group',
آدرس: 'address',
آدرس1: 'address',
آدرساصلی: 'address',
address: 'address',
address2: 'address2',
آدرس۲: 'address2',
آدرس2: 'address2',
آدرس_1: 'address2',
آدرسدوم: 'address2',
آدرسمنزل: 'homeAddress',
آدرمنزل: 'homeAddress',
آدرسخانه: 'homeAddress',
homeaddress: 'homeAddress',
کدپستی: 'postalCode',
کدپستی1: 'postalCode',
استانفیلدپیشفرض: 'province',
@@ -93,8 +106,13 @@ const PERSON_ALIASES: Record<string, string> = {
type: '_type',
_type: '_type',
آیدیاینستاگرام: 'instagram',
اینستاگرام: 'instagram',
پیجاینستاگرام: 'instagram',
instagram: 'instagram',
معرف: 'referrer',
سایتهایمشتری: 'website',
تاریخثبت: 'registeredAt',
registeredat: 'registeredAt',
شمارهفکس: 'fax',
تلفن2: 'phone2',
تلفنهایدیگرمشتری: 'otherPhones',
@@ -128,6 +146,11 @@ const PERSON_FIELDS = [
{ key: 'position', label: 'سمت' },
{ key: 'companyName', label: 'شرکت' },
{ key: 'ownerName', label: 'کارشناس فروش' },
{ key: 'address', label: 'آدرس' },
{ key: 'address2', label: 'آدرس ۲' },
{ key: 'homeAddress', label: 'آدرس منزل' },
{ key: 'instagram', label: 'اینستاگرام' },
{ key: 'registeredAt', label: 'تاریخ ثبت' },
{ key: 'notes', label: 'یادداشت' },
{ key: 'mood', label: 'وضعیت مشتری' },
];
@@ -218,6 +241,7 @@ const CUSTOM_KEYS = [
'province',
'city',
'address',
'address2',
'nationalId',
'birthDate',
'group',
@@ -279,20 +303,20 @@ export class ContactsExcelService {
birthDate: extra.birthDate ?? '',
mood: extra.group || PERSON_MOOD_LABELS[p.mood || 'newcomer'],
otherPhones: extra.otherPhones ?? '',
address: extra.address ?? '',
website: extra.website ?? '',
address: p.addresses[0] ?? extra.address ?? '',
website: p.website ?? extra.website ?? '',
otherEmails: extra.otherEmails ?? '',
position2: p.position ?? extra.position ?? '',
city2: extra.city ?? '',
code2: extra.customerCode ?? '',
group2: extra.group ?? '',
address2: extra.address ?? '',
address2: p.addresses[1] ?? extra.address ?? '',
phone2: extra.phone2 ?? p.phone ?? '',
postalCode2: extra.postalCode ?? '',
referrer: extra.referrer ?? '',
homeAddress: extra.homeAddress ?? '',
referrer: extra.referrer ?? p.referrer ?? '',
homeAddress: p.addresses[2] ?? extra.homeAddress ?? '',
birthDate2: extra.birthDate ?? '',
instagram: extra.instagram ?? '',
instagram: p.instagram ?? extra.instagram ?? '',
group: extra.group ?? '',
colleagueContact: extra.colleagueContact ?? '',
previousCompany: extra.previousCompany ?? '',
@@ -388,10 +412,33 @@ export class ContactsExcelService {
const customFields: Record<string, string> = {};
for (const key of CUSTOM_KEYS) {
if (
key === 'address' ||
key === 'address2' ||
key === 'homeAddress' ||
key === 'instagram' ||
key === 'website'
) {
continue;
}
const value = row[key]?.trim();
if (value) customFields[key] = value;
}
const addresses = collectAddresses(
row.address,
row.address2,
row.homeAddress,
);
const registeredAt =
parseJalaliDateTime(row.registeredAt) ??
(() => {
const raw = row.registeredAt?.trim();
if (!raw) return null;
const d = new Date(raw);
return Number.isNaN(d.getTime()) ? null : d;
})();
try {
await this.people.create(actor, {
firstName: names.firstName,
@@ -400,11 +447,15 @@ export class ContactsExcelService {
phone: row.phone || row.phone2 || undefined,
mobile: row.mobile || undefined,
position: row.position || undefined,
website: row.website || undefined,
instagram: row.instagram || undefined,
addresses,
notes: row.notes || undefined,
mood: parseMood(row.mood) ?? parseMood(row.group),
companyId,
ownerId: resolveOwnerId(actor, ownerId ?? null),
customFields,
registeredAt: registeredAt?.toISOString() ?? null,
});
result.created += 1;
if (ownerMissing) {
+25
View File
@@ -181,11 +181,21 @@ export class CreatePersonDto {
@MaxLength(300)
website?: string;
@IsOptional()
@IsString()
@MaxLength(200)
instagram?: string;
@IsOptional()
@IsString()
@MaxLength(120)
referrer?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
addresses?: string[];
@IsOptional()
@IsString()
@MaxLength(2000)
@@ -213,6 +223,11 @@ export class CreatePersonDto {
@ValidateIf((_, v) => v !== '' && v != null)
@IsString()
ownerId?: string | null;
/** فقط برای ایمپورت اکسل — تاریخ ثبت مبدأ */
@IsOptional()
@IsString()
registeredAt?: string | null;
}
export class UpdatePersonDto {
@@ -251,11 +266,21 @@ export class UpdatePersonDto {
@MaxLength(300)
website?: string;
@IsOptional()
@IsString()
@MaxLength(200)
instagram?: string;
@IsOptional()
@IsString()
@MaxLength(120)
referrer?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
addresses?: string[];
@IsOptional()
@IsString()
@MaxLength(2000)
+23
View File
@@ -15,7 +15,9 @@ import { PrismaService } from '../prisma/prisma.service';
import { CompaniesService } from './companies.service';
import { emptyToNull, normalizeEmail, normalizePhone } from './normalize';
import {
asAddresses,
asCustomFields,
toJsonAddresses,
toJsonCustomFields,
} from '../common/custom-fields';
import {
@@ -47,7 +49,9 @@ type PersonRow = {
mobile: string | null;
position: string | null;
website: string | null;
instagram: string | null;
referrer: string | null;
addresses: unknown;
notes: string | null;
mood: PersonMood;
tags: string[];
@@ -138,6 +142,7 @@ export class PeopleService {
await this.companies.ensureInOrg(actor.organizationId, companyId, actor);
}
const registeredAt = dto.registeredAt ? new Date(dto.registeredAt) : null;
const data: Prisma.PersonUncheckedCreateInput = {
organizationId: actor.organizationId,
firstName: (dto.firstName ?? '').trim(),
@@ -147,13 +152,18 @@ export class PeopleService {
mobile: normalizePhone(dto.mobile),
position: emptyToNull(dto.position),
website: emptyToNull(dto.website),
instagram: emptyToNull(dto.instagram),
referrer: emptyToNull(dto.referrer),
addresses: toJsonAddresses(dto.addresses),
notes: emptyToNull(dto.notes),
mood: dto.mood ?? 'newcomer',
tags: normalizeTags(dto.tags),
companyId,
ownerId: resolveOwnerId(actor, dto.ownerId),
customFields: toJsonCustomFields(dto.customFields),
...(registeredAt && !Number.isNaN(registeredAt.getTime())
? { createdAt: registeredAt }
: {}),
};
await this.assertNoDuplicate(actor.organizationId, data);
@@ -202,7 +212,9 @@ export class PeopleService {
if ('mobile' in dto) data.mobile = normalizePhone(dto.mobile);
if ('position' in dto) data.position = emptyToNull(dto.position);
if ('website' in dto) data.website = emptyToNull(dto.website);
if ('instagram' in dto) data.instagram = emptyToNull(dto.instagram);
if ('referrer' in dto) data.referrer = emptyToNull(dto.referrer);
if ('addresses' in dto) data.addresses = toJsonAddresses(dto.addresses);
if ('notes' in dto) data.notes = emptyToNull(dto.notes);
if (dto.mood !== undefined) data.mood = dto.mood;
if ('tags' in dto) data.tags = normalizeTags(dto.tags);
@@ -295,7 +307,18 @@ export class PeopleService {
mobile: row.mobile,
position: row.position,
website: row.website,
instagram: row.instagram,
referrer: row.referrer,
addresses: (() => {
const fromCol = asAddresses(row.addresses);
if (fromCol.length) return fromCol;
const extra = asCustomFields(row.customFields);
return asAddresses(
[extra.address, extra.homeAddress, extra.address2]
.map((v) => (typeof v === 'string' ? v : ''))
.filter(Boolean),
);
})(),
notes: row.notes,
mood: row.mood,
tags: row.tags ?? [],
+6
View File
@@ -21,6 +21,8 @@ export class CreateLeadDto {
@IsOptional() @IsString() phone?: string;
@IsOptional() @IsString() city?: string;
@IsOptional() @IsString() region?: string;
@IsOptional() @IsString() instagram?: string;
@IsOptional() @IsArray() @IsString({ each: true }) addresses?: string[];
@IsOptional() @IsString() trade?: string;
@IsOptional() @IsString() source?: string;
@IsOptional() @IsString() notes?: string;
@@ -28,6 +30,8 @@ export class CreateLeadDto {
@IsOptional() @IsString() stageId?: string;
@IsOptional() @IsString() assigneeId?: string | null;
@IsOptional() @IsString() nextFollowUpAt?: string | null;
/** فقط برای ایمپورت اکسل — تاریخ ثبت مبدأ */
@IsOptional() @IsString() registeredAt?: string | null;
}
export class UpdateLeadDto {
@@ -37,6 +41,8 @@ export class UpdateLeadDto {
@IsOptional() @IsString() phone?: string | null;
@IsOptional() @IsString() city?: string | null;
@IsOptional() @IsString() region?: string | null;
@IsOptional() @IsString() instagram?: string | null;
@IsOptional() @IsArray() @IsString({ each: true }) addresses?: string[];
@IsOptional() @IsString() trade?: string | null;
@IsOptional() @IsString() source?: string | null;
@IsOptional() @IsString() notes?: string | null;
@@ -5,6 +5,7 @@ import type { LeadImportJobDto } from '@mento/shared';
import { PrismaService } from '../prisma/prisma.service';
import {
parseExcelMapping,
parseJalaliDateTime,
previewExcel,
readMappedRows,
type ExcelFieldOption,
@@ -40,6 +41,23 @@ const LEAD_ALIASES: Record<string, string> = {
region: 'region',
منطقه: 'region',
محله: 'region',
address: 'address',
آدرس: 'address',
آدرساصلی: 'address',
address2: 'address2',
آدرس۲: 'address2',
آدرس2: 'address2',
آدرسدوم: 'address2',
homeaddress: 'homeAddress',
آدرسمنزل: 'homeAddress',
آدرسخانه: 'homeAddress',
instagram: 'instagram',
اینستاگرام: 'instagram',
پیجاینستاگرام: 'instagram',
آیدیاینستاگرام: 'instagram',
registeredat: 'registeredAt',
تاریخثبت: 'registeredAt',
تاریخثبتمشتری: 'registeredAt',
trade: 'trade',
صنف: 'trade',
رسته: 'trade',
@@ -58,6 +76,11 @@ const LEAD_FIELDS: ExcelFieldOption[] = [
{ key: 'phone', label: 'تلفن' },
{ key: 'city', label: 'شهر' },
{ key: 'region', label: 'منطقه' },
{ key: 'address', label: 'آدرس' },
{ key: 'address2', label: 'آدرس ۲' },
{ key: 'homeAddress', label: 'آدرس منزل' },
{ key: 'instagram', label: 'اینستاگرام' },
{ key: 'registeredAt', label: 'تاریخ ثبت' },
{ key: 'trade', label: 'صنف' },
{ key: 'source', label: 'منبع' },
{ key: 'notes', label: 'توضیحات' },
@@ -237,6 +260,19 @@ export class LeadsImportService {
}
return '';
};
const registeredRaw = get(
'registeredAt',
'تاریخ ثبت',
'تاریخ ثبت مشتری',
'registeredat',
);
const registeredAt =
parseJalaliDateTime(registeredRaw)?.toISOString() ??
(() => {
if (!registeredRaw) return '';
const d = new Date(registeredRaw);
return Number.isNaN(d.getTime()) ? '' : d.toISOString();
})();
return {
title: get('title', 'نام', 'نام فروشگاه', 'فروشگاه', 'shop', 'name'),
contactName: get('contactName', 'مالک', 'مسئول', 'نام مالک', 'owner'),
@@ -244,6 +280,11 @@ export class LeadsImportService {
phone: get('phone', 'تلفن'),
city: get('city', 'شهر'),
region: get('region', 'منطقه', 'محله'),
address: get('address', 'آدرس', 'آدرس اصلی'),
address2: get('address2', 'آدرس ۲', 'آدرس2', 'آدرس دوم'),
homeAddress: get('homeAddress', 'آدرس منزل', 'آدرس خانه'),
instagram: get('instagram', 'اینستاگرام', 'پیج اینستاگرام', 'آی دی اینستاگرام'),
registeredAt,
trade: get('trade', 'صنف', 'رسته'),
source: get('source', 'منبع', 'منبع لید'),
notes: get('notes', 'توضیحات', 'یادداشت'),
+38
View File
@@ -20,6 +20,11 @@ import {
type Actor,
elevated,
} from '../common/record-scope';
import {
asAddresses,
collectAddresses,
toJsonAddresses,
} from '../common/custom-fields';
import { emptyToNull, normalizePhone } from '../contacts/normalize';
import { LocalFileStorage } from '../storage/local-file.storage';
import { LeadStagesService } from './lead-stages.service';
@@ -238,6 +243,8 @@ export class LeadsService {
phone?: string | null;
city?: string | null;
region?: string | null;
instagram?: string | null;
addresses?: string[];
trade?: string | null;
source?: string | null;
notes?: string | null;
@@ -245,6 +252,7 @@ export class LeadsService {
stageId?: string;
assigneeId?: string | null;
nextFollowUpAt?: string | null;
registeredAt?: string | null;
},
): Promise<LeadDto> {
await this.stages.ensureDefaults(actor.organizationId);
@@ -271,6 +279,7 @@ export class LeadsService {
assigneeId = actor.userId;
}
const registeredAt = dto.registeredAt ? new Date(dto.registeredAt) : null;
const row = await this.prisma.lead.create({
data: {
organizationId: actor.organizationId,
@@ -280,6 +289,8 @@ export class LeadsService {
phone: emptyToNull(dto.phone),
city: emptyToNull(dto.city),
region: emptyToNull(dto.region),
instagram: emptyToNull(dto.instagram),
addresses: toJsonAddresses(dto.addresses),
trade: emptyToNull(dto.trade),
source: emptyToNull(dto.source),
notes: emptyToNull(dto.notes),
@@ -287,6 +298,9 @@ export class LeadsService {
dto.estimatedValue != null
? new Prisma.Decimal(dto.estimatedValue)
: null,
...(registeredAt && !Number.isNaN(registeredAt.getTime())
? { createdAt: registeredAt }
: {}),
stageId,
assigneeId,
createdById: actor.userId,
@@ -351,6 +365,12 @@ export class LeadsService {
...(dto.region !== undefined
? { region: emptyToNull(dto.region as string) }
: {}),
...(dto.instagram !== undefined
? { instagram: emptyToNull(dto.instagram as string) }
: {}),
...(dto.addresses !== undefined
? { addresses: toJsonAddresses(dto.addresses) }
: {}),
...(dto.trade !== undefined
? { trade: emptyToNull(dto.trade as string) }
: {}),
@@ -717,6 +737,8 @@ export class LeadsService {
lastName,
mobile: lead.mobile,
phone: lead.phone,
instagram: lead.instagram,
addresses: toJsonAddresses(asAddresses(lead.addresses)),
notes: [
lead.notes,
lead.city ? `شهر: ${lead.city}` : null,
@@ -727,6 +749,7 @@ export class LeadsService {
.filter(Boolean)
.join('\n'),
ownerId: lead.assigneeId ?? actor.userId,
createdAt: lead.createdAt,
},
});
createdPerson = true;
@@ -884,6 +907,11 @@ export class LeadsService {
phone?: string;
city?: string;
region?: string;
address?: string;
address2?: string;
homeAddress?: string;
instagram?: string;
registeredAt?: string;
trade?: string;
source?: string;
notes?: string;
@@ -910,6 +938,7 @@ export class LeadsService {
if (existingPerson) return 'duplicate';
try {
const registeredAt = row.registeredAt ? new Date(row.registeredAt) : null;
const lead = await this.prisma.lead.create({
data: {
organizationId,
@@ -919,11 +948,18 @@ export class LeadsService {
phone: emptyToNull(row.phone),
city: emptyToNull(row.city),
region: emptyToNull(row.region),
instagram: emptyToNull(row.instagram),
addresses: toJsonAddresses(
collectAddresses(row.address, row.address2, row.homeAddress),
),
trade: emptyToNull(row.trade),
source: emptyToNull(row.source) ?? 'ایمپورت اکسل',
notes: emptyToNull(row.notes),
stageId: defaultStageId,
createdById,
...(registeredAt && !Number.isNaN(registeredAt.getTime())
? { createdAt: registeredAt }
: {}),
},
});
await this.prisma.leadEvent.create({
@@ -990,6 +1026,8 @@ export class LeadsService {
phone: row.phone,
city: row.city,
region: row.region,
instagram: row.instagram,
addresses: asAddresses(row.addresses),
trade: row.trade,
source: row.source,
notes: row.notes,
+33 -8
View File
@@ -3,7 +3,7 @@ import { computed, reactive, ref } from 'vue';
import axios from 'axios';
import { api } from '@/lib/api';
import type { ExcelPreviewResult, ImportContactsResult } from '@mento/shared';
import { UiButton, UiModal, UiSelect } from '@/components/ui';
import { UiBusyOverlay, UiButton, UiModal, UiSelect } from '@/components/ui';
const props = defineProps<{
previewPath: string;
@@ -23,6 +23,7 @@ const pending = ref<File | null>(null);
const preview = ref<ExcelPreviewResult | null>(null);
const mapping = reactive<Record<string, string>>({});
const submitting = ref(false);
const phase = ref<'idle' | 'preview' | 'import'>('idle');
const requiredKeys = computed(
() => preview.value?.fields.filter((f) => f.required).map((f) => f.key) ?? [],
@@ -32,6 +33,11 @@ const mappedFields = computed(() => new Set(Object.values(mapping).filter(Boolea
const canImport = computed(() => requiredKeys.value.every((key) => mappedFields.value.has(key)));
const busyOpen = computed(() => submitting.value && phase.value !== 'idle');
const busyMessage = computed(() =>
phase.value === 'import' ? 'در حال ورود اطلاعات از اکسل…' : 'در حال خواندن و بررسی فایل اکسل…',
);
function pick() {
if (props.disabled || submitting.value) return;
input.value?.click();
@@ -41,10 +47,12 @@ function reset() {
pending.value = null;
preview.value = null;
submitting.value = false;
phase.value = 'idle';
for (const key of Object.keys(mapping)) delete mapping[key];
}
function closeMapper() {
if (submitting.value) return;
reset();
emit('settled');
}
@@ -59,6 +67,7 @@ function setColumnField(header: string, field: string) {
}
async function postImport(file: File, map?: Record<string, string>) {
phase.value = 'import';
const form = new FormData();
form.append('file', file);
if (map && Object.values(map).some(Boolean)) {
@@ -89,6 +98,7 @@ async function onFile(ev: Event) {
if (!file) return;
emit('start');
submitting.value = true;
phase.value = 'preview';
try {
const form = new FormData();
form.append('file', file);
@@ -106,42 +116,51 @@ async function onFile(ev: Event) {
for (const col of data.columns) {
mapping[col.header] = data.suggested[col.header] ?? '';
}
phase.value = 'idle';
submitting.value = false;
// Allow parent toolbar while user maps columns.
emit('settled');
} catch (e) {
emit('fail', apiMessage(e, 'خواندن فایل اکسل ناموفق بود'));
reset();
emit('settled');
} finally {
submitting.value = false;
}
}
async function confirmMapping() {
if (!pending.value || !canImport.value) return;
if (!pending.value || !canImport.value || submitting.value) return;
emit('start');
submitting.value = true;
phase.value = 'import';
try {
emit('done', await postImport(pending.value, { ...mapping }));
reset();
emit('settled');
} catch (e) {
emit('fail', apiMessage(e, 'ایمپورت ناموفق بود'));
phase.value = 'idle';
submitting.value = false;
emit('settled');
}
}
</script>
<template>
<span class="excel-import" @click.stop="pick">
<slot />
<span class="excel-import" :class="{ isBusy: submitting }" @click.stop="pick">
<slot :loading="submitting" :disabled="disabled || submitting" />
<input
ref="input"
type="file"
accept=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
hidden
:disabled="disabled || submitting"
@change="onFile"
@click.stop
/>
</span>
<UiBusyOverlay :open="busyOpen" :message="busyMessage" nest />
<UiModal :open="!!preview" title="تطبیق ستون‌های اکسل" @close="closeMapper">
<p class="lead">
ستون‌های این فایل با قالب سیستم یکی نیست. مشخص کنید هر ستون فایل در کدام فیلد ریخته شود.
@@ -154,6 +173,7 @@ async function confirmMapping() {
</div>
<UiSelect
:model-value="mapping[col.header] ?? ''"
:disabled="submitting"
@update:model-value="setColumnField(col.header, $event)"
>
<option value="">نادیده بگیر</option>
@@ -166,8 +186,8 @@ async function confirmMapping() {
<p v-if="!canImport" class="hint">فیلدهای ستاره‌دار را حتماً به یک ستون وصل کنید.</p>
<template #footer>
<UiButton variant="ghost" :disabled="submitting" @click="closeMapper">انصراف</UiButton>
<UiButton :disabled="submitting || !canImport" @click="confirmMapping">
{{ submitting ? 'در حال ورود…' : 'ورود فایل' }}
<UiButton :disabled="!canImport" :loading="submitting" @click="confirmMapping">
ورود فایل
</UiButton>
</template>
</UiModal>
@@ -178,6 +198,11 @@ async function confirmMapping() {
display: inline-flex;
}
.excel-import.isBusy {
pointer-events: none;
opacity: 0.7;
}
.lead {
margin: 0 0 1rem;
color: var(--muted);
@@ -0,0 +1,84 @@
<script setup lang="ts">
withDefaults(
defineProps<{
open: boolean;
message?: string;
/** وقتی true باشد روی مودال هم دیده می‌شود */
nest?: boolean;
}>(),
{
message: 'لطفاً صبر کنید…',
nest: false,
},
);
</script>
<template>
<Teleport to="body">
<div
v-if="open"
class="busy-overlay"
:class="{ nest }"
role="status"
aria-live="polite"
aria-busy="true"
>
<div class="card">
<span class="spinner" aria-hidden="true" />
<p>{{ message }}</p>
</div>
</div>
</Teleport>
</template>
<style scoped>
.busy-overlay {
position: fixed;
inset: 0;
z-index: 90;
display: grid;
place-items: center;
padding: 16px;
background: rgba(15, 23, 42, 0.4);
backdrop-filter: blur(2px);
}
.busy-overlay.nest {
z-index: 110;
}
.card {
display: grid;
justify-items: center;
gap: 0.85rem;
min-width: min(18rem, 100%);
padding: 1.35rem 1.5rem;
border-radius: 16px;
background: #fff;
box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
color: #0f172a;
text-align: center;
}
.card p {
margin: 0;
font-size: 0.95rem;
font-weight: 600;
line-height: 1.6;
}
.spinner {
width: 28px;
height: 28px;
border: 3px solid #ccfbf1;
border-top-color: #0d9488;
border-radius: 50%;
animation: busy-spin 0.7s linear infinite;
}
@keyframes busy-spin {
to {
transform: rotate(360deg);
}
}
</style>
+1
View File
@@ -5,6 +5,7 @@ export { default as UiSelect } from './UiSelect.vue';
export { default as UiField } from './UiField.vue';
export { default as UiCard } from './UiCard.vue';
export { default as UiModal } from './UiModal.vue';
export { default as UiBusyOverlay } from './UiBusyOverlay.vue';
export { default as UiPageHeader } from './UiPageHeader.vue';
export { default as UiBadge } from './UiBadge.vue';
export { default as UiPagination } from './UiPagination.vue';
+16 -5
View File
@@ -11,6 +11,7 @@ import {
toFaDigits,
} from '@/lib/jalali';
import {
UiBusyOverlay,
UiButton,
UiDropdownMenu,
UiModal,
@@ -123,6 +124,8 @@ const activityModal = ref<{
} | null>(null);
const menuId = ref<string | null>(null);
const busy = ref(false);
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
const importMsg = ref('');
const counts = ref<Record<ActivityFilter, number>>({
today: 0,
@@ -391,6 +394,8 @@ function closePopovers() {
async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
@@ -405,11 +410,13 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
function onImportStart() {
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
@@ -433,6 +440,7 @@ function onImportFail(message: string) {
function onImportSettled() {
busy.value = false;
pageBusy.value = false;
}
watch(
@@ -473,6 +481,7 @@ onUnmounted(() => {
<template>
<section class="page" @click="closePopovers">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<nav class="crumbs" aria-label="مسیر">
<RouterLink :to="{ name: 'home' }">خانه</RouterLink>
<span>‹</span>
@@ -484,7 +493,7 @@ onUnmounted(() => {
lead="کارهای امروز، ارجاع به همکار و پیگیری وضعیت."
>
<template #actions>
<UiButton variant="ghost" type="button" :disabled="busy" @click.stop="exportExcel">
<UiButton variant="ghost" type="button" :disabled="busy" :loading="pageBusy" @click.stop="exportExcel">
<span class="btn-full">خروجی اکسل</span>
<span class="btn-short">خروجی</span>
</UiButton>
@@ -497,10 +506,12 @@ onUnmounted(() => {
@fail="onImportFail"
@settled="onImportSettled"
>
<UiButton variant="ghost" type="button" :disabled="busy">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
<template #default="{ loading }">
<UiButton variant="ghost" type="button" :disabled="busy" :loading="loading">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
</template>
</ExcelImportFlow>
<UiButton variant="primary" @click="activityModal = {}">
<UiIcon name="plus" :size="16" />
+19 -5
View File
@@ -8,6 +8,7 @@ import CustomerMoodFace from '@/components/CustomerMoodFace.vue';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import PhoneContactsImport from '@/components/PhoneContactsImport.vue';
import {
UiBusyOverlay,
UiButton,
UiDropdownMenu,
UiModal,
@@ -52,6 +53,8 @@ const moodFilter = computed<PersonMood | 'all'>(() => {
const q = ref(typeof route.query.q === 'string' ? route.query.q : '');
const loading = ref(false);
const busy = ref(false);
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
const error = ref('');
const importMsg = ref('');
const people = ref<PaginatedResponse<PersonDto> | null>(null);
@@ -208,6 +211,8 @@ async function setMoodFor(person: PersonDto, mood: PersonMood) {
async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
@@ -227,6 +232,7 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
@@ -239,6 +245,7 @@ const importPath = computed(() =>
function onImportStart() {
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
@@ -258,6 +265,8 @@ async function onImportDone(data: ImportContactsResult) {
function onPhoneImportStart() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال ورود مخاطبین گوشی…';
importMsg.value = '';
error.value = '';
}
@@ -279,6 +288,7 @@ function onPhoneImportFail(message: string) {
function onPhoneImportSettled() {
busy.value = false;
pageBusy.value = false;
}
function onImportFail(message: string) {
@@ -287,6 +297,7 @@ function onImportFail(message: string) {
function onImportSettled() {
busy.value = false;
pageBusy.value = false;
}
watch(
@@ -302,12 +313,13 @@ onMounted(load);
<template>
<section class="page" @click="closePopups">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<UiPageHeader
title="مخاطبین"
lead="مدیریت و مشاهده اشخاص و شرکت‌ها"
>
<template #actions>
<UiButton variant="ghost" size="sm" :disabled="busy" @click.stop="exportExcel">
<UiButton variant="ghost" size="sm" :disabled="busy" :loading="pageBusy && busyMessage.includes('خروجی')" @click.stop="exportExcel">
<span class="btn-full">خروجی اکسل</span>
<span class="btn-short">خروجی</span>
</UiButton>
@@ -320,10 +332,12 @@ onMounted(load);
@fail="onImportFail"
@settled="onImportSettled"
>
<UiButton variant="ghost" size="sm" :disabled="busy">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
<template #default="{ loading }">
<UiButton variant="ghost" size="sm" :disabled="busy" :loading="loading">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
</template>
</ExcelImportFlow>
<PhoneContactsImport
v-if="tab === 'people'"
+16
View File
@@ -262,13 +262,21 @@ onMounted(load);
<div><dt>تلفن</dt><dd dir="ltr">{{ lead.phone || '—' }}</dd></div>
<div><dt>شهر</dt><dd>{{ lead.city || '—' }}</dd></div>
<div><dt>منطقه</dt><dd>{{ lead.region || '—' }}</dd></div>
<div><dt>اینستاگرام</dt><dd dir="ltr">{{ lead.instagram || '—' }}</dd></div>
<div><dt>صنف</dt><dd>{{ lead.trade || '—' }}</dd></div>
<div><dt>منبع</dt><dd>{{ lead.source || '—' }}</dd></div>
<div><dt>وضعیت</dt><dd>{{ lead.stageName }}</dd></div>
<div><dt>کارشناس</dt><dd>{{ lead.assigneeName || '—' }}</dd></div>
<div><dt>تاریخ ثبت</dt><dd>{{ formatDate(lead.createdAt) }}</dd></div>
<div><dt>آخرین تماس</dt><dd>{{ formatDate(lead.lastContactAt) }}</dd></div>
<div><dt>پیگیری بعدی</dt><dd>{{ formatDate(lead.nextFollowUpAt) }}</dd></div>
<div><dt>روز در مرحله</dt><dd>{{ toFaDigits(lead.daysInStage) }}</dd></div>
<div v-if="lead.addresses?.length" class="full">
<dt>آدرس‌ها</dt>
<dd>
<p v-for="(addr, i) in lead.addresses" :key="i" class="addr-line">{{ addr }}</p>
</dd>
</div>
<div v-if="lead.notes" class="full">
<dt>یادداشت</dt>
<dd>{{ lead.notes }}</dd>
@@ -398,6 +406,14 @@ onMounted(load);
font-weight: 500;
}
.addr-line {
margin: 0 0 0.25rem;
}
.addr-line:last-child {
margin-bottom: 0;
}
.timeline {
list-style: none;
margin: 0;
+125 -6
View File
@@ -4,12 +4,14 @@ import { RouterLink, useRoute, useRouter } from 'vue-router';
import axios from 'axios';
import { api } from '@/lib/api';
import {
formatJalaliNumeric,
formatRelativeContact,
toFaDigits,
} from '@/lib/jalali';
import { useAuthStore } from '@/stores/auth';
import { canManageSettings } from '@/lib/roles';
import {
UiBusyOverlay,
UiButton,
UiDropdownMenu,
UiEmptyState,
@@ -102,6 +104,8 @@ const isAdmin = computed(() => canManageSettings(auth.user?.role));
const q = ref(typeof route.query.q === 'string' ? route.query.q : '');
const loading = ref(false);
const busy = ref(false);
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
const error = ref('');
const okMsg = ref('');
const data = ref<PaginatedResponse<LeadDto> | null>(null);
@@ -134,6 +138,8 @@ const createForm = ref({
city: '',
region: '',
source: '',
instagram: '',
addresses: [''] as string[],
stageId: '',
assigneeId: '',
});
@@ -638,6 +644,8 @@ function openCreate() {
city: '',
region: '',
source: '',
instagram: '',
addresses: [''],
stageId: stages.value[0]?.id ?? '',
assigneeId: '',
};
@@ -646,6 +654,18 @@ function openCreate() {
createOpen.value = true;
}
function addCreateAddress() {
createForm.value.addresses.push('');
}
function removeCreateAddress(index: number) {
if (createForm.value.addresses.length <= 1) {
createForm.value.addresses[0] = '';
return;
}
createForm.value.addresses.splice(index, 1);
}
function openEdit(lead: LeadDto) {
rowMenuId.value = null;
editingLeadId.value = lead.id;
@@ -657,6 +677,8 @@ function openEdit(lead: LeadDto) {
city: lead.city ?? '',
region: lead.region ?? '',
source: lead.source ?? '',
instagram: lead.instagram ?? '',
addresses: lead.addresses?.length ? [...lead.addresses] : [''],
stageId: lead.stageId,
assigneeId: lead.assigneeId ?? '',
};
@@ -803,6 +825,8 @@ async function submitCreate() {
city: createForm.value.city.trim() || null,
region: createForm.value.region.trim() || null,
source: createForm.value.source.trim() || null,
instagram: createForm.value.instagram.trim() || null,
addresses: createForm.value.addresses.map((a) => a.trim()).filter(Boolean),
stageId: createForm.value.stageId || undefined,
assigneeId: createForm.value.assigneeId || null,
};
@@ -890,6 +914,8 @@ async function archiveSelected() {
async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
error.value = '';
try {
const { data: blob } = await api.get<Blob>('/leads/export', {
@@ -905,6 +931,7 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
@@ -919,13 +946,19 @@ async function pollImport(jobId: string) {
try {
const { data: job } = await api.get<LeadImportJobDto>(`/leads/imports/${jobId}`);
importJob.value = job;
if (job.status === 'pending' || job.status === 'processing') {
pageBusy.value = true;
busyMessage.value = `در حال ورود لیدها… ${toFaDigits(job.processedCount)} از ${toFaDigits(job.totalCount || 0)}`;
}
if (job.status === 'done' || job.status === 'failed' || job.status === 'completed') {
stopImportPoll();
pageBusy.value = false;
okMsg.value = `ورود: موفق ${toFaDigits(job.successCount)} · تکراری ${toFaDigits(job.duplicateCount)} · خطا ${toFaDigits(job.errorCount)}`;
await load();
}
} catch {
stopImportPoll();
pageBusy.value = false;
error.value = 'پیگیری وضعیت ورود ناموفق بود.';
}
}
@@ -938,6 +971,7 @@ function startImportPoll(jobId: string) {
function onExcelImportStart() {
busy.value = true;
pageBusy.value = false;
okMsg.value = '';
error.value = '';
}
@@ -949,6 +983,8 @@ function onExcelImportDone(result: ImportContactsResult) {
return;
}
importJob.value = job;
pageBusy.value = true;
busyMessage.value = 'در حال ورود لیدها…';
startImportPoll(job.id);
}
@@ -962,6 +998,8 @@ function onExcelImportSettled() {
function onPhoneImportStart() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال ورود مخاطبین گوشی…';
okMsg.value = '';
error.value = '';
}
@@ -983,6 +1021,7 @@ function onPhoneImportFail(message: string) {
function onPhoneImportSettled() {
busy.value = false;
pageBusy.value = false;
}
function goDetail(id: string) {
@@ -1027,12 +1066,13 @@ onBeforeUnmount(() => {
<template>
<section class="page" @click="closePopups">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<UiPageHeader
title="لیدها"
lead="مدیریت و پیگیری تمام لیدهای ورودی"
>
<template #actions>
<UiButton variant="ghost" size="sm" :disabled="busy" @click.stop="exportExcel">
<UiButton variant="ghost" size="sm" :disabled="busy" :loading="pageBusy && busyMessage.includes('خروجی')" @click.stop="exportExcel">
<span class="btn-full">خروجی اکسل</span>
<span class="btn-short">خروجی</span>
</UiButton>
@@ -1045,10 +1085,12 @@ onBeforeUnmount(() => {
@fail="onExcelImportFail"
@settled="onExcelImportSettled"
>
<UiButton variant="ghost" size="sm" :disabled="busy">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
<template #default="{ loading }">
<UiButton variant="ghost" size="sm" :disabled="busy" :loading="loading">
<span class="btn-full">ورود از اکسل</span>
<span class="btn-short">ورود</span>
</UiButton>
</template>
</ExcelImportFlow>
<input
ref="logoFileInput"
@@ -1383,6 +1425,7 @@ onBeforeUnmount(() => {
<th>شماره تماس</th>
<th>شهر / منطقه</th>
<th>منبع لید</th>
<th>تاریخ ثبت</th>
<th>وضعیت</th>
<th>مسئول</th>
<th>آخرین فعالیت</th>
@@ -1454,6 +1497,7 @@ onBeforeUnmount(() => {
<span v-if="lead.source" class="source-pill">{{ lead.source }}</span>
<span v-else class="muted-dash">—</span>
</td>
<td class="date-col">{{ formatJalaliNumeric(new Date(lead.createdAt)) }}</td>
<td>
<span class="stage-pill" :data-tint="stageTintForLead(lead)">
{{ lead.stageName }}
@@ -1575,7 +1619,9 @@ onBeforeUnmount(() => {
@fail="onExcelImportFail"
@settled="onExcelImportSettled"
>
<UiButton variant="ghost" :disabled="busy">ورود از فایل</UiButton>
<template #default="{ loading }">
<UiButton variant="ghost" :disabled="busy" :loading="loading">ورود از فایل</UiButton>
</template>
</ExcelImportFlow>
</div>
</template>
@@ -1633,6 +1679,35 @@ onBeforeUnmount(() => {
منبع
<input v-model="createForm.source" placeholder="سایت، نمایشگاه…" />
</label>
<label>
پیج اینستاگرام
<input
v-model="createForm.instagram"
class="ltr"
dir="ltr"
placeholder="@username یا لینک"
/>
</label>
<div class="addresses">
<div class="addresses-head">
<span>آدرس‌ها</span>
<button type="button" class="add-addr" @click="addCreateAddress">+ افزودن آدرس</button>
</div>
<div v-for="(_, idx) in createForm.addresses" :key="idx" class="addr-row">
<input
v-model="createForm.addresses[idx]"
:placeholder="idx === 0 ? 'آدرس اصلی' : `آدرس ${idx + 1}`"
/>
<button
type="button"
class="rm-addr"
aria-label="حذف آدرس"
@click="removeCreateAddress(idx)"
>
×
</button>
</div>
</div>
<div class="create-grid">
<label>
وضعیت
@@ -2814,6 +2889,50 @@ button.m-line {
gap: 0.75rem;
}
.create-form .addresses {
display: grid;
gap: 0.45rem;
}
.create-form .addresses-head {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 0.86rem;
font-weight: 600;
}
.create-form .add-addr {
border: 0;
background: transparent;
color: var(--accent-deep, var(--accent));
font: inherit;
font-size: 0.75rem;
font-weight: 700;
cursor: pointer;
padding: 0;
}
.create-form .addr-row {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 0.45rem;
align-items: center;
}
.create-form .rm-addr {
width: 2rem;
height: 2rem;
border: 1px solid var(--line);
border-radius: var(--radius);
background: #fff;
color: var(--muted);
font: inherit;
font-size: 1.1rem;
line-height: 1;
cursor: pointer;
}
.create-form label {
display: grid;
gap: 0.35rem;
+90
View File
@@ -60,7 +60,9 @@ const phone = ref('');
const mobile = ref('');
const position = ref('');
const website = ref('');
const instagram = ref('');
const referrer = ref('');
const addresses = ref<string[]>(['']);
const notes = ref('');
const tagsRaw = ref('');
const companyId = ref('');
@@ -204,7 +206,9 @@ function fill(p: PersonDto) {
mobile.value = p.mobile ?? '';
position.value = p.position ?? '';
website.value = p.website ?? '';
instagram.value = p.instagram ?? '';
referrer.value = p.referrer ?? '';
addresses.value = p.addresses?.length ? [...p.addresses] : [''];
notes.value = p.notes ?? '';
tagsRaw.value = (p.tags ?? []).join('، ');
companyId.value = p.company?.id ?? '';
@@ -214,6 +218,18 @@ function fill(p: PersonDto) {
loyaltyTierName.value = p.loyaltyTier?.name ?? '';
}
function addAddress() {
addresses.value.push('');
}
function removeAddress(index: number) {
if (addresses.value.length <= 1) {
addresses.value[0] = '';
return;
}
addresses.value.splice(index, 1);
}
async function load() {
loading.value = true;
error.value = '';
@@ -253,7 +269,9 @@ function payload(): CreatePersonRequest {
mobile: mobile.value || undefined,
position: position.value || undefined,
website: website.value || undefined,
instagram: instagram.value || undefined,
referrer: referrer.value || undefined,
addresses: addresses.value.map((a) => a.trim()).filter(Boolean),
notes: notes.value || undefined,
tags: parseTags(tagsRaw.value),
companyId: companyId.value || null,
@@ -446,10 +464,31 @@ onMounted(load);
<UiInput id="website" v-model="website" dir="ltr" placeholder="https://example.com" />
</UiField>
<UiField label="پیج اینستاگرام" for-id="instagram">
<UiInput id="instagram" v-model="instagram" dir="ltr" placeholder="@username یا لینک" />
</UiField>
<UiField label="معرف" for-id="referrer">
<UiInput id="referrer" v-model="referrer" placeholder="نام معرف" />
</UiField>
<div class="crm-col-span-full addresses">
<div class="addresses-head">
<span>آدرس‌ها</span>
<button type="button" class="add-addr" @click="addAddress">+ افزودن آدرس</button>
</div>
<div v-for="(_, idx) in addresses" :key="idx" class="addr-row">
<UiInput
:id="`address-${idx}`"
v-model="addresses[idx]"
:placeholder="idx === 0 ? 'آدرس اصلی' : `آدرس ${idx + 1}`"
/>
<button type="button" class="rm-addr" aria-label="حذف آدرس" @click="removeAddress(idx)">
×
</button>
</div>
</div>
<div class="crm-col-span-full">
<UiField label="وضعیت مشتری">
<div class="moods">
@@ -550,6 +589,57 @@ onMounted(load);
margin-bottom: var(--sp-3);
}
.addresses {
display: grid;
gap: var(--sp-2);
}
.addresses-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-2);
font-size: var(--fs-sm);
font-weight: var(--fw-semibold);
color: var(--ink);
}
.add-addr {
border: 0;
background: transparent;
color: var(--accent-deep);
font: inherit;
font-size: var(--fs-xs);
font-weight: var(--fw-bold);
cursor: pointer;
padding: 0;
}
.addr-row {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: var(--sp-2);
align-items: center;
}
.rm-addr {
width: 2rem;
height: 2rem;
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--surface);
color: var(--muted);
font: inherit;
font-size: 1.1rem;
line-height: 1;
cursor: pointer;
}
.rm-addr:hover {
color: #b91c1c;
border-color: #fecaca;
}
.moods {
display: flex;
flex-wrap: wrap;
+40
View File
@@ -341,7 +341,9 @@ const infoEmpty = computed(() => {
!p.email &&
!p.position &&
!p.website &&
!p.instagram &&
!p.referrer &&
!(p.addresses?.length) &&
!p.company &&
!externalCode.value &&
!p.notes?.trim() &&
@@ -630,7 +632,17 @@ watch(() => route.query.tab, readTab, { immediate: true });
<div><dt>سمت</dt><dd>{{ person.position || '—' }}</dd></div>
<div><dt>کد مبدأ</dt><dd dir="ltr">{{ externalCode ? toFaDigits(externalCode) : '—' }}</dd></div>
<div><dt>وب‌سایت</dt><dd>{{ person.website || '—' }}</dd></div>
<div><dt>اینستاگرام</dt><dd dir="ltr">{{ person.instagram || '—' }}</dd></div>
<div><dt>معرف</dt><dd>{{ person.referrer || '—' }}</dd></div>
<div class="wide">
<dt>آدرس‌ها</dt>
<dd>
<template v-if="person.addresses?.length">
<p v-for="(addr, i) in person.addresses" :key="i" class="addr-line">{{ addr }}</p>
</template>
<template v-else>—</template>
</dd>
</div>
<div><dt>شرکت</dt><dd>{{ person.company?.name || '—' }}</dd></div>
<div><dt>تلفن</dt><dd>{{ phoneDisplay }}</dd></div>
<div><dt>ایمیل</dt><dd>{{ emailDisplay }}</dd></div>
@@ -906,9 +918,20 @@ watch(() => route.query.tab, readTab, { immediate: true });
<div><dt>سمت</dt><dd>{{ person.position || '—' }}</dd></div>
<div><dt>کد مبدأ</dt><dd dir="ltr">{{ externalCode ? toFaDigits(externalCode) : '—' }}</dd></div>
<div><dt>وب‌سایت</dt><dd>{{ person.website || '—' }}</dd></div>
<div><dt>اینستاگرام</dt><dd dir="ltr">{{ person.instagram || '—' }}</dd></div>
<div><dt>معرف</dt><dd>{{ person.referrer || '—' }}</dd></div>
<div class="wide">
<dt>آدرس‌ها</dt>
<dd>
<template v-if="person.addresses?.length">
<p v-for="(addr, i) in person.addresses" :key="i" class="addr-line">{{ addr }}</p>
</template>
<template v-else>—</template>
</dd>
</div>
<div><dt>شرکت</dt><dd>{{ person.company?.name || '—' }}</dd></div>
<div><dt>مسئول</dt><dd>{{ person.owner?.fullName || '—' }}</dd></div>
<div><dt>تاریخ ثبت</dt><dd>{{ registeredAt }}</dd></div>
<div>
<dt>باشگاه</dt>
<dd>
@@ -1176,6 +1199,23 @@ watch(() => route.query.tab, readTab, { immediate: true });
overflow-wrap: anywhere;
}
.facts .wide,
.info-panel .wide {
grid-template-columns: 5.6rem minmax(0, 1fr);
}
.info-panel .wide {
grid-template-columns: 7.5rem 1fr;
}
.addr-line {
margin: 0 0 0.25rem;
}
.addr-line:last-child {
margin-bottom: 0;
}
.status {
display: inline-flex;
align-items: center;
+10
View File
@@ -17,6 +17,7 @@ import {
updateDealStage,
} from '@/lib/pipeline-board';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import UiBusyOverlay from '@/components/ui/UiBusyOverlay.vue';
import UiButton from '@/components/ui/UiButton.vue';
import UiInput from '@/components/ui/UiInput.vue';
import UiModal from '@/components/ui/UiModal.vue';
@@ -400,8 +401,13 @@ function onOpenDeal(dealId: string) {
void router.push({ name: 'deal-detail', params: { id: dealId } });
}
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
@@ -416,11 +422,13 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
function onImportStart() {
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
@@ -448,6 +456,7 @@ function onImportFail(message: string) {
function onImportSettled() {
busy.value = false;
pageBusy.value = false;
}
function onMenuDeal(dealId: string) {
@@ -478,6 +487,7 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
<template>
<section class="page" dir="rtl">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<PipelineToolbar
pipeline-name="کاریز فروش"
:pipeline-options="pipelineOptions"
+13 -2
View File
@@ -7,6 +7,7 @@ import { formatClockFa, formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import { formatMoney } from '@/lib/money';
import {
UiBadge,
UiBusyOverlay,
UiButton,
UiDropdownMenu,
UiEmptyState,
@@ -42,6 +43,8 @@ const sortOpen = ref(false);
const moreOpen = ref(false);
const productModal = ref(false);
const busy = ref(false);
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
const importMsg = ref('');
const categories = computed(() => {
@@ -168,6 +171,8 @@ async function load() {
async function exportExcel() {
closeMenus();
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
@@ -185,12 +190,14 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
function onImportStart() {
closeMenus();
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
@@ -214,6 +221,7 @@ function onImportFail(message: string) {
function onImportSettled() {
busy.value = false;
pageBusy.value = false;
}
async function toggleActive(product: ProductDto) {
@@ -250,12 +258,13 @@ onMounted(load);
<template>
<section class="crm-page" @click="closeMenus">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<UiPageHeader
title="محصولات"
lead="مدیریت محصولات، قیمت‌ها و موجودی"
>
<template #actions>
<UiButton variant="ghost" type="button" :disabled="busy" @click="exportExcel">
<UiButton variant="ghost" type="button" :disabled="busy" :loading="pageBusy" @click="exportExcel">
خروجی اکسل
</UiButton>
<ExcelImportFlow
@@ -267,7 +276,9 @@ onMounted(load);
@fail="onImportFail"
@settled="onImportSettled"
>
<UiButton variant="ghost" type="button" :disabled="busy">ورود از اکسل</UiButton>
<template #default="{ loading }">
<UiButton variant="ghost" type="button" :disabled="busy" :loading="loading">ورود از اکسل</UiButton>
</template>
</ExcelImportFlow>
<UiButton variant="primary" @click="productModal = true">
<UiIcon name="plus" :size="16" />
+10
View File
@@ -18,6 +18,7 @@ import {
updateDealStage,
} from '@/lib/pipeline-board';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import UiBusyOverlay from '@/components/ui/UiBusyOverlay.vue';
import UiButton from '@/components/ui/UiButton.vue';
import UiInput from '@/components/ui/UiInput.vue';
import UiModal from '@/components/ui/UiModal.vue';
@@ -379,8 +380,13 @@ function onOpenCard(cardId: string) {
void router.push({ name: 'project-card-detail', params: { id: cardId } });
}
const pageBusy = ref(false);
const busyMessage = ref('لطفاً صبر کنید…');
async function exportExcel() {
busy.value = true;
pageBusy.value = true;
busyMessage.value = 'در حال تهیه خروجی اکسل…';
importMsg.value = '';
error.value = '';
try {
@@ -397,11 +403,13 @@ async function exportExcel() {
error.value = 'خروجی اکسل ناموفق بود.';
} finally {
busy.value = false;
pageBusy.value = false;
}
}
function onImportStart() {
busy.value = true;
pageBusy.value = false;
importMsg.value = '';
error.value = '';
}
@@ -429,6 +437,7 @@ function onImportFail(message: string) {
function onImportSettled() {
busy.value = false;
pageBusy.value = false;
}
function onMenuCard(cardId: string) {
@@ -457,6 +466,7 @@ onBeforeUnmount(() => {
<template>
<section class="page" dir="rtl">
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<PipelineToolbar
pipeline-name="کاریز پروژه — کارهای تیمی"
icon="grid"
+17
View File
@@ -700,7 +700,9 @@ export interface PersonDto {
mobile: string | null;
position: string | null;
website: string | null;
instagram: string | null;
referrer: string | null;
addresses: string[];
notes: string | null;
mood: PersonMood;
tags: string[];
@@ -721,13 +723,17 @@ export interface CreatePersonRequest {
mobile?: string;
position?: string;
website?: string;
instagram?: string;
referrer?: string;
addresses?: string[];
notes?: string;
mood?: PersonMood;
tags?: string[];
companyId?: string | null;
customFields?: Record<string, unknown>;
ownerId?: string | null;
/** فقط برای ایمپورت اکسل — تاریخ ثبت مبدأ */
registeredAt?: string | null;
}
export type UpdatePersonRequest = Partial<CreatePersonRequest>;
@@ -3802,6 +3808,8 @@ export interface LeadDto {
phone: string | null;
city: string | null;
region: string | null;
instagram: string | null;
addresses: string[];
trade: string | null;
source: string | null;
notes: string | null;
@@ -3838,6 +3846,8 @@ export interface CreateLeadRequest {
phone?: string | null;
city?: string | null;
region?: string | null;
instagram?: string | null;
addresses?: string[];
trade?: string | null;
source?: string | null;
notes?: string | null;
@@ -3845,6 +3855,8 @@ export interface CreateLeadRequest {
stageId?: string;
assigneeId?: string | null;
nextFollowUpAt?: string | null;
/** فقط برای ایمپورت اکسل — تاریخ ثبت مبدأ */
registeredAt?: string | null;
}
export interface UpdateLeadRequest {
@@ -3854,6 +3866,8 @@ export interface UpdateLeadRequest {
phone?: string | null;
city?: string | null;
region?: string | null;
instagram?: string | null;
addresses?: string[];
trade?: string | null;
source?: string | null;
notes?: string | null;
@@ -3943,6 +3957,9 @@ export interface LeadImportRow {
phone?: string;
city?: string;
region?: string;
address?: string;
instagram?: string;
registeredAt?: string;
trade?: string;
source?: string;
notes?: string;