feat(web): migrate CRM screens to Ant Design Vue with central theme

Adopt ant-design-vue and a shared antdTheme for leads, pipeline, invoices, and shared form controls under strict single-page governance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-18 19:39:59 +03:30
co-authored by Cursor
parent ab538b8304
commit 4abab55a6b
40 changed files with 7529 additions and 11795 deletions
+260 -430
View File
@@ -1,8 +1,31 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue';
import {
CalendarOutlined,
CheckOutlined,
DeleteOutlined,
MoreOutlined,
} from '@ant-design/icons-vue';
import {
Avatar as AAvatar,
Button as AButton,
Card as ACard,
Empty as AEmpty,
Flex as AFlex,
Space as ASpace,
Table as ATable,
Tag as ATag,
Typography,
theme,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
import UiIcon from '@/components/UiIcon.vue';
import type { PipelineDeal, PipelineStage, PipelineUiCopy } from '@/lib/pipeline-board';
import type {
PipelineAccent,
PipelineDeal,
PipelineStage,
PipelineUiCopy,
} from '@/lib/pipeline-board';
import {
DEAL_BOARD_COPY,
formatCurrencyParts,
@@ -26,14 +49,28 @@ const emit = defineEmits<{
bulkDelete: [];
}>();
const { Text: ATypographyText } = Typography;
const { token } = theme.useToken();
const listRoot = ref<HTMLElement | null>(null);
/** فقط یکی از جدول/کارت در DOM باشد تا منوی انتخاب گم نشود */
const useCards = ref(false);
let resizeObs: ResizeObserver | null = null;
const rows = computed(() =>
type Row = {
key: string;
deal: PipelineDeal;
stageTitle: string;
accent: PipelineAccent;
};
function accentColors(accent: PipelineAccent) {
return PIPELINE_ACCENT[accent];
}
const rows = computed<Row[]>(() =>
props.stages.flatMap((stage) =>
stage.deals.map((deal) => ({
key: deal.id,
deal,
stageTitle: stage.title,
accent: stage.color,
@@ -48,6 +85,33 @@ function money(deal: PipelineDeal) {
const hideAmount = computed(() => Boolean(props.copy.hideAmount));
const tableKey = computed(() => (hideAmount.value ? 'pipeline.leads' : 'pipeline.deals'));
const columns = computed<TableColumnsType<Row>>(() => {
const cols: TableColumnsType<Row> = [];
if (props.selectMode) {
cols.push({ key: 'select', title: '', width: 56 });
}
cols.push(
{ key: 'title', title: props.copy.listColTitle },
{ key: 'stage', title: 'مرحله' },
);
if (!hideAmount.value) {
cols.push({ key: 'amount', title: 'مبلغ' });
}
cols.push(
{ key: 'date', title: 'تاریخ' },
{ key: 'actions', title: 'عملیات', width: 72, align: 'center' },
);
return cols;
});
function customRow(record: Row) {
return {
onClick: () => {
if (props.selectMode) emit('toggleSelect', record.deal.id);
},
};
}
onMounted(() => {
const el = listRoot.value;
if (!el || typeof ResizeObserver === 'undefined') return;
@@ -66,445 +130,211 @@ onUnmounted(() => {
</script>
<template>
<div ref="listRoot" class="list" dir="rtl">
<p v-if="!rows.length" class="empty">{{ copy.empty }}</p>
<div ref="listRoot" dir="rtl" :style="{ minWidth: 0 }">
<a-empty v-if="!rows.length" :description="copy.empty" />
<div v-if="rows.length && !useCards" class="tc-row">
<TableColumnsMenu :table-key="tableKey" align="end" />
</div>
<div v-if="rows.length && !useCards" class="table-wrap">
<table v-table-cols="tableKey" class="data-table">
<thead>
<tr>
<th v-if="selectMode" class="tick-col"></th>
<th>{{ copy.listColTitle }}</th>
<th>مرحله</th>
<th v-if="!hideAmount">مبلغ</th>
<th>تاریخ</th>
<th class="menu-col">عملیات</th>
</tr>
</thead>
<tbody>
<tr
v-for="row in rows"
:key="row.deal.id"
:data-card-id="row.deal.id"
:class="{ selected: selectedIds.has(row.deal.id) }"
@click="selectMode && emit('toggleSelect', row.deal.id)"
>
<td v-if="selectMode" class="tick-col" @click.stop>
<button
type="button"
class="tick"
:class="{ on: selectedIds.has(row.deal.id) }"
:aria-label="selectedIds.has(row.deal.id) ? 'لغو انتخاب' : 'انتخاب معامله'"
:aria-pressed="selectedIds.has(row.deal.id)"
@click="emit('toggleSelect', row.deal.id)"
>
<UiIcon v-if="selectedIds.has(row.deal.id)" name="check" :size="14" />
</button>
</td>
<td>
<button
type="button"
class="identity"
@click.stop="
selectMode
? emit('toggleSelect', row.deal.id)
: emit('openDeal', row.deal.id)
"
>
<span
class="badge"
:style="{
background: PIPELINE_ACCENT[row.accent].soft,
color: PIPELINE_ACCENT[row.accent].text,
}"
>{{ row.deal.initials }}</span>
<span class="titles">
<strong>{{ row.deal.title }}</strong>
<em v-if="row.deal.description">{{ row.deal.description }}</em>
</span>
</button>
</td>
<td>
<span
class="stage"
<template v-else-if="!useCards">
<a-flex justify="flex-end" :style="{ marginBottom: '8px' }">
<TableColumnsMenu :table-key="tableKey" align="end" />
</a-flex>
<a-table
:columns="columns"
:data-source="rows"
:pagination="false"
row-key="key"
:custom-row="customRow"
:row-class-name="(record: Row) => (selectedIds.has(record.deal.id) ? 'pipeline-row-selected' : '')"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'select'">
<a-button
type="text"
shape="circle"
:aria-label="selectedIds.has(record.deal.id) ? 'لغو انتخاب' : 'انتخاب معامله'"
@click.stop="emit('toggleSelect', record.deal.id)"
>
<template #icon>
<CheckOutlined v-if="selectedIds.has(record.deal.id)" />
</template>
</a-button>
</template>
<template v-else-if="column.key === 'title'">
<a-flex
:gap="10"
align="center"
:style="{ minWidth: 0, cursor: 'pointer' }"
@click.stop="
selectMode
? emit('toggleSelect', record.deal.id)
: emit('openDeal', record.deal.id)
"
>
<a-avatar
:style="{
background: PIPELINE_ACCENT[row.accent].soft,
color: PIPELINE_ACCENT[row.accent].text,
background: accentColors(record.accent).soft,
color: accentColors(record.accent).text,
flexShrink: 0,
}"
>
<i :style="{ background: PIPELINE_ACCENT[row.accent].solid }" />
{{ row.stageTitle }}
</span>
</td>
<td v-if="!hideAmount">
<span class="amount" dir="ltr">
<strong>{{ money(row.deal).number }}</strong>
<small>{{ money(row.deal).unit }}</small>
</span>
</td>
<td>
<span class="date">
<UiIcon name="calendar" :size="14" />
{{ row.deal.date }}
</span>
</td>
<td class="menu-cell" @click.stop>
<button
v-if="selectMode && selectedIds.has(row.deal.id)"
type="button"
class="menu trash"
aria-label="حذف انتخاب‌شده‌ها"
@click="emit('bulkDelete')"
>
<UiIcon name="trash" :size="18" />
</button>
<button
v-else
type="button"
class="menu"
:aria-label="copy.itemMenuAria"
@click="emit('menuDeal', row.deal.id)"
>
<UiIcon name="dots-v" :size="18" />
</button>
</td>
</tr>
</tbody>
</table>
</div>
{{ record.deal.initials }}
</a-avatar>
<div :style="{ minWidth: 0 }">
<a-typography-text strong ellipsis :style="{ display: 'block', margin: 0 }">
{{ record.deal.title }}
</a-typography-text>
<a-typography-text
v-if="record.deal.description"
type="secondary"
ellipsis
:style="{ display: 'block', margin: 0, fontSize: `${token.fontSizeSM}px` }"
>
{{ record.deal.description }}
</a-typography-text>
</div>
</a-flex>
</template>
<template v-else-if="column.key === 'stage'">
<a-tag
:bordered="false"
:style="{
background: accentColors(record.accent).soft,
color: accentColors(record.accent).text,
}"
>
{{ record.stageTitle }}
</a-tag>
</template>
<template v-else-if="column.key === 'amount'">
<span dir="ltr">
<a-typography-text strong>{{ money(record.deal).number }}</a-typography-text>
<a-typography-text type="secondary" :style="{ marginInlineStart: '6px' }">
{{ money(record.deal).unit }}
</a-typography-text>
</span>
</template>
<template v-else-if="column.key === 'date'">
<a-space :size="6">
<CalendarOutlined />
<span>{{ record.deal.date }}</span>
</a-space>
</template>
<template v-else-if="column.key === 'actions'">
<a-button
v-if="selectMode && selectedIds.has(record.deal.id)"
type="text"
danger
aria-label="حذف انتخاب‌شده‌ها"
@click.stop="emit('bulkDelete')"
>
<template #icon><DeleteOutlined /></template>
</a-button>
<a-button
v-else
type="text"
:aria-label="copy.itemMenuAria"
@click.stop="emit('menuDeal', record.deal.id)"
>
<template #icon><MoreOutlined /></template>
</a-button>
</template>
</template>
</a-table>
</template>
<div v-if="rows.length && useCards" class="cards">
<article
<a-flex v-else vertical :gap="12">
<a-card
v-for="row in rows"
:key="row.deal.id"
class="card"
:class="{ selected: selectedIds.has(row.deal.id) }"
hoverable
:data-card-id="row.deal.id"
:body-style="{ padding: '14px 16px' }"
:style="{
background: selectedIds.has(row.deal.id)
? token.colorPrimaryBg
: token.colorBgContainer,
borderColor: selectedIds.has(row.deal.id)
? token.colorPrimary
: token.colorBorderSecondary,
}"
@dblclick="!selectMode && emit('openDeal', row.deal.id)"
@click="selectMode && emit('toggleSelect', row.deal.id)"
>
<div class="card-top">
<button
v-if="selectMode"
type="button"
class="tick"
:class="{ on: selectedIds.has(row.deal.id) }"
:aria-label="selectedIds.has(row.deal.id) ? 'لغو انتخاب' : 'انتخاب معامله'"
@click.stop="emit('toggleSelect', row.deal.id)"
>
<UiIcon v-if="selectedIds.has(row.deal.id)" name="check" :size="14" />
</button>
<button
type="button"
class="identity"
@click.stop="
selectMode
? emit('toggleSelect', row.deal.id)
: emit('openDeal', row.deal.id)
"
>
<span
class="badge"
<a-flex vertical :gap="12">
<a-flex align="center" :gap="10" :style="{ minWidth: 0 }">
<a-button
v-if="selectMode"
type="text"
shape="circle"
@click.stop="emit('toggleSelect', row.deal.id)"
>
<template #icon>
<CheckOutlined v-if="selectedIds.has(row.deal.id)" />
</template>
</a-button>
<a-avatar
:style="{
background: PIPELINE_ACCENT[row.accent].soft,
color: PIPELINE_ACCENT[row.accent].text,
background: accentColors(row.accent).soft,
color: accentColors(row.accent).text,
}"
>{{ row.deal.initials }}</span>
<span class="titles">
<strong>{{ row.deal.title }}</strong>
<em v-if="row.deal.description">{{ row.deal.description }}</em>
>
{{ row.deal.initials }}
</a-avatar>
<div
:style="{ flex: 1, minWidth: 0, cursor: 'pointer' }"
@click.stop="
selectMode
? emit('toggleSelect', row.deal.id)
: emit('openDeal', row.deal.id)
"
>
<a-typography-text strong ellipsis :style="{ display: 'block', margin: 0 }">
{{ row.deal.title }}
</a-typography-text>
<a-typography-text
v-if="row.deal.description"
type="secondary"
ellipsis
:style="{ display: 'block', margin: 0 }"
>
{{ row.deal.description }}
</a-typography-text>
</div>
<a-button
v-if="selectMode && selectedIds.has(row.deal.id)"
type="text"
danger
@click.stop="emit('bulkDelete')"
>
<template #icon><DeleteOutlined /></template>
</a-button>
<a-button v-else type="text" @click.stop="emit('menuDeal', row.deal.id)">
<template #icon><MoreOutlined /></template>
</a-button>
</a-flex>
<a-tag
:bordered="false"
:style="{
alignSelf: 'flex-start',
background: accentColors(row.accent).soft,
color: accentColors(row.accent).text,
}"
>
{{ row.stageTitle }}
</a-tag>
<a-flex justify="space-between" align="center">
<a-space :size="6">
<CalendarOutlined />
<a-typography-text type="secondary">{{ row.deal.date }}</a-typography-text>
</a-space>
<span v-if="!hideAmount" dir="ltr">
<a-typography-text strong>{{ money(row.deal).number }}</a-typography-text>
<a-typography-text type="secondary" :style="{ marginInlineStart: '6px' }">
{{ money(row.deal).unit }}
</a-typography-text>
</span>
</button>
<button
v-if="selectMode && selectedIds.has(row.deal.id)"
type="button"
class="menu trash"
aria-label="حذف انتخاب‌شده‌ها"
@click.stop="emit('bulkDelete')"
>
<UiIcon name="trash" :size="18" />
</button>
<button
v-else
type="button"
class="menu"
:aria-label="copy.itemMenuAria"
@click.stop="emit('menuDeal', row.deal.id)"
>
<UiIcon name="dots-v" :size="18" />
</button>
</div>
<span
class="stage"
:style="{
background: PIPELINE_ACCENT[row.accent].soft,
color: PIPELINE_ACCENT[row.accent].text,
}"
>
<i :style="{ background: PIPELINE_ACCENT[row.accent].solid }" />
{{ row.stageTitle }}
</span>
<div class="card-foot">
<span class="date">
<UiIcon name="calendar" :size="14" />
{{ row.deal.date }}
</span>
<span v-if="!hideAmount" class="amount" dir="ltr">
<strong>{{ money(row.deal).number }}</strong>
<small>{{ money(row.deal).unit }}</small>
</span>
</div>
</article>
</div>
</a-flex>
</a-flex>
</a-card>
</a-flex>
</div>
</template>
<style scoped>
.list {
min-width: 0;
}
.empty {
margin: 2rem 0;
text-align: center;
color: var(--muted);
font-weight: 700;
}
.table-wrap {
background: #fff;
border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
border-radius: var(--radius);
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
overflow: auto;
}
.data-table {
width: 100%;
border-collapse: collapse;
min-width: 640px;
}
.data-table th,
.data-table td {
padding: 0.85rem 1rem;
text-align: start;
border-bottom: 1px solid #f1f5f9;
vertical-align: middle;
}
.data-table th {
font-size: 0.78rem;
color: #94a3b8;
font-weight: 700;
background: #f8fafc;
}
.data-table tbody tr:last-child td {
border-bottom: 0;
}
.data-table tbody tr:hover td {
background: #f8fafc;
}
.data-table tbody tr.selected td {
background: color-mix(in srgb, var(--accent) 7%, #fff);
}
.tick-col {
width: 2.6rem;
padding-inline: 0.55rem !important;
}
.tick {
width: 1.45rem;
height: 1.45rem;
border-radius: 6px;
border: 2px solid #cbd5e1;
background: #fff;
color: #fff;
display: grid;
place-items: center;
padding: 0;
cursor: pointer;
flex: 0 0 auto;
}
.tick.on {
border-color: var(--accent);
background: var(--accent);
}
.identity {
display: flex;
align-items: center;
gap: 0.7rem;
min-width: 0;
border: 0;
background: transparent;
padding: 0;
cursor: pointer;
text-align: right;
font: inherit;
color: inherit;
}
.badge {
flex: 0 0 auto;
width: 2.2rem;
height: 2.2rem;
border-radius: 999px;
display: grid;
place-items: center;
font-size: 0.7rem;
font-weight: 600;
}
.titles {
display: grid;
gap: 0.1rem;
min-width: 0;
}
.titles strong {
font-size: 0.92rem;
font-weight: 600;
color: var(--ink);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.titles em {
font-style: normal;
color: var(--muted);
font-size: 0.78rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.stage {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.28rem 0.65rem;
border-radius: 999px;
font-size: 0.78rem;
font-weight: 700;
white-space: nowrap;
}
.stage i {
width: 0.45rem;
height: 0.45rem;
border-radius: 999px;
display: block;
}
.amount {
display: grid;
justify-items: start;
gap: 0.05rem;
}
.amount strong {
font-weight: 600;
color: var(--ink);
}
.amount small {
color: var(--muted);
font-size: 0.72rem;
font-weight: 600;
}
.date {
display: inline-flex;
align-items: center;
gap: 0.3rem;
color: var(--muted);
font-size: 0.82rem;
font-weight: 600;
white-space: nowrap;
}
.menu-col,
.menu-cell {
width: 3.2rem;
min-width: 3.2rem;
text-align: center;
}
.menu {
border: 0;
background: transparent;
color: var(--muted);
width: 2rem;
height: 2rem;
padding: 0;
border-radius: var(--radius);
display: inline-grid;
place-items: center;
cursor: pointer;
}
.menu:hover,
.menu:focus-visible {
color: var(--ink);
background: #f1f5f9;
}
.menu.trash {
color: var(--danger);
}
.menu.trash:hover,
.menu.trash:focus-visible {
color: var(--danger);
background: color-mix(in srgb, var(--danger) 10%, #fff);
}
.cards {
display: grid;
gap: 0.7rem;
}
.card {
background: #fff;
border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
border-radius: var(--radius);
padding: 0.95rem 1rem;
display: grid;
gap: 0.7rem;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.card.selected {
border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
background: color-mix(in srgb, var(--accent) 6%, #fff);
}
.card-top {
display: flex;
align-items: center;
gap: 0.55rem;
min-width: 0;
}
.card-top .identity {
flex: 1;
}
.card-foot {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 0.5rem;
}
</style>