Add optional activity experience on leads and people with form mapping and filters.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Lead" ADD COLUMN "activityExperience" TEXT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Person" ADD COLUMN "activityExperience" TEXT;
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Lead_organizationId_activityExperience_idx" ON "Lead"("organizationId", "activityExperience");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Person_organizationId_activityExperience_idx" ON "Person"("organizationId", "activityExperience");
|
||||||
@@ -656,6 +656,8 @@ model Person {
|
|||||||
birthDate DateTime?
|
birthDate DateTime?
|
||||||
/// نام معرف
|
/// نام معرف
|
||||||
referrer String?
|
referrer String?
|
||||||
|
/// سابقه فعالیت (ندارم | 1 الی 2 سال | 2 الی 5 سال | بیش از 5 سال)
|
||||||
|
activityExperience String?
|
||||||
/// لیست آدرسها (JSON array of strings)
|
/// لیست آدرسها (JSON array of strings)
|
||||||
addresses Json @default("[]")
|
addresses Json @default("[]")
|
||||||
notes String?
|
notes String?
|
||||||
@@ -710,6 +712,7 @@ model Person {
|
|||||||
@@index([ownerId])
|
@@index([ownerId])
|
||||||
@@index([loyaltyTierId])
|
@@index([loyaltyTierId])
|
||||||
@@index([organizationId, discLabel])
|
@@index([organizationId, discLabel])
|
||||||
|
@@index([organizationId, activityExperience])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Pipeline {
|
model Pipeline {
|
||||||
@@ -3158,6 +3161,8 @@ model Lead {
|
|||||||
/// صنف
|
/// صنف
|
||||||
trade String?
|
trade String?
|
||||||
source String?
|
source String?
|
||||||
|
/// سابقه فعالیت (ندارم | 1 الی 2 سال | 2 الی 5 سال | بیش از 5 سال)
|
||||||
|
activityExperience String?
|
||||||
notes String?
|
notes String?
|
||||||
/// لوگوی فروشگاه / شرکت
|
/// لوگوی فروشگاه / شرکت
|
||||||
logoStorageKey String?
|
logoStorageKey String?
|
||||||
@@ -3195,6 +3200,7 @@ model Lead {
|
|||||||
@@index([organizationId, city])
|
@@index([organizationId, city])
|
||||||
@@index([organizationId, trade])
|
@@index([organizationId, trade])
|
||||||
@@index([organizationId, source])
|
@@index([organizationId, source])
|
||||||
|
@@index([organizationId, activityExperience])
|
||||||
}
|
}
|
||||||
|
|
||||||
model LeadEvent {
|
model LeadEvent {
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ export class ListQueryDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@MaxLength(2000)
|
@MaxLength(2000)
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
|
||||||
|
/** فیلتر سابقه فعالیت؛ چندتایی با کاما */
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(400)
|
||||||
|
activityExperience?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompanyExtraFieldsDto {
|
class CompanyExtraFieldsDto {
|
||||||
@@ -360,6 +366,11 @@ export class CreatePersonDto {
|
|||||||
@MaxLength(120)
|
@MaxLength(120)
|
||||||
referrer?: string;
|
referrer?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(80)
|
||||||
|
activityExperience?: string | null;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsString({ each: true })
|
@IsString({ each: true })
|
||||||
@@ -486,6 +497,11 @@ export class UpdatePersonDto {
|
|||||||
@MaxLength(120)
|
@MaxLength(120)
|
||||||
referrer?: string;
|
referrer?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(80)
|
||||||
|
activityExperience?: string | null;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsString({ each: true })
|
@IsString({ each: true })
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ export class PeopleController {
|
|||||||
hasMobile,
|
hasMobile,
|
||||||
disc: query.disc,
|
disc: query.disc,
|
||||||
groupId: query.groupId,
|
groupId: query.groupId,
|
||||||
|
activityExperience: query.activityExperience,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,7 @@ export class PeopleController {
|
|||||||
hasMobile,
|
hasMobile,
|
||||||
disc: query.disc,
|
disc: query.disc,
|
||||||
groupId: query.groupId,
|
groupId: query.groupId,
|
||||||
|
activityExperience: query.activityExperience,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
PERSON_MOODS,
|
PERSON_MOODS,
|
||||||
applyPersonGenderTitle,
|
applyPersonGenderTitle,
|
||||||
canViewAllRecords,
|
canViewAllRecords,
|
||||||
|
normalizeActivityExperience,
|
||||||
splitPersonHonorific,
|
splitPersonHonorific,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
@@ -102,6 +103,7 @@ type PersonRow = {
|
|||||||
instagram: string | null;
|
instagram: string | null;
|
||||||
birthDate: Date | null;
|
birthDate: Date | null;
|
||||||
referrer: string | null;
|
referrer: string | null;
|
||||||
|
activityExperience: string | null;
|
||||||
addresses: unknown;
|
addresses: unknown;
|
||||||
notes: string | null;
|
notes: string | null;
|
||||||
mood: PersonMood;
|
mood: PersonMood;
|
||||||
@@ -174,6 +176,7 @@ export class PeopleService implements OnModuleInit {
|
|||||||
hasMobile?: boolean;
|
hasMobile?: boolean;
|
||||||
disc?: string;
|
disc?: string;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
activityExperience?: string;
|
||||||
},
|
},
|
||||||
): Prisma.PersonWhereInput {
|
): Prisma.PersonWhereInput {
|
||||||
const sources = [...new Set(splitCsv(opts?.importSource).map(normalizePersonImportSource))];
|
const sources = [...new Set(splitCsv(opts?.importSource).map(normalizePersonImportSource))];
|
||||||
@@ -181,6 +184,7 @@ export class PeopleService implements OnModuleInit {
|
|||||||
(PERSON_MOODS as readonly string[]).includes(m),
|
(PERSON_MOODS as readonly string[]).includes(m),
|
||||||
);
|
);
|
||||||
const groupIds = splitCsv(opts?.groupId);
|
const groupIds = splitCsv(opts?.groupId);
|
||||||
|
const experiences = splitCsv(opts?.activityExperience);
|
||||||
const search = buildSearchWhere<Prisma.PersonWhereInput>(q, (t) => [
|
const search = buildSearchWhere<Prisma.PersonWhereInput>(q, (t) => [
|
||||||
{ firstName: ci(t) },
|
{ firstName: ci(t) },
|
||||||
{ lastName: ci(t) },
|
{ lastName: ci(t) },
|
||||||
@@ -231,6 +235,9 @@ export class PeopleService implements OnModuleInit {
|
|||||||
if (sources.length) {
|
if (sources.length) {
|
||||||
facets.push({ importSource: { in: sources } });
|
facets.push({ importSource: { in: sources } });
|
||||||
}
|
}
|
||||||
|
if (experiences.length) {
|
||||||
|
facets.push({ activityExperience: { in: experiences } });
|
||||||
|
}
|
||||||
if (facets.length === 1) and.push(facets[0]!);
|
if (facets.length === 1) and.push(facets[0]!);
|
||||||
else if (facets.length > 1) and.push({ OR: facets });
|
else if (facets.length > 1) and.push({ OR: facets });
|
||||||
return {
|
return {
|
||||||
@@ -258,6 +265,7 @@ export class PeopleService implements OnModuleInit {
|
|||||||
hasMobile?: boolean;
|
hasMobile?: boolean;
|
||||||
disc?: string;
|
disc?: string;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
activityExperience?: string;
|
||||||
},
|
},
|
||||||
): Promise<PaginatedResponse<PersonDto>> {
|
): Promise<PaginatedResponse<PersonDto>> {
|
||||||
const seeDisc = await this.behaviorAccess.canView(actor);
|
const seeDisc = await this.behaviorAccess.canView(actor);
|
||||||
@@ -296,6 +304,7 @@ export class PeopleService implements OnModuleInit {
|
|||||||
hasMobile?: boolean;
|
hasMobile?: boolean;
|
||||||
disc?: string;
|
disc?: string;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
activityExperience?: string;
|
||||||
},
|
},
|
||||||
max = FILTERED_IDS_MAX,
|
max = FILTERED_IDS_MAX,
|
||||||
): Promise<FilteredIdsResponse> {
|
): Promise<FilteredIdsResponse> {
|
||||||
@@ -475,6 +484,9 @@ export class PeopleService implements OnModuleInit {
|
|||||||
instagram: emptyToNull(dto.instagram),
|
instagram: emptyToNull(dto.instagram),
|
||||||
birthDate: parseBirthDate(dto.birthDate),
|
birthDate: parseBirthDate(dto.birthDate),
|
||||||
referrer: emptyToNull(dto.referrer),
|
referrer: emptyToNull(dto.referrer),
|
||||||
|
activityExperience:
|
||||||
|
normalizeActivityExperience(dto.activityExperience) ??
|
||||||
|
emptyToNull(dto.activityExperience),
|
||||||
addresses: toJsonAddresses(dto.addresses),
|
addresses: toJsonAddresses(dto.addresses),
|
||||||
notes: emptyToNull(dto.notes),
|
notes: emptyToNull(dto.notes),
|
||||||
mood: dto.mood ?? 'newcomer',
|
mood: dto.mood ?? 'newcomer',
|
||||||
@@ -587,6 +599,11 @@ export class PeopleService implements OnModuleInit {
|
|||||||
if ('instagram' in dto) data.instagram = emptyToNull(dto.instagram);
|
if ('instagram' in dto) data.instagram = emptyToNull(dto.instagram);
|
||||||
if ('birthDate' in dto) data.birthDate = parseBirthDate(dto.birthDate);
|
if ('birthDate' in dto) data.birthDate = parseBirthDate(dto.birthDate);
|
||||||
if ('referrer' in dto) data.referrer = emptyToNull(dto.referrer);
|
if ('referrer' in dto) data.referrer = emptyToNull(dto.referrer);
|
||||||
|
if ('activityExperience' in dto) {
|
||||||
|
data.activityExperience =
|
||||||
|
normalizeActivityExperience(dto.activityExperience) ??
|
||||||
|
emptyToNull(dto.activityExperience);
|
||||||
|
}
|
||||||
if ('addresses' in dto) data.addresses = toJsonAddresses(dto.addresses);
|
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;
|
||||||
@@ -1022,6 +1039,7 @@ export class PeopleService implements OnModuleInit {
|
|||||||
instagram: row.instagram,
|
instagram: row.instagram,
|
||||||
birthDate: row.birthDate?.toISOString() ?? null,
|
birthDate: row.birthDate?.toISOString() ?? null,
|
||||||
referrer: row.referrer,
|
referrer: row.referrer,
|
||||||
|
activityExperience: row.activityExperience,
|
||||||
addresses: (() => {
|
addresses: (() => {
|
||||||
const fromCol = asAddresses(row.addresses);
|
const fromCol = asAddresses(row.addresses);
|
||||||
if (fromCol.length) return fromCol;
|
if (fromCol.length) return fromCol;
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ const MAP_TO = [
|
|||||||
'lead.city',
|
'lead.city',
|
||||||
'lead.region',
|
'lead.region',
|
||||||
'lead.trade',
|
'lead.trade',
|
||||||
|
'lead.activityExperience',
|
||||||
'lead.notes',
|
'lead.notes',
|
||||||
'lead.source',
|
'lead.source',
|
||||||
'lead.gender',
|
'lead.gender',
|
||||||
|
'person.activityExperience',
|
||||||
'person.gender',
|
'person.gender',
|
||||||
'notes',
|
'notes',
|
||||||
'custom',
|
'custom',
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ import type {
|
|||||||
SubmitLeadFormResponse,
|
SubmitLeadFormResponse,
|
||||||
UpdateLeadFormRequest,
|
UpdateLeadFormRequest,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { isGenderQuestionLabel, parsePersonGenderAnswer } from '@mento/shared';
|
import {
|
||||||
|
isActivityExperienceLabel,
|
||||||
|
isGenderQuestionLabel,
|
||||||
|
normalizeActivityExperience,
|
||||||
|
parsePersonGenderAnswer,
|
||||||
|
} from '@mento/shared';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { LocalFileStorage } from '../storage/local-file.storage';
|
import { LocalFileStorage } from '../storage/local-file.storage';
|
||||||
@@ -569,6 +574,9 @@ export class LeadFormsService {
|
|||||||
region: emptyToNull(mapped.region) ?? existingLead.region,
|
region: emptyToNull(mapped.region) ?? existingLead.region,
|
||||||
trade: emptyToNull(mapped.trade) ?? existingLead.trade,
|
trade: emptyToNull(mapped.trade) ?? existingLead.trade,
|
||||||
source: source ?? existingLead.source,
|
source: source ?? existingLead.source,
|
||||||
|
activityExperience:
|
||||||
|
emptyToNull(mapped.activityExperience) ??
|
||||||
|
existingLead.activityExperience,
|
||||||
notes: emptyToNull(mapped.notes) ?? existingLead.notes,
|
notes: emptyToNull(mapped.notes) ?? existingLead.notes,
|
||||||
...(mapped.gender ? { gender: mapped.gender } : {}),
|
...(mapped.gender ? { gender: mapped.gender } : {}),
|
||||||
assigneeId: existingLead.assigneeId ?? assigneeId,
|
assigneeId: existingLead.assigneeId ?? assigneeId,
|
||||||
@@ -620,6 +628,7 @@ export class LeadFormsService {
|
|||||||
region: emptyToNull(mapped.region),
|
region: emptyToNull(mapped.region),
|
||||||
trade: emptyToNull(mapped.trade),
|
trade: emptyToNull(mapped.trade),
|
||||||
source,
|
source,
|
||||||
|
activityExperience: emptyToNull(mapped.activityExperience),
|
||||||
notes: emptyToNull(mapped.notes),
|
notes: emptyToNull(mapped.notes),
|
||||||
gender: mapped.gender ?? 'none',
|
gender: mapped.gender ?? 'none',
|
||||||
stageId,
|
stageId,
|
||||||
@@ -684,6 +693,8 @@ export class LeadFormsService {
|
|||||||
phone: phone ?? existing.phone,
|
phone: phone ?? existing.phone,
|
||||||
position: emptyToNull(mapped.position) ?? existing.position,
|
position: emptyToNull(mapped.position) ?? existing.position,
|
||||||
notes: emptyToNull(mapped.notes) ?? existing.notes,
|
notes: emptyToNull(mapped.notes) ?? existing.notes,
|
||||||
|
activityExperience:
|
||||||
|
emptyToNull(mapped.activityExperience) ?? existing.activityExperience,
|
||||||
...(mapped.gender ? { gender: mapped.gender } : {}),
|
...(mapped.gender ? { gender: mapped.gender } : {}),
|
||||||
ownerId: existing.ownerId ?? ownerId,
|
ownerId: existing.ownerId ?? ownerId,
|
||||||
},
|
},
|
||||||
@@ -701,6 +712,7 @@ export class LeadFormsService {
|
|||||||
phone,
|
phone,
|
||||||
position: emptyToNull(mapped.position),
|
position: emptyToNull(mapped.position),
|
||||||
notes: emptyToNull(mapped.notes),
|
notes: emptyToNull(mapped.notes),
|
||||||
|
activityExperience: emptyToNull(mapped.activityExperience),
|
||||||
gender: mapped.gender ?? 'none',
|
gender: mapped.gender ?? 'none',
|
||||||
ownerId,
|
ownerId,
|
||||||
},
|
},
|
||||||
@@ -964,6 +976,7 @@ type MappedValues = {
|
|||||||
city?: string;
|
city?: string;
|
||||||
region?: string;
|
region?: string;
|
||||||
trade?: string;
|
trade?: string;
|
||||||
|
activityExperience?: string;
|
||||||
leadSource?: string;
|
leadSource?: string;
|
||||||
gender?: 'male' | 'female' | 'none';
|
gender?: 'male' | 'female' | 'none';
|
||||||
};
|
};
|
||||||
@@ -995,6 +1008,15 @@ function mapValues(
|
|||||||
if (gender) mapped.gender = gender;
|
if (gender) mapped.gender = gender;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
field.mapTo === 'lead.activityExperience' ||
|
||||||
|
field.mapTo === 'person.activityExperience' ||
|
||||||
|
isActivityExperienceLabel(field.label)
|
||||||
|
) {
|
||||||
|
mapped.activityExperience =
|
||||||
|
normalizeActivityExperience(raw) ?? raw;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (field.mapTo) {
|
switch (field.mapTo) {
|
||||||
case 'person.fullName': {
|
case 'person.fullName': {
|
||||||
const parts = raw.split(/\s+/).filter(Boolean);
|
const parts = raw.split(/\s+/).filter(Boolean);
|
||||||
@@ -1048,6 +1070,11 @@ function mapValues(
|
|||||||
case 'lead.trade':
|
case 'lead.trade':
|
||||||
mapped.trade = raw;
|
mapped.trade = raw;
|
||||||
break;
|
break;
|
||||||
|
case 'lead.activityExperience':
|
||||||
|
case 'person.activityExperience':
|
||||||
|
mapped.activityExperience =
|
||||||
|
normalizeActivityExperience(raw) ?? raw;
|
||||||
|
break;
|
||||||
case 'lead.notes':
|
case 'lead.notes':
|
||||||
mapped.notes = raw;
|
mapped.notes = raw;
|
||||||
break;
|
break;
|
||||||
@@ -1118,7 +1145,9 @@ function collectExtras(
|
|||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.fieldType === 'heading' || field.mapTo !== 'custom') continue;
|
if (field.fieldType === 'heading' || field.mapTo !== 'custom') continue;
|
||||||
const raw = (values?.[field.key] ?? '').toString().trim();
|
const raw = (values?.[field.key] ?? '').toString().trim();
|
||||||
if (!raw || (isGenderQuestionLabel(field.label) && parsePersonGenderAnswer(raw))) continue;
|
if (!raw) continue;
|
||||||
|
if (isGenderQuestionLabel(field.label) && parsePersonGenderAnswer(raw)) continue;
|
||||||
|
if (isActivityExperienceLabel(field.label)) continue;
|
||||||
lines.push(`${field.label}: ${raw}`);
|
lines.push(`${field.label}: ${raw}`);
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export class CreateLeadDto {
|
|||||||
@IsOptional() @IsArray() @IsString({ each: true }) addresses?: 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() activityExperience?: string | null;
|
||||||
@IsOptional() @IsString() notes?: string;
|
@IsOptional() @IsString() notes?: string;
|
||||||
@IsOptional() @IsNumber() estimatedValue?: number;
|
@IsOptional() @IsNumber() estimatedValue?: number;
|
||||||
@IsOptional() @IsString() stageId?: string;
|
@IsOptional() @IsString() stageId?: string;
|
||||||
@@ -60,6 +61,7 @@ export class UpdateLeadDto {
|
|||||||
@IsOptional() @IsArray() @IsString({ each: true }) addresses?: string[];
|
@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() activityExperience?: string | null;
|
||||||
@IsOptional() @IsString() notes?: string | null;
|
@IsOptional() @IsString() notes?: string | null;
|
||||||
@IsOptional() @IsNumber() estimatedValue?: number | null;
|
@IsOptional() @IsNumber() estimatedValue?: number | null;
|
||||||
@IsOptional() @IsString() stageId?: string;
|
@IsOptional() @IsString() stageId?: string;
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ export class LeadsController {
|
|||||||
@Query('region') region?: string,
|
@Query('region') region?: string,
|
||||||
@Query('trade') trade?: string,
|
@Query('trade') trade?: string,
|
||||||
@Query('source') source?: string,
|
@Query('source') source?: string,
|
||||||
|
@Query('activityExperience') activityExperience?: string,
|
||||||
@Query('unassigned') unassigned?: string,
|
@Query('unassigned') unassigned?: string,
|
||||||
@Query('archived') archived?: string,
|
@Query('archived') archived?: string,
|
||||||
@Query('converted') converted?: string,
|
@Query('converted') converted?: string,
|
||||||
@@ -265,6 +266,7 @@ export class LeadsController {
|
|||||||
region,
|
region,
|
||||||
trade,
|
trade,
|
||||||
source,
|
source,
|
||||||
|
activityExperience,
|
||||||
unassigned: unassigned === '1' || unassigned === 'true',
|
unassigned: unassigned === '1' || unassigned === 'true',
|
||||||
archived: archived === '1' || archived === 'true',
|
archived: archived === '1' || archived === 'true',
|
||||||
converted: converted === '1' || converted === 'true',
|
converted: converted === '1' || converted === 'true',
|
||||||
@@ -287,6 +289,7 @@ export class LeadsController {
|
|||||||
@Query('region') region?: string,
|
@Query('region') region?: string,
|
||||||
@Query('trade') trade?: string,
|
@Query('trade') trade?: string,
|
||||||
@Query('source') source?: string,
|
@Query('source') source?: string,
|
||||||
|
@Query('activityExperience') activityExperience?: string,
|
||||||
@Query('unassigned') unassigned?: string,
|
@Query('unassigned') unassigned?: string,
|
||||||
@Query('archived') archived?: string,
|
@Query('archived') archived?: string,
|
||||||
@Query('converted') converted?: string,
|
@Query('converted') converted?: string,
|
||||||
@@ -306,6 +309,7 @@ export class LeadsController {
|
|||||||
region,
|
region,
|
||||||
trade,
|
trade,
|
||||||
source,
|
source,
|
||||||
|
activityExperience,
|
||||||
unassigned: unassigned === '1' || unassigned === 'true',
|
unassigned: unassigned === '1' || unassigned === 'true',
|
||||||
archived: archived === '1' || archived === 'true',
|
archived: archived === '1' || archived === 'true',
|
||||||
converted: converted === '1' || converted === 'true',
|
converted: converted === '1' || converted === 'true',
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ import type {
|
|||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { FILTERED_IDS_MAX } from '@mento/shared';
|
import { FILTERED_IDS_MAX } from '@mento/shared';
|
||||||
import { applyLeadGenderName, applyPersonGenderTitle } from '@mento/shared';
|
import {
|
||||||
|
applyLeadGenderName,
|
||||||
|
applyPersonGenderTitle,
|
||||||
|
normalizeActivityExperience,
|
||||||
|
} from '@mento/shared';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { SmsGatewayService } from '../sms-billing/sms-gateway.service';
|
import { SmsGatewayService } from '../sms-billing/sms-gateway.service';
|
||||||
import { renderSmsText } from '../common/sms-text';
|
import { renderSmsText } from '../common/sms-text';
|
||||||
@@ -119,6 +123,7 @@ const boardLeadSelect = {
|
|||||||
birthDate: true,
|
birthDate: true,
|
||||||
trade: true,
|
trade: true,
|
||||||
source: true,
|
source: true,
|
||||||
|
activityExperience: true,
|
||||||
logoStorageKey: true,
|
logoStorageKey: true,
|
||||||
estimatedValue: true,
|
estimatedValue: true,
|
||||||
stageId: true,
|
stageId: true,
|
||||||
@@ -177,6 +182,7 @@ export class LeadsService {
|
|||||||
region?: string;
|
region?: string;
|
||||||
trade?: string;
|
trade?: string;
|
||||||
source?: string;
|
source?: string;
|
||||||
|
activityExperience?: string;
|
||||||
unassigned?: boolean;
|
unassigned?: boolean;
|
||||||
archived?: boolean;
|
archived?: boolean;
|
||||||
converted?: boolean;
|
converted?: boolean;
|
||||||
@@ -196,6 +202,7 @@ export class LeadsService {
|
|||||||
{ trade: ci(t) },
|
{ trade: ci(t) },
|
||||||
{ instagram: ci(t) },
|
{ instagram: ci(t) },
|
||||||
{ source: ci(t) },
|
{ source: ci(t) },
|
||||||
|
{ activityExperience: ci(t) },
|
||||||
]);
|
]);
|
||||||
const and: Prisma.LeadWhereInput[] = [];
|
const and: Prisma.LeadWhereInput[] = [];
|
||||||
if (search) and.push(search);
|
if (search) and.push(search);
|
||||||
@@ -222,6 +229,9 @@ export class LeadsService {
|
|||||||
...(opts.source
|
...(opts.source
|
||||||
? { source: { contains: opts.source, mode: 'insensitive' } }
|
? { source: { contains: opts.source, mode: 'insensitive' } }
|
||||||
: {}),
|
: {}),
|
||||||
|
...(opts.activityExperience
|
||||||
|
? { activityExperience: opts.activityExperience }
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
...(opts.unassigned ? [{ assigneeId: null }] : []),
|
...(opts.unassigned ? [{ assigneeId: null }] : []),
|
||||||
...(opts.assigneeId && !opts.unassigned ? [{ assigneeId: opts.assigneeId }] : []),
|
...(opts.assigneeId && !opts.unassigned ? [{ assigneeId: opts.assigneeId }] : []),
|
||||||
@@ -288,6 +298,7 @@ export class LeadsService {
|
|||||||
region?: string;
|
region?: string;
|
||||||
trade?: string;
|
trade?: string;
|
||||||
source?: string;
|
source?: string;
|
||||||
|
activityExperience?: string;
|
||||||
unassigned?: boolean;
|
unassigned?: boolean;
|
||||||
archived?: boolean;
|
archived?: boolean;
|
||||||
converted?: boolean;
|
converted?: boolean;
|
||||||
@@ -341,6 +352,7 @@ export class LeadsService {
|
|||||||
region?: string;
|
region?: string;
|
||||||
trade?: string;
|
trade?: string;
|
||||||
source?: string;
|
source?: string;
|
||||||
|
activityExperience?: string;
|
||||||
unassigned?: boolean;
|
unassigned?: boolean;
|
||||||
archived?: boolean;
|
archived?: boolean;
|
||||||
converted?: boolean;
|
converted?: boolean;
|
||||||
@@ -492,6 +504,7 @@ export class LeadsService {
|
|||||||
addresses?: string[];
|
addresses?: string[];
|
||||||
trade?: string | null;
|
trade?: string | null;
|
||||||
source?: string | null;
|
source?: string | null;
|
||||||
|
activityExperience?: string | null;
|
||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
estimatedValue?: number | null;
|
estimatedValue?: number | null;
|
||||||
stageId?: string;
|
stageId?: string;
|
||||||
@@ -553,6 +566,9 @@ export class LeadsService {
|
|||||||
addresses: toJsonAddresses(dto.addresses),
|
addresses: toJsonAddresses(dto.addresses),
|
||||||
trade: emptyToNull(dto.trade),
|
trade: emptyToNull(dto.trade),
|
||||||
source: emptyToNull(dto.source),
|
source: emptyToNull(dto.source),
|
||||||
|
activityExperience:
|
||||||
|
normalizeActivityExperience(dto.activityExperience) ??
|
||||||
|
emptyToNull(dto.activityExperience),
|
||||||
notes: emptyToNull(dto.notes),
|
notes: emptyToNull(dto.notes),
|
||||||
estimatedValue:
|
estimatedValue:
|
||||||
dto.estimatedValue != null
|
dto.estimatedValue != null
|
||||||
@@ -684,6 +700,13 @@ export class LeadsService {
|
|||||||
...(dto.source !== undefined
|
...(dto.source !== undefined
|
||||||
? { source: emptyToNull(dto.source as string) }
|
? { source: emptyToNull(dto.source as string) }
|
||||||
: {}),
|
: {}),
|
||||||
|
...(dto.activityExperience !== undefined
|
||||||
|
? {
|
||||||
|
activityExperience:
|
||||||
|
normalizeActivityExperience(dto.activityExperience as string | null) ??
|
||||||
|
emptyToNull(dto.activityExperience as string),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
...(dto.notes !== undefined
|
...(dto.notes !== undefined
|
||||||
? { notes: emptyToNull(dto.notes as string) }
|
? { notes: emptyToNull(dto.notes as string) }
|
||||||
: {}),
|
: {}),
|
||||||
@@ -1194,6 +1217,7 @@ export class LeadsService {
|
|||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join('\n'),
|
.join('\n'),
|
||||||
|
activityExperience: lead.activityExperience,
|
||||||
ownerId: lead.assigneeId ?? actor.userId,
|
ownerId: lead.assigneeId ?? actor.userId,
|
||||||
createdAt: lead.createdAt,
|
createdAt: lead.createdAt,
|
||||||
importSource: 'lead_form',
|
importSource: 'lead_form',
|
||||||
@@ -1201,11 +1225,23 @@ export class LeadsService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
createdPerson = true;
|
createdPerson = true;
|
||||||
} else if (!person.birthDate && lead.birthDate) {
|
} else {
|
||||||
await this.prisma.person.update({
|
const personPatch: {
|
||||||
where: { id: person.id },
|
birthDate?: Date | null;
|
||||||
data: { birthDate: lead.birthDate },
|
activityExperience?: string | null;
|
||||||
});
|
} = {};
|
||||||
|
if (!person.birthDate && lead.birthDate) {
|
||||||
|
personPatch.birthDate = lead.birthDate;
|
||||||
|
}
|
||||||
|
if (!person.activityExperience && lead.activityExperience) {
|
||||||
|
personPatch.activityExperience = lead.activityExperience;
|
||||||
|
}
|
||||||
|
if (Object.keys(personPatch).length) {
|
||||||
|
await this.prisma.person.update({
|
||||||
|
where: { id: person.id },
|
||||||
|
data: personPatch,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedStage = await this.prisma.leadStage.findFirst({
|
const convertedStage = await this.prisma.leadStage.findFirst({
|
||||||
@@ -1626,6 +1662,7 @@ export class LeadsService {
|
|||||||
addresses: asAddresses(row.addresses),
|
addresses: asAddresses(row.addresses),
|
||||||
trade: row.trade,
|
trade: row.trade,
|
||||||
source: row.source,
|
source: row.source,
|
||||||
|
activityExperience: row.activityExperience,
|
||||||
notes: row.notes,
|
notes: row.notes,
|
||||||
estimatedValue:
|
estimatedValue:
|
||||||
row.estimatedValue != null ? Number(row.estimatedValue) : null,
|
row.estimatedValue != null ? Number(row.estimatedValue) : null,
|
||||||
@@ -1668,6 +1705,7 @@ export class LeadsService {
|
|||||||
addresses: [],
|
addresses: [],
|
||||||
trade: row.trade,
|
trade: row.trade,
|
||||||
source: row.source,
|
source: row.source,
|
||||||
|
activityExperience: row.activityExperience,
|
||||||
notes: null,
|
notes: null,
|
||||||
estimatedValue:
|
estimatedValue:
|
||||||
row.estimatedValue != null ? Number(row.estimatedValue) : null,
|
row.estimatedValue != null ? Number(row.estimatedValue) : null,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||||
import type { CustomerGroupDto, PersonImportSourceStatDto, PersonMood } from '@mento/shared';
|
import type { CustomerGroupDto, PersonImportSourceStatDto, PersonMood } from '@mento/shared';
|
||||||
|
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
|
||||||
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
||||||
import { groupSwatch } from '@/lib/customer-groups';
|
import { groupSwatch } from '@/lib/customer-groups';
|
||||||
import { toFaDigits } from '@/lib/jalali';
|
import { toFaDigits } from '@/lib/jalali';
|
||||||
@@ -12,6 +13,7 @@ export type ContactsFilterValue = {
|
|||||||
sources: string[];
|
sources: string[];
|
||||||
moods: PersonMood[];
|
moods: PersonMood[];
|
||||||
disc: string;
|
disc: string;
|
||||||
|
activityExperiences: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -33,7 +35,13 @@ const emit = defineEmits<{
|
|||||||
close: [];
|
close: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const draft = reactive<ContactsFilterValue>({ groups: [], sources: [], moods: [], disc: '' });
|
const draft = reactive<ContactsFilterValue>({
|
||||||
|
groups: [],
|
||||||
|
sources: [],
|
||||||
|
moods: [],
|
||||||
|
disc: '',
|
||||||
|
activityExperiences: [],
|
||||||
|
});
|
||||||
const draftSort = ref('');
|
const draftSort = ref('');
|
||||||
const groupQuery = ref('');
|
const groupQuery = ref('');
|
||||||
const GROUP_SEARCH_MIN = 8;
|
const GROUP_SEARCH_MIN = 8;
|
||||||
@@ -50,6 +58,7 @@ watch(
|
|||||||
draft.sources = [...props.value.sources];
|
draft.sources = [...props.value.sources];
|
||||||
draft.moods = [...props.value.moods];
|
draft.moods = [...props.value.moods];
|
||||||
draft.disc = props.value.disc;
|
draft.disc = props.value.disc;
|
||||||
|
draft.activityExperiences = [...(props.value.activityExperiences ?? [])];
|
||||||
draftSort.value = props.sort ?? defaultSort.value;
|
draftSort.value = props.sort ?? defaultSort.value;
|
||||||
groupQuery.value = '';
|
groupQuery.value = '';
|
||||||
},
|
},
|
||||||
@@ -77,7 +86,12 @@ const filteredGroups = computed(() => {
|
|||||||
const draftCount = computed(
|
const draftCount = computed(
|
||||||
() =>
|
() =>
|
||||||
draft.groups.length +
|
draft.groups.length +
|
||||||
(isPeople.value ? draft.sources.length + draft.moods.length + (draft.disc ? 1 : 0) : 0) +
|
(isPeople.value
|
||||||
|
? draft.sources.length +
|
||||||
|
draft.moods.length +
|
||||||
|
draft.activityExperiences.length +
|
||||||
|
(draft.disc ? 1 : 0)
|
||||||
|
: 0) +
|
||||||
(hasSort.value && draftSort.value !== defaultSort.value ? 1 : 0),
|
(hasSort.value && draftSort.value !== defaultSort.value ? 1 : 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,6 +106,7 @@ function clearAll() {
|
|||||||
draft.sources = [];
|
draft.sources = [];
|
||||||
draft.moods = [];
|
draft.moods = [];
|
||||||
draft.disc = '';
|
draft.disc = '';
|
||||||
|
draft.activityExperiences = [];
|
||||||
if (hasSort.value) draftSort.value = defaultSort.value;
|
if (hasSort.value) draftSort.value = defaultSort.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +118,7 @@ function apply() {
|
|||||||
sources: [...draft.sources],
|
sources: [...draft.sources],
|
||||||
moods: [...draft.moods],
|
moods: [...draft.moods],
|
||||||
disc: draft.disc,
|
disc: draft.disc,
|
||||||
|
activityExperiences: [...draft.activityExperiences],
|
||||||
},
|
},
|
||||||
hasSort.value ? draftSort.value : undefined,
|
hasSort.value ? draftSort.value : undefined,
|
||||||
);
|
);
|
||||||
@@ -210,6 +226,27 @@ function apply() {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="sec">
|
||||||
|
<h4>
|
||||||
|
سابقه فعالیت
|
||||||
|
<span v-if="draft.activityExperiences.length" class="sel">
|
||||||
|
{{ toFaDigits(draft.activityExperiences.length) }} انتخاب
|
||||||
|
</span>
|
||||||
|
</h4>
|
||||||
|
<div class="pills">
|
||||||
|
<button
|
||||||
|
v-for="item in ACTIVITY_EXPERIENCE_OPTIONS"
|
||||||
|
:key="item"
|
||||||
|
type="button"
|
||||||
|
class="pill"
|
||||||
|
:class="{ on: draft.activityExperiences.includes(item) }"
|
||||||
|
@click="toggle(draft.activityExperiences, item)"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section v-if="canBehavior" class="sec">
|
<section v-if="canBehavior" class="sec">
|
||||||
<h4>تیپ DISC</h4>
|
<h4>تیپ DISC</h4>
|
||||||
<div class="pills">
|
<div class="pills">
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ export function isBirthDateAnswer(label: string): boolean {
|
|||||||
return label.trim() === 'تاریخ تولد';
|
return label.trim() === 'تاریخ تولد';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** فیلد سابقه فعالیت روی خود لید/مشتری هست؛ جواب فرم نباید دوباره ردیف بسازد. */
|
||||||
|
export function isActivityExperienceAnswer(label: string): boolean {
|
||||||
|
const text = label.trim().replace(/ي/g, 'ی').replace(/ك/g, 'ک');
|
||||||
|
return /سابقه\s*فعالیت/.test(text);
|
||||||
|
}
|
||||||
|
|
||||||
function parseAnswerLine(line: string): LeadNoteRow | null {
|
function parseAnswerLine(line: string): LeadNoteRow | null {
|
||||||
const splitAt = line.indexOf(':');
|
const splitAt = line.indexOf(':');
|
||||||
if (splitAt <= 0 || splitAt > 200) return null;
|
if (splitAt <= 0 || splitAt > 200) return null;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ const discFilter = computed(() => {
|
|||||||
return /^[DISC](\/[DISC]){0,3}$/.test(value) ? value : '';
|
return /^[DISC](\/[DISC]){0,3}$/.test(value) ? value : '';
|
||||||
});
|
});
|
||||||
const sourceFilters = computed(() => queryList('source'));
|
const sourceFilters = computed(() => queryList('source'));
|
||||||
|
const activityExperienceFilters = computed(() => queryList('activityExperience'));
|
||||||
const groupFilters = computed(() => queryList('group'));
|
const groupFilters = computed(() => queryList('group'));
|
||||||
const { groups: customerGroups, load: loadCustomerGroups } = useCustomerGroups();
|
const { groups: customerGroups, load: loadCustomerGroups } = useCustomerGroups();
|
||||||
/** گروههای فیلتر — با شمارش scoped بر اساس دسترسی کاربر */
|
/** گروههای فیلتر — با شمارش scoped بر اساس دسترسی کاربر */
|
||||||
@@ -93,9 +94,15 @@ const filterValue = computed<ContactsFilterValue>(() => ({
|
|||||||
sources: sourceFilters.value,
|
sources: sourceFilters.value,
|
||||||
moods: moodFilters.value,
|
moods: moodFilters.value,
|
||||||
disc: discFilter.value,
|
disc: discFilter.value,
|
||||||
|
activityExperiences: activityExperienceFilters.value,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
type FilterTag = { kind: 'group' | 'source' | 'mood' | 'disc'; value: string; label: string; color?: string };
|
type FilterTag = {
|
||||||
|
kind: 'group' | 'source' | 'mood' | 'disc' | 'activityExperience';
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
color?: string;
|
||||||
|
};
|
||||||
const activeTags = computed<FilterTag[]>(() => {
|
const activeTags = computed<FilterTag[]>(() => {
|
||||||
const tags: FilterTag[] = groupFilters.value.map((id) => {
|
const tags: FilterTag[] = groupFilters.value.map((id) => {
|
||||||
const g =
|
const g =
|
||||||
@@ -110,6 +117,9 @@ const activeTags = computed<FilterTag[]>(() => {
|
|||||||
for (const m of moodFilters.value) {
|
for (const m of moodFilters.value) {
|
||||||
tags.push({ kind: 'mood', value: m, label: moodLabel(m) });
|
tags.push({ kind: 'mood', value: m, label: moodLabel(m) });
|
||||||
}
|
}
|
||||||
|
for (const exp of activityExperienceFilters.value) {
|
||||||
|
tags.push({ kind: 'activityExperience', value: exp, label: `سابقه: ${exp}` });
|
||||||
|
}
|
||||||
if (discFilter.value) tags.push({ kind: 'disc', value: discFilter.value, label: `DISC: ${discFilter.value}` });
|
if (discFilter.value) tags.push({ kind: 'disc', value: discFilter.value, label: `DISC: ${discFilter.value}` });
|
||||||
return tags;
|
return tags;
|
||||||
});
|
});
|
||||||
@@ -208,6 +218,8 @@ const peopleSavedFilters = computed(() => {
|
|||||||
if (mood) out.mood = mood;
|
if (mood) out.mood = mood;
|
||||||
const source = csv(sourceFilters.value);
|
const source = csv(sourceFilters.value);
|
||||||
if (source) out.source = source;
|
if (source) out.source = source;
|
||||||
|
const activityExperience = csv(activityExperienceFilters.value);
|
||||||
|
if (activityExperience) out.activityExperience = activityExperience;
|
||||||
if (discFilter.value) out.disc = discFilter.value;
|
if (discFilter.value) out.disc = discFilter.value;
|
||||||
const group = csv(groupFilters.value);
|
const group = csv(groupFilters.value);
|
||||||
if (group) out.group = group;
|
if (group) out.group = group;
|
||||||
@@ -230,7 +242,7 @@ function applyPeopleSavedFilters(filters: Record<string, unknown>) {
|
|||||||
// کلیدهای فیلتر را از نو میسازیم تا فیلتر قبلی روی صفحه نماند
|
// کلیدهای فیلتر را از نو میسازیم تا فیلتر قبلی روی صفحه نماند
|
||||||
const query: Record<string, string | string[]> = {};
|
const query: Record<string, string | string[]> = {};
|
||||||
for (const [key, value] of Object.entries(route.query)) {
|
for (const [key, value] of Object.entries(route.query)) {
|
||||||
if (['q', 'sort', 'mood', 'source', 'disc', 'group', 'page', 'tab'].includes(key)) continue;
|
if (['q', 'sort', 'mood', 'source', 'activityExperience', 'disc', 'group', 'page', 'tab'].includes(key)) continue;
|
||||||
if (value == null || value === '') continue;
|
if (value == null || value === '') continue;
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
const list = value.filter((v): v is string => typeof v === 'string' && v !== '');
|
const list = value.filter((v): v is string => typeof v === 'string' && v !== '');
|
||||||
@@ -245,6 +257,8 @@ function applyPeopleSavedFilters(filters: Record<string, unknown>) {
|
|||||||
if (mood) query.mood = mood;
|
if (mood) query.mood = mood;
|
||||||
const source = savedCsv(filters.source);
|
const source = savedCsv(filters.source);
|
||||||
if (source) query.source = source;
|
if (source) query.source = source;
|
||||||
|
const activityExperience = savedCsv(filters.activityExperience);
|
||||||
|
if (activityExperience) query.activityExperience = activityExperience;
|
||||||
const disc = savedCsv(filters.disc);
|
const disc = savedCsv(filters.disc);
|
||||||
if (disc) query.disc = disc;
|
if (disc) query.disc = disc;
|
||||||
const group = savedCsv(filters.group);
|
const group = savedCsv(filters.group);
|
||||||
@@ -317,6 +331,7 @@ async function load() {
|
|||||||
sort: sort.value,
|
sort: sort.value,
|
||||||
mood: csv(moodFilters.value),
|
mood: csv(moodFilters.value),
|
||||||
importSource: csv(sourceFilters.value),
|
importSource: csv(sourceFilters.value),
|
||||||
|
activityExperience: csv(activityExperienceFilters.value),
|
||||||
disc: discFilter.value || undefined,
|
disc: discFilter.value || undefined,
|
||||||
groupId: csv(groupFilters.value),
|
groupId: csv(groupFilters.value),
|
||||||
},
|
},
|
||||||
@@ -391,7 +406,12 @@ function applyFilters(next: ContactsFilterValue, nextSort?: string) {
|
|||||||
patchQuery({
|
patchQuery({
|
||||||
group: csv(next.groups),
|
group: csv(next.groups),
|
||||||
...(people
|
...(people
|
||||||
? { source: csv(next.sources), mood: csv(next.moods), disc: next.disc || undefined }
|
? {
|
||||||
|
source: csv(next.sources),
|
||||||
|
mood: csv(next.moods),
|
||||||
|
activityExperience: csv(next.activityExperiences),
|
||||||
|
disc: next.disc || undefined,
|
||||||
|
}
|
||||||
: {}),
|
: {}),
|
||||||
// در موبایل مرتبسازی داخل همان شیت فیلتر است؛ یک patch تا query قبلی overwrite نشود
|
// در موبایل مرتبسازی داخل همان شیت فیلتر است؛ یک patch تا query قبلی overwrite نشود
|
||||||
...(nextSort !== undefined
|
...(nextSort !== undefined
|
||||||
@@ -421,13 +441,25 @@ function removeTag(tag: FilterTag) {
|
|||||||
if (tag.kind === 'group') patchQuery({ group: without(groupFilters.value), page: undefined });
|
if (tag.kind === 'group') patchQuery({ group: without(groupFilters.value), page: undefined });
|
||||||
else if (tag.kind === 'source') patchQuery({ source: without(sourceFilters.value), page: undefined });
|
else if (tag.kind === 'source') patchQuery({ source: without(sourceFilters.value), page: undefined });
|
||||||
else if (tag.kind === 'mood') patchQuery({ mood: without(moodFilters.value), page: undefined });
|
else if (tag.kind === 'mood') patchQuery({ mood: without(moodFilters.value), page: undefined });
|
||||||
else patchQuery({ disc: undefined, page: undefined });
|
else if (tag.kind === 'activityExperience') {
|
||||||
|
patchQuery({
|
||||||
|
activityExperience: without(activityExperienceFilters.value),
|
||||||
|
page: undefined,
|
||||||
|
});
|
||||||
|
} else patchQuery({ disc: undefined, page: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearFilters() {
|
function clearFilters() {
|
||||||
patchQuery({
|
patchQuery({
|
||||||
group: undefined,
|
group: undefined,
|
||||||
...(tab.value === 'people' ? { source: undefined, mood: undefined, disc: undefined } : {}),
|
...(tab.value === 'people'
|
||||||
|
? {
|
||||||
|
source: undefined,
|
||||||
|
mood: undefined,
|
||||||
|
activityExperience: undefined,
|
||||||
|
disc: undefined,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
page: undefined,
|
page: undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -923,6 +955,7 @@ onMounted(load);
|
|||||||
<th>شرکت</th>
|
<th>شرکت</th>
|
||||||
<th>تلفن</th>
|
<th>تلفن</th>
|
||||||
<th>ایمیل</th>
|
<th>ایمیل</th>
|
||||||
|
<th>سابقه فعالیت</th>
|
||||||
<th>تاریخ ثبت</th>
|
<th>تاریخ ثبت</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -978,6 +1011,7 @@ onMounted(load);
|
|||||||
<UiIcon v-if="p.email" name="mail" :size="14" />
|
<UiIcon v-if="p.email" name="mail" :size="14" />
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{ p.activityExperience || '—' }}</td>
|
||||||
<td>{{ formatDate(p.createdAt) }}</td>
|
<td>{{ formatDate(p.createdAt) }}</td>
|
||||||
<td class="ops" @click.stop>
|
<td class="ops" @click.stop>
|
||||||
<UiDropdownMenu
|
<UiDropdownMenu
|
||||||
|
|||||||
@@ -46,7 +46,13 @@ import {
|
|||||||
UserAddOutlined,
|
UserAddOutlined,
|
||||||
} from '@ant-design/icons-vue';
|
} from '@ant-design/icons-vue';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import { isBirthDateAnswer, leadNoteFileIsImage, parseLeadFormNotes } from '@/lib/lead-form-notes';
|
import {
|
||||||
|
isActivityExperienceAnswer,
|
||||||
|
isBirthDateAnswer,
|
||||||
|
leadNoteFileIsImage,
|
||||||
|
parseLeadFormNotes,
|
||||||
|
} from '@/lib/lead-form-notes';
|
||||||
|
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
|
||||||
import {
|
import {
|
||||||
formatClockFa,
|
formatClockFa,
|
||||||
formatJalaliNumeric,
|
formatJalaliNumeric,
|
||||||
@@ -140,9 +146,15 @@ const editForm = ref({
|
|||||||
instagram: '',
|
instagram: '',
|
||||||
birthDate: '',
|
birthDate: '',
|
||||||
trade: '',
|
trade: '',
|
||||||
|
activityExperience: '' as string,
|
||||||
notes: '',
|
notes: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const activityExperienceOptions = [
|
||||||
|
{ value: '', label: '—' },
|
||||||
|
...ACTIVITY_EXPERIENCE_OPTIONS.map((value) => ({ value, label: value })),
|
||||||
|
];
|
||||||
|
|
||||||
function formatDate(value: string | null | undefined) {
|
function formatDate(value: string | null | undefined) {
|
||||||
if (!value) return '—';
|
if (!value) return '—';
|
||||||
try {
|
try {
|
||||||
@@ -160,8 +172,18 @@ const shownBirthDate = computed(() => {
|
|||||||
if (lead.value?.birthDate) return formatDate(lead.value.birthDate);
|
if (lead.value?.birthDate) return formatDate(lead.value.birthDate);
|
||||||
return formBirthDate.value || '—';
|
return formBirthDate.value || '—';
|
||||||
});
|
});
|
||||||
|
const formActivityExperience = computed(
|
||||||
|
() =>
|
||||||
|
noteView.value.rows.find((row) => isActivityExperienceAnswer(row.label) && !row.file)?.text ??
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
const shownActivityExperience = computed(
|
||||||
|
() => lead.value?.activityExperience || formActivityExperience.value || '—',
|
||||||
|
);
|
||||||
const answerRows = computed(() =>
|
const answerRows = computed(() =>
|
||||||
noteView.value.rows.filter((row) => !isBirthDateAnswer(row.label)),
|
noteView.value.rows.filter(
|
||||||
|
(row) => !isBirthDateAnswer(row.label) && !isActivityExperienceAnswer(row.label),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const genderOptions = PERSON_GENDERS.map((key) => ({
|
const genderOptions = PERSON_GENDERS.map((key) => ({
|
||||||
@@ -246,6 +268,7 @@ function startEdit() {
|
|||||||
? formatLocalDateInput(new Date(lead.value.birthDate))
|
? formatLocalDateInput(new Date(lead.value.birthDate))
|
||||||
: '',
|
: '',
|
||||||
trade: lead.value.trade ?? '',
|
trade: lead.value.trade ?? '',
|
||||||
|
activityExperience: lead.value.activityExperience ?? '',
|
||||||
notes: lead.value.notes ?? '',
|
notes: lead.value.notes ?? '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -272,6 +295,7 @@ async function saveEdit() {
|
|||||||
instagram: editForm.value.instagram.trim() || null,
|
instagram: editForm.value.instagram.trim() || null,
|
||||||
birthDate: editForm.value.birthDate || null,
|
birthDate: editForm.value.birthDate || null,
|
||||||
trade: editForm.value.trade.trim() || null,
|
trade: editForm.value.trade.trim() || null,
|
||||||
|
activityExperience: editForm.value.activityExperience.trim() || null,
|
||||||
notes: editForm.value.notes.trim() || null,
|
notes: editForm.value.notes.trim() || null,
|
||||||
});
|
});
|
||||||
okMsg.value = 'لید ویرایش شد.';
|
okMsg.value = 'لید ویرایش شد.';
|
||||||
@@ -710,6 +734,17 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
|||||||
<a-input v-model:value="editForm.trade" style="width: 100%" />
|
<a-input v-model:value="editForm.trade" style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<a-col :xs="24" :sm="12" :md="8">
|
||||||
|
<a-form-item label="سابقه فعالیت">
|
||||||
|
<a-select
|
||||||
|
v-model:value="editForm.activityExperience"
|
||||||
|
allow-clear
|
||||||
|
placeholder="اختیاری"
|
||||||
|
style="width: 100%"
|
||||||
|
:options="activityExperienceOptions"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item label="یادداشت">
|
<a-form-item label="یادداشت">
|
||||||
<a-textarea
|
<a-textarea
|
||||||
@@ -782,6 +817,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
|||||||
<span dir="ltr">{{ lead.instagram || '—' }}</span>
|
<span dir="ltr">{{ lead.instagram || '—' }}</span>
|
||||||
</a-descriptions-item>
|
</a-descriptions-item>
|
||||||
<a-descriptions-item label="صنف">{{ lead.trade || '—' }}</a-descriptions-item>
|
<a-descriptions-item label="صنف">{{ lead.trade || '—' }}</a-descriptions-item>
|
||||||
|
<a-descriptions-item label="سابقه فعالیت">
|
||||||
|
{{ shownActivityExperience }}
|
||||||
|
</a-descriptions-item>
|
||||||
<a-descriptions-item label="منبع">
|
<a-descriptions-item label="منبع">
|
||||||
{{ lead.source || '—' }}
|
{{ lead.source || '—' }}
|
||||||
</a-descriptions-item>
|
</a-descriptions-item>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import type {
|
|||||||
OrgUserDto,
|
OrgUserDto,
|
||||||
PipelineDto,
|
PipelineDto,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
|
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
|
||||||
import { toFaDigits } from '@/lib/jalali';
|
import { toFaDigits } from '@/lib/jalali';
|
||||||
import { prepareFormCover } from '@/lib/form-cover';
|
import { prepareFormCover } from '@/lib/form-cover';
|
||||||
import { useEscClose } from '@/lib/modal-stack';
|
import { useEscClose } from '@/lib/modal-stack';
|
||||||
@@ -96,6 +97,12 @@ const readyGroups = [
|
|||||||
{ label: 'شهر', fieldType: 'text' as const, mapTo: 'lead.city' as const },
|
{ label: 'شهر', fieldType: 'text' as const, mapTo: 'lead.city' as const },
|
||||||
{ label: 'منطقه', fieldType: 'text' as const, mapTo: 'lead.region' as const },
|
{ label: 'منطقه', fieldType: 'text' as const, mapTo: 'lead.region' as const },
|
||||||
{ label: 'صنف', fieldType: 'text' as const, mapTo: 'lead.trade' as const },
|
{ label: 'صنف', fieldType: 'text' as const, mapTo: 'lead.trade' as const },
|
||||||
|
{
|
||||||
|
label: 'سابقه فعالیت',
|
||||||
|
fieldType: 'select' as const,
|
||||||
|
mapTo: 'lead.activityExperience' as const,
|
||||||
|
options: [...ACTIVITY_EXPERIENCE_OPTIONS],
|
||||||
|
},
|
||||||
{ label: 'توضیحات', fieldType: 'textarea' as const, mapTo: 'lead.notes' as const },
|
{ label: 'توضیحات', fieldType: 'textarea' as const, mapTo: 'lead.notes' as const },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -105,6 +112,12 @@ const readyGroups = [
|
|||||||
{ label: 'نام و نام خانوادگی', fieldType: 'text' as const, mapTo: 'person.fullName' as const },
|
{ label: 'نام و نام خانوادگی', fieldType: 'text' as const, mapTo: 'person.fullName' as const },
|
||||||
{ label: 'ایمیل', fieldType: 'email' as const, mapTo: 'person.email' as const },
|
{ label: 'ایمیل', fieldType: 'email' as const, mapTo: 'person.email' as const },
|
||||||
{ label: 'موبایل', fieldType: 'phone' as const, mapTo: 'person.mobile' as const },
|
{ label: 'موبایل', fieldType: 'phone' as const, mapTo: 'person.mobile' as const },
|
||||||
|
{
|
||||||
|
label: 'سابقه فعالیت',
|
||||||
|
fieldType: 'select' as const,
|
||||||
|
mapTo: 'person.activityExperience' as const,
|
||||||
|
options: [...ACTIVITY_EXPERIENCE_OPTIONS],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -995,6 +1008,7 @@ onMounted(load);
|
|||||||
<option value="lead.city">شهر</option>
|
<option value="lead.city">شهر</option>
|
||||||
<option value="lead.region">منطقه</option>
|
<option value="lead.region">منطقه</option>
|
||||||
<option value="lead.trade">صنف</option>
|
<option value="lead.trade">صنف</option>
|
||||||
|
<option value="lead.activityExperience">سابقه فعالیت</option>
|
||||||
<option value="lead.notes">یادداشت لید</option>
|
<option value="lead.notes">یادداشت لید</option>
|
||||||
<option value="lead.source">منبع لید</option>
|
<option value="lead.source">منبع لید</option>
|
||||||
<option value="lead.gender">جنسیت</option>
|
<option value="lead.gender">جنسیت</option>
|
||||||
@@ -1007,6 +1021,7 @@ onMounted(load);
|
|||||||
<option value="person.email">ایمیل</option>
|
<option value="person.email">ایمیل</option>
|
||||||
<option value="person.phone">تلفن</option>
|
<option value="person.phone">تلفن</option>
|
||||||
<option value="person.position">سمت</option>
|
<option value="person.position">سمت</option>
|
||||||
|
<option value="person.activityExperience">سابقه فعالیت</option>
|
||||||
<option value="person.gender">جنسیت شخص</option>
|
<option value="person.gender">جنسیت شخص</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<optgroup label="معامله">
|
<optgroup label="معامله">
|
||||||
|
|||||||
@@ -84,7 +84,13 @@ import type {
|
|||||||
PersonGender,
|
PersonGender,
|
||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
import { brand, PERSON_GENDERS, PERSON_GENDER_LABELS, splitPersonHonorific } from '@mento/shared';
|
import {
|
||||||
|
ACTIVITY_EXPERIENCE_OPTIONS,
|
||||||
|
brand,
|
||||||
|
PERSON_GENDERS,
|
||||||
|
PERSON_GENDER_LABELS,
|
||||||
|
splitPersonHonorific,
|
||||||
|
} from '@mento/shared';
|
||||||
|
|
||||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||||
Typography;
|
Typography;
|
||||||
@@ -158,6 +164,7 @@ const LEAD_COL_LABELS = [
|
|||||||
'شماره تماس',
|
'شماره تماس',
|
||||||
'شهر / منطقه',
|
'شهر / منطقه',
|
||||||
'منبع لید',
|
'منبع لید',
|
||||||
|
'سابقه فعالیت',
|
||||||
'تاریخ ثبت',
|
'تاریخ ثبت',
|
||||||
'وضعیت',
|
'وضعیت',
|
||||||
'مسئول',
|
'مسئول',
|
||||||
@@ -226,6 +233,9 @@ const regionFilter = computed(() =>
|
|||||||
const tradeFilter = computed(() =>
|
const tradeFilter = computed(() =>
|
||||||
typeof route.query.trade === 'string' ? route.query.trade : '',
|
typeof route.query.trade === 'string' ? route.query.trade : '',
|
||||||
);
|
);
|
||||||
|
const activityExperienceFilter = computed(() =>
|
||||||
|
typeof route.query.activityExperience === 'string' ? route.query.activityExperience : '',
|
||||||
|
);
|
||||||
const sourceFilter = computed(() =>
|
const sourceFilter = computed(() =>
|
||||||
typeof route.query.source === 'string' ? route.query.source : '',
|
typeof route.query.source === 'string' ? route.query.source : '',
|
||||||
);
|
);
|
||||||
@@ -270,6 +280,7 @@ const mobileFilterBadgeCount = computed(() =>
|
|||||||
cityFilter.value,
|
cityFilter.value,
|
||||||
regionFilter.value,
|
regionFilter.value,
|
||||||
tradeFilter.value,
|
tradeFilter.value,
|
||||||
|
activityExperienceFilter.value,
|
||||||
sourceFilter.value,
|
sourceFilter.value,
|
||||||
createdFromFilter.value,
|
createdFromFilter.value,
|
||||||
createdToFilter.value,
|
createdToFilter.value,
|
||||||
@@ -283,7 +294,15 @@ const filterBtnLabel = computed(() =>
|
|||||||
: 'فیلتر',
|
: 'فیلتر',
|
||||||
);
|
);
|
||||||
|
|
||||||
type LeadFacetKey = 'assignee' | 'stage' | 'source' | 'followUp' | 'city' | 'region' | 'trade';
|
type LeadFacetKey =
|
||||||
|
| 'assignee'
|
||||||
|
| 'stage'
|
||||||
|
| 'source'
|
||||||
|
| 'followUp'
|
||||||
|
| 'city'
|
||||||
|
| 'region'
|
||||||
|
| 'trade'
|
||||||
|
| 'activityExperience';
|
||||||
const filterSection = ref<LeadFacetKey | 'createdFrom' | 'createdTo' | 'converted' | 'archived' | null>(
|
const filterSection = ref<LeadFacetKey | 'createdFrom' | 'createdTo' | 'converted' | 'archived' | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
@@ -468,6 +487,18 @@ const textFacets = computed(() => [
|
|||||||
...tradeOptions.value.map((item) => ({ value: item, label: item })),
|
...tradeOptions.value.map((item) => ({ value: item, label: item })),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'activityExperience' as const,
|
||||||
|
label: 'سابقه فعالیت',
|
||||||
|
value: activityExperienceFilter.value || 'همه',
|
||||||
|
active: Boolean(activityExperienceFilter.value),
|
||||||
|
current: activityExperienceFilter.value,
|
||||||
|
searchable: false,
|
||||||
|
options: [
|
||||||
|
{ value: '', label: 'همه' },
|
||||||
|
...ACTIVITY_EXPERIENCE_OPTIONS.map((item) => ({ value: item, label: item })),
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function visibleFacetOptions(options: Array<{ value: string; label: string }>) {
|
function visibleFacetOptions(options: Array<{ value: string; label: string }>) {
|
||||||
@@ -492,6 +523,7 @@ function pickFacet(key: LeadFacetKey, value: string) {
|
|||||||
else if (key === 'city') setCityFilter(next);
|
else if (key === 'city') setCityFilter(next);
|
||||||
else if (key === 'region') setRegionFilter(next);
|
else if (key === 'region') setRegionFilter(next);
|
||||||
else if (key === 'trade') setTradeFilter(next);
|
else if (key === 'trade') setTradeFilter(next);
|
||||||
|
else if (key === 'activityExperience') setActivityExperienceFilter(next);
|
||||||
filterSection.value = null;
|
filterSection.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -808,6 +840,10 @@ function setTradeFilter(value: string) {
|
|||||||
patchQuery({ trade: value || undefined, page: undefined });
|
patchQuery({ trade: value || undefined, page: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setActivityExperienceFilter(value: string) {
|
||||||
|
patchQuery({ activityExperience: value || undefined, page: undefined });
|
||||||
|
}
|
||||||
|
|
||||||
function setSourceFilter(value: string) {
|
function setSourceFilter(value: string) {
|
||||||
patchQuery({ source: value || undefined, page: undefined });
|
patchQuery({ source: value || undefined, page: undefined });
|
||||||
}
|
}
|
||||||
@@ -837,6 +873,7 @@ function clearMoreFilters() {
|
|||||||
city: undefined,
|
city: undefined,
|
||||||
region: undefined,
|
region: undefined,
|
||||||
trade: undefined,
|
trade: undefined,
|
||||||
|
activityExperience: undefined,
|
||||||
source: undefined,
|
source: undefined,
|
||||||
createdFrom: undefined,
|
createdFrom: undefined,
|
||||||
createdTo: undefined,
|
createdTo: undefined,
|
||||||
@@ -964,6 +1001,7 @@ async function load() {
|
|||||||
city: cityFilter.value || undefined,
|
city: cityFilter.value || undefined,
|
||||||
region: regionFilter.value || undefined,
|
region: regionFilter.value || undefined,
|
||||||
trade: tradeFilter.value || undefined,
|
trade: tradeFilter.value || undefined,
|
||||||
|
activityExperience: activityExperienceFilter.value || undefined,
|
||||||
source: sourceFilter.value || undefined,
|
source: sourceFilter.value || undefined,
|
||||||
unassigned: unassigned.value ? '1' : undefined,
|
unassigned: unassigned.value ? '1' : undefined,
|
||||||
archived: archivedFilter.value ? '1' : undefined,
|
archived: archivedFilter.value ? '1' : undefined,
|
||||||
@@ -1477,6 +1515,7 @@ watch(
|
|||||||
route.query.city,
|
route.query.city,
|
||||||
route.query.region,
|
route.query.region,
|
||||||
route.query.trade,
|
route.query.trade,
|
||||||
|
route.query.activityExperience,
|
||||||
route.query.source,
|
route.query.source,
|
||||||
route.query.unassigned,
|
route.query.unassigned,
|
||||||
route.query.archived,
|
route.query.archived,
|
||||||
@@ -1521,6 +1560,11 @@ const tableColumns = computed<TableColumnsType<LeadDto>>(() => {
|
|||||||
{ title: 'شماره تماس', key: 'mobile', dataIndex: 'mobile' },
|
{ title: 'شماره تماس', key: 'mobile', dataIndex: 'mobile' },
|
||||||
{ title: 'شهر / منطقه', key: 'city' },
|
{ title: 'شهر / منطقه', key: 'city' },
|
||||||
{ title: 'منبع لید', key: 'source', dataIndex: 'source' },
|
{ title: 'منبع لید', key: 'source', dataIndex: 'source' },
|
||||||
|
{
|
||||||
|
title: 'سابقه فعالیت',
|
||||||
|
key: 'activityExperience',
|
||||||
|
dataIndex: 'activityExperience',
|
||||||
|
},
|
||||||
{ title: 'تاریخ ثبت', key: 'createdAt', dataIndex: 'createdAt' },
|
{ title: 'تاریخ ثبت', key: 'createdAt', dataIndex: 'createdAt' },
|
||||||
{ title: 'وضعیت', key: 'stage', dataIndex: 'stageName' },
|
{ title: 'وضعیت', key: 'stage', dataIndex: 'stageName' },
|
||||||
{ title: 'مسئول', key: 'assignee', dataIndex: 'assigneeName' },
|
{ title: 'مسئول', key: 'assignee', dataIndex: 'assigneeName' },
|
||||||
@@ -2226,6 +2270,11 @@ onBeforeUnmount(() => {
|
|||||||
<a-tag v-if="(record as LeadDto).source">{{ (record as LeadDto).source }}</a-tag>
|
<a-tag v-if="(record as LeadDto).source">{{ (record as LeadDto).source }}</a-tag>
|
||||||
<a-typography-text v-else type="secondary">—</a-typography-text>
|
<a-typography-text v-else type="secondary">—</a-typography-text>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="column.key === 'activityExperience'">
|
||||||
|
<a-typography-text>
|
||||||
|
{{ (record as LeadDto).activityExperience || '—' }}
|
||||||
|
</a-typography-text>
|
||||||
|
</template>
|
||||||
<template v-else-if="column.key === 'createdAt'">
|
<template v-else-if="column.key === 'createdAt'">
|
||||||
{{ formatJalaliNumeric(new Date((record as LeadDto).createdAt)) }}
|
{{ formatJalaliNumeric(new Date((record as LeadDto).createdAt)) }}
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -36,7 +36,12 @@ import {
|
|||||||
} from '@ant-design/icons-vue';
|
} from '@ant-design/icons-vue';
|
||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
||||||
import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared';
|
import {
|
||||||
|
ACTIVITY_EXPERIENCE_OPTIONS,
|
||||||
|
PERSON_GENDER_LABELS,
|
||||||
|
PERSON_GENDERS,
|
||||||
|
splitPersonHonorific,
|
||||||
|
} from '@mento/shared';
|
||||||
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
||||||
import { formatLocalDateInput, toFaDigits } from '@/lib/jalali';
|
import { formatLocalDateInput, toFaDigits } from '@/lib/jalali';
|
||||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||||
@@ -97,6 +102,7 @@ const website = ref('');
|
|||||||
const instagram = ref('');
|
const instagram = ref('');
|
||||||
const birthDate = ref('');
|
const birthDate = ref('');
|
||||||
const referrer = ref('');
|
const referrer = ref('');
|
||||||
|
const activityExperience = ref('');
|
||||||
const nationalId = ref('');
|
const nationalId = ref('');
|
||||||
const city = ref('');
|
const city = ref('');
|
||||||
const rasteh = ref('');
|
const rasteh = ref('');
|
||||||
@@ -279,6 +285,7 @@ function fill(p: PersonDto) {
|
|||||||
instagram.value = p.instagram ?? '';
|
instagram.value = p.instagram ?? '';
|
||||||
birthDate.value = p.birthDate ? formatLocalDateInput(new Date(p.birthDate)) : '';
|
birthDate.value = p.birthDate ? formatLocalDateInput(new Date(p.birthDate)) : '';
|
||||||
referrer.value = p.referrer ?? '';
|
referrer.value = p.referrer ?? '';
|
||||||
|
activityExperience.value = p.activityExperience ?? '';
|
||||||
addresses.value = p.addresses?.length ? [...p.addresses] : [''];
|
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('، ');
|
||||||
@@ -382,6 +389,7 @@ function payload(): CreatePersonRequest {
|
|||||||
instagram: instagram.value || undefined,
|
instagram: instagram.value || undefined,
|
||||||
birthDate: birthDate.value || null,
|
birthDate: birthDate.value || null,
|
||||||
referrer: referrer.value || undefined,
|
referrer: referrer.value || undefined,
|
||||||
|
activityExperience: activityExperience.value || null,
|
||||||
addresses: addresses.value.map((a) => a.trim()).filter(Boolean),
|
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),
|
||||||
@@ -570,6 +578,20 @@ onMounted(load);
|
|||||||
<a-input v-model:value="referrer" placeholder="نام معرف" />
|
<a-input v-model:value="referrer" placeholder="نام معرف" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<a-col :xs="24" :md="12">
|
||||||
|
<a-form-item label="سابقه فعالیت">
|
||||||
|
<a-select
|
||||||
|
v-model:value="activityExperience"
|
||||||
|
allow-clear
|
||||||
|
placeholder="اختیاری"
|
||||||
|
style="width: 100%"
|
||||||
|
:options="[
|
||||||
|
{ value: '', label: '—' },
|
||||||
|
...ACTIVITY_EXPERIENCE_OPTIONS.map((value) => ({ value, label: value })),
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
<a-col :xs="24" :md="12">
|
<a-col :xs="24" :md="12">
|
||||||
<a-form-item label="کد ملی">
|
<a-form-item label="کد ملی">
|
||||||
<a-input v-model:value="nationalId" dir="ltr" placeholder="کد ملی (تهحساب)" />
|
<a-input v-model:value="nationalId" dir="ltr" placeholder="کد ملی (تهحساب)" />
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ const infoEmpty = computed(() => {
|
|||||||
!p.position &&
|
!p.position &&
|
||||||
!p.website &&
|
!p.website &&
|
||||||
!p.instagram &&
|
!p.instagram &&
|
||||||
|
!p.activityExperience &&
|
||||||
!p.birthDate &&
|
!p.birthDate &&
|
||||||
!p.referrer &&
|
!p.referrer &&
|
||||||
!nationalIdLabel.value &&
|
!nationalIdLabel.value &&
|
||||||
@@ -829,6 +830,10 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
|||||||
<dt>اینستاگرام</dt>
|
<dt>اینستاگرام</dt>
|
||||||
<dd dir="ltr">{{ person.instagram }}</dd>
|
<dd dir="ltr">{{ person.instagram }}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="person.activityExperience" class="fact">
|
||||||
|
<dt>سابقه فعالیت</dt>
|
||||||
|
<dd>{{ person.activityExperience }}</dd>
|
||||||
|
</div>
|
||||||
<div v-if="person.addresses?.length" class="fact wide">
|
<div v-if="person.addresses?.length" class="fact wide">
|
||||||
<dt>آدرسها</dt>
|
<dt>آدرسها</dt>
|
||||||
<dd>
|
<dd>
|
||||||
@@ -1145,6 +1150,7 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
|||||||
<div><dt>نام قبلی</dt><dd>{{ person.previousFullName || '—' }}</dd></div>
|
<div><dt>نام قبلی</dt><dd>{{ person.previousFullName || '—' }}</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 dir="ltr">{{ person.instagram || '—' }}</dd></div>
|
||||||
|
<div><dt>سابقه فعالیت</dt><dd>{{ person.activityExperience || '—' }}</dd></div>
|
||||||
<div><dt>معرف</dt><dd>{{ person.referrer || '—' }}</dd></div>
|
<div><dt>معرف</dt><dd>{{ person.referrer || '—' }}</dd></div>
|
||||||
<div>
|
<div>
|
||||||
<dt>کد ملی</dt>
|
<dt>کد ملی</dt>
|
||||||
|
|||||||
@@ -1491,6 +1491,74 @@ export const PERSON_IMPORT_SOURCE_LABELS: Record<PersonImportSource, string> = {
|
|||||||
other: "سایر",
|
other: "سایر",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** گزینههای ثابت فیلد «سابقه فعالیت» برای لید و مشتری */
|
||||||
|
export const ACTIVITY_EXPERIENCE_OPTIONS = [
|
||||||
|
"ندارم",
|
||||||
|
"1 الی 2 سال",
|
||||||
|
"2 الی 5 سال",
|
||||||
|
"بیش از 5 سال",
|
||||||
|
] as const;
|
||||||
|
export type ActivityExperience = (typeof ACTIVITY_EXPERIENCE_OPTIONS)[number];
|
||||||
|
|
||||||
|
/** نرمالسازی جواب فرم/ویرایش به یکی از گزینههای ثابت */
|
||||||
|
export function normalizeActivityExperience(
|
||||||
|
raw: string | null | undefined,
|
||||||
|
): ActivityExperience | null {
|
||||||
|
const text = (raw ?? "")
|
||||||
|
.trim()
|
||||||
|
.replace(/[۰-۹]/g, (d) => String("۰۱۲۳۴۵۶۷۸۹".indexOf(d)))
|
||||||
|
.replace(/[٠-٩]/g, (d) => String("٠١٢٣٤٥٦٧٨٩".indexOf(d)))
|
||||||
|
.replace(/\s+/g, " ");
|
||||||
|
if (!text) return null;
|
||||||
|
const lower = text.replace(/ي/g, "ی").replace(/ك/g, "ک").toLowerCase();
|
||||||
|
if (
|
||||||
|
lower === "ندارم" ||
|
||||||
|
lower === "ندارد" ||
|
||||||
|
lower.includes("بدون سابقه") ||
|
||||||
|
lower === "0" ||
|
||||||
|
lower === "هیچ"
|
||||||
|
) {
|
||||||
|
return "ندارم";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
lower.includes("بیش از 5") ||
|
||||||
|
lower.includes("بیشتر از 5") ||
|
||||||
|
lower.includes("بالای 5") ||
|
||||||
|
lower.includes("+5") ||
|
||||||
|
lower.includes("5 سال به بالا")
|
||||||
|
) {
|
||||||
|
return "بیش از 5 سال";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
lower.includes("2 الی 5") ||
|
||||||
|
lower.includes("2 تا 5") ||
|
||||||
|
lower.includes("۲ الی ۵") ||
|
||||||
|
lower.includes("2-5") ||
|
||||||
|
lower.includes("2–5")
|
||||||
|
) {
|
||||||
|
return "2 الی 5 سال";
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
lower.includes("1 الی 2") ||
|
||||||
|
lower.includes("1 تا 2") ||
|
||||||
|
lower.includes("۱ الی ۲") ||
|
||||||
|
lower.includes("1-2") ||
|
||||||
|
lower.includes("1–2")
|
||||||
|
) {
|
||||||
|
return "1 الی 2 سال";
|
||||||
|
}
|
||||||
|
for (const option of ACTIVITY_EXPERIENCE_OPTIONS) {
|
||||||
|
if (lower === option.toLowerCase()) return option;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** برچسب سؤال فرم که به فیلد سابقه فعالیت مربوط است */
|
||||||
|
export function isActivityExperienceLabel(label: string): boolean {
|
||||||
|
const text = label.trim().replace(/ي/g, "ی").replace(/ك/g, "ک");
|
||||||
|
return /سابقه\s*فعالیت/.test(text);
|
||||||
|
}
|
||||||
|
|
||||||
export interface PersonImportSourceStatDto {
|
export interface PersonImportSourceStatDto {
|
||||||
source: PersonImportSource | string;
|
source: PersonImportSource | string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -1520,6 +1588,7 @@ export interface PersonDto {
|
|||||||
instagram: string | null;
|
instagram: string | null;
|
||||||
birthDate: string | null;
|
birthDate: string | null;
|
||||||
referrer: string | null;
|
referrer: string | null;
|
||||||
|
activityExperience: string | null;
|
||||||
addresses: string[];
|
addresses: string[];
|
||||||
notes: string | null;
|
notes: string | null;
|
||||||
mood: PersonMood;
|
mood: PersonMood;
|
||||||
@@ -1555,6 +1624,7 @@ export interface CreatePersonRequest {
|
|||||||
instagram?: string;
|
instagram?: string;
|
||||||
birthDate?: string | null;
|
birthDate?: string | null;
|
||||||
referrer?: string;
|
referrer?: string;
|
||||||
|
activityExperience?: string | null;
|
||||||
addresses?: string[];
|
addresses?: string[];
|
||||||
notes?: string;
|
notes?: string;
|
||||||
mood?: PersonMood;
|
mood?: PersonMood;
|
||||||
@@ -2912,9 +2982,11 @@ export type LeadFormMapTo =
|
|||||||
| "lead.city"
|
| "lead.city"
|
||||||
| "lead.region"
|
| "lead.region"
|
||||||
| "lead.trade"
|
| "lead.trade"
|
||||||
|
| "lead.activityExperience"
|
||||||
| "lead.notes"
|
| "lead.notes"
|
||||||
| "lead.source"
|
| "lead.source"
|
||||||
| "lead.gender"
|
| "lead.gender"
|
||||||
|
| "person.activityExperience"
|
||||||
| "person.gender"
|
| "person.gender"
|
||||||
| "notes"
|
| "notes"
|
||||||
| "custom";
|
| "custom";
|
||||||
@@ -6289,6 +6361,7 @@ export interface LeadDto {
|
|||||||
addresses: string[];
|
addresses: string[];
|
||||||
trade: string | null;
|
trade: string | null;
|
||||||
source: string | null;
|
source: string | null;
|
||||||
|
activityExperience: string | null;
|
||||||
notes: string | null;
|
notes: string | null;
|
||||||
estimatedValue: number | null;
|
estimatedValue: number | null;
|
||||||
stageId: string;
|
stageId: string;
|
||||||
@@ -6330,6 +6403,7 @@ export interface CreateLeadRequest {
|
|||||||
addresses?: string[];
|
addresses?: string[];
|
||||||
trade?: string | null;
|
trade?: string | null;
|
||||||
source?: string | null;
|
source?: string | null;
|
||||||
|
activityExperience?: string | null;
|
||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
estimatedValue?: number | null;
|
estimatedValue?: number | null;
|
||||||
stageId?: string;
|
stageId?: string;
|
||||||
@@ -6353,6 +6427,7 @@ export interface UpdateLeadRequest {
|
|||||||
addresses?: string[];
|
addresses?: string[];
|
||||||
trade?: string | null;
|
trade?: string | null;
|
||||||
source?: string | null;
|
source?: string | null;
|
||||||
|
activityExperience?: string | null;
|
||||||
notes?: string | null;
|
notes?: string | null;
|
||||||
estimatedValue?: number | null;
|
estimatedValue?: number | null;
|
||||||
stageId?: string;
|
stageId?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user