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,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
Affix as AAffix,
|
||||
Alert as AAlert,
|
||||
@@ -13,7 +12,6 @@ import {
|
||||
Descriptions as ADescriptions,
|
||||
DescriptionsItem as ADescriptionsItem,
|
||||
Divider as ADivider,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
@@ -30,7 +28,6 @@ import {
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
CheckOutlined,
|
||||
DeleteOutlined,
|
||||
FileTextOutlined,
|
||||
@@ -38,6 +35,7 @@ import {
|
||||
UserAddOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canAssignToOthers } from '@/lib/assign-access';
|
||||
import { canUseBehavior } from '@/lib/behavior-access';
|
||||
@@ -65,8 +63,11 @@ import type {
|
||||
PipelineDto,
|
||||
ProductDto,
|
||||
} from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { FundOutlined, FileOutlined, BulbOutlined } from '@/icons/ant-bridge';
|
||||
import type { PageHeaderMenuItem } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const ASpaceCompact = Space.Compact;
|
||||
type LineDraft = {
|
||||
key: string;
|
||||
@@ -96,6 +97,7 @@ const emit = defineEmits<{
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const auth = useAuthStore();
|
||||
const canBehavior = computed(() => canUseBehavior(auth.user));
|
||||
const id = computed(() => {
|
||||
@@ -221,16 +223,10 @@ function onStageSelect(nextId: string) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.patch(`/deals/${id.value}/move`, { stageId: nextId });
|
||||
feedback.success('مرحله معامله بهروز شد.');
|
||||
} catch (e) {
|
||||
stageId.value = prev;
|
||||
if (axios.isAxiosError(e)) {
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
error.value = Array.isArray(msg)
|
||||
? msg.join('، ')
|
||||
: (msg ?? 'جابهجایی مرحله ناموفق بود.');
|
||||
} else {
|
||||
error.value = 'جابهجایی مرحله ناموفق بود.';
|
||||
}
|
||||
feedback.fromError(e, 'جابهجایی مرحله ناموفق بود.');
|
||||
throw e;
|
||||
} finally {
|
||||
stageMoving.value = false;
|
||||
@@ -593,6 +589,7 @@ async function submit() {
|
||||
} catch {
|
||||
/* deal saved; follow-up is optional */
|
||||
}
|
||||
feedback.success('معامله ذخیره شد.');
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
@@ -614,6 +611,7 @@ async function submit() {
|
||||
} catch {
|
||||
/* deal saved; follow-up is optional */
|
||||
}
|
||||
feedback.success('معامله ذخیره شد.');
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
@@ -621,16 +619,7 @@ async function submit() {
|
||||
await router.push({ name: 'pipeline' });
|
||||
}
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
if (!e.response) {
|
||||
error.value = 'اتصال به سرور برقرار نشد.';
|
||||
} else {
|
||||
const msg = (e.response.data as { message?: string | string[] })?.message;
|
||||
error.value = Array.isArray(msg) ? msg.join('، ') : (msg ?? 'ذخیره ناموفق بود');
|
||||
}
|
||||
} else {
|
||||
error.value = 'ذخیره ناموفق بود';
|
||||
}
|
||||
feedback.fromError(e, 'ذخیره ناموفق بود');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -644,67 +633,54 @@ watch(othersKeys, (keys) => {
|
||||
});
|
||||
|
||||
onMounted(load);
|
||||
|
||||
/* ---------- هدر صفحه ---------- */
|
||||
const dealMenuItems = computed<PageHeaderMenuItem[]>(() => {
|
||||
if (isNew.value || !id.value) return [];
|
||||
const items: PageHeaderMenuItem[] = [
|
||||
{ key: 'quote', label: 'صدور پیشفاکتور', icon: FileOutlined },
|
||||
{ key: 'invoice', label: 'صدور فاکتور', icon: FileTextOutlined },
|
||||
];
|
||||
if (personId.value && canBehavior.value) {
|
||||
items.push({ key: 'copilot', label: 'کمک برای ادامه مذاکره', icon: BulbOutlined, dividerBefore: true });
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
function onDealMenu(key: string) {
|
||||
if (key === 'quote') void router.push({ name: 'quote-new', query: { fromDealId: id.value } });
|
||||
else if (key === 'invoice') void router.push({ name: 'invoice-new', query: { fromDealId: id.value } });
|
||||
else if (key === 'copilot' && personId.value) {
|
||||
void router.push({
|
||||
name: 'person-detail',
|
||||
params: { id: personId.value },
|
||||
query: { tab: 'copilot', dealId: id.value },
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div dir="rtl">
|
||||
<a-spin :spinning="loading">
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="pageTitle"
|
||||
subtitle="مشتری، مبلغ، مرحله و پیگیری معامله"
|
||||
:icon="FundOutlined"
|
||||
:back-to="{ name: 'pipeline' }"
|
||||
:primary-label="saving ? 'در حال ذخیره…' : 'ذخیره معامله'"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
:menu-items="dealMenuItems"
|
||||
:style="{ marginBottom: '16px' }"
|
||||
@primary="submit"
|
||||
@menu="onDealMenu"
|
||||
>
|
||||
<div>
|
||||
<a-space :size="8">
|
||||
<RouterLink :to="{ name: 'pipeline' }" custom v-slot="{ navigate }">
|
||||
<a-button type="text" @click="navigate">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
</a-button>
|
||||
</RouterLink>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title>
|
||||
</a-space>
|
||||
<div>
|
||||
<a-typography-text type="secondary">
|
||||
<RouterLink :to="{ name: 'pipeline' }">مسیر فروش</RouterLink>
|
||||
· {{ pageTitle }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
</div>
|
||||
<a-space wrap :size="8">
|
||||
<RouterLink
|
||||
v-if="!isNew && id"
|
||||
:to="{ name: 'quote-new', query: { fromDealId: id } }"
|
||||
custom
|
||||
v-slot="{ navigate }"
|
||||
>
|
||||
<a-button @click="navigate">صدور پیشفاکتور</a-button>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
v-if="!isNew && id"
|
||||
:to="{ name: 'invoice-new', query: { fromDealId: id } }"
|
||||
custom
|
||||
v-slot="{ navigate }"
|
||||
>
|
||||
<a-button @click="navigate">صدور فاکتور</a-button>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
v-if="!isNew && personId && canBehavior"
|
||||
:to="{ name: 'person-detail', params: { id: personId }, query: { tab: 'copilot', dealId: id } }"
|
||||
custom
|
||||
v-slot="{ navigate }"
|
||||
>
|
||||
<a-button @click="navigate">کمک برای ادامه مذاکره</a-button>
|
||||
</RouterLink>
|
||||
<template #actions>
|
||||
<a-button :disabled="saving" @click="cancel">انصراف</a-button>
|
||||
<a-button type="primary" :loading="saving" @click="submit">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
{{ saving ? 'در حال ذخیره…' : 'ذخیره معامله' }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div
|
||||
v-if="stagePathItems.length"
|
||||
|
||||
Reference in New Issue
Block a user