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:
+10
-3
@@ -10,7 +10,10 @@
|
||||
.app-frame {
|
||||
display: grid;
|
||||
grid-template-columns: 244px minmax(0, 1fr);
|
||||
min-height: 100vh;
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
overflow: hidden;
|
||||
}
|
||||
.app-frame.collapsed {
|
||||
grid-template-columns: 80px minmax(0, 1fr);
|
||||
@@ -18,15 +21,19 @@
|
||||
.app-frame > .sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: start;
|
||||
align-self: stretch;
|
||||
box-sizing: border-box;
|
||||
height: calc(100vh - 28px);
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
@media (min-width: 901px) {
|
||||
.app-frame.collapsed > .sidebar {
|
||||
width: 64px;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
.app-frame .mobile-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons-vue": "^7.0.1",
|
||||
"@mento/shared": "*",
|
||||
"@tanstack/vue-query": "^5.108.4",
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.8.4",
|
||||
"echarts": "^6.1.0",
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 197.7 151.02">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #10897d;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #16c1a8;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #43f7dd;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Layer_1-2" data-name="Layer 1">
|
||||
<path class="cls-1" d="M43.57,77.15v64.37c0,4.79-3.88,8.67-8.67,8.67H8.67c-4.79,0-8.67-3.88-8.67-8.67V51.62c0-2.96,1.51-5.71,3.99-7.3l41.67-26.69c3.67-2.35,8.52-1.61,11.32,1.73l35.74,42.59c.57.68,1.6.72,2.22.09l26.07-26.6c3.38-3.45,8.92-3.47,12.33-.06l19.42,19.42c3.39,3.39,3.39,8.88,0,12.26l-55.06,55.06c-3.58,3.58-9.45,3.35-12.73-.5l-38.76-45.42c-.9-1.06-2.64-.42-2.64.97Z"/>
|
||||
<circle class="cls-3" cx="167.06" cy="21.02" r="21.02"/>
|
||||
<rect class="cls-3" x="172.68" y="52.7" width="25.02" height="98.32" rx="12.51" ry="12.51"/>
|
||||
<rect class="cls-2" x="142.38" y="83.17" width="25.02" height="67.85" rx="12.51" ry="12.51"/>
|
||||
<rect class="cls-1" x="111.4" y="114.24" width="25.02" height="36.78" rx="12.51" ry="12.51"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterView } from 'vue-router';
|
||||
import {
|
||||
App as AApp,
|
||||
ConfigProvider as AConfigProvider,
|
||||
StyleProvider as AStyleProvider,
|
||||
} from 'ant-design-vue';
|
||||
@@ -11,7 +12,9 @@ import { antdTheme } from '@/theme/antdTheme';
|
||||
<template>
|
||||
<a-style-provider hash-priority="high">
|
||||
<a-config-provider direction="rtl" :locale="faIR" :theme="antdTheme">
|
||||
<a-app>
|
||||
<RouterView />
|
||||
</a-app>
|
||||
</a-config-provider>
|
||||
</a-style-provider>
|
||||
</template>
|
||||
|
||||
@@ -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
|
||||
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:
|
||||
18px 18px,
|
||||
28px 28px;
|
||||
mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.25));
|
||||
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"
|
||||
<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)"
|
||||
>
|
||||
<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" />
|
||||
<!-- انتخاب مسیر: زمینهٔ صفحه، نه فیلتر ← کنار عنوان -->
|
||||
<template #title-extra>
|
||||
<a-select
|
||||
:value="selectedPipelineId"
|
||||
:options="pipelineSelectOptions"
|
||||
:style="{ width: '180px' }"
|
||||
@update:value="onPick"
|
||||
/>
|
||||
<slot name="excel" />
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
<!-- یک نوار فیلتر تکردیفه؛ بدون 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%' }"
|
||||
/>
|
||||
<template v-if="showAmountFilters">
|
||||
<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', flex: '0 0 auto' }"
|
||||
:style="{ width: '140px' }"
|
||||
/>
|
||||
<a-input-number
|
||||
v-model:value="amountMaxNum"
|
||||
:min="0"
|
||||
placeholder="حداکثر مبلغ"
|
||||
:style="{ width: '140px', flex: '0 0 auto' }"
|
||||
:style="{ width: '140px' }"
|
||||
/>
|
||||
</template>
|
||||
<div :style="{ flex: '1 1 240px', minWidth: '200px', maxWidth: '100%' }">
|
||||
|
||||
<template v-if="$slots.filters" #saved-filters>
|
||||
<div :style="{ width: '280px', maxWidth: '100%' }">
|
||||
<slot name="filters" />
|
||||
</div>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { message } from 'ant-design-vue';
|
||||
import { apiErrorMessage } from '@/lib/apiErrorMessage';
|
||||
|
||||
/**
|
||||
* Central CRM feedback via Ant static Message (portal on document.body).
|
||||
* Configured once in main.ts — do not use App.useApp() message here.
|
||||
*/
|
||||
export function useFeedback() {
|
||||
return {
|
||||
success: (content: string) => {
|
||||
void message.success(content);
|
||||
},
|
||||
error: (content: string) => {
|
||||
void message.error(content);
|
||||
},
|
||||
warning: (content: string) => {
|
||||
void message.warning(content);
|
||||
},
|
||||
info: (content: string) => {
|
||||
void message.info(content);
|
||||
},
|
||||
fromError: (e: unknown, fallback: string) => {
|
||||
void message.error(apiErrorMessage(e, fallback));
|
||||
},
|
||||
};
|
||||
}
|
||||
+1345
-497
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,44 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import type { ActivityPriority, ActivityPrioritySetting } from '@mento/shared';
|
||||
import {
|
||||
DEFAULT_ACTIVITY_PRIORITY_SETTINGS,
|
||||
parseActivityPrioritySettings,
|
||||
} from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { activityPriorityKeys } from '@/queries/keys';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
const items = ref<ActivityPrioritySetting[]>([...DEFAULT_ACTIVITY_PRIORITY_SETTINGS]);
|
||||
const loaded = ref(false);
|
||||
let pending: Promise<void> | null = null;
|
||||
const REF_STALE_MS = 5 * 60_000;
|
||||
|
||||
/** تنظیمات اولویت فعالیت/روتین (کش مشترک) */
|
||||
async function fetchActivityPriorities(): Promise<ActivityPrioritySetting[]> {
|
||||
try {
|
||||
const { data } = await api.get<ActivityPrioritySetting[]>('/activities/priorities');
|
||||
return parseActivityPrioritySettings(data);
|
||||
} catch {
|
||||
return [...DEFAULT_ACTIVITY_PRIORITY_SETTINGS];
|
||||
}
|
||||
}
|
||||
|
||||
/** تنظیمات اولویت فعالیت/روتین (کش مشترک Vue Query) */
|
||||
export function useActivityPriorities() {
|
||||
async function load(force = false): Promise<void> {
|
||||
if (loaded.value && !force) return;
|
||||
if (pending && !force) return pending;
|
||||
pending = api
|
||||
.get<ActivityPrioritySetting[]>('/activities/priorities')
|
||||
.then(({ data }) => {
|
||||
items.value = parseActivityPrioritySettings(data);
|
||||
loaded.value = true;
|
||||
})
|
||||
.catch(() => {
|
||||
if (!loaded.value) items.value = [...DEFAULT_ACTIVITY_PRIORITY_SETTINGS];
|
||||
})
|
||||
.finally(() => {
|
||||
pending = null;
|
||||
const query = useQuery({
|
||||
queryKey: activityPriorityKeys.list(),
|
||||
queryFn: fetchActivityPriorities,
|
||||
staleTime: REF_STALE_MS,
|
||||
placeholderData: [...DEFAULT_ACTIVITY_PRIORITY_SETTINGS],
|
||||
});
|
||||
return pending;
|
||||
|
||||
const items = computed(
|
||||
() => query.data.value ?? [...DEFAULT_ACTIVITY_PRIORITY_SETTINGS],
|
||||
);
|
||||
const loaded = computed(() => query.isFetched.value);
|
||||
|
||||
async function load(force = false): Promise<void> {
|
||||
if (force) {
|
||||
await queryClient.invalidateQueries({ queryKey: activityPriorityKeys.all });
|
||||
}
|
||||
await query.refetch();
|
||||
}
|
||||
|
||||
const byKey = computed(() => {
|
||||
@@ -59,9 +70,11 @@ export function useActivityPriorities() {
|
||||
}
|
||||
|
||||
function setLocal(next: ActivityPrioritySetting[]) {
|
||||
items.value = parseActivityPrioritySettings(next);
|
||||
loaded.value = true;
|
||||
queryClient.setQueryData(
|
||||
activityPriorityKeys.list(),
|
||||
parseActivityPrioritySettings(next),
|
||||
);
|
||||
}
|
||||
|
||||
return { items, byKey, labels, colors, loaded, load, labelOf, colorOf, setLocal };
|
||||
return { items, byKey, labels, colors, loaded, load, labelOf, colorOf, setLocal, query };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import type {
|
||||
ActivityDto,
|
||||
ActivityStageColor,
|
||||
@@ -9,6 +10,8 @@ import type {
|
||||
import { ACTIVITY_TYPE_LABELS } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { PIPELINE_ACCENT } from '@/lib/pipeline-board';
|
||||
import { activityTypeKeys } from '@/queries/keys';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
export const BASE_TYPE_ICON: Record<ActivityType, ActivityTypeIcon> = {
|
||||
call: 'phone',
|
||||
@@ -45,28 +48,29 @@ export const ACTIVITY_TYPE_ICON_LABELS: Record<ActivityTypeIcon, string> = {
|
||||
sparkle: 'درخشش',
|
||||
};
|
||||
|
||||
const types = ref<ActivityTypeDefDto[]>([]);
|
||||
const loaded = ref(false);
|
||||
let pending: Promise<void> | null = null;
|
||||
const REF_STALE_MS = 5 * 60_000;
|
||||
|
||||
/** انواع فعالیت سازمان (کش مشترک بین صفحات) */
|
||||
async function fetchActivityTypes(): Promise<ActivityTypeDefDto[]> {
|
||||
const { data } = await api.get<ActivityTypeDefDto[]>('/activities/types');
|
||||
return data;
|
||||
}
|
||||
|
||||
/** انواع فعالیت سازمان (کش مشترک Vue Query) */
|
||||
export function useActivityTypes() {
|
||||
async function load(force = false): Promise<void> {
|
||||
if (loaded.value && !force) return;
|
||||
if (pending && !force) return pending;
|
||||
pending = api
|
||||
.get<ActivityTypeDefDto[]>('/activities/types')
|
||||
.then(({ data }) => {
|
||||
types.value = data;
|
||||
loaded.value = true;
|
||||
})
|
||||
.catch(() => {
|
||||
if (!loaded.value) types.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
pending = null;
|
||||
const query = useQuery({
|
||||
queryKey: activityTypeKeys.list(),
|
||||
queryFn: fetchActivityTypes,
|
||||
staleTime: REF_STALE_MS,
|
||||
});
|
||||
return pending;
|
||||
|
||||
const types = computed(() => query.data.value ?? []);
|
||||
const loaded = computed(() => query.isFetched.value);
|
||||
|
||||
async function load(force = false): Promise<void> {
|
||||
if (force) {
|
||||
await queryClient.invalidateQueries({ queryKey: activityTypeKeys.all });
|
||||
}
|
||||
await query.refetch();
|
||||
}
|
||||
|
||||
const active = computed(() => types.value.filter((t) => t.isActive));
|
||||
@@ -84,7 +88,7 @@ export function useActivityTypes() {
|
||||
return systemOf.value[a.type] ?? null;
|
||||
}
|
||||
|
||||
return { types, active, byId, systemOf, loaded, load, defOf };
|
||||
return { types, active, byId, systemOf, loaded, load, defOf, query };
|
||||
}
|
||||
|
||||
export type TypeView = { name: string; icon: ActivityTypeIcon; color: ActivityStageColor };
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import axios from 'axios';
|
||||
|
||||
/** Extract a user-facing message from an API/axios error. */
|
||||
export function apiErrorMessage(e: unknown, fallback: string): string {
|
||||
if (axios.isAxiosError(e)) {
|
||||
const msg = (e.response?.data as { message?: string | string[] } | undefined)?.message;
|
||||
if (Array.isArray(msg)) return msg.join('، ');
|
||||
if (msg) return msg;
|
||||
if (!e.response) return 'اتصال به سرور برقرار نشد.';
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { ref } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import type { CustomerGroupColor, CustomerGroupDto } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { customerGroupKeys } from '@/queries/keys';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
export const CUSTOMER_GROUP_COLOR_LABELS: Record<CustomerGroupColor, string> = {
|
||||
teal: 'سبزآبی',
|
||||
@@ -27,27 +30,31 @@ export function groupSwatch(color: string | null | undefined) {
|
||||
return CUSTOMER_GROUP_SWATCH[(color ?? 'teal') as CustomerGroupColor] ?? CUSTOMER_GROUP_SWATCH.teal;
|
||||
}
|
||||
|
||||
const groups = ref<CustomerGroupDto[]>([]);
|
||||
const loaded = ref(false);
|
||||
let pending: Promise<CustomerGroupDto[]> | null = null;
|
||||
const REF_STALE_MS = 5 * 60_000;
|
||||
|
||||
/** فهرست گروههای مشتری محیط (مشترک بین صفحهها) */
|
||||
export function useCustomerGroups() {
|
||||
async function load(force = false): Promise<CustomerGroupDto[]> {
|
||||
if (loaded.value && !force) return groups.value;
|
||||
if (pending && !force) return pending;
|
||||
pending = api
|
||||
.get<CustomerGroupDto[]>('/customer-groups')
|
||||
.then(({ data }) => {
|
||||
groups.value = data;
|
||||
loaded.value = true;
|
||||
async function fetchCustomerGroups(): Promise<CustomerGroupDto[]> {
|
||||
const { data } = await api.get<CustomerGroupDto[]>('/customer-groups');
|
||||
return data;
|
||||
})
|
||||
.finally(() => {
|
||||
pending = null;
|
||||
});
|
||||
return pending;
|
||||
}
|
||||
|
||||
return { groups, loaded, load };
|
||||
/** فهرست گروههای مشتری محیط (کش مشترک Vue Query) */
|
||||
export function useCustomerGroups() {
|
||||
const query = useQuery({
|
||||
queryKey: customerGroupKeys.list(),
|
||||
queryFn: fetchCustomerGroups,
|
||||
staleTime: REF_STALE_MS,
|
||||
});
|
||||
|
||||
const groups = computed(() => query.data.value ?? []);
|
||||
const loaded = computed(() => query.isFetched.value);
|
||||
|
||||
async function load(force = false): Promise<CustomerGroupDto[]> {
|
||||
if (force) {
|
||||
await queryClient.invalidateQueries({ queryKey: customerGroupKeys.all });
|
||||
}
|
||||
const result = await query.refetch();
|
||||
return result.data ?? groups.value;
|
||||
}
|
||||
|
||||
return { groups, loaded, load, query };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
import { ref } from 'vue';
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
||||
|
||||
export type WorkspaceTab = {
|
||||
id: string;
|
||||
fullPath: string;
|
||||
path: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'mento_workspace_tabs_v1';
|
||||
const MAX_TABS = 14;
|
||||
|
||||
const tabs = ref<WorkspaceTab[]>([]);
|
||||
const hydrated = ref(false);
|
||||
|
||||
const ROUTE_TITLES: Record<string, string> = {
|
||||
home: 'داشبورد',
|
||||
profile: 'حساب کاربری',
|
||||
reports: 'گزارشها',
|
||||
'tahesab-sales-report': 'گزارش فروش تهحساب',
|
||||
'disc-report': 'گزارش دیسک',
|
||||
'sales-forecast': 'هدف و پیشبینی',
|
||||
tickets: 'تیکتها',
|
||||
conversations: 'گفتگو',
|
||||
'ticket-new': 'تیکت جدید',
|
||||
'ticket-detail': 'جزئیات تیکت',
|
||||
activities: 'میز کار من',
|
||||
'activities-calendar': 'تقویم کارها',
|
||||
'activity-new': 'کار جدید',
|
||||
'activity-edit': 'ویرایش کار',
|
||||
'activity-detail': 'جزئیات کار',
|
||||
'routines-today': 'روتین امروز',
|
||||
'routines-overdue': 'روتین معوق',
|
||||
'routines-calendar': 'تقویم روتین',
|
||||
'routines-list': 'فهرست روتین',
|
||||
'routines-me': 'روتین من',
|
||||
'routines-team': 'روتین تیم',
|
||||
'routines-manage': 'مدیریت روتین',
|
||||
'routine-new': 'روتین جدید',
|
||||
'routine-edit': 'ویرایش روتین',
|
||||
'routines-settings': 'تنظیمات روتین',
|
||||
quotes: 'پیشفاکتورها',
|
||||
'quote-new': 'پیشفاکتور جدید',
|
||||
'quote-detail': 'جزئیات پیشفاکتور',
|
||||
invoices: 'فاکتورها',
|
||||
'invoice-new': 'فاکتور جدید',
|
||||
'invoice-detail': 'جزئیات فاکتور',
|
||||
inventory: 'انبار',
|
||||
cheques: 'چکها',
|
||||
finance: 'مدیریت مالی',
|
||||
'finance-accounts': 'حسابها',
|
||||
'finance-account': 'جزئیات حساب',
|
||||
'finance-incomes': 'دریافتها',
|
||||
'finance-expenses': 'پرداختها',
|
||||
'finance-receivables': 'مطالبات',
|
||||
'finance-payroll': 'حقوق',
|
||||
'finance-recurring': 'تراکنشهای تکراری',
|
||||
'finance-reports': 'گزارش مالی',
|
||||
'finance-audit': 'حسابرسی مالی',
|
||||
'finance-categories': 'دستهبندی مالی',
|
||||
reservations: 'رزرو و نوبتدهی',
|
||||
commissions: 'پورسانت',
|
||||
pipeline: 'مسیر فروش',
|
||||
leads: 'فهرست لیدها',
|
||||
'leads-board': 'مسیر لیدها',
|
||||
'lead-detail': 'جزئیات لید',
|
||||
projects: 'تابلوی پروژه',
|
||||
'project-card-new': 'کارت پروژه جدید',
|
||||
'project-card-detail': 'جزئیات کارت پروژه',
|
||||
loyalty: 'باشگاه مشتریان',
|
||||
gamification: 'باشگاه امتیازات',
|
||||
'gamification-admin': 'مدیریت باشگاه',
|
||||
'deal-new': 'معامله جدید',
|
||||
'deal-detail': 'جزئیات معامله',
|
||||
contacts: 'مشتریان',
|
||||
notes: 'یادداشتها',
|
||||
attachments: 'پیوستها',
|
||||
automations: 'اتوماسیون گردش کار',
|
||||
'message-automations': 'اتوماسیون پیامکها',
|
||||
'lead-stages': 'مراحل و وضعیتها',
|
||||
'pipeline-settings': 'تنظیمات مسیر فروش',
|
||||
'lead-forms': 'فرمساز سرنخ',
|
||||
'lead-form-builder': 'ویرایش فرم لید',
|
||||
'team-settings': 'تیم و نقشها',
|
||||
'audit-logs': 'لاگ فعالیت کاربران',
|
||||
'deletion-archives': 'تاریخچه کارها',
|
||||
'public-api': 'API و وبهوک',
|
||||
'sms-campaigns': 'پیامک گروهی',
|
||||
'sms-campaign-report': 'گزارش پیامک گروهی',
|
||||
'custom-fields': 'فیلدهای سفارشی',
|
||||
products: 'محصولات و خدمات',
|
||||
'product-new': 'محصول جدید',
|
||||
'product-edit': 'ویرایش محصول',
|
||||
currencies: 'ارزها',
|
||||
'tahesab-settings': 'تهحساب',
|
||||
'account-balance-settings': 'مانده حساب',
|
||||
'woocommerce-settings': 'ووکامرس',
|
||||
'montify-settings': 'فروشگاههای مونتیفای',
|
||||
'voip-settings': 'تلفن سازمانی',
|
||||
'faq-settings': 'FAQ',
|
||||
'person-new': 'شخص جدید',
|
||||
'person-edit': 'ویرایش شخص',
|
||||
'person-detail': 'پروفایل شخص',
|
||||
'company-new': 'شرکت جدید',
|
||||
'company-edit': 'ویرایش شرکت',
|
||||
'company-detail': 'پروفایل شرکت',
|
||||
settings: 'تنظیمات',
|
||||
};
|
||||
|
||||
function readStorage(): WorkspaceTab[] {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return [];
|
||||
const parsed = JSON.parse(raw) as WorkspaceTab[];
|
||||
if (!Array.isArray(parsed)) return [];
|
||||
return parsed.filter(
|
||||
(t) =>
|
||||
t &&
|
||||
typeof t.id === 'string' &&
|
||||
typeof t.fullPath === 'string' &&
|
||||
typeof t.title === 'string',
|
||||
);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function writeStorage(next: WorkspaceTab[]) {
|
||||
try {
|
||||
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
||||
} catch {
|
||||
/* ignore quota */
|
||||
}
|
||||
}
|
||||
|
||||
function ensureHydrated() {
|
||||
if (hydrated.value) return;
|
||||
tabs.value = readStorage();
|
||||
hydrated.value = true;
|
||||
}
|
||||
|
||||
export function titleForRoute(route: RouteLocationNormalizedLoaded): string {
|
||||
const metaTitle = route.meta?.title;
|
||||
if (typeof metaTitle === 'string' && metaTitle.trim()) return metaTitle.trim();
|
||||
|
||||
const name = typeof route.name === 'string' ? route.name : '';
|
||||
if (name && ROUTE_TITLES[name]) return ROUTE_TITLES[name];
|
||||
|
||||
for (let i = route.matched.length - 1; i >= 0; i -= 1) {
|
||||
const matchedName = route.matched[i]?.name;
|
||||
if (typeof matchedName === 'string' && ROUTE_TITLES[matchedName]) {
|
||||
return ROUTE_TITLES[matchedName];
|
||||
}
|
||||
}
|
||||
|
||||
const leaf = route.path.split('/').filter(Boolean).pop();
|
||||
if (!leaf) return 'صفحه';
|
||||
if (/^\d+$/.test(leaf) || leaf.length > 24) {
|
||||
const parent = route.path.split('/').filter(Boolean).slice(-2, -1)[0];
|
||||
if (parent && ROUTE_TITLES[parent]) return ROUTE_TITLES[parent];
|
||||
}
|
||||
return decodeURIComponent(leaf);
|
||||
}
|
||||
|
||||
export function useWorkspaceTabs() {
|
||||
ensureHydrated();
|
||||
|
||||
function syncFromRoute(route: RouteLocationNormalizedLoaded) {
|
||||
if (route.meta?.public) return;
|
||||
const fullPath = route.fullPath;
|
||||
const path = route.path;
|
||||
if (!path || path.startsWith('/login') || path.startsWith('/adm')) return;
|
||||
|
||||
const id = path;
|
||||
const title = titleForRoute(route);
|
||||
const existing = tabs.value.find((t) => t.id === id);
|
||||
if (existing) {
|
||||
let dirty = false;
|
||||
if (existing.fullPath !== fullPath) {
|
||||
existing.fullPath = fullPath;
|
||||
dirty = true;
|
||||
}
|
||||
if (existing.title !== title) {
|
||||
existing.title = title;
|
||||
dirty = true;
|
||||
}
|
||||
if (dirty) writeStorage(tabs.value);
|
||||
return;
|
||||
}
|
||||
|
||||
const next = [
|
||||
...tabs.value,
|
||||
{
|
||||
id,
|
||||
fullPath,
|
||||
path,
|
||||
title,
|
||||
},
|
||||
];
|
||||
while (next.length > MAX_TABS) next.shift();
|
||||
tabs.value = next;
|
||||
writeStorage(tabs.value);
|
||||
}
|
||||
|
||||
function activateTab(id: string, push: (to: string) => void) {
|
||||
const tab = tabs.value.find((t) => t.id === id);
|
||||
if (!tab) return;
|
||||
push(tab.fullPath);
|
||||
}
|
||||
|
||||
function closeTab(
|
||||
id: string,
|
||||
currentPath: string,
|
||||
push: (to: string) => void,
|
||||
) {
|
||||
const index = tabs.value.findIndex((t) => t.id === id);
|
||||
if (index < 0) return;
|
||||
const wasActive = currentPath === id;
|
||||
const next = tabs.value.filter((t) => t.id !== id);
|
||||
tabs.value = next;
|
||||
writeStorage(next);
|
||||
if (!wasActive) return;
|
||||
const fallback = next[index] ?? next[index - 1] ?? next[next.length - 1];
|
||||
push(fallback?.fullPath || '/');
|
||||
}
|
||||
|
||||
return {
|
||||
tabs,
|
||||
syncFromRoute,
|
||||
activateTab,
|
||||
closeTab,
|
||||
};
|
||||
}
|
||||
@@ -1,18 +1,59 @@
|
||||
import { createApp } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { VueQueryPlugin } from '@tanstack/vue-query';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { brand } from '@mento/shared';
|
||||
import App from './App.vue';
|
||||
import { router } from './router';
|
||||
import { vTableCols } from './lib/tableColumns';
|
||||
import { queryClient } from './queries/queryClient';
|
||||
import './styles/fonts.css';
|
||||
import './styles/main.css';
|
||||
|
||||
/** Toast on document.body — App.useApp() holder can silent-no-op in this shell. */
|
||||
message.config({
|
||||
top: '64px',
|
||||
duration: 3,
|
||||
maxCount: 3,
|
||||
rtl: true,
|
||||
getContainer: () => document.body,
|
||||
});
|
||||
|
||||
document.title = `${brand.nameFa} | ${brand.fullName}`;
|
||||
const favicon = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
||||
if (favicon) favicon.href = brand.logo;
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(createPinia());
|
||||
app.use(VueQueryPlugin, { queryClient });
|
||||
app.use(router);
|
||||
app.directive('table-cols', vTableCols);
|
||||
|
||||
if (import.meta.hot) {
|
||||
// Vue's HMR unmount throws "Cannot destructure property 'type' of 'vnode'"
|
||||
// after the DOM is already removed, and the exception is outside the HMR
|
||||
// try/catch — #app stays empty until a manual refresh. Reload once.
|
||||
let recovering = false;
|
||||
const recoverBlankApp = () => {
|
||||
if (recovering) return;
|
||||
const root = document.getElementById('app');
|
||||
if (!root || root.childElementCount > 0) return;
|
||||
const key = 'mento:blank-recover-at';
|
||||
const last = Number(sessionStorage.getItem(key) || 0);
|
||||
if (Date.now() - last < 8000) return;
|
||||
sessionStorage.setItem(key, String(Date.now()));
|
||||
recovering = true;
|
||||
window.location.reload();
|
||||
};
|
||||
window.addEventListener('error', (event) => {
|
||||
const message = event.message || '';
|
||||
if (message.includes('vnode') || message.includes('unmount')) {
|
||||
queueMicrotask(recoverBlankApp);
|
||||
}
|
||||
});
|
||||
import.meta.hot.on('vite:afterUpdate', () => {
|
||||
setTimeout(recoverBlankApp, 80);
|
||||
});
|
||||
}
|
||||
|
||||
app.mount('#app');
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import type {
|
||||
ActivityBoardDto,
|
||||
ActivityDto,
|
||||
ActivityStageCountsDto,
|
||||
ActivityStageDto,
|
||||
PaginatedResponse,
|
||||
} from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { activityKeys } from '@/queries/keys';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
export async function fetchActivityBoards(): Promise<ActivityBoardDto[]> {
|
||||
const { data } = await api.get<ActivityBoardDto[]>('/activities/boards');
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchActivityStages(
|
||||
boardId: string | undefined,
|
||||
): Promise<ActivityStageDto[]> {
|
||||
const { data } = await api.get<ActivityStageDto[]>('/activities/stages', {
|
||||
params: { boardId: boardId || undefined },
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchActivityList(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<PaginatedResponse<ActivityDto>> {
|
||||
const { data } = await api.get<PaginatedResponse<ActivityDto>>('/activities', {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchActivityStageCounts(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<ActivityStageCountsDto> {
|
||||
const { data } = await api.get<ActivityStageCountsDto>('/activities/stage-counts', {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Time-tab badge totals (limit=1 per filter key). */
|
||||
export async function fetchActivityTimeCounts(
|
||||
base: Record<string, unknown>,
|
||||
timeKeys: string[],
|
||||
stageId: string,
|
||||
): Promise<Record<string, number>> {
|
||||
const results = await Promise.all(
|
||||
timeKeys.map((key) =>
|
||||
api.get<PaginatedResponse<ActivityDto>>('/activities', {
|
||||
params: { ...base, filter: key, stageId, limit: 1 },
|
||||
}),
|
||||
),
|
||||
);
|
||||
const next: Record<string, number> = {};
|
||||
timeKeys.forEach((key, i) => {
|
||||
next[key] = results[i]?.data.total ?? 0;
|
||||
});
|
||||
return next;
|
||||
}
|
||||
|
||||
export function invalidateActivityQueries() {
|
||||
return queryClient.invalidateQueries({ queryKey: activityKeys.all });
|
||||
}
|
||||
|
||||
export function invalidateActivityBoards() {
|
||||
return queryClient.invalidateQueries({ queryKey: activityKeys.boards() });
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import type {
|
||||
CompanyDto,
|
||||
CustomerGroupDto,
|
||||
PaginatedResponse,
|
||||
PersonDto,
|
||||
PersonImportSourceStatDto,
|
||||
} from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { contactKeys } from '@/queries/keys';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
export async function fetchPeople(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<PaginatedResponse<PersonDto>> {
|
||||
const { data } = await api.get<PaginatedResponse<PersonDto>>('/people', { params });
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchCompanies(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<PaginatedResponse<CompanyDto>> {
|
||||
const { data } = await api.get<PaginatedResponse<CompanyDto>>('/companies', { params });
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function fetchPeopleSourceStats(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<PersonImportSourceStatDto[]> {
|
||||
try {
|
||||
const { data } = await api.get<PersonImportSourceStatDto[]>('/people/source-stats', {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchPeopleGroupStats(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<CustomerGroupDto[]> {
|
||||
try {
|
||||
const { data } = await api.get<CustomerGroupDto[]>('/people/group-stats', { params });
|
||||
return data;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchCompanyGroupStats(
|
||||
params: Record<string, unknown>,
|
||||
): Promise<CustomerGroupDto[]> {
|
||||
try {
|
||||
const { data } = await api.get<CustomerGroupDto[]>('/companies/group-stats', { params });
|
||||
return data;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function invalidateContactQueries() {
|
||||
return queryClient.invalidateQueries({ queryKey: contactKeys.all });
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/** Hierarchical TanStack Query keys for CRM server state. */
|
||||
|
||||
export const userKeys = {
|
||||
all: ['users'] as const,
|
||||
org: () => [...userKeys.all, 'org'] as const,
|
||||
};
|
||||
|
||||
export const activityTypeKeys = {
|
||||
all: ['activity-types'] as const,
|
||||
list: () => [...activityTypeKeys.all, 'list'] as const,
|
||||
};
|
||||
|
||||
export const activityPriorityKeys = {
|
||||
all: ['activity-priorities'] as const,
|
||||
list: () => [...activityPriorityKeys.all, 'list'] as const,
|
||||
};
|
||||
|
||||
export const customerGroupKeys = {
|
||||
all: ['customer-groups'] as const,
|
||||
list: () => [...customerGroupKeys.all, 'list'] as const,
|
||||
};
|
||||
|
||||
export const activityKeys = {
|
||||
all: ['activities'] as const,
|
||||
boards: () => [...activityKeys.all, 'boards'] as const,
|
||||
stages: (boardId: string | undefined) =>
|
||||
[...activityKeys.all, 'stages', boardId ?? ''] as const,
|
||||
list: (params: Record<string, unknown>) =>
|
||||
[...activityKeys.all, 'list', params] as const,
|
||||
counts: (params: Record<string, unknown>) =>
|
||||
[...activityKeys.all, 'counts', params] as const,
|
||||
stageCounts: (params: Record<string, unknown>) =>
|
||||
[...activityKeys.all, 'stage-counts', params] as const,
|
||||
};
|
||||
|
||||
export const contactKeys = {
|
||||
all: ['contacts'] as const,
|
||||
people: (params: Record<string, unknown>) =>
|
||||
[...contactKeys.all, 'people', params] as const,
|
||||
companies: (params: Record<string, unknown>) =>
|
||||
[...contactKeys.all, 'companies', params] as const,
|
||||
peopleSourceStats: (params: Record<string, unknown>) =>
|
||||
[...contactKeys.all, 'people-source-stats', params] as const,
|
||||
peopleGroupStats: (params: Record<string, unknown>) =>
|
||||
[...contactKeys.all, 'people-group-stats', params] as const,
|
||||
companyGroupStats: (params: Record<string, unknown>) =>
|
||||
[...contactKeys.all, 'company-group-stats', params] as const,
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { QueryClient } from '@tanstack/vue-query';
|
||||
|
||||
/** Shared QueryClient — used by VueQueryPlugin and for clear/invalidate outside setup. */
|
||||
export const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 30_000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { computed, unref, type MaybeRef } from 'vue';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import type { OrgUserDto } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { userKeys } from '@/queries/keys';
|
||||
|
||||
const REF_STALE_MS = 5 * 60_000;
|
||||
|
||||
async function fetchOrgUsers(): Promise<OrgUserDto[]> {
|
||||
const { data } = await api.get<OrgUserDto[]>('/users');
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Org members list — shared across assign pickers and desk tabs. */
|
||||
export function useOrgUsersQuery(options?: {
|
||||
enabled?: MaybeRef<boolean>;
|
||||
/** When true (default), only users with isActive !== false. */
|
||||
activeOnly?: boolean;
|
||||
}) {
|
||||
const enabled = computed(() => unref(options?.enabled) ?? true);
|
||||
const activeOnly = options?.activeOnly !== false;
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: userKeys.org(),
|
||||
queryFn: fetchOrgUsers,
|
||||
staleTime: REF_STALE_MS,
|
||||
enabled,
|
||||
});
|
||||
|
||||
const users = computed(() => {
|
||||
const rows = query.data.value ?? [];
|
||||
return activeOnly ? rows.filter((u) => u.isActive !== false) : rows;
|
||||
});
|
||||
|
||||
return {
|
||||
...query,
|
||||
users,
|
||||
};
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import type {
|
||||
} from '@mento/shared';
|
||||
import { isLoginOrganizationChoice } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import { queryClient } from '@/queries/queryClient';
|
||||
|
||||
const TOKEN_KEY = 'mento_token';
|
||||
const USER_KEY = 'mento_user';
|
||||
@@ -74,7 +75,16 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function clearServerStateCache() {
|
||||
queryClient.clear();
|
||||
}
|
||||
|
||||
function persist(payload: LoginResponse) {
|
||||
const prevOrgId = user.value?.organizationId;
|
||||
const nextOrgId = payload.user.organizationId;
|
||||
if (prevOrgId && nextOrgId && prevOrgId !== nextOrgId) {
|
||||
clearServerStateCache();
|
||||
}
|
||||
token.value = payload.accessToken;
|
||||
user.value = payload.user;
|
||||
localStorage.setItem(TOKEN_KEY, payload.accessToken);
|
||||
@@ -169,6 +179,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
localStorage.removeItem(USER_KEY);
|
||||
clearLegacy();
|
||||
clearServerStateCache();
|
||||
}
|
||||
|
||||
function setUser(next: AuthUserDto) {
|
||||
|
||||
@@ -49,22 +49,27 @@
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "IRANSans";
|
||||
src:
|
||||
url("../assets/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Black.woff2") format("woff2"),
|
||||
url("../assets/fonts/iranSans/woff/IRANSansWeb(FaNum)_Black.woff") format("woff");
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
/* map common 600 → Bold so font-weight:600 works */
|
||||
/* 900 → Bold too: Black is a display cut and reads as shouting in UI chrome */
|
||||
@font-face {
|
||||
font-family: "IRANSans";
|
||||
src:
|
||||
url("../assets/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Bold.woff2") format("woff2"),
|
||||
url("../assets/fonts/iranSans/woff/IRANSansWeb(FaNum)_Bold.woff") format("woff");
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
/*
|
||||
* IRANSans has no semibold cut. 600 is Ant's fontWeightStrong (table heads,
|
||||
* titles, <strong>, active items) and the most used weight in the app, so it
|
||||
* maps to Medium; mapping it to Bold made the whole UI look heavy.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: "IRANSans";
|
||||
src:
|
||||
url("../assets/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Medium.woff2") format("woff2"),
|
||||
url("../assets/fonts/iranSans/woff/IRANSansWeb(FaNum)_Medium.woff") format("woff");
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
|
||||
@@ -150,13 +150,28 @@ body,
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Ant Message portals to body; keep above shell chrome (header/sidebar/modals). */
|
||||
.ant-message {
|
||||
z-index: 11000 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--font);
|
||||
/* match Ant's 14px base; without it plain markup inherited the browser's 16px */
|
||||
font-size: var(--fs-base);
|
||||
line-height: var(--lh-normal);
|
||||
color: var(--ink);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
/* UA default is `bold` (700 → IRANSans Bold); emphasis in UI should be semibold */
|
||||
strong,
|
||||
b,
|
||||
th {
|
||||
font-weight: var(--fw-semibold);
|
||||
}
|
||||
|
||||
img,
|
||||
svg,
|
||||
video,
|
||||
|
||||
@@ -15,8 +15,28 @@ const GRAY_200 = '#e5e7eb';
|
||||
export const antdTheme = {
|
||||
token: {
|
||||
colorPrimary: '#10897d',
|
||||
/**
|
||||
* Ant's generated tint for #10897d is a muddy grey-green; pin the light
|
||||
* brand tints (main.css --accent-subtle / --accent-soft) for selected items.
|
||||
*/
|
||||
colorPrimaryBg: '#eef8f7',
|
||||
colorPrimaryBgHover: '#d0ebe8',
|
||||
controlItemBgActive: '#eef8f7',
|
||||
controlItemBgActiveHover: '#e2f3f1',
|
||||
fontFamily: '"IRANSans", Tahoma, sans-serif',
|
||||
|
||||
/**
|
||||
* Ant's default heading scale (38/30/24/20/16) is sized for Latin
|
||||
* marketing pages; IRANSans runs large, so page titles (level 3) were 24px.
|
||||
* Compact app scale: page title 20, section 16, card title 14.
|
||||
*/
|
||||
fontSizeHeading1: 28,
|
||||
fontSizeHeading2: 24,
|
||||
fontSizeHeading3: 20,
|
||||
fontSizeHeading4: 16,
|
||||
fontSizeHeading5: 14,
|
||||
fontWeightStrong: 600,
|
||||
|
||||
/** Page / subtle surface fill */
|
||||
colorBgLayout: GRAY_50,
|
||||
colorFillQuaternary: GRAY_50,
|
||||
@@ -78,6 +98,10 @@ export const antdTheme = {
|
||||
},
|
||||
Select: {
|
||||
colorBorder: GRAY_200,
|
||||
optionSelectedBg: '#eef8f7',
|
||||
optionSelectedColor: '#0a5c54',
|
||||
optionSelectedFontWeight: 600,
|
||||
optionPadding: '7px 12px',
|
||||
},
|
||||
Form: {
|
||||
itemMarginBottom: 18,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import type { ActivityDto, PaginatedResponse } from '@mento/shared';
|
||||
import {
|
||||
addJalaliMonths,
|
||||
@@ -15,6 +14,8 @@ import {
|
||||
jalaliToDate,
|
||||
toFaDigits,
|
||||
} from '@/lib/jalali';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { CalendarOutlined, UnorderedListOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -257,30 +258,19 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<nav class="crumbs" aria-label="مسیر">
|
||||
<RouterLink :to="{ name: 'home' }">خانه</RouterLink>
|
||||
<span>‹</span>
|
||||
<RouterLink :to="{ name: 'activities' }">فعالیتها</RouterLink>
|
||||
<span>‹</span>
|
||||
<span>تقویم</span>
|
||||
</nav>
|
||||
|
||||
<header class="page-head">
|
||||
<div class="head-copy">
|
||||
<h1>تقویم فعالیتها</h1>
|
||||
<p class="lead">نمای ماهانه شمسی موعد تماس، جلسه و وظیفه.</p>
|
||||
</div>
|
||||
<div class="head-actions">
|
||||
<RouterLink class="btn ghost" :to="{ name: 'activities' }">
|
||||
<UiIcon name="list" :size="18" />
|
||||
لیست
|
||||
</RouterLink>
|
||||
<RouterLink class="btn primary" :to="newForSelected()">
|
||||
<span>+</span>
|
||||
فعالیت جدید
|
||||
</RouterLink>
|
||||
</div>
|
||||
</header>
|
||||
<PageHeader
|
||||
title="تقویم فعالیتها"
|
||||
subtitle="نمای ماهانه شمسی موعد تماس، جلسه و وظیفه."
|
||||
:icon="CalendarOutlined"
|
||||
primary-label="فعالیت جدید"
|
||||
:view-options="[
|
||||
{ value: 'list', label: 'لیست', icon: UnorderedListOutlined },
|
||||
{ value: 'calendar', label: 'تقویم', icon: CalendarOutlined },
|
||||
]"
|
||||
view="calendar"
|
||||
@primary="router.push(newForSelected())"
|
||||
@update:view="(v) => { if (v === 'list') void router.push({ name: 'activities' }) }"
|
||||
/>
|
||||
|
||||
<div class="nav">
|
||||
<button class="btn ghost nav-btn" type="button" @click="goMonth(-1)">ماه قبل</button>
|
||||
@@ -366,48 +356,6 @@ onMounted(() => {
|
||||
overflow-x: clip;
|
||||
}
|
||||
|
||||
.crumbs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
align-items: center;
|
||||
color: #94a3b8;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.crumbs a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.crumbs a:hover {
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.head-copy {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.head-actions {
|
||||
display: flex;
|
||||
gap: 0.55rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 0.3rem;
|
||||
font-size: clamp(1.45rem, 2.5vw, 1.85rem);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
@@ -650,26 +598,10 @@ h2 {
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.crumbs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.head-actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.head-actions .btn {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.day {
|
||||
min-height: 68px;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1199,21 +1199,23 @@ onUnmounted(() => {
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<header class="nav">
|
||||
<a class="icon-btn back" href="/activities" aria-label="بازگشت" @click.prevent="goBack">
|
||||
<UiIcon name="chevron" :size="18" />
|
||||
</a>
|
||||
<h1>جزئیات فعالیت</h1>
|
||||
<nav v-if="showNav" class="neighbors" aria-label="فعالیتهای همین فهرست">
|
||||
<button type="button" class="neighbor" :disabled="!prevNavId" @click="goNeighbor(prevNavId)">
|
||||
قبلی
|
||||
</button>
|
||||
<span>{{ toFaDigits(navIndex + 1) }} از {{ toFaDigits(navIds.length) }}</span>
|
||||
<button type="button" class="neighbor" :disabled="!nextNavId" @click="goNeighbor(nextNavId)">
|
||||
بعدی
|
||||
</button>
|
||||
</nav>
|
||||
</header>
|
||||
<PageHeader
|
||||
title="جزئیات فعالیت"
|
||||
:subtitle="activity?.title"
|
||||
:icon="ScheduleOutlined"
|
||||
backable
|
||||
@back="goBack"
|
||||
>
|
||||
<template v-if="showNav" #actions>
|
||||
<a-space :size="4" aria-label="فعالیتهای همین فهرست">
|
||||
<a-button type="text" :disabled="!prevNavId" @click="goNeighbor(prevNavId)">قبلی</a-button>
|
||||
<a-typography-text type="secondary">
|
||||
{{ toFaDigits(navIndex + 1) }} از {{ toFaDigits(navIds.length) }}
|
||||
</a-typography-text>
|
||||
<a-button type="text" :disabled="!nextNavId" @click="goNeighbor(nextNavId)">بعدی</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<p v-if="loading && !activity" class="muted">در حال بارگذاری…</p>
|
||||
<p v-else-if="error && !activity" class="error">{{ error }}</p>
|
||||
|
||||
@@ -1245,9 +1247,6 @@ onUnmounted(() => {
|
||||
#{{ t }}
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="activity.accountBalance" class="claim-balances">
|
||||
<ActivityAccountBalances :balance="activity.accountBalance" />
|
||||
</div>
|
||||
</div>
|
||||
<span class="type-ico" :style="typeColorStyle(draftTypeView!.color)">
|
||||
<UiIcon :name="draftTypeView!.icon" :size="22" />
|
||||
@@ -1698,11 +1697,7 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<ul v-if="entry.media.some((image) => image.kind === 'file')" class="note-files">
|
||||
<li v-for="image in entry.media.filter((item) => item.kind === 'file')" :key="image.id">
|
||||
<span class="note-file-name">{{ image.name }}</span>
|
||||
<span class="note-file-actions">
|
||||
<button type="button" class="note-file-btn" @click="viewMedia(image)">مشاهده</button>
|
||||
<button type="button" class="note-file-btn" @click="downloadMedia(image)">دانلود</button>
|
||||
</span>
|
||||
<a :href="image.url" :download="image.name">{{ image.name }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -1785,11 +1780,7 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<ul v-if="looseMedia.some((image) => image.kind === 'file')" class="note-files">
|
||||
<li v-for="image in looseMedia.filter((item) => item.kind === 'file')" :key="image.id">
|
||||
<span class="note-file-name">{{ image.name }}</span>
|
||||
<span class="note-file-actions">
|
||||
<button type="button" class="note-file-btn" @click="viewMedia(image)">مشاهده</button>
|
||||
<button type="button" class="note-file-btn" @click="downloadMedia(image)">دانلود</button>
|
||||
</span>
|
||||
<a :href="image.url" :download="image.name">{{ image.name }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1885,77 +1876,6 @@ onUnmounted(() => {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 32px;
|
||||
/* زیر هدر دسکتاپ اپ (۱۶ + control + ۱۶) بماند تا با اسکرول در دسترس باشد */
|
||||
position: sticky;
|
||||
top: calc(16px + var(--control-h) + 16px);
|
||||
z-index: 15;
|
||||
margin-inline: -16px;
|
||||
padding: 0.4rem 16px;
|
||||
background: color-mix(in srgb, var(--bg, #f8fafc) 92%, transparent);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.nav h1 {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
border-radius: var(--radius);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: #334155;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.back :deep(.ico) {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
.neighbors {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.15rem;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.neighbors span {
|
||||
color: #64748b;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
padding-inline: 0.2rem;
|
||||
}
|
||||
|
||||
.neighbor {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #0f766e;
|
||||
font: inherit;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.2rem 0.45rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.neighbor:disabled {
|
||||
color: #94a3b8;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.muted,
|
||||
.error {
|
||||
margin: 0;
|
||||
@@ -2048,10 +1968,6 @@ onUnmounted(() => {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.claim-balances {
|
||||
margin-top: 0.65rem;
|
||||
}
|
||||
|
||||
.tag {
|
||||
background: #f0fdfa;
|
||||
color: #0f766e;
|
||||
@@ -2150,10 +2066,6 @@ onUnmounted(() => {
|
||||
.meta {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.nav {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
dt,
|
||||
@@ -2731,35 +2643,8 @@ dd {
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.note-files li {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.note-file-name {
|
||||
.note-files a {
|
||||
color: #0f766e;
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.note-file-actions {
|
||||
display: inline-flex;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.note-file-btn {
|
||||
border: 1px solid #99f6e4;
|
||||
background: #fff;
|
||||
color: #0f766e;
|
||||
border-radius: 0.45rem;
|
||||
font: inherit;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
padding: 0.2rem 0.55rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dock {
|
||||
@@ -2797,13 +2682,6 @@ dd {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.nav {
|
||||
/* زیر هدر موبایل اپ (۰٫۷۵rem + control + ۰٫۷۵rem) */
|
||||
top: calc(0.75rem + var(--control-h) + 0.75rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 899px) {
|
||||
.page {
|
||||
padding-bottom: calc(1rem + var(--mobile-tabbar-h));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canAssignToOthers } from '@/lib/assign-access';
|
||||
import {
|
||||
@@ -71,6 +71,7 @@ const emit = defineEmits<{ saved: []; cancel: [] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const auth = useAuthStore();
|
||||
const id = computed(() => {
|
||||
if (props.embedded) return props.entityId ?? '';
|
||||
@@ -820,9 +821,14 @@ function removePendingPhoto(localId: string) {
|
||||
async function removeSavedPhoto(photo: SavedPhoto) {
|
||||
const activityId = id.value || createdActivityId.value;
|
||||
if (!activityId) return;
|
||||
try {
|
||||
await api.delete(`/activities/${activityId}/images/${photo.id}`);
|
||||
if (photo.previewUrl.startsWith('blob:')) URL.revokeObjectURL(photo.previewUrl);
|
||||
savedPhotos.value = savedPhotos.value.filter((item) => item.id !== photo.id);
|
||||
feedback.success('تصویر حذف شد.');
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف تصویر ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
function formatVoiceClock(total: number) {
|
||||
@@ -896,9 +902,14 @@ function removePendingVoice(localId: string) {
|
||||
async function removeSavedVoice(voice: SavedVoice) {
|
||||
const activityId = id.value || createdActivityId.value;
|
||||
if (!activityId) return;
|
||||
try {
|
||||
await api.delete(`/activities/${activityId}/images/${voice.id}`);
|
||||
if (voice.previewUrl.startsWith('blob:')) URL.revokeObjectURL(voice.previewUrl);
|
||||
savedVoices.value = savedVoices.value.filter((item) => item.id !== voice.id);
|
||||
feedback.success('صوت حذف شد.');
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف صوت ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
function removePendingFile(localId: string) {
|
||||
@@ -908,8 +919,13 @@ function removePendingFile(localId: string) {
|
||||
async function removeSavedFile(file: SavedFile) {
|
||||
const activityId = id.value || createdActivityId.value;
|
||||
if (!activityId) return;
|
||||
try {
|
||||
await api.delete(`/activities/${activityId}/images/${file.id}`);
|
||||
savedFiles.value = savedFiles.value.filter((item) => item.id !== file.id);
|
||||
feedback.success('فایل حذف شد.');
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف فایل ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadPendingFiles(activityId: string) {
|
||||
@@ -1018,6 +1034,7 @@ async function submit(next: 'detail' | 'new' = 'detail') {
|
||||
await uploadPendingPhotos(savedId);
|
||||
await uploadPendingVoices(savedId);
|
||||
await uploadPendingFiles(savedId);
|
||||
feedback.success('فعالیت ذخیره شد.');
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
@@ -1031,15 +1048,7 @@ async function submit(next: 'detail' | 'new' = 'detail') {
|
||||
}
|
||||
await router.replace({ name: 'activity-detail', params: { id: savedId } });
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { DownloadOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Link: ATypographyLink } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { PaperClipOutlined } from '@/icons/ant-bridge';
|
||||
const { Link: ATypographyLink } = Typography;
|
||||
|
||||
type Row = NoteAttachmentDto & {
|
||||
noteId: string;
|
||||
@@ -105,7 +107,12 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">پیوستها</a-typography-title>
|
||||
<PageHeader
|
||||
title="پیوستها"
|
||||
subtitle="فایلهای پیوستشده به یادداشتها"
|
||||
:icon="PaperClipOutlined"
|
||||
:count="loading ? undefined : items.length"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ import {
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Table as ATable,
|
||||
Tabs as ATabs,
|
||||
TabPane as ATabPane,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
@@ -40,7 +38,9 @@ import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { ReloadOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { HistoryOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
type LogTab = 'all' | 'creates' | 'edits' | 'deletes' | 'attendance';
|
||||
|
||||
@@ -454,17 +454,20 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">لاگ فعالیت کاربران</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load()">
|
||||
<PageHeader
|
||||
title="لاگ فعالیت کاربران"
|
||||
subtitle="چه کسی، چه زمانی، چه تغییری داده است"
|
||||
:icon="HistoryOutlined"
|
||||
:tabs="visibleTabs.map((item) => ({ key: item.key, label: item.label }))"
|
||||
:active-tab="tab"
|
||||
@update:active-tab="(k) => selectTab(k ?? 'all')"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load()">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
|
||||
<a-tabs :active-key="tab" @change="selectTab">
|
||||
<a-tab-pane v-for="item in visibleTabs" :key="item.key" :tab="item.label" />
|
||||
</a-tabs>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-card v-if="showingArchive" :bordered="false">
|
||||
<a-form layout="vertical">
|
||||
|
||||
@@ -56,9 +56,11 @@ import {
|
||||
SearchOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ThunderboltOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const auth = useAuthStore();
|
||||
@@ -587,12 +589,17 @@ watch(trigger, (next, prev) => {
|
||||
:gap="token.margin"
|
||||
:style="{ flex: 1, minHeight: 0, height: '100%' }"
|
||||
>
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون</a-typography-title>
|
||||
<a-space wrap>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<PageHeader
|
||||
title="اتوماسیون"
|
||||
subtitle="قانونهایی که با رخدادهای CRM خودکار اجرا میشوند"
|
||||
:icon="ThunderboltOutlined"
|
||||
primary-label="قانون جدید"
|
||||
:style="{ flex: '0 0 auto' }"
|
||||
@primary="openCreateModal"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="editingId"
|
||||
@@ -604,12 +611,8 @@ watch(trigger, (next, prev) => {
|
||||
>
|
||||
ذخیره قانون
|
||||
</a-button>
|
||||
<a-button type="primary" @click="openCreateModal">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
قانون جدید
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -31,19 +31,17 @@ import {
|
||||
Modal as AModal,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Table as ATable,
|
||||
TabPane as ATabPane,
|
||||
Tabs as ATabs,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { PlusOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { ReloadOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { CreditCardOutlined } from '@/icons/ant-bridge';
|
||||
const {
|
||||
Title: ATypographyTitle,
|
||||
Text: ATypographyText,
|
||||
Link: ATypographyLink,
|
||||
Paragraph: ATypographyParagraph,
|
||||
@@ -350,26 +348,25 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">چکها</a-typography-title>
|
||||
<a-space wrap :size="8">
|
||||
<a-button type="primary" @click="openForm('in')">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
دریافت چک
|
||||
<PageHeader
|
||||
title="چکها"
|
||||
subtitle="چکهای دریافتی و پرداختی و وضعیت وصول"
|
||||
:icon="CreditCardOutlined"
|
||||
primary-label="دریافت چک"
|
||||
:tabs="[{ key: 'in', label: 'دریافتی' }, { key: 'out', label: 'پرداختی' }]"
|
||||
:active-tab="tab"
|
||||
@primary="openForm('in')"
|
||||
@update:active-tab="(k) => onTabChange(k ?? 'in')"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
</a-button>
|
||||
<a-button @click="openForm('out')">پرداخت چک</a-button>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-tabs :active-key="tab" @change="onTabChange">
|
||||
<a-tab-pane key="in" tab="دریافتی" />
|
||||
<a-tab-pane key="out" tab="پرداختی" />
|
||||
</a-tabs>
|
||||
|
||||
<a-form layout="vertical" @finish="load">
|
||||
<a-row :gutter="[16, 0]" align="bottom">
|
||||
|
||||
@@ -30,7 +30,8 @@ import {
|
||||
import type { CommissionEntryDto } from '@mento/shared';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Link: ATypographyLink } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
const { Text: ATypographyText, Link: ATypographyLink } = Typography;
|
||||
|
||||
const COMMISSION_COL_LABELS = [
|
||||
'کارشناس فروش',
|
||||
@@ -111,15 +112,17 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">پورسانت فروش</a-typography-title>
|
||||
</div>
|
||||
<a-button :disabled="loading" :loading="loading" @click="load">
|
||||
<PageHeader
|
||||
title="پورسانت فروش"
|
||||
subtitle="پورسانت کارشناسان از فاکتورهای تأییدشده"
|
||||
:icon="WalletOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" :loading="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :xs="24" :md="8">
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Breadcrumb as ABreadcrumb,
|
||||
BreadcrumbItem as ABreadcrumbItem,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
@@ -18,7 +16,6 @@ import {
|
||||
Row as ARow,
|
||||
Space as ASpace,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { CheckOutlined, DeleteOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
@@ -30,8 +27,9 @@ import RelatedTasksPanel from '@/components/routines/RelatedTasksPanel.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import CustomerGroupPicker from '@/components/CustomerGroupPicker.vue';
|
||||
import { formatLocalDateInput, parseLocalInput } from '@/lib/jalali';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { BankOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -225,46 +223,22 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16" dir="rtl">
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="pageTitle"
|
||||
subtitle="ثبت و ویرایش مشخصات حقوقی، اطلاعات تماس و فیلدهای سفارشی شرکت"
|
||||
:icon="BankOutlined"
|
||||
primary-label="ذخیره"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
:menu-items="isNew ? [] : [{ key: 'delete', label: 'حذف شرکت', icon: DeleteOutlined, danger: true, disabled: saving }]"
|
||||
@primary="submit"
|
||||
@menu="remove"
|
||||
>
|
||||
<a-flex vertical :gap="4">
|
||||
<a-breadcrumb>
|
||||
<a-breadcrumb-item>
|
||||
<RouterLink :to="{ name: 'contacts', query: { tab: 'companies' } }">
|
||||
شرکتها
|
||||
</RouterLink>
|
||||
</a-breadcrumb-item>
|
||||
<a-breadcrumb-item>{{ pageTitle }}</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ pageTitle }}
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
ثبت و ویرایش مشخصات حقوقی، اطلاعات تماس و فیلدهای سفارشی شرکت
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button type="primary" :loading="saving" @click="submit">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
ذخیره
|
||||
</a-button>
|
||||
<template #actions>
|
||||
<a-button :disabled="saving" @click="cancel">انصراف</a-button>
|
||||
<a-button
|
||||
v-if="!isNew"
|
||||
danger
|
||||
:disabled="saving"
|
||||
@click="remove"
|
||||
>
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
حذف
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
+506
-201
@@ -1,50 +1,93 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
Dropdown as ADropdown,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Grid,
|
||||
List as AList,
|
||||
ListItem as AListItem,
|
||||
Menu as AMenu,
|
||||
MenuItem as AMenuItem,
|
||||
Modal as AModal,
|
||||
Pagination as APagination,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Table as ATable,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import {
|
||||
BankOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
FileExcelOutlined,
|
||||
IdcardOutlined,
|
||||
MailOutlined,
|
||||
MoreOutlined,
|
||||
PhoneOutlined,
|
||||
TeamOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { api } from '@/lib/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
|
||||
import CustomerMoodFace from '@/components/CustomerMoodFace.vue';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import PhoneContactsImport from '@/components/PhoneContactsImport.vue';
|
||||
import {
|
||||
UiBusyOverlay,
|
||||
UiButton,
|
||||
UiDropdownMenu,
|
||||
UiModal,
|
||||
UiPagination,
|
||||
UiEmptyState,
|
||||
} from '@/components/ui';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { Drawer as ADrawer } from 'ant-design-vue';
|
||||
import { FilterChips, PageHeader } from '@/components/page';
|
||||
import type {
|
||||
PageHeaderActiveFilter,
|
||||
PageHeaderMenuItem,
|
||||
PageHeaderTab,
|
||||
} from '@/components/page';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import PersonFormView from '@/views/PersonFormView.vue';
|
||||
import CompanyFormView from '@/views/CompanyFormView.vue';
|
||||
import SavedFiltersBar from '@/components/SavedFiltersBar.vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
|
||||
import type {
|
||||
CompanyDto,
|
||||
CustomerGroupDto,
|
||||
ImportContactsResult,
|
||||
PaginatedResponse,
|
||||
PersonDto,
|
||||
PersonImportSource,
|
||||
PersonImportSourceStatDto,
|
||||
PersonMood,
|
||||
} from '@mento/shared';
|
||||
import {
|
||||
brand,
|
||||
PERSON_IMPORT_SOURCE_LABELS,
|
||||
PERSON_IMPORT_SOURCES,
|
||||
} from '@mento/shared';
|
||||
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
||||
import { canUseBehavior } from '@/lib/behavior-access';
|
||||
import DiscBadge from '@/components/behavior/DiscBadge.vue';
|
||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||
import CustomerGroupChips from '@/components/CustomerGroupChips.vue';
|
||||
import CustomerGroupsManager from '@/components/CustomerGroupsManager.vue';
|
||||
import { groupSwatch, useCustomerGroups } from '@/lib/customer-groups';
|
||||
import ContactsFilterPanel, { type ContactsFilterValue } from '@/components/ContactsFilterPanel.vue';
|
||||
import { useCustomerGroups } from '@/lib/customer-groups';
|
||||
import { type ContactsFilterValue } from '@/components/ContactsFilterPanel.vue';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
import { contactKeys } from '@/queries/keys';
|
||||
import {
|
||||
fetchCompanies,
|
||||
fetchCompanyGroupStats,
|
||||
fetchPeople,
|
||||
fetchPeopleGroupStats,
|
||||
fetchPeopleSourceStats,
|
||||
invalidateContactQueries,
|
||||
} from '@/queries/contacts';
|
||||
|
||||
const { Link: ATypographyLink, Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
const screens = Grid.useBreakpoint();
|
||||
|
||||
type Tab = 'people' | 'companies';
|
||||
type SortKey = 'name' | 'newest';
|
||||
@@ -83,9 +126,7 @@ const discFilter = computed(() => {
|
||||
const sourceFilters = computed(() => queryList('source'));
|
||||
const activityExperienceFilters = computed(() => queryList('activityExperience'));
|
||||
const groupFilters = computed(() => queryList('group'));
|
||||
const { groups: customerGroups, load: loadCustomerGroups } = useCustomerGroups();
|
||||
/** گروههای فیلتر — با شمارش scoped بر اساس دسترسی کاربر */
|
||||
const filterGroups = ref<CustomerGroupDto[]>([]);
|
||||
const { groups: customerGroups } = useCustomerGroups();
|
||||
const canManageGroups = computed(() => canManageSettings(auth.user?.role));
|
||||
const groupsManagerOpen = ref(false);
|
||||
|
||||
@@ -124,15 +165,11 @@ const activeTags = computed<FilterTag[]>(() => {
|
||||
return tags;
|
||||
});
|
||||
const q = ref(typeof route.query.q === 'string' ? route.query.q : '');
|
||||
const loading = ref(false);
|
||||
const busy = ref(false);
|
||||
const pageBusy = ref(false);
|
||||
const busyMessage = ref('لطفاً صبر کنید…');
|
||||
const error = ref('');
|
||||
const importMsg = ref('');
|
||||
const people = ref<PaginatedResponse<PersonDto> | null>(null);
|
||||
const companies = ref<PaginatedResponse<CompanyDto> | null>(null);
|
||||
const sourceStats = ref<PersonImportSourceStatDto[]>([]);
|
||||
const menuId = ref<string | null>(null);
|
||||
const sortOpen = ref(false);
|
||||
const filterOpen = ref(false);
|
||||
@@ -158,6 +195,91 @@ const SORT_OPTIONS = [
|
||||
{ value: 'newest', label: 'جدیدترین' },
|
||||
];
|
||||
|
||||
const peopleParams = computed(() => ({
|
||||
q: q.value || undefined,
|
||||
page: page.value,
|
||||
limit: pageSize.value,
|
||||
sort: sort.value,
|
||||
mood: csv(moodFilters.value),
|
||||
importSource: csv(sourceFilters.value),
|
||||
activityExperience: csv(activityExperienceFilters.value),
|
||||
disc: discFilter.value || undefined,
|
||||
groupId: csv(groupFilters.value),
|
||||
}));
|
||||
|
||||
const companyParams = computed(() => ({
|
||||
q: q.value || undefined,
|
||||
page: page.value,
|
||||
limit: pageSize.value,
|
||||
groupId: csv(groupFilters.value),
|
||||
}));
|
||||
|
||||
const peopleQuery = useQuery({
|
||||
queryKey: computed(() => contactKeys.people({ ...peopleParams.value })),
|
||||
queryFn: () => fetchPeople({ ...peopleParams.value }),
|
||||
enabled: computed(() => tab.value === 'people'),
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
|
||||
const companiesQuery = useQuery({
|
||||
queryKey: computed(() => contactKeys.companies({ ...companyParams.value })),
|
||||
queryFn: () => fetchCompanies({ ...companyParams.value }),
|
||||
enabled: computed(() => tab.value === 'companies'),
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
|
||||
const peopleSourceStatsQuery = useQuery({
|
||||
queryKey: computed(() => contactKeys.peopleSourceStats({ ...peopleParams.value })),
|
||||
queryFn: () => fetchPeopleSourceStats({ ...peopleParams.value }),
|
||||
enabled: computed(() => tab.value === 'people'),
|
||||
staleTime: 60_000,
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
|
||||
const peopleGroupStatsQuery = useQuery({
|
||||
queryKey: computed(() => contactKeys.peopleGroupStats({ ...peopleParams.value })),
|
||||
queryFn: () => fetchPeopleGroupStats({ ...peopleParams.value }),
|
||||
enabled: computed(() => tab.value === 'people'),
|
||||
staleTime: 60_000,
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
|
||||
const companyGroupStatsQuery = useQuery({
|
||||
queryKey: computed(() => contactKeys.companyGroupStats({ ...companyParams.value })),
|
||||
queryFn: () => fetchCompanyGroupStats({ ...companyParams.value }),
|
||||
enabled: computed(() => tab.value === 'companies'),
|
||||
staleTime: 60_000,
|
||||
placeholderData: (prev) => prev,
|
||||
});
|
||||
|
||||
const people = computed(() => peopleQuery.data.value ?? null);
|
||||
const companies = computed(() => companiesQuery.data.value ?? null);
|
||||
const sourceStats = computed(() => peopleSourceStatsQuery.data.value ?? []);
|
||||
const filterGroups = computed(() =>
|
||||
tab.value === 'people'
|
||||
? (peopleGroupStatsQuery.data.value ?? [])
|
||||
: (companyGroupStatsQuery.data.value ?? []),
|
||||
);
|
||||
|
||||
const loading = computed(() => {
|
||||
if (tab.value === 'people') {
|
||||
return peopleQuery.isFetching.value && peopleQuery.data.value == null;
|
||||
}
|
||||
return companiesQuery.isFetching.value && companiesQuery.data.value == null;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => (tab.value === 'people' ? peopleQuery.error.value : companiesQuery.error.value),
|
||||
(err) => {
|
||||
if (!err) return;
|
||||
if (axios.isAxiosError(err) && !err.response) {
|
||||
error.value = 'اتصال به API برقرار نشد.';
|
||||
} else {
|
||||
error.value = 'بارگذاری مخاطبین ناموفق بود.';
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const total = computed(() =>
|
||||
tab.value === 'people' ? people.value?.total ?? 0 : companies.value?.total ?? 0,
|
||||
);
|
||||
@@ -166,6 +288,14 @@ const rowOffset = computed(() => (page.value - 1) * pageSize.value);
|
||||
|
||||
const selectedIds = ref<string[]>([]);
|
||||
const pageIds = computed(() => people.value?.items.map((p) => p.id) ?? []);
|
||||
|
||||
watch(
|
||||
() => people.value?.items.map((p) => p.id) ?? [],
|
||||
(ids) => {
|
||||
const visible = new Set(ids);
|
||||
selectedIds.value = selectedIds.value.filter((id) => visible.has(id));
|
||||
},
|
||||
);
|
||||
const allSelected = computed(
|
||||
() => pageIds.value.length > 0 && pageIds.value.every((id) => selectedIds.value.includes(id)),
|
||||
);
|
||||
@@ -206,7 +336,7 @@ async function deleteSelected() {
|
||||
|
||||
function onPageSize(size: number) {
|
||||
pageSize.value = size;
|
||||
if (page.value === 1) void load();
|
||||
/* peopleParams/companyParams include limit → query key refetch */
|
||||
}
|
||||
|
||||
const peopleSavedFilters = computed(() => {
|
||||
@@ -316,63 +446,17 @@ function closePopups() {
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
closePopups();
|
||||
void loadCustomerGroups(true).catch(() => undefined);
|
||||
try {
|
||||
await invalidateContactQueries();
|
||||
if (tab.value === 'people') {
|
||||
const [peopleRes, statsRes, groupStatsRes] = await Promise.all([
|
||||
api.get<PaginatedResponse<PersonDto>>('/people', {
|
||||
params: {
|
||||
q: q.value || undefined,
|
||||
page: page.value,
|
||||
limit: pageSize.value,
|
||||
sort: sort.value,
|
||||
mood: csv(moodFilters.value),
|
||||
importSource: csv(sourceFilters.value),
|
||||
activityExperience: csv(activityExperienceFilters.value),
|
||||
disc: discFilter.value || undefined,
|
||||
groupId: csv(groupFilters.value),
|
||||
},
|
||||
}),
|
||||
api.get<PersonImportSourceStatDto[]>('/people/source-stats').catch(() => ({
|
||||
data: [] as PersonImportSourceStatDto[],
|
||||
})),
|
||||
api.get<CustomerGroupDto[]>('/people/group-stats').catch(() => ({
|
||||
data: [] as CustomerGroupDto[],
|
||||
})),
|
||||
await Promise.all([
|
||||
peopleQuery.refetch(),
|
||||
peopleSourceStatsQuery.refetch(),
|
||||
peopleGroupStatsQuery.refetch(),
|
||||
]);
|
||||
people.value = peopleRes.data;
|
||||
sourceStats.value = statsRes.data;
|
||||
filterGroups.value = groupStatsRes.data;
|
||||
const visible = new Set(peopleRes.data.items.map((p) => p.id));
|
||||
selectedIds.value = selectedIds.value.filter((id) => visible.has(id));
|
||||
} else {
|
||||
const [companiesRes, groupStatsRes] = await Promise.all([
|
||||
api.get<PaginatedResponse<CompanyDto>>('/companies', {
|
||||
params: {
|
||||
q: q.value || undefined,
|
||||
page: page.value,
|
||||
limit: pageSize.value,
|
||||
groupId: csv(groupFilters.value),
|
||||
},
|
||||
}),
|
||||
api.get<CustomerGroupDto[]>('/companies/group-stats').catch(() => ({
|
||||
data: [] as CustomerGroupDto[],
|
||||
})),
|
||||
]);
|
||||
companies.value = companiesRes.data;
|
||||
filterGroups.value = groupStatsRes.data;
|
||||
}
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e) && !e.response) {
|
||||
error.value = 'اتصال به API برقرار نشد.';
|
||||
} else {
|
||||
error.value = 'بارگذاری مخاطبین ناموفق بود.';
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
await Promise.all([companiesQuery.refetch(), companyGroupStatsQuery.refetch()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,34 +659,355 @@ function onImportSettled() {
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [route.query.tab, route.query.q, route.query.page, route.query.sort, route.query.mood, route.query.disc, route.query.source, route.query.group],
|
||||
() => route.query.q,
|
||||
() => {
|
||||
q.value = typeof route.query.q === 'string' ? route.query.q : '';
|
||||
void load();
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(load);
|
||||
const isCompact = computed(() => !screens.value.lg);
|
||||
const excelImportTrigger = ref<HTMLElement | null>(null);
|
||||
const phoneImportTrigger = ref<HTMLElement | null>(null);
|
||||
|
||||
const contactModalOpen = computed({
|
||||
get: () => contactModal.value !== null,
|
||||
set: (open: boolean) => {
|
||||
if (!open) contactModal.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
/** سلکت سریع هدر — تکمقدار روی query چندمقداری */
|
||||
const moodFilter = computed<PersonMood | 'all'>(() => moodFilters.value[0] ?? 'all');
|
||||
const sourceFilter = computed<PersonImportSource | 'all'>(() => {
|
||||
const value = sourceFilters.value[0];
|
||||
return value && PERSON_IMPORT_SOURCES.includes(value as PersonImportSource)
|
||||
? (value as PersonImportSource)
|
||||
: 'all';
|
||||
});
|
||||
|
||||
const headerTabs: PageHeaderTab[] = [
|
||||
{ key: 'people', label: 'اشخاص' },
|
||||
{ key: 'companies', label: 'شرکتها' },
|
||||
];
|
||||
|
||||
const headerMenuItems = computed<PageHeaderMenuItem[]>(() => {
|
||||
const items: PageHeaderMenuItem[] = [
|
||||
{ key: 'export', label: 'خروجی اکسل', icon: FileExcelOutlined },
|
||||
{ key: 'import', label: 'ورود از اکسل', icon: FileExcelOutlined },
|
||||
];
|
||||
if (tab.value === 'people') {
|
||||
items.push({ key: 'phone', label: 'از مخاطبین گوشی', icon: PhoneOutlined });
|
||||
}
|
||||
if (canManageGroups.value) {
|
||||
items.push({
|
||||
key: 'groups',
|
||||
label: 'مدیریت گروهها',
|
||||
dividerBefore: true,
|
||||
});
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
const KIND_LABEL: Record<FilterTag['kind'], string> = {
|
||||
group: 'گروه',
|
||||
source: 'منبع',
|
||||
mood: 'وضعیت',
|
||||
disc: 'DISC',
|
||||
activityExperience: 'سابقه',
|
||||
};
|
||||
|
||||
const activeFilterChips = computed<PageHeaderActiveFilter[]>(() =>
|
||||
activeTags.value.map((tag) => ({
|
||||
key: `${tag.kind}:${tag.value}`,
|
||||
label: KIND_LABEL[tag.kind],
|
||||
value: tag.label,
|
||||
})),
|
||||
);
|
||||
|
||||
function onHeaderMenu(key: string) {
|
||||
if (key === 'export') void exportExcel();
|
||||
else if (key === 'import') excelImportTrigger.value?.click();
|
||||
else if (key === 'phone') phoneImportTrigger.value?.click();
|
||||
else if (key === 'groups') groupsManagerOpen.value = true;
|
||||
}
|
||||
|
||||
function onHeaderTab(key: string | number) {
|
||||
setTab(String(key) === 'companies' ? 'companies' : 'people');
|
||||
}
|
||||
|
||||
function onSearchInput(value: string) {
|
||||
q.value = value;
|
||||
}
|
||||
|
||||
function onRemoveFilter(key: string) {
|
||||
const sep = key.indexOf(':');
|
||||
if (sep < 0) return;
|
||||
const kind = key.slice(0, sep) as FilterTag['kind'];
|
||||
const value = key.slice(sep + 1);
|
||||
const tag = activeTags.value.find((t) => t.kind === kind && t.value === value);
|
||||
if (tag) removeTag(tag);
|
||||
}
|
||||
|
||||
function clearPeopleFilters() {
|
||||
clearFilters();
|
||||
}
|
||||
|
||||
const PEOPLE_COL_LABELS = [
|
||||
'#',
|
||||
'وضعیت',
|
||||
'نام شخص',
|
||||
'منبع',
|
||||
'کد مبدأ',
|
||||
'سمت',
|
||||
'شرکت',
|
||||
'تلفن',
|
||||
'ایمیل',
|
||||
'تاریخ ثبت',
|
||||
];
|
||||
const COMPANY_COL_LABELS = [
|
||||
'#',
|
||||
'نام شرکت',
|
||||
'کد دیدار شرکت',
|
||||
'کد شرکت',
|
||||
'منبع',
|
||||
'گروه بندی',
|
||||
'استان',
|
||||
'شهرستان',
|
||||
'تلفن شرکت',
|
||||
'ایمیل شرکت',
|
||||
'شناسه ملی',
|
||||
'شماره اقتصادی',
|
||||
'مسئول شرکت',
|
||||
'تاریخ ثبت',
|
||||
'افراد',
|
||||
];
|
||||
registerTableColumns('contacts.people', PEOPLE_COL_LABELS);
|
||||
registerTableColumns('contacts.companies', COMPANY_COL_LABELS);
|
||||
const peopleCols = useTableColumns(() => 'contacts.people');
|
||||
const companyCols = useTableColumns(() => 'contacts.companies');
|
||||
|
||||
function shownColumns<T>(cols: TableColumnsType<T>, visible: (label: string) => boolean) {
|
||||
return cols.filter((col) => {
|
||||
const title = typeof col.title === 'string' ? col.title : '';
|
||||
if (!title || col.key === 'select' || col.key === 'actions') return true;
|
||||
return visible(title);
|
||||
});
|
||||
}
|
||||
|
||||
const peopleColumns = computed<TableColumnsType<PersonDto>>(() =>
|
||||
shownColumns(
|
||||
[
|
||||
{ title: '', key: 'select', width: 48 },
|
||||
{ title: '#', key: 'row', width: 72 },
|
||||
{ title: 'وضعیت', key: 'mood', width: 88 },
|
||||
{ title: 'نام شخص', key: 'name' },
|
||||
{ title: 'منبع', key: 'source' },
|
||||
{ title: 'کد مبدأ', key: 'code', width: 120 },
|
||||
{ title: 'سمت', key: 'position' },
|
||||
{ title: 'شرکت', key: 'company' },
|
||||
{ title: 'تلفن', key: 'phone' },
|
||||
{ title: 'ایمیل', key: 'email' },
|
||||
{ title: 'تاریخ ثبت', key: 'createdAt', width: 130 },
|
||||
{ title: '', key: 'actions', width: 56 },
|
||||
],
|
||||
(label) => peopleCols.isVisible(label),
|
||||
),
|
||||
);
|
||||
|
||||
const companyColumns = computed<TableColumnsType<CompanyDto>>(() =>
|
||||
shownColumns(
|
||||
[
|
||||
{ title: '#', key: 'row', width: 72 },
|
||||
{ title: 'نام شرکت', key: 'name' },
|
||||
{ title: 'کد دیدار شرکت', key: 'sourceRef' },
|
||||
{ title: 'کد شرکت', key: 'code' },
|
||||
{ title: 'منبع', key: 'source' },
|
||||
{ title: 'گروه بندی', key: 'group' },
|
||||
{ title: 'استان', key: 'province' },
|
||||
{ title: 'شهرستان', key: 'city' },
|
||||
{ title: 'تلفن شرکت', key: 'phone' },
|
||||
{ title: 'ایمیل شرکت', key: 'email' },
|
||||
{ title: 'شناسه ملی', key: 'nationalId' },
|
||||
{ title: 'شماره اقتصادی', key: 'economicCode' },
|
||||
{ title: 'مسئول شرکت', key: 'owner' },
|
||||
{ title: 'تاریخ ثبت', key: 'createdAt', width: 130 },
|
||||
{ title: 'افراد', key: 'peopleCount', width: 80 },
|
||||
],
|
||||
(label) => companyCols.isVisible(label),
|
||||
),
|
||||
);
|
||||
|
||||
const sortOptions: Array<{ value: SortKey; label: string }> = [
|
||||
{ value: 'name', label: 'نام' },
|
||||
{ value: 'newest', label: 'جدیدترین' },
|
||||
];
|
||||
|
||||
const moodOptions = computed(() => [
|
||||
{ value: 'all', label: 'همه' },
|
||||
...PERSON_MOODS.map((mood) => ({ value: mood, label: moodLabel(mood) })),
|
||||
]);
|
||||
|
||||
const sourceOptions = computed(() => [
|
||||
{ value: 'all', label: 'همه منابع' },
|
||||
...sourceStats.value.map((row) => ({
|
||||
value: row.source,
|
||||
label: `${row.label} (${toFaDigits(row.count)})`,
|
||||
})),
|
||||
]);
|
||||
|
||||
const discOptions = [
|
||||
{ value: 'D', label: 'D' },
|
||||
{ value: 'I', label: 'I' },
|
||||
{ value: 'S', label: 'S' },
|
||||
{ value: 'C', label: 'C' },
|
||||
];
|
||||
|
||||
const discSelected = computed(() =>
|
||||
discFilter.value ? discFilter.value.split('/').filter(Boolean) : [],
|
||||
);
|
||||
|
||||
function onDiscChange(next: string[]) {
|
||||
const cleaned = discOptions.map((o) => o.value).filter((v) => next.includes(v));
|
||||
patchQuery({ disc: cleaned.length ? cleaned.join('/') : undefined, page: undefined });
|
||||
}
|
||||
|
||||
function moodTagColor(mood: PersonMood) {
|
||||
if (mood === 'happy') return 'purple';
|
||||
if (mood === 'unhappy') return 'error';
|
||||
if (mood === 'special') return 'warning';
|
||||
return 'success';
|
||||
}
|
||||
|
||||
function onSortChange(value: unknown) {
|
||||
if (Array.isArray(value)) {
|
||||
setSort(value[0] === 'newest' ? 'newest' : 'name');
|
||||
return;
|
||||
}
|
||||
setSort(value === 'newest' ? 'newest' : 'name');
|
||||
}
|
||||
|
||||
function onMoodChange(value: unknown) {
|
||||
const next =
|
||||
typeof value === 'string' && PERSON_MOODS.includes(value as PersonMood)
|
||||
? (value as PersonMood)
|
||||
: undefined;
|
||||
patchQuery({ mood: next, page: undefined });
|
||||
}
|
||||
|
||||
function onSourceChange(value: unknown) {
|
||||
const next =
|
||||
typeof value === 'string' && PERSON_IMPORT_SOURCES.includes(value as PersonImportSource)
|
||||
? value
|
||||
: undefined;
|
||||
patchQuery({ source: next, page: undefined });
|
||||
}
|
||||
|
||||
function onPersonMenu(id: string, prefix: 't' | 'm', open: boolean) {
|
||||
menuId.value = open ? `${prefix}:${id}` : null;
|
||||
}
|
||||
|
||||
function onTablePage(nextPage: number, nextSize: number) {
|
||||
const size = Number(nextSize);
|
||||
if (size !== pageSize.value) onPageSize(size);
|
||||
if (nextPage !== page.value) setPage(nextPage);
|
||||
}
|
||||
|
||||
function pageTotalText(totalCount: number, range: [number, number]) {
|
||||
return `نمایش ${toFaDigits(range[0])} تا ${toFaDigits(range[1])} از ${toFaDigits(totalCount)}`;
|
||||
}
|
||||
|
||||
function peopleCustomRow(record: PersonDto) {
|
||||
return {
|
||||
style: selectedIds.value.includes(record.id)
|
||||
? { background: token.value.colorPrimaryBg }
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16" @click="closePopups">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">مخاطبین</a-typography-title>
|
||||
</div>
|
||||
<a-space wrap>
|
||||
<RouterLink v-if="canBehavior" :to="{ name: 'disc-report' }">
|
||||
<a-button>گزارش DISC</a-button>
|
||||
</RouterLink>
|
||||
<a-button
|
||||
:disabled="busy"
|
||||
:loading="pageBusy && busyMessage.includes('خروجی')"
|
||||
@click.stop="exportExcel"
|
||||
<PageHeader
|
||||
title="مخاطبین"
|
||||
:icon="TeamOutlined"
|
||||
:primary-label="tab === 'companies' ? 'شرکت جدید' : 'شخص جدید'"
|
||||
:menu-items="headerMenuItems"
|
||||
:tabs="headerTabs"
|
||||
:active-tab="tab"
|
||||
searchable
|
||||
:search="q"
|
||||
:search-placeholder="tab === 'people' ? 'جستجو در اشخاص…' : 'جستجو در شرکتها…'"
|
||||
:active-filters="activeFilterChips"
|
||||
:result-count="activeFilterChips.length ? total : undefined"
|
||||
@primary="contactModal = tab === 'companies' ? 'company' : 'person'"
|
||||
@menu="onHeaderMenu"
|
||||
@update:active-tab="onHeaderTab"
|
||||
@update:search="onSearchInput"
|
||||
@search-submit="onSearch"
|
||||
@remove-filter="onRemoveFilter"
|
||||
@clear-filters="clearPeopleFilters"
|
||||
>
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
{{ isCompact ? 'خروجی' : 'خروجی اکسل' }}
|
||||
</a-button>
|
||||
<template #quick-filters>
|
||||
<template v-if="tab === 'people'">
|
||||
<a-select
|
||||
:value="moodFilter"
|
||||
:options="moodOptions"
|
||||
:style="{ width: '150px' }"
|
||||
@update:value="onMoodChange"
|
||||
/>
|
||||
<a-select
|
||||
v-if="sourceStats.length"
|
||||
:value="sourceFilter"
|
||||
:options="sourceOptions"
|
||||
:style="{ width: '170px' }"
|
||||
@update:value="onSourceChange"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="tab === 'people'" #saved-filters>
|
||||
<div :style="{ width: '280px', maxWidth: '100%' }">
|
||||
<SavedFiltersBar
|
||||
scope="people"
|
||||
compact
|
||||
:current-filters="peopleSavedFilters"
|
||||
@apply="applyPeopleSavedFilters"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #toolbar-end>
|
||||
<TableColumnsMenu
|
||||
icon-only
|
||||
align="end"
|
||||
:table-key="tab === 'people' ? 'contacts.people' : 'contacts.companies'"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-if="tab === 'people' && canBehavior" #chips>
|
||||
<FilterChips
|
||||
label="DISC"
|
||||
:options="discOptions"
|
||||
:model-value="discSelected"
|
||||
@update:model-value="onDiscChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- مرتبسازی فقط روی لیست اشخاص اثر دارد -->
|
||||
<template v-if="tab === 'people'" #chips-end>
|
||||
<FilterChips
|
||||
label="مرتبسازی"
|
||||
:options="sortOptions"
|
||||
:multiple="false"
|
||||
:show-all="false"
|
||||
:model-value="[sort]"
|
||||
@update:model-value="onSortChange"
|
||||
/>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- تریگرهای ورود داده؛ از منوی «⋯» هدر کلیک میشوند (مودالهایشان به body تلپورت میشوند) -->
|
||||
<div hidden>
|
||||
<ExcelImportFlow
|
||||
:preview-path="importPreviewPath"
|
||||
:import-path="importPath"
|
||||
@@ -612,12 +1017,7 @@ onMounted(load);
|
||||
@fail="onImportFail"
|
||||
@settled="onImportSettled"
|
||||
>
|
||||
<template #default="{ loading: excelLoading }">
|
||||
<a-button :disabled="busy" :loading="excelLoading">
|
||||
<template #icon><FileExcelOutlined /></template>
|
||||
{{ isCompact ? 'ورود' : 'ورود از اکسل' }}
|
||||
</a-button>
|
||||
</template>
|
||||
<span ref="excelImportTrigger"></span>
|
||||
</ExcelImportFlow>
|
||||
<PhoneContactsImport
|
||||
v-if="tab === 'people'"
|
||||
@@ -627,109 +1027,13 @@ onMounted(load);
|
||||
@fail="onPhoneImportFail"
|
||||
@settled="onPhoneImportSettled"
|
||||
>
|
||||
<a-button :disabled="busy">
|
||||
<template #icon><PhoneOutlined /></template>
|
||||
{{ isCompact ? 'گوشی' : 'از مخاطبین گوشی' }}
|
||||
</a-button>
|
||||
<span ref="phoneImportTrigger"></span>
|
||||
</PhoneContactsImport>
|
||||
<a-button type="primary" @click="contactModal = tab === 'companies' ? 'company' : 'person'">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ tab === 'companies' ? 'شرکت جدید' : 'شخص جدید' }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</div>
|
||||
|
||||
<a-spin :spinning="pageBusy" :tip="busyMessage">
|
||||
<a-card :bordered="false">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<a-radio-group :value="tab" button-style="solid" @change="onTabChange">
|
||||
<a-radio-button value="people">
|
||||
<UserOutlined />
|
||||
اشخاص
|
||||
<template v-if="people"> {{ toFaDigits(people.total) }}</template>
|
||||
</a-radio-button>
|
||||
<a-radio-button value="companies">
|
||||
<BankOutlined />
|
||||
شرکتها
|
||||
<template v-if="companies"> {{ toFaDigits(companies.total) }}</template>
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
<TableColumnsMenu
|
||||
:table-key="tab === 'people' ? 'contacts.people' : 'contacts.companies'"
|
||||
/>
|
||||
</a-flex>
|
||||
|
||||
<a-divider orientation="left">جستجو و فیلتر</a-divider>
|
||||
|
||||
<a-form layout="vertical" @submit.prevent="onSearch">
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :xs="24" :md="tab === 'people' ? 8 : 12">
|
||||
<a-form-item label="جستجو">
|
||||
<a-input-search
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
:placeholder="tab === 'people' ? 'جستجو در اشخاص…' : 'جستجو در شرکتها…'"
|
||||
style="width: 100%"
|
||||
@search="onSearch"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="tab === 'people' ? 8 : 12">
|
||||
<a-form-item label="مرتبسازی">
|
||||
<a-select
|
||||
:value="sort"
|
||||
:options="sortOptions"
|
||||
style="width: 100%"
|
||||
@update:value="onSortChange"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="tab === 'people'" :xs="24" :md="8">
|
||||
<a-form-item label="وضعیت">
|
||||
<a-select
|
||||
:value="moodFilter"
|
||||
:options="moodOptions"
|
||||
style="width: 100%"
|
||||
@update:value="onMoodChange"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="tab === 'people' && sourceStats.length" :xs="24" :md="8">
|
||||
<a-form-item label="منبع">
|
||||
<a-select
|
||||
:value="sourceFilter"
|
||||
:options="sourceOptions"
|
||||
style="width: 100%"
|
||||
@update:value="onSourceChange"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="tab === 'people' && canBehavior" :xs="24" :md="sourceStats.length ? 16 : 24">
|
||||
<a-form-item label="تیپ DISC">
|
||||
<a-space wrap :size="8">
|
||||
<a-button
|
||||
v-for="chip in discChipItems"
|
||||
:key="chip.value || 'all'"
|
||||
:type="(chip.value ? discFilter === chip.value : !discFilter) ? 'primary' : 'default'"
|
||||
@click="setDisc(chip.value)"
|
||||
>
|
||||
{{ chip.label }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
|
||||
<SavedFiltersBar
|
||||
v-if="tab === 'people'"
|
||||
scope="people"
|
||||
:current-filters="peopleSavedFilters"
|
||||
@apply="applyPeopleSavedFilters"
|
||||
/>
|
||||
|
||||
<a-divider orientation="left">فهرست</a-divider>
|
||||
|
||||
<a-flex vertical :gap="16">
|
||||
<a-alert v-if="importMsg" type="success" show-icon :message="importMsg" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
@@ -1112,7 +1416,7 @@ onMounted(load);
|
||||
</CrmSkeletonTable>
|
||||
</CrmSkeleton>
|
||||
|
||||
<a-flex v-if="total" justify="flex-start" :style="{ marginTop: `${token.margin}px` }">
|
||||
<a-flex v-if="total" justify="flex-start">
|
||||
<a-pagination
|
||||
:current="page"
|
||||
:page-size="pageSize"
|
||||
@@ -1123,6 +1427,7 @@ onMounted(load);
|
||||
@change="onTablePage"
|
||||
/>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
</a-card>
|
||||
</a-spin>
|
||||
</a-flex>
|
||||
|
||||
@@ -39,6 +39,9 @@ import {
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import AskMentoPanel from '@/components/AskMentoPanel.vue';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { Badge as ABadge } from 'ant-design-vue';
|
||||
import { MessageOutlined } from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import UserAvatar from '@/components/UserAvatar.vue';
|
||||
import {
|
||||
brand,
|
||||
@@ -1824,16 +1827,22 @@ onUnmounted(() => {
|
||||
<div class="conv-page" :class="{ 'chat-open': mobileChatOpen }">
|
||||
<div class="conv-aurora" aria-hidden="true" />
|
||||
|
||||
<header class="conv-head desktop-head">
|
||||
<div>
|
||||
<p class="eyebrow">درون سازمان</p>
|
||||
<h1>گفتگو</h1>
|
||||
<p class="sub">فضای زنده برای هماهنگی تیم — بدون پیامرسان بیرونی.</p>
|
||||
<!-- هدر یکپارچه (فقط دسکتاپ؛ موبایل هدر فشردهٔ خودش را دارد) -->
|
||||
<div class="conv-head desktop-head">
|
||||
<PageHeader
|
||||
title="گفتگو"
|
||||
subtitle="فضای زنده برای هماهنگی تیم درون سازمان، بدون پیامرسان بیرونی"
|
||||
:icon="MessageOutlined"
|
||||
:style="{ flex: '1 1 auto', minWidth: 0 }"
|
||||
>
|
||||
<template #title-extra>
|
||||
<a-badge
|
||||
:status="status === 'open' ? 'success' : 'default'"
|
||||
:text="status === 'open' ? 'آنلاین' : 'در حال اتصال…'"
|
||||
/>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</div>
|
||||
<div class="head-actions">
|
||||
<span class="ws-pill" :data-state="status">{{ status === 'open' ? 'آنلاین' : '…' }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<header class="mobile-list-head" :hidden="mobileChatOpen">
|
||||
<h1>گفتگو</h1>
|
||||
@@ -2981,32 +2990,6 @@ onUnmounted(() => {
|
||||
.mobile-list-head {
|
||||
display: none;
|
||||
}
|
||||
.eyebrow {
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
.conv-head h1 {
|
||||
margin: 0;
|
||||
font-size: 1.75rem;
|
||||
font-weight: 800;
|
||||
background: linear-gradient(120deg, #0f766e, #7c3aed 55%, #db2777);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
.sub {
|
||||
margin: 0.35rem 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
.head-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.ws-pill {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.25rem 0.65rem;
|
||||
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { DollarOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -129,7 +131,11 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">ارزها و نرخ تبدیل</a-typography-title>
|
||||
<PageHeader
|
||||
title="ارزها و نرخ تبدیل"
|
||||
subtitle="ارز پایه و ارزهای فعال در فاکتورها و معاملات"
|
||||
:icon="DollarOutlined"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" />
|
||||
|
||||
@@ -32,7 +32,9 @@ import {
|
||||
import { PlusOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ControlOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -179,7 +181,11 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">فیلدهای سفارشی</a-typography-title>
|
||||
<PageHeader
|
||||
title="فیلدهای سفارشی"
|
||||
subtitle="فیلدهای اضافه برای مخاطبین، معاملات و سایر بخشها"
|
||||
:icon="ControlOutlined"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -30,13 +30,13 @@ import {
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Tabs as ATabs,
|
||||
TabPane as ATabPane,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { HistoryOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
type HistoryTab = 'creates' | 'edits' | 'deletes';
|
||||
|
||||
@@ -517,11 +517,14 @@ void loadActors();
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">تاریخچه کارها</a-typography-title>
|
||||
|
||||
<a-tabs :active-key="tab" @change="selectTab">
|
||||
<a-tab-pane v-for="item in TABS" :key="item.key" :tab="item.label" />
|
||||
</a-tabs>
|
||||
<PageHeader
|
||||
title="تاریخچه کارها"
|
||||
subtitle="موارد حذفشده و بایگانیشده و امکان بازگردانی"
|
||||
:icon="HistoryOutlined"
|
||||
:tabs="TABS.map((item) => ({ key: item.key, label: item.label }))"
|
||||
:active-tab="tab"
|
||||
@update:active-tab="(k) => selectTab(k ?? TABS[0]!.key)"
|
||||
/>
|
||||
|
||||
<a-alert v-if="okMsg" type="success" show-icon :message="okMsg" closable @close="okMsg = ''" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRouter } from 'vue-router';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import type { DiscDistributionRow } from '@mento/shared';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
@@ -11,17 +11,17 @@ import {
|
||||
Flex as AFlex,
|
||||
Progress as AProgress,
|
||||
Row as ARow,
|
||||
Space as ASpace,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { ArrowRightOutlined, DownloadOutlined } from '@/icons/ant-bridge';
|
||||
import { DownloadOutlined } from '@/icons/ant-bridge';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { BarChartOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const router = useRouter();
|
||||
const rows = ref<DiscDistributionRow[]>([]);
|
||||
const error = ref('');
|
||||
const loading = ref(true);
|
||||
@@ -66,26 +66,19 @@ function percentOf(count: number) {
|
||||
<template>
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :span="24">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
توزیع تیپهای DISC
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
فقط ارزیابیهای تأییدشده و قابل اتکا، در محدودهٔ دسترسی شما
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-space wrap>
|
||||
<a-button @click="router.push({ name: 'contacts' })">
|
||||
<template #icon><ArrowRightOutlined /></template>
|
||||
بازگشت
|
||||
</a-button>
|
||||
<PageHeader
|
||||
title="توزیع تیپهای DISC"
|
||||
subtitle="فقط ارزیابیهای تأییدشده و قابل اتکا، در محدودهٔ دسترسی شما"
|
||||
:icon="BarChartOutlined"
|
||||
:back-to="{ name: 'contacts' }"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="exporting" :loading="exporting" @click="exportExcel">
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
خروجی اکسل
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
|
||||
@@ -28,7 +28,9 @@ import {
|
||||
import { DeleteOutlined, EditOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { QuestionCircleOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -140,9 +142,11 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
پایگاه دانش و سؤالات متداول
|
||||
</a-typography-title>
|
||||
<PageHeader
|
||||
title="پایگاه دانش و سؤالات متداول"
|
||||
subtitle="مقالهها و پاسخهای آماده برای تیم و مشتریان"
|
||||
:icon="QuestionCircleOutlined"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
@@ -42,7 +42,9 @@ import type {
|
||||
StockMovementType,
|
||||
} from '@mento/shared';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ContainerOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const STOCK_COL_LABELS = ['نام کالا', 'واحد', 'موجودی'] as const;
|
||||
|
||||
@@ -186,18 +188,17 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">انبار</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
موجودی کالا، ورود خرید و مانده وقتی تهحساب وصل نباشد
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-button :disabled="loading" :loading="loading" @click="load">
|
||||
<PageHeader
|
||||
title="انبار"
|
||||
subtitle="موجودی کالا، ورود خرید و مانده وقتی تهحساب وصل نباشد"
|
||||
:icon="ContainerOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" :loading="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert
|
||||
v-if="error"
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { matchesSearch } from '@/lib/search';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import {
|
||||
CURRENCY_OPTIONS,
|
||||
currencySuffix,
|
||||
@@ -66,6 +66,7 @@ import type {
|
||||
QuoteDto,
|
||||
QuoteStatus,
|
||||
} from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
type DocMode = 'invoice' | 'quote' | 'credit';
|
||||
|
||||
@@ -99,6 +100,7 @@ const emit = defineEmits<{ saved: []; cancel: [] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const loadedInvoiceKind = ref<'invoice' | 'credit' | null>(null);
|
||||
|
||||
const docMode = computed<DocMode>(() => {
|
||||
@@ -681,14 +683,6 @@ function quotePayload(): CreateQuoteRequest {
|
||||
return body;
|
||||
}
|
||||
|
||||
function axiosMessage(e: unknown, fallback: string) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
return Array.isArray(msg) ? msg.join('، ') : (msg ?? fallback);
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!issuedAt.value) {
|
||||
error.value = 'تاریخ را وارد کنید.';
|
||||
@@ -713,13 +707,20 @@ async function save() {
|
||||
} else {
|
||||
await api.patch(`/invoices/${id.value}`, invoicePayload());
|
||||
}
|
||||
feedback.success(
|
||||
docMode.value === 'quote'
|
||||
? 'پیشفاکتور ذخیره شد.'
|
||||
: docMode.value === 'credit'
|
||||
? 'فاکتور برگشتی ذخیره شد.'
|
||||
: 'فاکتور ذخیره شد.',
|
||||
);
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
}
|
||||
await router.push({ name: listRouteName });
|
||||
} catch (e) {
|
||||
error.value = axiosMessage(e, 'ذخیره ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره ناموفق بود');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -733,12 +734,23 @@ async function remove() {
|
||||
? 'این فاکتور برگشتی حذف شود؟'
|
||||
: 'این فاکتور حذف شود؟';
|
||||
if (!id.value || !confirm(label)) return;
|
||||
try {
|
||||
if (docMode.value === 'quote') {
|
||||
await api.delete(`/quotes/${id.value}`);
|
||||
} else {
|
||||
await api.delete(`/invoices/${id.value}`);
|
||||
}
|
||||
feedback.success(
|
||||
docMode.value === 'quote'
|
||||
? 'پیشفاکتور حذف شد.'
|
||||
: docMode.value === 'credit'
|
||||
? 'فاکتور برگشتی حذف شد.'
|
||||
: 'فاکتور حذف شد.',
|
||||
);
|
||||
await router.push({ name: listRouteName });
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
async function submitPayment() {
|
||||
@@ -781,9 +793,10 @@ async function submitPayment() {
|
||||
chequeBank.value = '';
|
||||
chequeDue.value = '';
|
||||
chequeStatus.value = 'pending';
|
||||
feedback.success('پرداخت ثبت شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = axiosMessage(e, 'ثبت پرداخت ناموفق بود');
|
||||
feedback.fromError(e, 'ثبت پرداخت ناموفق بود');
|
||||
} finally {
|
||||
paying.value = false;
|
||||
}
|
||||
@@ -791,8 +804,13 @@ async function submitPayment() {
|
||||
|
||||
async function removePayment(paymentId: string) {
|
||||
if (!id.value || !confirm('این پرداخت حذف شود؟')) return;
|
||||
try {
|
||||
await api.delete(`/invoices/${id.value}/payments/${paymentId}`);
|
||||
feedback.success('پرداخت حذف شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف پرداخت ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
function addInstallment() {
|
||||
@@ -1012,26 +1030,21 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="pageTitle"
|
||||
subtitle="اقلام، تخفیف، مالیات و تسویه فاکتور"
|
||||
:icon="FileTextOutlined"
|
||||
class="no-print"
|
||||
:style="{ marginBottom: '16px' }"
|
||||
>
|
||||
<a-space :size="12" align="start">
|
||||
<FileTextOutlined />
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title>
|
||||
</div>
|
||||
</a-space>
|
||||
<template #actions>
|
||||
<a-button @click="goBack">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
بازگشت
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
|
||||
@@ -54,7 +54,9 @@ import type {
|
||||
QuoteDto,
|
||||
} from '@mento/shared';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { FileTextOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const AMenuItem = AMenu.Item;
|
||||
|
||||
type DocTab = 'all' | 'invoice' | 'quote' | 'credit';
|
||||
@@ -547,17 +549,14 @@ defineExpose({ toggleSelect, pageCount, statusIcon });
|
||||
|
||||
<template>
|
||||
<div @click="closeMenus">
|
||||
<a-flex
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
<PageHeader
|
||||
title="فاکتورها"
|
||||
subtitle="فاکتورها، پیشفاکتورها و فاکتورهای برگشتی"
|
||||
:icon="FileTextOutlined"
|
||||
:style="{ marginBottom: '16px' }"
|
||||
>
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">فاکتور ها</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="8" @click.stop>
|
||||
<template #primary>
|
||||
<span @click.stop>
|
||||
<a-dropdown v-model:open="addOpen">
|
||||
<a-button type="primary">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
@@ -572,8 +571,9 @@ defineExpose({ toggleSelect, pageCount, statusIcon });
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</span>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-row :gutter="[16, 12]">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRouter } from 'vue-router';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
MenuItem as AMenuItem,
|
||||
Modal as AModal,
|
||||
Space as ASpace,
|
||||
Tooltip as ATooltip,
|
||||
Spin as ASpin,
|
||||
Tag as ATag,
|
||||
Textarea as ATextarea,
|
||||
@@ -29,7 +30,11 @@ import {
|
||||
PlusOutlined,
|
||||
ReloadOutlined,
|
||||
UnorderedListOutlined,
|
||||
AppstoreOutlined,
|
||||
UserAddOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderViewOption } from '@/components/page';
|
||||
import { api } from '@/lib/api';
|
||||
import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
@@ -38,13 +43,24 @@ import { useAuthStore } from '@/stores/auth';
|
||||
import type { LeadBoardColumnDto, LeadDto, LeadStageDto } from '@mento/shared';
|
||||
import { CrmSkeletonCard } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const canManage = computed(() => canManageSettings(auth.user?.role));
|
||||
|
||||
const GAP = 16;
|
||||
|
||||
const viewOptions: PageHeaderViewOption[] = [
|
||||
{ value: 'list', label: 'لیست', icon: UnorderedListOutlined },
|
||||
{ value: 'board', label: 'بورد', icon: AppstoreOutlined },
|
||||
];
|
||||
|
||||
function onViewChange(value: string | undefined) {
|
||||
if (value === 'list') void router.push({ name: 'leads' });
|
||||
}
|
||||
|
||||
const boardTotal = computed(() => columns.value.reduce((sum, col) => sum + (col.total ?? 0), 0));
|
||||
const COL_WIDTH = 280;
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -645,29 +661,27 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<div class="lead-board-page" :style="pageStyle">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="GAP">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
مسیر لیدها
|
||||
</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="GAP">
|
||||
<RouterLink :to="{ name: 'leads' }" custom v-slot="{ navigate }">
|
||||
<a-button @click="navigate">
|
||||
<template #icon><UnorderedListOutlined /></template>
|
||||
فهرست لیدها
|
||||
</a-button>
|
||||
</RouterLink>
|
||||
<a-button
|
||||
:disabled="loading || moving"
|
||||
:loading="loading"
|
||||
@click="load"
|
||||
<PageHeader
|
||||
title="مسیر لیدها"
|
||||
subtitle="لیدها را بین مراحل بکشید تا وضعیتشان عوض شود"
|
||||
:icon="UserAddOutlined"
|
||||
:count="loading && !columns.length ? undefined : boardTotal"
|
||||
:primary-label="canManage ? 'افزودن ستون' : undefined"
|
||||
:primary-disabled="loading || moving"
|
||||
:view-options="viewOptions"
|
||||
view="board"
|
||||
:style="{ flex: '0 0 auto' }"
|
||||
@primary="openAdd"
|
||||
@update:view="onViewChange"
|
||||
>
|
||||
<template #actions>
|
||||
<a-tooltip title="بروزرسانی">
|
||||
<a-button :disabled="loading || moving" :loading="loading" aria-label="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -568,59 +568,33 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<template>
|
||||
<a-row :gutter="[24, 24]">
|
||||
<a-col :span="24">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM">
|
||||
<a-space :size="12" align="start">
|
||||
<a-button aria-label="بازگشت" @click="goBack">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
</a-button>
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ lead?.title || 'جزئیات لید' }}
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
{{ lead ? `موبایل ${lead.mobile}` : 'در حال بارگذاری…' }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
</a-space>
|
||||
<a-space v-if="lead" :size="8" wrap>
|
||||
<a-button
|
||||
v-if="!editing"
|
||||
:disabled="busy || !lead.mobile"
|
||||
@click="smsOpen = true"
|
||||
<PageHeader
|
||||
:title="lead?.title || 'جزئیات لید'"
|
||||
:subtitle="lead ? `موبایل ${lead.mobile}` : 'در حال بارگذاری…'"
|
||||
:icon="UserAddOutlined"
|
||||
:back-to="{ name: 'leads-board' }"
|
||||
:primary-label="lead && !lead.convertedPersonId ? 'تبدیل به مشتری' : undefined"
|
||||
:primary-icon="UserAddOutlined"
|
||||
:primary-disabled="busy"
|
||||
:menu-items="leadMenuItems"
|
||||
@primary="convertLead"
|
||||
@menu="onLeadMenu"
|
||||
>
|
||||
<template v-if="lead" #actions>
|
||||
<a-button v-if="!editing" :disabled="busy || !lead.mobile" @click="smsOpen = true">
|
||||
<template #icon><MessageOutlined /></template>
|
||||
پیامک
|
||||
</a-button>
|
||||
<a-button v-if="!editing && canBehavior" @click="copilotOpen = !copilotOpen">
|
||||
کمک برای ادامه مذاکره
|
||||
</a-button>
|
||||
<a-button v-if="!editing" :disabled="busy" @click="startEdit">
|
||||
<template #icon><EditOutlined /></template>
|
||||
ویرایش
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="!lead.convertedPersonId"
|
||||
type="primary"
|
||||
:disabled="busy"
|
||||
@click="convertLead"
|
||||
>
|
||||
<template #icon><UserAddOutlined /></template>
|
||||
تبدیل به مشتری
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="!lead.archivedAt"
|
||||
danger
|
||||
:disabled="busy"
|
||||
@click="archiveLead"
|
||||
>
|
||||
بایگانی
|
||||
</a-button>
|
||||
<a-button v-if="narrow" @click="moreOpen = true">
|
||||
<template #icon><MoreOutlined /></template>
|
||||
بیشتر
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="lead && copilotOpen && canBehavior" :span="24">
|
||||
@@ -734,17 +708,6 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<a-input v-model:value="editForm.trade" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="سابقه فعالیت">
|
||||
<a-select
|
||||
v-model:value="editForm.activityExperience"
|
||||
allow-clear
|
||||
placeholder="اختیاری"
|
||||
style="width: 100%"
|
||||
:options="activityExperienceOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="یادداشت">
|
||||
<a-textarea
|
||||
@@ -817,9 +780,6 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<span dir="ltr">{{ lead.instagram || '—' }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="صنف">{{ lead.trade || '—' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="سابقه فعالیت">
|
||||
{{ shownActivityExperience }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="منبع">
|
||||
{{ lead.source || '—' }}
|
||||
</a-descriptions-item>
|
||||
@@ -952,7 +912,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-typography-paragraph v-if="ev.body" type="secondary">
|
||||
<template v-if="ev.type === 'stage_changed'">دلیل: </template>{{ ev.body }}
|
||||
{{ ev.body }}
|
||||
</a-typography-paragraph>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
@@ -1022,12 +982,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-button
|
||||
block
|
||||
:disabled="busy || stageId === lead.stageId"
|
||||
:loading="busy"
|
||||
@click="openStageMove"
|
||||
>
|
||||
<a-button block :disabled="busy" :loading="busy" @click="changeStage">
|
||||
اعمال وضعیت
|
||||
</a-button>
|
||||
|
||||
@@ -1173,13 +1128,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-button
|
||||
block
|
||||
:disabled="busy || stageId === lead.stageId"
|
||||
@click="openStageMove"
|
||||
>
|
||||
اعمال وضعیت
|
||||
</a-button>
|
||||
<a-button block :disabled="busy" @click="changeStage">اعمال وضعیت</a-button>
|
||||
|
||||
<template v-if="canAssignOthers">
|
||||
<a-divider orientation="right">تخصیص کارشناس</a-divider>
|
||||
@@ -1267,39 +1216,8 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
</a-button>
|
||||
</a-form>
|
||||
</a-drawer>
|
||||
</template>
|
||||
</a-spin>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-modal
|
||||
v-model:open="stageMoveOpen"
|
||||
title="دلیل تغییر وضعیت"
|
||||
ok-text="ثبت و انتقال"
|
||||
cancel-text="انصراف"
|
||||
destroy-on-close
|
||||
:confirm-loading="busy"
|
||||
:ok-button-props="{ disabled: !stageMoveReason.trim() }"
|
||||
@ok="changeStage"
|
||||
@cancel="cancelStageMove"
|
||||
>
|
||||
<a-flex vertical :gap="12">
|
||||
<a-typography-text type="secondary">
|
||||
انتقال از «{{ lead?.stageName || '—' }}» به «{{ stages.find((s) => s.id === stageId)?.name || '—' }}»
|
||||
</a-typography-text>
|
||||
<a-textarea
|
||||
v-model:value="stageMoveReason"
|
||||
:rows="4"
|
||||
:maxlength="1000"
|
||||
show-count
|
||||
placeholder="دلیل تغییر وضعیت را بنویسید…"
|
||||
/>
|
||||
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
|
||||
</a-flex>
|
||||
</a-modal>
|
||||
|
||||
<SmsComposeModal
|
||||
v-if="lead"
|
||||
:open="smsOpen"
|
||||
title="ارسال پیامک"
|
||||
:endpoint="`/leads/${lead.id}/sms`"
|
||||
@@ -1310,4 +1228,8 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
:company="lead.trade ?? ''"
|
||||
@close="smsOpen = false"
|
||||
/>
|
||||
</template>
|
||||
</a-spin>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
@@ -558,14 +558,18 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-flex vertical :gap="4">
|
||||
<RouterLink :to="{ name: 'lead-forms' }" custom v-slot="{ href, navigate }">
|
||||
<a-typography-link :href="href" @click="navigate">بازگشت به فرمها</a-typography-link>
|
||||
</RouterLink>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">فرمساز</a-typography-title>
|
||||
</a-flex>
|
||||
<a-space wrap>
|
||||
<PageHeader
|
||||
title="فرمساز"
|
||||
:subtitle="form?.name || 'فیلدها، ظاهر و تنظیمات انتشار فرم'"
|
||||
:icon="FileTextOutlined"
|
||||
:back-to="{ name: 'lead-forms' }"
|
||||
primary-label="ذخیره تغییرات"
|
||||
:primary-icon="SaveOutlined"
|
||||
:primary-loading="saving"
|
||||
:primary-disabled="saving"
|
||||
@primary="save"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="!form?.publicPath" @click="openPreview">
|
||||
<template #icon><EyeOutlined /></template>
|
||||
پیشنمایش
|
||||
@@ -574,12 +578,8 @@ onMounted(load);
|
||||
<template #icon><NotificationOutlined /></template>
|
||||
انتشار فرم
|
||||
</a-button>
|
||||
<a-button type="primary" :loading="saving" :disabled="saving" @click="save">
|
||||
<template #icon><SaveOutlined /></template>
|
||||
ذخیره تغییرات
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
@@ -26,8 +26,10 @@ import {
|
||||
EyeOutlined,
|
||||
PlusOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { FileTextOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
@@ -111,13 +113,15 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">فرمساز وب</a-typography-title>
|
||||
<a-button type="primary" :loading="saving" @click="createForm">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
فرم جدید
|
||||
</a-button>
|
||||
</a-flex>
|
||||
<PageHeader
|
||||
title="فرمساز وب"
|
||||
subtitle="فرمهای جذب لید برای وبسایت و شبکههای اجتماعی"
|
||||
:icon="FileTextOutlined"
|
||||
:count="loading ? undefined : forms.length"
|
||||
primary-label="فرم جدید"
|
||||
:primary-loading="saving"
|
||||
@primary="createForm"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ import {
|
||||
EditOutlined,
|
||||
PlusOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { FlagOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
@@ -209,12 +211,11 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">مراحل لید</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
تعریف وضعیتهای مسیر لیدها و برچسبهای تبدیل/از دسترفته
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<PageHeader
|
||||
title="مراحل لید"
|
||||
subtitle="تعریف وضعیتهای مسیر لیدها و برچسبهای تبدیل/از دسترفته"
|
||||
:icon="FlagOutlined"
|
||||
/>
|
||||
|
||||
<a-alert v-if="okMsg" type="success" show-icon :message="okMsg" closable @close="okMsg = ''" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
|
||||
+220
-350
@@ -50,6 +50,7 @@ import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
UnorderedListOutlined,
|
||||
UserAddOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import {
|
||||
@@ -66,6 +67,13 @@ import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import PhoneContactsImport from '@/components/PhoneContactsImport.vue';
|
||||
import { FilterChips, PageHeader } from '@/components/page';
|
||||
import type {
|
||||
PageHeaderActiveFilter,
|
||||
PageHeaderMenuItem,
|
||||
PageHeaderTab,
|
||||
PageHeaderViewOption,
|
||||
} from '@/components/page';
|
||||
import {
|
||||
filterPhoneContacts,
|
||||
isContactPickerSupported,
|
||||
@@ -394,6 +402,25 @@ function facetValueStyle(active: boolean) {
|
||||
} as const;
|
||||
}
|
||||
|
||||
const filterRowHover = ref<string | null>(null);
|
||||
const facetItemStyle = computed(() => ({
|
||||
borderBottom: `${token.value.lineWidth}px ${token.value.lineType} ${token.value.colorSplit}`,
|
||||
}));
|
||||
const facetBodyStyle = computed(() => ({
|
||||
paddingInline: `${token.value.paddingSM}px`,
|
||||
paddingBottom: `${token.value.paddingSM}px`,
|
||||
}));
|
||||
function facetRowStyle(key: string) {
|
||||
const open = filterSection.value === key;
|
||||
const hover = filterRowHover.value === key;
|
||||
return {
|
||||
cursor: 'pointer',
|
||||
padding: `${token.value.paddingXS}px ${token.value.paddingSM}px`,
|
||||
borderRadius: `${token.value.borderRadiusSM}px`,
|
||||
background: open || hover ? token.value.colorFillTertiary : 'transparent',
|
||||
};
|
||||
}
|
||||
|
||||
const textFacets = computed(() => [
|
||||
{
|
||||
key: 'assignee' as const,
|
||||
@@ -576,6 +603,92 @@ const totalLeadsCount = computed(() => {
|
||||
return stages.value.reduce((sum, s) => sum + (s.leadCount ?? 0), 0) || total.value;
|
||||
});
|
||||
|
||||
const headerTabs = computed<PageHeaderTab[]>(() => [
|
||||
{ key: 'all', label: 'همه', count: totalLeadsCount.value },
|
||||
...stageCards.value.map((card) => ({
|
||||
key: card.stageId,
|
||||
label: card.label,
|
||||
count: card.count,
|
||||
})),
|
||||
]);
|
||||
const stageSegValue = computed(() => stageId.value || 'all');
|
||||
|
||||
const viewOptions: PageHeaderViewOption[] = [
|
||||
{ value: 'list', label: 'لیست', icon: UnorderedListOutlined },
|
||||
{ value: 'board', label: 'بورد', icon: AppstoreOutlined },
|
||||
];
|
||||
|
||||
const headerMenuItems = computed<PageHeaderMenuItem[]>(() => [
|
||||
{ key: 'export', label: 'خروجی اکسل', icon: FileExcelOutlined },
|
||||
{ key: 'import', label: 'ورود از اکسل', icon: FileExcelOutlined },
|
||||
{ key: 'phone', label: 'از مخاطبین گوشی', icon: PhoneOutlined },
|
||||
]);
|
||||
|
||||
const sortOptions: Array<{ value: SortKey; label: string }> = [
|
||||
{ value: 'newest', label: 'تاریخ جدیدترین' },
|
||||
{ value: 'updated', label: 'آخرین بهروزرسانی' },
|
||||
{ value: 'follow_up', label: 'پیگیری بعدی' },
|
||||
{ value: 'last_contact', label: 'آخرین تماس' },
|
||||
];
|
||||
const sortSelected = computed<SortKey[]>(() => [sort.value]);
|
||||
|
||||
const activeFilterChips = computed<PageHeaderActiveFilter[]>(() => {
|
||||
const chips: PageHeaderActiveFilter[] = textFacets.value
|
||||
.filter((facet) => facet.active)
|
||||
.map((facet) => ({ key: facet.key, label: facet.label, value: facet.value }));
|
||||
if (createdFromFilter.value) {
|
||||
chips.push({ key: 'createdFrom', label: 'از تاریخ', value: dateFacetLabel(createdFromFilter.value) });
|
||||
}
|
||||
if (createdToFilter.value) {
|
||||
chips.push({ key: 'createdTo', label: 'تا تاریخ', value: dateFacetLabel(createdToFilter.value) });
|
||||
}
|
||||
if (convertedFilter.value) chips.push({ key: 'converted', label: 'تبدیل', value: 'تبدیلشده' });
|
||||
if (archivedFilter.value) chips.push({ key: 'archived', label: 'بایگانی', value: 'بایگانیشده' });
|
||||
return chips;
|
||||
});
|
||||
|
||||
const excelImportTrigger = ref<HTMLElement | null>(null);
|
||||
const phoneImportTrigger = ref<HTMLElement | null>(null);
|
||||
|
||||
function onHeaderMenu(key: string) {
|
||||
if (key === 'export') void exportExcel();
|
||||
else if (key === 'import') excelImportTrigger.value?.click();
|
||||
else if (key === 'phone') phoneImportTrigger.value?.click();
|
||||
}
|
||||
|
||||
function onHeaderTab(key: string | number) {
|
||||
const value = String(key);
|
||||
setStageFilter(value === 'all' ? '' : value);
|
||||
}
|
||||
|
||||
function onSearchInput(value: string) {
|
||||
q.value = value;
|
||||
}
|
||||
|
||||
function onViewChange(value: string | undefined) {
|
||||
if (value === 'board') void router.push({ name: 'leads-board' });
|
||||
}
|
||||
|
||||
function onSortChange(value: SortKey[]) {
|
||||
const next = value[0];
|
||||
if (next) setSort(next);
|
||||
}
|
||||
|
||||
function onRemoveFilter(key: string) {
|
||||
if (key === 'assignee') setAssigneeFilter(undefined);
|
||||
else if (key === 'stage') setStageFilter('');
|
||||
else if (key === 'source') setSourceFilter('');
|
||||
else if (key === 'followUp') setFollowUpFilter(undefined);
|
||||
else if (key === 'city') setCityFilter('');
|
||||
else if (key === 'region') setRegionFilter('');
|
||||
else if (key === 'trade') setTradeFilter('');
|
||||
else if (key === 'activityExperience') setActivityExperienceFilter('');
|
||||
else if (key === 'createdFrom') setCreatedFromFilter('');
|
||||
else if (key === 'createdTo') setCreatedToFilter('');
|
||||
else if (key === 'converted') setConvertedFilter(false);
|
||||
else if (key === 'archived') setArchivedFilter(false);
|
||||
}
|
||||
|
||||
/** گزینههای سلکت موبایل — برچسب + تعداد */
|
||||
const stageFilterOptions = computed(() => [
|
||||
{
|
||||
@@ -1596,304 +1709,51 @@ onBeforeUnmount(() => {
|
||||
<template>
|
||||
<a-row :gutter="[16, 16]" align="top" :style="{ alignContent: 'flex-start' }" @click="closePopups">
|
||||
<a-col :span="24">
|
||||
<a-flex
|
||||
v-if="isMobile"
|
||||
vertical
|
||||
:gap="8"
|
||||
:style="{ width: '100%' }"
|
||||
<PageHeader
|
||||
title="لیدها"
|
||||
:icon="UserAddOutlined"
|
||||
:count="totalLeadsCount"
|
||||
:primary-label="isMobile ? 'جدید' : 'لید جدید'"
|
||||
:menu-items="headerMenuItems"
|
||||
:tabs="headerTabs"
|
||||
:active-tab="stageSegValue"
|
||||
searchable
|
||||
search-placeholder="جستجو نام، موبایل، شهر…"
|
||||
:search="q"
|
||||
:view-options="viewOptions"
|
||||
view="list"
|
||||
:active-filters="activeFilterChips"
|
||||
:result-count="activeFilterChips.length ? total : undefined"
|
||||
@primary="openCreate"
|
||||
@menu="onHeaderMenu"
|
||||
@update:active-tab="onHeaderTab"
|
||||
@update:search="onSearchInput"
|
||||
@search-submit="onSearch"
|
||||
@update:view="onViewChange"
|
||||
@remove-filter="onRemoveFilter"
|
||||
@clear-filters="clearMoreFilters"
|
||||
>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">لیدها</a-typography-title>
|
||||
<a-flex :gap="8" align="center" :style="{ width: '100%' }">
|
||||
<div :style="{ flex: '1 1 0%', minWidth: 0 }">
|
||||
<a-button block type="primary" @click.stop="openCreate">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
جدید
|
||||
</a-button>
|
||||
</div>
|
||||
<a-radio-group
|
||||
value="list"
|
||||
button-style="solid"
|
||||
@change="(e: any) => { if (e?.target?.value === 'board') void router.push({ name: 'leads-board' }) }"
|
||||
>
|
||||
<a-radio-button value="list">
|
||||
<UnorderedListOutlined />
|
||||
</a-radio-button>
|
||||
<a-radio-button value="board">
|
||||
<AppstoreOutlined />
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
<div :style="{ flex: '0 0 auto' }">
|
||||
<a-dropdown :trigger="['click']" placement="bottomLeft">
|
||||
<a-button :disabled="busy" aria-label="بیشتر">
|
||||
<template #icon><MoreOutlined /></template>
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item
|
||||
key="export"
|
||||
:disabled="busy || (pageBusy && busyMessage.includes('خروجی'))"
|
||||
@click="exportExcel"
|
||||
>
|
||||
<ExportOutlined />
|
||||
خروجی اکسل
|
||||
</a-menu-item>
|
||||
<a-menu-item key="excel" :disabled="busy">
|
||||
<ExcelImportFlow
|
||||
preview-path="/leads/import/preview"
|
||||
import-path="/leads/import/file"
|
||||
:disabled="busy"
|
||||
@start="onExcelImportStart"
|
||||
@done="onExcelImportDone"
|
||||
@fail="onExcelImportFail"
|
||||
@settled="onExcelImportSettled"
|
||||
>
|
||||
<template #default="{ loading: excelLoading }">
|
||||
<a-flex align="center" :gap="8" :style="{ opacity: excelLoading ? 0.6 : 1 }">
|
||||
<FileExcelOutlined />
|
||||
ورود از اکسل
|
||||
</a-flex>
|
||||
</template>
|
||||
</ExcelImportFlow>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="phone" :disabled="busy">
|
||||
<PhoneContactsImport
|
||||
target="leads"
|
||||
:disabled="busy"
|
||||
@start="onPhoneImportStart"
|
||||
@done="onPhoneImportDone"
|
||||
@fail="onPhoneImportFail"
|
||||
@settled="onPhoneImportSettled"
|
||||
>
|
||||
<a-flex align="center" :gap="8">
|
||||
<PhoneOutlined />
|
||||
از مخاطبین گوشی
|
||||
</a-flex>
|
||||
</PhoneContactsImport>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
<a-flex
|
||||
v-else
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.marginSM"
|
||||
>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">لیدها</a-typography-title>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button :disabled="busy" :loading="pageBusy && busyMessage.includes('خروجی')" @click.stop="exportExcel">
|
||||
<template #icon><ExportOutlined /></template>
|
||||
خروجی اکسل
|
||||
</a-button>
|
||||
<ExcelImportFlow
|
||||
preview-path="/leads/import/preview"
|
||||
import-path="/leads/import/file"
|
||||
:disabled="busy"
|
||||
@start="onExcelImportStart"
|
||||
@done="onExcelImportDone"
|
||||
@fail="onExcelImportFail"
|
||||
@settled="onExcelImportSettled"
|
||||
>
|
||||
<template #default="{ loading: excelLoading }">
|
||||
<a-button :disabled="busy" :loading="excelLoading">
|
||||
<template #icon><FileExcelOutlined /></template>
|
||||
ورود از اکسل
|
||||
</a-button>
|
||||
</template>
|
||||
</ExcelImportFlow>
|
||||
<PhoneContactsImport
|
||||
target="leads"
|
||||
:disabled="busy"
|
||||
@start="onPhoneImportStart"
|
||||
@done="onPhoneImportDone"
|
||||
@fail="onPhoneImportFail"
|
||||
@settled="onPhoneImportSettled"
|
||||
>
|
||||
<a-button :disabled="busy">
|
||||
<template #icon><PhoneOutlined /></template>
|
||||
از مخاطبین گوشی
|
||||
</a-button>
|
||||
</PhoneContactsImport>
|
||||
<a-button type="primary" @click.stop="openCreate">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
لید جدید
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24" @click.stop>
|
||||
<a-flex vertical :gap="8">
|
||||
<a-flex v-if="!isMobile" wrap="wrap" :gap="8" align="center">
|
||||
<a-button :type="!stageId ? 'primary' : 'default'" @click="setStageFilter('')">
|
||||
همه لیدها
|
||||
<a-typography-text
|
||||
:type="!stageId ? undefined : 'secondary'"
|
||||
:style="{ color: !stageId ? 'inherit' : undefined, marginInlineStart: '6px' }"
|
||||
>
|
||||
{{ formatCount(totalLeadsCount) }}
|
||||
</a-typography-text>
|
||||
</a-button>
|
||||
<a-button
|
||||
v-for="card in stageCards"
|
||||
:key="card.key"
|
||||
:type="isStatActive(card) ? 'primary' : 'default'"
|
||||
@click="selectStatCard(card)"
|
||||
>
|
||||
{{ card.label }}
|
||||
<a-typography-text
|
||||
:type="isStatActive(card) ? undefined : 'secondary'"
|
||||
:style="{ color: isStatActive(card) ? 'inherit' : undefined, marginInlineStart: '6px' }"
|
||||
>
|
||||
{{ formatCount(card.count) }}
|
||||
</a-typography-text>
|
||||
</a-button>
|
||||
</a-flex>
|
||||
|
||||
<a-flex
|
||||
v-if="isMobile"
|
||||
wrap="nowrap"
|
||||
:gap="8"
|
||||
align="center"
|
||||
:style="{ width: '100%' }"
|
||||
>
|
||||
<div :style="{ flex: '1 1 0%', minWidth: 0 }">
|
||||
<a-select
|
||||
:value="stageId"
|
||||
style="width: 100%"
|
||||
:options="stageFilterOptions"
|
||||
@update:value="(v) => setStageFilter(String(v ?? ''))"
|
||||
/>
|
||||
</div>
|
||||
<div :style="{ flex: '1 1 0%', minWidth: 0 }">
|
||||
<a-select
|
||||
:value="sort"
|
||||
style="width: 100%"
|
||||
:options="Object.entries(sortLabels).map(([value, label]) => ({ value, label }))"
|
||||
@update:value="(v) => setSort(String(v ?? 'updated') as SortKey)"
|
||||
/>
|
||||
</div>
|
||||
</a-flex>
|
||||
|
||||
<!-- موبایل: جستجو + آیکن فیلتر داخل یک باکس (مثل مخاطبین) -->
|
||||
<a-input
|
||||
v-if="isMobile"
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
placeholder="جستجو نام، موبایل، شهر…"
|
||||
style="width: 100%"
|
||||
@pressEnter="onSearch"
|
||||
>
|
||||
<template #prefix>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
<template #suffix>
|
||||
<span
|
||||
ref="filterAnchor"
|
||||
:style="{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: '4px',
|
||||
color: mobileFilterBadgeCount ? token.colorPrimary : token.colorTextSecondary,
|
||||
}"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="فیلتر"
|
||||
@click.stop="toggleFilterPopover"
|
||||
@keydown.enter.prevent="toggleFilterPopover"
|
||||
>
|
||||
<FilterOutlined />
|
||||
<a-typography-text
|
||||
<template #quick-filters>
|
||||
<div ref="filterAnchor" :style="{ position: 'relative' }" @click.stop>
|
||||
<a-button @click.stop="toggleFilterPopover">
|
||||
<template #icon><FilterOutlined /></template>
|
||||
فیلتر
|
||||
<a-badge
|
||||
v-if="mobileFilterBadgeCount"
|
||||
:style="{ color: 'inherit', fontSize: `${token.fontSizeSM}px` }"
|
||||
>
|
||||
{{ toFaDigits(mobileFilterBadgeCount) }}
|
||||
</a-typography-text>
|
||||
</span>
|
||||
</template>
|
||||
</a-input>
|
||||
|
||||
<a-flex
|
||||
v-else
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="8"
|
||||
:style="{ width: '100%' }"
|
||||
>
|
||||
<a-flex wrap="wrap" align="center" :gap="8">
|
||||
<a-input-search
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
placeholder="جستجو نام، موبایل، شهر…"
|
||||
style="width: 15rem; max-width: 100%"
|
||||
@search="onSearch"
|
||||
>
|
||||
<template #enterButton>
|
||||
<a-button type="primary">
|
||||
<template #icon><SearchOutlined /></template>
|
||||
</a-button>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<div ref="filterAnchor" :style="{ position: 'relative', flex: '0 0 auto' }">
|
||||
<a-button
|
||||
:style="mobileFilterBadgeCount
|
||||
? {
|
||||
borderColor: token.colorPrimary,
|
||||
color: token.colorPrimary,
|
||||
background: token.colorPrimaryBg,
|
||||
}
|
||||
: undefined"
|
||||
@click.stop="toggleFilterPopover"
|
||||
>
|
||||
<a-flex align="center" justify="center" :gap="6">
|
||||
<FilterOutlined />
|
||||
<span>{{ filterBtnLabel }}</span>
|
||||
<DownOutlined />
|
||||
</a-flex>
|
||||
</a-button>
|
||||
</div>
|
||||
<a-select
|
||||
:value="sort"
|
||||
style="width: 10rem"
|
||||
:options="Object.entries(sortLabels).map(([value, label]) => ({ value, label }))"
|
||||
@update:value="(v) => setSort(String(v ?? 'updated') as SortKey)"
|
||||
:count="mobileFilterBadgeCount"
|
||||
:number-style="{ backgroundColor: token.colorPrimary, boxShadow: 'none' }"
|
||||
:style="{ marginInlineStart: '6px' }"
|
||||
/>
|
||||
</a-flex>
|
||||
<a-space :size="8">
|
||||
<TableColumnsMenu table-key="leads" align="end" />
|
||||
<a-radio-group
|
||||
value="list"
|
||||
button-style="solid"
|
||||
@change="(e: any) => { if (e?.target?.value === 'board') void router.push({ name: 'leads-board' }) }"
|
||||
>
|
||||
<a-radio-button value="list">
|
||||
<UnorderedListOutlined />
|
||||
</a-radio-button>
|
||||
<a-radio-button value="board">
|
||||
<AppstoreOutlined />
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="moreFiltersOpen"
|
||||
data-lead-filter
|
||||
:style="filterPanelStyle"
|
||||
@click.stop
|
||||
>
|
||||
<a-flex vertical :gap="10">
|
||||
<div v-for="facet in textFacets" :key="facet.key">
|
||||
</a-button>
|
||||
<div v-if="moreFiltersOpen" data-lead-filter :style="filterPanelStyle" @click.stop>
|
||||
<a-flex vertical :gap="2">
|
||||
<div v-for="facet in textFacets" :key="facet.key" :style="facetItemStyle">
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:style="{ cursor: 'pointer' }"
|
||||
:style="facetRowStyle(facet.key)"
|
||||
@mouseenter="filterRowHover = facet.key"
|
||||
@mouseleave="filterRowHover = null"
|
||||
@click="toggleFilterSection(facet.key)"
|
||||
@keydown.enter.prevent="toggleFilterSection(facet.key)"
|
||||
>
|
||||
@@ -1908,7 +1768,7 @@ onBeforeUnmount(() => {
|
||||
v-if="filterSection === facet.key"
|
||||
vertical
|
||||
:gap="4"
|
||||
:style="{ marginTop: '6px' }"
|
||||
:style="facetBodyStyle"
|
||||
>
|
||||
<a-input
|
||||
v-if="facet.searchable"
|
||||
@@ -1916,7 +1776,7 @@ onBeforeUnmount(() => {
|
||||
allow-clear
|
||||
placeholder="جستجو"
|
||||
/>
|
||||
<div :style="{ maxHeight: '11.5rem', overflow: 'auto' }">
|
||||
<div :style="{ maxHeight: '11.5rem', overflow: 'auto', scrollbarWidth: 'none' }">
|
||||
<a-button
|
||||
v-for="option in visibleFacetOptions(facet.options).options"
|
||||
:key="option.value || 'all'"
|
||||
@@ -1943,11 +1803,13 @@ onBeforeUnmount(() => {
|
||||
</a-flex>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div :style="facetItemStyle">
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:style="{ cursor: 'pointer' }"
|
||||
:style="facetRowStyle('createdFrom')"
|
||||
@mouseenter="filterRowHover = 'createdFrom'"
|
||||
@mouseleave="filterRowHover = null"
|
||||
@click="toggleFilterSection('createdFrom')"
|
||||
@keydown.enter.prevent="toggleFilterSection('createdFrom')"
|
||||
>
|
||||
@@ -1958,7 +1820,7 @@ onBeforeUnmount(() => {
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</div>
|
||||
<div v-if="filterSection === 'createdFrom'" :style="{ marginTop: '6px' }">
|
||||
<div v-if="filterSection === 'createdFrom'" :style="facetBodyStyle">
|
||||
<JalaliDateInput
|
||||
:model-value="createdFromFilter"
|
||||
placeholder="از تاریخ"
|
||||
@@ -1967,11 +1829,13 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div :style="facetItemStyle">
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:style="{ cursor: 'pointer' }"
|
||||
:style="facetRowStyle('createdTo')"
|
||||
@mouseenter="filterRowHover = 'createdTo'"
|
||||
@mouseleave="filterRowHover = null"
|
||||
@click="toggleFilterSection('createdTo')"
|
||||
@keydown.enter.prevent="toggleFilterSection('createdTo')"
|
||||
>
|
||||
@@ -1982,7 +1846,7 @@ onBeforeUnmount(() => {
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</div>
|
||||
<div v-if="filterSection === 'createdTo'" :style="{ marginTop: '6px' }">
|
||||
<div v-if="filterSection === 'createdTo'" :style="facetBodyStyle">
|
||||
<JalaliDateInput
|
||||
:model-value="createdToFilter"
|
||||
placeholder="تا تاریخ"
|
||||
@@ -1991,11 +1855,13 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div :style="facetItemStyle">
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:style="{ cursor: 'pointer' }"
|
||||
:style="facetRowStyle('converted')"
|
||||
@mouseenter="filterRowHover = 'converted'"
|
||||
@mouseleave="filterRowHover = null"
|
||||
@click="toggleFilterSection('converted')"
|
||||
@keydown.enter.prevent="toggleFilterSection('converted')"
|
||||
>
|
||||
@@ -2006,7 +1872,7 @@ onBeforeUnmount(() => {
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</div>
|
||||
<a-flex v-if="filterSection === 'converted'" vertical :style="{ marginTop: '6px' }">
|
||||
<a-flex v-if="filterSection === 'converted'" vertical :style="facetBodyStyle">
|
||||
<a-button
|
||||
type="text"
|
||||
block
|
||||
@@ -2026,11 +1892,13 @@ onBeforeUnmount(() => {
|
||||
</a-flex>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div :style="facetItemStyle">
|
||||
<div
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:style="{ cursor: 'pointer' }"
|
||||
:style="facetRowStyle('archived')"
|
||||
@mouseenter="filterRowHover = 'archived'"
|
||||
@mouseleave="filterRowHover = null"
|
||||
@click="toggleFilterSection('archived')"
|
||||
@keydown.enter.prevent="toggleFilterSection('archived')"
|
||||
>
|
||||
@@ -2041,7 +1909,7 @@ onBeforeUnmount(() => {
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</div>
|
||||
<a-flex v-if="filterSection === 'archived'" vertical :style="{ marginTop: '6px' }">
|
||||
<a-flex v-if="filterSection === 'archived'" vertical :style="facetBodyStyle">
|
||||
<a-button
|
||||
type="text"
|
||||
block
|
||||
@@ -2072,8 +1940,47 @@ onBeforeUnmount(() => {
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</div>
|
||||
</Teleport>
|
||||
</a-flex>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="!isMobile" #toolbar-end>
|
||||
<TableColumnsMenu table-key="leads" icon-only align="end" />
|
||||
</template>
|
||||
<template #chips-end>
|
||||
<FilterChips
|
||||
label="مرتبسازی"
|
||||
:options="sortOptions"
|
||||
:multiple="false"
|
||||
:show-all="false"
|
||||
:model-value="sortSelected"
|
||||
@update:model-value="onSortChange"
|
||||
/>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- تریگرهای ورود داده؛ از منوی «⋯» هدر کلیک میشوند (مودالهایشان به body تلپورت میشوند) -->
|
||||
<div hidden>
|
||||
<ExcelImportFlow
|
||||
preview-path="/leads/import/preview"
|
||||
import-path="/leads/import/file"
|
||||
:disabled="busy"
|
||||
@start="onExcelImportStart"
|
||||
@done="onExcelImportDone"
|
||||
@fail="onExcelImportFail"
|
||||
@settled="onExcelImportSettled"
|
||||
>
|
||||
<span ref="excelImportTrigger"></span>
|
||||
</ExcelImportFlow>
|
||||
<PhoneContactsImport
|
||||
target="leads"
|
||||
:disabled="busy"
|
||||
@start="onPhoneImportStart"
|
||||
@done="onPhoneImportDone"
|
||||
@fail="onPhoneImportFail"
|
||||
@settled="onPhoneImportSettled"
|
||||
>
|
||||
<span ref="phoneImportTrigger"></span>
|
||||
</PhoneContactsImport>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="selectedIds.length" :span="24" @click.stop>
|
||||
@@ -2100,7 +2007,7 @@ onBeforeUnmount(() => {
|
||||
allow-clear
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
<a-button :disabled="!bulkStageId || busy" @click="openBulkStageReason">اعمال وضعیت</a-button>
|
||||
<a-button :disabled="!bulkStageId || busy" @click="bulkStageSelected">اعمال وضعیت</a-button>
|
||||
</template>
|
||||
<a-button danger :disabled="busy" @click="archiveSelected">بایگانی</a-button>
|
||||
</a-space>
|
||||
@@ -2125,8 +2032,9 @@ onBeforeUnmount(() => {
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-card>
|
||||
<a-spin :spinning="loading || pageBusy" :tip="pageBusy ? busyMessage : undefined">
|
||||
<template v-if="data?.items.length">
|
||||
<template v-if="data?.items?.length">
|
||||
<a-row v-if="isMobile" :gutter="[12, 12]">
|
||||
<a-col v-for="(lead, idx) in data.items" :key="`m-${lead.id}`" :span="24">
|
||||
<a-card
|
||||
@@ -2238,10 +2146,7 @@ onBeforeUnmount(() => {
|
||||
:pagination="false"
|
||||
:row-key="(r: LeadDto) => r.id"
|
||||
:scroll="{ x: 1100 }"
|
||||
:custom-row="(record: LeadDto) => ({
|
||||
onClick: () => goDetail(record.id),
|
||||
style: { cursor: 'pointer' },
|
||||
})"
|
||||
:custom-row="(record: LeadDto) => ({ onClick: () => goDetail(record.id) })"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'select'">
|
||||
@@ -2270,11 +2175,6 @@ onBeforeUnmount(() => {
|
||||
<a-tag v-if="(record as LeadDto).source">{{ (record as LeadDto).source }}</a-tag>
|
||||
<a-typography-text v-else type="secondary">—</a-typography-text>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'activityExperience'">
|
||||
<a-typography-text>
|
||||
{{ (record as LeadDto).activityExperience || '—' }}
|
||||
</a-typography-text>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'createdAt'">
|
||||
{{ formatJalaliNumeric(new Date((record as LeadDto).createdAt)) }}
|
||||
</template>
|
||||
@@ -2370,6 +2270,7 @@ onBeforeUnmount(() => {
|
||||
</a-space>
|
||||
</a-empty>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-modal
|
||||
@@ -2584,36 +2485,5 @@ onBeforeUnmount(() => {
|
||||
</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="bulkStageReasonOpen"
|
||||
title="دلیل تغییر وضعیت"
|
||||
ok-text="ثبت و انتقال"
|
||||
cancel-text="انصراف"
|
||||
:confirm-loading="busy"
|
||||
:ok-button-props="{ disabled: !bulkStageReason.trim() }"
|
||||
@ok="bulkStageSelected"
|
||||
@cancel="cancelBulkStageReason"
|
||||
>
|
||||
<a-flex vertical :gap="12">
|
||||
<a-typography-text type="secondary">
|
||||
انتقال {{ toFaDigits(selectedIds.length) }} لید به
|
||||
«{{ stages.find((s) => s.id === bulkStageId)?.name || '—' }}»
|
||||
</a-typography-text>
|
||||
<a-textarea
|
||||
v-model:value="bulkStageReason"
|
||||
:rows="4"
|
||||
:maxlength="1000"
|
||||
show-count
|
||||
placeholder="دلیل تغییر وضعیت را بنویسید…"
|
||||
/>
|
||||
<a-alert
|
||||
v-if="bulkStageReasonError"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="bulkStageReasonError"
|
||||
/>
|
||||
</a-flex>
|
||||
</a-modal>
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
@@ -76,6 +76,7 @@ import {
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard, CrmSkeletonKpi } from '@/components/skeleton';
|
||||
import type { Component } from 'vue';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
@@ -726,16 +727,18 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
<CrownOutlined :style="{ color: 'var(--ant-color-warning)' }" />
|
||||
باشگاه مشتریان
|
||||
</a-typography-title>
|
||||
<PageHeader
|
||||
title="باشگاه مشتریان"
|
||||
subtitle="امتیاز، سطح و پاداش مشتریان وفادار"
|
||||
:icon="CrownOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button @click="openSettings">
|
||||
<template #icon><SettingOutlined /></template>
|
||||
تنظیمات باشگاه
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
@@ -72,6 +72,7 @@ import {
|
||||
UserOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
@@ -803,13 +804,17 @@ onUnmounted(() => {
|
||||
|
||||
<!-- Desktop -->
|
||||
<template v-else>
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون پیامکها</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<PageHeader
|
||||
title="اتوماسیون پیامکها"
|
||||
subtitle="برای هر رویداد در سیستم، به صورت خودکار پیامک ارسال کنید"
|
||||
:icon="MessageOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
@@ -34,8 +34,10 @@ import {
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ShoppingOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -269,15 +271,17 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
فروشگاههای مونتیفای
|
||||
</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load()">
|
||||
<PageHeader
|
||||
title="فروشگاههای مونتیفای"
|
||||
subtitle="اتصال فروشگاهها برای همگامسازی سفارشها و مشتریان"
|
||||
:icon="ShoppingOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load()">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
+114
-146
@@ -11,6 +11,14 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import VoiceToTextButton from '@/components/VoiceToTextButton.vue';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { UiDropdownMenu } from '@/components/ui';
|
||||
import { FilterChips, PageHeader } from '@/components/page';
|
||||
import type { PageHeaderMenuItem, PageHeaderViewOption } from '@/components/page';
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
FileTextOutlined,
|
||||
SettingOutlined,
|
||||
UnorderedListOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { appendSpokenText } from '@/lib/spoken-text';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
@@ -119,6 +127,46 @@ const categoryChips = computed(() => [
|
||||
.map((item) => ({ value: item.key, label: item.label, tone: item.tone || 'general' })),
|
||||
]);
|
||||
|
||||
/* ---------- هدر صفحه (دسکتاپ) ---------- */
|
||||
const categoryOptions = computed(() =>
|
||||
categoryChips.value
|
||||
.filter((c) => c.value !== 'all')
|
||||
.map((c) => ({ value: c.value, label: c.label })),
|
||||
);
|
||||
|
||||
const visibilityOptions: Array<{ value: NoteVisibility; label: string }> = [
|
||||
{ value: 'team', label: 'تیمی' },
|
||||
{ value: 'personal', label: 'فقط من' },
|
||||
];
|
||||
|
||||
const sortOptions: Array<{ value: SortKey; label: string }> = [
|
||||
{ value: 'updatedAt', label: 'جدیدترین' },
|
||||
{ value: 'createdAt', label: 'تاریخ ایجاد' },
|
||||
{ value: 'reminderAt', label: 'یادآوری' },
|
||||
];
|
||||
|
||||
const viewOptions: PageHeaderViewOption[] = [
|
||||
{ value: 'grid', label: 'شبکه', icon: AppstoreOutlined },
|
||||
{ value: 'list', label: 'لیست', icon: UnorderedListOutlined },
|
||||
];
|
||||
|
||||
const headerMenuItems = computed<PageHeaderMenuItem[]>(() =>
|
||||
canManageNoteFields.value
|
||||
? [{ key: 'categories', label: 'مدیریت دستهها', icon: SettingOutlined }]
|
||||
: [],
|
||||
);
|
||||
|
||||
function onHeaderMenu(key: string) {
|
||||
if (key === 'categories') categoriesOpen.value = true;
|
||||
}
|
||||
|
||||
function onSearchInput(value: string) {
|
||||
const hadQuery = !!q.value;
|
||||
q.value = value;
|
||||
// پاک کردن با × فوراً همهٔ یادداشتها را برمیگرداند
|
||||
if (!value && hadQuery) void load();
|
||||
}
|
||||
|
||||
const noteTypeOptions = computed(() =>
|
||||
noteCategories.value
|
||||
.filter((item) => item.isActive)
|
||||
@@ -759,95 +807,64 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<section class="notes-page">
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h1>یادداشتها</h1>
|
||||
<p class="lead">فکر کنید، یادداشت کنید، هیچ چیز را فراموش نکنید.</p>
|
||||
</div>
|
||||
</header>
|
||||
<!--
|
||||
هدر یکپارچه. نوار ابزار و ردیف چیپ فقط در دسکتاپ؛
|
||||
موبایل نوار سریع و چیپهای اسکرولی خودش را دارد.
|
||||
-->
|
||||
<PageHeader
|
||||
title="یادداشتها"
|
||||
subtitle="فکر کنید، یادداشت کنید، هیچ چیز را فراموش نکنید."
|
||||
:icon="FileTextOutlined"
|
||||
:count="loading ? undefined : notes.length"
|
||||
:primary-label="isMobile ? undefined : 'یادداشت جدید'"
|
||||
:menu-items="headerMenuItems"
|
||||
:searchable="!isMobile"
|
||||
:search="q"
|
||||
search-placeholder="جستجو در یادداشتها…"
|
||||
:view-options="isMobile ? [] : viewOptions"
|
||||
:view="viewMode"
|
||||
@primary="openEditor()"
|
||||
@menu="onHeaderMenu"
|
||||
@update:search="onSearchInput"
|
||||
@search-submit="load"
|
||||
@update:view="(v?: string) => (viewMode = v === 'list' ? 'list' : 'grid')"
|
||||
>
|
||||
<template v-if="!isMobile" #chips>
|
||||
<FilterChips
|
||||
label="دسته"
|
||||
:options="categoryOptions"
|
||||
:multiple="false"
|
||||
:model-value="typeFilter === 'all' ? [] : [typeFilter]"
|
||||
@update:model-value="(v: string[]) => (typeFilter = v[0] ?? 'all')"
|
||||
/>
|
||||
<FilterChips
|
||||
label="دسترسی"
|
||||
:options="visibilityOptions"
|
||||
:multiple="false"
|
||||
:model-value="visibilityFilter === 'all' ? [] : [visibilityFilter]"
|
||||
@update:model-value="(v: NoteVisibility[]) => (visibilityFilter = v[0] ?? 'all')"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="!isMobile" #chips-end>
|
||||
<FilterChips
|
||||
label="مرتبسازی"
|
||||
:options="sortOptions"
|
||||
:multiple="false"
|
||||
:show-all="false"
|
||||
:model-value="[sortKey]"
|
||||
@update:model-value="(v: SortKey[]) => v[0] && (sortKey = v[0])"
|
||||
/>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<p v-if="error" class="banner-error">{{ error }}</p>
|
||||
|
||||
<!-- Desktop toolbar -->
|
||||
<div class="toolbar desktop-only">
|
||||
<div class="chips">
|
||||
<button
|
||||
v-for="chip in categoryChips"
|
||||
:key="chip.value"
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="[`tone-${chip.tone}`, { active: typeFilter === chip.value }]"
|
||||
@click="typeFilter = chip.value"
|
||||
>
|
||||
<span v-if="chip.value !== 'all'" class="dot" />
|
||||
{{ chip.label }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canManageNoteFields"
|
||||
type="button"
|
||||
class="chip chip-manage"
|
||||
@click="categoriesOpen = true"
|
||||
>
|
||||
دستهها
|
||||
</button>
|
||||
<span class="chip-sep" aria-hidden="true" />
|
||||
<button
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="{ active: visibilityFilter === 'all' }"
|
||||
@click="visibilityFilter = 'all'"
|
||||
>
|
||||
همه دسترسیها
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="chip tone-team"
|
||||
:class="{ active: visibilityFilter === 'team' }"
|
||||
@click="visibilityFilter = 'team'"
|
||||
>
|
||||
تیمی
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="chip tone-private"
|
||||
:class="{ active: visibilityFilter === 'personal' }"
|
||||
@click="visibilityFilter = 'personal'"
|
||||
>
|
||||
فقط من
|
||||
</button>
|
||||
</div>
|
||||
<div class="toolbar-end">
|
||||
<div class="view-toggle" role="group" aria-label="نمای لیست">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: viewMode === 'grid' }"
|
||||
title="شبکه"
|
||||
@click="viewMode = 'grid'"
|
||||
>
|
||||
<UiIcon name="grid" :size="18" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: viewMode === 'list' }"
|
||||
title="لیست"
|
||||
@click="viewMode = 'list'"
|
||||
>
|
||||
<UiIcon name="list" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="sortKey" class="sort-select" aria-label="مرتبسازی">
|
||||
<option value="updatedAt">جدیدترین</option>
|
||||
<option value="createdAt">تاریخ ایجاد</option>
|
||||
<option value="reminderAt">یادآوری</option>
|
||||
</select>
|
||||
<button type="button" class="icon-btn" title="فیلتر" @click="q = q; load()">
|
||||
<UiIcon name="filter" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Desktop quick-add -->
|
||||
<div class="quick-add desktop-only" @click="openEditor()">
|
||||
<div
|
||||
class="quick-add desktop-only"
|
||||
:class="{ 'is-list': viewMode === 'list' }"
|
||||
@click="openEditor()"
|
||||
>
|
||||
<input
|
||||
class="quick-input"
|
||||
type="text"
|
||||
@@ -1124,10 +1141,7 @@ onBeforeUnmount(() => {
|
||||
<div class="panel-backdrop" aria-hidden="true" />
|
||||
<aside
|
||||
class="editor-panel"
|
||||
:style="{
|
||||
'--canvas': draftColorCss,
|
||||
background: draftColorCss,
|
||||
}"
|
||||
:style="{ '--canvas': draftColorCss }"
|
||||
>
|
||||
<header class="panel-head">
|
||||
<h2>{{ editorTitle }}</h2>
|
||||
@@ -1562,23 +1576,6 @@ onBeforeUnmount(() => {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.page-head h1 {
|
||||
margin: 0;
|
||||
font-size: 1.55rem;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
}
|
||||
.lead {
|
||||
margin: 0.35rem 0 0;
|
||||
color: #64748b;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.card-fields {
|
||||
margin: 0.4rem 0 0;
|
||||
padding: 0;
|
||||
@@ -1602,19 +1599,6 @@ onBeforeUnmount(() => {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 1.1rem;
|
||||
}
|
||||
.toolbar-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
@@ -1726,32 +1710,6 @@ onBeforeUnmount(() => {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.view-toggle {
|
||||
display: inline-flex;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
.view-toggle button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0.35rem 0.45rem;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.view-toggle button.active {
|
||||
background: var(--teal-soft);
|
||||
color: var(--teal);
|
||||
}
|
||||
.sort-select {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.35rem 0.55rem;
|
||||
background: #fff;
|
||||
color: #334155;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
border: 0;
|
||||
@@ -1838,6 +1796,15 @@ onBeforeUnmount(() => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
/* نمای لیست: ستون وسطچین با عرض خوانا، نه تمامعرض */
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
.quick-add.is-list {
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
.notes-board.is-list .note-card {
|
||||
aspect-ratio: auto;
|
||||
@@ -2207,7 +2174,8 @@ onBeforeUnmount(() => {
|
||||
font-size: 0.98rem;
|
||||
line-height: 1.6;
|
||||
outline: none;
|
||||
box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
|
||||
box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
.swatches {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
@@ -27,7 +26,6 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import type { UploadProps } from 'ant-design-vue';
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
CheckOutlined,
|
||||
DeleteOutlined,
|
||||
PhoneOutlined,
|
||||
@@ -35,6 +33,7 @@ import {
|
||||
SearchOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
||||
import {
|
||||
ACTIVITY_EXPERIENCE_OPTIONS,
|
||||
@@ -58,9 +57,11 @@ import CustomFieldsSection from '@/components/CustomFieldsSection.vue';
|
||||
import CustomerMoodFace from '@/components/CustomerMoodFace.vue';
|
||||
import EntityTimeline from '@/components/EntityTimeline.vue';
|
||||
import MentoMemoryPanel from '@/components/MentoMemoryPanel.vue';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { UserOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const ASpaceCompact = Space.Compact;
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
const AListItem = AList.Item;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
@@ -78,6 +79,7 @@ const emit = defineEmits<{ saved: [person?: PersonDto]; cancel: [] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const id = computed(() => {
|
||||
if (props.embedded) return props.entityId ?? '';
|
||||
return typeof route.params.id === 'string' ? route.params.id : '';
|
||||
@@ -406,6 +408,7 @@ async function submit() {
|
||||
try {
|
||||
if (isNew.value) {
|
||||
const { data } = await api.post<PersonDto>('/people', payload());
|
||||
feedback.success('شخص ذخیره شد.');
|
||||
if (props.embedded) {
|
||||
emit('saved', data);
|
||||
return;
|
||||
@@ -413,6 +416,7 @@ async function submit() {
|
||||
await router.replace({ name: 'person-detail', params: { id: data.id } });
|
||||
} else {
|
||||
await api.patch(`/people/${id.value}`, payload());
|
||||
feedback.success('شخص ذخیره شد.');
|
||||
if (props.embedded) {
|
||||
emit('saved');
|
||||
return;
|
||||
@@ -420,16 +424,7 @@ async function submit() {
|
||||
await router.push({ name: 'person-detail', params: { id: id.value } });
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
@@ -446,9 +441,10 @@ function remove() {
|
||||
async onOk() {
|
||||
try {
|
||||
await api.delete(`/people/${id.value}`);
|
||||
feedback.success('شخص حذف شد.');
|
||||
await router.push({ name: 'contacts' });
|
||||
} catch {
|
||||
error.value = 'حذف ناموفق بود';
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف ناموفق بود');
|
||||
return Promise.reject();
|
||||
}
|
||||
},
|
||||
@@ -468,36 +464,23 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="pageTitle"
|
||||
subtitle="مشخصات، اطلاعات تماس و فیلدهای سفارشی شخص"
|
||||
:icon="UserOutlined"
|
||||
primary-label="ذخیره"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
:menu-items="isNew ? [] : [{ key: 'delete', label: 'حذف مخاطب', icon: DeleteOutlined, danger: true, disabled: saving }]"
|
||||
:style="{ marginBottom: '16px' }"
|
||||
@primary="submit"
|
||||
@menu="remove"
|
||||
>
|
||||
<div>
|
||||
<a-typography-text type="secondary">
|
||||
<RouterLink :to="{ name: 'contacts' }">مخاطبین</RouterLink>
|
||||
· {{ pageTitle }}
|
||||
</a-typography-text>
|
||||
<a-typography-title :level="3" :style="{ margin: '4px 0 0' }">{{ pageTitle }}</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button @click="cancel">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
انصراف
|
||||
</a-button>
|
||||
<a-button v-if="!isNew" danger :disabled="saving" @click="remove">
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
حذف
|
||||
</a-button>
|
||||
<a-button type="primary" :loading="saving" @click="submit">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
ذخیره
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
<template #actions>
|
||||
<a-button @click="cancel">انصراف</a-button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-spin :spinning="loading">
|
||||
<a-form v-if="!loading" layout="vertical" @finish="submit">
|
||||
|
||||
@@ -54,6 +54,9 @@ import DiscBadge from '@/components/behavior/DiscBadge.vue';
|
||||
import CustomerGroupChips from '@/components/CustomerGroupChips.vue';
|
||||
import DiscPanel from '@/components/behavior/DiscPanel.vue';
|
||||
import SalesCopilotPanel from '@/components/behavior/SalesCopilotPanel.vue';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { UserOutlined, EditOutlined } from '@/icons/ant-bridge';
|
||||
import type { PageHeaderMenuItem } from '@/components/page';
|
||||
|
||||
type TabKey = 'activities' | 'tasks' | 'deals' | 'cards' | 'assets' | 'info' | 'disc' | 'copilot';
|
||||
type TimelineTone = 'call' | 'quote' | 'note' | 'meeting' | 'task';
|
||||
@@ -142,6 +145,24 @@ const moreItems = computed<ProfileMoreItem[]>(() => [
|
||||
{ key: 'delete', label: 'حذف شخص', danger: true },
|
||||
]);
|
||||
|
||||
/** منوی «⋯» هدر دسکتاپ؛ همان گزینههای منوی بیشتر موبایل (ویرایش دکمهٔ اصلی است) */
|
||||
const headerMenuItems = computed<PageHeaderMenuItem[]>(() =>
|
||||
moreItems.value
|
||||
.filter((item) => item.key !== 'edit')
|
||||
.map((item) => ({
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
danger: item.danger,
|
||||
dividerBefore: item.key === 'delete',
|
||||
})),
|
||||
);
|
||||
|
||||
function onHeaderMenu(key: string) {
|
||||
const item = moreItems.value.find((row) => row.key === key);
|
||||
if (item?.to) void router.push(item.to);
|
||||
else onMoreSelect(key);
|
||||
}
|
||||
|
||||
function onMoreSelect(key: string) {
|
||||
if (key === 'sms') smsOpen.value = true;
|
||||
if (key === 'delete') void removePerson();
|
||||
@@ -689,25 +710,20 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
||||
|
||||
<template>
|
||||
<section class="page" @click="closeMenus">
|
||||
<header class="desk-head">
|
||||
<div class="title-block">
|
||||
<RouterLink class="back-link" :to="{ name: 'contacts' }">
|
||||
بازگشت به لیست مخاطبین
|
||||
</RouterLink>
|
||||
<h1>جزئیات مخاطب</h1>
|
||||
<div class="desk-head">
|
||||
<PageHeader
|
||||
title="جزئیات مخاطب"
|
||||
:subtitle="person ? fullName : undefined"
|
||||
:icon="UserOutlined"
|
||||
:back-to="{ name: 'contacts' }"
|
||||
primary-label="ویرایش"
|
||||
:primary-icon="EditOutlined"
|
||||
:menu-items="headerMenuItems"
|
||||
:style="{ flex: '1 1 auto', minWidth: 0 }"
|
||||
@primary="router.push({ name: 'person-edit', params: { id } })"
|
||||
@menu="onHeaderMenu"
|
||||
/>
|
||||
</div>
|
||||
<div class="desk-actions">
|
||||
<RouterLink class="btn edit" :to="{ name: 'person-edit', params: { id } }">
|
||||
<UiIcon name="pencil" :size="16" />
|
||||
ویرایش
|
||||
</RouterLink>
|
||||
<button class="btn danger" type="button" @click.stop="removePerson">
|
||||
<UiIcon name="trash" :size="16" />
|
||||
حذف
|
||||
</button>
|
||||
<ProfileMoreMenu v-model="moreOpen" :items="moreItems" @select="onMoreSelect" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<header class="mob-head">
|
||||
<RouterLink class="icon-btn" :to="{ name: 'contacts' }" aria-label="بازگشت">
|
||||
@@ -1255,49 +1271,6 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.title-block h1 {
|
||||
margin: 0.15rem 0 0;
|
||||
font-size: 1.45rem;
|
||||
}
|
||||
|
||||
.back-link {
|
||||
color: #0f766e;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.desk-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #334155;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.55rem 0.9rem;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn.edit {
|
||||
color: #0f766e;
|
||||
border-color: #ccfbf1;
|
||||
background: #f0fdfa;
|
||||
}
|
||||
|
||||
.btn.danger {
|
||||
color: #b91c1c;
|
||||
border-color: #fecaca;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.mob-head {
|
||||
display: grid;
|
||||
grid-template-columns: 40px 1fr auto;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import { formatRelativeDayLabel, toFaDigits } from '@/lib/jalali';
|
||||
import PipelineToolbar from '@/components/pipeline/PipelineToolbar.vue';
|
||||
import type { PipelineViewMode } from '@/components/pipeline/PipelineToolbar.vue';
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import DealFormView from '@/views/DealFormView.vue';
|
||||
import SavedFiltersBar from '@/components/SavedFiltersBar.vue';
|
||||
import type { PageHeaderMenuItem } from '@/components/page';
|
||||
import {
|
||||
DeleteOutlined,
|
||||
DownloadOutlined,
|
||||
@@ -80,6 +82,7 @@ const pageStyle = {
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const auth = useAuthStore();
|
||||
const canCreatePipeline = computed(() => canManageSettings(auth.user?.role));
|
||||
|
||||
@@ -98,8 +101,6 @@ const newName = ref('');
|
||||
const dealModal = ref<{ dealId?: string; stageId?: string } | null>(null);
|
||||
const stageBusy = ref(false);
|
||||
const busy = ref(false);
|
||||
const importMsg = ref('');
|
||||
|
||||
const draggingId = ref<string | null>(null);
|
||||
const draggingColumnId = ref<string | null>(null);
|
||||
const dropStageId = ref<string | null>(null);
|
||||
@@ -229,9 +230,10 @@ async function createPipeline() {
|
||||
const { data } = await api.post<PipelineDto>('/pipelines', { name });
|
||||
newName.value = '';
|
||||
showCreate.value = false;
|
||||
feedback.success('مسیر فروش ساخته شد.');
|
||||
await router.replace({ name: 'pipeline', query: { pipelineId: data.id } });
|
||||
} catch {
|
||||
error.value = 'ساخت مسیر فروش ناموفق بود.';
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'ساخت مسیر فروش ناموفق بود.');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -306,9 +308,9 @@ async function applyUpdateDealStage(
|
||||
stageId,
|
||||
position: position ?? undefined,
|
||||
});
|
||||
} catch {
|
||||
} catch (e) {
|
||||
stages.value = prev;
|
||||
error.value = 'جابهجایی معامله ناموفق بود.';
|
||||
feedback.fromError(e, 'جابهجایی معامله ناموفق بود.');
|
||||
} finally {
|
||||
moving.value = false;
|
||||
}
|
||||
@@ -357,15 +359,6 @@ async function onDrop(stageId: string, event: DragEvent, index?: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function apiMessage(e: unknown, fallback: string) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
if (typeof msg === 'string' && msg) return msg;
|
||||
if (Array.isArray(msg) && msg[0]) return String(msg[0]);
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function onAddDeal(stageId: string) {
|
||||
dealModal.value = { stageId };
|
||||
}
|
||||
@@ -392,7 +385,7 @@ async function persistStageOrder(next: PipelineStage[], prev: PipelineStage[]) {
|
||||
});
|
||||
} catch (e) {
|
||||
stages.value = prev;
|
||||
error.value = apiMessage(e, 'جابهجایی ستون ناموفق بود.');
|
||||
feedback.fromError(e, 'جابهجایی ستون ناموفق بود.');
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
}
|
||||
@@ -431,9 +424,10 @@ async function onRenameStage(stageId: string, title: string) {
|
||||
await api.patch(`/pipelines/${boardPipelineId.value}/stages/${stageId}`, {
|
||||
name: title,
|
||||
});
|
||||
feedback.success('نام ستون بهروز شد.');
|
||||
} catch (e) {
|
||||
stages.value = prev;
|
||||
error.value = apiMessage(e, 'تغییر نام ستون ناموفق بود.');
|
||||
feedback.fromError(e, 'تغییر نام ستون ناموفق بود.');
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
}
|
||||
@@ -445,9 +439,10 @@ async function onAddStage(name: string) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.post(`/pipelines/${boardPipelineId.value}/stages`, { name });
|
||||
feedback.success('ستون اضافه شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'افزودن ستون ناموفق بود.');
|
||||
feedback.fromError(e, 'افزودن ستون ناموفق بود.');
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
}
|
||||
@@ -467,9 +462,10 @@ function onDeleteStage(stageId: string) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.delete(`/pipelines/${boardPipelineId.value}/stages/${stageId}`);
|
||||
feedback.success('ستون حذف شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'حذف ستون ناموفق بود.');
|
||||
feedback.fromError(e, 'حذف ستون ناموفق بود.');
|
||||
throw e;
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
@@ -543,13 +539,18 @@ function confirmDeleteDeals(ids: string[]) {
|
||||
clearSelect();
|
||||
await load();
|
||||
if (failed) {
|
||||
error.value =
|
||||
feedback.error(
|
||||
failed === ids.length
|
||||
? 'حذف معاملهها ناموفق بود.'
|
||||
: `${toFaDigits(failed)} مورد حذف نشد.`;
|
||||
: `${toFaDigits(failed)} مورد حذف نشد.`,
|
||||
);
|
||||
} else {
|
||||
feedback.success(
|
||||
ids.length > 1 ? 'معاملهها حذف شدند.' : 'معامله حذف شد.',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'حذف معامله ناموفق بود.');
|
||||
feedback.fromError(e, 'حذف معامله ناموفق بود.');
|
||||
throw e;
|
||||
} finally {
|
||||
dealDeleting.value = false;
|
||||
@@ -589,9 +590,10 @@ async function promotePriorDeal(dealId: string) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.post(`/deals/${dealId}/promote-from-prior`);
|
||||
feedback.success('معامله به کار جاری منتقل شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'انتقال معامله به کار جاری ناموفق بود.');
|
||||
feedback.fromError(e, 'انتقال معامله به کار جاری ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +604,6 @@ async function exportExcel() {
|
||||
busy.value = true;
|
||||
pageBusy.value = true;
|
||||
busyMessage.value = 'در حال تهیه خروجی اکسل…';
|
||||
importMsg.value = '';
|
||||
error.value = '';
|
||||
try {
|
||||
const { data } = await api.get<Blob>('/deals/export', { responseType: 'blob' });
|
||||
@@ -612,8 +613,9 @@ async function exportExcel() {
|
||||
a.download = `${brand.filePrefix}-deals.xlsx`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch {
|
||||
error.value = 'خروجی اکسل ناموفق بود.';
|
||||
feedback.success('خروجی اکسل آماده شد.');
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'خروجی اکسل ناموفق بود.');
|
||||
} finally {
|
||||
busy.value = false;
|
||||
pageBusy.value = false;
|
||||
@@ -623,19 +625,23 @@ async function exportExcel() {
|
||||
function onImportStart() {
|
||||
busy.value = true;
|
||||
pageBusy.value = false;
|
||||
importMsg.value = '';
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
async function onImportDone(data: ImportContactsResult) {
|
||||
importMsg.value = `وارد شد: ${data.created} · تکراری رد شد: ${data.skipped}${
|
||||
const summary = `وارد شد: ${data.created} · تکراری رد شد: ${data.skipped}${
|
||||
data.errors.length ? ` · خطا: ${data.errors.length}` : ''
|
||||
}${data.boards?.length ? ` · مسیر فروش: ${data.boards.join('، ')}` : ''}`;
|
||||
if (data.errors.length) {
|
||||
error.value = data.errors
|
||||
feedback.warning(summary);
|
||||
feedback.error(
|
||||
data.errors
|
||||
.slice(0, 3)
|
||||
.map((e) => `ردیف ${e.row}: ${e.message}`)
|
||||
.join(' | ');
|
||||
.join(' | '),
|
||||
);
|
||||
} else {
|
||||
feedback.success(summary);
|
||||
}
|
||||
if (data.boardId && data.boardId !== selectedPipelineId.value) {
|
||||
await router.replace({ name: 'pipeline', query: { pipelineId: data.boardId } });
|
||||
@@ -645,7 +651,7 @@ async function onImportDone(data: ImportContactsResult) {
|
||||
}
|
||||
|
||||
function onImportFail(message: string) {
|
||||
error.value = message;
|
||||
feedback.error(message);
|
||||
}
|
||||
|
||||
function onImportSettled() {
|
||||
@@ -708,6 +714,29 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
|
||||
defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
/* ---------- هدر صفحه ---------- */
|
||||
const importTrigger = ref<HTMLElement | null>(null);
|
||||
|
||||
const dealCount = computed(() =>
|
||||
stages.value.reduce((sum, stage) => sum + (stage.total ?? stage.deals.length), 0),
|
||||
);
|
||||
|
||||
const headerMenuItems = computed<PageHeaderMenuItem[]>(() => [
|
||||
{ key: 'export', label: 'خروجی اکسل', icon: DownloadOutlined, disabled: loading.value || busy.value },
|
||||
{ key: 'import', label: 'ورود از اکسل', icon: UploadOutlined, disabled: loading.value || busy.value },
|
||||
]);
|
||||
|
||||
function onHeaderMenu(key: string) {
|
||||
if (key === 'export') void exportExcel();
|
||||
// تریگر مخفی؛ کلیک کاربر روی منو activation را نگه میدارد
|
||||
else if (key === 'import') importTrigger.value?.click();
|
||||
}
|
||||
|
||||
/** معامله جدید از هدر ← اولین مرحلهٔ مسیر انتخابشده */
|
||||
function onNewDeal() {
|
||||
onAddDeal(stages.value[0]?.id ?? '');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -715,6 +744,10 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
<a-flex vertical :gap="GAP" :style="{ flexShrink: 0 }">
|
||||
<PipelineToolbar
|
||||
pipeline-name="مسیر فروش"
|
||||
subtitle="معاملات را بین مراحل بکشید تا وضعیتشان عوض شود"
|
||||
:count="loading && !stages.length ? undefined : dealCount"
|
||||
primary-label="معامله جدید"
|
||||
:menu-items="headerMenuItems"
|
||||
:pipeline-options="pipelineOptions"
|
||||
v-model:selected-pipeline-id="selectedPipelineId"
|
||||
v-model:view-mode="viewMode"
|
||||
@@ -723,12 +756,21 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
v-model:amount-max="amountMax"
|
||||
:can-create="canCreatePipeline"
|
||||
@create="showCreate = true"
|
||||
@primary="onNewDeal"
|
||||
@menu="onHeaderMenu"
|
||||
>
|
||||
<template #excel>
|
||||
<a-button :disabled="loading || busy" @click="exportExcel">
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
خروجی اکسل
|
||||
</a-button>
|
||||
<template #filters>
|
||||
<SavedFiltersBar
|
||||
compact
|
||||
scope="deals"
|
||||
:current-filters="dealsSavedFilters"
|
||||
@apply="applyDealsSavedFilters"
|
||||
/>
|
||||
</template>
|
||||
</PipelineToolbar>
|
||||
|
||||
<!-- تریگر ورود از اکسل؛ از منوی «⋯» هدر کلیک میشود (مودالش به body تلپورت میشود) -->
|
||||
<div hidden>
|
||||
<ExcelImportFlow
|
||||
preview-path="/deals/import/preview"
|
||||
import-path="/deals/import"
|
||||
@@ -742,24 +784,11 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
@fail="onImportFail"
|
||||
@settled="onImportSettled"
|
||||
>
|
||||
<a-button :disabled="loading || busy">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
ورود از اکسل
|
||||
</a-button>
|
||||
<span ref="importTrigger"></span>
|
||||
</ExcelImportFlow>
|
||||
</template>
|
||||
<template #filters>
|
||||
<SavedFiltersBar
|
||||
compact
|
||||
scope="deals"
|
||||
:current-filters="dealsSavedFilters"
|
||||
@apply="applyDealsSavedFilters"
|
||||
/>
|
||||
</template>
|
||||
</PipelineToolbar>
|
||||
</div>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="importMsg" type="success" show-icon :message="importMsg" />
|
||||
<a-spin v-if="loading && !stages.length" tip="در حال بارگذاری مسیر فروش…" />
|
||||
|
||||
<a-alert
|
||||
|
||||
@@ -27,8 +27,10 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import { PlusOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { FundOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
type PipelineListItem = PipelineDto & {
|
||||
dealCount?: number | null;
|
||||
@@ -176,7 +178,11 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">تنظیمات مسیر فروش</a-typography-title>
|
||||
<PageHeader
|
||||
title="تنظیمات مسیر فروش"
|
||||
subtitle="کاریزها و مراحل معاملات"
|
||||
:icon="FundOutlined"
|
||||
/>
|
||||
|
||||
<a-alert v-if="okMsg" type="success" show-icon :message="okMsg" closable @close="okMsg = ''" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { currencySuffix } from '@/lib/money';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Breadcrumb as ABreadcrumb,
|
||||
BreadcrumbItem as ABreadcrumbItem,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
@@ -34,8 +32,10 @@ import type {
|
||||
OrganizationDto,
|
||||
ProductDto,
|
||||
} from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ShoppingOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const CATEGORIES = [
|
||||
'کارساخته',
|
||||
@@ -240,30 +240,20 @@ onMounted(async () => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="title"
|
||||
subtitle="مشخصات، قیمت و موجودی محصول"
|
||||
:icon="ShoppingOutlined"
|
||||
:primary-label="submitLabel"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
@primary="submit"
|
||||
>
|
||||
<a-flex vertical :gap="4">
|
||||
<a-breadcrumb>
|
||||
<a-breadcrumb-item>
|
||||
<RouterLink :to="{ name: 'products' }">محصولات</RouterLink>
|
||||
</a-breadcrumb-item>
|
||||
<a-breadcrumb-item>{{ title }}</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">{{ title }}</a-typography-title>
|
||||
</a-flex>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button type="primary" :loading="saving" @click="submit">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
{{ submitLabel }}
|
||||
</a-button>
|
||||
<template #actions>
|
||||
<a-button :disabled="saving" @click="cancel">انصراف</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { canAssignToOthers } from '@/lib/assign-access';
|
||||
@@ -9,8 +9,6 @@ import type { OrgUserDto, ProjectCardDto } from '@mento/shared';
|
||||
import {
|
||||
Affix as AAffix,
|
||||
Alert as AAlert,
|
||||
Breadcrumb as ABreadcrumb,
|
||||
BreadcrumbItem as ABreadcrumbItem,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
@@ -23,20 +21,19 @@ import {
|
||||
Input as AInput,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import {
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
DeleteOutlined,
|
||||
FileTextOutlined,
|
||||
SaveOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -227,40 +224,23 @@ onMounted(async () => {
|
||||
</a-button>
|
||||
</a-flex>
|
||||
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-else
|
||||
justify="space-between"
|
||||
align="flex-start"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
:title="pageTitle"
|
||||
subtitle="کارت پروژه، مسئولان و زمانبندی"
|
||||
:icon="FileTextOutlined"
|
||||
:primary-label="saving ? 'در حال ذخیره…' : 'ذخیره'"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
:primary-disabled="!canSave"
|
||||
:menu-items="isNew ? [] : [{ key: 'delete', label: 'حذف کارت', icon: DeleteOutlined, danger: true }]"
|
||||
@primary="save"
|
||||
@menu="removeCard"
|
||||
>
|
||||
<a-flex vertical :gap="4">
|
||||
<a-breadcrumb>
|
||||
<a-breadcrumb-item>
|
||||
<RouterLink :to="{ name: 'projects' }">پروژهها</RouterLink>
|
||||
</a-breadcrumb-item>
|
||||
<a-breadcrumb-item>{{ pageTitle }}</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
<a-flex align="center" :gap="8">
|
||||
<FileTextOutlined />
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
<a-space wrap>
|
||||
<a-button type="primary" :loading="saving" :disabled="!canSave" @click="save">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
|
||||
</a-button>
|
||||
<a-button @click="cancel">
|
||||
<template #icon><CloseOutlined /></template>
|
||||
انصراف
|
||||
</a-button>
|
||||
<a-button v-if="!isNew" danger @click="removeCard">
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
حذف
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
<template #actions>
|
||||
<a-button @click="cancel">انصراف</a-button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -37,8 +37,10 @@ import {
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { CopyOutlined, PlusOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { LinkOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } = Typography;
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } = Typography;
|
||||
const ACheckableTag = ATag.CheckableTag;
|
||||
|
||||
const KEY_COL_LABELS = ['نام', 'پیشوند', 'آخرین استفاده', 'وضعیت'] as const;
|
||||
@@ -229,13 +231,17 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">API و وبهوک</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<PageHeader
|
||||
title="API و وبهوک"
|
||||
subtitle="کلیدهای دسترسی و وبهوکها برای اتصال سرویسهای دیگر"
|
||||
:icon="LinkOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
@@ -1265,13 +1265,16 @@ const activityMax = computed(() =>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="token.margin">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="token.marginSM">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
گزارشات و داشبورد
|
||||
</a-typography-title>
|
||||
</div>
|
||||
<a-space wrap>
|
||||
<PageHeader
|
||||
title="گزارشات و داشبورد"
|
||||
subtitle="داشبورد عملکرد و گزارشساز سفارشی"
|
||||
:icon="BarChartOutlined"
|
||||
primary-label="خروجی اکسل / CSV"
|
||||
:primary-icon="FileExcelOutlined"
|
||||
:primary-disabled="pageMode === 'dashboard' ? !data : !builderResult"
|
||||
@primary="exportReport"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button @click="openSaveModal">
|
||||
<template #icon><SaveOutlined /></template>
|
||||
ذخیره نما
|
||||
@@ -1280,16 +1283,8 @@ const activityMax = computed(() =>
|
||||
<template #icon><LinkOutlined /></template>
|
||||
کپی لینک اشتراک
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="pageMode === 'dashboard' ? !data : !builderResult"
|
||||
@click="exportReport"
|
||||
>
|
||||
<template #icon><FileExcelOutlined /></template>
|
||||
خروجی اکسل / CSV
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-form layout="vertical">
|
||||
|
||||
@@ -42,15 +42,15 @@ import {
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
TabPane as ATabPane,
|
||||
Tabs as ATabs,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { PlusOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ScheduleOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
const AListItem = AList.Item;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
@@ -359,33 +359,24 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">رزرو و نوبتدهی</a-typography-title>
|
||||
<a-space wrap :size="8">
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
<a-button v-if="tab === 'appointments'" type="primary" @click="openCreate">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
نوبت جدید
|
||||
</a-button>
|
||||
<a-button
|
||||
v-else-if="canEditServices"
|
||||
type="primary"
|
||||
@click="openServiceCreate"
|
||||
<PageHeader
|
||||
title="رزرو و نوبتدهی"
|
||||
subtitle="نوبتهای مشتریان و خدماتی که رزرو میشوند"
|
||||
:icon="ScheduleOutlined"
|
||||
:primary-label="tab === 'appointments' ? 'نوبت جدید' : canEditServices ? 'خدمت جدید' : undefined"
|
||||
:tabs="[{ key: 'appointments', label: 'نوبتها' }, { key: 'services', label: 'خدمات' }]"
|
||||
:active-tab="tab"
|
||||
@primary="tab === 'appointments' ? openCreate() : openServiceCreate()"
|
||||
@update:active-tab="(k) => onTabChange(k ?? 'appointments')"
|
||||
>
|
||||
<template #icon><PlusOutlined /></template>
|
||||
خدمت جدید
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-tabs :active-key="tab" @change="onTabChange">
|
||||
<a-tab-pane key="appointments" tab="نوبتها" />
|
||||
<a-tab-pane key="services" tab="خدمات" />
|
||||
</a-tabs>
|
||||
|
||||
<a-alert
|
||||
v-if="error"
|
||||
|
||||
@@ -80,6 +80,7 @@ import type {
|
||||
SalesGoalType,
|
||||
UpdateSalesGoalRequest,
|
||||
} from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
|
||||
@@ -519,21 +520,14 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</a-flex>
|
||||
|
||||
<a-flex
|
||||
<PageHeader
|
||||
v-else
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="12"
|
||||
>
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">هدف و پیشبینی</a-typography-title>
|
||||
</div>
|
||||
<a-button type="primary" @click="openCreate">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
افزودن هدف جدید
|
||||
</a-button>
|
||||
</a-flex>
|
||||
title="هدف و پیشبینی"
|
||||
subtitle="اهداف فروش ماهانه و پیشبینی تحقق آنها"
|
||||
:icon="AimOutlined"
|
||||
primary-label="افزودن هدف جدید"
|
||||
@primary="openCreate"
|
||||
/>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import type {
|
||||
FilteredIdsResponse,
|
||||
LeadDto,
|
||||
@@ -49,24 +50,26 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import type { TableColumnsType, TableProps } from 'ant-design-vue';
|
||||
import {
|
||||
MessageOutlined,
|
||||
ReloadOutlined,
|
||||
SendOutlined,
|
||||
StopOutlined,
|
||||
BarChartOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonList, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
|
||||
type AudienceTab = 'people' | 'leads';
|
||||
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
const loading = ref(false);
|
||||
const listLoading = ref(false);
|
||||
const saving = ref(false);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const campaigns = ref<SmsCampaignDto[]>([]);
|
||||
const audience = ref<AudienceTab>('people');
|
||||
const selectedIds = ref<string[]>([]);
|
||||
@@ -285,18 +288,11 @@ async function selectAllFiltered() {
|
||||
cancelText: 'انصراف',
|
||||
onOk: () => {
|
||||
selectedIds.value = data.ids;
|
||||
ok.value = `${toFaDigits(data.ids.length)} مخاطب انتخاب شد.`;
|
||||
feedback.success(`${toFaDigits(data.ids.length)} مخاطب انتخاب شد.`);
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
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, 'انتخاب همه ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +320,6 @@ async function createCampaign() {
|
||||
}
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
const chunks = chunkIds(selectedIds.value);
|
||||
const wantQueue = queueNow.value;
|
||||
try {
|
||||
@@ -353,17 +348,14 @@ async function createCampaign() {
|
||||
name.value = '';
|
||||
body.value = '';
|
||||
selectedIds.value = [];
|
||||
ok.value = wantQueue
|
||||
feedback.success(
|
||||
wantQueue
|
||||
? `کمپین با ${toFaDigits(chunks.reduce((n, c) => n + c.length, 0))} مخاطب در صف ارسال قرار گرفت.`
|
||||
: 'کمپین بهصورت پیشنویس ذخیره شد.';
|
||||
: 'کمپین بهصورت پیشنویس ذخیره شد.',
|
||||
);
|
||||
await loadCampaigns();
|
||||
} catch (e) {
|
||||
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, 'ساخت کمپین ناموفق بود.');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -372,18 +364,20 @@ async function createCampaign() {
|
||||
async function queue(id: string) {
|
||||
try {
|
||||
await api.post(`/sms-campaigns/${id}/queue`);
|
||||
feedback.success('کمپین در صف ارسال قرار گرفت.');
|
||||
await loadCampaigns();
|
||||
} catch {
|
||||
error.value = 'صفبندی ناموفق بود.';
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'صفبندی ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
async function cancel(id: string) {
|
||||
try {
|
||||
await api.post(`/sms-campaigns/${id}/cancel`);
|
||||
feedback.success('کمپین لغو شد.');
|
||||
await loadCampaigns();
|
||||
} catch {
|
||||
error.value = 'لغو ناموفق بود.';
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'لغو ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,16 +410,25 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">پیامک گروهی</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<PageHeader
|
||||
title="پیامک گروهی"
|
||||
subtitle="ارسال پیامک به اشخاص و لیدها، با فیلدهای پویا و گزارش هر کمپین"
|
||||
:icon="MessageOutlined"
|
||||
:count="loading ? undefined : campaigns.length"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button
|
||||
:loading="loading"
|
||||
aria-label="بروزرسانی"
|
||||
title="بروزرسانی"
|
||||
@click="load"
|
||||
>
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
<a-card :bordered="false" title="کمپین جدید">
|
||||
<a-form layout="vertical" @finish="createCampaign">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
@@ -23,18 +22,16 @@ import {
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
message,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import type { TableColumnsType, TablePaginationConfig } from 'ant-design-vue';
|
||||
import {
|
||||
ArrowRightOutlined,
|
||||
FilterOutlined,
|
||||
SearchOutlined,
|
||||
SyncOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import axios from 'axios';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const AListItem = AList.Item;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
import {
|
||||
@@ -66,9 +63,9 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import SalesReportBoard from '@/components/tahesab/SalesReportBoard.vue';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { BarChartOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const router = useRouter();
|
||||
const { token } = theme.useToken();
|
||||
const { groups: customerGroups, load: loadCustomerGroups } = useCustomerGroups();
|
||||
|
||||
const connections = ref<TahesabConnectionDto[]>([]);
|
||||
@@ -678,28 +675,16 @@ onUnmounted(() => {
|
||||
<template>
|
||||
<a-row :gutter="[24, 24]">
|
||||
<a-col :span="24">
|
||||
<a-flex
|
||||
justify="space-between"
|
||||
align="center"
|
||||
wrap="wrap"
|
||||
:gap="token.marginSM"
|
||||
>
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
گزارش فروش تهحساب
|
||||
</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button @click="router.push({ name: 'reports' })">
|
||||
<template #icon><ArrowRightOutlined /></template>
|
||||
بازگشت
|
||||
</a-button>
|
||||
<a-button type="primary" :loading="syncing" @click="openSyncChoice">
|
||||
<template #icon><SyncOutlined /></template>
|
||||
بهروزرسانی از تهحساب
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
<PageHeader
|
||||
title="گزارش فروش تهحساب"
|
||||
subtitle="فروش و ماندهها از حسابداری تهحساب"
|
||||
:icon="BarChartOutlined"
|
||||
:back-to="{ name: 'reports' }"
|
||||
primary-label="بهروزرسانی از تهحساب"
|
||||
:primary-icon="SyncOutlined"
|
||||
:primary-loading="syncing"
|
||||
@primary="openSyncChoice"
|
||||
/>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="error" :span="24">
|
||||
|
||||
@@ -4,6 +4,8 @@ import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { apiErrorMessage } from '@/lib/apiErrorMessage';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import type {
|
||||
CreateTahesabConnectionRequest,
|
||||
TahesabConnectionDto,
|
||||
@@ -24,10 +26,10 @@ import {
|
||||
} from '@/components/ui';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
|
||||
const feedback = useFeedback();
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const items = ref<TahesabConnectionDto[]>([]);
|
||||
const editingId = ref<string | null>(null);
|
||||
|
||||
@@ -133,17 +135,16 @@ async function saveAutoSync() {
|
||||
}
|
||||
autoSyncSaving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.patch(`/integrations/tahesab/connections/${sync.connectionId}`, {
|
||||
customerSyncHours: hours,
|
||||
});
|
||||
ok.value = hours.length
|
||||
feedback.success(hours.length
|
||||
? 'زمانبندی بروزرسانی ذخیره شد.'
|
||||
: 'بروزرسانی خودکار خاموش شد.';
|
||||
: 'بروزرسانی خودکار خاموش شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'ذخیره زمانبندی ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره زمانبندی ناموفق بود');
|
||||
} finally {
|
||||
autoSyncSaving.value = false;
|
||||
}
|
||||
@@ -161,7 +162,6 @@ async function syncCustomersNow() {
|
||||
importOverlay.message =
|
||||
'در حال همگامسازی همهٔ مشتریان… نام، موبایل، کد ملی، آدرس، شهر، رسته و گروه بهروز میشود.';
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const { data } = await api.post<{
|
||||
imported: number;
|
||||
@@ -173,11 +173,11 @@ async function syncCustomersNow() {
|
||||
}>('/integrations/tahesab/sync/customers-now', {
|
||||
connectionId: sync.connectionId,
|
||||
});
|
||||
ok.value = data.summary;
|
||||
if (data.error) error.value = data.error;
|
||||
feedback.success(data.summary);
|
||||
if (data.error) feedback.warning(data.error);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'همگامسازی مشتریان ناموفق بود');
|
||||
feedback.fromError(e, 'همگامسازی مشتریان ناموفق بود');
|
||||
} finally {
|
||||
syncBusy.value = false;
|
||||
importOverlay.open = false;
|
||||
@@ -285,11 +285,7 @@ function pendingProductNames() {
|
||||
}
|
||||
|
||||
function apiErr(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;
|
||||
return apiErrorMessage(e, fallback);
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
@@ -356,7 +352,6 @@ async function load() {
|
||||
async function save() {
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
if (editingId.value) {
|
||||
const body: UpdateTahesabConnectionRequest = {
|
||||
@@ -372,7 +367,7 @@ async function save() {
|
||||
`/integrations/tahesab/connections/${editingId.value}`,
|
||||
body,
|
||||
);
|
||||
ok.value = 'اتصال بهروزرسانی شد.';
|
||||
feedback.success('اتصال بهروزرسانی شد.');
|
||||
} else {
|
||||
if (!form.token.trim()) {
|
||||
error.value = 'توکن الزامی است.';
|
||||
@@ -388,17 +383,12 @@ async function save() {
|
||||
enabled: form.enabled,
|
||||
};
|
||||
await api.post('/integrations/tahesab/connections', body);
|
||||
ok.value = 'اتصال افزوده شد.';
|
||||
feedback.success('اتصال افزوده شد.');
|
||||
}
|
||||
resetForm();
|
||||
await load();
|
||||
} catch (e) {
|
||||
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, 'ذخیره ناموفق بود');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -406,37 +396,36 @@ async function save() {
|
||||
|
||||
async function testConn(id: string) {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const { data } = await api.post<{ ok: boolean; error?: string }>(
|
||||
`/integrations/tahesab/connections/${id}/test`,
|
||||
);
|
||||
if (data.ok) ok.value = 'اتصال سالم است.';
|
||||
if (data.ok) feedback.success('اتصال سالم است.');
|
||||
else {
|
||||
error.value = data.error ?? 'تست اتصال ناموفق بود.';
|
||||
let msg = data.error ?? 'تست اتصال ناموفق بود.';
|
||||
if (isTlsError(data.error)) {
|
||||
error.value +=
|
||||
msg +=
|
||||
' → دکمه «فعالسازی SSL خودامضا» را بزنید یا در ویرایش اتصال تیک آن را بگذارید.';
|
||||
}
|
||||
feedback.error(msg);
|
||||
}
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'تست ناموفق');
|
||||
feedback.fromError(e, 'تست ناموفق');
|
||||
}
|
||||
}
|
||||
|
||||
async function enableInsecureTls(id: string) {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.patch(`/integrations/tahesab/connections/${id}`, {
|
||||
allowInsecureTls: true,
|
||||
});
|
||||
ok.value = 'پذیرش گواهی خودامضا فعال شد. در حال تست…';
|
||||
feedback.success('پذیرش گواهی خودامضا فعال شد. در حال تست…');
|
||||
await load();
|
||||
await testConn(id);
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'فعالسازی ناموفق بود');
|
||||
feedback.fromError(e, 'فعالسازی ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,13 +434,11 @@ async function removeConn(id: string) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.delete(`/integrations/tahesab/connections/${id}`);
|
||||
ok.value = 'اتصال حذف شد.';
|
||||
feedback.success('اتصال حذف شد.');
|
||||
if (editingId.value === id) resetForm();
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String((e.response?.data as { message?: string })?.message ?? 'حذف ناموفق')
|
||||
: 'حذف ناموفق';
|
||||
feedback.fromError(e, 'حذف ناموفق');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +480,6 @@ async function fetchAllCustomers(): Promise<SyncResult[]> {
|
||||
|
||||
async function searchTahesab(mode: 'range' | 'filter') {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
if (!sync.connectionId) {
|
||||
error.value = 'ابتدا یک اتصال انتخاب کنید.';
|
||||
return;
|
||||
@@ -545,18 +531,19 @@ async function searchTahesab(mode: 'range' | 'filter') {
|
||||
syncTablePage.value = 1;
|
||||
|
||||
if (!syncResults.value.length) {
|
||||
ok.value = 'نتیجهای یافت نشد.';
|
||||
feedback.success('نتیجهای یافت نشد.');
|
||||
} else {
|
||||
const linked = syncResults.value.filter((r) => r.alreadyLinked).length;
|
||||
const duplicate = syncResults.value.filter((r) => duplicateOwner(r)).length;
|
||||
const pending = syncResults.value.length - linked - duplicate;
|
||||
ok.value =
|
||||
feedback.success(
|
||||
`${toFaDigits(syncResults.value.length)} مشتری پیدا شد` +
|
||||
` · ${toFaDigits(linked)} قبلاً وارد شده · ${toFaDigits(pending)} واردنشده` +
|
||||
(duplicate ? ` · ${toFaDigits(duplicate)} شماره تکراری` : '');
|
||||
(duplicate ? ` · ${toFaDigits(duplicate)} شماره تکراری` : ''),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'جستجو ناموفق');
|
||||
feedback.fromError(e, 'جستجو ناموفق');
|
||||
} finally {
|
||||
syncBusy.value = false;
|
||||
}
|
||||
@@ -568,21 +555,20 @@ function onSyncTablePageChange(page: number) {
|
||||
|
||||
async function importOne(moshtariCode: number) {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
syncBusy.value = true;
|
||||
const { data } = await api.post<{ personId: string }>(
|
||||
'/integrations/tahesab/sync/import',
|
||||
{ connectionId: sync.connectionId, moshtariCode },
|
||||
);
|
||||
ok.value = `وارد شد — در مخاطبین با شناسه ${data.personId}`;
|
||||
feedback.success(`وارد شد — در مخاطبین با شناسه ${data.personId}`);
|
||||
const row = syncResults.value.find((r) => r.moshtariCode === moshtariCode);
|
||||
if (row) {
|
||||
row.alreadyLinked = true;
|
||||
row.personId = data.personId;
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'وارد کردن ناموفق');
|
||||
feedback.fromError(e, 'وارد کردن ناموفق');
|
||||
} finally {
|
||||
syncBusy.value = false;
|
||||
}
|
||||
@@ -590,7 +576,6 @@ async function importOne(moshtariCode: number) {
|
||||
|
||||
async function importBulk() {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
if (!sync.connectionId) {
|
||||
error.value = 'ابتدا اتصال را انتخاب کنید.';
|
||||
return;
|
||||
@@ -650,10 +635,10 @@ async function importBulk() {
|
||||
importOverlay.progress = total ? ((i + chunk.length) / total) * 100 : 100;
|
||||
}
|
||||
|
||||
ok.value = `وارد شد: ${toFaDigits(totals.imported)} · قبلاً بود: ${toFaDigits(totals.skipped)} · ناموفق: ${toFaDigits(totals.failed)}`;
|
||||
if (firstError) error.value = `برخی موارد وارد نشدند: ${firstError}`;
|
||||
feedback.success(`وارد شد: ${toFaDigits(totals.imported)} · قبلاً بود: ${toFaDigits(totals.skipped)} · ناموفق: ${toFaDigits(totals.failed)}`);
|
||||
if (firstError) feedback.warning(`برخی موارد وارد نشدند: ${firstError}`);
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'وارد کردن دستهای ناموفق');
|
||||
feedback.fromError(e, 'وارد کردن دستهای ناموفق');
|
||||
} finally {
|
||||
importOverlay.open = false;
|
||||
importOverlay.progress = null;
|
||||
@@ -664,7 +649,6 @@ async function importBulk() {
|
||||
/** همهٔ بازههای کد خوانده میشود و گروه تهحساب روی مشتریهای لینکشده نشانده میشود */
|
||||
async function syncGroups() {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
if (!sync.connectionId) {
|
||||
error.value = 'ابتدا اتصال را انتخاب کنید.';
|
||||
return;
|
||||
@@ -689,9 +673,9 @@ async function syncGroups() {
|
||||
emptyStreak = data.rows ? 0 : emptyStreak + 1;
|
||||
page += 1;
|
||||
}
|
||||
ok.value = `گروهها همگام شد: ${toFaDigits(totals.linked)} مشتری لینکشده بررسی شد · گروه ${toFaDigits(totals.updated)} نفر بهروز شد.`;
|
||||
feedback.success(`گروهها همگام شد: ${toFaDigits(totals.linked)} مشتری لینکشده بررسی شد · گروه ${toFaDigits(totals.updated)} نفر بهروز شد.`);
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'همگامسازی گروهها ناموفق بود');
|
||||
feedback.fromError(e, 'همگامسازی گروهها ناموفق بود');
|
||||
} finally {
|
||||
importOverlay.open = false;
|
||||
syncBusy.value = false;
|
||||
@@ -711,7 +695,6 @@ const exportIssues = ref<ExportItem[]>([]);
|
||||
/** شخصهای لینکنشده: اول تطبیق، بعد ساخت در تهحساب (بدون ساخت تکراری) */
|
||||
async function exportUnlinked() {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
exportIssues.value = [];
|
||||
if (!sync.connectionId) {
|
||||
error.value = 'ابتدا اتصال را انتخاب کنید.';
|
||||
@@ -724,7 +707,7 @@ async function exportUnlinked() {
|
||||
{ params: { connectionId: sync.connectionId } },
|
||||
);
|
||||
if (!unlinked.total) {
|
||||
ok.value = 'همهٔ اشخاص به تهحساب لینک هستند.';
|
||||
feedback.success('همهٔ اشخاص به تهحساب لینک هستند.');
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@@ -770,12 +753,13 @@ async function exportUnlinked() {
|
||||
}
|
||||
importOverlay.progress = ((i + chunk.length) / ids.length) * 100;
|
||||
}
|
||||
ok.value =
|
||||
feedback.success(
|
||||
`ثبت در تهحساب تمام شد: لینک با مشتری موجود ${toFaDigits(totals.matched)} · ` +
|
||||
`ساختهشده ${toFaDigits(totals.created)} · چند نتیجه (نیاز به بررسی) ${toFaDigits(totals.ambiguous)} · ` +
|
||||
`ناموفق ${toFaDigits(totals.failed)}`;
|
||||
`ناموفق ${toFaDigits(totals.failed)}`,
|
||||
);
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'ثبت گروهی در تهحساب ناموفق بود');
|
||||
feedback.fromError(e, 'ثبت گروهی در تهحساب ناموفق بود');
|
||||
} finally {
|
||||
importOverlay.open = false;
|
||||
importOverlay.progress = null;
|
||||
@@ -785,7 +769,6 @@ async function exportUnlinked() {
|
||||
|
||||
async function searchProducts() {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
if (!productSync.connectionId) {
|
||||
error.value = 'ابتدا اتصال را برای کارساخته انتخاب کنید.';
|
||||
return;
|
||||
@@ -803,15 +786,16 @@ async function searchProducts() {
|
||||
productSyncResults.value = data.results ?? [];
|
||||
if (data.categoryLabel) productCategoryLabel.value = data.categoryLabel;
|
||||
if (!productSyncResults.value.length) {
|
||||
ok.value = 'کارساختهای یافت نشد.';
|
||||
feedback.success('کارساختهای یافت نشد.');
|
||||
} else {
|
||||
const linked = productSyncResults.value.filter((r) => r.alreadyImported).length;
|
||||
ok.value =
|
||||
feedback.success(
|
||||
`${productSyncResults.value.length} ${productCategoryLabel.value} پیدا شد` +
|
||||
(linked ? ` (${linked} قبلاً وارد شده)` : '');
|
||||
(linked ? ` (${linked} قبلاً وارد شده)` : ''),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'دریافت لیست کارساخته ناموفق');
|
||||
feedback.fromError(e, 'دریافت لیست کارساخته ناموفق');
|
||||
} finally {
|
||||
productSyncBusy.value = false;
|
||||
}
|
||||
@@ -819,21 +803,20 @@ async function searchProducts() {
|
||||
|
||||
async function importProductOne(name: string) {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
productSyncBusy.value = true;
|
||||
const { data } = await api.post<{ productId: string }>(
|
||||
'/integrations/tahesab/sync/products/import',
|
||||
{ connectionId: productSync.connectionId, name },
|
||||
);
|
||||
ok.value = `وارد شد — در محصولات با شناسه ${data.productId}`;
|
||||
feedback.success(`وارد شد — در محصولات با شناسه ${data.productId}`);
|
||||
const row = productSyncResults.value.find((r) => r.name === name);
|
||||
if (row) {
|
||||
row.alreadyImported = true;
|
||||
row.productId = data.productId;
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'وارد کردن محصول ناموفق');
|
||||
feedback.fromError(e, 'وارد کردن محصول ناموفق');
|
||||
} finally {
|
||||
productSyncBusy.value = false;
|
||||
}
|
||||
@@ -841,7 +824,6 @@ async function importProductOne(name: string) {
|
||||
|
||||
async function importProductsBulk(mode: 'pending' | 'all') {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
if (!productSync.connectionId) {
|
||||
error.value = 'ابتدا اتصال را انتخاب کنید.';
|
||||
return;
|
||||
@@ -875,10 +857,10 @@ async function importProductsBulk(mode: 'pending' | 'all') {
|
||||
skipped: number;
|
||||
failed: number;
|
||||
}>('/integrations/tahesab/sync/products/import-bulk', body, { timeout: 120_000 });
|
||||
ok.value = `وارد شد: ${data.imported} · قبلاً بود: ${data.skipped} · ناموفق: ${data.failed}`;
|
||||
feedback.success(`وارد شد: ${data.imported} · قبلاً بود: ${data.skipped} · ناموفق: ${data.failed}`);
|
||||
await searchProducts();
|
||||
} catch (e) {
|
||||
error.value = apiErr(e, 'وارد کردن دستهای محصولات ناموفق');
|
||||
feedback.fromError(e, 'وارد کردن دستهای محصولات ناموفق');
|
||||
} finally {
|
||||
productSyncBusy.value = false;
|
||||
}
|
||||
@@ -895,7 +877,6 @@ onMounted(load);
|
||||
/>
|
||||
|
||||
<div v-if="error" class="crm-alert crm-alert-danger">{{ error }}</div>
|
||||
<div v-if="ok" class="crm-alert crm-alert-success">{{ ok }}</div>
|
||||
|
||||
<div
|
||||
v-if="items.some((r) => !r.allowInsecureTls && isTlsError(r.lastError))"
|
||||
|
||||
@@ -7,6 +7,7 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { UiDropdownMenu, UiModal, UiPagination } from '@/components/ui';
|
||||
@@ -35,6 +36,8 @@ import {
|
||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||
import TeamsSettingsPanel from '@/components/TeamsSettingsPanel.vue';
|
||||
import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { TeamOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
type TabKey = 'users' | 'roles' | 'access' | 'teams';
|
||||
type RoleColor = 'teal' | 'violet' | 'rose' | 'sky' | 'amber' | 'slate' | 'pink';
|
||||
@@ -54,6 +57,7 @@ const ROLE_COLOR_OPTIONS: Array<{ value: RoleColor; label: string }> = [
|
||||
const auth = useAuthStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const feedback = useFeedback();
|
||||
|
||||
/** مجوزی که ماژولش در سوپرادمین خاموش است در نقشها نشان داده نمیشود. */
|
||||
const PERMISSION_MODULES: Partial<Record<RolePermissionKey, OrgModuleKey[]>> = {
|
||||
@@ -92,7 +96,6 @@ const PERMISSION_MODULES: Partial<Record<RolePermissionKey, OrgModuleKey[]>> = {
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const users = ref<OrgUserDto[]>([]);
|
||||
const roles = ref<OrgRoleDto[]>([]);
|
||||
const org = ref<OrganizationDto | null>(null);
|
||||
@@ -351,14 +354,15 @@ async function switchViewAs(targetUserId: string) {
|
||||
if (viewAsBusy.value) return;
|
||||
viewAsBusy.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await auth.viewAs(targetUserId);
|
||||
ok.value = auth.user?.viewAs
|
||||
feedback.success(
|
||||
auth.user?.viewAs
|
||||
? `در حال مشاهده بهجای ${auth.user.fullName}`
|
||||
: 'به حساب خودتان برگشتید.';
|
||||
: 'به حساب خودتان برگشتید.',
|
||||
);
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'تغییر حالت مشاهده ناموفق بود.');
|
||||
feedback.fromError(e, 'تغییر حالت مشاهده ناموفق بود.');
|
||||
} finally {
|
||||
viewAsBusy.value = false;
|
||||
}
|
||||
@@ -374,14 +378,6 @@ function formatLastLogin(iso: string | null | undefined) {
|
||||
return formatJalaliNumeric(d);
|
||||
}
|
||||
|
||||
function apiError(e: unknown, fallback: string) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
return Array.isArray(msg) ? msg.join('، ') : (msg ?? fallback);
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
async function loadAvatars(ids: Array<{ id: string; hasAvatar?: boolean }>) {
|
||||
await Promise.all(
|
||||
ids
|
||||
@@ -442,7 +438,6 @@ async function saveOrg() {
|
||||
}
|
||||
orgSaving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const payload: UpdateOrganizationRequest = {
|
||||
name: orgName.value.trim(),
|
||||
@@ -452,9 +447,9 @@ async function saveOrg() {
|
||||
org.value = data;
|
||||
orgName.value = data.name;
|
||||
businessField.value = data.businessField ?? '';
|
||||
ok.value = 'مشخصات سازمان ذخیره شد.';
|
||||
feedback.success('مشخصات سازمان ذخیره شد.');
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره سازمان ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره سازمان ناموفق بود');
|
||||
} finally {
|
||||
orgSaving.value = false;
|
||||
}
|
||||
@@ -492,10 +487,10 @@ async function submitInvite() {
|
||||
};
|
||||
await api.post('/users', payload);
|
||||
inviteOpen.value = false;
|
||||
ok.value = 'کاربر به این محیط اضافه شد.';
|
||||
feedback.success('کاربر به این محیط اضافه شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'افزودن کاربر ناموفق بود');
|
||||
feedback.fromError(e, 'افزودن کاربر ناموفق بود');
|
||||
} finally {
|
||||
inviteSaving.value = false;
|
||||
}
|
||||
@@ -513,7 +508,6 @@ function openEditUser(user: OrgUserDto) {
|
||||
editRoleLocked.value = user.role === 'owner';
|
||||
editOpen.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
}
|
||||
|
||||
async function submitEditUser() {
|
||||
@@ -539,10 +533,10 @@ async function submitEditUser() {
|
||||
await api.patch(`/users/${editUserId.value}/role`, { orgRoleId: editRoleId.value });
|
||||
}
|
||||
editOpen.value = false;
|
||||
ok.value = 'مشخصات کاربر ذخیره شد.';
|
||||
feedback.success('مشخصات کاربر ذخیره شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ویرایش کاربر ناموفق بود');
|
||||
feedback.fromError(e, 'ویرایش کاربر ناموفق بود');
|
||||
} finally {
|
||||
editSaving.value = false;
|
||||
}
|
||||
@@ -553,9 +547,12 @@ async function toggleStatus(user: OrgUserDto) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.patch(`/users/${user.id}/status`, { isActive: user.isActive === false });
|
||||
feedback.success(
|
||||
user.isActive === false ? 'کاربر فعال شد.' : 'کاربر غیرفعال شد.',
|
||||
);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'تغییر وضعیت ناموفق بود');
|
||||
feedback.fromError(e, 'تغییر وضعیت ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,16 +563,17 @@ async function toggleLoginOtpOnly(user: OrgUserDto) {
|
||||
menuUserId.value = null;
|
||||
if (user.role === 'owner') return;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const next = !user.loginOtpOnly;
|
||||
await api.patch(`/users/${user.id}/login-otp-only`, { loginOtpOnly: next });
|
||||
ok.value = next
|
||||
feedback.success(
|
||||
next
|
||||
? `«${user.fullName}» فقط با کد پیامکی وارد میشود.`
|
||||
: `ورود با رمز برای «${user.fullName}» دوباره فعال شد.`;
|
||||
: `ورود با رمز برای «${user.fullName}» دوباره فعال شد.`,
|
||||
);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'تغییر شیوهٔ ورود ناموفق بود');
|
||||
feedback.fromError(e, 'تغییر شیوهٔ ورود ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,17 +593,18 @@ async function changeLogoutTime(user: OrgUserDto, raw: string) {
|
||||
return;
|
||||
}
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
logoutSaving.value = true;
|
||||
try {
|
||||
await api.patch(`/users/${user.id}/logout-time`, { logoutTime: next || null });
|
||||
ok.value = next
|
||||
feedback.success(
|
||||
next
|
||||
? `ساعت خروج «${user.fullName}» روی ${toFaDigits(next)} تنظیم شد.`
|
||||
: `محدودیت خروج «${user.fullName}» برداشته شد.`;
|
||||
: `محدودیت خروج «${user.fullName}» برداشته شد.`,
|
||||
);
|
||||
logoutModal.value = null;
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره ساعت خروج ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره ساعت خروج ناموفق بود');
|
||||
} finally {
|
||||
logoutSaving.value = false;
|
||||
}
|
||||
@@ -615,18 +614,19 @@ async function toggleBlockAfterLogout(user: OrgUserDto) {
|
||||
if (!canSetLogoutTime.value || user.role === 'owner' || !user.logoutTime) return;
|
||||
const next = !user.blockLoginAfterLogout;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.patch(`/users/${user.id}/logout-time`, {
|
||||
logoutTime: user.logoutTime,
|
||||
blockLoginAfterLogout: next,
|
||||
});
|
||||
ok.value = next
|
||||
feedback.success(
|
||||
next
|
||||
? `«${user.fullName}» بعد از ساعت ${toFaDigits(user.logoutTime)} دیگر نمیتواند وارد شود.`
|
||||
: `«${user.fullName}» بعد از ساعت خروج هم میتواند وارد شود.`;
|
||||
: `«${user.fullName}» بعد از ساعت خروج هم میتواند وارد شود.`,
|
||||
);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'تغییر محدودیت ورود ناموفق بود');
|
||||
feedback.fromError(e, 'تغییر محدودیت ورود ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,13 +635,12 @@ async function changeCommission(user: OrgUserDto, raw: string) {
|
||||
const next = Number(raw);
|
||||
if (!Number.isFinite(next) || next === Number(user.commissionPercent ?? 0)) return;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.patch(`/users/${user.id}/commission`, { commissionPercent: next });
|
||||
ok.value = `پورسانت «${user.fullName}» ذخیره شد.`;
|
||||
feedback.success(`پورسانت «${user.fullName}» ذخیره شد.`);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره پورسانت ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره پورسانت ناموفق بود');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,10 +775,10 @@ async function submitRoleForm() {
|
||||
selectedRoleId.value = data.id;
|
||||
}
|
||||
roleFormOpen.value = false;
|
||||
ok.value = roleFormId.value ? 'نقش بهروز شد.' : 'نقش جدید ساخته شد.';
|
||||
feedback.success(roleFormId.value ? 'نقش بهروز شد.' : 'نقش جدید ساخته شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره نقش ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره نقش ناموفق بود');
|
||||
} finally {
|
||||
roleFormSaving.value = false;
|
||||
}
|
||||
@@ -794,10 +793,10 @@ async function confirmDeleteRole() {
|
||||
await api.delete(`/org-roles/${role.id}`);
|
||||
deleteOpen.value = false;
|
||||
selectedRoleId.value = null;
|
||||
ok.value = 'نقش حذف شد.';
|
||||
feedback.success('نقش حذف شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'حذف نقش ناموفق بود');
|
||||
feedback.fromError(e, 'حذف نقش ناموفق بود');
|
||||
} finally {
|
||||
deleteSaving.value = false;
|
||||
}
|
||||
@@ -812,8 +811,9 @@ async function toggleAccess(role: OrgRoleDto, key: RolePermissionKey) {
|
||||
error.value = '';
|
||||
try {
|
||||
await api.patch(`/org-roles/${role.id}`, { permissions: next });
|
||||
feedback.success('دسترسی نقش ذخیره شد.');
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره دسترسی ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره دسترسی ناموفق بود');
|
||||
await load();
|
||||
} finally {
|
||||
accessSaving.value = false;
|
||||
@@ -854,11 +854,11 @@ async function saveFocusDataAccess() {
|
||||
const dataAccessPolicy = withOpenSections(focusDataAccess.value);
|
||||
focusDataAccess.value = dataAccessPolicy;
|
||||
await api.patch(`/org-roles/${role.id}`, { dataAccessPolicy });
|
||||
ok.value = `محدوده داده برای نقش «${role.name}» ذخیره شد.`;
|
||||
feedback.success(`محدوده داده برای نقش «${role.name}» ذخیره شد.`);
|
||||
await load();
|
||||
syncFocusDataAccess();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'ذخیره محدوده داده ناموفق بود');
|
||||
feedback.fromError(e, 'ذخیره محدوده داده ناموفق بود');
|
||||
} finally {
|
||||
accessSaving.value = false;
|
||||
}
|
||||
@@ -924,34 +924,21 @@ onUnmounted(() => {
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<header class="page-head">
|
||||
<div class="head-copy">
|
||||
<h1>
|
||||
<span class="title-ico"><UiIcon name="users" :size="22" /></span>
|
||||
مدیریت کاربران
|
||||
</h1>
|
||||
<p class="lead">کاربران سامانه را مدیریت کنید و نقشهای مختلف را برای آنها تعریف کنید.</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="tabs" aria-label="بخشهای مدیریت کاربران">
|
||||
<button type="button" :class="{ on: tab === 'users' }" @click="setTab('users')">
|
||||
<span class="tab-full">لیست کاربران</span>
|
||||
<span class="tab-short">کاربران</span>
|
||||
</button>
|
||||
<button type="button" :class="{ on: tab === 'roles' }" @click="setTab('roles')">نقشها</button>
|
||||
<button type="button" :class="{ on: tab === 'teams' }" @click="setTab('teams')">
|
||||
<span class="tab-full">تیمها و سطح دسترسی به پروندهها</span>
|
||||
<span class="tab-short">تیمها و دسترسی</span>
|
||||
</button>
|
||||
<button type="button" :class="{ on: tab === 'access' }" @click="setTab('access')">
|
||||
<span class="tab-full">تنظیمات دسترسی</span>
|
||||
<span class="tab-short">دسترسی</span>
|
||||
</button>
|
||||
</nav>
|
||||
<PageHeader
|
||||
title="مدیریت کاربران"
|
||||
subtitle="کاربران سامانه را مدیریت کنید و نقشهای مختلف را برای آنها تعریف کنید."
|
||||
:icon="TeamOutlined"
|
||||
:tabs="[
|
||||
{ key: 'users', label: isNarrow ? 'کاربران' : 'لیست کاربران', count: users.length || undefined },
|
||||
{ key: 'roles', label: 'نقشها' },
|
||||
{ key: 'teams', label: isNarrow ? 'تیمها و دسترسی' : 'تیمها و سطح دسترسی به پروندهها' },
|
||||
{ key: 'access', label: isNarrow ? 'دسترسی' : 'تنظیمات دسترسی' },
|
||||
]"
|
||||
:active-tab="tab"
|
||||
@update:active-tab="(k) => setTab((k ?? 'users') as TabKey)"
|
||||
/>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="ok" class="ok">{{ ok }}</p>
|
||||
|
||||
<TeamsSettingsPanel
|
||||
v-if="tab === 'teams'"
|
||||
@@ -1700,26 +1687,6 @@ onUnmounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.head-copy {
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 0.35rem;
|
||||
font-size: clamp(1.35rem, 2.2vw, 1.7rem);
|
||||
font-weight: 800;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.title-ico {
|
||||
width: 2.15rem;
|
||||
height: 2.15rem;
|
||||
@@ -1756,41 +1723,6 @@ h1 {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
gap: 1.25rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
scrollbar-width: thin;
|
||||
overscroll-behavior-x: contain;
|
||||
}
|
||||
|
||||
.tabs button {
|
||||
appearance: none;
|
||||
background: none;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -1px;
|
||||
padding: 0.55rem 0.15rem;
|
||||
color: #94a3b8;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tabs button.on {
|
||||
color: #0d9488;
|
||||
border-bottom-color: #14b8a6;
|
||||
}
|
||||
|
||||
.tab-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.stage {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 220px;
|
||||
@@ -2788,19 +2720,6 @@ textarea {
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.tab-full {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab-short {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
gap: 1rem;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
.stage {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-areas: 'list';
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Breadcrumb as ABreadcrumb,
|
||||
BreadcrumbItem as ABreadcrumbItem,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
@@ -22,7 +20,6 @@ import {
|
||||
RadioGroup as ARadioGroup,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Tag as ATag,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
@@ -49,8 +46,10 @@ import type {
|
||||
TicketPriority,
|
||||
TicketStatus,
|
||||
} from '@mento/shared';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { CustomerServiceOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
|
||||
const route = useRoute();
|
||||
@@ -347,30 +346,21 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<a-flex vertical :gap="4">
|
||||
<a-breadcrumb>
|
||||
<a-breadcrumb-item>
|
||||
<RouterLink :to="{ name: 'tickets' }">تیکتها</RouterLink>
|
||||
</a-breadcrumb-item>
|
||||
<a-breadcrumb-item>{{ pageTitle }}</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ pageTitle }}
|
||||
</a-typography-title>
|
||||
</a-flex>
|
||||
<a-space :size="8" wrap>
|
||||
<a-button type="primary" :loading="saving" @click="save">
|
||||
<template #icon><CheckOutlined /></template>
|
||||
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
|
||||
</a-button>
|
||||
<PageHeader
|
||||
:title="pageTitle"
|
||||
subtitle="موضوع، اولویت و پیگیری درخواست مشتری"
|
||||
:icon="CustomerServiceOutlined"
|
||||
:primary-label="saving ? 'در حال ذخیره…' : 'ذخیره'"
|
||||
:primary-icon="CheckOutlined"
|
||||
:primary-loading="saving"
|
||||
:menu-items="isNew ? [] : [{ key: 'delete', label: 'حذف تیکت', icon: DeleteOutlined, danger: true, disabled: saving }]"
|
||||
@primary="save"
|
||||
@menu="remove"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="saving" @click="cancel">انصراف</a-button>
|
||||
<a-button v-if="!isNew" danger :disabled="saving" @click="remove">
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
حذف
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
|
||||
@@ -33,7 +33,9 @@ import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { FilterOutlined, PlusOutlined, SearchOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Link: ATypographyLink } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { CustomerServiceOutlined } from '@/icons/ant-bridge';
|
||||
const { Text: ATypographyText, Link: ATypographyLink } = Typography;
|
||||
|
||||
const TICKET_COL_LABELS = [
|
||||
'موضوع',
|
||||
@@ -211,13 +213,13 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">تیکتها</a-typography-title>
|
||||
<a-button type="primary" @click="goNew">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
تیکت جدید
|
||||
</a-button>
|
||||
</a-flex>
|
||||
<PageHeader
|
||||
title="تیکتها"
|
||||
subtitle="درخواستهای پشتیبانی مشتریان و وضعیت SLA"
|
||||
:icon="CustomerServiceOutlined"
|
||||
primary-label="تیکت جدید"
|
||||
@primary="goNew"
|
||||
/>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-form layout="vertical" @finish="onSearch">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { useFeedback } from '@/composables/useFeedback';
|
||||
import type {
|
||||
CreateWooCommerceConnectionRequest,
|
||||
WooCommerceConnectionDto,
|
||||
@@ -30,8 +31,10 @@ import {
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { CopyOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import { ShoppingOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
const { Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
|
||||
const ORDER_COL_LABELS = [
|
||||
@@ -45,11 +48,11 @@ const ORDER_COL_LABELS = [
|
||||
registerTableColumns('woocommerce.orders', [...ORDER_COL_LABELS]);
|
||||
const orderTableCols = useTableColumns(() => 'woocommerce.orders');
|
||||
|
||||
const feedback = useFeedback();
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const syncing = ref(false);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const items = ref<WooCommerceConnectionDto[]>([]);
|
||||
const orders = ref<WooCommerceOrderLinkDto[]>([]);
|
||||
const lastSync = ref<WooCommerceSyncResultDto | null>(null);
|
||||
@@ -108,7 +111,6 @@ async function create() {
|
||||
}
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const payload: CreateWooCommerceConnectionRequest = {
|
||||
label: form.label.trim() || 'فروشگاه',
|
||||
@@ -122,12 +124,10 @@ async function create() {
|
||||
form.consumerKey = '';
|
||||
form.consumerSecret = '';
|
||||
form.webhookSecret = '';
|
||||
ok.value = 'اتصال ذخیره شد.';
|
||||
feedback.success('اتصال ذخیره شد.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String((e.response?.data as { message?: string })?.message ?? 'ذخیره ناموفق بود.')
|
||||
: 'ذخیره ناموفق بود.';
|
||||
feedback.fromError(e, 'ذخیره ناموفق بود.');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -136,12 +136,10 @@ async function create() {
|
||||
async function test(id: string) {
|
||||
try {
|
||||
await api.post(`/integrations/woocommerce/connections/${id}/test`);
|
||||
ok.value = 'اتصال به فروشگاه موفق بود.';
|
||||
feedback.success('اتصال به فروشگاه موفق بود.');
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String((e.response?.data as { message?: string })?.message ?? 'تست ناموفق بود.')
|
||||
: 'تست ناموفق بود.';
|
||||
feedback.fromError(e, 'تست ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,12 +151,12 @@ async function sync(id: string) {
|
||||
`/integrations/woocommerce/connections/${id}/sync`,
|
||||
);
|
||||
lastSync.value = data;
|
||||
ok.value = `همگامسازی: ${toFaDigits(data.created)} جدید، ${toFaDigits(data.updated)} بهروز.`;
|
||||
feedback.success(
|
||||
`همگامسازی: ${toFaDigits(data.created)} جدید، ${toFaDigits(data.updated)} بهروز.`,
|
||||
);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String((e.response?.data as { message?: string })?.message ?? 'همگامسازی ناموفق بود.')
|
||||
: 'همگامسازی ناموفق بود.';
|
||||
feedback.fromError(e, 'همگامسازی ناموفق بود.');
|
||||
} finally {
|
||||
syncing.value = false;
|
||||
}
|
||||
@@ -170,9 +168,10 @@ async function remove(id: string) {
|
||||
}
|
||||
try {
|
||||
await api.delete(`/integrations/woocommerce/connections/${id}`);
|
||||
feedback.success('اتصال حذف شد.');
|
||||
await load();
|
||||
} catch {
|
||||
error.value = 'حذف ناموفق بود.';
|
||||
} catch (e) {
|
||||
feedback.fromError(e, 'حذف ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,9 +179,9 @@ async function copyWebhook() {
|
||||
if (!webhookUrl.value) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(webhookUrl.value);
|
||||
ok.value = 'آدرس وبهوک کپی شد.';
|
||||
feedback.success('آدرس وبهوک کپی شد.');
|
||||
} catch {
|
||||
error.value = 'کپی ممکن نشد.';
|
||||
feedback.error('کپی ممکن نشد.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,16 +192,19 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">ووکامرس</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<PageHeader
|
||||
title="ووکامرس"
|
||||
subtitle="اتصال فروشگاه ووکامرس و دریافت سفارشها با وبهوک"
|
||||
:icon="ShoppingOutlined"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button :disabled="loading" aria-label="بروزرسانی" title="بروزرسانی" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
|
||||
@@ -2,7 +2,19 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import type { GamificationReportDto } from '@mento/shared';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { Alert as AAlert, Flex as AFlex } from 'ant-design-vue';
|
||||
import {
|
||||
BarChartOutlined,
|
||||
CheckOutlined,
|
||||
EditOutlined,
|
||||
GiftOutlined,
|
||||
SettingOutlined,
|
||||
SlidersOutlined,
|
||||
StarOutlined,
|
||||
TrophyOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderTab } from '@/components/page';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { api } from '@/lib/api';
|
||||
import AdminRules from '@/components/gamification/admin/AdminRules.vue';
|
||||
@@ -12,21 +24,20 @@ import AdminAchievements from '@/components/gamification/admin/AdminAchievements
|
||||
import AdminAdjust from '@/components/gamification/admin/AdminAdjust.vue';
|
||||
import AdminSettings from '@/components/gamification/admin/AdminSettings.vue';
|
||||
import AdminReports from '@/components/gamification/admin/AdminReports.vue';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
|
||||
type Tab = 'rules' | 'redemptions' | 'rewards' | 'badges' | 'adjust' | 'settings' | 'reports';
|
||||
const TABS: Array<{
|
||||
value: Tab;
|
||||
label: string;
|
||||
icon: 'sliders' | 'check' | 'gift' | 'medal' | 'edit' | 'settings' | 'chart';
|
||||
icon: PageHeaderTab['icon'];
|
||||
}> = [
|
||||
{ value: 'rules', label: 'قوانین امتیاز', icon: 'sliders' },
|
||||
{ value: 'redemptions', label: 'تأییدها', icon: 'check' },
|
||||
{ value: 'rewards', label: 'فروشگاه پاداش', icon: 'gift' },
|
||||
{ value: 'badges', label: 'نشانها و بونوسها', icon: 'medal' },
|
||||
{ value: 'adjust', label: 'تنظیم دستی', icon: 'edit' },
|
||||
{ value: 'reports', label: 'گزارش و ROI', icon: 'chart' },
|
||||
{ value: 'settings', label: 'تنظیمات', icon: 'settings' },
|
||||
{ value: 'rules', label: 'قوانین امتیاز', icon: SlidersOutlined },
|
||||
{ value: 'redemptions', label: 'تأییدها', icon: CheckOutlined },
|
||||
{ value: 'rewards', label: 'فروشگاه پاداش', icon: GiftOutlined },
|
||||
{ value: 'badges', label: 'نشانها و بونوسها', icon: StarOutlined },
|
||||
{ value: 'adjust', label: 'تنظیم دستی', icon: EditOutlined },
|
||||
{ value: 'reports', label: 'گزارش و ROI', icon: BarChartOutlined },
|
||||
{ value: 'settings', label: 'تنظیمات', icon: SettingOutlined },
|
||||
];
|
||||
|
||||
const route = useRoute();
|
||||
@@ -41,6 +52,21 @@ const tab = computed<Tab>(() => {
|
||||
return TABS.some((x) => x.value === t) ? (t as Tab) : 'rules';
|
||||
});
|
||||
|
||||
const headerTabs = computed<PageHeaderTab[]>(() =>
|
||||
TABS.map((t) => ({
|
||||
key: t.value,
|
||||
label: t.label,
|
||||
icon: t.icon,
|
||||
count: t.value === 'redemptions' && pendingCount.value ? pendingCount.value : undefined,
|
||||
tone: t.value === 'redemptions' ? ('warning' as const) : undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
function onHeaderTab(key: string | undefined) {
|
||||
const next = TABS.find((t) => t.value === key)?.value ?? 'rules';
|
||||
setTab(next);
|
||||
}
|
||||
|
||||
function setTab(next: Tab) {
|
||||
void router.replace({ query: { ...route.query, tab: next === 'rules' ? undefined : next } });
|
||||
}
|
||||
@@ -67,31 +93,25 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="crm-page gadmin">
|
||||
<header class="head">
|
||||
<RouterLink to="/club" class="back"><UiIcon name="chevron-right" :size="16" /> باشگاه امتیازات</RouterLink>
|
||||
<h1>مدیریت باشگاه امتیازات</h1>
|
||||
<p>قوانین امتیازدهی، پاداشها، نشانها و درخواستها را از اینجا مدیریت کنید.</p>
|
||||
</header>
|
||||
<a-flex vertical :gap="16">
|
||||
<PageHeader
|
||||
title="مدیریت باشگاه امتیازات"
|
||||
subtitle="قوانین امتیازدهی، پاداشها، نشانها و درخواستها را از اینجا مدیریت کنید."
|
||||
:icon="TrophyOutlined"
|
||||
back-to="/club"
|
||||
:tabs="isAdmin ? headerTabs : undefined"
|
||||
:active-tab="tab"
|
||||
@update:active-tab="onHeaderTab"
|
||||
/>
|
||||
|
||||
<p v-if="!isAdmin" class="denied">این بخش فقط برای مالک و مدیران سازمان در دسترس است.</p>
|
||||
<a-alert
|
||||
v-if="!isAdmin"
|
||||
type="warning"
|
||||
show-icon
|
||||
message="این بخش فقط برای مالک و مدیران سازمان در دسترس است."
|
||||
/>
|
||||
|
||||
<template v-else>
|
||||
<nav class="tabs" aria-label="بخشهای مدیریت باشگاه">
|
||||
<button
|
||||
v-for="t in TABS"
|
||||
:key="t.value"
|
||||
type="button"
|
||||
class="tab"
|
||||
:class="{ on: tab === t.value }"
|
||||
@click="setTab(t.value)"
|
||||
>
|
||||
<UiIcon :name="t.icon" :size="15" />
|
||||
<span>{{ t.label }}</span>
|
||||
<em v-if="t.value === 'redemptions' && pendingCount">{{ toFaDigits(pendingCount) }}</em>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<AdminRules v-if="tab === 'rules'" />
|
||||
<AdminApprovals v-else-if="tab === 'redemptions'" @changed="onChanged" />
|
||||
<AdminRewards v-else-if="tab === 'rewards'" />
|
||||
@@ -100,88 +120,5 @@ onMounted(() => {
|
||||
<AdminReports v-else-if="tab === 'reports'" />
|
||||
<AdminSettings v-else-if="tab === 'settings'" @changed="onChanged" />
|
||||
</template>
|
||||
</section>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.gadmin {
|
||||
gap: var(--sp-4);
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.head {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: var(--accent-deep);
|
||||
font-size: var(--fs-sm);
|
||||
text-decoration: none;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.head h1 {
|
||||
margin: 0;
|
||||
font-size: var(--fs-xl);
|
||||
}
|
||||
|
||||
.head p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.denied {
|
||||
padding: var(--sp-4);
|
||||
border-radius: var(--radius);
|
||||
background: var(--warning-soft);
|
||||
color: var(--warning-deep);
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 2px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.tab {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 9px 12px;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font: inherit;
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tab.on {
|
||||
color: var(--accent-deep);
|
||||
border-bottom-color: var(--accent);
|
||||
}
|
||||
|
||||
.tab em {
|
||||
font-style: normal;
|
||||
font-size: 0.68rem;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--danger);
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -11,9 +11,6 @@ import {
|
||||
Flex as AFlex,
|
||||
Progress as AProgress,
|
||||
Row as ARow,
|
||||
Space as ASpace,
|
||||
TabPane as ATabPane,
|
||||
Tabs as ATabs,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
theme,
|
||||
@@ -42,11 +39,12 @@ import ClubTeams from '@/components/gamification/ClubTeams.vue';
|
||||
import ClubRulesModal from '@/components/gamification/ClubRulesModal.vue';
|
||||
import { CLUB_CTX } from '@/components/gamification/club-context';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderTab } from '@/components/page';
|
||||
|
||||
const {
|
||||
Title: ATypographyTitle,
|
||||
Text: ATypographyText,
|
||||
Paragraph: ATypographyParagraph,
|
||||
} = Typography;
|
||||
|
||||
const { token } = theme.useToken();
|
||||
@@ -77,10 +75,12 @@ function setTab(next: Tab) {
|
||||
void router.replace({ query: { ...route.query, tab: next === 'home' ? undefined : next } });
|
||||
}
|
||||
|
||||
function onTabChange(key: string | number) {
|
||||
setTab(String(key) as Tab);
|
||||
function onTabChange(key: string | number | undefined) {
|
||||
setTab(String(key ?? 'home') as Tab);
|
||||
}
|
||||
|
||||
const headerTabs: PageHeaderTab[] = TABS.map((t) => ({ key: t.value, label: t.label, icon: t.icon }));
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const res = await api.get<GamificationMeDto>('/gamification/me', { params: { period: 'month' } });
|
||||
@@ -177,44 +177,25 @@ watch(
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<!-- هدر صفحه باشگاه هماهنگ با طراحی پنل -->
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<a-flex align="center" :gap="12">
|
||||
<a-avatar
|
||||
:size="44"
|
||||
shape="square"
|
||||
:style="{
|
||||
background: token.colorPrimaryBg,
|
||||
color: token.colorPrimary,
|
||||
borderRadius: `${token.borderRadiusLG}px`,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}"
|
||||
<!-- هدر یکپارچه: عنوان + اکشنها + تبهای بخشهای باشگاه -->
|
||||
<PageHeader
|
||||
title="باشگاه امتیازات"
|
||||
subtitle="سیستم انگیزش، پیشرفت و پاداش تیمی همکاران؛ ثبت فعالیت، رقابت سالم و دریافت پاداش"
|
||||
:icon="TrophyOutlined"
|
||||
:primary-label="me?.isManager ? 'مدیریت باشگاه' : undefined"
|
||||
:primary-icon="SettingOutlined"
|
||||
:tabs="headerTabs"
|
||||
:active-tab="tab"
|
||||
@primary="router.push('/club/admin')"
|
||||
@update:active-tab="onTabChange"
|
||||
>
|
||||
<template #icon><TrophyOutlined :style="{ fontSize: '22px' }" /></template>
|
||||
</a-avatar>
|
||||
<a-flex vertical :gap="2">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
باشگاه امتیازات
|
||||
</a-typography-title>
|
||||
<a-typography-paragraph type="secondary" :style="{ margin: 0 }">
|
||||
سیستم انگیزش، پیشرفت و پاداش تیمی همکاران؛ ثبت فعالیت، رقابت سالم و دریافت پاداش
|
||||
</a-typography-paragraph>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
|
||||
<a-space :size="8">
|
||||
<template #actions>
|
||||
<a-button @click="rulesOpen = true">
|
||||
<template #icon><BulbOutlined /></template>
|
||||
قوانین و نحوه امتیازدهی
|
||||
</a-button>
|
||||
<a-button v-if="me?.isManager" type="primary" @click="router.push('/club/admin')">
|
||||
<template #icon><SettingOutlined /></template>
|
||||
مدیریت باشگاه
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- پیام خطا در صورت وجود -->
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
@@ -475,18 +456,6 @@ watch(
|
||||
</a-card>
|
||||
</CrmSkeleton>
|
||||
|
||||
<!-- تبهای ناوبری بخشهای مختلف باشگاه -->
|
||||
<a-tabs :active-key="tab" @change="onTabChange">
|
||||
<a-tab-pane v-for="t in TABS" :key="t.value">
|
||||
<template #tab>
|
||||
<a-flex align="center" :gap="8">
|
||||
<component :is="t.icon" />
|
||||
<span>{{ t.label }}</span>
|
||||
</a-flex>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
|
||||
<!-- محتوای تب فعال -->
|
||||
<ClubHome v-if="tab === 'home'" @go="setTab" />
|
||||
<ClubHistory v-else-if="tab === 'history'" />
|
||||
|
||||
@@ -5,31 +5,21 @@ import type { RoutineContextDto } from '@mento/shared';
|
||||
import RoutineTaskDrawer from '@/components/routines/RoutineTaskDrawer.vue';
|
||||
import QuickTaskModal from '@/components/routines/QuickTaskModal.vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { formatJalaliShort } from '@/lib/jalali';
|
||||
import { ROUTINES_CTX, apiError } from '@/lib/routines';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
Flex as AFlex,
|
||||
Space as ASpace,
|
||||
TabPane as ATabPane,
|
||||
Tabs as ATabs,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { Alert as AAlert, Button as AButton, Flex as AFlex } from 'ant-design-vue';
|
||||
import {
|
||||
BellOutlined,
|
||||
CalendarOutlined,
|
||||
ControlOutlined,
|
||||
FundOutlined,
|
||||
PlusOutlined,
|
||||
ScheduleOutlined,
|
||||
SyncOutlined,
|
||||
TeamOutlined,
|
||||
WarningOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle } = Typography;
|
||||
import { PageHeader } from '@/components/page';
|
||||
import type { PageHeaderTab } from '@/components/page';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -120,7 +110,20 @@ const activeTab = computed(
|
||||
() => visibleTabs.value.find((t) => tabActive(t))?.name ?? 'routines-today',
|
||||
);
|
||||
|
||||
function onTabChange(key: string | number) {
|
||||
/** تبهای هدر یکپارچه؛ «عقبافتاده» شمارندهٔ هشداری دارد */
|
||||
const headerTabs = computed<PageHeaderTab[]>(() =>
|
||||
visibleTabs.value.map((t) => ({
|
||||
key: t.name,
|
||||
label: t.label,
|
||||
icon: t.icon,
|
||||
count: t.name === 'routines-overdue' && overdueCount.value > 0 ? overdueCount.value : undefined,
|
||||
tone: t.name === 'routines-overdue' ? 'warning' : 'default',
|
||||
})),
|
||||
);
|
||||
|
||||
const todayLabel = formatJalaliShort(new Date());
|
||||
|
||||
function onTabChange(key: string | number | undefined) {
|
||||
const tab = tabs.find((t) => t.name === String(key));
|
||||
if (tab && route.name !== tab.name) {
|
||||
void router.push(tab.to);
|
||||
@@ -132,12 +135,18 @@ const hideHeader = computed(() => route.name === 'routine-new' || route.name ===
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<template v-if="!hideHeader">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">کارهای روتین</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="8" wrap>
|
||||
<PageHeader
|
||||
v-if="!hideHeader"
|
||||
title="کارهای روتین"
|
||||
:subtitle="todayLabel"
|
||||
:icon="SyncOutlined"
|
||||
primary-label="کار جدید"
|
||||
:tabs="headerTabs"
|
||||
:active-tab="activeTab"
|
||||
@primary="quickOpen = true"
|
||||
@update:active-tab="onTabChange"
|
||||
>
|
||||
<template #actions>
|
||||
<a-button
|
||||
aria-label="تنظیمات یادآوری و اعلانها"
|
||||
title="تنظیمات یادآوری و اعلانها"
|
||||
@@ -149,31 +158,8 @@ const hideHeader = computed(() => route.name === 'routine-new' || route.name ===
|
||||
<template #icon><SyncOutlined /></template>
|
||||
روتین جدید
|
||||
</a-button>
|
||||
<a-button type="primary" @click="quickOpen = true">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
کار جدید
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
|
||||
<a-tabs :active-key="activeTab" @change="onTabChange">
|
||||
<a-tab-pane v-for="tab in visibleTabs" :key="tab.name">
|
||||
<template #tab>
|
||||
<a-space :size="6">
|
||||
<component :is="tab.icon" />
|
||||
<span>{{ tab.label }}</span>
|
||||
<a-tag
|
||||
v-if="tab.name === 'routines-overdue' && overdueCount > 0"
|
||||
color="error"
|
||||
:bordered="false"
|
||||
>
|
||||
{{ toFaDigits(overdueCount) }}
|
||||
</a-tag>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<a-alert v-if="contextError" type="error" show-icon :message="contextError" />
|
||||
|
||||
|
||||
+17
-1
@@ -14,7 +14,23 @@ export default defineConfig(({ mode }) => {
|
||||
console.log(`[montact] UI → ${apiTarget}${usingLocalApi ? ' (API لوکال)' : ' (سرور اصلی)'}`);
|
||||
|
||||
return {
|
||||
plugins: [vue(), tailwindcss()],
|
||||
plugins: [
|
||||
vue(),
|
||||
tailwindcss(),
|
||||
{
|
||||
name: 'survive-windows-watcher',
|
||||
configureServer(server) {
|
||||
// On Windows, fs.watch throws EBUSY when a file is locked (brand SVGs,
|
||||
// antivirus). An unhandled watcher "error" kills Vite and the page
|
||||
// stays white because nothing is left to serve a refresh.
|
||||
server.watcher.on('error', (err: NodeJS.ErrnoException) => {
|
||||
console.error(
|
||||
`[vite] watcher ${err?.code || 'error'} ignored: ${err?.message || err}`,
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
|
||||
Generated
+90
@@ -62,6 +62,7 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons-vue": "^7.0.1",
|
||||
"@mento/shared": "*",
|
||||
"@tanstack/vue-query": "^5.108.4",
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"axios": "^1.8.4",
|
||||
"echarts": "^6.1.0",
|
||||
@@ -1450,6 +1451,89 @@
|
||||
"vite": "^5.2.0 || ^6 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/match-sorter-utils": {
|
||||
"version": "9.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/match-sorter-utils/-/match-sorter-utils-9.2.6.tgz",
|
||||
"integrity": "sha512-DIpUSOhPfQ7u/qfUi/Wgm0wBO56MyBYXGvnlI0NcauDRPqdBUlAZZjW2Dxm92m+k1UWVhKw8YJ4f47+75Aujyw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"remove-accents": "0.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/query-core": {
|
||||
"version": "5.108.4",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.108.4.tgz",
|
||||
"integrity": "sha512-2Ks5dlLWz4eXJrthOyG0qW3SLt3xx0RrQmAmN0rnmogiaaOYuWiAe6HAm9KE2b2v8nig+vraNz8fsfZ6fF6zFg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/vue-query": {
|
||||
"version": "5.108.4",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/vue-query/-/vue-query-5.108.4.tgz",
|
||||
"integrity": "sha512-yvvIjGz3g8vxN+CCBFS7HC6o+RtIsMtgTQFbXsxxeNjOro219CT+55peW6APpGlkxU9FZGIVy6KuNgWlL7agnQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/match-sorter-utils": "^9.1.2",
|
||||
"@tanstack/query-core": "5.108.4",
|
||||
"@vue/devtools-api": "^6.6.3",
|
||||
"vue-demi": "^0.14.10"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.1.2",
|
||||
"vue": "^2.6.0 || ^3.3.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/vue-query/node_modules/@vue/devtools-api": {
|
||||
"version": "6.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz",
|
||||
"integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tanstack/vue-query/node_modules/vue-demi": {
|
||||
"version": "0.14.10",
|
||||
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
|
||||
"integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.0-rc.1",
|
||||
"vue": "^3.0.0-0 || ^2.6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@tokenizer/inflate": {
|
||||
"version": "0.4.1",
|
||||
"license": "MIT",
|
||||
@@ -5451,6 +5535,12 @@
|
||||
"version": "0.2.2",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/remove-accents": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.5.0.tgz",
|
||||
"integrity": "sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"dev": true,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
packages:
|
||||
- apps/*
|
||||
- packages/*
|
||||
@@ -1,72 +0,0 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
|
||||
function gitShow(stage, file) {
|
||||
return execFileSync('git', ['show', `${stage}:${file}`], {
|
||||
encoding: 'utf8',
|
||||
maxBuffer: 32 * 1024 * 1024,
|
||||
});
|
||||
}
|
||||
|
||||
/** Extract top-level SFC blocks; nested <template> inside root template is kept intact. */
|
||||
function extractSfc(src) {
|
||||
const scripts = [];
|
||||
const styles = [];
|
||||
let template = null;
|
||||
|
||||
const scriptRe = /<script\b[^>]*>[\s\S]*?<\/script>/gi;
|
||||
let m;
|
||||
while ((m = scriptRe.exec(src))) scripts.push(m[0]);
|
||||
|
||||
const styleRe = /<style\b[^>]*>[\s\S]*?<\/style>/gi;
|
||||
while ((m = styleRe.exec(src))) styles.push(m[0]);
|
||||
|
||||
const start = src.search(/<template\b/i);
|
||||
if (start >= 0) {
|
||||
const end = src.toLowerCase().lastIndexOf('</template>');
|
||||
if (end > start) {
|
||||
template = src.slice(start, end + '</template>'.length);
|
||||
}
|
||||
}
|
||||
|
||||
return { scripts, template, styles };
|
||||
}
|
||||
|
||||
/** Script/logic from main (theirs=:3), template+style from local/dev (ours=:2). */
|
||||
function hybrid(oursSrc, theirsSrc) {
|
||||
const ours = extractSfc(oursSrc);
|
||||
const theirs = extractSfc(theirsSrc);
|
||||
const scripts = theirs.scripts.length ? theirs.scripts : ours.scripts;
|
||||
const template = ours.template || theirs.template;
|
||||
const styles = ours.styles.length ? ours.styles : theirs.styles;
|
||||
return [...scripts, template, ...styles].filter(Boolean).join('\n\n') + '\n';
|
||||
}
|
||||
|
||||
const files = process.argv.slice(2);
|
||||
if (!files.length) {
|
||||
console.error('Usage: node _hybrid-vue-merge.mjs <file>...');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
const ours = gitShow(':2', file);
|
||||
const theirs = gitShow(':3', file);
|
||||
const merged = hybrid(ours, theirs);
|
||||
const check = extractSfc(merged);
|
||||
if (!check.scripts.length || !check.template) {
|
||||
console.error('invalid hybrid result for', file, {
|
||||
scripts: check.scripts.length,
|
||||
hasTemplate: Boolean(check.template),
|
||||
});
|
||||
process.exit(2);
|
||||
}
|
||||
writeFileSync(file, merged, 'utf8');
|
||||
execFileSync('git', ['add', file]);
|
||||
console.log(
|
||||
'hybrid-resolved',
|
||||
file,
|
||||
`scripts=${check.scripts.length}`,
|
||||
`styles=${check.styles.length}`,
|
||||
`tplLen=${check.template.length}`,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user