Align companies with the Didar export: new fields, Didar-format Excel import/export, and people linked to companies by Didar code
This commit is contained in:
@@ -6,6 +6,8 @@ import { api } from '@/lib/api';
|
||||
import type { CompanyDto, CreateCompanyRequest } from '@mento/shared';
|
||||
import CustomFieldsSection from '@/components/CustomFieldsSection.vue';
|
||||
import EntityTimeline from '@/components/EntityTimeline.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import { formatLocalDateInput, parseLocalInput } from '@/lib/jalali';
|
||||
import {
|
||||
UiButton,
|
||||
UiCard,
|
||||
@@ -39,11 +41,24 @@ const saving = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
const name = ref('');
|
||||
const code = ref('');
|
||||
const sourceRef = ref('');
|
||||
const importSource = ref('manual');
|
||||
const nationalId = ref('');
|
||||
const economicCode = ref('');
|
||||
const registrationNumber = ref('');
|
||||
const phone = ref('');
|
||||
const otherPhones = ref('');
|
||||
const fax = ref('');
|
||||
const email = ref('');
|
||||
const otherEmails = ref('');
|
||||
const website = ref('');
|
||||
const province = ref('');
|
||||
const city = ref('');
|
||||
const postalCode = ref('');
|
||||
const address = ref('');
|
||||
const groupName = ref('');
|
||||
const registeredAt = ref('');
|
||||
const notes = ref('');
|
||||
const tagsRaw = ref('');
|
||||
const customFields = ref<Record<string, unknown>>({});
|
||||
@@ -61,11 +76,24 @@ function parseTags(raw: string): string[] {
|
||||
|
||||
function fill(c: CompanyDto) {
|
||||
name.value = c.name;
|
||||
code.value = c.code ?? '';
|
||||
sourceRef.value = c.sourceRef ?? '';
|
||||
importSource.value = c.importSource || 'manual';
|
||||
nationalId.value = c.nationalId ?? '';
|
||||
economicCode.value = c.economicCode ?? '';
|
||||
registrationNumber.value = c.registrationNumber ?? '';
|
||||
phone.value = c.phone ?? '';
|
||||
otherPhones.value = c.otherPhones ?? '';
|
||||
fax.value = c.fax ?? '';
|
||||
email.value = c.email ?? '';
|
||||
otherEmails.value = c.otherEmails ?? '';
|
||||
website.value = c.website ?? '';
|
||||
province.value = c.province ?? '';
|
||||
city.value = c.city ?? '';
|
||||
postalCode.value = c.postalCode ?? '';
|
||||
address.value = c.address ?? '';
|
||||
groupName.value = c.groupName ?? '';
|
||||
registeredAt.value = c.registeredAt ? formatLocalDateInput(new Date(c.registeredAt)) : '';
|
||||
notes.value = c.notes ?? '';
|
||||
tagsRaw.value = (c.tags ?? []).join('، ');
|
||||
customFields.value = { ...(c.customFields ?? {}) };
|
||||
@@ -88,11 +116,24 @@ async function load() {
|
||||
function payload(): CreateCompanyRequest {
|
||||
return {
|
||||
name: name.value,
|
||||
code: code.value || null,
|
||||
sourceRef: sourceRef.value || null,
|
||||
...(sourceRef.value && importSource.value === 'manual' ? { importSource: 'didar' } : {}),
|
||||
nationalId: nationalId.value || undefined,
|
||||
economicCode: economicCode.value || null,
|
||||
registrationNumber: registrationNumber.value || null,
|
||||
phone: phone.value || undefined,
|
||||
otherPhones: otherPhones.value || null,
|
||||
fax: fax.value || null,
|
||||
email: email.value || undefined,
|
||||
otherEmails: otherEmails.value || null,
|
||||
website: website.value || undefined,
|
||||
province: province.value || null,
|
||||
city: city.value || null,
|
||||
postalCode: postalCode.value || null,
|
||||
address: address.value || undefined,
|
||||
groupName: groupName.value || null,
|
||||
registeredAt: parseLocalInput(registeredAt.value)?.toISOString() ?? null,
|
||||
notes: notes.value || undefined,
|
||||
tags: parseTags(tagsRaw.value),
|
||||
customFields: customFields.value,
|
||||
@@ -204,50 +245,20 @@ onMounted(load);
|
||||
/>
|
||||
</UiField>
|
||||
|
||||
<UiField label="شناسه ملی">
|
||||
<UiInput
|
||||
id="nationalId"
|
||||
v-model="nationalId"
|
||||
placeholder="شناسه ملی ۱۱ رقمی"
|
||||
dir="ltr"
|
||||
/>
|
||||
<UiField label="کد شرکت">
|
||||
<UiInput id="code" v-model="code" placeholder="کد داخلی" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="شماره تلفن شرکت">
|
||||
<UiInput
|
||||
id="phone"
|
||||
v-model="phone"
|
||||
type="tel"
|
||||
placeholder="۰۲۱..."
|
||||
dir="ltr"
|
||||
/>
|
||||
<UiField label="کد دیدار شرکت">
|
||||
<UiInput id="sourceRef" v-model="sourceRef" placeholder="مثال: 5277" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="پست الکترونیکی (ایمیل)">
|
||||
<UiInput
|
||||
id="email"
|
||||
v-model="email"
|
||||
type="email"
|
||||
placeholder="info@company.ir"
|
||||
dir="ltr"
|
||||
/>
|
||||
<UiField label="گروه بندی شرکت">
|
||||
<UiInput id="groupName" v-model="groupName" placeholder="مثال: همکار، عمدهفروش" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="وبسایت">
|
||||
<UiInput
|
||||
id="website"
|
||||
v-model="website"
|
||||
placeholder="https://..."
|
||||
dir="ltr"
|
||||
/>
|
||||
</UiField>
|
||||
|
||||
<UiField label="آدرس پستی" class="col-span-2">
|
||||
<UiInput
|
||||
id="address"
|
||||
v-model="address"
|
||||
placeholder="نشانی، طبقه، پلاک..."
|
||||
/>
|
||||
<UiField label="تاریخ ثبت شرکت">
|
||||
<JalaliDateInput id="registeredAt" v-model="registeredAt" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="برچسبها" class="col-span-2">
|
||||
@@ -258,7 +269,7 @@ onMounted(load);
|
||||
/>
|
||||
</UiField>
|
||||
|
||||
<UiField label="یادداشت و توضیحات تکمیلی" class="col-span-2">
|
||||
<UiField label="توضیحات شرکت" class="col-span-2">
|
||||
<UiTextarea
|
||||
id="notes"
|
||||
v-model="notes"
|
||||
@@ -269,6 +280,72 @@ onMounted(load);
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<UiCard title="اطلاعات تماس و آدرس" class="section-card">
|
||||
<div class="crm-form-grid-2">
|
||||
<UiField label="تلفن شرکت">
|
||||
<UiInput id="phone" v-model="phone" type="tel" placeholder="۰۲۱..." dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="تلفن های دیگر شرکت">
|
||||
<UiInput id="otherPhones" v-model="otherPhones" placeholder="با کاما جدا کنید" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="ایمیل شرکت">
|
||||
<UiInput
|
||||
id="email"
|
||||
v-model="email"
|
||||
type="email"
|
||||
placeholder="info@company.ir"
|
||||
dir="ltr"
|
||||
/>
|
||||
</UiField>
|
||||
|
||||
<UiField label="ایمیل های دیگر شرکت">
|
||||
<UiInput id="otherEmails" v-model="otherEmails" placeholder="با کاما جدا کنید" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="شماره فکس">
|
||||
<UiInput id="fax" v-model="fax" type="tel" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="سایت های شرکت">
|
||||
<UiInput id="website" v-model="website" placeholder="https://..." dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="استان">
|
||||
<UiInput id="province" v-model="province" placeholder="مثال: تهران" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="شهرستان">
|
||||
<UiInput id="city" v-model="city" placeholder="مثال: تهران" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="کد پستی">
|
||||
<UiInput id="postalCode" v-model="postalCode" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="آدرس" class="col-span-2">
|
||||
<UiInput id="address" v-model="address" placeholder="نشانی، طبقه، پلاک..." />
|
||||
</UiField>
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<UiCard title="اطلاعات حقوقی و ثبتی" class="section-card">
|
||||
<div class="crm-form-grid-2">
|
||||
<UiField label="شناسه ملی">
|
||||
<UiInput id="nationalId" v-model="nationalId" placeholder="شناسه ملی ۱۱ رقمی" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="شماره اقتصادی">
|
||||
<UiInput id="economicCode" v-model="economicCode" dir="ltr" />
|
||||
</UiField>
|
||||
|
||||
<UiField label="شماره ثبت">
|
||||
<UiInput id="registrationNumber" v-model="registrationNumber" dir="ltr" />
|
||||
</UiField>
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<CustomFieldsSection entity-type="company" v-model="customFields" />
|
||||
<EntityTimeline v-if="!isNew && id" entity-type="company" :entity-id="id" />
|
||||
|
||||
|
||||
@@ -733,7 +733,17 @@ onMounted(load);
|
||||
<UiIcon name="mail" :size="13" />
|
||||
<span>{{ c.email }}</span>
|
||||
</p>
|
||||
<p class="role">افراد: {{ toFaDigits(c.peopleCount) }}</p>
|
||||
<p v-if="c.sourceRef || c.code" class="line">
|
||||
<span>
|
||||
{{ c.sourceRef ? `کد دیدار: ${toFaDigits(c.sourceRef)}` : '' }}
|
||||
{{ c.sourceRef && c.code ? ' • ' : '' }}
|
||||
{{ c.code ? `کد: ${toFaDigits(c.code)}` : '' }}
|
||||
</span>
|
||||
</p>
|
||||
<p class="role">
|
||||
{{ [c.city, c.owner?.fullName].filter(Boolean).join(' • ') }}
|
||||
{{ c.city || c.owner ? ' • ' : '' }}افراد: {{ toFaDigits(c.peopleCount) }}
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
@@ -743,8 +753,18 @@ onMounted(load);
|
||||
<tr>
|
||||
<th class="num-col">#</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>شماره اقتصادی</th>
|
||||
<th>مسئول شرکت</th>
|
||||
<th>تاریخ ثبت</th>
|
||||
<th>افراد</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -756,8 +776,18 @@ onMounted(load);
|
||||
{{ c.name }}
|
||||
</RouterLink>
|
||||
</td>
|
||||
<td>{{ c.phone || '—' }}</td>
|
||||
<td>{{ c.email || '—' }}</td>
|
||||
<td dir="ltr">{{ c.sourceRef ? toFaDigits(c.sourceRef) : '—' }}</td>
|
||||
<td dir="ltr">{{ c.code ? toFaDigits(c.code) : '—' }}</td>
|
||||
<td>{{ sourceLabel(c.importSource || 'manual') }}</td>
|
||||
<td>{{ c.groupName || '—' }}</td>
|
||||
<td>{{ c.province || '—' }}</td>
|
||||
<td>{{ c.city || '—' }}</td>
|
||||
<td dir="ltr">{{ c.phone || '—' }}</td>
|
||||
<td><span class="mail">{{ c.email || '—' }}</span></td>
|
||||
<td dir="ltr">{{ c.nationalId || '—' }}</td>
|
||||
<td dir="ltr">{{ c.economicCode || '—' }}</td>
|
||||
<td>{{ c.owner?.fullName || '—' }}</td>
|
||||
<td>{{ formatDate(c.registeredAt || c.createdAt) }}</td>
|
||||
<td>{{ toFaDigits(c.peopleCount) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user