feat: move brand name to one config and redesign the accounting card
اپ: نام برند در همهی صفحهها و پیامها یکسان شده و از یک تنظیم مرکزی خوانده میشود. اپ: کارت حسابداری در صفحهی مشتری بازطراحی شد؛ ماندهها و وضعیت لینک واضحتر نمایش داده میشوند. پنل: کارت حسابداری در پروندهی مشتری بازطراحی شد؛ ماندهها، آخرین ارسال و فرم لینک دستی واضحتر شدهاند. پنل: ستون «کد» در جدولها بهطور پیشفرض پنهان است و از انتخاب ستونها قابل نمایش است. پنل: تغییر نمایش ستونها در جدولها بلافاصله اعمال میشود. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
5d2a1efb0c
commit
532ceee189
@@ -3,123 +3,279 @@
|
||||
Shared implementation of legacy ViewOmdeCustomer.vue (376 lines) and
|
||||
ViewSingleCustomer.vue (425 lines) — the customer detail screens.
|
||||
|
||||
Both show the same four panels (profile, orders, financial documents, wallet)
|
||||
Both show the same panels (profile, orders, financial documents, wallet)
|
||||
against the same customer record; legacy duplicated the whole page per
|
||||
customer kind. The differing bits are parameterised:
|
||||
- the wholesale screen adds an activity-log panel (legacy log/ago/{id})
|
||||
- the retail screen adds a wallet panel (legacy single/wallet/{id})
|
||||
|
||||
Layout: profile header → financial KPI tiles → main column (record tabs)
|
||||
beside a side column (profile details, accounting).
|
||||
-->
|
||||
<a-spin :spinning="loading">
|
||||
<a-card :title="title" class="page-card">
|
||||
<a-descriptions bordered size="small" :column="{ xxl: 3, xl: 3, lg: 3, md: 2, sm: 2, xs: 1 }">
|
||||
<a-descriptions-item label="نام">{{ customer?.name ?? '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="موبایل">{{ customer?.mobile ?? '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="کد ملی">
|
||||
{{ customer?.national_code ?? '-' }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="شهر">{{ customer?.city?.title ?? '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="کارشناس فروش">
|
||||
{{ customer?.reagent?.name ?? '-' }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="وضعیت">
|
||||
<a-tag :color="customer?.active === 1 ? 'green' : 'red'">
|
||||
{{ customer?.active === 1 ? 'فعال' : 'غیر فعال' }}
|
||||
</a-tag>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="سطح اعتبار">
|
||||
{{ customer?.gram_level ?? '-' }} گرم
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="بدهی گرمی">{{ customer?.remain ?? '-' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="بدهی ریالی">
|
||||
{{ customer?.rial_remain ?? '-' }}
|
||||
</a-descriptions-item>
|
||||
<!-- legacy ViewOmdeCustomer.vue:28-30 -->
|
||||
<a-descriptions-item label="میزان فروش">{{ dashboard?.grams_sell ?? '-' }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
<div v-if="dashboard" class="stats mt-4">
|
||||
<a-tag color="blue">کل سفارشها: {{ dashboard.total_order }}</a-tag>
|
||||
<a-tag color="orange">سفارش باز: {{ dashboard.open_order }}</a-tag>
|
||||
<a-tag color="green">اسناد: {{ dashboard.ledger_entries }}</a-tag>
|
||||
</div>
|
||||
</a-card>
|
||||
|
||||
<!-- D27 — link and balance in the accounting software. -->
|
||||
<CustomerAccountingCard :customer-id="id" />
|
||||
|
||||
<a-tabs class="mt-4 detail-tabs" :default-active-key="defaultTab">
|
||||
<a-tab-pane key="orders" tab="سفارش ها">
|
||||
<a-table
|
||||
size="small"
|
||||
:data-source="orders"
|
||||
:columns="orderColumns"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane key="documents" tab="سند های مالی">
|
||||
<a-table
|
||||
size="small"
|
||||
:data-source="documents"
|
||||
:columns="documentColumns"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'confirmed'">
|
||||
<a-tag :color="record.confirmed === 1 ? 'green' : ''">
|
||||
{{ record.confirmed === 1 ? 'تایید شده' : 'تایید نشده' }}
|
||||
<div class="customer-detail" :style="themeVars">
|
||||
<!-- Profile header -->
|
||||
<section class="panel hero">
|
||||
<div class="hero-main">
|
||||
<a-avatar :size="64" :src="customer?.image?.image" class="hero-avatar">
|
||||
{{ initials }}
|
||||
</a-avatar>
|
||||
<div class="hero-text">
|
||||
<div class="hero-eyebrow">{{ title }}</div>
|
||||
<h1 class="hero-name">{{ customer?.name || '—' }}</h1>
|
||||
<div class="hero-tags">
|
||||
<a-tag v-if="customer" :color="customer.active === 1 ? 'success' : 'error'">
|
||||
{{ customer.active === 1 ? 'فعال' : 'غیرفعال' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
<a-tag v-if="customer" :color="customer.sts === 1 ? 'processing' : 'warning'">
|
||||
{{ customer.sts === 1 ? 'مجاز به سفارش' : 'عدم سفارش' }}
|
||||
</a-tag>
|
||||
<a-tag v-if="customer?.type_str">{{ customer.type_str }}</a-tag>
|
||||
<a-tag v-if="customer?.is_archive === 1" color="default">بایگانیشده</a-tag>
|
||||
</div>
|
||||
<div class="hero-meta">
|
||||
<span v-if="customer?.mobile" class="meta-item">
|
||||
<PhoneOutlined />
|
||||
<span dir="ltr">{{ customer.mobile }}</span>
|
||||
</span>
|
||||
<span v-if="customer?.city?.title" class="meta-item">
|
||||
<EnvironmentOutlined />
|
||||
{{ customer.city.title }}
|
||||
</span>
|
||||
<span v-if="customer?.reagent?.name" class="meta-item">
|
||||
<UserOutlined />
|
||||
کارشناس فروش: {{ customer.reagent.name }}
|
||||
</span>
|
||||
<span v-if="customer?.caj" class="meta-item">
|
||||
<CalendarOutlined />
|
||||
عضویت از {{ jdate(customer.caj) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a-button @click="router.back()">
|
||||
<template #icon><ArrowRightOutlined /></template>
|
||||
بازگشت
|
||||
</a-button>
|
||||
<a-button v-if="canEdit" type="primary" @click="router.push({ name: editRoute, params: { id } })">
|
||||
<template #icon><EditOutlined /></template>
|
||||
ویرایش مشتری
|
||||
</a-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a-tab-pane v-if="showWallet" key="wallet" tab="کیف پول">
|
||||
<a-table
|
||||
size="small"
|
||||
:data-source="wallet"
|
||||
:columns="walletColumns"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
<template v-else-if="column.dataIndex === 'expires_at'">
|
||||
{{ jdate(record.expires_at) }}
|
||||
</template>
|
||||
<!-- Financial KPIs -->
|
||||
<section class="kpis">
|
||||
<div class="panel kpi">
|
||||
<div class="kpi-label">بدهی طلایی</div>
|
||||
<div class="kpi-value" :class="sign(customer?.remain)">
|
||||
{{ num(customer?.remain, 3) }}<small>گرم</small>
|
||||
</div>
|
||||
<div class="kpi-foot">{{ balanceWord(customer?.remain) }}</div>
|
||||
</div>
|
||||
<div class="panel kpi">
|
||||
<div class="kpi-label">بدهی ریالی</div>
|
||||
<div class="kpi-value" :class="sign(customer?.rial_remain)">
|
||||
{{ num(customer?.rial_remain, 0) }}<small>ریال</small>
|
||||
</div>
|
||||
<div class="kpi-foot">{{ balanceWord(customer?.rial_remain) }}</div>
|
||||
</div>
|
||||
<div class="panel kpi">
|
||||
<div class="kpi-label">سقف اعتبار</div>
|
||||
<div class="kpi-value">{{ num(customer?.gram_level, 3) }}<small>گرم</small></div>
|
||||
<template v-if="creditUsage !== null">
|
||||
<a-progress
|
||||
:percent="creditUsage"
|
||||
:stroke-color="creditColor"
|
||||
:show-info="false"
|
||||
size="small"
|
||||
class="kpi-progress"
|
||||
/>
|
||||
<div class="kpi-foot">{{ num(creditUsage, 0) }}٪ از سقف استفاده شده</div>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
<div v-else class="kpi-foot">سقفی تعیین نشده</div>
|
||||
</div>
|
||||
<div class="panel kpi">
|
||||
<div class="kpi-label">میزان فروش</div>
|
||||
<div class="kpi-value">{{ num(dashboard?.grams_sell, 3) }}<small>گرم</small></div>
|
||||
<div class="kpi-foot">مجموع وزن سفارشها</div>
|
||||
</div>
|
||||
<div class="panel kpi">
|
||||
<div class="kpi-label">سفارشها</div>
|
||||
<div class="kpi-value">{{ num(dashboard?.total_order ?? orders.length, 0) }}</div>
|
||||
<div class="kpi-foot">
|
||||
<span :class="{ 'text-warning': Number(dashboard?.open_order) > 0 }">
|
||||
{{ num(dashboard?.open_order, 0) }} باز
|
||||
</span>
|
||||
· {{ num(dashboard?.ledger_entries ?? documents.length, 0) }} سند
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<a-tab-pane v-if="showActivity" key="activity" tab="فعالیت ها">
|
||||
<a-table
|
||||
size="small"
|
||||
:data-source="activity"
|
||||
:columns="activityColumns"
|
||||
:pagination="{ pageSize: 15 }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'caj'">{{ jdateTime(record.caj) }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
<div class="layout">
|
||||
<!-- Main column: the customer's records -->
|
||||
<section class="panel layout-main">
|
||||
<a-tabs v-model:active-key="activeTab" class="detail-tabs">
|
||||
<a-tab-pane key="orders">
|
||||
<template #tab>
|
||||
سفارشها <span class="tab-count">{{ num(orders.length, 0) }}</span>
|
||||
</template>
|
||||
<a-table
|
||||
size="middle"
|
||||
:data-source="orders"
|
||||
:columns="orderColumns"
|
||||
:pagination="pagination(10, orders.length)"
|
||||
:locale="{ emptyText: 'سفارشی برای این مشتری ثبت نشده است' }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<span class="mono" dir="ltr">{{ record.name }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'w'">
|
||||
{{ num(record.w, 3) }} <span class="unit">گرم</span>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'status'">
|
||||
<a-tag :color="ORDER_STATUS[record.status]?.color">
|
||||
{{ ORDER_STATUS[record.status]?.label ?? record.status ?? '—' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'branch'">{{ record.branch ?? '—' }}</template>
|
||||
<template v-else-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane key="documents">
|
||||
<template #tab>
|
||||
سندهای مالی <span class="tab-count">{{ num(documents.length, 0) }}</span>
|
||||
</template>
|
||||
<a-table
|
||||
size="middle"
|
||||
:data-source="documents"
|
||||
:columns="documentColumns"
|
||||
:pagination="pagination(10, documents.length)"
|
||||
:locale="{ emptyText: 'سندی برای این مشتری ثبت نشده است' }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'type'">
|
||||
{{ SOURCE_TYPE[record.type] ?? record.type }}
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'value'">
|
||||
<span :class="record.direction === 'DEBIT' ? 'debt' : record.direction === 'CREDIT' ? 'credit' : ''">
|
||||
{{ record.direction === 'CREDIT' ? '−' : record.direction === 'DEBIT' ? '+' : '' }}{{
|
||||
num(record.value, record.currency === 'RIAL' ? 0 : 3)
|
||||
}}
|
||||
</span>
|
||||
<span class="unit">{{ record.currency === 'RIAL' ? 'ریال' : 'گرم' }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'confirmed'">
|
||||
<a-badge
|
||||
:status="record.confirmed === 1 ? 'success' : 'default'"
|
||||
:text="record.confirmed === 1 ? 'تایید شده' : 'تایید نشده'"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'note'">
|
||||
<span class="note">{{ record.note || '—' }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane v-if="showWallet" key="wallet">
|
||||
<template #tab>
|
||||
کیف پول <span class="tab-count">{{ num(wallet.length, 0) }}</span>
|
||||
</template>
|
||||
<a-table
|
||||
size="middle"
|
||||
:data-source="wallet"
|
||||
:columns="walletColumns"
|
||||
:pagination="pagination(10, wallet.length)"
|
||||
:locale="{ emptyText: 'اعتباری در کیف پول ثبت نشده است' }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'value'">
|
||||
{{ num(record.value, 3) }} <span class="unit">گرم</span>
|
||||
</template>
|
||||
<template v-else-if="column.dataIndex === 'caj'">{{ jdate(record.caj) }}</template>
|
||||
<template v-else-if="column.dataIndex === 'expires_at'">
|
||||
{{ record.expires_at ? jdate(record.expires_at) : '—' }}
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
|
||||
<a-tab-pane v-if="showActivity" key="activity">
|
||||
<template #tab>
|
||||
فعالیتها <span class="tab-count">{{ num(activity.length, 0) }}</span>
|
||||
</template>
|
||||
<a-table
|
||||
size="middle"
|
||||
:data-source="activity"
|
||||
:columns="activityColumns"
|
||||
:pagination="pagination(15, activity.length)"
|
||||
:locale="{ emptyText: 'فعالیتی ثبت نشده است' }"
|
||||
row-key="id"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'caj'">
|
||||
<span dir="ltr">{{ jdateTime(record.caj) }}</span>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</section>
|
||||
|
||||
<!-- Side column: who the customer is -->
|
||||
<aside class="layout-side">
|
||||
<section class="panel">
|
||||
<h2 class="panel-title">اطلاعات هویتی و تماس</h2>
|
||||
<dl class="facts">
|
||||
<div v-for="f in identityFacts" :key="f.label" class="fact">
|
||||
<dt>{{ f.label }}</dt>
|
||||
<dd :dir="f.ltr ? 'ltr' : undefined">{{ f.value || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section v-if="businessFacts.length" class="panel">
|
||||
<h2 class="panel-title">اطلاعات کسبوکار</h2>
|
||||
<dl class="facts">
|
||||
<div v-for="f in businessFacts" :key="f.label" class="fact">
|
||||
<dt>{{ f.label }}</dt>
|
||||
<dd>{{ f.value }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<!-- D27 — link and balance in the accounting software. -->
|
||||
<CustomerAccountingCard :customer-id="id" />
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { theme } from 'ant-design-vue';
|
||||
import {
|
||||
ArrowRightOutlined,
|
||||
CalendarOutlined,
|
||||
EditOutlined,
|
||||
EnvironmentOutlined,
|
||||
PhoneOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { jdate, jdateTime } from '../../utils/filters';
|
||||
import api from '../../api/client';
|
||||
import { useUsersStore } from '../../stores/users';
|
||||
import CustomerAccountingCard from '../../components/accounting/CustomerAccountingCard.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
@@ -130,14 +286,26 @@ const props = withDefaults(
|
||||
/** The wholesale screen shows the activity log. */
|
||||
showActivity?: boolean;
|
||||
defaultTab?: string;
|
||||
/** Named route of this customer kind's edit form; the button hides if absent or not permitted. */
|
||||
editRoute?: string;
|
||||
}>(),
|
||||
{ title: 'مشاهده اطلاعات مشتری', showWallet: false, showActivity: false, defaultTab: 'orders' },
|
||||
{
|
||||
title: 'مشاهده اطلاعات مشتری',
|
||||
showWallet: false,
|
||||
showActivity: false,
|
||||
defaultTab: 'orders',
|
||||
editRoute: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const users = useUsersStore();
|
||||
const { token } = theme.useToken();
|
||||
const id = route.params.id as string;
|
||||
|
||||
const loading = ref(false);
|
||||
const activeTab = ref(props.defaultTab);
|
||||
const customer = ref<Record<string, any> | undefined>(undefined);
|
||||
const dashboard = ref<Record<string, any> | undefined>(undefined);
|
||||
const orders = ref<Record<string, any>[]>([]);
|
||||
@@ -145,10 +313,50 @@ const documents = ref<Record<string, any>[]>([]);
|
||||
const wallet = ref<Record<string, any>[]>([]);
|
||||
const activity = ref<Record<string, any>[]>([]);
|
||||
|
||||
// Colours come from the antd theme so the page follows the panel's palette.
|
||||
const themeVars = computed(() => ({
|
||||
'--cd-bg': token.value.colorBgContainer,
|
||||
'--cd-border': token.value.colorBorderSecondary,
|
||||
'--cd-text': token.value.colorText,
|
||||
'--cd-text-2': token.value.colorTextSecondary,
|
||||
'--cd-text-3': token.value.colorTextTertiary,
|
||||
'--cd-fill': token.value.colorFillQuaternary,
|
||||
'--cd-primary': token.value.colorPrimary,
|
||||
'--cd-primary-bg': token.value.colorPrimaryBg,
|
||||
'--cd-error': token.value.colorError,
|
||||
'--cd-success': token.value.colorSuccess,
|
||||
'--cd-warning': token.value.colorWarning,
|
||||
}));
|
||||
|
||||
// OrderStatus enum (schema.prisma); labels as on the accounting settings page.
|
||||
const ORDER_STATUS: Record<string, { label: string; color?: string }> = {
|
||||
SUSPENDED: { label: 'معلق (عبور از سقف)', color: 'error' },
|
||||
PLACED: { label: 'ثبت سفارش', color: 'default' },
|
||||
ADMIN_APPROVED: { label: 'تأیید مدیر', color: 'processing' },
|
||||
SOURCING: { label: 'در حال تأمین', color: 'processing' },
|
||||
PREPARING: { label: 'در حال آمادهسازی', color: 'processing' },
|
||||
DELIVERED_TO_AGENT: { label: 'تحویل مسئول فروش', color: 'cyan' },
|
||||
DELIVERED_TO_CUSTOMER: { label: 'تحویل مشتری', color: 'success' },
|
||||
CANCELLED: { label: 'لغو شده', color: 'default' },
|
||||
};
|
||||
|
||||
// LedgerSourceType enum (schema.prisma).
|
||||
const SOURCE_TYPE: Record<string, string> = {
|
||||
ORDER_STOCK: 'سفارش کالای موجود',
|
||||
ORDER_PRE_ORDER: 'پیشسفارش',
|
||||
REPAYMENT_MELTED_GOLD: 'تسویه با آبشده',
|
||||
REPAYMENT_TRANSFER: 'تسویه با واریز',
|
||||
REPAYMENT_CHEQUE: 'تسویه با چک',
|
||||
REPAYMENT_CASH: 'تسویه نقدی',
|
||||
WALLET_BONUS: 'پاداش کیف پول',
|
||||
ADJUSTMENT: 'اصلاحیه',
|
||||
};
|
||||
|
||||
const orderColumns = [
|
||||
{ title: 'شماره سفارش', dataIndex: 'name' },
|
||||
{ title: 'وضعیت', dataIndex: 'status' },
|
||||
{ title: 'وزن', dataIndex: 'w' },
|
||||
{ title: 'تعداد آیتم', dataIndex: 'items_count' },
|
||||
{ title: 'تعداد آیتم', dataIndex: 'items_count', align: 'center' as const },
|
||||
{ title: 'شعبه', dataIndex: 'branch' },
|
||||
{ title: 'تاریخ', dataIndex: 'caj' },
|
||||
];
|
||||
@@ -157,12 +365,12 @@ const documentColumns = [
|
||||
{ title: 'نوع', dataIndex: 'type' },
|
||||
{ title: 'مقدار', dataIndex: 'value' },
|
||||
{ title: 'وضعیت', dataIndex: 'confirmed' },
|
||||
{ title: 'توضیحات', dataIndex: 'note' },
|
||||
{ title: 'توضیحات', dataIndex: 'note', ellipsis: true },
|
||||
{ title: 'تاریخ', dataIndex: 'caj' },
|
||||
];
|
||||
|
||||
const walletColumns = [
|
||||
{ title: 'مقدار (گرم)', dataIndex: 'value' },
|
||||
{ title: 'مقدار', dataIndex: 'value' },
|
||||
{ title: 'تاریخ اعطا', dataIndex: 'caj' },
|
||||
{ title: 'انقضا', dataIndex: 'expires_at' },
|
||||
];
|
||||
@@ -173,6 +381,65 @@ const activityColumns = [
|
||||
{ title: 'تاریخ', dataIndex: 'caj' },
|
||||
];
|
||||
|
||||
const num = (v: unknown, places: number) =>
|
||||
v === null || v === undefined || v === '' || Number.isNaN(Number(v))
|
||||
? '—'
|
||||
: Number(v).toLocaleString('fa-IR', { maximumFractionDigits: places });
|
||||
// Positive balance = the customer owes (same convention as the accounting card).
|
||||
const sign = (v: unknown) => (Number(v) > 0 ? 'debt' : Number(v) < 0 ? 'credit' : '');
|
||||
const balanceWord = (v: unknown) =>
|
||||
v === null || v === undefined ? '' : Number(v) > 0 ? 'بدهکار' : Number(v) < 0 ? 'بستانکار' : 'تسویه';
|
||||
const pagination = (pageSize: number, total: number) =>
|
||||
total > pageSize ? { pageSize, size: 'small' as const, showSizeChanger: false } : false;
|
||||
|
||||
const initials = computed(() => (customer.value?.name ?? '').trim().charAt(0) || '؟');
|
||||
|
||||
const creditUsage = computed<number | null>(() => {
|
||||
const limit = Number(customer.value?.gram_level);
|
||||
if (!limit || limit <= 0) return null;
|
||||
const used = Math.max(Number(customer.value?.remain) || 0, 0);
|
||||
return Math.min(Math.round((used / limit) * 100), 100);
|
||||
});
|
||||
const creditColor = computed(() => {
|
||||
const u = creditUsage.value ?? 0;
|
||||
return u >= 90 ? token.value.colorError : u >= 70 ? token.value.colorWarning : token.value.colorPrimary;
|
||||
});
|
||||
|
||||
const canEdit = computed(() => {
|
||||
if (!props.editRoute || !router.hasRoute(props.editRoute)) return false;
|
||||
const meta = router.resolve({ name: props.editRoute, params: { id } }).meta as Record<string, any>;
|
||||
if (meta.superAdminOnly && !users.isSuperAdmin) return false;
|
||||
return !meta.role || Boolean(users.hasPermission(meta.role));
|
||||
});
|
||||
|
||||
const identityFacts = computed(() => {
|
||||
const c = customer.value;
|
||||
return [
|
||||
{ label: 'موبایل', value: c?.mobile, ltr: true },
|
||||
{ label: 'تلفن ثابت', value: c?.phone, ltr: true },
|
||||
{ label: 'کد ملی', value: c?.national_code, ltr: true },
|
||||
{ label: 'تاریخ تولد', value: c?.birth_date ? jdate(c.birth_date) : null },
|
||||
{ label: 'شهر', value: c?.city?.title },
|
||||
{ label: 'آدرس', value: c?.address },
|
||||
];
|
||||
});
|
||||
|
||||
// Only the fields this customer actually has — retail customers usually have none.
|
||||
const businessFacts = computed(() => {
|
||||
const c = customer.value;
|
||||
return [
|
||||
{ label: 'نام فروشگاه', value: c?.store_name },
|
||||
{ label: 'پاساژ', value: c?.pasazh_name },
|
||||
{ label: 'منطقه', value: c?.zone },
|
||||
{ label: 'کد عضویت', value: c?.mcode },
|
||||
{ label: 'کارشناس فروش', value: c?.reagent?.name },
|
||||
{
|
||||
label: 'درصد اجرت',
|
||||
value: c?.percent !== null && c?.percent !== undefined && c?.percent !== '' ? `${num(c.percent, 2)}٪` : null,
|
||||
},
|
||||
].filter((f) => f.value);
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
@@ -206,24 +473,282 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.stats {
|
||||
.customer-detail {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.mt-4 {
|
||||
margin-top: 1rem;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
color: var(--cd-text);
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--cd-bg);
|
||||
border: 1px solid var(--cd-border);
|
||||
border-radius: 12px;
|
||||
}
|
||||
.panel-title {
|
||||
margin: 0;
|
||||
padding: 14px 18px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
border-bottom: 1px solid var(--cd-border);
|
||||
}
|
||||
|
||||
/* ── Header ─────────────────────────────────────────── */
|
||||
.hero {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 20px 24px;
|
||||
}
|
||||
.hero-main {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
.hero-avatar {
|
||||
flex-shrink: 0;
|
||||
background: var(--cd-primary);
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.hero-text {
|
||||
min-width: 0;
|
||||
}
|
||||
.hero-eyebrow {
|
||||
font-size: 12px;
|
||||
color: var(--cd-text-3);
|
||||
}
|
||||
.hero-name {
|
||||
margin: 2px 0 8px;
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
line-height: 1.4;
|
||||
color: var(--cd-text);
|
||||
}
|
||||
.hero-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
.hero-tags :deep(.ant-tag) {
|
||||
margin: 0;
|
||||
}
|
||||
.hero-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 20px;
|
||||
margin-top: 12px;
|
||||
font-size: 13px;
|
||||
color: var(--cd-text-2);
|
||||
}
|
||||
.meta-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.meta-item :deep(.anticon) {
|
||||
color: var(--cd-text-3);
|
||||
}
|
||||
.hero-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ── KPI tiles ──────────────────────────────────────── */
|
||||
.kpis {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
.kpi {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px 18px;
|
||||
}
|
||||
.kpi-label {
|
||||
font-size: 13px;
|
||||
color: var(--cd-text-2);
|
||||
}
|
||||
.kpi-value {
|
||||
margin-top: 6px;
|
||||
font-size: 22px;
|
||||
font-weight: 800;
|
||||
line-height: 1.3;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--cd-text);
|
||||
}
|
||||
.kpi-value small {
|
||||
margin-inline-start: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--cd-text-3);
|
||||
}
|
||||
.kpi-progress {
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
.kpi-foot {
|
||||
margin-top: auto;
|
||||
padding-top: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--cd-text-3);
|
||||
}
|
||||
|
||||
/* ── Two-column body ────────────────────────────────── */
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 360px;
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
.layout-main {
|
||||
padding: 4px 20px 16px;
|
||||
}
|
||||
.layout-side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.detail-tabs :deep(.ant-tabs-nav) {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.detail-tabs :deep(.ant-tabs-tab) {
|
||||
padding: 14px 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
.tab-count {
|
||||
display: inline-block;
|
||||
min-width: 22px;
|
||||
margin-inline-start: 6px;
|
||||
padding: 0 7px;
|
||||
border-radius: 10px;
|
||||
background: var(--cd-fill);
|
||||
color: var(--cd-text-2);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.detail-tabs :deep(.ant-tabs-tab-active) .tab-count {
|
||||
background: var(--cd-primary-bg);
|
||||
color: var(--cd-primary);
|
||||
}
|
||||
.detail-tabs :deep(.ant-table-thead > tr > th) {
|
||||
font-weight: 600;
|
||||
color: var(--cd-text-2);
|
||||
}
|
||||
|
||||
.facts {
|
||||
margin: 0;
|
||||
padding: 6px 18px 10px;
|
||||
}
|
||||
.fact {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 16px;
|
||||
padding: 9px 0;
|
||||
border-bottom: 1px dashed var(--cd-border);
|
||||
}
|
||||
.fact:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.fact dt {
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
color: var(--cd-text-2);
|
||||
}
|
||||
.fact dd {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
text-align: end;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* ── Shared bits ────────────────────────────────────── */
|
||||
.debt {
|
||||
color: var(--cd-error);
|
||||
}
|
||||
.credit {
|
||||
color: var(--cd-success);
|
||||
}
|
||||
.text-warning {
|
||||
color: var(--cd-warning);
|
||||
font-weight: 600;
|
||||
}
|
||||
.unit {
|
||||
font-size: 12px;
|
||||
color: var(--cd-text-3);
|
||||
}
|
||||
.mono {
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
.note {
|
||||
color: var(--cd-text-2);
|
||||
}
|
||||
|
||||
/* ── Responsive ─────────────────────────────────────── */
|
||||
@media (max-width: 1399px) {
|
||||
.kpis {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
@media (max-width: 1199px) {
|
||||
.layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
/* details first on narrow screens — they frame the records below */
|
||||
.layout-side {
|
||||
order: -1;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
align-items: start;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.hero {
|
||||
flex-direction: column;
|
||||
padding: 16px;
|
||||
}
|
||||
.hero-actions {
|
||||
width: 100%;
|
||||
}
|
||||
.hero-actions :deep(.ant-btn) {
|
||||
flex: 1;
|
||||
}
|
||||
.kpis {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 575px) {
|
||||
.mt-4 {
|
||||
margin-top: 12px;
|
||||
.customer-detail {
|
||||
gap: 12px;
|
||||
}
|
||||
.stats :deep(.ant-tag) {
|
||||
margin: 0;
|
||||
.hero-avatar {
|
||||
width: 48px !important;
|
||||
height: 48px !important;
|
||||
line-height: 48px !important;
|
||||
font-size: 20px;
|
||||
}
|
||||
.detail-tabs :deep(.ant-tabs-nav) {
|
||||
margin-bottom: 8px;
|
||||
.hero-name {
|
||||
font-size: 18px;
|
||||
}
|
||||
.kpi {
|
||||
padding: 12px 14px;
|
||||
}
|
||||
.kpi-value {
|
||||
font-size: 18px;
|
||||
}
|
||||
.layout-main {
|
||||
padding: 0 12px 12px;
|
||||
}
|
||||
.layout-side {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.detail-tabs :deep(.ant-table-content) {
|
||||
overflow-x: auto;
|
||||
|
||||
Reference in New Issue
Block a user