feat(web): add Ant workspace tabs and harden page chrome
Persist workspace tabs in the app shell with Ant Design styling aligned to the desktop top bar, and fix tab bar layout flicker on select. Add shared PageHeader components, query helpers, and missing header state across CRM views; improve mobile shell layout and Vite HMR stability on Windows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import axios from 'axios';
|
||||
import type { CustomerGroupColor, CustomerGroupDto, OrgUserDto } from '@mento/shared';
|
||||
import type { CustomerGroupColor, CustomerGroupDto } from '@mento/shared';
|
||||
import { CUSTOMER_GROUP_COLORS } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
groupSwatch,
|
||||
useCustomerGroups,
|
||||
} from '@/lib/customer-groups';
|
||||
import { useOrgUsersQuery } from '@/queries/useOrgUsersQuery';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { UiButton, UiInput, UiModal } from '@/components/ui';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
@@ -25,7 +26,8 @@ const canManage = computed(
|
||||
);
|
||||
|
||||
const { groups, load } = useCustomerGroups();
|
||||
const users = ref<OrgUserDto[]>([]);
|
||||
const usersQuery = useOrgUsersQuery({ enabled: computed(() => props.open) });
|
||||
const users = usersQuery.users;
|
||||
const newName = ref('');
|
||||
const newColor = ref<CustomerGroupColor>('teal');
|
||||
const newAssigneeIds = ref<string[]>([]);
|
||||
@@ -58,15 +60,6 @@ function errorText(e: unknown, fallback: string) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const { data } = await api.get<OrgUserDto[]>('/users');
|
||||
users.value = data.filter((u) => u.isActive !== false);
|
||||
} catch {
|
||||
users.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
function syncAssigneeDraft() {
|
||||
const next: Record<string, string[]> = {};
|
||||
for (const g of groups.value) {
|
||||
@@ -165,7 +158,7 @@ watch(
|
||||
error.value = '';
|
||||
editingId.value = null;
|
||||
listQuery.value = '';
|
||||
void Promise.all([load(true), loadUsers()])
|
||||
void Promise.all([load(true), usersQuery.refetch()])
|
||||
.then(() => syncAssigneeDraft())
|
||||
.catch(() => {
|
||||
error.value = 'بارگذاری گروهها ناموفق بود.';
|
||||
|
||||
@@ -54,8 +54,8 @@ const currentInitial = computed(() => {
|
||||
|
||||
const canSwitch = computed(() => orgs.value.length > 1);
|
||||
const isWorkspace = computed(() => props.variant === 'workspace');
|
||||
/** در حالت workspace منو همیشه باز میشود؛ در حالت پیشفرض فقط وقتی بیش از یکی باشد */
|
||||
const menuEnabled = computed(() => isWorkspace.value || canSwitch.value);
|
||||
/** فقط وقتی بیش از یک محیط باشد نمایش و تعویض فعال است */
|
||||
const menuEnabled = computed(() => canSwitch.value);
|
||||
|
||||
function apiError(e: unknown, fallback: string) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
@@ -163,20 +163,23 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="rootEl" class="org-switch" :class="{ 'org-ws': isWorkspace, compact }">
|
||||
<div
|
||||
v-if="canSwitch"
|
||||
ref="rootEl"
|
||||
class="org-switch"
|
||||
:class="{ 'org-ws': isWorkspace, compact }"
|
||||
>
|
||||
<button
|
||||
class="org-btn"
|
||||
:class="{
|
||||
compact,
|
||||
static: !menuEnabled,
|
||||
'org-ws': isWorkspace,
|
||||
open,
|
||||
}"
|
||||
type="button"
|
||||
:title="currentName"
|
||||
:aria-expanded="open"
|
||||
:aria-haspopup="menuEnabled ? 'listbox' : undefined"
|
||||
:aria-disabled="!menuEnabled"
|
||||
aria-haspopup="listbox"
|
||||
@click.stop="toggle"
|
||||
>
|
||||
<template v-if="isWorkspace">
|
||||
@@ -306,20 +309,24 @@ onUnmounted(() => {
|
||||
.org-btn.org-ws {
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
padding: 0.45rem 0.55rem;
|
||||
border-radius: 16px;
|
||||
padding: 0.5rem 0.65rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
color: #0f172a;
|
||||
text-align: start;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.org-btn.org-ws:hover,
|
||||
.org-btn.org-ws.open {
|
||||
background: #f8fafc;
|
||||
background: #f3f4f6;
|
||||
border-color: #eef2f7;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.org-btn.org-ws.static:hover {
|
||||
background: #f8fafc;
|
||||
background: #f3f4f6;
|
||||
border-color: #eef2f7;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
countSmsParts,
|
||||
} from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import { formatJalaliDay, formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
|
||||
import { formatTahesabBedBes } from '@/lib/tahesab';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
@@ -51,11 +52,11 @@ const emit = defineEmits<{
|
||||
type Panel = 'none' | 'fields' | 'templates';
|
||||
|
||||
const auth = useAuthStore();
|
||||
const feedback = useFeedback();
|
||||
const text = ref('');
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
const done = ref('');
|
||||
const notice = ref('');
|
||||
const sent = ref(false);
|
||||
const panel = ref<Panel>('none');
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
@@ -122,8 +123,7 @@ watch(
|
||||
if (!open) return;
|
||||
text.value = props.defaultText;
|
||||
error.value = '';
|
||||
done.value = '';
|
||||
notice.value = '';
|
||||
sent.value = false;
|
||||
panel.value = 'none';
|
||||
templateName.value = '';
|
||||
templateBody.value = '';
|
||||
@@ -183,7 +183,7 @@ async function loadTemplates() {
|
||||
templates.value = Array.isArray(data) ? data : [];
|
||||
} catch (e) {
|
||||
templates.value = [];
|
||||
error.value = apiMessage(e, 'بارگذاری پیامکهای آماده ناموفق بود.');
|
||||
feedback.fromError(e, 'بارگذاری پیامکهای آماده ناموفق بود.');
|
||||
} finally {
|
||||
templatesLoading.value = false;
|
||||
}
|
||||
@@ -284,7 +284,6 @@ function insertInto(
|
||||
|
||||
function openPanel(next: Panel) {
|
||||
panel.value = panel.value === next ? 'none' : next;
|
||||
notice.value = '';
|
||||
if (panel.value === 'templates') {
|
||||
error.value = '';
|
||||
void loadTemplates();
|
||||
@@ -294,7 +293,7 @@ function openPanel(next: Panel) {
|
||||
function applyTemplate(item: SmsTemplateDto) {
|
||||
text.value = item.body;
|
||||
error.value = '';
|
||||
notice.value = `قالب «${item.name}» در متن پیام قرار گرفت.`;
|
||||
feedback.info(`قالب «${item.name}» در متن پیام قرار گرفت.`);
|
||||
}
|
||||
|
||||
async function saveTemplate() {
|
||||
@@ -303,15 +302,14 @@ async function saveTemplate() {
|
||||
if (!canSaveTemplate.value || !name || body.length < 2) return;
|
||||
savingTemplate.value = true;
|
||||
error.value = '';
|
||||
notice.value = '';
|
||||
try {
|
||||
const { data } = await api.post<SmsTemplateDto[]>('/sms-templates', { name, body });
|
||||
templates.value = Array.isArray(data) ? data : [];
|
||||
templateName.value = '';
|
||||
templateBody.value = '';
|
||||
notice.value = `پیامک آماده «${name}» ذخیره شد.`;
|
||||
feedback.success(`پیامک آماده «${name}» ذخیره شد.`);
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'ذخیره پیامک آماده ناموفق بود.');
|
||||
feedback.fromError(e, 'ذخیره پیامک آماده ناموفق بود.');
|
||||
} finally {
|
||||
savingTemplate.value = false;
|
||||
}
|
||||
@@ -320,45 +318,38 @@ async function saveTemplate() {
|
||||
async function removeTemplate(item: SmsTemplateDto) {
|
||||
if (!confirm(`پیامک آماده «${item.name}» حذف شود؟`)) return;
|
||||
error.value = '';
|
||||
notice.value = '';
|
||||
try {
|
||||
const { data } = await api.delete<SmsTemplateDto[]>(`/sms-templates/${item.id}`);
|
||||
templates.value = Array.isArray(data) ? data : [];
|
||||
notice.value = `«${item.name}» حذف شد.`;
|
||||
feedback.success(`«${item.name}» حذف شد.`);
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'حذف پیامک آماده ناموفق بود.');
|
||||
feedback.fromError(e, 'حذف پیامک آماده ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
function apiMessage(e: unknown, fallback: string) {
|
||||
if (!axios.isAxiosError(e)) return fallback;
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
if (Array.isArray(msg)) return msg.join('، ') || fallback;
|
||||
if (typeof msg === 'string' && msg.trim()) return msg;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
async function send(force = false) {
|
||||
if (!props.endpoint || busy.value || done.value) return;
|
||||
if (!props.endpoint || busy.value || sent.value) return;
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
notice.value = '';
|
||||
try {
|
||||
await api.post(props.endpoint, { text: text.value, ...(force ? { force: true } : {}) });
|
||||
done.value = 'پیامک ارسال شد.';
|
||||
sent.value = true;
|
||||
feedback.success('پیامک ارسال شد.');
|
||||
emit('sent');
|
||||
void loadHistory();
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e) && e.response?.status === 409) {
|
||||
const msg = apiMessage(e, 'قبلاً پیامک تبریک فرستاده شده است. دوباره بفرستیم؟');
|
||||
const msg =
|
||||
(e.response?.data as { message?: string } | undefined)?.message?.trim() ||
|
||||
'قبلاً پیامک تبریک فرستاده شده است. دوباره بفرستیم؟';
|
||||
if (confirm(msg)) {
|
||||
busy.value = false;
|
||||
await send(true);
|
||||
return;
|
||||
}
|
||||
error.value = msg;
|
||||
feedback.warning(msg);
|
||||
} else {
|
||||
error.value = apiMessage(e, 'ارسال پیامک ناموفق بود.');
|
||||
feedback.fromError(e, 'ارسال پیامک ناموفق بود.');
|
||||
}
|
||||
} finally {
|
||||
busy.value = false;
|
||||
@@ -541,15 +532,13 @@ function statusLabel(status: OutboundSmsLogDto['status']) {
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="err">{{ error }}</p>
|
||||
<p v-else-if="notice" class="ok">{{ notice }}</p>
|
||||
<p v-if="done" class="ok">{{ done }}</p>
|
||||
|
||||
<template #footer>
|
||||
<UiButton variant="ghost" :disabled="busy" @click="emit('close')">بستن</UiButton>
|
||||
<UiButton
|
||||
variant="primary"
|
||||
:loading="busy"
|
||||
:disabled="busy || !!done || !phone || text.trim().length < 2"
|
||||
:disabled="busy || sent || !phone || text.trim().length < 2"
|
||||
@click="send"
|
||||
>
|
||||
ارسال پیامک
|
||||
|
||||
@@ -141,8 +141,9 @@ const statusMessage = computed(() => {
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
border-radius: 1rem;
|
||||
border: 1px solid rgb(16 137 125 / 0.28);
|
||||
box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
|
||||
border: 1px solid color-mix(in srgb, var(--accent, #10897d) 22%, #e2e8f0);
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 2px rgb(15 23 42 / 0.03);
|
||||
}
|
||||
|
||||
.home-hero__gradient,
|
||||
@@ -159,55 +160,49 @@ const statusMessage = computed(() => {
|
||||
|
||||
.home-hero__gradient {
|
||||
background:
|
||||
linear-gradient(
|
||||
115deg,
|
||||
#eef8f7 0%,
|
||||
#d0ebe8 28%,
|
||||
#c5e6e2 55%,
|
||||
#eef8f7 78%,
|
||||
#ffffff 100%
|
||||
);
|
||||
radial-gradient(
|
||||
120% 140% at 100% 0%,
|
||||
color-mix(in srgb, var(--accent, #10897d) 16%, white) 0%,
|
||||
transparent 55%
|
||||
),
|
||||
radial-gradient(
|
||||
90% 120% at 0% 100%,
|
||||
color-mix(in srgb, var(--accent, #10897d) 10%, white) 0%,
|
||||
transparent 50%
|
||||
),
|
||||
linear-gradient(180deg, var(--accent-subtle, #eef8f7) 0%, #ffffff 72%);
|
||||
}
|
||||
|
||||
.home-hero__pattern {
|
||||
opacity: 0.45;
|
||||
background-image:
|
||||
radial-gradient(circle at 1px 1px, rgba(16, 137, 125, 0.28) 1px, transparent 0),
|
||||
linear-gradient(
|
||||
135deg,
|
||||
rgba(16, 137, 125, 0.08) 25%,
|
||||
transparent 25%,
|
||||
transparent 50%,
|
||||
rgba(16, 137, 125, 0.08) 50%,
|
||||
rgba(16, 137, 125, 0.08) 75%,
|
||||
transparent 75%,
|
||||
transparent
|
||||
);
|
||||
background-size:
|
||||
18px 18px,
|
||||
28px 28px;
|
||||
mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.25));
|
||||
opacity: 0.32;
|
||||
background-image: radial-gradient(
|
||||
circle at 1px 1px,
|
||||
color-mix(in srgb, var(--accent, #10897d) 26%, transparent) 1px,
|
||||
transparent 0
|
||||
);
|
||||
background-size: 16px 16px;
|
||||
mask-image: linear-gradient(to left, rgb(0 0 0 / 0.5), rgb(0 0 0 / 0.06));
|
||||
}
|
||||
|
||||
.home-hero__orb {
|
||||
border-radius: 999px;
|
||||
filter: blur(48px);
|
||||
filter: blur(56px);
|
||||
}
|
||||
|
||||
.home-hero__orb--start {
|
||||
inset-inline-end: -5rem;
|
||||
top: -6rem;
|
||||
width: 13rem;
|
||||
height: 13rem;
|
||||
background: rgb(22 193 168 / 0.22);
|
||||
inset-inline-end: -4.5rem;
|
||||
top: -5.5rem;
|
||||
width: 12rem;
|
||||
height: 12rem;
|
||||
background: color-mix(in srgb, var(--accent, #10897d) 22%, transparent);
|
||||
}
|
||||
|
||||
.home-hero__orb--end {
|
||||
inset-inline-start: -4rem;
|
||||
bottom: -5rem;
|
||||
width: 12rem;
|
||||
height: 12rem;
|
||||
background: rgb(16 137 125 / 0.16);
|
||||
inset-inline-start: -3.5rem;
|
||||
bottom: -4.5rem;
|
||||
width: 11rem;
|
||||
height: 11rem;
|
||||
background: color-mix(in srgb, var(--accent-deep, #0a5c54) 14%, transparent);
|
||||
}
|
||||
|
||||
.home-hero__row {
|
||||
@@ -253,8 +248,13 @@ const statusMessage = computed(() => {
|
||||
justify-content: center;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 800;
|
||||
color: #eef8f7;
|
||||
background: linear-gradient(160deg, #16c1a8 0%, #10897d 100%);
|
||||
color: #fff;
|
||||
background: linear-gradient(
|
||||
160deg,
|
||||
color-mix(in srgb, var(--accent, #10897d) 82%, white) 0%,
|
||||
var(--accent, #10897d) 48%,
|
||||
var(--accent-deep, #0a5c54) 100%
|
||||
);
|
||||
letter-spacing: -0.02em;
|
||||
user-select: none;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ const statusMessage = computed(() => {
|
||||
width: 0.7rem;
|
||||
height: 0.7rem;
|
||||
border-radius: 999px;
|
||||
background: #10897d;
|
||||
background: var(--accent, #10897d);
|
||||
border: 2px solid #fff;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ const statusMessage = computed(() => {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
color: rgb(4 120 87 / 0.8);
|
||||
color: var(--accent-deep, #0a5c54);
|
||||
}
|
||||
|
||||
.home-hero__title {
|
||||
@@ -316,7 +316,7 @@ const statusMessage = computed(() => {
|
||||
border: 1px solid rgb(255 255 255 / 0.8);
|
||||
border-radius: 1rem;
|
||||
box-shadow:
|
||||
0 4px 12px rgb(6 78 59 / 0.05),
|
||||
0 4px 12px color-mix(in srgb, var(--accent, #10897d) 8%, transparent),
|
||||
0 1px 2px rgb(15 23 42 / 0.04);
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
@@ -324,10 +324,10 @@ const statusMessage = computed(() => {
|
||||
}
|
||||
|
||||
.home-hero__ask:focus-within {
|
||||
border-color: #16c1a8;
|
||||
border-color: color-mix(in srgb, var(--accent, #10897d) 55%, #e2e8f0);
|
||||
box-shadow:
|
||||
0 0 0 2px rgb(16 137 125 / 0.18),
|
||||
0 4px 12px rgb(10 92 84 / 0.06);
|
||||
0 0 0 2px color-mix(in srgb, var(--accent, #10897d) 16%, transparent),
|
||||
0 4px 12px color-mix(in srgb, var(--accent-deep, #0a5c54) 8%, transparent);
|
||||
}
|
||||
|
||||
.home-hero__ask-input {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
CalendarOutlined,
|
||||
CheckCircleOutlined,
|
||||
@@ -18,6 +19,17 @@ const props = defineProps<{
|
||||
formatChange: (value: number | null) => string;
|
||||
}>();
|
||||
|
||||
/** ستونها با تعداد کارت همخوان باشد تا ردیف تمامعرض پر شود */
|
||||
const gridClass = computed(() => {
|
||||
const n = props.kpis.length;
|
||||
if (n <= 1) return 'grid grid-cols-1 gap-4';
|
||||
if (n === 2) return 'grid grid-cols-1 sm:grid-cols-2 gap-4';
|
||||
if (n === 3) return 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4';
|
||||
if (n === 4) return 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4';
|
||||
if (n === 5) return 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 gap-4';
|
||||
return 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4';
|
||||
});
|
||||
|
||||
function salesAmount(value: number) {
|
||||
return new Intl.NumberFormat('fa-IR').format(value);
|
||||
}
|
||||
@@ -43,11 +55,11 @@ function pillClass(kpi: HomeDashboardKpiDto) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4">
|
||||
<section :class="gridClass">
|
||||
<div
|
||||
v-for="kpi in kpis"
|
||||
:key="kpi.key"
|
||||
class="rounded-2xl p-4 border shadow-sm flex flex-col justify-between transition duration-200 hover:-translate-y-0.5"
|
||||
class="min-w-0 w-full rounded-2xl p-4 border shadow-sm flex flex-col justify-between transition duration-200 hover:-translate-y-0.5"
|
||||
:class="
|
||||
kpi.key === 'overdue'
|
||||
? 'border-rose-200/70 bg-gradient-to-b from-white to-rose-50/20'
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup lang="ts" generic="T extends string">
|
||||
/**
|
||||
* فیلتر چیپی برای نوار ابزار PageHeader (اسلات quick-filters).
|
||||
*
|
||||
* برای فیلترهایی با گزینههای کم و ثابت (حدود ۲ تا ۶ مورد، مثل تیپ DISC):
|
||||
* همه گزینهها همیشه دیده میشوند، با یک کلیک روشن/خاموش میشوند و
|
||||
* کشوی «فیلتر» لازم ندارند. «همه» یعنی آرایهٔ خالی.
|
||||
* گزینههای زیاد یا پویا (منبع، مسئول…) همچنان a-select هستند.
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { Flex as AFlex, Tag as ATag, Typography, theme } from 'ant-design-vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
label?: string;
|
||||
options: Array<{ value: T; label: string }>;
|
||||
/** false = فقط یک گزینه در هر لحظه */
|
||||
multiple?: boolean;
|
||||
allLabel?: string;
|
||||
/**
|
||||
* false = بدون چیپ «همه»؛ با multiple=false همیشه دقیقاً یک گزینه روشن است
|
||||
* (مثل مرتبسازی: نام / جدیدترین).
|
||||
*/
|
||||
showAll?: boolean;
|
||||
}>(),
|
||||
{ label: undefined, multiple: true, allLabel: 'همه', showAll: true },
|
||||
);
|
||||
|
||||
const model = defineModel<T[]>({ default: () => [] });
|
||||
|
||||
const ACheckableTag = ATag.CheckableTag;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
function chipStyle(checked: boolean) {
|
||||
const t = token.value;
|
||||
return {
|
||||
marginInlineEnd: 0,
|
||||
paddingInline: `${t.paddingSM}px`,
|
||||
lineHeight: `${t.controlHeightSM - t.lineWidth * 2}px`,
|
||||
border: `${t.lineWidth}px ${t.lineType} ${checked ? t.colorPrimary : t.colorBorder}`,
|
||||
fontWeight: checked ? t.fontWeightStrong : undefined,
|
||||
userSelect: 'none' as const,
|
||||
};
|
||||
}
|
||||
|
||||
const allChecked = computed(() => model.value.length === 0);
|
||||
|
||||
function toggle(value: T, checked: boolean) {
|
||||
if (!props.multiple) {
|
||||
// انتخاب اجباری: کلیک روی چیپ روشن چیزی را خاموش نمیکند
|
||||
if (!checked && !props.showAll) return;
|
||||
model.value = checked ? [value] : [];
|
||||
return;
|
||||
}
|
||||
const next = checked
|
||||
? [...model.value, value]
|
||||
: model.value.filter((v) => v !== value);
|
||||
// ترتیب ثابت مطابق options، تا مقدار URL/ذخیرهشده پایدار بماند
|
||||
model.value = props.options.map((o) => o.value).filter((v) => next.includes(v));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex align="center" wrap="wrap" :gap="token.marginXXS" role="group" :aria-label="label">
|
||||
<a-typography-text v-if="label" type="secondary" :style="{ marginInlineEnd: `${token.marginXXS}px` }">
|
||||
{{ label }}
|
||||
</a-typography-text>
|
||||
<a-checkable-tag
|
||||
v-if="showAll"
|
||||
:checked="allChecked"
|
||||
:style="chipStyle(allChecked)"
|
||||
@change="model = []"
|
||||
>
|
||||
{{ allLabel }}
|
||||
</a-checkable-tag>
|
||||
<a-checkable-tag
|
||||
v-for="opt in options"
|
||||
:key="opt.value"
|
||||
:checked="model.includes(opt.value)"
|
||||
:style="chipStyle(model.includes(opt.value))"
|
||||
@change="(checked: boolean) => toggle(opt.value, checked)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</a-checkable-tag>
|
||||
</a-flex>
|
||||
</template>
|
||||
@@ -0,0 +1,489 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* هدر یکپارچهٔ صفحههای لیستی (مخاطبین، مسیر فروش، لیدها، روتین و…).
|
||||
*
|
||||
* چهار ردیف ثابت؛ هر صفحه فقط ردیفهایی را که لازم دارد روشن میکند:
|
||||
* ۱. عنوان و اکشنها — همیشه: آیکن + عنوان + شمارنده | «⋯» + اکشن فرعی + یک دکمهٔ اصلی
|
||||
* ۲. تبها — فقط با prop `tabs`
|
||||
* ۳. نوار ابزار — جستجو → سلکتهای سریع → «فیلتر» → ذخیرهشده | ستونها → نمای نمایش
|
||||
* ۳ب. ردیف چیپ — اسلات chips (FilterChips فیلترها) | اسلات chips-end (مرتبسازی چیپی)
|
||||
* ۴. فیلترهای فعال — فقط وقتی `activeFilters` خالی نیست
|
||||
*
|
||||
* ظاهر فقط از توکنهای تم Ant (theme.useToken) میآید؛ CSS دستی ندارد.
|
||||
*/
|
||||
import { computed, h, onBeforeUnmount, ref, useSlots, type Component } from 'vue';
|
||||
import { useRouter, type RouteLocationRaw } from 'vue-router';
|
||||
import {
|
||||
Badge as ABadge,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
ConfigProvider as AConfigProvider,
|
||||
Divider as ADivider,
|
||||
Dropdown as ADropdown,
|
||||
Flex as AFlex,
|
||||
Input as AInput,
|
||||
Menu as AMenu,
|
||||
Segmented as ASegmented,
|
||||
TabPane as ATabPane,
|
||||
Tabs as ATabs,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import type { MenuProps } from 'ant-design-vue';
|
||||
import {
|
||||
ArrowRightOutlined,
|
||||
FilterOutlined,
|
||||
MoreOutlined,
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import type {
|
||||
PageHeaderActiveFilter,
|
||||
PageHeaderMenuItem,
|
||||
PageHeaderTab,
|
||||
PageHeaderViewOption,
|
||||
} from './types';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/* ردیف ۱ */
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
icon?: Component;
|
||||
/** شمارندهٔ کل کنار عنوان */
|
||||
count?: number;
|
||||
/** صفحههای جزئیات: دکمهٔ بازگشت قبل از عنوان */
|
||||
backTo?: RouteLocationRaw;
|
||||
/** دکمهٔ بازگشت بدون مسیر ثابت؛ صفحه خودش رویداد back را هندل میکند (مثلاً چک تغییرات ذخیرهنشده) */
|
||||
backable?: boolean;
|
||||
/** متن دکمهٔ اصلی؛ خالی = بدون دکمهٔ اصلی */
|
||||
primaryLabel?: string;
|
||||
primaryIcon?: Component;
|
||||
primaryDisabled?: boolean;
|
||||
primaryLoading?: boolean;
|
||||
/** آیتمهای منوی «⋯» */
|
||||
menuItems?: PageHeaderMenuItem[];
|
||||
|
||||
/* ردیف ۲ */
|
||||
tabs?: PageHeaderTab[];
|
||||
|
||||
/* ردیف ۳ */
|
||||
searchable?: boolean;
|
||||
searchPlaceholder?: string;
|
||||
/** نمایش دکمهٔ «فیلتر» (کشوی فیلترهای پیشرفته) */
|
||||
filterable?: boolean;
|
||||
/** تعداد فیلترهای پیشرفتهٔ فعال روی دکمهٔ «فیلتر» */
|
||||
filterCount?: number;
|
||||
viewOptions?: PageHeaderViewOption[];
|
||||
|
||||
/* ردیف ۴ */
|
||||
activeFilters?: PageHeaderActiveFilter[];
|
||||
resultCount?: number;
|
||||
totalCount?: number;
|
||||
}>(),
|
||||
{
|
||||
subtitle: undefined,
|
||||
icon: undefined,
|
||||
count: undefined,
|
||||
backTo: undefined,
|
||||
backable: false,
|
||||
primaryLabel: undefined,
|
||||
primaryIcon: undefined,
|
||||
primaryDisabled: false,
|
||||
primaryLoading: false,
|
||||
menuItems: () => [],
|
||||
tabs: () => [],
|
||||
searchable: false,
|
||||
searchPlaceholder: 'جستجو…',
|
||||
filterable: false,
|
||||
filterCount: 0,
|
||||
viewOptions: () => [],
|
||||
activeFilters: () => [],
|
||||
resultCount: undefined,
|
||||
totalCount: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
primary: [];
|
||||
back: [];
|
||||
menu: [key: string];
|
||||
filters: [];
|
||||
searchSubmit: [value: string];
|
||||
removeFilter: [key: string];
|
||||
clearFilters: [];
|
||||
}>();
|
||||
|
||||
const activeTab = defineModel<string>('activeTab');
|
||||
const search = defineModel<string>('search', { default: '' });
|
||||
const view = defineModel<string>('view');
|
||||
|
||||
const slots = useSlots();
|
||||
const router = useRouter();
|
||||
const { token } = theme.useToken();
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
|
||||
const fa = (n: number) => n.toLocaleString('fa-IR');
|
||||
|
||||
/* ---------- موبایل ---------- */
|
||||
/**
|
||||
* matchMedia همزمان (نه Grid.useBreakpoint که تا بعد از mount خالی است)؛
|
||||
* در عرض کم، عنوان همیشه ردیف خودش را دارد و اکشنها زیرش میآیند تا با رسیدن
|
||||
* دیتای دیرهنگام (شمارنده، زیرعنوان) ارتفاع هدر عوض نشود و صفحه نپرد.
|
||||
*/
|
||||
const narrowMq = typeof window !== 'undefined' ? window.matchMedia('(max-width: 767.98px)') : null;
|
||||
const narrow = ref(narrowMq?.matches ?? false);
|
||||
const onNarrowChange = (e: MediaQueryListEvent) => {
|
||||
narrow.value = e.matches;
|
||||
};
|
||||
narrowMq?.addEventListener('change', onNarrowChange);
|
||||
onBeforeUnmount(() => narrowMq?.removeEventListener('change', onNarrowChange));
|
||||
|
||||
const hasActions = computed(
|
||||
() => props.menuItems.length > 0 || !!props.primaryLabel || !!slots.actions || !!slots.primary,
|
||||
);
|
||||
|
||||
/* ---------- layout (همه از توکن) ---------- */
|
||||
const rowPad = computed(() => `${token.value.paddingSM}px ${token.value.paddingMD}px`);
|
||||
|
||||
const hasTabs = computed(() => props.tabs.length > 0);
|
||||
|
||||
const hasToolbar = computed(
|
||||
() =>
|
||||
props.searchable ||
|
||||
props.filterable ||
|
||||
props.viewOptions.length > 0 ||
|
||||
!!slots['quick-filters'] ||
|
||||
!!slots['saved-filters'] ||
|
||||
!!slots['toolbar-end'],
|
||||
);
|
||||
|
||||
/** ردیف ۳ب: فیلترهای چیپی (FilterChips) — شروع: فیلترها، پایان: مرتبسازی */
|
||||
const hasChipRow = computed(() => !!slots.chips || !!slots['chips-end']);
|
||||
|
||||
const chipRowStyle = computed(() => {
|
||||
const t = token.value;
|
||||
// زیر نوار ابزار: فقط پدینگ پایین؛ اگر نوار ابزار نباشد خودش ردیف کامل است
|
||||
if (hasToolbar.value) return { padding: `0 ${t.paddingMD}px ${t.paddingSM}px` };
|
||||
return {
|
||||
padding: rowPad.value,
|
||||
borderTop: hasTabs.value ? undefined : `${t.lineWidth}px ${t.lineType} ${t.colorBorderSecondary}`,
|
||||
};
|
||||
});
|
||||
|
||||
const hasChips = computed(() => props.activeFilters.length > 0);
|
||||
|
||||
/** تبها آخرین ردیف کارتاند ← خط زیر نوار تب لازم نیست (بوردر کارت هست) */
|
||||
const tabsAreLast = computed(() => !hasToolbar.value && !hasChipRow.value && !hasChips.value);
|
||||
|
||||
const tabsTheme = computed(() =>
|
||||
tabsAreLast.value
|
||||
? // خط nav-list در استایل Tabs از colorSplit میآید
|
||||
{ components: { Tabs: { colorSplit: 'transparent' } } }
|
||||
: {},
|
||||
);
|
||||
|
||||
const toolbarStyle = computed(() => ({
|
||||
padding: rowPad.value,
|
||||
// بدون ردیف تب، خط جداکننده را خود نوار ابزار میکشد
|
||||
borderTop: hasTabs.value ? undefined : `${token.value.lineWidth}px ${token.value.lineType} ${token.value.colorBorderSecondary}`,
|
||||
}));
|
||||
|
||||
const chipsStyle = computed(() => ({
|
||||
padding: `0 ${token.value.paddingMD}px ${token.value.paddingSM}px`,
|
||||
}));
|
||||
|
||||
const iconTileStyle = computed(() => ({
|
||||
width: `${token.value.controlHeight}px`,
|
||||
height: `${token.value.controlHeight}px`,
|
||||
borderRadius: `${token.value.borderRadius}px`,
|
||||
background: token.value.colorPrimaryBg,
|
||||
color: token.value.colorPrimary,
|
||||
fontSize: `${token.value.fontSizeLG}px`,
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
flexShrink: 0,
|
||||
}));
|
||||
|
||||
/* ---------- شمارندهها ---------- */
|
||||
function countStyle(kind: 'neutral' | 'active' | 'warning') {
|
||||
const t = token.value;
|
||||
const map = {
|
||||
neutral: { bg: t.colorFillSecondary, fg: t.colorTextSecondary },
|
||||
active: { bg: t.colorPrimaryBg, fg: t.colorPrimary },
|
||||
warning: { bg: t.colorWarningBg, fg: t.colorWarningText },
|
||||
} as const;
|
||||
return {
|
||||
backgroundColor: map[kind].bg,
|
||||
color: map[kind].fg,
|
||||
boxShadow: 'none',
|
||||
fontWeight: t.fontWeightStrong,
|
||||
fontVariantNumeric: 'tabular-nums',
|
||||
};
|
||||
}
|
||||
|
||||
function tabCountKind(tab: PageHeaderTab): 'neutral' | 'active' | 'warning' {
|
||||
if (tab.tone === 'warning' && (tab.count ?? 0) > 0) return 'warning';
|
||||
return tab.key === activeTab.value ? 'active' : 'neutral';
|
||||
}
|
||||
|
||||
/* ---------- منوی «⋯» ---------- */
|
||||
const menuAntItems = computed<NonNullable<MenuProps['items']>>(() => {
|
||||
const out: NonNullable<MenuProps['items']> = [];
|
||||
for (const item of props.menuItems) {
|
||||
if (item.dividerBefore && out.length) out.push({ type: 'divider' });
|
||||
out.push({
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
danger: item.danger,
|
||||
disabled: item.disabled,
|
||||
icon: item.icon ? () => h(item.icon as Component) : undefined,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
const onMenuClick: MenuProps['onClick'] = (info) => emit('menu', String(info.key));
|
||||
|
||||
/* ---------- نمای نمایش ---------- */
|
||||
const segOptions = computed(() =>
|
||||
props.viewOptions.map((o) => ({ value: o.value, payload: o })),
|
||||
);
|
||||
|
||||
/* ---------- ردیف ۴ ---------- */
|
||||
function onTagClose(e: Event, key: string) {
|
||||
// a-tag خودش را مخفی میکند؛ کنترل دست صفحه بماند
|
||||
e.preventDefault();
|
||||
emit('removeFilter', key);
|
||||
}
|
||||
|
||||
const resultText = computed(() => {
|
||||
if (props.resultCount == null) return '';
|
||||
if (props.totalCount == null) return `${fa(props.resultCount)} نتیجه`;
|
||||
return `${fa(props.resultCount)} نتیجه از ${fa(props.totalCount)}`;
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
emit('back');
|
||||
if (props.backTo) void router.push(props.backTo);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- overflow: خط و ink-bar تبها از گوشههای گرد کارت بیرون نزنند -->
|
||||
<a-card :bordered="true" :body-style="{ padding: 0 }" :style="{ overflow: 'hidden' }" dir="rtl">
|
||||
<!-- ۱ · عنوان و اکشنها -->
|
||||
<a-flex
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.margin"
|
||||
:style="{ padding: rowPad, minHeight: `${token.controlHeight + token.paddingSM * 2}px` }"
|
||||
>
|
||||
<a-flex
|
||||
align="center"
|
||||
:gap="token.marginSM"
|
||||
:style="{ minWidth: 0, flexBasis: narrow && hasActions ? '100%' : undefined }"
|
||||
>
|
||||
<a-button v-if="backTo || backable" aria-label="بازگشت" title="بازگشت" @click="goBack">
|
||||
<template #icon><ArrowRightOutlined /></template>
|
||||
</a-button>
|
||||
|
||||
<span v-if="icon || $slots.icon" :style="iconTileStyle" aria-hidden="true">
|
||||
<slot name="icon"><component :is="icon" /></slot>
|
||||
</span>
|
||||
|
||||
<a-flex vertical :style="{ minWidth: 0 }">
|
||||
<a-flex align="center" wrap="wrap" :gap="token.marginXS">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }" :ellipsis="true" :title="title">
|
||||
{{ title }}
|
||||
</a-typography-title>
|
||||
<a-badge
|
||||
v-if="count != null"
|
||||
:count="fa(count)"
|
||||
:number-style="countStyle('neutral')"
|
||||
:overflow-count="Number.MAX_SAFE_INTEGER"
|
||||
/>
|
||||
<!-- مثلاً انتخاب مسیر فروش: زمینهٔ صفحه، نه فیلتر -->
|
||||
<slot name="title-extra" />
|
||||
</a-flex>
|
||||
<a-typography-text
|
||||
v-if="subtitle || $slots.subtitle"
|
||||
type="secondary"
|
||||
:style="{ fontSize: `${token.fontSizeSM}px` }"
|
||||
>
|
||||
<slot name="subtitle">{{ subtitle }}</slot>
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
|
||||
<!-- a-flex نه a-space: Space تا بعد از mount از gap استفاده نمیکند و فریم اول پرش دارد -->
|
||||
<a-flex v-if="hasActions" align="center" wrap="wrap" :gap="token.marginXS">
|
||||
<a-dropdown v-if="menuItems.length" :trigger="['click']" placement="bottomLeft">
|
||||
<a-button aria-label="اکشنهای بیشتر" title="بیشتر">
|
||||
<template #icon><MoreOutlined /></template>
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu :items="menuAntItems" @click="onMenuClick" />
|
||||
</template>
|
||||
</a-dropdown>
|
||||
|
||||
<!-- حداکثر یک دکمهٔ فرعی (default) یا دکمهٔ آیکنی -->
|
||||
<slot name="actions" />
|
||||
|
||||
<slot name="primary">
|
||||
<a-button
|
||||
v-if="primaryLabel"
|
||||
type="primary"
|
||||
:disabled="primaryDisabled"
|
||||
:loading="primaryLoading"
|
||||
@click="emit('primary')"
|
||||
>
|
||||
<template #icon><component :is="primaryIcon ?? PlusOutlined" /></template>
|
||||
{{ primaryLabel }}
|
||||
</a-button>
|
||||
</slot>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
|
||||
<!-- ۲ · تبها -->
|
||||
<!--
|
||||
وقتی تبها آخرین ردیف کارتاند، خط زیر نوار تب با بوردر کارت دوتا میشود؛
|
||||
رنگ خط تب را فقط برای همین Tabs شفاف میکنیم (توکن کامپوننت، نه CSS).
|
||||
-->
|
||||
<!-- direction صریح: پیشفرض prop در ConfigProvider «ltr» است و از والد ارث نمیبرد؛
|
||||
بدون آن تبها LTR حساب میشوند (جای ink-bar میپرد و اسکرول تبها برعکس میشود) -->
|
||||
<a-config-provider v-if="hasTabs" direction="rtl" :theme="tabsTheme">
|
||||
<a-tabs
|
||||
v-model:activeKey="activeTab"
|
||||
:tab-bar-style="{ margin: 0, paddingInline: `${token.paddingMD}px` }"
|
||||
>
|
||||
<a-tab-pane v-for="tab in tabs" :key="tab.key" :disabled="tab.disabled">
|
||||
<template #tab>
|
||||
<a-flex align="center" :gap="token.marginXS">
|
||||
<component :is="tab.icon" v-if="tab.icon" />
|
||||
<span>{{ tab.label }}</span>
|
||||
<a-badge
|
||||
v-if="tab.count != null"
|
||||
:count="fa(tab.count)"
|
||||
:number-style="countStyle(tabCountKind(tab))"
|
||||
:overflow-count="Number.MAX_SAFE_INTEGER"
|
||||
/>
|
||||
</a-flex>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-config-provider>
|
||||
|
||||
<!-- ۳ · نوار ابزار -->
|
||||
<a-flex
|
||||
v-if="hasToolbar"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.marginSM"
|
||||
:style="toolbarStyle"
|
||||
>
|
||||
<a-flex align="center" wrap="wrap" :gap="token.marginXS" :style="{ minWidth: 0, flex: '1 1 auto' }">
|
||||
<a-input
|
||||
v-if="searchable"
|
||||
v-model:value="search"
|
||||
allow-clear
|
||||
:placeholder="searchPlaceholder"
|
||||
:style="{ flex: '1 1 220px', minWidth: '200px', maxWidth: '320px' }"
|
||||
@press-enter="emit('searchSubmit', search)"
|
||||
>
|
||||
<template #prefix>
|
||||
<SearchOutlined :style="{ color: token.colorTextTertiary }" />
|
||||
</template>
|
||||
</a-input>
|
||||
|
||||
<!--
|
||||
فقط کنترلهای «کادری» (a-select) برای گزینههای زیاد/پویا، حداکثر دو تا.
|
||||
گزینههای کم و ثابت (DISC، اولویت…) و مرتبسازی → اسلاتهای chips / chips-end.
|
||||
بقیه داخل کشوی «فیلتر».
|
||||
-->
|
||||
<slot name="quick-filters" />
|
||||
|
||||
<a-button
|
||||
v-if="filterable"
|
||||
:type="filterCount ? 'primary' : 'default'"
|
||||
:ghost="!!filterCount"
|
||||
@click="emit('filters')"
|
||||
>
|
||||
<template #icon><FilterOutlined /></template>
|
||||
فیلتر
|
||||
<a-badge
|
||||
v-if="filterCount"
|
||||
:count="fa(filterCount)"
|
||||
:number-style="{ backgroundColor: token.colorPrimary, boxShadow: 'none' }"
|
||||
:style="{ marginInlineStart: `${token.marginXXS}px` }"
|
||||
/>
|
||||
</a-button>
|
||||
|
||||
<!-- SavedFiltersBar compact -->
|
||||
<slot name="saved-filters" />
|
||||
</a-flex>
|
||||
|
||||
<a-flex
|
||||
v-if="$slots['toolbar-end'] || viewOptions.length"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.marginXS"
|
||||
>
|
||||
<!-- تنظیمات نما: ستونها (مرتبسازی چیپی است و در ردیف چیپ میآید) -->
|
||||
<slot name="toolbar-end" />
|
||||
<a-divider v-if="$slots['toolbar-end'] && viewOptions.length" type="vertical" :style="{ margin: 0 }" />
|
||||
<a-segmented v-if="viewOptions.length" v-model:value="view" :options="segOptions">
|
||||
<template #label="{ payload }">
|
||||
<span :title="payload.label" :aria-label="payload.label">
|
||||
<component :is="payload.icon" />
|
||||
</span>
|
||||
</template>
|
||||
</a-segmented>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
|
||||
<!-- ۳ب · ردیف چیپ: FilterChips فیلترها در شروع، مرتبسازی در پایان -->
|
||||
<a-flex
|
||||
v-if="hasChipRow"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.marginSM"
|
||||
:style="chipRowStyle"
|
||||
>
|
||||
<a-flex align="center" wrap="wrap" :gap="token.margin" :style="{ minWidth: 0 }">
|
||||
<slot name="chips" />
|
||||
</a-flex>
|
||||
<a-flex v-if="$slots['chips-end']" align="center" wrap="wrap" :gap="token.margin">
|
||||
<slot name="chips-end" />
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
|
||||
<!-- ۴ · فیلترهای فعال -->
|
||||
<a-flex v-if="hasChips" align="center" wrap="wrap" :gap="token.marginXS" :style="chipsStyle">
|
||||
<a-tag
|
||||
v-for="f in activeFilters"
|
||||
:key="f.key"
|
||||
closable
|
||||
:bordered="false"
|
||||
:style="{ marginInlineEnd: 0, background: token.colorPrimaryBg }"
|
||||
@close="onTagClose($event, f.key)"
|
||||
>
|
||||
<a-typography-text type="secondary">{{ f.label }}:</a-typography-text>
|
||||
{{ f.value }}
|
||||
</a-tag>
|
||||
<a-button type="link" size="small" @click="emit('clearFilters')">پاک کردن همه</a-button>
|
||||
<a-typography-text
|
||||
v-if="resultText"
|
||||
type="secondary"
|
||||
:style="{ marginInlineStart: 'auto', fontSize: `${token.fontSizeSM}px` }"
|
||||
>
|
||||
{{ resultText }}
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-card>
|
||||
</template>
|
||||
@@ -0,0 +1,8 @@
|
||||
export { default as PageHeader } from './PageHeader.vue';
|
||||
export { default as FilterChips } from './FilterChips.vue';
|
||||
export type {
|
||||
PageHeaderActiveFilter,
|
||||
PageHeaderMenuItem,
|
||||
PageHeaderTab,
|
||||
PageHeaderViewOption,
|
||||
} from './types';
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Component } from 'vue';
|
||||
|
||||
/** تب ردیف ۲ هدر صفحه (زیرنماها / وضعیتها) */
|
||||
export interface PageHeaderTab {
|
||||
key: string;
|
||||
label: string;
|
||||
/** شمارنده کنار تب؛ undefined = بدون شمارنده */
|
||||
count?: number;
|
||||
icon?: Component;
|
||||
/** warning برای مواردی مثل «عقبافتاده» */
|
||||
tone?: 'default' | 'warning';
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/** آیتم منوی «⋯» در ردیف عنوان (اکسل، ورود داده، تنظیمات کمکاربرد) */
|
||||
export interface PageHeaderMenuItem {
|
||||
key: string;
|
||||
label: string;
|
||||
icon?: Component;
|
||||
danger?: boolean;
|
||||
disabled?: boolean;
|
||||
/** خط جداکننده قبل از این آیتم */
|
||||
dividerBefore?: boolean;
|
||||
}
|
||||
|
||||
/** گزینهٔ نمای نمایش (لیست / ستونی / شبکه / تقویم) */
|
||||
export interface PageHeaderViewOption {
|
||||
value: string;
|
||||
label: string;
|
||||
icon: Component;
|
||||
}
|
||||
|
||||
/** چیپ فیلتر فعال در ردیف ۴ */
|
||||
export interface PageHeaderActiveFilter {
|
||||
key: string;
|
||||
/** نام فیلتر، مثل «منبع» */
|
||||
label: string;
|
||||
/** مقدار خوانا، مثل «اینستاگرام، تلگرام» */
|
||||
value: string;
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* هدر صفحههای بردی (مسیر فروش، تابلوی پروژه) روی PageHeader سراسری.
|
||||
* API قبلی (v-model ها، create، اسلاتهای excel/filters) حفظ شده تا صفحهها نشکنند.
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
FundOutlined,
|
||||
UnorderedListOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import {
|
||||
Flex as AFlex,
|
||||
InputNumber as AInputNumber,
|
||||
InputSearch as AInputSearch,
|
||||
Segmented as ASegmented,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderMenuItem, PageHeaderViewOption } from '@/components/page';
|
||||
|
||||
export type PipelineViewMode = 'kanban' | 'list';
|
||||
|
||||
@@ -25,33 +26,45 @@ const props = withDefaults(
|
||||
icon?: 'briefcase' | 'grid';
|
||||
createOptionLabel?: string;
|
||||
showAmountFilters?: boolean;
|
||||
subtitle?: string;
|
||||
/** شمارندهٔ کنار عنوان (مثلاً تعداد معاملات) */
|
||||
count?: number;
|
||||
/** دکمهٔ اصلی هدر (مثلاً «معامله جدید») */
|
||||
primaryLabel?: string;
|
||||
/** آیتمهای منوی «⋯» (خروجی/ورود اکسل و…) */
|
||||
menuItems?: PageHeaderMenuItem[];
|
||||
}>(),
|
||||
{
|
||||
canCreate: false,
|
||||
icon: 'briefcase',
|
||||
createOptionLabel: 'مسیر فروش جدید…',
|
||||
showAmountFilters: true,
|
||||
subtitle: undefined,
|
||||
count: undefined,
|
||||
primaryLabel: undefined,
|
||||
menuItems: () => [],
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
create: [];
|
||||
primary: [];
|
||||
menu: [key: string];
|
||||
}>();
|
||||
|
||||
const { Title: ATypographyTitle } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const viewMode = defineModel<PipelineViewMode>('viewMode', { required: true });
|
||||
const search = defineModel<string>('search', { default: '' });
|
||||
const selectedPipelineId = defineModel<string>('selectedPipelineId', { required: true });
|
||||
const amountMin = defineModel<string>('amountMin', { default: '' });
|
||||
const amountMax = defineModel<string>('amountMax', { default: '' });
|
||||
|
||||
const viewOptions = [
|
||||
{ value: 'kanban' as const, label: 'ستونی' },
|
||||
{ value: 'list' as const, label: 'لیست' },
|
||||
const viewOptions: PageHeaderViewOption[] = [
|
||||
{ value: 'kanban', label: 'ستونی', icon: AppstoreOutlined },
|
||||
{ value: 'list', label: 'لیست', icon: UnorderedListOutlined },
|
||||
];
|
||||
|
||||
const headerIcon = computed(() => (props.icon === 'grid' ? AppstoreOutlined : FundOutlined));
|
||||
|
||||
const pipelineSelectOptions = computed(() => {
|
||||
const list = props.pipelineOptions.map((o) => ({ value: o.id, label: o.name }));
|
||||
if (props.canCreate) {
|
||||
@@ -69,6 +82,10 @@ function onPick(value: unknown) {
|
||||
selectedPipelineId.value = v;
|
||||
}
|
||||
|
||||
function onView(value: string | undefined) {
|
||||
viewMode.value = value === 'list' ? 'list' : 'kanban';
|
||||
}
|
||||
|
||||
const amountMinNum = computed({
|
||||
get: () => (amountMin.value === '' ? undefined : Number(amountMin.value)),
|
||||
set: (v: number | string | null | undefined) => {
|
||||
@@ -87,73 +104,55 @@ const amountMaxNum = computed({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="12" dir="rtl">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<a-space :size="10" align="center">
|
||||
<span
|
||||
:style="{
|
||||
width: `${token.controlHeight}px`,
|
||||
height: `${token.controlHeight}px`,
|
||||
borderRadius: `${token.borderRadius}px`,
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
background: token.colorPrimary,
|
||||
color: token.colorTextLightSolid,
|
||||
flexShrink: 0,
|
||||
}"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<AppstoreOutlined v-if="icon === 'grid'" />
|
||||
<FundOutlined v-else />
|
||||
</span>
|
||||
<a-typography-title :level="4" :style="{ margin: 0 }">
|
||||
{{ pipelineName }}
|
||||
</a-typography-title>
|
||||
</a-space>
|
||||
|
||||
<a-space wrap :size="8">
|
||||
<a-segmented v-model:value="viewMode" :options="viewOptions" />
|
||||
<a-select
|
||||
:value="selectedPipelineId"
|
||||
:options="pipelineSelectOptions"
|
||||
:style="{ width: '180px' }"
|
||||
@update:value="onPick"
|
||||
/>
|
||||
<slot name="excel" />
|
||||
</a-space>
|
||||
</a-flex>
|
||||
|
||||
<!-- یک نوار فیلتر تکردیفه؛ بدون a-row و بدون فاصلهٔ ول -->
|
||||
<a-flex
|
||||
wrap="wrap"
|
||||
align="center"
|
||||
:gap="8"
|
||||
:style="{ width: '100%', minWidth: 0 }"
|
||||
>
|
||||
<a-input-search
|
||||
v-model:value="search"
|
||||
allow-clear
|
||||
placeholder="جستجو در معاملات…"
|
||||
:style="{ flex: '1 1 220px', minWidth: '180px', maxWidth: '100%' }"
|
||||
<PageHeader
|
||||
:title="pipelineName"
|
||||
:subtitle="subtitle"
|
||||
:icon="headerIcon"
|
||||
:count="count"
|
||||
:primary-label="primaryLabel"
|
||||
:menu-items="menuItems"
|
||||
searchable
|
||||
search-placeholder="جستجو در معاملات…"
|
||||
v-model:search="search"
|
||||
:view-options="viewOptions"
|
||||
:view="viewMode"
|
||||
@update:view="onView"
|
||||
@primary="emit('primary')"
|
||||
@menu="(key) => emit('menu', key)"
|
||||
>
|
||||
<!-- انتخاب مسیر: زمینهٔ صفحه، نه فیلتر ← کنار عنوان -->
|
||||
<template #title-extra>
|
||||
<a-select
|
||||
:value="selectedPipelineId"
|
||||
:options="pipelineSelectOptions"
|
||||
:style="{ width: '180px' }"
|
||||
@update:value="onPick"
|
||||
/>
|
||||
<template v-if="showAmountFilters">
|
||||
<a-input-number
|
||||
v-model:value="amountMinNum"
|
||||
:min="0"
|
||||
placeholder="حداقل مبلغ"
|
||||
:style="{ width: '140px', flex: '0 0 auto' }"
|
||||
/>
|
||||
<a-input-number
|
||||
v-model:value="amountMaxNum"
|
||||
:min="0"
|
||||
placeholder="حداکثر مبلغ"
|
||||
:style="{ width: '140px', flex: '0 0 auto' }"
|
||||
/>
|
||||
</template>
|
||||
<div :style="{ flex: '1 1 240px', minWidth: '200px', maxWidth: '100%' }">
|
||||
</template>
|
||||
|
||||
<template v-if="$slots.excel" #actions>
|
||||
<slot name="excel" />
|
||||
</template>
|
||||
|
||||
<template v-if="showAmountFilters" #quick-filters>
|
||||
<a-input-number
|
||||
v-model:value="amountMinNum"
|
||||
:min="0"
|
||||
placeholder="حداقل مبلغ"
|
||||
:style="{ width: '140px' }"
|
||||
/>
|
||||
<a-input-number
|
||||
v-model:value="amountMaxNum"
|
||||
:min="0"
|
||||
placeholder="حداکثر مبلغ"
|
||||
:style="{ width: '140px' }"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-if="$slots.filters" #saved-filters>
|
||||
<div :style="{ width: '280px', maxWidth: '100%' }">
|
||||
<slot name="filters" />
|
||||
</div>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user