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