feat(web): continue Ant settings migration and tighten page chrome

Migrate remaining settings screens to Ant Design Vue, densify teams/roles UI, drop page-header subtitles project-wide, and polish notes cards plus contacts row actions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-04 10:05:28 +03:30
co-authored by Cursor
parent b11affbdfd
commit cb3a488b21
46 changed files with 6024 additions and 7679 deletions
+62 -98
View File
@@ -1,6 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, watch } from 'vue'; import { computed, watch } from 'vue';
import { Select as ASelect } from 'ant-design-vue'; import {
Alert as AAlert,
Card as ACard,
Checkbox as ACheckbox,
Flex as AFlex,
FormItem as AFormItem,
Radio as ARadio,
RadioGroup as ARadioGroup,
Select as ASelect,
Space as ASpace,
Typography,
} from 'ant-design-vue';
import type { import type {
DataAccessOwnerKind, DataAccessOwnerKind,
DataAccessRule, DataAccessRule,
@@ -15,9 +26,12 @@ import {
PERSON_MOODS, PERSON_MOODS,
sectionHasDataAccessLimits, sectionHasDataAccessLimits,
} from '@mento/shared'; } from '@mento/shared';
export type IdOption = { id: string; name: string }; export type IdOption = { id: string; name: string };
type Choice = { value: string; label: string }; type Choice = { value: string; label: string };
const { Text: ATypographyText } = Typography;
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
modelValue: SectionDataAccess; modelValue: SectionDataAccess;
@@ -429,53 +443,59 @@ const filterSummary = computed(() => {
</script> </script>
<template> <template>
<div class="dae" :class="{ compact }"> <a-flex vertical :gap="compact ? 8 : 12">
<div class="dae-mode"> <a-radio-group v-model:value="mode" :disabled="disabled">
<label> <a-flex vertical :gap="4">
<input v-model="mode" type="radio" value="all" :disabled="disabled" /> <a-radio value="all">همهٔ {{ sectionLabel }}</a-radio>
همهٔ {{ sectionLabel }} <a-radio value="rules">محدود با فیلتر</a-radio>
</label> </a-flex>
<label> </a-radio-group>
<input v-model="mode" type="radio" value="rules" :disabled="disabled" />
محدود با فیلتر
</label>
</div>
<template v-if="mode === 'rules'"> <template v-if="mode === 'rules'">
<p class="hint"> <a-typography-text type="secondary">
فقط رکوردهایی دیده می‌شوند که با فقط رکوردهایی دیده می‌شوند که با
<strong>همهٔ فیلترهای پرشده</strong> <strong>همهٔ فیلترهای پرشده</strong>
جور باشند. در هر فهرست، چند انتخاب یعنی هر کدام کافی است. خالی یعنی بدون محدودیت. جور باشند. در هر فهرست، چند انتخاب یعنی هر کدام کافی است. خالی یعنی بدون محدودیت.
</p> </a-typography-text>
<p v-if="hadMultipleRules" class="hint warn"> <a-alert
تنظیم قبلی چندتکه بود؛ اینجا در یک فیلتر ادغام شده. با ذخیره به همین شکل ساده ثبت می‌شود. v-if="hadMultipleRules"
</p> type="warning"
<p class="summary">{{ filterSummary }}</p> show-icon
message="تنظیم قبلی چندتکه بود؛ اینجا در یک فیلتر ادغام شده. با ذخیره به همین شکل ساده ثبت می‌شود."
/>
<a-typography-text strong>{{ filterSummary }}</a-typography-text>
<fieldset :disabled="disabled"> <a-card size="small" title="مالک / مسئول" :bordered="true">
<legend>مالک / مسئول</legend> <a-flex vertical :gap="8">
<p class="muted">خالی = بدون محدودیت مالک</p> <a-typography-text type="secondary">خالی = بدون محدودیت مالک</a-typography-text>
<label class="chip"> <a-space wrap :size="8">
<input <a-checkbox
type="checkbox"
:checked="filter.owners?.includes('self')" :checked="filter.owners?.includes('self')"
:disabled="disabled"
@change="toggleOwner('self')" @change="toggleOwner('self')"
/> >
{{ ownerSelfLabel }} {{ ownerSelfLabel }}
</label> </a-checkbox>
<label class="chip"> <a-checkbox
<input
type="checkbox"
:checked="filter.owners?.includes('team')" :checked="filter.owners?.includes('team')"
:disabled="disabled"
@change="toggleOwner('team')" @change="toggleOwner('team')"
/> >
تیم‌های عضو تیم‌های عضو
</label> </a-checkbox>
</fieldset> </a-space>
</a-flex>
</a-card>
<label v-for="picker in pickers" :key="picker.legend" class="pick"> <a-form-item
<span>{{ picker.legend }}</span> v-for="picker in pickers"
<p v-if="picker.loading" class="muted">در حال بارگذاری منبع‌ها…</p> :key="picker.legend"
:label="picker.legend"
:style="{ marginBottom: 0 }"
>
<a-typography-text v-if="picker.loading" type="secondary">
در حال بارگذاری منبع‌ها…
</a-typography-text>
<a-select <a-select
v-else v-else
:value="pickerValue(picker)" :value="pickerValue(picker)"
@@ -490,70 +510,14 @@ const filterSummary = computed(() => {
style="width: 100%" style="width: 100%"
@update:value="setList(picker.key, $event)" @update:value="setList(picker.key, $event)"
/> />
<p v-if="picker.hint" class="muted">{{ picker.hint }}</p> <a-typography-text v-if="picker.hint" type="secondary">
</label> {{ picker.hint }}
</a-typography-text>
</a-form-item>
</template> </template>
<p v-else-if="!hasLimits" class="hint"> <a-typography-text v-else-if="!hasLimits" type="secondary">
بدون محدودیت — همهٔ {{ sectionLabel }} قابل مشاهده‌اند. بدون محدودیت — همهٔ {{ sectionLabel }} قابل مشاهده‌اند.
</p> </a-typography-text>
</div> </a-flex>
</template> </template>
<style scoped>
.dae {
display: grid;
gap: 0.75rem;
}
.dae-mode {
display: grid;
gap: 0.35rem;
}
.dae-mode label,
.chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
font-size: 0.88rem;
margin-inline-end: 0.55rem;
margin-bottom: 0.25rem;
}
.hint,
.muted,
.summary {
color: #64748b;
font-size: 0.82rem;
margin: 0;
}
.hint.warn {
color: #b45309;
}
.summary {
font-weight: 600;
color: #334155;
}
fieldset {
border: 1px dashed #e2e8f0;
border-radius: 8px;
padding: 0.5rem 0.65rem;
margin: 0;
}
legend {
padding-inline: 0.25rem;
font-size: 0.8rem;
color: #475569;
font-weight: 600;
}
.pick {
display: grid;
gap: 0.35rem;
}
.pick > span {
font-size: 0.8rem;
font-weight: 600;
color: #475569;
}
.compact fieldset {
padding: 0.45rem 0.55rem;
}
</style>
@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import { Tabs as ATabs, TabPane as ATabPane, Typography } from 'ant-design-vue';
import type { import type {
DataAccessPolicy, DataAccessPolicy,
DataAccessSection, DataAccessSection,
@@ -16,6 +17,8 @@ import { api } from '@/lib/api';
import { useCustomerGroups } from '@/lib/customer-groups'; import { useCustomerGroups } from '@/lib/customer-groups';
import DataAccessEditor, { type IdOption } from '@/components/DataAccessEditor.vue'; import DataAccessEditor, { type IdOption } from '@/components/DataAccessEditor.vue';
const { Text: ATypographyText } = Typography;
const props = defineProps<{ const props = defineProps<{
modelValue: DataAccessPolicy; modelValue: DataAccessPolicy;
/** فقط بخش‌هایی که این مجوزها را دارند نشان بده؛ خالی = همه */ /** فقط بخش‌هایی که این مجوزها را دارند نشان بده؛ خالی = همه */
@@ -177,95 +180,35 @@ async function loadOptions() {
onMounted(() => { onMounted(() => {
void loadOptions(); void loadOptions();
}); });
const stagesForActive = computed(() => {
if (active.value === 'leads') return leadStages.value;
if (active.value === 'sales') return dealStages.value;
if (active.value === 'activities') return activityStages.value;
if (active.value === 'projects') return projectStages.value;
return [];
});
const boardsForActive = computed(() => {
if (active.value === 'activities') return activityBoards.value;
if (active.value === 'projects') return projectBoards.value;
return [];
});
const typesForActive = computed(() => {
if (active.value === 'activities') return activityTypes.value;
if (active.value === 'routines') return routineCategories.value;
return [];
});
</script> </script>
<template> <template>
<div class="dap"> <div>
<p v-if="!visibleSections.length" class="muted"> <a-typography-text v-if="!visibleSections.length" type="secondary">
برای تنظیم محدوده، ابتدا مجوز بخش مربوط را روشن کنید. برای تنظیم محدوده، ابتدا مجوز بخش مربوط را روشن کنید.
</p> </a-typography-text>
<template v-else> <a-tabs v-else v-model:activeKey="active">
<div class="tabs" role="tablist"> <a-tab-pane
<button
v-for="s in visibleSections" v-for="s in visibleSections"
:key="s" :key="s"
type="button" :tab="DATA_ACCESS_SECTION_LABELS[s]"
class="tab"
:class="{ on: active === s }"
role="tab"
:aria-selected="active === s"
@click="active = s"
> >
{{ DATA_ACCESS_SECTION_LABELS[s] }}
</button>
</div>
<DataAccessEditor <DataAccessEditor
:key="active" :section="s"
:section="active" :model-value="sectionValue(s)"
:model-value="sectionValue(active)"
:groups="customerGroups" :groups="customerGroups"
:stages="stagesForActive" :stages="s === 'leads' ? leadStages : s === 'sales' ? dealStages : s === 'activities' ? activityStages : s === 'projects' ? projectStages : []"
:pipelines="pipelines" :pipelines="pipelines"
:boards="boardsForActive" :boards="s === 'activities' ? activityBoards : s === 'projects' ? projectBoards : []"
:activity-types="typesForActive" :activity-types="s === 'activities' ? activityTypes : s === 'routines' ? routineCategories : []"
:import-sources="importSources" :import-sources="importSources"
:import-sources-ready="importSourcesReady" :import-sources-ready="importSourcesReady"
:import-sources-failed="importSourcesFailed" :import-sources-failed="importSourcesFailed"
:disabled="disabled" :disabled="disabled"
:compact="compact" :compact="compact"
@update:model-value="setSection(active, $event)" @update:model-value="setSection(s, $event)"
/> />
</template> </a-tab-pane>
</a-tabs>
</div> </div>
</template> </template>
<style scoped>
.dap {
display: grid;
gap: 0.75rem;
}
.tabs {
display: flex;
flex-wrap: wrap;
gap: 0.35rem;
}
.tab {
font: inherit;
border: 1px solid #e2e8f0;
background: #fff;
border-radius: 999px;
padding: 0.3rem 0.7rem;
cursor: pointer;
color: #475569;
}
.tab.on {
border-color: #0f766e;
background: #f0fdfa;
color: #0f766e;
font-weight: 600;
}
.muted {
color: #64748b;
font-size: 0.85rem;
}
</style>
+144
View File
@@ -0,0 +1,144 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { toFaDigits } from '@/lib/jalali';
import type { OrgRoleDto, RolePermissionKey } from '@mento/shared';
import {
Avatar as AAvatar,
Descriptions as ADescriptions,
DescriptionsItem as ADescriptionsItem,
Empty as AEmpty,
Flex as AFlex,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Space as ASpace,
TabPane as ATabPane,
Tabs as ATabs,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import { UserOutlined } from '@ant-design/icons-vue';
const { Text: ATypographyText, Link: ATypographyLink } = Typography;
const emptySimple = AEmpty.PRESENTED_IMAGE_SIMPLE;
const props = defineProps<{
role: OrgRoleDto;
childRoles: OrgRoleDto[];
permissionItems: Array<{ key: RolePermissionKey; label: string }>;
avatarOf: (id: string) => string;
tagColor: (color: string | null | undefined) => string;
}>();
const emit = defineEmits<{
'pick-role': [id: string];
}>();
const innerTab = ref('summary');
watch(
() => props.role.id,
() => {
innerTab.value = 'summary';
},
);
const grantedPermissions = computed(() =>
props.permissionItems.filter((item) => props.role.permissions.includes(item.key)),
);
const permSummary = computed(
() =>
`${toFaDigits(grantedPermissions.value.length)} از ${toFaDigits(props.permissionItems.length)}`,
);
</script>
<template>
<a-flex vertical :gap="16">
<a-space direction="vertical" :size="4">
<a-space wrap>
<a-tag v-if="role.systemKey" :bordered="false">سیستمی</a-tag>
<a-typography-text v-if="role.parentName" type="secondary">
زیرمجموعهٔ
<a-typography-link @click="emit('pick-role', role.parentId!)">
{{ role.parentName }}
</a-typography-link>
</a-typography-text>
</a-space>
<a-typography-text v-if="role.description" type="secondary">
{{ role.description }}
</a-typography-text>
</a-space>
<a-tabs v-model:activeKey="innerTab">
<a-tab-pane key="summary" tab="خلاصه">
<a-flex vertical :gap="16">
<a-descriptions :column="1" bordered>
<a-descriptions-item label="کاربران">
{{ toFaDigits(role.userCount) }} نفر
</a-descriptions-item>
<a-descriptions-item label="مجوزها">
{{ permSummary }}
</a-descriptions-item>
<a-descriptions-item label="زیرنقش‌ها">
{{ toFaDigits(childRoles.length) }} مورد
</a-descriptions-item>
</a-descriptions>
<a-flex vertical :gap="8">
<a-typography-text strong>زیرنقش‌ها</a-typography-text>
<a-space v-if="childRoles.length" wrap>
<a-tag
v-for="child in childRoles"
:key="child.id"
:color="tagColor(child.color)"
:bordered="false"
style="cursor: pointer"
@click="emit('pick-role', child.id)"
>
{{ child.name }} · {{ toFaDigits(child.userCount) }}
</a-tag>
</a-space>
<a-empty v-else description="زیرنقشی تعریف نشده" :image="emptySimple" />
</a-flex>
</a-flex>
</a-tab-pane>
<a-tab-pane key="perms" :tab="`مجوزها (${permSummary})`">
<a-flex vertical :gap="12">
<a-typography-text type="secondary">
فقط مجوزهای فعال نمایش داده می‌شود. برای تغییر، ویرایش نقش را بزنید.
</a-typography-text>
<a-space v-if="grantedPermissions.length" wrap>
<a-tag
v-for="perm in grantedPermissions"
:key="perm.key"
color="success"
:bordered="false"
>
{{ perm.label }}
</a-tag>
</a-space>
<a-empty v-else description="هیچ مجوزی فعال نیست" :image="emptySimple" />
</a-flex>
</a-tab-pane>
<a-tab-pane key="members" :tab="`کاربران (${toFaDigits(role.userCount)})`">
<a-list v-if="role.members.length" :data-source="role.members">
<template #renderItem="{ item }">
<a-list-item>
<a-list-item-meta :title="item.fullName">
<template #avatar>
<a-avatar :src="avatarOf(item.id)">
<template #icon><UserOutlined /></template>
</a-avatar>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
<a-empty v-else description="کاربری با این نقش نیست" :image="emptySimple" />
</a-tab-pane>
</a-tabs>
</a-flex>
</template>
+248 -330
View File
@@ -18,9 +18,36 @@ import {
emptySectionDataAccess, emptySectionDataAccess,
sectionHasDataAccessLimits, sectionHasDataAccessLimits,
} from '@mento/shared'; } from '@mento/shared';
import { UiButton, UiEmptyState, UiField, UiInput } from '@/components/ui';
import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue'; import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue';
import { formatLocalDateInput, parseLocalInput, toFaDigits } from '@/lib/jalali'; import { formatLocalDateInput, parseLocalInput, toFaDigits } from '@/lib/jalali';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Checkbox as ACheckbox,
Col as ACol,
Collapse as ACollapse,
CollapsePanel as ACollapsePanel,
Divider as ADivider,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Radio as ARadio,
RadioGroup as ARadioGroup,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Tag as ATag,
Typography,
} from 'ant-design-vue';
const { Text: ATypographyText } = Typography;
const props = defineProps<{ const props = defineProps<{
users: OrgUserDto[]; users: OrgUserDto[];
@@ -36,7 +63,7 @@ const showPriorArchive = computed(
const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false)); const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false));
const selectedPriorUsers = computed(() => priorUsers.value.filter((u) => u.priorArchiveEnabled)); const selectedPriorUsers = computed(() => priorUsers.value.filter((u) => u.priorArchiveEnabled));
const priorSearch = ref(''); const priorSearch = ref('');
const priorPick = ref(''); const priorPick = ref<string | undefined>(undefined);
const priorSavingId = ref(''); const priorSavingId = ref('');
const cutoffLocal = ref(''); const cutoffLocal = ref('');
const cutoffSaving = ref(false); const cutoffSaving = ref(false);
@@ -47,10 +74,16 @@ const availablePriorUsers = computed(() => {
return priorUsers.value.filter((u) => { return priorUsers.value.filter((u) => {
if (u.priorArchiveEnabled) return false; if (u.priorArchiveEnabled) return false;
if (!q) return true; if (!q) return true;
return [u.fullName, u.email, u.mobile].filter(Boolean).some((v) => String(v).toLowerCase().includes(q)); return [u.fullName, u.email, u.mobile]
.filter(Boolean)
.some((v) => String(v).toLowerCase().includes(q));
}); });
}); });
const availablePriorOptions = computed(() =>
availablePriorUsers.value.map((u) => ({ value: u.id, label: u.fullName })),
);
const emit = defineEmits<{ const emit = defineEmits<{
refreshUsers: []; refreshUsers: [];
}>(); }>();
@@ -73,9 +106,14 @@ const editableUsers = computed(() =>
props.users.filter((u) => u.isActive !== false && u.role !== 'owner' && u.role !== 'admin'), props.users.filter((u) => u.isActive !== false && u.role !== 'owner' && u.role !== 'admin'),
); );
const memberRoleOptions = [
{ value: 'member', label: 'عضو' },
{ value: 'manager', label: 'سرپرست' },
];
async function setPriorArchive(userId: string, enabled: boolean) { async function setPriorArchive(userId: string, enabled: boolean) {
priorSavingId.value = userId; priorSavingId.value = userId;
priorPick.value = ''; priorPick.value = undefined;
error.value = ''; error.value = '';
ok.value = ''; ok.value = '';
try { try {
@@ -113,7 +151,10 @@ async function loadPriorArchiveCutoff() {
applyCutoffFromOrg(data); applyCutoffFromOrg(data);
} catch (e) { } catch (e) {
error.value = axios.isAxiosError(e) error.value = axios.isAxiosError(e)
? String((e.response?.data as { message?: string })?.message ?? 'بارگذاری تاریخ بایگانی ناموفق بود.') ? String(
(e.response?.data as { message?: string })?.message ??
'بارگذاری تاریخ بایگانی ناموفق بود.',
)
: 'بارگذاری تاریخ بایگانی ناموفق بود.'; : 'بارگذاری تاریخ بایگانی ناموفق بود.';
} finally { } finally {
cutoffLoading.value = false; cutoffLoading.value = false;
@@ -135,7 +176,10 @@ async function onCutoffChange(value: string) {
await auth.hydrate(); await auth.hydrate();
} catch (e) { } catch (e) {
error.value = axios.isAxiosError(e) error.value = axios.isAxiosError(e)
? String((e.response?.data as { message?: string })?.message ?? 'ذخیره تاریخ بایگانی ناموفق بود.') ? String(
(e.response?.data as { message?: string })?.message ??
'ذخیره تاریخ بایگانی ناموفق بود.',
)
: 'ذخیره تاریخ بایگانی ناموفق بود.'; : 'ذخیره تاریخ بایگانی ناموفق بود.';
await loadPriorArchiveCutoff(); await loadPriorArchiveCutoff();
} finally { } finally {
@@ -143,9 +187,10 @@ async function onCutoffChange(value: string) {
} }
} }
function pickPriorUser(userId: string) { function pickPriorUser(userId: unknown) {
if (!userId) return; const id = userId == null ? '' : String(userId);
void setPriorArchive(userId, true); if (!id) return;
void setPriorArchive(id, true);
} }
async function load() { async function load() {
@@ -242,9 +287,12 @@ function toggleMember(userId: string) {
} }
} }
function setRole(userId: string, role: TeamMemberRole) { function setRole(userId: string, role: unknown) {
if (!memberDraft.value[userId]) return; if (!memberDraft.value[userId]) return;
memberDraft.value = { ...memberDraft.value, [userId]: role }; memberDraft.value = {
...memberDraft.value,
[userId]: String(role) as TeamMemberRole,
};
} }
async function saveMembers() { async function saveMembers() {
@@ -358,47 +406,57 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="teams-panel"> <a-flex vertical :gap="12">
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<p v-if="ok" class="ok">{{ ok }}</p> <a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<section v-if="canEdit" class="card"> <a-card :bordered="false">
<h3>تیم جدید</h3> <a-form v-if="canEdit" layout="vertical" @finish="createTeam">
<div class="row"> <a-divider orientation="right">تیم جدید</a-divider>
<UiField label="نام تیم"> <a-row :gutter="[16, 0]" align="bottom">
<UiInput v-model="newName" placeholder="مثلاً فروش تهران" /> <a-col :xs="24" :md="8">
</UiField> <a-form-item label="نام تیم">
<UiField label="توضیح"> <a-input v-model:value="newName" placeholder="مثلاً فروش تهران" style="width: 100%" />
<UiInput v-model="newDesc" placeholder="اختیاری" /> </a-form-item>
</UiField> </a-col>
<UiButton :loading="saving" @click="createTeam">افزودن</UiButton> <a-col :xs="24" :md="10">
</div> <a-form-item label="توضیح">
</section> <a-input v-model:value="newDesc" placeholder="اختیاری" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="6">
<a-form-item label=" ">
<a-button type="primary" html-type="submit" :loading="saving" block>افزودن</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
<section class="card"> <a-divider orientation="right">تیم‌ها</a-divider>
<h3>تیم‌ها</h3> <a-spin :spinning="loading">
<UiEmptyState <a-empty
v-if="!loading && !teams.length" v-if="!loading && !teams.length"
title="تیمی تعریف نشده" description="تیمی تعریف نشده. تیم بسازید تا اعضای فروش پرونده‌های هم‌تیمی را ببینند."
description="تیم بسازید تا اعضای فروش پرونده‌های هم‌تیمی را ببینند."
/> />
<div v-else class="team-list"> <a-list v-else item-layout="vertical" :data-source="teams">
<article v-for="t in teams" :key="t.id" class="team"> <template #renderItem="{ item: t }">
<header> <a-list-item>
<div> <template v-if="canEdit" #actions>
<strong>{{ t.name }}</strong> <a-button type="link" @click="startMetaEdit(t)">ویرایش</a-button>
<p class="muted"> <a-button type="link" @click="startEdit(t)">اعضا</a-button>
{{ t.description || '—' }} <a-button type="link" danger @click="removeTeam(t.id)">حذف</a-button>
· {{ toFaDigits(t.memberCount) }} عضو </template>
</p> <a-list-item-meta>
</div> <template #title>
<div v-if="canEdit" class="actions"> <a-space wrap>
<UiButton variant="secondary" @click="startMetaEdit(t)">ویرایش</UiButton> <a-typography-text strong>{{ t.name }}</a-typography-text>
<UiButton variant="secondary" @click="startEdit(t)">اعضا</UiButton> <a-tag :bordered="false">{{ toFaDigits(t.memberCount) }} عضو</a-tag>
<UiButton variant="secondary" @click="removeTeam(t.id)">حذف</UiButton> </a-space>
</div> </template>
</header> <template #description>
<p class="members"> <a-typography-text type="secondary">
{{ t.description || 'بدون توضیح' }}
·
{{ {{
t.members.length t.members.length
? t.members ? t.members
@@ -406,53 +464,77 @@ onMounted(() => {
.join('، ') .join('، ')
: 'بدون عضو' : 'بدون عضو'
}} }}
</p> </a-typography-text>
</template>
</a-list-item-meta>
<div v-if="editingMetaId === t.id" class="editor"> <a-form
<div class="row"> v-if="editingMetaId === t.id"
<UiField label="نام تیم"> layout="vertical"
<UiInput v-model="editName" /> style="width: 100%"
</UiField> @finish="saveMeta"
<UiField label="توضیح"> >
<UiInput v-model="editDesc" /> <a-row :gutter="[16, 0]">
</UiField> <a-col :xs="24" :md="12">
</div> <a-form-item label="نام تیم">
<div class="actions"> <a-input v-model:value="editName" style="width: 100%" />
<UiButton :loading="saving" @click="saveMeta">ذخیره</UiButton> </a-form-item>
<UiButton variant="secondary" @click="editingMetaId = null">انصراف</UiButton> </a-col>
</div> <a-col :xs="24" :md="12">
</div> <a-form-item label="توضیح">
<a-input v-model:value="editDesc" style="width: 100%" />
</a-form-item>
</a-col>
</a-row>
<a-space>
<a-button type="primary" html-type="submit" :loading="saving">ذخیره</a-button>
<a-button @click="editingMetaId = null">انصراف</a-button>
</a-space>
</a-form>
<div v-if="editingId === t.id" class="editor"> <a-flex v-if="editingId === t.id" vertical :gap="8" style="width: 100%">
<p class="hint">اعضا را انتخاب کنید؛ سرپرست همان عضو تیم است.</p> <a-typography-text type="secondary">
<label v-for="u in users.filter((x) => x.isActive !== false)" :key="u.id" class="person"> اعضا را انتخاب کنید؛ سرپرست همان عضو تیم است.
<input </a-typography-text>
type="checkbox" <a-row :gutter="[12, 8]">
<a-col
v-for="u in users.filter((x) => x.isActive !== false)"
:key="u.id"
:xs="24"
:sm="12"
:lg="8"
>
<a-space>
<a-checkbox
:checked="Boolean(memberDraft[u.id])" :checked="Boolean(memberDraft[u.id])"
@change="toggleMember(u.id)" @change="toggleMember(u.id)"
/> >
<span>{{ u.fullName }}</span> {{ u.fullName }}
<select </a-checkbox>
<a-select
v-if="memberDraft[u.id]" v-if="memberDraft[u.id]"
:value="memberDraft[u.id]" :value="memberDraft[u.id]"
@change="setRole(u.id, ($event.target as HTMLSelectElement).value as TeamMemberRole)" :options="memberRoleOptions"
> style="width: 120px"
<option value="member">عضو</option> @update:value="setRole(u.id, $event)"
<option value="manager">سرپرست</option> />
</select> </a-space>
</label> </a-col>
<div class="actions"> </a-row>
<UiButton :loading="saving" @click="saveMembers">ذخیره اعضا</UiButton> <a-space>
<UiButton variant="secondary" @click="editingId = null">انصراف</UiButton> <a-button type="primary" :loading="saving" @click="saveMembers">ذخیره اعضا</a-button>
</div> <a-button @click="editingId = null">انصراف</a-button>
</div> </a-space>
</article> </a-flex>
</div> </a-list-item>
</section> </template>
</a-list>
</a-spin>
<section v-if="showPriorArchive" class="card"> <a-collapse :bordered="false" ghost>
<header class="prior-head"> <a-collapse-panel v-if="showPriorArchive" key="prior" header="بایگانی اطلاعات قبل">
<h3>بایگانی اطلاعات قبل</h3> <a-row :gutter="[16, 12]" align="middle">
<a-col :xs="24" :lg="8">
<JalaliDateInput <JalaliDateInput
:model-value="cutoffLocal" :model-value="cutoffLocal"
mode="date" mode="date"
@@ -460,258 +542,94 @@ onMounted(() => {
:disabled="cutoffSaving || cutoffLoading" :disabled="cutoffSaving || cutoffLoading"
@update:model-value="onCutoffChange" @update:model-value="onCutoffChange"
/> />
</header> </a-col>
<p class="hint"> <a-col :xs="24" :lg="8">
فقط کاربرانی که تیک می‌خورند سوئیچ کار جاری و بایگانی را می‌بینند. بقیهٔ محیط مثل قبل همهٔ <a-input v-model:value="priorSearch" placeholder="جستجوی کاربر…" style="width: 100%" />
رکوردها را مطابق سطح دسترسی خودشان می‌بینند. </a-col>
</p> <a-col :xs="24" :lg="8">
<div class="prior-picker"> <a-select
<UiInput v-model="priorSearch" placeholder="جستجوی کاربر…" /> :value="priorPick"
<select :options="availablePriorOptions"
v-model="priorPick"
:disabled="!availablePriorUsers.length || Boolean(priorSavingId)" :disabled="!availablePriorUsers.length || Boolean(priorSavingId)"
@change="pickPriorUser(($event.target as HTMLSelectElement).value)" allow-clear
> show-search
<option value=""> option-filter-prop="label"
{{ availablePriorUsers.length ? 'انتخاب کاربر برای فعال‌سازی' : 'کاربر دیگری پیدا نشد' }} :placeholder="
</option> availablePriorUsers.length ? 'فعال‌سازی کاربر' : 'کاربر دیگری پیدا نشد'
<option v-for="u in availablePriorUsers" :key="u.id" :value="u.id"> "
{{ u.fullName }} style="width: 100%"
</option> @update:value="pickPriorUser"
</select> />
</div> </a-col>
<div v-if="selectedPriorUsers.length" class="prior-chips"> </a-row>
<span v-for="u in selectedPriorUsers" :key="u.id" class="prior-chip"> <a-flex vertical :gap="8">
{{ u.fullName }} <a-typography-text type="secondary">
<button فقط این کاربران سوئیچ کار جاری / بایگانی را می‌بینند.
type="button" </a-typography-text>
<a-space v-if="selectedPriorUsers.length" wrap>
<a-tag
v-for="u in selectedPriorUsers"
:key="u.id"
closable
:disabled="priorSavingId === u.id" :disabled="priorSavingId === u.id"
:aria-label="`حذف ${u.fullName}`" @close.prevent="setPriorArchive(u.id, false)"
@click="setPriorArchive(u.id, false)"
> >
× {{ u.fullName }}
</button> </a-tag>
</span> </a-space>
</div> <a-typography-text v-else type="secondary">
<p v-else class="hint">هنوز کاربری برای دیدن سوئیچ بایگانی انتخاب نشده است.</p> هنوز کاربری انتخاب نشده است.
</section> </a-typography-text>
</a-flex>
</a-collapse-panel>
<section class="card"> <a-collapse-panel key="access" header="محدوده داده کاربران">
<h3>محدوده داده</h3> <a-flex vertical :gap="8">
<p class="hint"> <a-typography-text type="secondary">
مالک و مدیر همیشه همه را می‌بینند. پیش‌فرض از نقش می‌آید؛ برای کاربر خاص می‌توانید فیلتر پیش‌فرض از نقش است؛ برای کاربر خاص می‌توانید فیلتر جدا بگذارید.
جدا بگذارید. </a-typography-text>
</p> <a-empty
<UiEmptyState
v-if="!editableUsers.length" v-if="!editableUsers.length"
title="کاربر قابل تنظیم نیست"
description="فقط نقش‌های فروش و پشتیبانی محدوده داده جدا دارند." description="فقط نقش‌های فروش و پشتیبانی محدوده داده جدا دارند."
/> />
<div v-else class="vis-table"> <a-list v-else item-layout="vertical" :data-source="editableUsers">
<div v-for="u in editableUsers" :key="u.id" class="vis-user"> <template #renderItem="{ item: u }">
<div class="vis-row"> <a-list-item>
<span> <template v-if="canEdit" #actions>
{{ u.fullName }} <a-button type="link" @click="openAccessEditor(u)">
<small class="vis-badge">{{ accessSummary(u) }}</small> {{ expandedAccess === u.id ? 'بستن' : 'تنظیم' }}
</span> </a-button>
<UiButton v-if="canEdit" variant="secondary" @click="openAccessEditor(u)"> </template>
{{ expandedAccess === u.id ? 'بستن' : 'تنظیم محدوده' }} <a-list-item-meta :description="accessSummary(u)">
</UiButton> <template #title>
</div> <a-typography-text strong>{{ u.fullName }}</a-typography-text>
<div v-if="expandedAccess === u.id" class="vis-scopes"> </template>
<label class="chip-row"> </a-list-item-meta>
<input v-model="accessMode" type="radio" value="inherit" /> <a-flex v-if="expandedAccess === u.id" vertical :gap="8" style="width: 100%">
مثل نقش (بدون override) <a-radio-group v-model:value="accessMode">
</label> <a-space wrap>
<label class="chip-row"> <a-radio value="inherit">مثل نقش</a-radio>
<input v-model="accessMode" type="radio" value="custom" /> <a-radio value="custom">سفارشی</a-radio>
سفارشی برای این کاربر </a-space>
</label> </a-radio-group>
<DataAccessPolicyPanel <DataAccessPolicyPanel
v-if="accessMode === 'custom'" v-if="accessMode === 'custom'"
v-model="draftAccess" v-model="draftAccess"
compact compact
/> />
<div class="actions"> <a-space>
<UiButton :loading="accessSaving" @click="saveUserAccess(u.id)">ذخیره</UiButton> <a-button type="primary" :loading="accessSaving" @click="saveUserAccess(u.id)">
<UiButton variant="secondary" @click="expandedAccess = null">انصراف</UiButton> ذخیره
</div> </a-button>
</div> <a-button @click="expandedAccess = null">انصراف</a-button>
</div> </a-space>
</div> </a-flex>
</section> </a-list-item>
</div> </template>
</a-list>
</a-flex>
</a-collapse-panel>
</a-collapse>
</a-card>
</a-flex>
</template> </template>
<style scoped>
.teams-panel {
display: grid;
gap: 1rem;
}
.card {
background: #fff;
border: 1px solid #eef2f7;
border-radius: var(--radius, 12px);
padding: 1rem;
}
.card h3 {
margin: 0 0 0.75rem;
font-size: 1rem;
}
.prior-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
flex-wrap: wrap;
margin-bottom: 0.75rem;
}
.prior-head h3 {
margin: 0;
}
.prior-head :deep(.trigger) {
min-width: 12rem;
}
.prior-picker {
display: grid;
grid-template-columns: minmax(10rem, 1fr) minmax(13rem, 1fr);
gap: 0.6rem;
margin-top: 0.75rem;
}
.prior-chips {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
margin-top: 0.75rem;
}
.prior-chip {
display: inline-flex;
align-items: center;
gap: 0.35rem;
border: 1px solid #ccfbf1;
border-radius: 999px;
background: #f0fdfa;
color: #0f766e;
padding: 0.25rem 0.6rem;
font-size: 0.85rem;
font-weight: 600;
}
.prior-chip button {
border: 0;
background: transparent;
color: inherit;
cursor: pointer;
font: inherit;
line-height: 1;
padding: 0;
}
.prior-chip button:disabled {
opacity: 0.45;
cursor: wait;
}
.row {
display: grid;
grid-template-columns: 1fr 1fr auto;
gap: 0.75rem;
align-items: end;
}
.team-list {
display: grid;
gap: 0.75rem;
}
.team {
border: 1px solid #eef2f7;
border-radius: var(--radius, 12px);
padding: 0.75rem;
}
.team header {
display: flex;
justify-content: space-between;
gap: 0.75rem;
align-items: start;
}
.actions {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
}
.muted,
.hint,
.members {
color: #64748b;
font-size: 0.85rem;
margin: 0.25rem 0 0;
}
.editor {
margin-top: 0.75rem;
padding-top: 0.75rem;
border-top: 1px solid #eef2f7;
display: grid;
gap: 0.45rem;
}
.person {
display: grid;
grid-template-columns: auto 1fr auto;
gap: 0.5rem;
align-items: center;
padding: 0.35rem 0;
}
.vis-table {
display: grid;
gap: 0.5rem;
}
.vis-user {
border-bottom: 1px solid #f1f5f9;
padding-bottom: 0.45rem;
}
.vis-row {
display: grid;
grid-template-columns: 1fr auto;
gap: 0.75rem;
align-items: center;
padding: 0.45rem 0;
}
.vis-badge {
margin-inline-start: 0.4rem;
padding: 0.1rem 0.45rem;
border-radius: 999px;
background: #eef2ff;
color: #4338ca;
font-size: 0.72rem;
}
.vis-scopes {
display: grid;
gap: 0.55rem;
padding: 0.6rem 0.75rem;
background: #f8fafc;
border-radius: 10px;
}
.chip-row {
display: inline-flex;
align-items: center;
gap: 0.4rem;
font-size: 0.88rem;
}
select {
font: inherit;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 0.4rem 0.55rem;
background: #fff;
}
.error {
color: #b91c1c;
font-weight: 600;
}
.ok {
color: #0f766e;
font-weight: 600;
}
@media (max-width: 800px) {
.row,
.vis-row,
.prior-picker {
grid-template-columns: 1fr;
}
}
</style>
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, type Component } from 'vue'; import { computed, onBeforeUnmount, onMounted, ref, type Component } from 'vue';
import AutomationNode from '@/components/automations/AutomationNode.vue'; import AutomationNode from '@/components/automations/AutomationNode.vue';
import { import {
AUTOMATION_ACTION_LABELS, AUTOMATION_ACTION_LABELS,
@@ -29,6 +29,8 @@ import {
ExpandOutlined, ExpandOutlined,
FilterOutlined, FilterOutlined,
FlagOutlined, FlagOutlined,
FullscreenExitOutlined,
FullscreenOutlined,
GiftOutlined, GiftOutlined,
PlusOutlined, PlusOutlined,
SelectOutlined, SelectOutlined,
@@ -56,8 +58,15 @@ const props = withDefaults(
form?: LeadFormDto | null; form?: LeadFormDto | null;
users?: OrgUserDto[]; users?: OrgUserDto[];
teams?: TeamDto[]; teams?: TeamDto[];
fullscreen?: boolean;
}>(), }>(),
{ chainMode: 'stop', form: null, users: () => [], teams: () => [] }, {
chainMode: 'stop',
form: null,
users: () => [],
teams: () => [],
fullscreen: false,
},
); );
const emit = defineEmits<{ const emit = defineEmits<{
@@ -66,6 +75,7 @@ const emit = defineEmits<{
remove: [id: string]; remove: [id: string];
removeRange: [start: number, end: number]; removeRange: [start: number, end: number];
addBranch: []; addBranch: [];
'update:fullscreen': [value: boolean];
}>(); }>();
const addAt = ref<{ key: string; index: number; allow: AddAllow } | null>(null); const addAt = ref<{ key: string; index: number; allow: AddAllow } | null>(null);
@@ -169,6 +179,21 @@ function onViewportClick() {
addAt.value = null; addAt.value = null;
} }
function onDocPointerDown(e: PointerEvent) {
if (!addAt.value) return;
const target = e.target;
if (!(target instanceof Element)) return;
if (target.closest('.picker') || target.closest('.plus')) return;
addAt.value = null;
}
onMounted(() => {
document.addEventListener('pointerdown', onDocPointerDown, true);
});
onBeforeUnmount(() => {
document.removeEventListener('pointerdown', onDocPointerDown, true);
});
const layout = computed((): { main: LaneItem[]; branches: BranchLane[] } => { const layout = computed((): { main: LaneItem[]; branches: BranchLane[] } => {
const steps = props.steps; const steps = props.steps;
const { prefixEnd, branches } = splitAutomationBranches(steps); const { prefixEnd, branches } = splitAutomationBranches(steps);
@@ -395,6 +420,7 @@ function removeBranch(lane: BranchLane) {
> >
<PlusOutlined :style="{ fontSize: item.end ? '16px' : '14px' }" /> <PlusOutlined :style="{ fontSize: item.end ? '16px' : '14px' }" />
</button> </button>
<Transition name="auto-picker">
<div <div
v-if="addAt?.key === item.key" v-if="addAt?.key === item.key"
class="picker" class="picker"
@@ -431,6 +457,7 @@ function removeBranch(lane: BranchLane) {
</button> </button>
</template> </template>
</div> </div>
</Transition>
</div> </div>
<AutomationNode <AutomationNode
v-else v-else
@@ -474,6 +501,7 @@ function removeBranch(lane: BranchLane) {
> >
<PlusOutlined :style="{ fontSize: '14px' }" /> <PlusOutlined :style="{ fontSize: '14px' }" />
</button> </button>
<Transition name="auto-picker">
<div <div
v-if="addAt?.key === item.key" v-if="addAt?.key === item.key"
class="picker" class="picker"
@@ -510,6 +538,7 @@ function removeBranch(lane: BranchLane) {
</button> </button>
</template> </template>
</div> </div>
</Transition>
</div> </div>
<AutomationNode <AutomationNode
v-else v-else
@@ -582,6 +611,19 @@ function removeBranch(lane: BranchLane) {
<template #icon><ExpandOutlined /></template> <template #icon><ExpandOutlined /></template>
</a-button> </a-button>
</a-tooltip> </a-tooltip>
<a-divider type="vertical" :style="{ height: '20px', margin: 0 }" />
<a-tooltip :title="fullscreen ? 'خروج از تمام‌صفحه' : 'تمام‌صفحه'">
<a-button
type="text"
:class="{ on: fullscreen }"
@click="emit('update:fullscreen', !fullscreen)"
>
<template #icon>
<FullscreenExitOutlined v-if="fullscreen" />
<FullscreenOutlined v-else />
</template>
</a-button>
</a-tooltip>
</a-space> </a-space>
</div> </div>
</div> </div>
@@ -892,6 +934,28 @@ strong {
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16); box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
} }
.auto-picker-enter-active,
.auto-picker-leave-active {
transition:
opacity 0.16s ease,
transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
transform-origin: top center;
will-change: opacity, transform;
pointer-events: none;
}
.auto-picker-enter-from,
.auto-picker-leave-to {
opacity: 0;
transform: translateX(-50%) translateY(6px) scale(0.97);
}
.auto-picker-enter-to,
.auto-picker-leave-from {
opacity: 1;
transform: translateX(-50%) translateY(0) scale(1);
}
.picker-head { .picker-head {
padding: 6px 8px 8px; padding: 6px 8px 8px;
font-size: 11px; font-size: 11px;
@@ -9,8 +9,31 @@ import type {
} from '@mento/shared'; } from '@mento/shared';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { UiButton, UiField, UiSelect } from '@/components/ui'; import {
import UiIcon from '@/components/UiIcon.vue'; Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Descriptions as ADescriptions,
DescriptionsItem as ADescriptionsItem,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Steps as ASteps,
Step as AStep,
Typography,
} from 'ant-design-vue';
import {
AppstoreOutlined,
AimOutlined,
CheckCircleOutlined,
} from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } = Typography;
type Step = 'target' | 'map' | 'review'; type Step = 'target' | 'map' | 'review';
@@ -31,10 +54,23 @@ const stageMap = ref<Record<string, string>>({});
const busy = ref(false); const busy = ref(false);
const error = ref(''); const error = ref('');
const stepIndex = computed(() => {
if (step.value === 'target') return 0;
if (step.value === 'map') return 1;
return 2;
});
const selectedTarget = computed( const selectedTarget = computed(
() => preview.value?.targets.find((target) => target.id === targetId.value) ?? null, () => preview.value?.targets.find((target) => target.id === targetId.value) ?? null,
); );
const targetOptions = computed(() =>
(preview.value?.targets ?? []).map((target) => ({
value: target.id,
label: target.name,
})),
);
const canContinueTarget = computed(() => Boolean(targetId.value && selectedTarget.value)); const canContinueTarget = computed(() => Boolean(targetId.value && selectedTarget.value));
const canContinueMap = computed(() => { const canContinueMap = computed(() => {
const current = preview.value; const current = preview.value;
@@ -71,6 +107,13 @@ function compatibleTargets(src: PipelineMergePreviewStageDto) {
}); });
} }
function compatibleOptions(src: PipelineMergePreviewStageDto) {
return compatibleTargets(src).map((stage) => ({
value: stage.id,
label: stage.name,
}));
}
function statusLabel(stage: Pick<PipelineMergePreviewStageDto, 'isWon' | 'isLost'>) { function statusLabel(stage: Pick<PipelineMergePreviewStageDto, 'isWon' | 'isLost'>) {
if (stage.isWon) return 'برد'; if (stage.isWon) return 'برد';
if (stage.isLost) return 'باخت'; if (stage.isLost) return 'باخت';
@@ -171,298 +214,181 @@ watch(targetId, () => {
</script> </script>
<template> <template>
<div class="merge-wizard"> <a-flex vertical :gap="16">
<ol class="steps" aria-label="مراحل ادغام کاریز"> <a-steps :current="stepIndex">
<li :class="{ active: step === 'target', done: step !== 'target' }">۱. مقصد</li> <a-step title="مقصد" />
<li :class="{ active: step === 'map', done: step === 'review' }">۲. نگاشت</li> <a-step title="نگاشت" />
<li :class="{ active: step === 'review' }">۳. بازبینی</li> <a-step title="بازبینی" />
</ol> </a-steps>
<p v-if="busy && !preview" class="muted">در حال آماده‌سازی پیش‌نمایش…</p> <a-spin :spinning="busy && !preview">
<template v-if="preview">
<template v-else-if="preview"> <a-flex v-if="step === 'target'" vertical :gap="16">
<section v-if="step === 'target'" class="step-panel"> <a-flex :gap="8" align="flex-start">
<div class="intro"> <AppstoreOutlined />
<UiIcon name="layers" :size="20" /> <a-flex vertical :gap="4">
<div> <a-typography-title :level="5" :style="{ margin: 0 }">
<h3>کاریز مقصد را انتخاب کنید</h3> کاریز مقصد را انتخاب کنید
<p> </a-typography-title>
<a-typography-text type="secondary">
معاملات و فرم‌های سرنخ از «{{ preview.source.name }}» به کاریز مقصد منتقل می‌شوند. معاملات و فرم‌های سرنخ از «{{ preview.source.name }}» به کاریز مقصد منتقل می‌شوند.
</p> </a-typography-text>
</div> </a-flex>
</div> </a-flex>
<UiField label="کاریز مقصد" required> <a-form layout="vertical">
<UiSelect v-model="targetId" required> <a-form-item label="کاریز مقصد" required>
<option value="" disabled>انتخاب کنید</option> <a-select
<option v-for="target in preview.targets" :key="target.id" :value="target.id"> v-model:value="targetId"
{{ target.name }} :options="targetOptions"
</option> placeholder="انتخاب کنید"
</UiSelect> style="width: 100%"
</UiField> />
</a-form-item>
</a-form>
<div class="summary-grid"> <a-row :gutter="[16, 16]">
<article> <a-col :xs="24" :md="8">
<strong>{{ toFaDigits(preview.dealCount) }}</strong> <a-card :bordered="true">
<span>معامله منتقل می‌شود</span> <a-typography-text strong>{{ toFaDigits(preview.dealCount) }}</a-typography-text>
</article> <br />
<article> <a-typography-text type="secondary">معامله منتقل می‌شود</a-typography-text>
<strong>{{ toFaDigits(preview.leadForms.length) }}</strong> </a-card>
<span>فرم سرنخ به مقصد وصل می‌شود</span> </a-col>
</article> <a-col :xs="24" :md="8">
<article v-if="preview.source.isDefault" class="warn"> <a-card :bordered="true">
<strong>هشدار</strong> <a-typography-text strong>{{ toFaDigits(preview.leadForms.length) }}</a-typography-text>
<span>کاریز مبدا پیش‌فرض است و بعد از ادغام حذف می‌شود.</span> <br />
</article> <a-typography-text type="secondary">فرم سرنخ به مقصد وصل می‌شود</a-typography-text>
</div> </a-card>
</a-col>
<a-col v-if="preview.source.isDefault" :xs="24" :md="8">
<a-alert
type="warning"
show-icon
message="هشدار"
description="کاریز مبدا پیش‌فرض است و بعد از ادغام حذف می‌شود."
/>
</a-col>
</a-row>
<p v-if="selectedTarget?.isDefault" class="note">مقصد انتخاب‌شده کاریز پیش‌فرض است.</p> <a-alert
</section> v-if="selectedTarget?.isDefault"
type="info"
show-icon
message="مقصد انتخاب‌شده کاریز پیش‌فرض است."
/>
</a-flex>
<section v-else-if="step === 'map'" class="step-panel"> <a-flex v-else-if="step === 'map'" vertical :gap="16">
<div class="intro"> <a-flex :gap="8" align="flex-start">
<UiIcon name="target" :size="20" /> <AimOutlined />
<div> <a-flex vertical :gap="4">
<h3>مرحله‌های مبدا را نگاشت کنید</h3> <a-typography-title :level="5" :style="{ margin: 0 }">
<p>هر مرحله فقط به مرحله‌ای با وضعیت سازگار در مقصد وصل می‌شود.</p> مرحله‌های مبدا را نگاشت کنید
</div> </a-typography-title>
</div> <a-typography-text type="secondary">
هر مرحله فقط به مرحله‌ای با وضعیت سازگار در مقصد وصل می‌شود.
</a-typography-text>
</a-flex>
</a-flex>
<div class="map-list"> <a-form layout="vertical">
<article v-for="sourceStage in preview.stages" :key="sourceStage.id" class="map-row"> <a-row
<div class="stage-info"> v-for="sourceStage in preview.stages"
<strong>{{ sourceStage.name }}</strong> :key="sourceStage.id"
<span> :gutter="[16, 0]"
{{ statusLabel(sourceStage) }} · {{ toFaDigits(sourceStage.dealCount) }} معامله align="middle"
</span>
</div>
<UiSelect v-model="stageMap[sourceStage.id]" :error="!stageMap[sourceStage.id]">
<option value="" disabled>مرحله مقصد</option>
<option
v-for="targetStage in compatibleTargets(sourceStage)"
:key="targetStage.id"
:value="targetStage.id"
> >
{{ targetStage.name }} <a-col :xs="24" :md="12">
</option> <a-form-item :style="{ marginBottom: '12px' }">
</UiSelect> <a-typography-text strong>{{ sourceStage.name }}</a-typography-text>
</article> <br />
</div> <a-typography-text type="secondary">
</section> {{ statusLabel(sourceStage) }} · {{ toFaDigits(sourceStage.dealCount) }} معامله
</a-typography-text>
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item
label="مرحله مقصد"
required
:validate-status="stageMap[sourceStage.id] ? undefined : 'error'"
:style="{ marginBottom: '12px' }"
>
<a-select
v-model:value="stageMap[sourceStage.id]"
:options="compatibleOptions(sourceStage)"
placeholder="مرحله مقصد"
style="width: 100%"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-flex>
<section v-else class="step-panel"> <a-flex v-else vertical :gap="16">
<div class="intro"> <a-flex :gap="8" align="flex-start">
<UiIcon name="check" :size="20" /> <CheckCircleOutlined />
<div> <a-flex vertical :gap="4">
<h3>بازبینی نهایی</h3> <a-typography-title :level="5" :style="{ margin: 0 }">بازبینی نهایی</a-typography-title>
<p> <a-typography-paragraph type="secondary" :style="{ margin: 0 }">
«{{ toFaDigits(preview.dealCount) }}» معامله منتقل می‌شود. «{{ toFaDigits(preview.dealCount) }}» معامله منتقل می‌شود.
{{ toFaDigits(preview.leadForms.length) }} فرم سرنخ به مقصد وصل می‌شود. {{ toFaDigits(preview.leadForms.length) }} فرم سرنخ به مقصد وصل می‌شود.
کاریز «{{ preview.source.name }}» حذف می‌شود. کاریز «{{ preview.source.name }}» حذف می‌شود.
</p> </a-typography-paragraph>
</div> </a-flex>
</div> </a-flex>
<dl class="review-list"> <a-descriptions :column="1" size="small" bordered>
<div> <a-descriptions-item label="مبدا">{{ preview.source.name }}</a-descriptions-item>
<dt>مبدا</dt> <a-descriptions-item label="مقصد">{{ selectedTarget?.name }}</a-descriptions-item>
<dd>{{ preview.source.name }}</dd> <a-descriptions-item label="روش فرم‌ها">
</div> همه فرم‌های سرنخ به مقصد وصل می‌شوند.
<div> </a-descriptions-item>
<dt>مقصد</dt> </a-descriptions>
<dd>{{ selectedTarget?.name }}</dd> </a-flex>
</div>
<div>
<dt>روش فرم‌ها</dt>
<dd>همه فرم‌های سرنخ به مقصد وصل می‌شوند.</dd>
</div>
</dl>
</section>
</template> </template>
<p v-else-if="!busy && !error" class="muted"> <a-typography-text v-else-if="!busy && !error" type="secondary">
<template v-if="sourceId">در حال بارگذاری پیش‌نمایش ادغام…</template> <template v-if="sourceId">در حال بارگذاری پیش‌نمایش ادغام…</template>
<template v-else>برای شروع ادغام، از فهرست کاریزها دکمهٔ «ادغام» را بزنید.</template> <template v-else>برای شروع ادغام، از فهرست کاریزها دکمهٔ «ادغام» را بزنید.</template>
</p> </a-typography-text>
</a-spin>
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" />
<div class="actions"> <a-space wrap>
<UiButton variant="ghost" :disabled="busy" @click="emit('close')">بستن</UiButton> <a-button :disabled="busy" @click="emit('close')">بستن</a-button>
<UiButton v-if="step === 'map'" variant="ghost" :disabled="busy" @click="step = 'target'"> <a-button v-if="step === 'map'" :disabled="busy" @click="step = 'target'">قبلی</a-button>
قبلی <a-button v-else-if="step === 'review'" :disabled="busy" @click="step = 'map'">قبلی</a-button>
</UiButton> <a-button
<UiButton v-else-if="step === 'review'" variant="ghost" :disabled="busy" @click="step = 'map'"> v-if="step === 'target'"
قبلی type="primary"
</UiButton> :disabled="!preview || !canContinueTarget"
<UiButton v-if="step === 'target'" :disabled="!preview || !canContinueTarget" @click="nextFromTarget"> @click="nextFromTarget"
>
ادامه ادامه
</UiButton> </a-button>
<UiButton v-else-if="step === 'map'" :disabled="!canContinueMap" @click="nextFromMap"> <a-button
v-else-if="step === 'map'"
type="primary"
:disabled="!canContinueMap"
@click="nextFromMap"
>
بازبینی بازبینی
</UiButton> </a-button>
<UiButton v-else variant="danger" :loading="busy" :disabled="!canContinueMap" @click="submitMerge"> <a-button
v-else
type="primary"
danger
:loading="busy"
:disabled="!canContinueMap"
@click="submitMerge"
>
ادغام و حذف مبدا ادغام و حذف مبدا
</UiButton> </a-button>
</div> </a-space>
</div> </a-flex>
</template> </template>
<style scoped>
.merge-wizard {
display: grid;
gap: 1rem;
}
.steps {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
padding: 0;
margin: 0;
list-style: none;
}
.steps li {
padding: 0.3rem 0.65rem;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
font-size: 0.85rem;
}
.steps li.active {
border-color: var(--accent);
background: var(--accent-soft);
color: var(--accent);
}
.steps li.done {
color: var(--ink);
}
.step-panel {
display: grid;
gap: 1rem;
}
.intro {
display: flex;
gap: 0.65rem;
align-items: flex-start;
}
.intro h3,
.intro p {
margin: 0;
}
.intro h3 {
font-size: 1rem;
}
.intro p {
margin-top: 0.25rem;
color: var(--muted);
line-height: 1.8;
}
.summary-grid {
display: grid;
gap: 0.75rem;
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}
.summary-grid article {
display: grid;
gap: 0.2rem;
padding: 0.75rem;
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--surface-subtle);
}
.summary-grid strong {
color: var(--ink);
}
.summary-grid span,
.muted,
.note {
color: var(--muted);
font-size: 0.9rem;
}
.summary-grid .warn {
border-color: var(--danger);
background: var(--danger-soft);
}
.map-list {
display: grid;
gap: 0.65rem;
}
.map-row {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(12rem, 18rem);
gap: 0.75rem;
align-items: center;
padding: 0.75rem;
border: 1px solid var(--line);
border-radius: var(--radius);
}
.stage-info {
display: grid;
gap: 0.25rem;
}
.stage-info span {
color: var(--muted);
font-size: 0.85rem;
}
.review-list {
display: grid;
gap: 0.65rem;
margin: 0;
}
.review-list div {
display: flex;
justify-content: space-between;
gap: 1rem;
padding-bottom: 0.55rem;
border-bottom: 1px solid var(--line);
}
.review-list dt,
.review-list dd {
margin: 0;
}
.review-list dt {
color: var(--muted);
}
.actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
justify-content: flex-start;
padding-top: 0.75rem;
border-top: 1px solid var(--line);
}
.error {
color: #b91c1c;
margin: 0;
}
@media (max-width: 720px) {
.map-row {
grid-template-columns: 1fr;
}
}
</style>
+1 -10
View File
@@ -23,9 +23,7 @@ withDefaults(
<div class="titles"> <div class="titles">
<h1 v-if="title" class="title">{{ title }}</h1> <h1 v-if="title" class="title">{{ title }}</h1>
<slot v-else name="title" /> <slot v-else name="title" />
<slot name="lead" />
<p v-if="lead || description" class="lead">{{ lead || description }}</p>
<slot v-else name="lead" />
</div> </div>
</div> </div>
@@ -87,13 +85,6 @@ withDefaults(
line-height: var(--lh-tight); line-height: var(--lh-tight);
} }
.lead {
margin: 0;
font-size: var(--fs-sm);
color: var(--muted);
line-height: var(--lh-normal);
}
.actions { .actions {
display: flex; display: flex;
align-items: center; align-items: center;
+93 -59
View File
@@ -1,27 +1,69 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import TableColumnsMenu from '@/components/TableColumnsMenu.vue'; import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
import { RouterLink } from 'vue-router'; import { RouterLink } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { formatJalaliNumeric } from '@/lib/jalali'; import { formatJalaliNumeric } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import type { NoteAttachmentDto, NoteDto, PaginatedResponse } from '@mento/shared'; import type { NoteAttachmentDto, NoteDto, PaginatedResponse } from '@mento/shared';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Empty as AEmpty,
Flex as AFlex,
Spin as ASpin,
Table as ATable,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { DownloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Link: ATypographyLink } = Typography;
type Row = NoteAttachmentDto & { type Row = NoteAttachmentDto & {
noteId: string; noteId: string;
noteTitle: string; noteTitle: string;
}; };
const ATT_COL_LABELS = ['نام فایل', 'یادداشت', 'حجم', 'تاریخ'] as const;
registerTableColumns('attachments', [...ATT_COL_LABELS]);
const tableCols = useTableColumns(() => 'attachments');
const loading = ref(false); const loading = ref(false);
const error = ref(''); const error = ref('');
const items = ref<Row[]>([]); const items = ref<Row[]>([]);
const listEmpty = computed(() => !loading.value && !items.value.length);
const columns = computed<TableColumnsType<Row>>(() => {
const all: TableColumnsType<Row> = [
{ title: 'نام فایل', key: 'نام فایل', dataIndex: 'fileName' },
{ title: 'یادداشت', key: 'یادداشت' },
{ title: 'حجم', key: 'حجم' },
{ title: 'تاریخ', key: 'تاریخ' },
{ title: '', key: 'عملیات', width: 110 },
];
return all.filter((col) => {
const key = String(col.key ?? '');
if (key === 'عملیات') return true;
if (!ATT_COL_LABELS.includes(key as (typeof ATT_COL_LABELS)[number])) return true;
return tableCols.isVisible(key);
});
});
function sizeLabel(bytes: number) { function sizeLabel(bytes: number) {
if (bytes < 1024) return `${bytes} B`; if (bytes < 1024) return `${bytes} B`;
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`; if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
} }
function rowKey(row: Row) {
return `${row.noteId}-${row.id}`;
}
async function load() { async function load() {
loading.value = true; loading.value = true;
error.value = ''; error.value = '';
@@ -62,62 +104,54 @@ onMounted(load);
</script> </script>
<template> <template>
<section class="page" dir="rtl"> <a-flex vertical :gap="16">
<header class="head"> <a-typography-title :level="3" :style="{ margin: 0 }">پیوست‌ها</a-typography-title>
<div>
<h1>پیوست‌ها</h1>
<p class="sub">فایل‌های پیوست‌شده به یادداشت‌ها</p>
</div>
</header>
<p v-if="error" class="error">{{ error }}</p>
<p v-else-if="loading && !items.length" class="muted">در حال بارگذاری…</p>
<p v-else-if="!items.length" class="muted">پیوستی ثبت نشده.</p>
<div v-else class="table-wrap">
<div class="tc-row">
<TableColumnsMenu table-key="attachments" align="end" />
</div>
<table v-table-cols="'attachments'">
<thead>
<tr>
<th>نام فایل</th>
<th>یادداشت</th>
<th>حجم</th>
<th>تاریخ</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="row in items" :key="`${row.noteId}-${row.id}`">
<td>{{ row.fileName }}</td>
<td>
<RouterLink :to="{ name: 'notes' }">
{{ row.noteTitle }}
</RouterLink>
</td>
<td>{{ sizeLabel(row.sizeBytes) }}</td>
<td>{{ formatJalaliNumeric(new Date(row.createdAt)) }}</td>
<td>
<button type="button" @click="download(row)">دانلود</button>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</template>
<style scoped> <a-alert v-if="error" type="error" show-icon :message="error" />
.page { display: grid; gap: 1rem; }
h1 { margin: 0; font-size: 1.25rem; } <a-spin :spinning="loading">
.sub, .muted { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; } <a-card v-if="listEmpty && !error" :bordered="false">
.error { color: var(--danger, #dc2626); font-weight: 600; } <a-empty description="پیوستی ثبت نشده." />
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); } </a-card>
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 0.7rem 0.65rem; border-bottom: 1px solid #eef2f7; text-align: right; } <a-card v-else-if="!error && items.length" :bordered="false">
th { background: #f8fafc; color: #64748b; font-size: 0.82rem; } <a-flex justify="flex-end" :style="{ marginBottom: '12px' }">
a { color: #0f766e; font-weight: 700; } <TableColumnsMenu table-key="attachments" align="end" />
button { </a-flex>
min-height: var(--control-h); border: 1px solid var(--line); border-radius: var(--radius);
padding: 0 0.75rem; background: #fff; cursor: pointer; font: inherit; <a-table
} :columns="columns"
</style> :data-source="items"
:pagination="false"
:row-key="rowKey"
:scroll="{ x: 640 }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'نام فایل'">
{{ (record as Row).fileName }}
</template>
<template v-else-if="column.key === 'یادداشت'">
<RouterLink :to="{ name: 'notes' }" custom v-slot="{ href, navigate }">
<a-typography-link :href="href" @click="navigate">
{{ (record as Row).noteTitle }}
</a-typography-link>
</RouterLink>
</template>
<template v-else-if="column.key === 'حجم'">
{{ sizeLabel((record as Row).sizeBytes) }}
</template>
<template v-else-if="column.key === 'تاریخ'">
{{ formatJalaliNumeric(new Date((record as Row).createdAt)) }}
</template>
<template v-else-if="column.key === 'عملیات'">
<a-button @click="download(record as Row)">
<template #icon><DownloadOutlined /></template>
دانلود
</a-button>
</template>
</template>
</a-table>
</a-card>
</a-spin>
</a-flex>
</template>
+394 -508
View File
@@ -13,21 +13,45 @@ import type {
DeletionArchiveListResponse, DeletionArchiveListResponse,
DeletionRetention, DeletionRetention,
} from '@mento/shared'; } from '@mento/shared';
import { formatClockFa, formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import { import {
UiButton, Alert as AAlert,
UiCard, Button as AButton,
UiEmptyState, Card as ACard,
UiField, Col as ACol,
UiInput, Empty as AEmpty,
UiModal, Flex as AFlex,
UiPageHeader, Form as AForm,
UiPagination, FormItem as AFormItem,
} from '@/components/ui'; Input as AInput,
import UiIcon from '@/components/UiIcon.vue'; Modal as AModal,
import { formatClockFa, formatJalaliNumeric } from '@/lib/jalali'; Pagination as APagination,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Table as ATable,
Tabs as ATabs,
TabPane as ATabPane,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
type LogTab = 'all' | 'creates' | 'edits' | 'deletes' | 'attendance'; type LogTab = 'all' | 'creates' | 'edits' | 'deletes' | 'attendance';
type AttendanceRow = {
id: string;
fullName: string;
kind: 'login' | 'logout' | 'forced_logout';
at: string;
afterHours: boolean;
};
const TABS: Array<{ key: LogTab; label: string; action?: string }> = [ const TABS: Array<{ key: LogTab; label: string; action?: string }> = [
{ key: 'all', label: 'همه' }, { key: 'all', label: 'همه' },
{ key: 'attendance', label: 'ورود و خروج' }, { key: 'attendance', label: 'ورود و خروج' },
@@ -61,6 +85,10 @@ const RETENTION_OPTIONS: Array<{ value: DeletionRetention; label: string }> = [
{ value: 'never', label: 'هرگز' }, { value: 'never', label: 'هرگز' },
]; ];
const AUDIT_COL_LABELS = ['زمان', 'کاربر', 'عملیات', 'موضوع', 'شرح'] as const;
registerTableColumns('audit-logs', [...AUDIT_COL_LABELS]);
const tableCols = useTableColumns(() => 'audit-logs');
const router = useRouter(); const router = useRouter();
const auth = useAuthStore(); const auth = useAuthStore();
const isOwner = computed(() => auth.user?.role === 'owner'); const isOwner = computed(() => auth.user?.role === 'owner');
@@ -84,16 +112,7 @@ const page = ref(1);
const pageSize = usePageSize('audit-logs'); const pageSize = usePageSize('audit-logs');
const data = ref<AuditLogListResponse | null>(null); const data = ref<AuditLogListResponse | null>(null);
const deletions = ref<DeletionArchiveListResponse | null>(null); const deletions = ref<DeletionArchiveListResponse | null>(null);
const attendance = ref<{ const attendance = ref<{ items: AttendanceRow[]; total: number } | null>(null);
items: Array<{
id: string;
fullName: string;
kind: 'login' | 'logout' | 'forced_logout';
at: string;
afterHours: boolean;
}>;
total: number;
} | null>(null);
const retention = ref<DeletionRetention>('never'); const retention = ref<DeletionRetention>('never');
const purgeId = ref<string | null>(null); const purgeId = ref<string | null>(null);
@@ -118,6 +137,72 @@ const purgeItem = computed(
() => deletions.value?.items.find((item) => item.id === purgeId.value) ?? null, () => deletions.value?.items.find((item) => item.id === purgeId.value) ?? null,
); );
const actorOptions = computed(() => [
{ value: '', label: 'همه' },
...actors.value.map((user) => ({ value: user.id, label: user.fullName })),
]);
const auditColumns = computed<TableColumnsType<AuditLogDto>>(() => {
const all: TableColumnsType<AuditLogDto> = [
{ title: 'زمان', key: 'زمان', width: 120 },
{ title: 'کاربر', key: 'کاربر' },
{ title: 'عملیات', key: 'عملیات', width: 110 },
{ title: 'موضوع', key: 'موضوع' },
{ title: 'شرح', key: 'شرح' },
{ title: '', key: 'مشاهده', width: 100 },
];
return all.filter((col) => {
const key = String(col.key ?? '');
if (key === 'مشاهده') return true;
if (!AUDIT_COL_LABELS.includes(key as (typeof AUDIT_COL_LABELS)[number])) return true;
return tableCols.isVisible(key);
});
});
const deletionColumns: TableColumnsType<DeletionArchiveDto> = [
{ title: 'زمان', key: 'زمان', width: 120 },
{ title: 'انجام‌دهنده', key: 'انجام‌دهنده' },
{ title: 'نوع', key: 'نوع' },
{ title: 'عنوان', key: 'عنوان' },
{ title: 'شرح', key: 'شرح' },
{ title: '', key: 'عملیات', width: 220 },
];
const attendanceColumns: TableColumnsType<AttendanceRow> = [
{ title: 'زمان', key: 'زمان', width: 120 },
{ title: 'کاربر', key: 'کاربر' },
{ title: 'رویداد', key: 'رویداد' },
];
const initialLoading = computed(
() => loading.value && !data.value && !deletions.value && !attendance.value,
);
const showAuditEmpty = computed(
() =>
!showingArchive.value &&
!showingAttendance.value &&
!loading.value &&
data.value &&
!data.value.items.length,
);
const showArchiveEmpty = computed(
() =>
showingArchive.value &&
!loading.value &&
deletions.value &&
!deletions.value.items.length,
);
const showAttendanceEmpty = computed(
() =>
showingAttendance.value &&
!loading.value &&
attendance.value &&
!attendance.value.items.length,
);
function entityLabel(entityType: string | null) { function entityLabel(entityType: string | null) {
if (!entityType) return 'مورد'; if (!entityType) return 'مورد';
return ENTITY_LABELS[entityType] ?? 'مورد'; return ENTITY_LABELS[entityType] ?? 'مورد';
@@ -283,9 +368,10 @@ function attendanceLabel(kind: string, afterHours: boolean) {
return 'خروج'; return 'خروج';
} }
function selectTab(next: LogTab) { function selectTab(next: string | number) {
if (tab.value === next) return; const key = String(next) as LogTab;
tab.value = next; if (tab.value === key) return;
tab.value = key;
okMsg.value = ''; okMsg.value = '';
data.value = null; data.value = null;
deletions.value = null; deletions.value = null;
@@ -293,14 +379,16 @@ function selectTab(next: LogTab) {
void load(true); void load(true);
} }
function onPage(next: number) { function onPaginationChange(nextPage: number, nextSize: number) {
page.value = next; const sizeChanged = nextSize !== pageSize.value;
void load(); page.value = nextPage;
} if (sizeChanged) {
pageSize.value = nextSize;
function onPageSize(size: number) { if (page.value !== 1) {
pageSize.value = size; page.value = 1;
if (page.value === 1) void load(); }
}
void load(sizeChanged);
} }
async function saveRetention() { async function saveRetention() {
@@ -350,6 +438,14 @@ async function confirmPurge() {
} }
} }
function formatWhen(iso: string) {
const d = new Date(iso);
return {
clock: formatClockFa(d),
date: formatJalaliNumeric(d),
};
}
onMounted(() => { onMounted(() => {
void loadActors(); void loadActors();
void load(); void load();
@@ -357,503 +453,293 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="audit-page"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="لاگ فعالیت کاربران" <a-typography-title :level="3" :style="{ margin: 0 }">لاگ فعالیت کاربران</a-typography-title>
description="ثبت تغییرات ایجاد، ویرایش و حذف در سامانه" <a-button :disabled="loading" @click="load()">
> <template #icon><ReloadOutlined /></template>
<template #actions>
<UiButton variant="secondary" :disabled="loading" @click="load()">
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<nav class="tabs" aria-label="نوع رویداد"> <a-tabs :active-key="tab" @change="selectTab">
<button <a-tab-pane v-for="item in visibleTabs" :key="item.key" :tab="item.label" />
v-for="item in visibleTabs" </a-tabs>
:key="item.key"
type="button"
:class="{ on: tab === item.key }"
@click="selectTab(item.key)"
>
{{ item.label }}
</button>
</nav>
<UiCard v-if="showingArchive"> <a-card v-if="showingArchive" :bordered="false">
<div class="retention"> <a-form layout="vertical">
<label for="audit-retention">حذف خودکار از این فهرست</label> <a-row :gutter="[16, 0]" align="bottom">
<select id="audit-retention" v-model="retention"> <a-col :xs="24" :md="12">
<option v-for="option in RETENTION_OPTIONS" :key="option.value" :value="option.value"> <a-form-item label="حذف خودکار از این فهرست">
{{ option.label }} <a-select
</option> v-model:value="retention"
</select> :options="RETENTION_OPTIONS"
<UiButton size="sm" :loading="savingRetention" @click="saveRetention">ذخیره</UiButton> style="width: 100%"
</div> />
<p class="hint"> </a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label=" ">
<a-button type="primary" :loading="savingRetention" @click="saveRetention">
ذخیره
</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
<a-typography-text type="secondary">
تا پایان این مدت می‌توان مورد را برگرداند. «هرگز» یعنی فقط با حذف کامل از بین می‌رود. تا پایان این مدت می‌توان مورد را برگرداند. «هرگز» یعنی فقط با حذف کامل از بین می‌رود.
</p> </a-typography-text>
</UiCard> </a-card>
<UiCard class="filters"> <a-card :bordered="false">
<form class="filters-grid" @submit.prevent="load(true)"> <a-form layout="vertical" @finish="load(true)">
<UiField label="جستجو"> <a-row :gutter="[16, 0]">
<UiInput v-model="q" placeholder="نام، عنوان یا شرح تغییر…" /> <a-col :xs="24" :md="12">
</UiField> <a-form-item label="جستجو">
<UiField label="انجام‌دهنده"> <a-input v-model:value="q" placeholder="نام، عنوان یا شرح تغییر…" allow-clear />
<select v-model="actorId" class="actor" @change="load(true)"> </a-form-item>
<option value="">همه</option> </a-col>
<option v-for="user in actors" :key="user.id" :value="user.id">{{ user.fullName }}</option> <a-col :xs="24" :md="8">
</select> <a-form-item label="انجام‌دهنده">
</UiField> <a-select
<div class="filters-actions"> v-model:value="actorId"
<UiButton type="submit" :disabled="loading">اعمال فیلتر</UiButton> :options="actorOptions"
</div> style="width: 100%"
</form> show-search
</UiCard> option-filter-prop="label"
@change="load(true)"
<p v-if="okMsg" class="ok">{{ okMsg }}</p>
<p v-if="error" class="error">{{ error }}</p>
<UiCard v-if="loading && !data && !deletions" title="در حال بارگذاری…">
<p class="muted">لطفاً صبر کنید.</p>
</UiCard>
<UiEmptyState
v-else-if="showingArchive && !loading && deletions && !deletions.items.length"
title="حذفی در این فهرست نیست"
description="حذف‌ها با نام انجام‌دهنده اینجا می‌مانند و تا پایان مدت نگهداری قابل بازگشت‌اند."
/> />
</a-form-item>
</a-col>
<a-col :xs="24" :md="4">
<a-form-item label=" ">
<a-button type="primary" html-type="submit" :disabled="loading" block>
اعمال فیلتر
</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<UiEmptyState <a-alert v-if="okMsg" type="success" show-icon :message="okMsg" closable @close="okMsg = ''" />
v-else-if="showingAttendance && !loading && attendance && !attendance.items.length" <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
title="ورود و خروجی ثبت نشده"
description="با ورود یا خروج کارمندان، اینجا دیده می‌شود." <a-spin :spinning="loading">
<a-card v-if="initialLoading" :bordered="false">
<a-typography-text type="secondary">لطفاً صبر کنید.</a-typography-text>
</a-card>
<a-card v-else-if="showArchiveEmpty" :bordered="false">
<a-empty
description="حذفی در این فهرست نیست. حذف‌ها با نام انجام‌دهنده اینجا می‌مانند و تا پایان مدت نگهداری قابل بازگشت‌اند."
/> />
</a-card>
<UiEmptyState <a-card v-else-if="showAttendanceEmpty" :bordered="false">
v-else-if="!showingArchive && !showingAttendance && !loading && data && !data.items.length" <a-empty description="ورود و خروجی ثبت نشده. با ورود یا خروج کارمندان، اینجا دیده می‌شود." />
title="رویدادی در این بخش نیست" </a-card>
description="با انجام کار در سامانه، ایجاد و ویرایش اینجا دیده می‌شود."
/>
<UiCard v-else-if="showingArchive && deletions?.items.length" title="حذف‌ها"> <a-card v-else-if="showAuditEmpty" :bordered="false">
<div class="table-wrap"> <a-empty description="رویدادی در این بخش نیست. با انجام کار در سامانه، ایجاد و ویرایش اینجا دیده می‌شود." />
<table data-no-rownum> </a-card>
<thead>
<tr> <a-card
<th class="when-col">زمان</th> v-else-if="showingArchive && deletions?.items.length"
<th>انجام‌دهنده</th> title="حذف‌ها"
<th>نوع</th> :bordered="false"
<th>عنوان</th> >
<th>شرح</th> <a-table
<th class="actions"></th> :columns="deletionColumns"
</tr> :data-source="deletions.items"
</thead> :pagination="false"
<tbody> row-key="id"
<tr v-for="item in deletions.items" :key="item.id"> :scroll="{ x: 720 }"
<td class="when" data-label="زمان"> >
<span class="clock">{{ formatClockFa(new Date(item.deletedAt)) }}</span> <template #bodyCell="{ column, record }">
<span>{{ formatJalaliNumeric(new Date(item.deletedAt)) }}</span> <template v-if="column.key === 'زمان'">
</td> <a-flex vertical>
<td data-label="انجام‌دهنده">{{ item.deletedByName || 'سیستم' }}</td> <a-typography-text strong>{{ formatWhen((record as DeletionArchiveDto).deletedAt).clock }}</a-typography-text>
<td data-label="نوع">{{ item.modelLabel }}</td> <a-typography-text type="secondary">
<td data-label="عنوان"> {{ formatWhen((record as DeletionArchiveDto).deletedAt).date }}
<span class="clip" :title="item.label">{{ item.label }}</span> </a-typography-text>
</td> </a-flex>
<td data-label="شرح"> </template>
<span class="clip" :title="deletionStory(item)">{{ deletionStory(item) }}</span> <template v-else-if="column.key === 'انجام‌دهنده'">
</td> {{ (record as DeletionArchiveDto).deletedByName || 'سیستم' }}
<td class="ops" data-label="عملیات"> </template>
<UiButton size="sm" variant="secondary" :disabled="busyId === item.id" @click="restore(item)"> <template v-else-if="column.key === 'نوع'">
{{ (record as DeletionArchiveDto).modelLabel }}
</template>
<template v-else-if="column.key === 'عنوان'">
{{ (record as DeletionArchiveDto).label }}
</template>
<template v-else-if="column.key === 'شرح'">
{{ deletionStory(record as DeletionArchiveDto) }}
</template>
<template v-else-if="column.key === 'عملیات'">
<a-space wrap>
<a-button
:disabled="busyId === (record as DeletionArchiveDto).id"
@click="restore(record as DeletionArchiveDto)"
>
بازگردانی بازگردانی
</UiButton> </a-button>
<UiButton size="sm" variant="danger" :disabled="busyId === item.id" @click="purgeId = item.id"> <a-button
danger
:disabled="busyId === (record as DeletionArchiveDto).id"
@click="purgeId = (record as DeletionArchiveDto).id"
>
حذف کامل حذف کامل
</UiButton> </a-button>
</td> </a-space>
</tr> </template>
</tbody> </template>
</table> </a-table>
</div> <a-flex justify="space-between" align="center" wrap="wrap" :gap="8" :style="{ marginTop: '12px' }">
<UiPagination <a-pagination
:page="page" :current="page"
:total-pages="totalPages" :total="deletions.total"
:total-items="deletions.total"
:page-size="pageSize" :page-size="pageSize"
:page-size-options="PAGE_SIZE_OPTIONS" :show-size-changer="true"
@update:page="onPage" :page-size-options="PAGE_SIZE_OPTIONS.map(String)"
@update:page-size="onPageSize" @change="onPaginationChange"
/> />
</UiCard> <a-typography-text type="secondary">
صفحه {{ toFaDigits(page) }} از {{ toFaDigits(totalPages) }}
</a-typography-text>
</a-flex>
</a-card>
<UiCard v-else-if="showingAttendance && attendance?.items.length" title="ورود و خروج"> <a-card
<div class="table-wrap"> v-else-if="showingAttendance && attendance?.items.length"
<table data-no-rownum> title="ورود و خروج"
<thead> :bordered="false"
<tr> >
<th class="when-col">زمان</th> <a-table
<th>کاربر</th> :columns="attendanceColumns"
<th>رویداد</th> :data-source="attendance.items"
</tr> :pagination="false"
</thead> row-key="id"
<tbody> :scroll="{ x: 480 }"
<tr v-for="item in attendance.items" :key="item.id"> >
<td class="when" data-label="زمان"> <template #bodyCell="{ column, record }">
<span class="clock">{{ formatClockFa(new Date(item.at)) }}</span> <template v-if="column.key === 'زمان'">
<span>{{ formatJalaliNumeric(new Date(item.at)) }}</span> <a-flex vertical>
</td> <a-typography-text strong>
<td data-label="کاربر">{{ item.fullName }}</td> {{ formatWhen((record as AttendanceRow).at).clock }}
<td data-label="رویداد">{{ attendanceLabel(item.kind, item.afterHours) }}</td> </a-typography-text>
</tr> <a-typography-text type="secondary">
</tbody> {{ formatWhen((record as AttendanceRow).at).date }}
</table> </a-typography-text>
</div> </a-flex>
<UiPagination </template>
:page="page" <template v-else-if="column.key === 'کاربر'">
:total-pages="totalPages" {{ (record as AttendanceRow).fullName }}
:total-items="attendance.total" </template>
<template v-else-if="column.key === 'رویداد'">
{{
attendanceLabel(
(record as AttendanceRow).kind,
(record as AttendanceRow).afterHours,
)
}}
</template>
</template>
</a-table>
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8" :style="{ marginTop: '12px' }">
<a-pagination
:current="page"
:total="attendance.total"
:page-size="pageSize" :page-size="pageSize"
:page-size-options="PAGE_SIZE_OPTIONS" :show-size-changer="true"
@update:page="onPage" :page-size-options="PAGE_SIZE_OPTIONS.map(String)"
@update:page-size="onPageSize" @change="onPaginationChange"
/> />
</UiCard> <a-typography-text type="secondary">
صفحه {{ toFaDigits(page) }} از {{ toFaDigits(totalPages) }}
</a-typography-text>
</a-flex>
</a-card>
<UiCard v-else-if="data?.items.length" title="رویدادها"> <a-card v-else-if="data?.items.length" title="رویدادها" :bordered="false">
<div class="tc-row"> <a-flex justify="flex-end" :style="{ marginBottom: '12px' }">
<TableColumnsMenu table-key="audit-logs" align="end" /> <TableColumnsMenu table-key="audit-logs" align="end" />
</div> </a-flex>
<div class="table-wrap"> <a-table
<table :columns="auditColumns"
v-table-cols="'audit-logs'" :data-source="data.items"
data-no-rownum :pagination="false"
:style="{ '--row-start': (page - 1) * pageSize }" row-key="id"
:scroll="{ x: 720 }"
:custom-row="(record: AuditLogDto) => ({
style: recordPath(record) ? { cursor: 'pointer' } : undefined,
onClick: () => openRecord(record),
})"
> >
<thead> <template #bodyCell="{ column, record }">
<tr> <template v-if="column.key === 'زمان'">
<th class="when-col">زمان</th> <a-flex vertical>
<th>کاربر</th> <a-typography-text strong>{{ formatWhen((record as AuditLogDto).createdAt).clock }}</a-typography-text>
<th>عملیات</th> <a-typography-text type="secondary">
<th>موضوع</th> {{ formatWhen((record as AuditLogDto).createdAt).date }}
<th>شرح</th> </a-typography-text>
<th class="actions"></th> </a-flex>
</tr> </template>
</thead> <template v-else-if="column.key === 'کاربر'">
<tbody> {{ (record as AuditLogDto).actor?.fullName ?? '—' }}
<tr </template>
v-for="row in data.items" <template v-else-if="column.key === 'عملیات'">
:key="row.id" <a-tag color="processing" :bordered="false">{{ (record as AuditLogDto).action }}</a-tag>
:class="{ link: !!recordPath(row) }" </template>
@click="openRecord(row)" <template v-else-if="column.key === 'موضوع'">
> {{ rowName(record as AuditLogDto) || entityLabel((record as AuditLogDto).entityType) }}
<td class="when" data-label="زمان"> </template>
<span class="clock">{{ formatClockFa(new Date(row.createdAt)) }}</span> <template v-else-if="column.key === 'شرح'">
<span>{{ formatJalaliNumeric(new Date(row.createdAt)) }}</span> {{ rowStory(record as AuditLogDto) }}
</td> </template>
<td data-label="کاربر">{{ row.actor?.fullName ?? '—' }}</td> <template v-else-if="column.key === 'مشاهده'">
<td data-label="عملیات"> <a-button
<span class="pill">{{ row.action }}</span> v-if="recordPath(record as AuditLogDto)"
</td> type="link"
<td data-label="موضوع"> @click.stop="openRecord(record as AuditLogDto)"
<span class="clip" :title="rowName(row) || entityLabel(row.entityType)">
{{ rowName(row) || entityLabel(row.entityType) }}
</span>
</td>
<td data-label="شرح">
<span class="clip" :title="rowStory(row)">{{ rowStory(row) }}</span>
</td>
<td class="ops">
<button
v-if="recordPath(row)"
type="button"
class="view"
@click.stop="openRecord(row)"
> >
مشاهده مشاهده
</button> </a-button>
</td>
</tr>
</tbody>
</table>
</div>
<UiPagination
:page="page"
:total-pages="totalPages"
:total-items="data.total"
:page-size="pageSize"
:page-size-options="PAGE_SIZE_OPTIONS"
@update:page="onPage"
@update:page-size="onPageSize"
/>
</UiCard>
<UiModal :open="!!purgeItem" title="حذف کامل" @close="purgeId = null">
<p v-if="purgeItem" class="confirm">
«{{ purgeItem.label }}» برای همیشه پاک شود؟ بعد از این دیگر قابل بازگشت نیست.
</p>
<template #footer>
<UiButton variant="ghost" :disabled="!!busyId" @click="purgeId = null">انصراف</UiButton>
<UiButton variant="danger" :loading="!!busyId" @click="confirmPurge">حذف کامل</UiButton>
</template> </template>
</UiModal> </template>
</div> </a-table>
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8" :style="{ marginTop: '12px' }">
<a-pagination
:current="page"
:total="data.total"
:page-size="pageSize"
:show-size-changer="true"
:page-size-options="PAGE_SIZE_OPTIONS.map(String)"
@change="onPaginationChange"
/>
<a-typography-text type="secondary">
صفحه {{ toFaDigits(page) }} از {{ toFaDigits(totalPages) }}
</a-typography-text>
</a-flex>
</a-card>
</a-spin>
<a-modal
:open="!!purgeItem"
title="حذف کامل"
ok-text="حذف کامل"
cancel-text="انصراف"
ok-type="danger"
:confirm-loading="!!busyId"
destroy-on-close
@ok="confirmPurge"
@cancel="purgeId = null"
>
<a-typography-text v-if="purgeItem">
«{{ purgeItem.label }}» برای همیشه پاک شود؟ بعد از این دیگر قابل بازگشت نیست.
</a-typography-text>
</a-modal>
</a-flex>
</template> </template>
<style scoped>
.audit-page {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 1rem;
min-width: 0;
}
.tabs {
display: flex;
width: 100%;
min-width: 0;
overflow-x: auto;
border-bottom: 1px solid #e2e8f0;
}
.tabs button {
flex: 1 1 0;
min-width: 4.5rem;
border: 0;
background: none;
padding: 0.55rem 0.35rem 0.7rem;
color: #64748b;
font: inherit;
font-weight: 700;
cursor: pointer;
box-shadow: inset 0 -2px 0 transparent;
}
.tabs button.on {
color: #0f766e;
box-shadow: inset 0 -2px 0 #14b8a6;
}
.retention {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.6rem;
}
.retention label {
font-weight: 700;
}
.retention select,
.actor {
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
color: #0f172a;
font: inherit;
padding: 0.45rem 0.7rem;
min-width: 0;
max-width: 100%;
}
.retention select {
width: auto;
min-width: 8.5rem;
}
.actor {
width: 100%;
}
.hint,
.muted {
margin: 0.55rem 0 0;
color: #64748b;
font-size: 0.85rem;
}
.filters-grid {
display: flex;
flex-wrap: wrap;
align-items: end;
gap: 0.75rem;
}
.filters-grid :deep(.ui-field) {
flex: 1 1 14rem;
min-width: 0;
}
.filters-grid :deep(.ui-field:nth-child(2)) {
flex: 0 1 16rem;
max-width: 16rem;
}
.filters-actions {
display: flex;
align-items: end;
}
.filters-actions :deep(button) {
min-height: 2.4rem;
}
.ok {
margin: 0;
color: #0f766e;
font-weight: 700;
}
.error {
color: #b91c1c;
margin: 0;
font-weight: 600;
}
.table-wrap {
overflow: auto;
max-width: 100%;
}
table {
width: 100%;
min-width: 46rem;
border-collapse: collapse;
font-size: 0.9rem;
table-layout: fixed;
}
th,
td {
text-align: right;
padding: 0.65rem 0.55rem;
border-bottom: 1px solid #eef2f7;
vertical-align: middle;
}
.when-col,
.when {
width: 6.2rem;
}
.when span {
display: block;
line-height: 1.35;
}
.clock {
font-weight: 800;
}
.actions,
td.ops {
width: 11rem;
text-align: left;
}
.clip {
display: block;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
th {
color: #64748b;
font-weight: 700;
font-size: 0.8rem;
white-space: nowrap;
}
.nowrap {
white-space: nowrap;
}
.detail {
color: #334155;
line-height: 1.7;
}
.pill {
display: inline-flex;
padding: 0.15rem 0.55rem;
border-radius: var(--radius);
background: #f0fdfa;
color: #0f766e;
font-weight: 700;
font-size: 0.8rem;
}
.ops {
display: flex;
justify-content: flex-end;
flex-wrap: nowrap;
gap: 0.4rem;
white-space: nowrap;
}
tr.link {
cursor: pointer;
}
tr.link:hover td {
background: #f8fffd;
}
.view {
border: 0;
background: none;
padding: 0;
color: #0f766e;
font: inherit;
font-size: 0.85rem;
font-weight: 700;
cursor: pointer;
}
.confirm {
margin: 0;
line-height: 1.8;
}
@media (max-width: 720px) {
.filters-grid :deep(.ui-field),
.filters-grid :deep(.ui-field:nth-child(2)) {
flex: 1 1 100%;
max-width: none;
}
.filters-actions,
.filters-actions :deep(button) {
width: 100%;
}
.table-wrap {
overflow: visible;
}
table {
min-width: 0;
}
table thead {
display: none;
}
table,
tbody,
tr,
td {
display: block;
width: auto;
}
tbody tr {
border: 1px solid #e7eef2;
border-radius: 14px;
margin-bottom: 0.65rem;
padding: 0.35rem 0.7rem 0.55rem;
background: #fff;
}
td {
display: flex;
justify-content: space-between;
gap: 0.75rem;
border-bottom: 0;
padding: 0.35rem 0;
text-align: start;
}
td::before {
content: attr(data-label);
flex: 0 0 auto;
color: #64748b;
font-size: 0.75rem;
font-weight: 700;
}
td.ops {
justify-content: flex-end;
}
.view {
display: none;
}
tr.link {
cursor: pointer;
}
.when {
flex-direction: column;
align-items: flex-end;
width: auto;
}
.clip {
white-space: normal;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}
</style>
+134 -25
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'; import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import AutomationCanvas from '@/components/automations/AutomationCanvas.vue'; import AutomationCanvas from '@/components/automations/AutomationCanvas.vue';
@@ -85,6 +85,8 @@ const search = ref('');
const steps = ref<AutomationStep[]>([makeStep('create_activity')]); const steps = ref<AutomationStep[]>([makeStep('create_activity')]);
const selected = ref<'trigger' | string>('trigger'); const selected = ref<'trigger' | string>('trigger');
const inspectorOpen = ref(false); const inspectorOpen = ref(false);
const inspectorRef = ref<HTMLElement | null>(null);
const canvasFullscreen = ref(false);
const savedSnap = ref(''); const savedSnap = ref('');
const createOpen = ref(false); const createOpen = ref(false);
const draftName = ref(''); const draftName = ref('');
@@ -107,6 +109,38 @@ function selectNode(id: 'trigger' | string) {
inspectorOpen.value = true; inspectorOpen.value = true;
} }
function isAntOverlayTarget(target: Element) {
return !!(
target.closest('.ant-select-dropdown') ||
target.closest('.ant-picker-dropdown') ||
target.closest('.ant-cascader-dropdown') ||
target.closest('.ant-dropdown') ||
target.closest('.ant-modal-wrap') ||
target.closest('.ant-popover') ||
target.closest('.ant-tooltip') ||
target.closest('.ant-message')
);
}
function onDocPointerDown(e: PointerEvent) {
if (!inspectorOpen.value) return;
const root = inspectorRef.value;
if (!root) return;
const target = e.target;
if (!(target instanceof Element)) return;
if (root.contains(target) || isAntOverlayTarget(target)) return;
inspectorOpen.value = false;
}
function onDocKeydown(e: KeyboardEvent) {
if (e.key !== 'Escape') return;
if (inspectorOpen.value) {
inspectorOpen.value = false;
return;
}
if (canvasFullscreen.value) canvasFullscreen.value = false;
}
const dirty = computed(() => snap() !== savedSnap.value); const dirty = computed(() => snap() !== savedSnap.value);
const selectedForm = computed(() => const selectedForm = computed(() =>
trigger.value === 'lead_submitted' && sourceId.value trigger.value === 'lead_submitted' && sourceId.value
@@ -199,6 +233,8 @@ function errText(e: unknown, fallback: string) {
function hydrate(row?: AutomationRuleDto | null) { function hydrate(row?: AutomationRuleDto | null) {
if (!row) { if (!row) {
editingId.value = null; editingId.value = null;
canvasFullscreen.value = false;
inspectorOpen.value = false;
name.value = 'قانون بدون نام'; name.value = 'قانون بدون نام';
trigger.value = 'deal_won'; trigger.value = 'deal_won';
isActive.value = true; isActive.value = true;
@@ -493,6 +529,7 @@ function removeRule(id: string) {
if (editingId.value === id) { if (editingId.value === id) {
editingId.value = null; editingId.value = null;
inspectorOpen.value = false; inspectorOpen.value = false;
canvasFullscreen.value = false;
} }
await load(); await load();
if (!editingId.value && items.value[0]) hydrate(items.value[0]); if (!editingId.value && items.value[0]) hydrate(items.value[0]);
@@ -514,11 +551,23 @@ async function toggleActive(row: AutomationRuleDto, checked: boolean) {
} }
onMounted(async () => { onMounted(async () => {
document.addEventListener('pointerdown', onDocPointerDown, true);
document.addEventListener('keydown', onDocKeydown);
await load(); await load();
if (editingId.value) return; if (editingId.value) return;
if (items.value[0]) hydrate(items.value[0]); if (items.value[0]) hydrate(items.value[0]);
}); });
onBeforeUnmount(() => {
document.removeEventListener('pointerdown', onDocPointerDown, true);
document.removeEventListener('keydown', onDocKeydown);
document.body.style.overflow = '';
});
watch(canvasFullscreen, (on) => {
document.body.style.overflow = on ? 'hidden' : '';
});
watch(trigger, (next, prev) => { watch(trigger, (next, prev) => {
if (prev === 'lead_submitted' && next !== 'lead_submitted') sourceId.value = null; if (prev === 'lead_submitted' && next !== 'lead_submitted') sourceId.value = null;
const allowed = allowedConditionFields(next); const allowed = allowedConditionFields(next);
@@ -703,21 +752,33 @@ watch(trigger, (next, prev) => {
message="این قانون ویژگی حرفه‌ای دارد؛ برای ذخیره ارتقا دهید یا شاخه/شرط فرم/نوبت را بردارید." message="این قانون ویژگی حرفه‌ای دارد؛ برای ذخیره ارتقا دهید یا شاخه/شرط فرم/نوبت را بردارید."
/> />
<a-flex <Teleport to="body" :disabled="!canvasFullscreen">
v-if="editingId"
:style="{ flex: 1, minHeight: 0 }"
:gap="0"
>
<div <div
:style="{ v-if="editingId"
flex: 1, :style="
minWidth: 0, canvasFullscreen
minHeight: 0, ? {
position: 'fixed',
inset: 0,
zIndex: 500,
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}" minHeight: 0,
minWidth: 0,
background: token.colorBgLayout,
}
: {
position: 'relative',
flex: 1,
minHeight: 0,
minWidth: 0,
display: 'flex',
flexDirection: 'column',
}
"
> >
<AutomationCanvas <AutomationCanvas
v-model:fullscreen="canvasFullscreen"
:trigger="trigger" :trigger="trigger"
:steps="steps" :steps="steps"
:selected="selected" :selected="selected"
@@ -731,29 +792,52 @@ watch(trigger, (next, prev) => {
@remove-range="removeRange" @remove-range="removeRange"
@add-branch="addBranch" @add-branch="addBranch"
/> />
</div>
<aside <Transition name="auto-inspector">
v-show="inspectorOpen" <div
v-if="inspectorOpen"
ref="inspectorRef"
:style="{ :style="{
position: 'absolute',
insetInlineEnd: `${token.margin}px`,
top: `${token.margin}px`,
bottom: `${token.margin}px`,
width: '320px', width: '320px',
flexShrink: 0, maxWidth: `calc(100% - ${token.margin * 2}px)`,
minHeight: 0, zIndex: 10,
overflow: 'auto',
borderInlineStart: `1px solid ${token.colorBorderSecondary}`,
background: token.colorBgContainer,
padding: `${token.paddingSM}px`,
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: `${token.marginXS}px`, minHeight: 0,
borderRadius: `${token.borderRadiusLG}px`,
background: token.colorBgContainer,
border: `1px solid ${token.colorBorderSecondary}`,
boxShadow: token.boxShadowSecondary,
overflow: 'hidden',
}"
@pointerdown.stop
>
<a-flex
justify="space-between"
align="center"
:style="{
flexShrink: 0,
padding: `${token.paddingSM}px`,
borderBottom: `1px solid ${token.colorBorderSecondary}`,
}" }"
> >
<a-flex justify="space-between" align="center">
<a-typography-text strong>{{ inspectorTitle }}</a-typography-text> <a-typography-text strong>{{ inspectorTitle }}</a-typography-text>
<a-button type="text" @click="inspectorOpen = false"> <a-button type="text" @click="inspectorOpen = false">
<template #icon><CloseOutlined /></template> <template #icon><CloseOutlined /></template>
</a-button> </a-button>
</a-flex> </a-flex>
<div
:style="{
flex: 1,
minHeight: 0,
overflow: 'auto',
padding: `${token.paddingSM}px`,
}"
>
<AutomationInspector <AutomationInspector
v-model:trigger="trigger" v-model:trigger="trigger"
v-model:steps="steps" v-model:steps="steps"
@@ -766,11 +850,14 @@ watch(trigger, (next, prev) => {
:teams="teams" :teams="teams"
:activity-type-defs="activityTypeDefs" :activity-type-defs="activityTypeDefs"
/> />
</aside> </div>
</a-flex> </div>
</Transition>
</div>
</Teleport>
<a-flex <a-flex
v-else v-if="!editingId"
vertical vertical
align="center" align="center"
justify="center" justify="center"
@@ -890,4 +977,26 @@ watch(trigger, (next, prev) => {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.auto-inspector-enter-active,
.auto-inspector-leave-active {
transition:
opacity 0.16s ease,
transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
transform-origin: top center;
will-change: opacity, transform;
pointer-events: none;
}
.auto-inspector-enter-from,
.auto-inspector-leave-to {
opacity: 0;
transform: translate3d(0, 6px, 0) scale(0.97);
}
.auto-inspector-enter-to,
.auto-inspector-leave-from {
opacity: 1;
transform: translate3d(0, 0, 0) scale(1);
}
</style> </style>
-5
View File
@@ -351,12 +351,7 @@ onMounted(load);
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">چک‌ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">چک‌ها</a-typography-title>
<a-typography-text type="secondary">
دفتر چک‌های دریافتی و پرداختی. وضعیت فقط برای پیگیری است
</a-typography-text>
</a-flex>
<a-space wrap :size="8"> <a-space wrap :size="8">
<a-button type="primary" @click="openForm('in')"> <a-button type="primary" @click="openForm('in')">
<template #icon><PlusOutlined /></template> <template #icon><PlusOutlined /></template>
-3
View File
@@ -114,9 +114,6 @@ onMounted(load);
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">پورسانت فروش</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">پورسانت فروش</a-typography-title>
<a-typography-text type="secondary">
گزارش پورسانت ثبت‌شده برای کارشناسان فروش متصل به فاکتورهای صادره
</a-typography-text>
</div> </div>
<a-button :disabled="loading" :loading="loading" @click="load"> <a-button :disabled="loading" :loading="loading" @click="load">
<template #icon><ReloadOutlined /></template> <template #icon><ReloadOutlined /></template>
+52 -9
View File
@@ -38,7 +38,9 @@ import {
BankOutlined, BankOutlined,
DeleteOutlined, DeleteOutlined,
DownloadOutlined, DownloadOutlined,
EditOutlined,
FileExcelOutlined, FileExcelOutlined,
IdcardOutlined,
MailOutlined, MailOutlined,
MoreOutlined, MoreOutlined,
PhoneOutlined, PhoneOutlined,
@@ -637,7 +639,6 @@ function peopleCustomRow(record: PersonDto) {
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">مخاطبین</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">مخاطبین</a-typography-title>
<a-typography-text type="secondary">مدیریت و مشاهده اشخاص و شرکت‌ها</a-typography-text>
</div> </div>
<a-space wrap> <a-space wrap>
<RouterLink v-if="canBehavior" :to="{ name: 'disc-report' }"> <RouterLink v-if="canBehavior" :to="{ name: 'disc-report' }">
@@ -827,17 +828,38 @@ function peopleCustomRow(record: PersonDto) {
</a-button> </a-button>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="detail"> <a-menu-item
<RouterLink :to="{ name: 'person-detail', params: { id: item.id } }">پرونده</RouterLink> key="detail"
@click="
router.push({
name: 'person-detail',
params: { id: item.id },
})
"
>
<template #icon><IdcardOutlined /></template>
پرونده
</a-menu-item> </a-menu-item>
<a-menu-item key="edit"> <a-menu-item
<RouterLink :to="{ name: 'person-edit', params: { id: item.id } }">ویرایش</RouterLink> key="edit"
@click="
router.push({
name: 'person-edit',
params: { id: item.id },
})
"
>
<template #icon><EditOutlined /></template>
ویرایش
</a-menu-item> </a-menu-item>
<a-menu-item <a-menu-item
v-for="mood in PERSON_MOODS" v-for="mood in PERSON_MOODS"
:key="mood" :key="mood"
@click="setMoodFor(item, mood)" @click="setMoodFor(item, mood)"
> >
<template #icon>
<CustomerMoodFace :mood="mood" :size="18" />
</template>
{{ moodLabel(mood) }} {{ moodLabel(mood) }}
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
@@ -975,17 +997,38 @@ function peopleCustomRow(record: PersonDto) {
</a-button> </a-button>
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="detail"> <a-menu-item
<RouterLink :to="{ name: 'person-detail', params: { id: record.id } }">پرونده</RouterLink> key="detail"
@click="
router.push({
name: 'person-detail',
params: { id: record.id },
})
"
>
<template #icon><IdcardOutlined /></template>
پرونده
</a-menu-item> </a-menu-item>
<a-menu-item key="edit"> <a-menu-item
<RouterLink :to="{ name: 'person-edit', params: { id: record.id } }">ویرایش</RouterLink> key="edit"
@click="
router.push({
name: 'person-edit',
params: { id: record.id },
})
"
>
<template #icon><EditOutlined /></template>
ویرایش
</a-menu-item> </a-menu-item>
<a-menu-item <a-menu-item
v-for="mood in PERSON_MOODS" v-for="mood in PERSON_MOODS"
:key="mood" :key="mood"
@click="setMoodFor(record as PersonDto, mood)" @click="setMoodFor(record as PersonDto, mood)"
> >
<template #icon>
<CustomerMoodFace :mood="mood" :size="18" />
</template>
{{ moodLabel(mood) }} {{ moodLabel(mood) }}
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
+115 -200
View File
@@ -4,14 +4,24 @@ import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { CURRENCY_OPTIONS, formatMoney } from '@/lib/money'; import { CURRENCY_OPTIONS, formatMoney } from '@/lib/money';
import MoneyInput from '@/components/MoneyInput.vue'; import MoneyInput from '@/components/MoneyInput.vue';
import {
UiButton,
UiCard,
UiField,
UiPageHeader,
UiSelect,
} from '@/components/ui';
import type { OrganizationDto, UpdateOrgCurrenciesRequest } from '@mento/shared'; import type { OrganizationDto, UpdateOrgCurrenciesRequest } from '@mento/shared';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Checkbox as ACheckbox,
CheckboxGroup as ACheckboxGroup,
Col as ACol,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Row as ARow,
Select as ASelect,
Spin as ASpin,
Typography,
} from 'ant-design-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -27,19 +37,29 @@ const rateCurrencies = computed(() =>
enabled.value.filter((c) => c !== baseCurrency.value), enabled.value.filter((c) => c !== baseCurrency.value),
); );
function toggleCurrency(code: string) { const baseCurrencyOptions = CURRENCY_OPTIONS.map((c) => ({
if (code === baseCurrency.value) return; value: c.code,
if (enabled.value.includes(code)) { label: `${c.labelFa} (${c.code})`,
enabled.value = enabled.value.filter((c) => c !== code); }));
} else {
enabled.value = [...enabled.value, code]; function onEnabledChange(values: Array<string | number | boolean>) {
if (!rates.value[code]) rates.value[code] = ''; const next = values.map(String);
if (!next.includes(baseCurrency.value)) {
next.unshift(baseCurrency.value);
} }
for (const code of next) {
if (code !== baseCurrency.value && rates.value[code] == null) {
rates.value[code] = '';
}
}
enabled.value = next;
} }
function onBaseChange() { function onBaseChange(value: unknown) {
if (!enabled.value.includes(baseCurrency.value)) { const code = String(value ?? '');
enabled.value = [baseCurrency.value, ...enabled.value]; baseCurrency.value = code;
if (!enabled.value.includes(code)) {
enabled.value = [code, ...enabled.value];
} }
} }
@@ -108,201 +128,96 @@ onMounted(load);
</script> </script>
<template> <template>
<section class="crm-page currency-page" dir="rtl"> <a-flex vertical :gap="16">
<UiPageHeader <a-typography-title :level="3" :style="{ margin: 0 }">ارزها و نرخ تبدیل</a-typography-title>
title="ارزها و نرخ تبدیل"
description="ارز پایه برای تجمیع مبالغ و پیش‌بینی‌ها استفاده می‌شود. نرخ یعنی چند واحد ارز پایه برابر با ۱ واحد ارز خارجی است." <a-alert v-if="error" type="error" show-icon :message="error" />
<a-alert v-if="ok" type="success" show-icon :message="ok" />
<a-spin :spinning="loading">
<a-card v-if="!loading" :bordered="false">
<a-form layout="vertical" @finish="save">
<a-row :gutter="[16, 0]">
<a-col :xs="24" :md="12" :lg="8">
<a-form-item
label="ارز پایه سیستم"
extra="همه فاکتورها، پیش‌بینی‌ها و آمار کل بر پایه این واحد ارزی محاسبه می‌شوند."
>
<a-select
:value="baseCurrency"
:options="baseCurrencyOptions"
style="width: 100%"
@update:value="onBaseChange"
/> />
</a-form-item>
</a-col>
</a-row>
<div v-if="error" class="crm-alert crm-alert-danger">{{ error }}</div> <a-form-item label="ارزهای فعال در فاکتورها و معاملات">
<div v-if="ok" class="crm-alert crm-alert-success">{{ ok }}</div> <a-checkbox-group :value="enabled" @update:value="onEnabledChange">
<a-row :gutter="[12, 8]">
<UiCard v-if="!loading" class="section-card"> <a-col
<form class="crm-form" @submit.prevent="save">
<UiField label="ارز پایه سیستم" hint="همه فاکتورها، پیش‌بینی‌ها و آمار کل بر پایه این واحد ارزی محاسبه خواهند شد.">
<UiSelect v-model="baseCurrency" @change="onBaseChange">
<option
v-for="c in CURRENCY_OPTIONS" v-for="c in CURRENCY_OPTIONS"
:key="c.code" :key="c.code"
:value="c.code" :xs="24"
:sm="12"
:md="8"
:lg="6"
> >
{{ c.labelFa }} ({{ c.code }}) <a-checkbox :value="c.code" :disabled="c.code === baseCurrency">
</option> {{ c.labelFa }}
</UiSelect> <a-typography-text type="secondary" dir="ltr">
</UiField> ({{ c.code }})
</a-typography-text>
</a-checkbox>
</a-col>
</a-row>
</a-checkbox-group>
</a-form-item>
<UiField label="ارزهای فعال در فاکتورها و معاملات"> <a-card v-if="rateCurrencies.length" title="نرخ برابری" :bordered="true">
<div class="currency-chips"> <template #extra>
<label <a-typography-text type="secondary">نسبت به {{ baseCurrency }}</a-typography-text>
v-for="c in CURRENCY_OPTIONS" </template>
:key="c.code" <a-flex vertical :gap="12">
class="currency-chip" <a-row
:class="{ active: enabled.includes(c.code), locked: c.code === baseCurrency }" v-for="code in rateCurrencies"
:key="code"
:gutter="[12, 8]"
align="middle"
> >
<input <a-col :xs="24" :sm="6" :md="4">
type="checkbox" <a-typography-text strong dir="ltr">۱ {{ code }} =</a-typography-text>
:checked="enabled.includes(c.code)" </a-col>
:disabled="c.code === baseCurrency" <a-col :xs="24" :sm="12" :md="10">
@change="toggleCurrency(c.code)"
/>
<span class="chip-title">{{ c.labelFa }}</span>
<span class="chip-code font-mono">{{ c.code }}</span>
</label>
</div>
</UiField>
<div v-if="rateCurrencies.length" class="rates-section">
<h3 class="rates-title">نرخ برابری نسبت به {{ baseCurrency }}</h3>
<div class="rates-list">
<div v-for="code in rateCurrencies" :key="code" class="rate-row">
<span class="rate-unit">۱ {{ code }} =</span>
<div class="rate-input-wrap">
<MoneyInput <MoneyInput
v-model="rates[code]" v-model="rates[code]"
:decimals="6" :decimals="6"
:placeholder="`نرخ برابری به ${baseCurrency}`" :placeholder="`نرخ برابری به ${baseCurrency}`"
/> />
</div> </a-col>
<span class="rate-target">{{ baseCurrency }}</span> <a-col :xs="24" :sm="6" :md="4">
</div> <a-typography-text type="secondary" dir="ltr">{{ baseCurrency }}</a-typography-text>
</div> </a-col>
<p v-if="rates.USD" class="example-note"> </a-row>
نمونه محاسبه: ۱ دلار آمریکا ≈ <strong>{{ formatMoney(Number(rates.USD) || 0, baseCurrency) }}</strong> <a-typography-text v-if="rates.USD" type="secondary">
</p> نمونه محاسبه: ۱ دلار آمریکا ≈
</div> <a-typography-text strong>
{{ formatMoney(Number(rates.USD) || 0, baseCurrency) }}
</a-typography-text>
</a-typography-text>
</a-flex>
</a-card>
<div class="form-submit-row"> <a-form-item>
<UiButton type="submit" :loading="saving"> <a-flex justify="flex-end">
<a-button type="primary" html-type="submit" :loading="saving">
ذخیره تنظیمات ارز ذخیره تنظیمات ارز
</UiButton> </a-button>
</div> </a-flex>
</form> </a-form-item>
</UiCard> </a-form>
</section> </a-card>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.currency-page {
display: flex;
flex-direction: column;
gap: var(--sp-6);
width: 100%;
max-width: 100%;
}
.section-card {
padding: var(--sp-6);
}
.currency-chips {
display: flex;
flex-wrap: wrap;
gap: var(--sp-2);
}
.currency-chip {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
border-radius: var(--radius-md);
border: 1px solid var(--color-border);
background: var(--color-surface);
font-size: var(--fs-sm);
color: var(--color-text-secondary);
cursor: pointer;
user-select: none;
transition: all var(--transition-fast);
}
.currency-chip:hover {
border-color: var(--color-brand-400);
}
.currency-chip.active {
border-color: var(--color-brand-500);
background: var(--color-brand-50, #f0fdfa);
color: var(--color-brand-800, #115e59);
}
.currency-chip.locked {
opacity: 0.8;
cursor: default;
}
.chip-title {
font-weight: 600;
}
.chip-code {
font-size: var(--fs-xs);
color: var(--color-text-muted);
}
.font-mono {
font-family: var(--font-mono, monospace);
}
.rates-section {
display: flex;
flex-direction: column;
gap: var(--sp-3);
padding: var(--sp-4);
background: var(--color-surface-soft);
border-radius: var(--radius-lg);
border: 1px solid var(--color-border);
}
.rates-title {
font-size: var(--fs-sm);
font-weight: 700;
color: var(--color-text-primary);
margin: 0;
}
.rates-list {
display: flex;
flex-direction: column;
gap: var(--sp-3);
}
.rate-row {
display: flex;
align-items: center;
gap: var(--sp-3);
}
.rate-unit {
font-size: var(--fs-sm);
font-weight: 600;
color: var(--color-text-primary);
min-width: 4.5rem;
}
.rate-input-wrap {
flex: 1;
max-width: 14rem;
}
.rate-target {
font-size: var(--fs-sm);
color: var(--color-text-secondary);
font-family: var(--font-mono, monospace);
}
.example-note {
font-size: var(--fs-xs);
color: var(--color-text-secondary);
margin: 0;
}
.example-note strong {
color: var(--color-brand-700, #0f766e);
}
.form-submit-row {
display: flex;
justify-content: flex-end;
margin-top: var(--sp-2);
}
</style>
+160 -258
View File
@@ -2,23 +2,37 @@
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import {
UiBadge,
UiButton,
UiCard,
UiEmptyState,
UiField,
UiInput,
UiPageHeader,
UiSelect,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import type { import type {
CreateCustomFieldRequest, CreateCustomFieldRequest,
CustomFieldDefinitionDto, CustomFieldDefinitionDto,
CustomFieldEntity, CustomFieldEntity,
CustomFieldType, CustomFieldType,
} from '@mento/shared'; } from '@mento/shared';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Checkbox as ACheckbox,
Col as ACol,
Divider as ADivider,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import { PlusOutlined, ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -47,12 +61,44 @@ const typeLabels: Record<CustomFieldType, string> = {
select: 'لیست انتخابی', select: 'لیست انتخابی',
}; };
const entityOptions = [
{ value: 'person', label: 'شخص' },
{ value: 'company', label: 'شرکت' },
{ value: 'deal', label: 'معامله' },
{ value: 'note', label: 'یادداشت' },
];
const typeOptions = [
{ value: 'text', label: 'متن' },
{ value: 'number', label: 'عدد' },
{ value: 'date', label: 'تاریخ' },
{ value: 'boolean', label: 'بله/خیر' },
{ value: 'select', label: 'لیست انتخابی' },
];
const filterOptions = [
{ value: 'all', label: 'همه موجودیت‌ها' },
...entityOptions,
];
const visible = computed(() => const visible = computed(() =>
filter.value === 'all' filter.value === 'all'
? fields.value ? fields.value
: fields.value.filter((f) => f.entityType === filter.value), : fields.value.filter((f) => f.entityType === filter.value),
); );
function entityTagColor(entity: CustomFieldEntity) {
if (entity === 'deal') return 'warning';
if (entity === 'company') return 'processing';
return 'blue';
}
function fieldDescription(field: CustomFieldDefinitionDto) {
const parts = [`کلید سیستمی: ${field.key}`];
if (field.options?.length) parts.push(`گزینه‌ها: ${field.options.join('، ')}`);
return parts.join(' · ');
}
async function load() { async function load() {
loading.value = true; loading.value = true;
error.value = ''; error.value = '';
@@ -124,258 +170,114 @@ onMounted(load);
</script> </script>
<template> <template>
<section class="crm-page narrow"> <a-flex vertical :gap="16">
<UiPageHeader <a-typography-title :level="3" :style="{ margin: 0 }">فیلدهای سفارشی</a-typography-title>
title="فیلدهای سفارشی"
lead="فیلدهای اختصاصی سازمان را برای شخص، شرکت، معامله یا یادداشت تعریف کنید." <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<a-card :bordered="false">
<a-form layout="vertical" @finish="createField">
<a-divider orientation="right">فیلد جدید</a-divider>
<a-row :gutter="[16, 0]">
<a-col :xs="24" :md="8">
<a-form-item label="عنوان" required>
<a-input v-model:value="label" placeholder="مثلاً صنعت" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="روی چه چیزی؟">
<a-select
v-model:value="entityType"
:options="entityOptions"
style="width: 100%"
/> />
</a-form-item>
<form class="crm-form" @submit.prevent="createField"> </a-col>
<UiCard> <a-col :xs="24" :md="8">
<template #header> <a-form-item label="نوع فیلد">
<div class="card-title"> <a-select
<UiIcon name="settings" :size="18" /> v-model:value="fieldType"
<h3>فیلد جدید</h3> :options="typeOptions"
</div> style="width: 100%"
</template> />
<div class="crm-form-grid-3"> </a-form-item>
<UiField label="عنوان" required for-id="cf-label"> </a-col>
<UiInput id="cf-label" v-model="label" required placeholder="مثلاً صنعت" /> <a-col v-if="fieldType === 'select'" :span="24">
</UiField> <a-form-item label="گزینه‌ها (با کاما جدا کنید)">
<a-input
<UiField label="روی چه چیزی؟" for-id="cf-entity"> v-model:value="optionsRaw"
<UiSelect id="cf-entity" v-model="entityType">
<option value="person">شخص</option>
<option value="company">شرکت</option>
<option value="deal">معامله</option>
<option value="note">یادداشت</option>
</UiSelect>
</UiField>
<UiField label="نوع فیلد" for-id="cf-type">
<UiSelect id="cf-type" v-model="fieldType">
<option value="text">متن</option>
<option value="number">عدد</option>
<option value="date">تاریخ</option>
<option value="boolean">بله/خیر</option>
<option value="select">لیست انتخابی</option>
</UiSelect>
</UiField>
<div v-if="fieldType === 'select'" class="crm-col-span-full">
<UiField label="گزینه‌ها (با کاما جدا کنید)" for-id="cf-options">
<UiInput
id="cf-options"
v-model="optionsRaw"
placeholder="مثلاً فناوری، تولید، خدمات" placeholder="مثلاً فناوری، تولید، خدمات"
/> />
</UiField> </a-form-item>
</div> </a-col>
<a-col :span="24">
<div class="crm-col-span-full check-row"> <a-form-item>
<label class="check"> <a-checkbox v-model:checked="required">فیلد اجباری است</a-checkbox>
<input v-model="required" type="checkbox" /> </a-form-item>
<span>فیلد اجباری است</span> </a-col>
</label> <a-col :span="24">
</div> <a-button type="primary" html-type="submit" :loading="saving" :disabled="saving">
</div> <template #icon><PlusOutlined /></template>
<template #footer>
<UiButton
variant="primary"
type="submit"
:disabled="saving"
:loading="saving"
>
<UiIcon name="plus" :size="16" />
{{ saving ? 'در حال ثبت…' : 'افزودن فیلد' }} {{ saving ? 'در حال ثبت…' : 'افزودن فیلد' }}
</UiButton> </a-button>
</template> </a-col>
</UiCard> </a-row>
</form> </a-form>
<div class="crm-toolbar"> <a-divider orientation="right">فهرست فیلدها</a-divider>
<UiSelect v-model="filter" class="filter-select">
<option value="all">همه موجودیت‌ها</option>
<option value="person">شخص</option>
<option value="company">شرکت</option>
<option value="deal">معامله</option>
<option value="note">یادداشت</option>
</UiSelect>
<UiButton variant="ghost" type="button" @click="load">
<UiIcon name="refresh" :size="16" />
بروزرسانی
</UiButton>
</div>
<p v-if="error" class="error-msg">{{ error }}</p> <a-row :gutter="[16, 16]" :style="{ marginBottom: '16px' }">
<p v-if="loading" class="muted">در حال بارگذاری…</p> <a-col :xs="24" :md="12">
<a-select
<div v-else class="list"> v-model:value="filter"
<UiCard v-for="field in visible" :key="field.id" padding="sm" class="field-item-card"> :options="filterOptions"
<div class="field-item"> style="width: 100%"
<div class="field-meta">
<div class="field-title-line">
<strong>{{ field.label }}</strong>
<UiBadge :variant="field.entityType === 'deal' ? 'warning' : field.entityType === 'company' ? 'info' : 'primary'" size="sm">
{{ entityLabels[field.entityType] }}
</UiBadge>
<UiBadge variant="neutral" size="sm">
{{ typeLabels[field.fieldType] }}
</UiBadge>
<UiBadge v-if="field.required" variant="danger" size="sm">
اجباری
</UiBadge>
<UiBadge :variant="field.isActive ? 'success' : 'neutral'" size="sm" dot>
{{ field.isActive ? 'فعال' : 'غیرفعال' }}
</UiBadge>
</div>
<p class="meta-code">
کلید سیستمی: <code>{{ field.key }}</code>
<span v-if="field.options?.length" class="options-preview">
· گزینه‌ها: {{ field.options.join('، ') }}
</span>
</p>
</div>
<div class="actions">
<UiButton
variant="outline"
size="sm"
@click="toggleActive(field)"
>
{{ field.isActive ? 'غیرفعال‌سازی' : 'فعال‌سازی' }}
</UiButton>
<UiButton
variant="danger"
size="sm"
@click="removeField(field)"
>
حذف
</UiButton>
</div>
</div>
</UiCard>
<UiEmptyState
v-if="!visible.length"
icon="settings"
title="فیلدی تعریف نشده است"
description="هیچ فیلد سفارشی برای این موجودیت وجود ندارد."
/> />
</div> </a-col>
</section> <a-col :xs="24" :md="8">
<a-button @click="load">
<template #icon><ReloadOutlined /></template>
بروزرسانی
</a-button>
</a-col>
</a-row>
<a-spin :spinning="loading">
<a-empty
v-if="!loading && !visible.length"
description="فیلدی تعریف نشده است. هیچ فیلد سفارشی برای این موجودیت وجود ندارد."
/>
<a-list v-else-if="visible.length" item-layout="horizontal" :data-source="visible">
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a-space wrap>
<a-button @click="toggleActive(item)">
{{ item.isActive ? 'غیرفعال‌سازی' : 'فعال‌سازی' }}
</a-button>
<a-button danger @click="removeField(item)">حذف</a-button>
</a-space>
</template>
<a-list-item-meta :description="fieldDescription(item)">
<template #title>
<a-space wrap>
<a-typography-text strong>{{ item.label }}</a-typography-text>
<a-tag :color="entityTagColor(item.entityType)" :bordered="false">
{{ entityLabels[item.entityType] }}
</a-tag>
<a-tag :bordered="false">{{ typeLabels[item.fieldType] }}</a-tag>
<a-tag v-if="item.required" color="error" :bordered="false">اجباری</a-tag>
<a-tag :color="item.isActive ? 'success' : 'default'" :bordered="false">
{{ item.isActive ? 'فعال' : 'غیرفعال' }}
</a-tag>
</a-space>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-spin>
</a-card>
</a-flex>
</template> </template>
<style scoped>
.card-title {
display: flex;
align-items: center;
gap: var(--sp-2);
}
.card-title h3 {
margin: 0;
font-size: var(--fs-base);
font-weight: 700;
}
.check-row {
display: flex;
align-items: center;
}
.check {
display: flex;
align-items: center;
gap: var(--sp-2);
cursor: pointer;
font-size: var(--fs-sm);
color: var(--color-text);
}
.filter-select {
min-width: 180px;
}
.error-msg {
color: var(--color-danger);
font-size: var(--fs-sm);
font-weight: 600;
}
.list {
display: grid;
gap: var(--sp-3);
}
.field-item-card {
transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.field-item-card:hover {
box-shadow: var(--shadow-md);
}
.field-item {
display: flex;
justify-content: space-between;
align-items: center;
gap: var(--sp-4);
flex-wrap: wrap;
}
.field-meta {
display: grid;
gap: var(--sp-1);
}
.field-title-line {
display: flex;
align-items: center;
gap: var(--sp-2);
flex-wrap: wrap;
}
.field-title-line strong {
font-size: var(--fs-base);
color: var(--color-text-emphasis);
}
.meta-code {
margin: 0;
font-size: var(--fs-xs);
color: var(--color-text-muted);
}
.meta-code code {
font-family: Consolas, monospace;
background: var(--color-surface-sunken);
padding: 1px var(--sp-2);
border-radius: var(--radius-sm);
color: var(--color-text);
}
.options-preview {
color: var(--color-text-muted);
}
.actions {
display: flex;
gap: var(--sp-2);
align-items: center;
}
.muted {
color: var(--color-text-muted);
}
@media (max-width: 640px) {
.field-item {
flex-direction: column;
align-items: stretch;
}
.actions {
justify-content: flex-end;
}
}
</style>
+240 -318
View File
@@ -5,13 +5,38 @@ import axios from 'axios';
import type { import type {
AuditLogDto, AuditLogDto,
AuditLogListResponse, AuditLogListResponse,
DeletionArchiveDto,
DeletionArchiveListResponse, DeletionArchiveListResponse,
DeletionRetention, DeletionRetention,
} from '@mento/shared'; } from '@mento/shared';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { formatJalaliDateTime, toFaDigits } from '@/lib/jalali'; import { formatJalaliDateTime, toFaDigits } from '@/lib/jalali';
import { UiButton, UiCard, UiEmptyState, UiModal, UiPageHeader, UiPagination } from '@/components/ui';
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize'; import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Modal as AModal,
Pagination as APagination,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Tabs as ATabs,
TabPane as ATabPane,
Typography,
} from 'ant-design-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
type HistoryTab = 'creates' | 'edits' | 'deletes'; type HistoryTab = 'creates' | 'edits' | 'deletes';
@@ -102,6 +127,19 @@ function rowNo(index: number) {
const purgeItem = computed(() => data.value?.items.find((item) => item.id === purgeId.value) ?? null); const purgeItem = computed(() => data.value?.items.find((item) => item.id === purgeId.value) ?? null);
const actorOptions = computed(() => [
{ value: '', label: 'همه' },
...actors.value.map((user) => ({ value: user.id, label: user.fullName })),
]);
const showDeletesEmpty = computed(
() => tab.value === 'deletes' && !error.value && !loading.value && !data.value?.items.length,
);
const showAuditEmpty = computed(
() => tab.value !== 'deletes' && !error.value && !loading.value && !audit.value?.items.length,
);
function apiError(e: unknown, fallback: string) { function apiError(e: unknown, fallback: string) {
if (axios.isAxiosError(e)) { if (axios.isAxiosError(e)) {
const msg = (e.response?.data as { message?: string | string[] })?.message; const msg = (e.response?.data as { message?: string | string[] })?.message;
@@ -352,25 +390,26 @@ async function loadActors() {
} }
} }
function onPage(next: number) { function onPaginationChange(nextPage: number, nextSize: number) {
page.value = next; const sizeChanged = nextSize !== pageSize.value;
void load(); page.value = nextPage;
if (sizeChanged) {
pageSize.value = nextSize;
page.value = 1;
}
void load(sizeChanged);
} }
function onPageSize(size: number) { function selectTab(next: string | number) {
pageSize.value = size; const key = String(next) as HistoryTab;
if (page.value === 1) void load(); if (key === tab.value) return;
}
function selectTab(next: HistoryTab) {
if (next === tab.value) return;
q.value = ''; q.value = '';
page.value = 1; page.value = 1;
data.value = null; data.value = null;
audit.value = null; audit.value = null;
error.value = ''; error.value = '';
okMsg.value = ''; okMsg.value = '';
void router.replace({ query: next === 'deletes' ? {} : { tab: next } }); void router.replace({ query: key === 'deletes' ? {} : { tab: key } });
} }
async function load(resetPage = false) { async function load(resetPage = false) {
@@ -450,6 +489,21 @@ async function confirmPurge() {
} }
} }
function deletionDescription(item: DeletionArchiveDto) {
return [
item.modelLabel,
`${item.deletedByName || 'سیستم'} · ${formatJalaliDateTime(new Date(item.deletedAt))}`,
].join(' · ');
}
function auditDescription(row: AuditLogDto) {
const parts: string[] = [];
if (pathPhrase(row) !== rowHeading(row)) parts.push(pathPhrase(row));
parts.push(row.actor?.fullName || 'سیستم');
parts.push(formatJalaliDateTime(new Date(row.createdAt)));
return parts.join(' · ');
}
watch(tab, () => { watch(tab, () => {
void load(); void load();
}, { immediate: true }); }, { immediate: true });
@@ -462,319 +516,187 @@ void loadActors();
</script> </script>
<template> <template>
<section class="page"> <a-flex vertical :gap="16">
<UiPageHeader <a-typography-title :level="3" :style="{ margin: 0 }">تاریخچه کارها</a-typography-title>
title="تاریخچه کارها"
lead="هر ایجاد، ویرایش و حذف اینجا ثبت می‌شود." <a-tabs :active-key="tab" @change="selectTab">
<a-tab-pane v-for="item in TABS" :key="item.key" :tab="item.label" />
</a-tabs>
<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 = ''" />
<a-card v-if="tab === 'deletes'" :bordered="false">
<a-form layout="vertical">
<a-row :gutter="[16, 0]" align="bottom">
<a-col :xs="24" :md="12">
<a-form-item label="حذف خودکار از این فهرست">
<a-select
v-model:value="retention"
:options="RETENTION_OPTIONS"
style="width: 100%"
/> />
</a-form-item>
<nav class="tabs" aria-label="نوع تاریخچه"> </a-col>
<button <a-col :xs="24" :md="8">
v-for="item in TABS" <a-form-item label=" ">
:key="item.key" <a-button type="primary" :loading="savingRetention" @click="saveRetention">
type="button" ذخیره
:class="{ on: tab === item.key }" </a-button>
@click="selectTab(item.key)" </a-form-item>
> </a-col>
{{ item.label }} </a-row>
</button> </a-form>
</nav> <a-typography-text type="secondary">
<p v-if="okMsg" class="ok">{{ okMsg }}</p>
<p v-if="error" class="error">{{ error }}</p>
<UiCard v-if="tab === 'deletes'">
<div class="retention">
<label for="deletion-retention">حذف خودکار از این فهرست</label>
<select id="deletion-retention" v-model="retention">
<option v-for="option in RETENTION_OPTIONS" :key="option.value" :value="option.value">
{{ option.label }}
</option>
</select>
<UiButton size="sm" :loading="savingRetention" @click="saveRetention">ذخیره</UiButton>
</div>
<p class="hint">
تا پایان این مدت می‌توان مورد را برگرداند. «هرگز» یعنی فقط با حذف کامل از بین می‌رود. تا پایان این مدت می‌توان مورد را برگرداند. «هرگز» یعنی فقط با حذف کامل از بین می‌رود.
</p> </a-typography-text>
</UiCard> </a-card>
<form class="search" @submit.prevent="load(true)"> <a-card :bordered="false">
<input v-model="q" type="search" placeholder="جستجو در عنوان یا نوع" /> <a-form layout="vertical" @finish="load(true)">
<label class="actor"> <a-row :gutter="[16, 0]">
<span>انجام‌دهنده</span> <a-col :xs="24" :md="12">
<select v-model="actorId"> <a-form-item label="جستجو">
<option value="">همه</option> <a-input
<option v-for="user in actors" :key="user.id" :value="user.id">{{ user.fullName }}</option> v-model:value="q"
</select> type="search"
</label> placeholder="جستجو در عنوان یا نوع"
<UiButton type="submit" variant="secondary" size="sm">جستجو</UiButton> allow-clear
</form>
<p v-if="loading" class="muted">در حال بارگذاری…</p>
<UiEmptyState
v-else-if="tab === 'deletes' && !error && !data?.items.length"
title="حذفی ثبت نشده."
description="از این به بعد حذف‌ها با نام کاربر و زمان اینجا دیده می‌شوند."
/> />
<UiEmptyState </a-form-item>
v-else-if="tab !== 'deletes' && !error && !audit?.items.length" </a-col>
:title="tab === 'creates' ? 'ایجاد جدیدی ثبت نشده.' : 'ویرایشی ثبت نشده.'" <a-col :xs="24" :md="8">
description="با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود. روی مورد بزنید تا خود پرونده باز شود." <a-form-item label="انجام‌دهنده">
<a-select
v-model:value="actorId"
:options="actorOptions"
style="width: 100%"
show-search
option-filter-prop="label"
/> />
</a-form-item>
</a-col>
<a-col :xs="24" :md="4">
<a-form-item label=" ">
<a-button type="primary" html-type="submit" block>جستجو</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<div v-else-if="tab === 'deletes' && data?.items.length" class="list"> <a-spin :spinning="loading">
<article v-for="(item, index) in data.items" :key="item.id" class="row"> <a-card v-if="showDeletesEmpty" :bordered="false">
<span class="idx">{{ toFaDigits(rowNo(index)) }}</span> <a-empty description="حذفی ثبت نشده. از این به بعد حذف‌ها با نام کاربر و زمان اینجا دیده می‌شوند." />
<div class="info"> </a-card>
<strong>{{ item.label }}</strong>
<span>{{ item.modelLabel }}</span>
<span>
{{ item.deletedByName || 'سیستم' }}
·
{{ formatJalaliDateTime(new Date(item.deletedAt)) }}
</span>
</div>
<div class="ops">
<UiButton size="sm" variant="secondary" :disabled="busyId === item.id" @click="restore(item.id)">
بازگردانی
</UiButton>
<UiButton size="sm" variant="danger" :disabled="busyId === item.id" @click="purgeId = item.id">
حذف کامل
</UiButton>
</div>
</article>
</div>
<div v-else-if="audit?.items.length" class="list"> <a-card v-else-if="showAuditEmpty" :bordered="false">
<component <a-empty
:is="recordPath(row) ? 'button' : 'div'" :description="
v-for="(row, index) in audit.items" tab === 'creates'
:key="row.id" ? 'ایجاد جدیدی ثبت نشده. با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود.'
class="row" : 'ویرایشی ثبت نشده. با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود.'
:class="{ link: !!recordPath(row) }" "
:type="recordPath(row) ? 'button' : undefined" />
@click="openRecord(row)" </a-card>
<a-card v-else-if="tab === 'deletes' && data?.items.length" :bordered="false">
<a-list item-layout="horizontal" :data-source="data.items">
<template #renderItem="{ item, index }">
<a-list-item>
<template #actions>
<a-space wrap>
<a-button
:disabled="busyId === item.id"
@click="restore(item.id)"
> >
<span class="idx">{{ toFaDigits(rowNo(index)) }}</span> بازگردانی
<div class="info"> </a-button>
<strong>{{ rowHeading(row) }}</strong> <a-button
<span v-if="rowDetail(row)" class="detail">{{ rowDetail(row) }}</span> danger
<span> :disabled="busyId === item.id"
<template v-if="pathPhrase(row) !== rowHeading(row)">{{ pathPhrase(row) }} · </template> @click="purgeId = item.id"
{{ row.actor?.fullName || 'سیستم' }} >
· حذف کامل
{{ formatJalaliDateTime(new Date(row.createdAt)) }} </a-button>
</span> </a-space>
</div>
<span v-if="recordPath(row)" class="open">مشاهده</span>
</component>
</div>
<UiPagination
v-if="listSource"
:page="page"
:total-pages="totalPages"
:total-items="listSource.total"
:page-size="pageSize"
:page-size-options="PAGE_SIZE_OPTIONS"
@update:page="onPage"
@update:page-size="onPageSize"
/>
<UiModal :open="!!purgeItem" title="حذف کامل" @close="purgeId = null">
<p v-if="purgeItem" class="confirm">
«{{ purgeItem.label }}» برای همیشه پاک شود؟ بعد از این دیگر قابل بازگشت نیست.
</p>
<template #footer>
<UiButton variant="ghost" :disabled="!!busyId" @click="purgeId = null">انصراف</UiButton>
<UiButton variant="danger" :loading="!!busyId" @click="confirmPurge">حذف کامل</UiButton>
</template> </template>
</UiModal> <a-list-item-meta :description="deletionDescription(item)">
</section> <template #avatar>
<a-typography-text type="secondary">{{ toFaDigits(rowNo(index)) }}</a-typography-text>
</template>
<template #title>
<a-typography-text strong>{{ item.label }}</a-typography-text>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
<a-card v-else-if="audit?.items.length" :bordered="false">
<a-list item-layout="horizontal" :data-source="audit.items">
<template #renderItem="{ item, index }">
<a-list-item
:style="recordPath(item) ? { cursor: 'pointer' } : undefined"
@click="openRecord(item)"
>
<template v-if="recordPath(item)" #actions>
<a-button type="link" @click.stop="openRecord(item)">مشاهده</a-button>
</template>
<a-list-item-meta :description="auditDescription(item)">
<template #avatar>
<a-typography-text type="secondary">{{ toFaDigits(rowNo(index)) }}</a-typography-text>
</template>
<template #title>
<a-flex vertical :gap="2">
<a-typography-text strong>{{ rowHeading(item) }}</a-typography-text>
<a-typography-text v-if="rowDetail(item)" type="secondary">
{{ rowDetail(item) }}
</a-typography-text>
</a-flex>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-card>
</a-spin>
<a-flex
v-if="listSource"
justify="space-between"
align="center"
wrap="wrap"
:gap="8"
>
<a-pagination
:current="page"
:total="listSource.total"
:page-size="pageSize"
:show-size-changer="true"
:page-size-options="PAGE_SIZE_OPTIONS.map(String)"
@change="onPaginationChange"
/>
<a-typography-text type="secondary">
صفحه {{ toFaDigits(page) }} از {{ toFaDigits(totalPages) }}
</a-typography-text>
</a-flex>
<a-modal
:open="!!purgeItem"
title="حذف کامل"
ok-text="حذف کامل"
cancel-text="انصراف"
ok-type="danger"
:confirm-loading="!!busyId"
destroy-on-close
@ok="confirmPurge"
@cancel="purgeId = null"
>
<a-typography-text v-if="purgeItem">
«{{ purgeItem.label }}» برای همیشه پاک شود؟ بعد از این دیگر قابل بازگشت نیست.
</a-typography-text>
</a-modal>
</a-flex>
</template> </template>
<style scoped>
.page {
display: grid;
gap: 1rem;
min-width: 0;
}
.tabs {
display: flex;
width: 100%;
min-width: 0;
overflow-x: auto;
border-bottom: 1px solid #e2e8f0;
}
.tabs button {
flex: 1 1 0;
min-width: 0;
border: 0;
background: none;
padding: 0.55rem 0.2rem 0.7rem;
color: #64748b;
font: inherit;
font-weight: 700;
cursor: pointer;
box-shadow: inset 0 -2px 0 transparent;
}
.tabs button.on {
color: #0f766e;
box-shadow: inset 0 -2px 0 #14b8a6;
}
.retention {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.6rem;
}
.retention label {
font-weight: 700;
}
.retention select,
.search input,
.search select {
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
color: #0f172a;
font: inherit;
padding: 0.45rem 0.7rem;
min-width: 0;
}
.hint,
.muted {
margin: 0.55rem 0 0;
color: #64748b;
font-size: 0.85rem;
}
.search {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
}
.actor {
display: inline-flex;
align-items: center;
gap: 0.4rem;
font-size: 0.85rem;
font-weight: 700;
}
.idx {
flex: 0 0 auto;
min-width: 1.5rem;
color: #94a3b8;
font-size: 0.82rem;
font-weight: 700;
padding-top: 0.15rem;
}
.search input {
flex: 1 1 12rem;
}
.list {
display: grid;
gap: 0.65rem;
}
.row {
display: flex;
flex-wrap: nowrap;
align-items: flex-start;
justify-content: space-between;
gap: 0.75rem;
padding: 0.8rem 0.9rem;
background: #fff;
border: 1px solid #e7eef2;
border-radius: 14px;
min-width: 0;
text-align: right;
}
.row.link {
width: 100%;
font: inherit;
cursor: pointer;
}
.row.link:hover {
border-color: #99f6e4;
}
.open {
flex: 0 0 auto;
margin-inline-start: auto;
align-self: center;
color: #0f766e;
font-size: 0.82rem;
font-weight: 700;
}
.info {
display: grid;
flex: 1 1 auto;
gap: 0.15rem;
min-width: 0;
}
.info strong,
.info span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.info span {
color: #64748b;
font-size: 0.82rem;
}
.info span.detail {
color: #334155;
white-space: normal;
overflow: visible;
text-overflow: unset;
}
.ops {
display: flex;
flex: 0 0 auto;
flex-wrap: wrap;
gap: 0.4rem;
margin-inline-start: auto;
align-self: center;
}
.pager {
display: flex;
align-items: center;
gap: 0.6rem;
}
.confirm {
margin: 0;
line-height: 1.8;
}
.ok {
margin: 0;
color: #0f766e;
}
.error {
margin: 0;
color: #b91c1c;
}
</style>
+113 -198
View File
@@ -8,16 +8,28 @@ import type {
UpdateFaqArticleRequest, UpdateFaqArticleRequest,
} from '@mento/shared'; } from '@mento/shared';
import { import {
UiBadge, Alert as AAlert,
UiButton, Button as AButton,
UiCard, Card as ACard,
UiEmptyState, Checkbox as ACheckbox,
UiField, Col as ACol,
UiInput, Empty as AEmpty,
UiPageHeader, Flex as AFlex,
UiTextarea, Form as AForm,
} from '@/components/ui'; FormItem as AFormItem,
import UiIcon from '@/components/UiIcon.vue'; Input as AInput,
InputNumber as AInputNumber,
Row as ARow,
Space as ASpace,
Spin as ASpin,
Tag as ATag,
Textarea as ATextarea,
Typography,
} from 'ant-design-vue';
import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -127,204 +139,107 @@ onMounted(load);
</script> </script>
<template> <template>
<section class="crm-page faq-page" dir="rtl"> <a-flex vertical :gap="16">
<UiPageHeader <a-typography-title :level="3" :style="{ margin: 0 }">
title="پایگاه دانش و سؤالات متداول" پایگاه دانش و سؤالات متداول
description="سؤالات پرتکرار و پاسخ‌های جامع برای تسریع در پاسخگویی پشتیبانان و کاهش تیکت‌های مکرر" </a-typography-title>
<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 :title="editingId ? 'ویرایش مقاله' : 'مقاله جدید'" :bordered="false">
<a-form layout="vertical" @finish="save">
<a-form-item label="پرسش / عنوان مقاله" required>
<a-input
v-model:value="question"
:maxlength="500"
placeholder="مثلاً نحوه فعال‌سازی حساب کاربری..."
style="width: 100%"
/> />
</a-form-item>
<div v-if="error" class="crm-alert crm-alert-danger">{{ error }}</div> <a-form-item label="پاسخ کامل" required>
<div v-if="ok" class="crm-alert crm-alert-success">{{ ok }}</div> <a-textarea
v-model:value="answer"
:rows="4"
placeholder="توضیحات و راهنمای گام‌به‌گام..."
style="width: 100%"
/>
</a-form-item>
<UiCard :title="editingId ? 'ویرایش مقاله' : 'مقاله جدید'" class="editor-card"> <a-row :gutter="[16, 0]" align="bottom">
<form class="crm-form" @submit.prevent="save"> <a-col :xs="24" :md="10">
<UiField label="پرسش / عنوان مقاله" required> <a-form-item label="دسته‌بندی">
<UiInput v-model="question" required maxlength="500" placeholder="مثلاً نحوه فعال‌سازی حساب کاربری..." /> <a-input
</UiField> v-model:value="category"
:maxlength="100"
placeholder="مثلاً مالی، فنی، نصب"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="6">
<a-form-item label="ترتیب نمایش">
<a-input-number v-model:value="position" :min="0" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label=" ">
<a-checkbox v-model:checked="isPublished">منتشرشده در پورتال</a-checkbox>
</a-form-item>
</a-col>
</a-row>
<UiField label="پاسخ کامل" required> <a-form-item>
<UiTextarea v-model="answer" :rows="4" required placeholder="توضیحات و راهنمای گام‌به‌گام..." /> <a-space wrap>
</UiField> <a-button type="primary" html-type="submit" :loading="saving">
<div class="form-grid-extra">
<UiField label="دسته‌بندی">
<UiInput v-model="category" maxlength="100" placeholder="مثلاً مالی، فنی، نصب" />
</UiField>
<UiField label="ترتیب نمایش">
<UiInput v-model.number="position" type="number" min="0" />
</UiField>
<div class="publish-toggle-wrap">
<label class="publish-label">
<input v-model="isPublished" type="checkbox" />
<span>منتشرشده در پورتال</span>
</label>
</div>
</div>
<div class="form-actions-row">
<UiButton type="submit" :loading="saving">
{{ editingId ? 'ذخیره تغییرات' : 'افزودن مقاله' }} {{ editingId ? 'ذخیره تغییرات' : 'افزودن مقاله' }}
</UiButton> </a-button>
<UiButton v-if="editingId" variant="ghost" type="button" @click="resetForm"> <a-button v-if="editingId" @click="resetForm">انصراف</a-button>
انصراف </a-space>
</UiButton> </a-form-item>
</div> </a-form>
</form> </a-card>
</UiCard>
<UiEmptyState <a-spin :spinning="loading">
<a-empty
v-if="!loading && !items.length" v-if="!loading && !items.length"
title="هنوز مقاله‌ای ثبت نشده است" description="هنوز مقاله‌ای ثبت نشده است. با ثبت اولین سؤال و پاسخ، پایگاه دانش را تکمیل کنید."
description="با ثبت اولین سؤال و پاسخ، پایگاه دانش سازمان را تکمیل کنید."
icon="document"
/> />
<a-flex v-else vertical :gap="12">
<div v-else class="articles-list"> <a-card v-for="row in items" :key="row.id" :bordered="false">
<UiCard v-for="row in items" :key="row.id" class="article-card"> <a-row :gutter="[16, 12]" align="top">
<div class="article-content"> <a-col :xs="24" :lg="18">
<div class="article-title-row"> <a-flex vertical :gap="8">
<strong class="article-question">{{ row.question }}</strong> <a-space wrap>
<div class="article-badges"> <a-typography-text strong>{{ row.question }}</a-typography-text>
<UiBadge :variant="row.isPublished ? 'success' : 'neutral'"> <a-tag :color="row.isPublished ? 'success' : 'default'" :bordered="false">
{{ row.isPublished ? 'منتشرشده' : 'پیش‌نویس' }} {{ row.isPublished ? 'منتشرشده' : 'پیش‌نویس' }}
</UiBadge> </a-tag>
<UiBadge v-if="row.category" variant="info"> <a-tag v-if="row.category" color="processing" :bordered="false">
{{ row.category }} {{ row.category }}
</UiBadge> </a-tag>
</div> </a-space>
</div> <a-typography-paragraph type="secondary" :style="{ marginBottom: 0, whiteSpace: 'pre-wrap' }">
<p class="article-answer">{{ row.answer }}</p> {{ row.answer }}
</div> </a-typography-paragraph>
</a-flex>
<div class="article-actions"> </a-col>
<UiButton variant="secondary" size="sm" @click="startEdit(row)"> <a-col :xs="24" :lg="6">
<template #icon> <a-space wrap>
<UiIcon name="pencil" /> <a-button @click="startEdit(row)">
</template> <template #icon><EditOutlined /></template>
ویرایش ویرایش
</UiButton> </a-button>
<UiButton variant="danger" size="sm" @click="remove(row)"> <a-button danger @click="remove(row)">
<template #icon> <template #icon><DeleteOutlined /></template>
<UiIcon name="trash" />
</template>
حذف حذف
</UiButton> </a-button>
</div> </a-space>
</UiCard> </a-col>
</div> </a-row>
</section> </a-card>
</a-flex>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.faq-page {
display: flex;
flex-direction: column;
gap: var(--sp-6);
width: 100%;
max-width: 100%;
}
.editor-card {
padding: var(--sp-6);
}
.form-grid-extra {
display: grid;
grid-template-columns: 1fr 1fr auto;
gap: var(--sp-4);
align-items: flex-end;
}
.publish-toggle-wrap {
display: flex;
align-items: center;
height: var(--control-h, 40px);
}
.publish-label {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
font-size: var(--fs-sm);
color: var(--color-text-secondary);
cursor: pointer;
user-select: none;
}
.form-actions-row {
display: flex;
gap: var(--sp-2);
margin-top: var(--sp-2);
}
.articles-list {
display: flex;
flex-direction: column;
gap: var(--sp-4);
}
.article-card {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: var(--sp-4);
padding: var(--sp-4) var(--sp-5);
}
.article-content {
flex: 1;
display: flex;
flex-direction: column;
gap: var(--sp-2);
}
.article-title-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--sp-3);
}
.article-question {
font-size: var(--fs-md);
font-weight: 700;
color: var(--color-text-primary);
}
.article-badges {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
}
.article-answer {
margin: 0;
font-size: var(--fs-sm);
color: var(--color-text-secondary);
line-height: var(--lh-relaxed);
white-space: pre-wrap;
}
.article-actions {
display: flex;
gap: var(--sp-2);
flex-shrink: 0;
}
@media (max-width: 640px) {
.form-grid-extra {
grid-template-columns: 1fr;
}
.article-card {
flex-direction: column;
align-items: stretch;
}
.article-actions {
justify-content: flex-end;
}
}
</style>
-8
View File
@@ -216,13 +216,6 @@ const pageTitle = computed(() => {
return 'افزودن فاکتور'; return 'افزودن فاکتور';
}); });
const pageSubtitle = computed(() => {
if (mobileStep.value === 2) return 'محصولات و خدمات را اضافه کنید';
if (docMode.value === 'quote') return 'اطلاعات پیش فاکتور را وارد کنید';
if (docMode.value === 'credit') return 'اطلاعات فاکتور برگشتی را وارد کنید';
return 'اطلاعات فاکتور را وارد کنید';
});
const defaultTitle = computed(() => { const defaultTitle = computed(() => {
if (docMode.value === 'quote') return 'پیش فاکتور'; if (docMode.value === 'quote') return 'پیش فاکتور';
if (docMode.value === 'credit') return 'فاکتور برگشتی'; if (docMode.value === 'credit') return 'فاکتور برگشتی';
@@ -1032,7 +1025,6 @@ onMounted(load);
<FileTextOutlined /> <FileTextOutlined />
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title>
<a-typography-text type="secondary">{{ pageSubtitle }}</a-typography-text>
</div> </div>
</a-space> </a-space>
<a-button @click="goBack"> <a-button @click="goBack">
-3
View File
@@ -556,9 +556,6 @@ defineExpose({ toggleSelect, pageCount, statusIcon });
> >
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">فاکتور ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">فاکتور ها</a-typography-title>
<a-typography-text type="secondary">
مدیریت فاکتورهای فروش، پیش فاکتور و خدمات
</a-typography-text>
</div> </div>
<a-space :size="8" @click.stop> <a-space :size="8" @click.stop>
<a-dropdown v-model:open="addOpen"> <a-dropdown v-model:open="addOpen">
-3
View File
@@ -542,9 +542,6 @@ onMounted(load);
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
مسیر لیدها مسیر لیدها
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">
کشیدن کارت برای تغییر وضعیت. از منوی هر ستون می‌توانید نام، ترتیب و حذف را عوض کنید.
</a-typography-text>
</div> </div>
<a-space :size="GAP"> <a-space :size="GAP">
<RouterLink :to="{ name: 'leads' }" custom v-slot="{ navigate }"> <RouterLink :to="{ name: 'leads' }" custom v-slot="{ navigate }">
-3
View File
@@ -505,9 +505,6 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
{{ lead?.title || 'جزئیات لید' }} {{ lead?.title || 'جزئیات لید' }}
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">
{{ lead ? `موبایل ${lead.mobile}` : 'در حال بارگذاری…' }}
</a-typography-text>
</div> </div>
</a-space> </a-space>
<a-space v-if="lead" :size="8" wrap> <a-space v-if="lead" :size="8" wrap>
File diff suppressed because it is too large Load Diff
+98 -187
View File
@@ -3,16 +3,31 @@ import { computed, onMounted, ref } from 'vue';
import { RouterLink, useRouter } from 'vue-router'; import { RouterLink, useRouter } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import {
UiBadge,
UiButton,
UiCard,
UiEmptyState,
UiPageHeader,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import type { LeadFormDto } from '@mento/shared'; import type { LeadFormDto } from '@mento/shared';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Empty as AEmpty,
Flex as AFlex,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Space as ASpace,
Spin as ASpin,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import {
CopyOutlined,
DeleteOutlined,
EditOutlined,
EyeOutlined,
PlusOutlined,
} from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
const router = useRouter(); const router = useRouter();
const loading = ref(false); const loading = ref(false);
@@ -78,201 +93,97 @@ async function copyPublishLink(form: LeadFormDto) {
await navigator.clipboard.writeText(publicUrl(form)); await navigator.clipboard.writeText(publicUrl(form));
} }
function formMeta(form: LeadFormDto) {
const parts = [
`${toFaDigits(form.fields.length)} فیلد سفارشی`,
`${toFaDigits(form.submitCount ?? form.submissionCount ?? 0)} ارسال`,
`${toFaDigits(form.leadCreateCount ?? 0)} لید`,
];
if (form.source) parts.push(`منبع: ${form.source}`);
return parts.join(' · ');
}
const countLabel = computed(() => toFaDigits(forms.value.length)); const countLabel = computed(() => toFaDigits(forms.value.length));
const listEmpty = computed(() => !loading.value && !forms.value.length);
onMounted(load); onMounted(load);
</script> </script>
<template> <template>
<section class="crm-page lead-forms-page" dir="rtl"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="فرم‌ساز وب" <a-typography-title :level="3" :style="{ margin: 0 }">فرم‌ساز وب</a-typography-title>
description="فرم‌های آنلاین بسازید، در وب‌سایت منتشر کنید و لیدها را مستقیم در CRM دریافت کنید." <a-button type="primary" :loading="saving" @click="createForm">
> <template #icon><PlusOutlined /></template>
<template #actions>
<UiButton :loading="saving" @click="createForm">
<template #icon>
<UiIcon name="plus" />
</template>
فرم جدید فرم جدید
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<div v-if="error" class="crm-alert crm-alert-danger">{{ error }}</div> <a-alert v-if="error" type="error" show-icon :message="error" />
<div v-else-if="!loading && forms.length" class="forms-summary"> <a-spin :spinning="loading">
<span class="forms-count-badge">{{ countLabel }} فرم ساخته شده</span> <a-card v-if="listEmpty && !error" :bordered="false">
</div> <a-empty
description="هنوز فرمی نساخته‌اید. با ساخت اولین فرم، می‌توانید در وب‌سایت یا شبکه‌های اجتماعی سرنخ و مشتری جذب کنید."
<UiEmptyState
v-if="!loading && !forms.length"
title="هنوز فرمی نساخته‌اید"
description="با ساخت اولین فرم، می‌توانید در وب‌سایت یا شبکه‌های اجتماعی سرنخ و مشتری جذب کنید."
icon="document"
> >
<template #action> <a-button type="primary" :loading="saving" @click="createForm">
<UiButton :loading="saving" @click="createForm"> <template #icon><PlusOutlined /></template>
<template #icon>
<UiIcon name="plus" />
</template>
ساخت اولین فرم ساخت اولین فرم
</UiButton> </a-button>
</template> </a-empty>
</UiEmptyState> </a-card>
<div v-else class="forms-list"> <a-card v-else-if="!error && forms.length" :bordered="false">
<UiCard v-for="form in forms" :key="form.id" class="form-card"> <a-flex vertical :gap="12">
<div class="form-info"> <a-typography-text type="secondary">
<div class="form-title-row"> {{ countLabel }} فرم ساخته شده
<strong class="form-name">{{ form.name }}</strong> </a-typography-text>
<UiBadge :variant="form.isActive ? 'success' : 'neutral'">
{{ form.isActive ? 'فعال' : 'غیرفعال' }}
</UiBadge>
</div>
<p class="form-meta">
<span>{{ toFaDigits(form.fields.length) }} فیلد سفارشی</span>
<span class="meta-dot">·</span>
<span>{{ toFaDigits(form.submitCount ?? form.submissionCount ?? 0) }} ارسال</span>
<span class="meta-dot">·</span>
<span>{{ toFaDigits(form.leadCreateCount ?? 0) }} لید</span>
<span v-if="form.source" class="meta-dot">·</span>
<span v-if="form.source">منبع: {{ form.source }}</span>
</p>
</div>
<div class="form-actions"> <a-list item-layout="horizontal" :data-source="forms">
<RouterLink :to="{ name: 'lead-form-builder', params: { id: form.id } }"> <template #renderItem="{ item }">
<UiButton variant="secondary" size="sm"> <a-list-item>
<template #icon> <template #actions>
<UiIcon name="pencil" /> <a-space wrap>
</template> <RouterLink
:to="{ name: 'lead-form-builder', params: { id: item.id } }"
custom
v-slot="{ href, navigate }"
>
<a-button :href="href" @click="navigate">
<template #icon><EditOutlined /></template>
ویرایش فیلدها ویرایش فیلدها
</UiButton> </a-button>
</RouterLink> </RouterLink>
<a-button @click="copyPublishLink(item)">
<UiButton variant="secondary" size="sm" @click="copyPublishLink(form)"> <template #icon><CopyOutlined /></template>
<template #icon>
<UiIcon name="megaphone" />
</template>
کپی لینک انتشار کپی لینک انتشار
</UiButton> </a-button>
<a-button :href="item.publicPath" target="_blank" rel="noopener">
<a :href="form.publicPath" target="_blank" rel="noopener" class="preview-link"> <template #icon><EyeOutlined /></template>
<UiButton variant="ghost" size="sm">
<template #icon>
<UiIcon name="eye" />
</template>
پیش‌نمایش پیش‌نمایش
</UiButton> </a-button>
</a> <a-button danger @click="removeForm(item)">
<template #icon><DeleteOutlined /></template>
<UiButton variant="danger" size="sm" @click="removeForm(form)">
<template #icon>
<UiIcon name="trash" />
</template>
حذف حذف
</UiButton> </a-button>
</div> </a-space>
</UiCard> </template>
</div>
</section> <a-list-item-meta :description="formMeta(item)">
<template #title>
<a-space :size="8" align="center" wrap>
<a-typography-text strong>{{ item.name }}</a-typography-text>
<a-tag :color="item.isActive ? 'success' : 'default'" :bordered="false">
{{ item.isActive ? 'فعال' : 'غیرفعال' }}
</a-tag>
</a-space>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</a-flex>
</a-card>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.lead-forms-page {
display: flex;
flex-direction: column;
gap: var(--sp-6);
width: 100%;
max-width: 100%;
}
.forms-summary {
display: flex;
align-items: center;
}
.forms-count-badge {
font-size: var(--fs-sm);
color: var(--color-text-secondary);
background: var(--color-surface-soft);
padding: var(--sp-1) var(--sp-3);
border-radius: var(--radius-full);
border: 1px solid var(--color-border);
}
.forms-list {
display: flex;
flex-direction: column;
gap: var(--sp-4);
}
.form-card {
display: flex;
justify-content: space-between;
align-items: center;
gap: var(--sp-4);
padding: var(--sp-4) var(--sp-5);
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-card:hover {
border-color: var(--color-brand-300, #5eead4);
box-shadow: var(--shadow-sm);
}
.form-info {
display: flex;
flex-direction: column;
gap: var(--sp-1);
}
.form-title-row {
display: flex;
align-items: center;
gap: var(--sp-3);
}
.form-name {
font-size: var(--fs-md);
font-weight: 700;
color: var(--color-text-primary);
}
.form-meta {
margin: 0;
font-size: var(--fs-xs);
color: var(--color-text-secondary);
display: flex;
align-items: center;
gap: var(--sp-2);
}
.meta-dot {
color: var(--color-text-muted);
}
.form-actions {
display: flex;
align-items: center;
gap: var(--sp-2);
flex-wrap: wrap;
}
.preview-link {
text-decoration: none;
}
@media (max-width: 640px) {
.form-card {
flex-direction: column;
align-items: flex-start;
}
.form-actions {
width: 100%;
justify-content: flex-end;
}
}
</style>
-3
View File
@@ -1186,9 +1186,6 @@ onBeforeUnmount(() => {
<a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM">
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">لیدها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">لیدها</a-typography-title>
<a-typography-text type="secondary">
مدیریت و پیگیری تمام لیدهای ورودی
</a-typography-text>
</div> </div>
<a-space :size="8" wrap> <a-space :size="8" wrap>
<a-button :disabled="busy" :loading="pageBusy && busyMessage.includes('خروجی')" @click.stop="exportExcel"> <a-button :disabled="busy" :loading="pageBusy && busyMessage.includes('خروجی')" @click.stop="exportExcel">
-6
View File
@@ -727,13 +727,10 @@ onBeforeUnmount(() => {
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
<CrownOutlined :style="{ color: 'var(--ant-color-warning)' }" /> <CrownOutlined :style="{ color: 'var(--ant-color-warning)' }" />
باشگاه مشتریان باشگاه مشتریان
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">وفاداری، یک رابطه طولانی‌مدت است.</a-typography-text>
</a-flex>
<a-button @click="openSettings"> <a-button @click="openSettings">
<template #icon><SettingOutlined /></template> <template #icon><SettingOutlined /></template>
تنظیمات باشگاه تنظیمات باشگاه
@@ -782,9 +779,6 @@ onBeforeUnmount(() => {
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8" :style="{ marginBottom: '16px' }"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="8" :style="{ marginBottom: '16px' }">
<a-flex vertical :gap="2"> <a-flex vertical :gap="2">
<a-typography-title :level="5" :style="{ margin: 0 }">سطوح باشگاه</a-typography-title> <a-typography-title :level="5" :style="{ margin: 0 }">سطوح باشگاه</a-typography-title>
<a-typography-text type="secondary">
مرتب‌شده از کم‌ترین تا بیشترین آستانه امتیاز
</a-typography-text>
</a-flex> </a-flex>
<a-button v-if="canManage" type="primary" @click="openNewTier"> <a-button v-if="canManage" type="primary" @click="openNewTier">
<template #icon><PlusOutlined /></template> <template #icon><PlusOutlined /></template>
@@ -451,12 +451,7 @@ onUnmounted(() => {
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<!-- Mobile list --> <!-- Mobile list -->
<template v-if="isMobile && mobileView === 'list'"> <template v-if="isMobile && mobileView === 'list'">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون پیامک‌ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون پیامک‌ها</a-typography-title>
<a-typography-text type="secondary">
با قوانین هوشمند، در زمان مناسب پیام مناسب را ارسال کنید.
</a-typography-text>
</a-flex>
<a-card :bordered="false"> <a-card :bordered="false">
<a-flex vertical align="center" :gap="12"> <a-flex vertical align="center" :gap="12">
@@ -807,12 +802,7 @@ onUnmounted(() => {
<!-- Desktop --> <!-- Desktop -->
<template v-else> <template v-else>
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون پیامک‌ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">اتوماسیون پیامک‌ها</a-typography-title>
<a-typography-text type="secondary">
پیامک و ناتیف بعد از رویداد، با تأخیر یا همان لحظه.
</a-typography-text>
</a-flex>
<a-button :disabled="loading" @click="load"> <a-button :disabled="loading" @click="load">
<template #icon><ReloadOutlined /></template> <template #icon><ReloadOutlined /></template>
بروزرسانی بروزرسانی
+257 -311
View File
@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'; import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
import { RouterLink } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import type { import type {
@@ -10,16 +11,32 @@ import type {
MontifyTestResultDto, MontifyTestResultDto,
UpdateMontifyConnectionRequest, UpdateMontifyConnectionRequest,
} from '@mento/shared'; } from '@mento/shared';
import {
UiButton,
UiCard,
UiEmptyState,
UiField,
UiInput,
UiPageHeader,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali'; import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
InputPassword as AInputPassword,
List as AList,
ListItem as AListItem,
Row as ARow,
Space as ASpace,
Spin as ASpin,
Table as ATable,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -41,6 +58,16 @@ const form = reactive(emptyForm());
const anyRunning = computed(() => items.value.some((c) => c.syncStatus === 'running')); const anyRunning = computed(() => items.value.some((c) => c.syncStatus === 'running'));
const orderColumns: TableColumnsType<MontifyOrderDto> = [
{ title: 'فروشگاه', key: 'فروشگاه' },
{ title: 'کد سفارش', key: 'کد سفارش' },
{ title: 'مشتری', key: 'مشتری' },
{ title: 'وضعیت سفارش', key: 'وضعیت سفارش' },
{ title: 'وضعیت پرداخت', key: 'وضعیت پرداخت' },
{ title: 'مبلغ (ریال)', key: 'مبلغ (ریال)' },
{ title: 'تاریخ', key: 'تاریخ' },
];
function errMsg(e: unknown, fallback: string): string { function errMsg(e: unknown, fallback: string): string {
if (axios.isAxiosError(e)) { if (axios.isAxiosError(e)) {
const m = (e.response?.data as { message?: string | string[] })?.message; const m = (e.response?.data as { message?: string | string[] })?.message;
@@ -227,11 +254,11 @@ function statusLabel(c: MontifyConnectionDto): string {
return 'هنوز همگام نشده'; return 'هنوز همگام نشده';
} }
function statusClass(c: MontifyConnectionDto): string { function statusColor(c: MontifyConnectionDto): string {
if (!c.enabled) return 'off'; if (!c.enabled) return 'default';
if (c.syncStatus === 'running') return 'run'; if (c.syncStatus === 'running') return 'processing';
if (c.syncStatus === 'error' || c.lastHealthOk === false) return 'bad'; if (c.syncStatus === 'error' || c.lastHealthOk === false) return 'error';
return 'good'; return 'success';
} }
onMounted(() => void load()); onMounted(() => void load());
@@ -241,70 +268,107 @@ onBeforeUnmount(() => {
</script> </script>
<template> <template>
<div class="page"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="فروشگاه‌های مونتیفای" <a-typography-title :level="3" :style="{ margin: 0 }">
description="اتصال فقط‌خواندنی چند فروشگاه؛ مشتری‌ها به اشخاص وصل می‌شوند و سفارش، آدرس، تراکنش و تعاملات هر مشتری در پرونده‌اش دیده می‌شود" فروشگاه‌های مونتیفای
> </a-typography-title>
<template #actions> <a-button :disabled="loading" @click="load()">
<UiButton variant="secondary" :disabled="loading" @click="load()"> <template #icon><ReloadOutlined /></template>
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<p v-if="ok" class="ok">{{ ok }}</p> <a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<UiCard :title="editingId ? 'ویرایش فروشگاه' : 'افزودن فروشگاه'"> <a-spin :spinning="loading">
<p class="hint"> <a-flex vertical :gap="16">
فروشنده در پنل مونتیفای از «تنظیمات ← یکپارچه‌سازی‌ها ← CRM» توکن صادر می‌کند و <a-card :title="editingId ? 'ویرایش فروشگاه' : 'افزودن فروشگاه'" :bordered="false">
Base URL، Token و Store ID را به شما می‌دهد. توکن فقط روی سرور و به‌صورت رمزشده نگهداری می‌شود. <a-typography-paragraph type="secondary">
</p> فروشنده در پنل مونتیفای از «تنظیمات ← یکپارچه‌سازی‌ها ← CRM» توکن صادر می‌کند و Base URL،
<div class="form-grid"> Token و Store ID را به شما می‌دهد. توکن فقط روی سرور و به‌صورت رمزشده نگهداری می‌شود.
<UiField label="نام فروشگاه"> </a-typography-paragraph>
<UiInput v-model="form.label" placeholder="مثلاً فروشگاه شعبه ۱" /> <a-form layout="vertical" @finish="save">
</UiField> <a-row :gutter="[16, 0]">
<UiField label="Base URL"> <a-col :xs="24" :md="12">
<UiInput v-model="form.baseUrl" dir="ltr" placeholder="https://store1.montify.com/api/v1" /> <a-form-item label="نام فروشگاه" required>
</UiField> <a-input
<UiField :label="editingId ? 'توکن جدید (خالی = بدون تغییر)' : 'Token'"> v-model:value="form.label"
<UiInput v-model="form.token" type="password" dir="ltr" placeholder="mk_live_…" /> placeholder="مثلاً فروشگاه شعبه ۱"
</UiField> style="width: 100%"
<UiField label="Store ID">
<UiInput v-model="form.storeId" dir="ltr" placeholder="b2f1e4a0-…" />
</UiField>
</div>
<div class="form-actions">
<UiButton :loading="saving" @click="save">
{{ editingId ? 'ذخیره تغییرات' : 'افزودن فروشگاه' }}
</UiButton>
<UiButton v-if="editingId" variant="secondary" @click="resetForm">انصراف</UiButton>
</div>
</UiCard>
<UiCard title="فروشگاه‌های متصل">
<UiEmptyState
v-if="!loading && !items.length"
title="فروشگاهی وصل نشده"
description="اطلاعات اتصال هر فروشگاه را در فرم بالا وارد کنید."
/> />
<div v-else class="list"> </a-form-item>
<article v-for="c in items" :key="c.id" class="item"> </a-col>
<div class="info"> <a-col :xs="24" :md="12">
<div class="title-row"> <a-form-item label="Base URL" required>
<strong>{{ c.label }}</strong> <a-input
<span class="badge" :class="statusClass(c)">{{ statusLabel(c) }}</span> v-model:value="form.baseUrl"
</div> dir="ltr"
<p class="muted ltr">{{ c.baseUrl }}</p> placeholder="https://store1.montify.com/api/v1"
<p class="muted"> style="width: 100%"
توکن {{ c.tokenMasked }} />
<template v-if="c.storeId"> · Store ID {{ c.storeId }}</template> </a-form-item>
· {{ toFaDigits(c.linkedCustomers) }} مشتری </a-col>
· {{ toFaDigits(c.orders) }} سفارش <a-col :xs="24" :md="12">
</p> <a-form-item
<p class="muted"> :label="editingId ? 'توکن جدید (خالی = بدون تغییر)' : 'Token'"
:required="!editingId"
>
<a-input-password
v-model:value="form.token"
dir="ltr"
placeholder="mk_live_…"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item label="Store ID">
<a-input
v-model:value="form.storeId"
dir="ltr"
placeholder="b2f1e4a0-…"
style="width: 100%"
/>
</a-form-item>
</a-col>
</a-row>
<a-form-item>
<a-space wrap>
<a-button type="primary" html-type="submit" :loading="saving">
{{ editingId ? 'ذخیره تغییرات' : 'افزودن فروشگاه' }}
</a-button>
<a-button v-if="editingId" @click="resetForm">انصراف</a-button>
</a-space>
</a-form-item>
</a-form>
</a-card>
<a-card title="فروشگاه‌های متصل" :bordered="false">
<a-empty
v-if="!loading && !items.length"
description="فروشگاهی وصل نشده. اطلاعات اتصال هر فروشگاه را در فرم بالا وارد کنید."
/>
<a-flex v-else vertical :gap="12">
<a-card v-for="c in items" :key="c.id" type="inner">
<a-row :gutter="[16, 12]" align="top">
<a-col :xs="24" :lg="14">
<a-flex vertical :gap="4">
<a-space wrap>
<a-typography-text strong>{{ c.label }}</a-typography-text>
<a-tag :color="statusColor(c)" :bordered="false">{{ statusLabel(c) }}</a-tag>
</a-space>
<a-typography-text type="secondary" dir="ltr">{{ c.baseUrl }}</a-typography-text>
<a-typography-text type="secondary">
توکن
<span dir="ltr">{{ c.tokenMasked }}</span>
<template v-if="c.storeId">
· Store ID <span dir="ltr">{{ c.storeId }}</span>
</template>
· {{ toFaDigits(c.linkedCustomers) }} مشتری · {{ toFaDigits(c.orders) }} سفارش
</a-typography-text>
<a-typography-text type="secondary">
{{ {{
c.lastSyncAt c.lastSyncAt
? `آخرین همگام‌سازی ${formatJalaliNumeric(new Date(c.lastSyncAt))}` ? `آخرین همگام‌سازی ${formatJalaliNumeric(new Date(c.lastSyncAt))}`
@@ -314,259 +378,141 @@ onBeforeUnmount(() => {
<template v-if="c.lastWebhookAt"> <template v-if="c.lastWebhookAt">
(آخرین رویداد {{ formatJalaliNumeric(new Date(c.lastWebhookAt)) }}) (آخرین رویداد {{ formatJalaliNumeric(new Date(c.lastWebhookAt)) }})
</template> </template>
</p> </a-typography-text>
<p v-if="c.lastSyncResult" class="muted"> <a-typography-text v-if="c.lastSyncResult" type="secondary">
{{ c.syncStatus === 'running' ? 'پیشرفت' : 'نتیجه' }}: {{ c.syncStatus === 'running' ? 'پیشرفت' : 'نتیجه' }}:
{{ toFaDigits(c.lastSyncResult.customersFetched) }} مشتری خوانده شد {{ toFaDigits(c.lastSyncResult.customersFetched) }} مشتری خوانده شد ({{
({{ toFaDigits(c.lastSyncResult.customersCreated) }} شخص جدید)، toFaDigits(c.lastSyncResult.customersCreated)
{{ toFaDigits(c.lastSyncResult.ordersFetched) }} سفارش، }}
شخص جدید)، {{ toFaDigits(c.lastSyncResult.ordersFetched) }} سفارش،
{{ toFaDigits(c.lastSyncResult.transactionsFetched) }} تراکنش {{ toFaDigits(c.lastSyncResult.transactionsFetched) }} تراکنش
<template v-if="c.lastSyncResult.errors.length"> <template v-if="c.lastSyncResult.errors.length">
· {{ toFaDigits(c.lastSyncResult.errors.length) }} خطا · {{ toFaDigits(c.lastSyncResult.errors.length) }} خطا
</template> </template>
</p> </a-typography-text>
<p v-if="c.lastError" class="warn">{{ c.lastError }}</p> <a-alert
<div v-if="diagnoses[c.id]" class="diag"> v-if="c.lastError"
<p class="muted"> type="warning"
بررسی مسیرها show-icon
<template v-if="diagnoses[c.id]!.customerId"> :message="c.lastError"
(با مشتری {{ diagnoses[c.id]!.customerId }}) />
<a-card v-if="diagnoses[c.id]" type="inner" title="بررسی مسیرها">
<a-typography-text
v-if="diagnoses[c.id]!.customerId"
type="secondary"
>
با مشتری {{ diagnoses[c.id]!.customerId }}
</a-typography-text>
<a-list :data-source="diagnoses[c.id]!.checks">
<template #renderItem="{ item: ch }">
<a-list-item>
<a-flex vertical :gap="4" style="width: 100%">
<a-space wrap>
<a-tag :color="ch.ok ? 'success' : 'error'" :bordered="false">
{{ ch.ok ? 'موفق' : 'ناموفق' }}
</a-tag>
<a-typography-text strong>{{ ch.name }}</a-typography-text>
<a-typography-text type="secondary">
{{ ch.status || 'خطای شبکه' }}
</a-typography-text>
</a-space>
<a-typography-text type="secondary" dir="ltr" code>
{{ ch.path }}
</a-typography-text>
<a-typography-text type="secondary">{{ ch.info }}</a-typography-text>
</a-flex>
</a-list-item>
</template> </template>
</p> </a-list>
<ul> </a-card>
<li v-for="ch in diagnoses[c.id]!.checks" :key="ch.path" :class="ch.ok ? 'ok-line' : 'bad-line'"> </a-flex>
<strong>{{ ch.ok ? '✓' : '✗' }} {{ ch.name }}</strong> </a-col>
<span class="code">{{ ch.status || 'خطای شبکه' }}</span> <a-col :xs="24" :lg="10">
<span class="ltr path">{{ ch.path }}</span> <a-space wrap>
<span class="info">{{ ch.info }}</span> <a-button :loading="busyId === c.id" @click="test(c)">تست اتصال</a-button>
</li> <a-button :loading="busyId === c.id" @click="diagnose(c)">بررسی مسیرها</a-button>
</ul> <a-button
</div> type="primary"
</div>
<div class="actions">
<UiButton size="sm" variant="secondary" :loading="busyId === c.id" @click="test(c)">
تست اتصال
</UiButton>
<UiButton size="sm" variant="secondary" :loading="busyId === c.id" @click="diagnose(c)">
بررسی مسیرها
</UiButton>
<UiButton
size="sm"
:disabled="!c.enabled" :disabled="!c.enabled"
@click="sync(c, 'incremental')" @click="sync(c, 'incremental')"
> >
همگام‌سازی همگام‌سازی
</UiButton> </a-button>
<UiButton <a-button :disabled="!c.enabled" @click="sync(c, 'full')">
size="sm"
variant="secondary"
:disabled="!c.enabled"
@click="sync(c, 'full')"
>
همگام‌سازی کامل همگام‌سازی کامل
</UiButton> </a-button>
<UiButton size="sm" variant="secondary" :disabled="!c.enabled" @click="toggleWebhook(c)"> <a-button :disabled="!c.enabled" @click="toggleWebhook(c)">
{{ c.webhookRegistered ? 'حذف وب‌هوک' : 'ثبت وب‌هوک' }} {{ c.webhookRegistered ? 'حذف وب‌هوک' : 'ثبت وب‌هوک' }}
</UiButton> </a-button>
<UiButton size="sm" variant="secondary" @click="startEdit(c)">ویرایش</UiButton> <a-button @click="startEdit(c)">ویرایش</a-button>
<UiButton size="sm" variant="secondary" @click="toggleEnabled(c)"> <a-button @click="toggleEnabled(c)">
{{ c.enabled ? 'غیرفعال' : 'فعال' }} {{ c.enabled ? 'غیرفعال' : 'فعال' }}
</UiButton> </a-button>
<UiButton size="sm" variant="secondary" @click="remove(c)">حذف</UiButton> <a-button danger @click="remove(c)">حذف</a-button>
</div> </a-space>
</article> </a-col>
</div> </a-row>
</UiCard> </a-card>
</a-flex>
</a-card>
<UiCard title="آخرین سفارش‌های واردشده"> <a-card title="آخرین سفارش‌های واردشده" :bordered="false">
<UiEmptyState <a-empty
v-if="!orders.length" v-if="!orders.length"
title="سفارشی نیست" description="سفارشی نیست. همگام‌سازی را بزنید یا وب‌هوک را ثبت کنید."
description="همگام‌سازی را بزنید یا وب‌هوک را ثبت کنید."
/> />
<div v-else class="table-wrap"> <a-table
<table> v-else
<thead> :columns="orderColumns"
<tr> :data-source="orders"
<th>فروشگاه</th> :pagination="false"
<th>کد سفارش</th> row-key="id"
<th>مشتری</th> :scroll="{ x: 'max-content' }"
<th>وضعیت سفارش</th> >
<th>وضعیت پرداخت</th> <template #bodyCell="{ column, record }">
<th>مبلغ (ریال)</th> <template v-if="column.key === 'فروشگاه'">
<th>تاریخ</th> {{ (record as MontifyOrderDto).connectionLabel }}
</tr> </template>
</thead> <template v-else-if="column.key === 'کد سفارش'">
<tbody> {{
<tr v-for="o in orders" :key="o.id"> (record as MontifyOrderDto).orderReference ||
<td>{{ o.connectionLabel }}</td> `#${(record as MontifyOrderDto).externalId}`
<td>{{ o.orderReference || `#${o.externalId}` }}</td> }}
<td> </template>
<RouterLink v-if="o.personId" :to="`/contacts/people/${o.personId}`"> <template v-else-if="column.key === 'مشتری'">
{{ o.personName || 'مشاهده' }} <RouterLink
v-if="(record as MontifyOrderDto).personId"
:to="`/contacts/people/${(record as MontifyOrderDto).personId}`"
>
{{ (record as MontifyOrderDto).personName || 'مشاهده' }}
</RouterLink> </RouterLink>
<span v-else>—</span> <span v-else>—</span>
</td> </template>
<td>{{ o.orderStatus || '—' }}</td> <template v-else-if="column.key === 'وضعیت سفارش'">
<td>{{ o.paymentStatus || '—' }}</td> {{ (record as MontifyOrderDto).orderStatus || '—' }}
<td>{{ formatAmount(o.discountTotalPrice ?? o.totalPrice) }}</td> </template>
<td>{{ o.createdAt ? formatJalaliNumeric(new Date(o.createdAt)) : '—' }}</td> <template v-else-if="column.key === 'وضعیت پرداخت'">
</tr> {{ (record as MontifyOrderDto).paymentStatus || '—' }}
</tbody> </template>
</table> <template v-else-if="column.key === 'مبلغ (ریال)'">
</div> {{
</UiCard> formatAmount(
</div> (record as MontifyOrderDto).discountTotalPrice ??
(record as MontifyOrderDto).totalPrice,
)
}}
</template>
<template v-else-if="column.key === 'تاریخ'">
{{
(record as MontifyOrderDto).createdAt
? formatJalaliNumeric(new Date((record as MontifyOrderDto).createdAt!))
: '—'
}}
</template>
</template>
</a-table>
</a-card>
</a-flex>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.page {
display: grid;
gap: 1rem;
}
.hint,
.muted {
color: #64748b;
font-size: 0.88rem;
line-height: 1.7;
margin: 0;
}
.ltr {
direction: ltr;
text-align: right;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin: 0.75rem 0;
}
.form-actions {
display: flex;
gap: 0.5rem;
}
.list {
display: grid;
gap: 0.75rem;
}
.item {
display: flex;
justify-content: space-between;
gap: 0.75rem;
padding: 0.85rem;
border: 1px solid #eef2f7;
border-radius: var(--radius);
}
.info {
display: grid;
gap: 0.25rem;
min-width: 0;
}
.title-row {
display: flex;
align-items: center;
gap: 0.5rem;
}
.badge {
font-size: 0.75rem;
padding: 0.1rem 0.5rem;
border-radius: 999px;
background: #f1f5f9;
color: #475569;
}
.badge.good {
background: #dcfce7;
color: #166534;
}
.badge.bad {
background: #fee2e2;
color: #991b1b;
}
.badge.run {
background: #e0f2fe;
color: #075985;
}
.actions {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
align-content: start;
justify-content: end;
max-width: 340px;
}
.diag {
margin-top: 0.4rem;
padding: 0.6rem;
background: #f8fafc;
border-radius: var(--radius);
}
.diag ul {
list-style: none;
margin: 0.3rem 0 0;
padding: 0;
display: grid;
gap: 0.35rem;
font-size: 0.82rem;
}
.diag li {
display: grid;
gap: 0.1rem;
}
.diag .code {
font-weight: 700;
}
.diag .path,
.diag .info {
color: #64748b;
word-break: break-all;
}
.ok-line strong {
color: #166534;
}
.bad-line strong {
color: #991b1b;
}
.warn {
color: #b45309;
font-size: 0.85rem;
margin: 0;
}
.error {
color: #b91c1c;
font-weight: 600;
}
.ok {
color: #0f766e;
font-weight: 600;
}
.table-wrap {
overflow: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th,
td {
text-align: right;
padding: 0.55rem;
border-bottom: 1px solid #eef2f7;
}
th {
color: #64748b;
font-size: 0.8rem;
}
@media (max-width: 800px) {
.form-grid {
grid-template-columns: 1fr;
}
.item {
flex-direction: column;
}
.actions {
max-width: none;
justify-content: start;
}
}
</style>
+42 -15
View File
@@ -790,12 +790,7 @@ onBeforeUnmount(() => {
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">یادداشت‌ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">یادداشت‌ها</a-typography-title>
<a-typography-text type="secondary">
فکر کنید، یادداشت کنید، هیچ چیز را فراموش نکنید.
</a-typography-text>
</a-flex>
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" /> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
@@ -896,7 +891,7 @@ onBeforeUnmount(() => {
</a-button> </a-button>
</a-empty> </a-empty>
<a-row v-else :gutter="[12, 12]" align="top"> <a-row v-else :gutter="[12, 12]" align="stretch">
<a-col <a-col
v-for="note in notes" v-for="note in notes"
:key="note.id" :key="note.id"
@@ -919,17 +914,27 @@ onBeforeUnmount(() => {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: `${token.marginXS}px`, gap: `${token.marginXS}px`,
minHeight: viewMode === 'list' ? undefined : '88px', width: '100%',
aspectRatio: viewMode === 'list' ? undefined : '1 / 1',
overflow: 'hidden',
boxSizing: 'border-box',
}" }"
@click="openEditor('default', note)" @click="openEditor('default', note)"
@keydown.enter="openEditor('default', note)" @keydown.enter="openEditor('default', note)"
> >
<a-flex justify="space-between" align="flex-start" :gap="token.marginXXS"> <a-flex
justify="space-between"
align="flex-start"
:gap="token.marginXXS"
:style="{ flexShrink: 0 }"
>
<a-typography-text <a-typography-text
v-if="note.title" v-if="note.title"
strong strong
:ellipsis="viewMode === 'grid'"
:style="{ :style="{
flex: 1, flex: 1,
minWidth: 0,
fontSize: `${token.fontSizeLG}px`, fontSize: `${token.fontSizeLG}px`,
lineHeight: token.lineHeight, lineHeight: token.lineHeight,
wordBreak: 'break-word', wordBreak: 'break-word',
@@ -971,14 +976,25 @@ onBeforeUnmount(() => {
</a-space> </a-space>
</a-flex> </a-flex>
<div
:style="{
flex: 1,
minHeight: 0,
overflow: 'hidden',
display: 'flex',
flexDirection: 'column',
gap: `${token.marginXXS}px`,
}"
>
<a-flex <a-flex
v-if="note.checklist?.length" v-if="note.checklist?.length"
vertical vertical
:gap="token.marginXXS" :gap="token.marginXXS"
:style="{ overflow: 'hidden' }"
@click.stop @click.stop
> >
<a-checkbox <a-checkbox
v-for="item in note.checklist.slice(0, 6)" v-for="item in note.checklist.slice(0, viewMode === 'list' ? 6 : 4)"
:key="item.id" :key="item.id"
:checked="item.done" :checked="item.done"
@change="toggleCardChecklist(note, item.id)" @change="toggleCardChecklist(note, item.id)"
@@ -986,20 +1002,24 @@ onBeforeUnmount(() => {
<a-typography-text <a-typography-text
:delete="item.done" :delete="item.done"
:type="item.done ? 'secondary' : undefined" :type="item.done ? 'secondary' : undefined"
:ellipsis="viewMode === 'grid'"
> >
{{ item.text }} {{ item.text }}
</a-typography-text> </a-typography-text>
</a-checkbox> </a-checkbox>
<a-typography-text <a-typography-text
v-if="note.checklist.length > 6" v-if="note.checklist.length > (viewMode === 'list' ? 6 : 4)"
type="secondary" type="secondary"
> >
+{{ toFaDigits(note.checklist.length - 6) }} مورد دیگر +{{
toFaDigits(note.checklist.length - (viewMode === 'list' ? 6 : 4))
}}
مورد دیگر
</a-typography-text> </a-typography-text>
</a-flex> </a-flex>
<a-typography-paragraph <a-typography-paragraph
v-else-if="note.body" v-else-if="note.body"
:ellipsis="{ rows: 6 }" :ellipsis="{ rows: viewMode === 'list' ? 6 : 4 }"
:style="{ :style="{
marginBottom: 0, marginBottom: 0,
color: token.colorText, color: token.colorText,
@@ -1016,9 +1036,10 @@ onBeforeUnmount(() => {
:alt="firstImage(note)!.fileName" :alt="firstImage(note)!.fileName"
:style="{ :style="{
width: '100%', width: '100%',
maxHeight: '140px', maxHeight: viewMode === 'list' ? '140px' : '72px',
objectFit: 'cover', objectFit: 'cover',
borderRadius: `${token.borderRadius}px`, borderRadius: `${token.borderRadius}px`,
flexShrink: 0,
}" }"
/> />
@@ -1038,6 +1059,7 @@ onBeforeUnmount(() => {
:style="{ width: '100%', height: '32px' }" :style="{ width: '100%', height: '32px' }"
/> />
</div> </div>
</div>
<a-flex <a-flex
v-if=" v-if="
@@ -1048,6 +1070,7 @@ onBeforeUnmount(() => {
" "
wrap="wrap" wrap="wrap"
:gap="token.marginXXS" :gap="token.marginXXS"
:style="{ flexShrink: 0, overflow: 'hidden', maxHeight: '48px' }"
> >
<a-tag <a-tag
v-for="tag in note.tags ?? []" v-for="tag in note.tags ?? []"
@@ -1084,7 +1107,8 @@ onBeforeUnmount(() => {
<a-typography-text <a-typography-text
type="secondary" type="secondary"
:style="{ fontSize: `${token.fontSizeSM}px` }" :ellipsis="true"
:style="{ fontSize: `${token.fontSizeSM}px`, flexShrink: 0 }"
> >
{{ formatNoteTime(note.updatedAt) }} {{ formatNoteTime(note.updatedAt) }}
<template v-if="note.person"> · {{ note.person.fullName }}</template> <template v-if="note.person"> · {{ note.person.fullName }}</template>
@@ -1107,13 +1131,16 @@ onBeforeUnmount(() => {
border: `1px dashed ${token.colorBorder}`, border: `1px dashed ${token.colorBorder}`,
padding: `${token.padding}px`, padding: `${token.padding}px`,
cursor: 'pointer', cursor: 'pointer',
minHeight: '88px', width: '100%',
aspectRatio: viewMode === 'list' ? undefined : '1 / 1',
minHeight: viewMode === 'list' ? '88px' : undefined,
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
gap: `${token.marginXS}px`, gap: `${token.marginXS}px`,
background: token.colorBgContainer, background: token.colorBgContainer,
boxSizing: 'border-box',
}" }"
@click="openEditor()" @click="openEditor()"
@keydown.enter="openEditor()" @keydown.enter="openEditor()"
+111 -180
View File
@@ -3,10 +3,32 @@ import { computed, onMounted, ref } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { UiButton, UiCard, UiEmptyState, UiField, UiInput, UiModal, UiPageHeader } from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import PipelineMergeWizard from '@/components/pipeline/PipelineMergeWizard.vue'; import PipelineMergeWizard from '@/components/pipeline/PipelineMergeWizard.vue';
import type { PipelineDto } from '@mento/shared'; import type { PipelineDto } from '@mento/shared';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Divider as ADivider,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Modal as AModal,
Row as ARow,
Space as ASpace,
Spin as ASpin,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import { PlusOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
type PipelineListItem = PipelineDto & { type PipelineListItem = PipelineDto & {
dealCount?: number | null; dealCount?: number | null;
@@ -25,6 +47,13 @@ const deleteCountReady = ref(false);
const deleting = ref(false); const deleting = ref(false);
const canMerge = computed(() => pipelines.value.length >= 2); const canMerge = computed(() => pipelines.value.length >= 2);
const listEmpty = computed(() => !loading.value && !pipelines.value.length);
function pipelineMeta(pipeline: PipelineListItem) {
const parts = [`${toFaDigits(pipeline.stages.length)} مرحله`];
if (pipeline.dealCount != null) parts.push(`${toFaDigits(pipeline.dealCount)} معامله`);
return parts.join(' · ');
}
function apiError(e: unknown, fallback: string) { function apiError(e: unknown, fallback: string) {
if (axios.isAxiosError(e)) { if (axios.isAxiosError(e)) {
@@ -73,11 +102,11 @@ async function createPipeline() {
function deletePrompt(pipeline: PipelineListItem) { function deletePrompt(pipeline: PipelineListItem) {
if (!deleteCountReady.value) return 'در حال شمارش معاملات این مسیر…'; if (!deleteCountReady.value) return 'در حال شمارش معاملات این مسیر…';
const count = pipeline.dealCount ?? 0; const count = pipeline.dealCount ?? 0;
const name = pipeline.name; const pipelineName = pipeline.name;
if (count > 0) { if (count > 0) {
return `مسیر «${name}» شامل ${toFaDigits(count)} معامله است. با حذف، این معاملات هم پاک می‌شوند. از حذف مطمئن هستید؟`; return `مسیر «${pipelineName}» شامل ${toFaDigits(count)} معامله است. با حذف، این معاملات هم پاک می‌شوند. از حذف مطمئن هستید؟`;
} }
return `مسیر «${name}» معامله‌ای ندارد. از حذف آن مطمئن هستید؟`; return `مسیر «${pipelineName}» معامله‌ای ندارد. از حذف آن مطمئن هستید؟`;
} }
async function openDelete(pipeline: PipelineListItem) { async function openDelete(pipeline: PipelineListItem) {
@@ -146,195 +175,97 @@ onMounted(load);
</script> </script>
<template> <template>
<section class="crm-page"> <a-flex vertical :gap="16">
<UiPageHeader <a-typography-title :level="3" :style="{ margin: 0 }">تنظیمات مسیر فروش</a-typography-title>
title="تنظیمات مسیر فروش"
lead="مدیریت کاریزهای فروش و آماده‌سازی ادغام مسیرها" <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 = ''" />
<a-card :bordered="false">
<a-form layout="vertical" @finish="createPipeline">
<a-divider orientation="right">کاریز جدید</a-divider>
<a-row :gutter="[16, 0]">
<a-col :xs="24" :md="12">
<a-form-item label="نام کاریز" required>
<a-input
v-model:value="name"
placeholder="مثلاً فروش سازمانی"
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item label=" ">
<a-button type="primary" html-type="submit" :loading="saving">
<template #icon><PlusOutlined /></template>
افزودن کاریز
</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
<a-divider orientation="right">فهرست کاریزها</a-divider>
<a-spin :spinning="loading">
<a-empty
v-if="listEmpty"
description="کاریزی تعریف نشده. اولین مسیر فروش را اضافه کنید."
/> />
<p v-if="okMsg" class="ok">{{ okMsg }}</p> <a-list v-else-if="pipelines.length" item-layout="horizontal" :data-source="pipelines">
<p v-if="error" class="error">{{ error }}</p> <template #renderItem="{ item }">
<p v-else-if="loading" class="muted">در حال بارگذاری…</p> <a-list-item>
<template #actions>
<form class="crm-form" @submit.prevent="createPipeline"> <a-space wrap>
<UiCard> <a-button :disabled="!canMerge" @click="openMerge(item)">ادغام</a-button>
<template #header> <a-button danger @click="openDelete(item)">حذف</a-button>
<div class="card-title"> </a-space>
<UiIcon name="plus" :size="18" />
<h3>کاریز جدید</h3>
</div>
</template> </template>
<div class="form-grid"> <a-list-item-meta :description="pipelineMeta(item)">
<UiField label="نام کاریز" required for-id="pipeline-name"> <template #title>
<UiInput id="pipeline-name" v-model="name" required placeholder="مثلاً فروش سازمانی" /> <a-space wrap>
</UiField> <a-typography-text strong>{{ item.name }}</a-typography-text>
</div> <a-tag v-if="item.isDefault" color="processing" :bordered="false">پیش‌فرض</a-tag>
<template #footer> </a-space>
<UiButton type="submit" :loading="saving">افزودن کاریز</UiButton>
</template> </template>
</UiCard> </a-list-item-meta>
</form> </a-list-item>
<div v-if="pipelines.length" class="list">
<UiCard v-for="pipeline in pipelines" :key="pipeline.id" padding="sm" class="pipeline-card">
<div class="row">
<span class="dot" aria-hidden="true" />
<div class="info">
<div class="title-row">
<strong>{{ pipeline.name }}</strong>
<em v-if="pipeline.isDefault">پیش‌فرض</em>
</div>
<span class="muted">
{{ toFaDigits(pipeline.stages.length) }} مرحله
<template v-if="pipeline.dealCount != null">
· {{ toFaDigits(pipeline.dealCount) }} معامله
</template> </template>
</span> </a-list>
</div> </a-spin>
<div class="ops"> </a-card>
<UiButton
size="sm"
variant="ghost"
:disabled="!canMerge"
@click="openMerge(pipeline)"
>
ادغام
</UiButton>
<UiButton size="sm" variant="danger" @click="openDelete(pipeline)">
حذف
</UiButton>
</div>
</div>
</UiCard>
</div>
<UiEmptyState <a-modal
v-else-if="!loading"
title="کاریزی تعریف نشده."
description="اولین مسیر فروش را اضافه کنید."
/>
<UiModal
:open="!!deleteTarget" :open="!!deleteTarget"
title="حذف کاریز" title="حذف کاریز"
@close="closeDelete" :confirm-loading="deleting"
ok-text="حذف کاریز"
cancel-text="انصراف"
ok-type="danger"
:ok-button-props="{ disabled: !deleteCountReady }"
destroy-on-close
@ok="confirmDelete"
@cancel="closeDelete"
> >
<p v-if="deleteTarget" class="confirm">{{ deletePrompt(deleteTarget) }}</p> <a-typography-text v-if="deleteTarget">
<template #footer> {{ deletePrompt(deleteTarget) }}
<UiButton variant="ghost" :disabled="deleting" @click="closeDelete">انصراف</UiButton> </a-typography-text>
<UiButton </a-modal>
variant="danger"
:loading="deleting"
:disabled="!deleteCountReady"
@click="confirmDelete"
>
حذف کاریز
</UiButton>
</template>
</UiModal>
<UiModal :open="mergeOpen" title="ادغام کاریز" @close="closeMerge"> <a-modal
v-model:open="mergeOpen"
title="ادغام کاریز"
:footer="null"
width="720px"
destroy-on-close
@cancel="closeMerge"
>
<PipelineMergeWizard <PipelineMergeWizard
:open="mergeOpen" :open="mergeOpen"
:source-id="mergeSourceId" :source-id="mergeSourceId"
@close="closeMerge" @close="closeMerge"
@done="onMergeDone" @done="onMergeDone"
/> />
</UiModal> </a-modal>
</section> </a-flex>
</template> </template>
<style scoped>
.crm-page {
display: grid;
gap: 1rem;
}
.card-title {
display: flex;
align-items: center;
gap: 0.45rem;
}
.card-title h3 {
margin: 0;
font-size: 1rem;
}
.form-grid {
display: grid;
gap: 0.75rem;
grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
align-items: end;
}
.list {
display: grid;
gap: 0.65rem;
}
.row {
display: flex;
align-items: center;
gap: 0.65rem;
flex-wrap: wrap;
}
.dot {
width: 0.7rem;
height: 0.7rem;
border-radius: 50%;
flex-shrink: 0;
background: var(--accent);
}
.info {
flex: 1 1 12rem;
display: grid;
gap: 0.2rem;
min-width: 0;
}
.title-row {
display: flex;
align-items: center;
gap: 0.45rem;
flex-wrap: wrap;
}
.title-row em {
font-style: normal;
font-size: 0.75rem;
padding: 0.1rem 0.45rem;
border-radius: 999px;
background: var(--accent-soft);
color: var(--accent);
}
.ops {
display: flex;
flex-wrap: wrap;
gap: 0.35rem;
}
.muted {
color: var(--muted);
font-size: 0.85rem;
}
.confirm {
margin: 0;
line-height: 1.8;
color: #0f172a;
}
.ok {
color: #0f766e;
margin: 0;
}
.error {
color: #b91c1c;
margin: 0;
}
</style>
-3
View File
@@ -255,9 +255,6 @@ onMounted(async () => {
<a-breadcrumb-item>{{ title }}</a-breadcrumb-item> <a-breadcrumb-item>{{ title }}</a-breadcrumb-item>
</a-breadcrumb> </a-breadcrumb>
<a-typography-title :level="3" :style="{ margin: 0 }">{{ title }}</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">{{ title }}</a-typography-title>
<a-typography-text type="secondary">
تعریف و ویرایش کالا و خدمات، قیمت‌گذاری و مدیریت موجودی انبار
</a-typography-text>
</a-flex> </a-flex>
<a-space :size="8" wrap> <a-space :size="8" wrap>
<a-button type="primary" :loading="saving" @click="submit"> <a-button type="primary" :loading="saving" @click="submit">
@@ -407,9 +407,6 @@ onMounted(load);
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">محصولات</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">محصولات</a-typography-title>
<a-typography-text type="secondary">
مدیریت محصولات، قیمت‌ها و موجودی
</a-typography-text>
</div> </div>
<a-space :size="8" wrap @click.stop> <a-space :size="8" wrap @click.stop>
<a-button :disabled="busy" :loading="pageBusy" @click="exportExcel"> <a-button :disabled="busy" :loading="pageBusy" @click="exportExcel">
+190 -282
View File
@@ -6,7 +6,37 @@ import { api } from '@/lib/api';
import { canAssignToOthers } from '@/lib/assign-access'; import { canAssignToOthers } from '@/lib/assign-access';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
import type { OrgUserDto, ProjectCardDto } from '@mento/shared'; import type { OrgUserDto, ProjectCardDto } from '@mento/shared';
import UiIcon from '@/components/UiIcon.vue'; import {
Affix as AAffix,
Alert as AAlert,
Breadcrumb as ABreadcrumb,
BreadcrumbItem as ABreadcrumbItem,
Button as AButton,
Card as ACard,
Col as ACol,
Descriptions as ADescriptions,
DescriptionsItem as ADescriptionsItem,
Divider as ADivider,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
Row as ARow,
Select as ASelect,
Space as ASpace,
Spin as ASpin,
Textarea as ATextarea,
Typography,
} from 'ant-design-vue';
import {
CheckOutlined,
CloseOutlined,
DeleteOutlined,
FileTextOutlined,
SaveOutlined,
} from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@@ -43,6 +73,29 @@ const tagsRaw = ref('');
const selectedAssigneeIds = ref<string[]>([]); const selectedAssigneeIds = ref<string[]>([]);
const users = ref<OrgUserDto[]>([]); const users = ref<OrgUserDto[]>([]);
const userOptions = computed(() =>
users.value.map((u) => ({ value: u.id, label: u.fullName })),
);
const parsedTags = computed(() => parseTags(tagsRaw.value));
const summaryItems = computed(() => [
{ label: 'عنوان', value: title.value.trim() || '—' },
{ label: 'برچسب‌ها', value: parsedTags.value.length ? parsedTags.value.join('، ') : '—' },
{
label: 'مسئولان',
value: selectedAssigneeIds.value.length
? users.value
.filter((u) => selectedAssigneeIds.value.includes(u.id))
.map((u) => u.fullName)
.join('، ') || `${selectedAssigneeIds.value.length} نفر`
: '—',
},
{ label: 'یادداشت', value: notes.value.trim() ? 'دارد' : 'ندارد' },
]);
const canSave = computed(() => !saving.value && title.value.trim().length >= 2);
function parseTags(raw: string): string[] { function parseTags(raw: string): string[] {
return [ return [
...new Set( ...new Set(
@@ -161,293 +214,148 @@ onMounted(async () => {
</script> </script>
<template> <template>
<section class="page" :class="{ embedded }"> <a-flex vertical :gap="16">
<div v-if="embedded" class="embed-actions"> <a-flex v-if="embedded" wrap="wrap" :gap="8">
<button <a-button type="primary" :loading="saving" :disabled="!canSave" @click="save">
class="btn primary" <template #icon><SaveOutlined /></template>
type="button"
:disabled="saving || title.trim().length < 2"
@click="save"
>
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }} {{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
</button> </a-button>
<button class="btn cancel" type="button" @click="cancel">انصراف</button> <a-button @click="cancel">انصراف</a-button>
<button v-if="!isNew" class="btn danger" type="button" @click="removeCard">حذف</button> <a-button v-if="!isNew" danger @click="removeCard">
</div> <template #icon><DeleteOutlined /></template>
<header v-if="!embedded" class="desktop-head"> حذف
<div class="title-block"> </a-button>
<span class="doc-ico"><UiIcon name="document" :size="22" /></span> </a-flex>
<div>
<h1>{{ pageTitle }}</h1> <a-flex
<p class="crumb"> v-else
justify="space-between"
align="flex-start"
wrap="wrap"
:gap="12"
>
<a-flex vertical :gap="4">
<a-breadcrumb>
<a-breadcrumb-item>
<RouterLink :to="{ name: 'projects' }">پروژه‌ها</RouterLink> <RouterLink :to="{ name: 'projects' }">پروژه‌ها</RouterLink>
<span>›</span> </a-breadcrumb-item>
<strong>{{ pageTitle }}</strong> <a-breadcrumb-item>{{ pageTitle }}</a-breadcrumb-item>
</p> </a-breadcrumb>
</div> <a-flex align="center" :gap="8">
</div> <FileTextOutlined />
<div class="desk-actions"> <a-typography-title :level="3" :style="{ margin: 0 }">{{ pageTitle }}</a-typography-title>
<button </a-flex>
class="btn primary" </a-flex>
type="button" <a-space wrap>
:disabled="saving || title.trim().length < 2" <a-button type="primary" :loading="saving" :disabled="!canSave" @click="save">
@click="save" <template #icon><CheckOutlined /></template>
>
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }} {{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
</button> </a-button>
<button class="btn cancel" type="button" @click="cancel">انصراف</button> <a-button @click="cancel">
<button v-if="!isNew" class="btn danger" type="button" @click="removeCard">حذف</button> <template #icon><CloseOutlined /></template>
</div> انصراف
</header> </a-button>
<a-button v-if="!isNew" danger @click="removeCard">
<template #icon><DeleteOutlined /></template>
حذف
</a-button>
</a-space>
</a-flex>
<header v-if="!embedded" class="mobile-head"> <a-alert v-if="error" type="error" show-icon :message="error" />
<button
class="icon-btn"
type="button"
aria-label="ذخیره"
:disabled="saving || title.trim().length < 2"
@click="save"
>
<UiIcon name="check-plain" :size="22" />
</button>
<h1>{{ pageTitle }}</h1>
<button class="icon-btn" type="button" aria-label="بستن" @click="cancel">
<UiIcon name="x" :size="20" />
</button>
</header>
<p v-if="error" class="error">{{ error }}</p> <a-spin :spinning="loading">
<p v-else-if="loading" class="muted">در حال بارگذاری…</p> <a-row v-if="!loading" :gutter="[24, 24]" align="top">
<a-col :xs="24" :lg="17" :xl="18">
<form v-else class="card" @submit.prevent="save"> <a-card :bordered="false">
<div class="field"> <a-form layout="vertical" @finish="save">
<label for="card-title">عنوان</label> <a-divider orientation="right">اطلاعات کارت</a-divider>
<input id="card-title" v-model="title" type="text" required minlength="2" maxlength="200" /> <a-row :gutter="[16, 0]">
</div> <a-col :xs="24" :md="12">
<div class="field"> <a-form-item label="عنوان" required>
<label for="card-tags">برچسب‌ها</label> <a-input
<input v-model:value="title"
id="card-tags" :maxlength="200"
v-model="tagsRaw" placeholder="عنوان کارت"
type="text" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item label="برچسب‌ها">
<a-input
v-model:value="tagsRaw"
placeholder="فوری، پشتیبانی (با کاما جدا کنید)" placeholder="فوری، پشتیبانی (با کاما جدا کنید)"
/> />
</div> </a-form-item>
<div class="field"> </a-col>
<label for="card-assignees">مسئولان کارت</label> <a-col :span="24">
<select id="card-assignees" v-model="selectedAssigneeIds" multiple class="multi" :disabled="!canAssignOthers"> <a-form-item label="مسئولان کارت">
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option> <a-select
</select> v-model:value="selectedAssigneeIds"
<small v-if="canAssignOthers" class="hint">با نگه داشتن Ctrl می‌توانید چند نفر را انتخاب کنید.</small> mode="multiple"
<small v-else class="hint">بدون دسترسی «تخصیص کارت پروژه به دیگران» کارت فقط برای خودتان ثبت می‌شود.</small> :options="userOptions"
</div> :disabled="!canAssignOthers"
<div class="field"> placeholder="انتخاب مسئولان"
<label for="card-notes">یادداشت</label> style="width: 100%"
<textarea id="card-notes" v-model="notes" rows="5" maxlength="4000" /> option-filter-prop="label"
</div> />
<div v-if="!embedded" class="mobile-actions"> <a-typography-text type="secondary">
<button class="btn primary" type="submit" :disabled="saving || title.trim().length < 2"> <template v-if="canAssignOthers">
می‌توانید چند نفر را انتخاب کنید.
</template>
<template v-else>
بدون دسترسی «تخصیص کارت پروژه به دیگران» کارت فقط برای خودتان ثبت می‌شود.
</template>
</a-typography-text>
</a-form-item>
</a-col>
</a-row>
<a-divider orientation="right">یادداشت</a-divider>
<a-row :gutter="[16, 0]">
<a-col :span="24">
<a-form-item label="یادداشت">
<a-textarea
v-model:value="notes"
:rows="5"
:maxlength="4000"
style="width: 100%"
show-count
/>
</a-form-item>
</a-col>
</a-row>
<a-flex v-if="!embedded" justify="flex-end" wrap="wrap" :gap="8">
<a-button type="primary" html-type="submit" :loading="saving" :disabled="!canSave">
<template #icon><SaveOutlined /></template>
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }} {{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
</button> </a-button>
<button v-if="!isNew" class="btn danger" type="button" @click="removeCard">حذف</button> <a-button v-if="!isNew" danger @click="removeCard">
</div> <template #icon><DeleteOutlined /></template>
</form> حذف
</section> </a-button>
</a-flex>
</a-form>
</a-card>
</a-col>
<a-col :xs="24" :lg="7" :xl="6">
<a-affix :offset-top="24">
<a-card title="خلاصه کارت" :bordered="false">
<a-descriptions :column="1" size="small" bordered>
<a-descriptions-item
v-for="item in summaryItems"
:key="item.label"
:label="item.label"
>
{{ item.value }}
</a-descriptions-item>
</a-descriptions>
</a-card>
</a-affix>
</a-col>
</a-row>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.page {
display: grid;
gap: 0.85rem;
max-width: 100%;
min-width: 0;
width: 100%;
}
.page.embedded {
max-width: none;
}
.embed-actions {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.desktop-head {
display: none;
justify-content: space-between;
gap: 1rem;
align-items: center;
}
.title-block {
display: flex;
align-items: center;
gap: 0.75rem;
}
.doc-ico {
width: 44px;
height: 44px;
border-radius: var(--radius);
display: grid;
place-items: center;
background: #ecfdf5;
color: #0f766e;
}
h1 {
margin: 0;
font-size: 1.35rem;
}
.crumb {
margin: 0.2rem 0 0;
display: flex;
align-items: center;
gap: 0.35rem;
color: #94a3b8;
font-size: 0.82rem;
}
.crumb a {
color: #0f766e;
font-weight: 700;
text-decoration: none;
}
.desk-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.mobile-head {
display: grid;
grid-template-columns: 40px 1fr 40px;
align-items: center;
}
.mobile-head h1 {
text-align: center;
font-size: 1.05rem;
}
.icon-btn {
width: 40px;
height: 40px;
border: 0;
background: none;
color: #0f766e;
display: grid;
place-items: center;
cursor: pointer;
}
.card {
display: grid;
gap: 0.85rem;
background: #fff;
border-radius: var(--radius);
padding: 1rem;
box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}
.field {
display: grid;
gap: 0.35rem;
}
.field label {
color: #64748b;
font-size: 0.88rem;
font-weight: 700;
}
input,
textarea,
select {
width: 100%;
min-width: 0;
border: 1px solid #e2e8f0;
border-radius: var(--radius);
min-height: var(--control-h);
padding: 0 0.75rem;
font: inherit;
box-sizing: border-box;
}
select.multi {
min-height: 110px;
padding: 0.4rem;
}
.hint {
color: #64748b;
font-size: 0.8rem;
}
textarea {
min-height: 5.5rem;
padding: 0.65rem 0.85rem;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.35rem;
min-height: var(--control-h);
padding: 0 0.95rem;
border-radius: var(--radius);
font-weight: 700;
border: 1px solid transparent;
cursor: pointer;
font: inherit;
}
.btn.primary {
background: #14b8a6;
color: #fff;
box-shadow: 0 8px 18px rgba(20, 184, 166, 0.24);
}
.btn.cancel {
background: #fff;
color: #64748b;
border-color: #e2e8f0;
}
.btn.danger {
background: #fff;
color: #b91c1c;
border-color: #fecaca;
}
.mobile-actions {
display: grid;
gap: 0.5rem;
}
.error {
color: #b91c1c;
margin: 0;
}
.muted {
color: #64748b;
margin: 0;
}
@media (min-width: 960px) {
.desktop-head {
display: flex;
}
.mobile-head,
.mobile-actions {
display: none;
}
}
</style>
+267 -261
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import TableColumnsMenu from '@/components/TableColumnsMenu.vue'; import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
import axios from 'axios'; import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
@@ -12,16 +12,42 @@ import type {
WebhookEvent, WebhookEvent,
} from '@mento/shared'; } from '@mento/shared';
import { WEBHOOK_EVENTS } from '@mento/shared'; import { WEBHOOK_EVENTS } from '@mento/shared';
import {
UiButton,
UiCard,
UiEmptyState,
UiField,
UiInput,
UiPageHeader,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali'; import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Divider as ADivider,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
List as AList,
ListItem as AListItem,
ListItemMeta as AListItemMeta,
Row as ARow,
Space as ASpace,
Spin as ASpin,
Table as ATable,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { CopyOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } = Typography;
const ACheckableTag = ATag.CheckableTag;
const KEY_COL_LABELS = ['نام', 'پیشوند', 'آخرین استفاده', 'وضعیت'] as const;
const DELIVERY_COL_LABELS = ['زمان', 'رویداد', 'وضعیت', 'کد', 'تلاش'] as const;
registerTableColumns('public-api.keys', [...KEY_COL_LABELS]);
registerTableColumns('public-api.deliveries', [...DELIVERY_COL_LABELS]);
const keyTableCols = useTableColumns(() => 'public-api.keys');
const deliveryTableCols = useTableColumns(() => 'public-api.deliveries');
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -50,6 +76,37 @@ const EVENT_LABELS: Record<WebhookEvent, string> = {
'activity.created': 'ایجاد فعالیت', 'activity.created': 'ایجاد فعالیت',
}; };
const keyColumns = computed<TableColumnsType<OrganizationApiKeyDto>>(() => {
const all: TableColumnsType<OrganizationApiKeyDto> = [
{ title: 'نام', key: 'نام', dataIndex: 'name' },
{ title: 'پیشوند', key: 'پیشوند' },
{ title: 'آخرین استفاده', key: 'آخرین استفاده' },
{ title: 'وضعیت', key: 'وضعیت', width: 100 },
{ title: '', key: 'عملیات', width: 120 },
];
return all.filter((col) => {
const key = String(col.key ?? '');
if (key === 'عملیات') return true;
if (!KEY_COL_LABELS.includes(key as (typeof KEY_COL_LABELS)[number])) return true;
return keyTableCols.isVisible(key);
});
});
const deliveryColumns = computed<TableColumnsType<WebhookDeliveryDto>>(() => {
const all: TableColumnsType<WebhookDeliveryDto> = [
{ title: 'زمان', key: 'زمان' },
{ title: 'رویداد', key: 'رویداد' },
{ title: 'وضعیت', key: 'وضعیت' },
{ title: 'کد', key: 'کد', width: 80 },
{ title: 'تلاش', key: 'تلاش', width: 80 },
];
return all.filter((col) => {
const key = String(col.key ?? '');
if (!DELIVERY_COL_LABELS.includes(key as (typeof DELIVERY_COL_LABELS)[number])) return true;
return deliveryTableCols.isVisible(key);
});
});
async function load() { async function load() {
loading.value = true; loading.value = true;
error.value = ''; error.value = '';
@@ -161,30 +218,32 @@ async function copyText(text: string) {
} }
} }
function endpointEventsLabel(ep: WebhookEndpointDto) {
return ep.events.map((e) => EVENT_LABELS[e as WebhookEvent] ?? e).join('، ');
}
onMounted(() => { onMounted(() => {
void load(); void load();
}); });
</script> </script>
<template> <template>
<div class="page"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="API و وب‌هوک" <a-typography-title :level="3" :style="{ margin: 0 }">API و وب‌هوک</a-typography-title>
description="کلید عمومی برای یکپارچه‌سازی و ارسال رویداد به سرور شما" <a-button :disabled="loading" @click="load">
> <template #icon><ReloadOutlined /></template>
<template #actions>
<UiButton variant="secondary" :disabled="loading" @click="load">
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<p v-if="ok" class="ok">{{ ok }}</p> <a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<UiCard title="کلیدهای API"> <a-spin :spinning="loading">
<p class="hint"> <a-card :bordered="false">
<a-divider orientation="right">کلیدهای API</a-divider>
<a-typography-paragraph type="secondary">
هدر درخواست: هدر درخواست:
<code>X-Api-Key: mk_…</code> <code>X-Api-Key: mk_…</code>
یا یا
@@ -193,260 +252,207 @@ onMounted(() => {
<code>/api/public/v1/people</code> <code>/api/public/v1/people</code>
و و
<code>/api/public/v1/deals</code> <code>/api/public/v1/deals</code>
</p> </a-typography-paragraph>
<div class="row">
<UiField label="نام کلید"> <a-form layout="vertical" @finish="createKey">
<UiInput v-model="newKeyName" placeholder="مثلاً اتصال سایت" /> <a-row :gutter="[16, 0]">
</UiField> <a-col :xs="24" :md="12">
<UiButton :loading="saving" @click="createKey">ساخت کلید</UiButton> <a-form-item label="نام کلید" required>
</div> <a-input v-model:value="newKeyName" placeholder="مثلاً اتصال سایت" />
<div v-if="createdRawKey" class="raw-key"> </a-form-item>
<code>{{ createdRawKey }}</code> </a-col>
<UiButton variant="secondary" @click="copyText(createdRawKey)">کپی</UiButton> <a-col :xs="24" :md="8">
</div> <a-form-item label=" ">
<UiEmptyState <a-button type="primary" html-type="submit" :loading="saving">
<template #icon><PlusOutlined /></template>
ساخت کلید
</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
<a-alert
v-if="createdRawKey"
type="success"
show-icon
:message="createdRawKey"
:style="{ marginBottom: '12px' }"
>
<template #action>
<a-button @click="copyText(createdRawKey)">
<template #icon><CopyOutlined /></template>
کپی
</a-button>
</template>
</a-alert>
<a-empty
v-if="!loading && !keys.length" v-if="!loading && !keys.length"
title="کلیدی نیست" description="کلیدی نیست. برای دسترسی خارجی یک کلید بسازید."
description="برای دسترسی خارجی یک کلید بسازید."
/> />
<div v-else class="table-wrap"> <template v-else-if="keys.length">
<div class="tc-row"> <a-flex justify="flex-end" :style="{ marginBottom: '12px' }">
<TableColumnsMenu table-key="public-api.keys" align="end" /> <TableColumnsMenu table-key="public-api.keys" align="end" />
</div> </a-flex>
<table v-table-cols="'public-api.keys'"> <a-table
<thead> :columns="keyColumns"
<tr> :data-source="keys"
<th>نام</th> :pagination="false"
<th>پیشوند</th> row-key="id"
<th>آخرین استفاده</th> :scroll="{ x: 640 }"
<th>وضعیت</th> >
<th></th> <template #bodyCell="{ column, record }">
</tr> <template v-if="column.key === 'نام'">
</thead> {{ (record as OrganizationApiKeyDto).name }}
<tbody> </template>
<tr v-for="k in keys" :key="k.id"> <template v-else-if="column.key === 'پیشوند'">
<td>{{ k.name }}</td> <code>{{ (record as OrganizationApiKeyDto).prefix }}…</code>
<td><code>{{ k.prefix }}…</code></td> </template>
<td> <template v-else-if="column.key === 'آخرین استفاده'">
{{ {{
k.lastUsedAt (record as OrganizationApiKeyDto).lastUsedAt
? formatJalaliNumeric(new Date(k.lastUsedAt)) ? formatJalaliNumeric(new Date((record as OrganizationApiKeyDto).lastUsedAt!))
: '—' : '—'
}} }}
</td> </template>
<td>{{ k.revokedAt ? 'باطل' : 'فعال' }}</td> <template v-else-if="column.key === 'وضعیت'">
<td> <a-tag
<UiButton :color="(record as OrganizationApiKeyDto).revokedAt ? 'default' : 'success'"
v-if="!k.revokedAt" :bordered="false"
variant="secondary" >
@click="revokeKey(k.id)" {{ (record as OrganizationApiKeyDto).revokedAt ? 'باطل' : 'فعال' }}
</a-tag>
</template>
<template v-else-if="column.key === 'عملیات'">
<a-button
v-if="!(record as OrganizationApiKeyDto).revokedAt"
danger
@click="revokeKey((record as OrganizationApiKeyDto).id)"
> >
باطل‌سازی باطل‌سازی
</UiButton> </a-button>
</td> </template>
</tr> </template>
</tbody> </a-table>
</table> </template>
</div>
</UiCard>
<UiCard title="وب‌هوک‌های خروجی"> <a-divider orientation="right">وب‌هوک‌های خروجی</a-divider>
<div class="form-grid"> <a-form layout="vertical" @finish="createWebhook">
<UiField label="نام"> <a-row :gutter="[16, 0]">
<UiInput v-model="whName" placeholder="مثلاً n8n" /> <a-col :xs="24" :md="8">
</UiField> <a-form-item label="نام" required>
<UiField label="آدرس URL"> <a-input v-model:value="whName" placeholder="مثلاً n8n" />
<UiInput v-model="whUrl" placeholder="https://example.com/hook" /> </a-form-item>
</UiField> </a-col>
</div> <a-col :xs="24" :md="12">
<div class="events"> <a-form-item label="آدرس URL" required>
<button <a-input
v-model:value="whUrl"
placeholder="https://example.com/hook"
dir="ltr"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="رویدادها" required>
<a-space wrap>
<a-checkable-tag
v-for="ev in WEBHOOK_EVENTS" v-for="ev in WEBHOOK_EVENTS"
:key="ev" :key="ev"
type="button" :checked="whEvents.includes(ev)"
class="chip" @change="() => toggleEvent(ev)"
:class="{ on: whEvents.includes(ev) }"
@click="toggleEvent(ev)"
> >
{{ EVENT_LABELS[ev] }} {{ EVENT_LABELS[ev] }}
</button> </a-checkable-tag>
</div> </a-space>
<UiButton :loading="saving" @click="createWebhook">افزودن وب‌هوک</UiButton> </a-form-item>
<div v-if="createdWebhookSecret" class="raw-key"> </a-col>
<span>HMAC secret:</span> <a-col :span="24">
<code>{{ createdWebhookSecret }}</code> <a-button type="primary" html-type="submit" :loading="saving">
<UiButton variant="secondary" @click="copyText(createdWebhookSecret)">کپی</UiButton> <template #icon><PlusOutlined /></template>
</div> افزودن وب‌هوک
</a-button>
</a-col>
</a-row>
</a-form>
<UiEmptyState <a-alert
v-if="createdWebhookSecret"
type="success"
show-icon
:message="`HMAC secret: ${createdWebhookSecret}`"
:style="{ marginTop: '12px', marginBottom: '12px' }"
>
<template #action>
<a-button @click="copyText(createdWebhookSecret)">
<template #icon><CopyOutlined /></template>
کپی
</a-button>
</template>
</a-alert>
<a-empty
v-if="!loading && !endpoints.length" v-if="!loading && !endpoints.length"
title="وب‌هوکی نیست" description="وب‌هوکی نیست. رویدادهای CRM به آدرس شما POST می‌شوند."
description="رویدادهای CRM به آدرس شما POST می‌شوند."
/> />
<div v-else class="list"> <a-list v-else-if="endpoints.length" item-layout="horizontal" :data-source="endpoints">
<article v-for="ep in endpoints" :key="ep.id" class="item"> <template #renderItem="{ item }">
<div> <a-list-item>
<strong>{{ ep.name }}</strong> <template #actions>
<p class="muted">{{ ep.url }}</p> <a-button danger @click="removeWebhook(item.id)">حذف</a-button>
<p class="muted"> </template>
{{ ep.events.map((e) => EVENT_LABELS[e as WebhookEvent] ?? e).join('، ') }} <a-list-item-meta
</p> :description="`${item.url} · ${endpointEventsLabel(item)}`"
</div> >
<UiButton variant="secondary" @click="removeWebhook(ep.id)">حذف</UiButton> <template #title>
</article> <a-typography-text strong>{{ item.name }}</a-typography-text>
</div> </template>
</UiCard> </a-list-item-meta>
</a-list-item>
</template>
</a-list>
<UiCard title="آخرین ارسال‌های وب‌هوک"> <a-divider orientation="right">آخرین ارسال‌های وب‌هوک</a-divider>
<UiEmptyState <a-empty
v-if="!deliveries.length" v-if="!deliveries.length"
title="ارسالی ثبت نشده" description="ارسالی ثبت نشده. پس از وقوع رویدادها اینجا دیده می‌شوند."
description="پس از وقوع رویدادها اینجا دیده می‌شوند."
/> />
<div v-else class="table-wrap"> <template v-else>
<div class="tc-row"> <a-flex justify="flex-end" :style="{ marginBottom: '12px' }">
<TableColumnsMenu table-key="public-api.deliveries" align="end" /> <TableColumnsMenu table-key="public-api.deliveries" align="end" />
</div> </a-flex>
<table v-table-cols="'public-api.deliveries'"> <a-table
<thead> :columns="deliveryColumns"
<tr> :data-source="deliveries"
<th>زمان</th> :pagination="false"
<th>رویداد</th> row-key="id"
<th>وضعیت</th> :scroll="{ x: 640 }"
<th>کد</th> >
<th>تلاش</th> <template #bodyCell="{ column, record }">
</tr> <template v-if="column.key === 'زمان'">
</thead> {{ formatJalaliNumeric(new Date((record as WebhookDeliveryDto).createdAt)) }}
<tbody> </template>
<tr v-for="d in deliveries" :key="d.id"> <template v-else-if="column.key === 'رویداد'">
<td>{{ formatJalaliNumeric(new Date(d.createdAt)) }}</td> {{
<td>{{ EVENT_LABELS[d.event as WebhookEvent] ?? d.event }}</td> EVENT_LABELS[(record as WebhookDeliveryDto).event as WebhookEvent] ??
<td>{{ d.status }}</td> (record as WebhookDeliveryDto).event
<td>{{ d.statusCode ?? '—' }}</td> }}
<td>{{ toFaDigits(d.attempts) }}</td> </template>
</tr> <template v-else-if="column.key === 'وضعیت'">
</tbody> {{ (record as WebhookDeliveryDto).status }}
</table> </template>
</div> <template v-else-if="column.key === 'کد'">
</UiCard> {{ (record as WebhookDeliveryDto).statusCode ?? '—' }}
</div> </template>
<template v-else-if="column.key === 'تلاش'">
{{ toFaDigits((record as WebhookDeliveryDto).attempts) }}
</template>
</template>
</a-table>
</template>
</a-card>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.page {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 1rem;
}
.hint {
color: #64748b;
font-size: 0.88rem;
line-height: 1.7;
}
.hint code {
background: #f1f5f9;
padding: 0.1rem 0.35rem;
border-radius: 6px;
font-size: 0.8rem;
}
.row {
display: grid;
grid-template-columns: 1fr auto;
gap: 0.75rem;
align-items: end;
margin: 0.75rem 0;
}
.raw-key {
display: flex;
gap: 0.75rem;
align-items: center;
flex-wrap: wrap;
padding: 0.75rem;
background: #f0fdfa;
border-radius: var(--radius);
margin-bottom: 0.75rem;
}
.raw-key code {
word-break: break-all;
font-weight: 700;
color: #0f766e;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1.4fr;
gap: 0.75rem;
margin-bottom: 0.75rem;
}
.events {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
margin-bottom: 0.85rem;
}
.chip {
border: 1px solid #e2e8f0;
background: #fff;
border-radius: 999px;
padding: 0.35rem 0.75rem;
font: inherit;
cursor: pointer;
color: #334155;
}
.chip.on {
background: #f0fdfa;
border-color: #99f6e4;
color: #0f766e;
font-weight: 700;
}
.list {
display: grid;
gap: 0.65rem;
margin-top: 1rem;
}
.item {
display: flex;
justify-content: space-between;
gap: 0.75rem;
padding: 0.75rem;
border: 1px solid #eef2f7;
border-radius: var(--radius);
}
.muted {
color: #64748b;
margin: 0.2rem 0 0;
font-size: 0.85rem;
}
.error {
color: #b91c1c;
font-weight: 600;
}
.ok {
color: #0f766e;
font-weight: 600;
}
.table-wrap {
overflow: auto;
margin-top: 0.75rem;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th,
td {
text-align: right;
padding: 0.55rem;
border-bottom: 1px solid #eef2f7;
}
th {
color: #64748b;
font-size: 0.8rem;
}
@media (max-width: 800px) {
.row,
.form-grid {
grid-template-columns: 1fr;
}
}
</style>
-3
View File
@@ -1339,9 +1339,6 @@ const activityMax = computed(() =>
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
گزارشات و داشبورد گزارشات و داشبورد
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">
نمای جامع عملکرد فروش، مشتریان، فعالیت‌ها و تیم
</a-typography-text>
</div> </div>
<a-space wrap> <a-space wrap>
<a-button @click="openSaveModal"> <a-button @click="openSaveModal">
-5
View File
@@ -360,12 +360,7 @@ onMounted(() => {
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">رزرو و نوبت‌دهی</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">رزرو و نوبت‌دهی</a-typography-title>
<a-typography-text type="secondary">
تعریف خدمت، انتخاب بازه آزاد و ثبت نوبت برای مشتری
</a-typography-text>
</a-flex>
<a-space wrap :size="8"> <a-space wrap :size="8">
<a-button :disabled="loading" @click="load"> <a-button :disabled="loading" @click="load">
<template #icon><ReloadOutlined /></template> <template #icon><ReloadOutlined /></template>
-3
View File
@@ -528,9 +528,6 @@ onBeforeUnmount(() => {
> >
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">هدف و پیش‌بینی</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">هدف و پیش‌بینی</a-typography-title>
<a-typography-text type="secondary">
اهداف ماهانه را تنظیم و پیش‌بینی‌های خود را مشاهده نمایید
</a-typography-text>
</div> </div>
<a-button type="primary" @click="openCreate"> <a-button type="primary" @click="openCreate">
<template #icon><PlusOutlined /></template> <template #icon><PlusOutlined /></template>
-5
View File
@@ -417,12 +417,7 @@ onMounted(() => {
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">پیامک گروهی</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">پیامک گروهی</a-typography-title>
<a-typography-text type="secondary">
ارسال انبوه پیامک به اشخاص یا لیدهای فیلترشده
</a-typography-text>
</a-flex>
<a-button :disabled="loading" @click="load"> <a-button :disabled="loading" @click="load">
<template #icon><ReloadOutlined /></template> <template #icon><ReloadOutlined /></template>
بروزرسانی بروزرسانی
@@ -688,9 +688,6 @@ onUnmounted(() => {
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
گزارش فروش ته‌حساب گزارش فروش ته‌حساب
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">
وزن خالص فروش و خرید بعد از مرجوعی، به تفکیک گروه و کارشناس{{ showInternet ? ' و فروش اینترنتی' : '' }}
</a-typography-text>
</div> </div>
<a-space :size="8" wrap> <a-space :size="8" wrap>
<a-button @click="router.push({ name: 'reports' })"> <a-button @click="router.push({ name: 'reports' })">
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-5
View File
@@ -212,12 +212,7 @@ onMounted(load);
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
<a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">تیکت‌ها</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">تیکت‌ها</a-typography-title>
<a-typography-text type="secondary">
درخواست‌های پشتیبانی را ثبت و پیگیری کنید.
</a-typography-text>
</a-flex>
<a-button type="primary" @click="goNew"> <a-button type="primary" @click="goNew">
<template #icon><PlusOutlined /></template> <template #icon><PlusOutlined /></template>
تیکت جدید تیکت جدید
+240 -258
View File
@@ -9,16 +9,43 @@ import type {
VoipCallLogDto, VoipCallLogDto,
VoipConnectionDto, VoipConnectionDto,
} from '@mento/shared'; } from '@mento/shared';
import {
UiButton,
UiCard,
UiEmptyState,
UiField,
UiInput,
UiPageHeader,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import { formatJalaliNumeric, rewriteGregorianDates, toFaDigits } from '@/lib/jalali'; import { formatJalaliNumeric, rewriteGregorianDates, toFaDigits } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
InputPassword as AInputPassword,
Row as ARow,
Spin as ASpin,
Table as ATable,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { CopyOutlined, ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const CALL_COL_LABELS = [
'جهت',
'وضعیت',
'از / به',
'مشتری',
'مدت',
'خلاصه',
'زمان',
] as const;
registerTableColumns('voip.calls', [...CALL_COL_LABELS]);
const callTableCols = useTableColumns(() => 'voip.calls');
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -57,12 +84,39 @@ const summaryLabel: Record<string, string> = {
skipped: 'رد شده', skipped: 'رد شده',
}; };
const callColumns = computed<TableColumnsType<VoipCallLogDto>>(() => {
const all: TableColumnsType<VoipCallLogDto> = [
{ title: 'جهت', key: 'جهت' },
{ title: 'وضعیت', key: 'وضعیت' },
{ title: 'از / به', key: 'از / به' },
{ title: 'مشتری', key: 'مشتری' },
{ title: 'مدت', key: 'مدت' },
{ title: 'خلاصه', key: 'خلاصه' },
{ title: 'زمان', key: 'زمان' },
];
return all.filter((col) => callTableCols.isVisible(String(col.key ?? '')));
});
function noteLink(c: VoipCallLogDto): string | null { function noteLink(c: VoipCallLogDto): string | null {
if (!c.summaryNoteId) return null; if (!c.summaryNoteId) return null;
if (c.personId) return `/contacts/people/${c.personId}`; if (c.personId) return `/contacts/people/${c.personId}`;
return '/notes'; return '/notes';
} }
function summaryColor(status: string | null | undefined): string {
switch (status) {
case 'done':
return 'success';
case 'pending':
case 'processing':
return 'processing';
case 'failed':
return 'error';
default:
return 'default';
}
}
async function load() { async function load() {
loading.value = true; loading.value = true;
error.value = ''; error.value = '';
@@ -137,275 +191,203 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="page"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="تلفن سازمانی" <a-typography-title :level="3" :style="{ margin: 0 }">تلفن سازمانی</a-typography-title>
description="ثبت خودکار تماس، خلاصه گفتگو و اعلان تماس ورودی" <a-button :disabled="loading" @click="load">
> <template #icon><ReloadOutlined /></template>
<template #actions>
<UiButton variant="secondary" :disabled="loading" @click="load">
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<p v-if="ok" class="ok">{{ ok }}</p> <a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<UiCard title="اتصال جدید"> <a-spin :spinning="loading">
<p class="hint"> <a-flex vertical :gap="16">
سانترال یا سرویس VoIP شما باید رویداد تماس را با JSON به آدرس وب‌هوک بفرستد. <a-card title="اتصال جدید" :bordered="false">
فیلدهای اصلی: <a-typography-paragraph type="secondary">
<code>callId</code>، سانترال یا سرویس VoIP شما باید رویداد تماس را با JSON به آدرس وب‌هوک بفرستد. فیلدهای اصلی:
<code>direction</code> (inbound/outbound)، <code>callId</code>، <code>direction</code> (inbound/outbound)، <code>status</code>،
<code>status</code>، <code>from</code>، <code>to</code>. برای خلاصه خودکار یکی از <code>recordingUrl</code>
<code>from</code>، (لینک فایل ضبط) یا <code>transcript</code> (متن آماده) را بفرستید؛ پس از
<code>to</code>. <code>completed</code> / <code>answered</code> صف خلاصه ساخته می‌شود. امضا اختیاری با هدر
برای خلاصه خودکار یکی از <code>X-Voip-Signature</code> (HMAC-SHA256 هگز).
<code>recordingUrl</code> </a-typography-paragraph>
(لینک فایل ضبط) یا <a-form layout="vertical" @finish="create">
<code>transcript</code> <a-row :gutter="[16, 0]">
(متن آماده) را بفرستید؛ پس از <a-col :xs="24" :md="12">
<code>completed</code> <a-form-item label="نام" required>
/ <a-input
<code>answered</code> v-model:value="form.label"
صف خلاصه ساخته می‌شود. placeholder="سانترال اصلی"
امضا اختیاری با هدر style="width: 100%"
<code>X-Voip-Signature</code> />
(HMAC-SHA256 هگز). </a-form-item>
</p> </a-col>
<div class="form-grid"> <a-col :xs="24" :md="12">
<UiField label="نام"> <a-form-item label="رمز وب‌هوک (اختیاری)">
<UiInput v-model="form.label" placeholder="سانترال اصلی" /> <a-input-password
</UiField> v-model:value="form.webhookSecret"
<UiField label="رمز وب‌هوک (اختیاری)"> dir="ltr"
<UiInput v-model="form.webhookSecret" placeholder="برای تأیید امضا" /> placeholder="برای تأیید امضا"
</UiField> style="width: 100%"
<UiField label="آدرس Click-to-Call (اختیاری)"> />
<UiInput </a-form-item>
v-model="form.clickToCallUrl" </a-col>
<a-col :xs="24" :md="12">
<a-form-item label="آدرس Click-to-Call (اختیاری)">
<a-input
v-model:value="form.clickToCallUrl"
dir="ltr"
placeholder="https://pbx.example/originate?num={number}" placeholder="https://pbx.example/originate?num={number}"
style="width: 100%"
/> />
</UiField> </a-form-item>
</div> </a-col>
<UiButton :loading="saving" @click="create">ذخیره اتصال</UiButton> </a-row>
</UiCard> <a-form-item>
<a-button type="primary" html-type="submit" :loading="saving">ذخیره اتصال</a-button>
</a-form-item>
</a-form>
</a-card>
<UiCard title="اتصال‌ها"> <a-card title="اتصال‌ها" :bordered="false">
<UiEmptyState <a-flex vertical :gap="12">
<a-empty
v-if="!loading && !items.length" v-if="!loading && !items.length"
title="اتصالی نیست" description="اتصالی نیست. یک اتصال برای دریافت رویداد تماس بسازید."
description="یک اتصال برای دریافت رویداد تماس بسازید."
/> />
<div v-else class="list"> <a-card v-for="c in items" :key="c.id" type="inner">
<article v-for="c in items" :key="c.id" class="item"> <a-row :gutter="[16, 12]" align="middle">
<div> <a-col :xs="24" :lg="18">
<strong>{{ c.label }}</strong> <a-flex vertical :gap="4">
<p class="muted"> <a-typography-text strong>{{ c.label }}</a-typography-text>
تماس‌های ثبت‌شده {{ toFaDigits(c.callCount) }} <a-typography-text type="secondary">
· تماس‌های ثبت‌شده {{ toFaDigits(c.callCount) }} ·
{{ {{
c.lastEventAt c.lastEventAt
? `آخرین رویداد ${formatJalaliNumeric(new Date(c.lastEventAt))}` ? `آخرین رویداد ${formatJalaliNumeric(new Date(c.lastEventAt))}`
: 'هنوز رویدادی نیامده' : 'هنوز رویدادی نیامده'
}} }}
</p> </a-typography-text>
<p v-if="c.clickToCallUrl" class="muted">Click-to-Call فعال</p> <a-tag v-if="c.clickToCallUrl" color="processing" :bordered="false">
<p v-if="c.lastError" class="warn">{{ c.lastError }}</p> Click-to-Call فعال
</div> </a-tag>
<UiButton variant="secondary" @click="remove(c.id)">حذف</UiButton> <a-alert
</article> v-if="c.lastError"
</div> type="warning"
<div v-if="webhookUrl" class="webhook"> show-icon
<p class="hint">آدرس وب‌هوک:</p> :message="c.lastError"
<code>{{ webhookUrl }}</code>
<UiButton variant="secondary" @click="copyWebhook">کپی</UiButton>
</div>
</UiCard>
<UiCard title="آخرین تماس‌ها">
<UiEmptyState
v-if="!calls.length"
title="تماسی نیست"
description="پس از ارسال رویداد از سانترال اینجا دیده می‌شوند."
/> />
<div v-else class="table-wrap"> </a-flex>
<div class="tc-row"> </a-col>
<TableColumnsMenu table-key="voip.calls" align="end" /> <a-col :xs="24" :lg="6">
<a-button danger @click="remove(c.id)">حذف</a-button>
</a-col>
</a-row>
</a-card>
<a-card v-if="webhookUrl" type="inner" title="آدرس وب‌هوک">
<a-flex vertical :gap="8">
<a-typography-text dir="ltr" code>{{ webhookUrl }}</a-typography-text>
<div>
<a-button @click="copyWebhook">
<template #icon><CopyOutlined /></template>
کپی
</a-button>
</div> </div>
<table v-table-cols="'voip.calls'"> </a-flex>
<thead> </a-card>
<tr> </a-flex>
<th>جهت</th> </a-card>
<th>وضعیت</th>
<th>از / به</th> <a-card title="آخرین تماس‌ها" :bordered="false">
<th>مشتری</th> <a-empty
<th>مدت</th> v-if="!calls.length"
<th>خلاصه</th> description="تماسی نیست. پس از ارسال رویداد از سانترال اینجا دیده می‌شوند."
<th>زمان</th> />
</tr> <a-flex v-else vertical :gap="12">
</thead> <a-flex justify="flex-end">
<tbody> <TableColumnsMenu table-key="voip.calls" align="end" />
<tr v-for="c in calls" :key="c.id"> </a-flex>
<td>{{ c.direction === 'outbound' ? 'خروجی' : 'ورودی' }}</td> <a-table
<td>{{ statusLabel[c.status] ?? c.status }}</td> :columns="callColumns"
<td>{{ c.fromNumber || '—' }} → {{ c.toNumber || '—' }}</td> :data-source="calls"
<td>{{ c.personName || '—' }}</td> :pagination="false"
<td> row-key="id"
:scroll="{ x: 'max-content' }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'جهت'">
{{ (record as VoipCallLogDto).direction === 'outbound' ? 'خروجی' : 'ورودی' }}
</template>
<template v-else-if="column.key === 'وضعیت'">
{{ {{
c.durationSec != null statusLabel[(record as VoipCallLogDto).status] ??
? `${toFaDigits(c.durationSec)} ثانیه` (record as VoipCallLogDto).status
}}
</template>
<template v-else-if="column.key === 'از / به'">
<span dir="ltr">
{{ (record as VoipCallLogDto).fromNumber || '—' }} →
{{ (record as VoipCallLogDto).toNumber || '—' }}
</span>
</template>
<template v-else-if="column.key === 'مشتری'">
{{ (record as VoipCallLogDto).personName || '—' }}
</template>
<template v-else-if="column.key === 'مدت'">
{{
(record as VoipCallLogDto).durationSec != null
? `${toFaDigits((record as VoipCallLogDto).durationSec!)} ثانیه`
: '—' : '—'
}} }}
</td> </template>
<td class="summary-cell"> <template v-else-if="column.key === 'خلاصه'">
<span <a-flex vertical :gap="4">
class="summary-badge" <a-tag
:data-status="c.summaryStatus || 'none'" :color="summaryColor((record as VoipCallLogDto).summaryStatus)"
:bordered="false"
> >
{{ summaryLabel[c.summaryStatus] ?? c.summaryStatus ?? '—' }} {{
</span> summaryLabel[(record as VoipCallLogDto).summaryStatus] ??
<p v-if="c.summary" class="summary-preview"> (record as VoipCallLogDto).summaryStatus ??
{{ rewriteGregorianDates(c.summary).slice(0, 120) }}{{ c.summary.length > 120 ? '…' : '' }} '—'
</p> }}
<p v-if="c.summaryError && c.summaryStatus === 'failed'" class="warn"> </a-tag>
{{ c.summaryError }} <a-typography-text
</p> v-if="(record as VoipCallLogDto).summary"
<RouterLink type="secondary"
v-if="noteLink(c)"
class="note-link"
:to="noteLink(c)!"
> >
{{
rewriteGregorianDates((record as VoipCallLogDto).summary!).slice(0, 120)
}}{{
(record as VoipCallLogDto).summary!.length > 120 ? '…' : ''
}}
</a-typography-text>
<a-typography-text
v-if="
(record as VoipCallLogDto).summaryError &&
(record as VoipCallLogDto).summaryStatus === 'failed'
"
type="danger"
>
{{ (record as VoipCallLogDto).summaryError }}
</a-typography-text>
<RouterLink v-if="noteLink(record as VoipCallLogDto)" :to="noteLink(record as VoipCallLogDto)!">
مشاهده در پرونده مشاهده در پرونده
</RouterLink> </RouterLink>
</td> </a-flex>
<td>{{ formatJalaliNumeric(new Date(c.startedAt)) }}</td> </template>
</tr> <template v-else-if="column.key === 'زمان'">
</tbody> {{ formatJalaliNumeric(new Date((record as VoipCallLogDto).startedAt)) }}
</table> </template>
</div> </template>
</UiCard> </a-table>
</div> </a-flex>
</a-card>
</a-flex>
</a-spin>
</a-flex>
</template> </template>
<style scoped>
.page {
display: grid;
gap: 1rem;
}
.hint,
.muted {
color: #64748b;
font-size: 0.88rem;
line-height: 1.7;
}
.hint code {
background: #f1f5f9;
padding: 0.1rem 0.35rem;
border-radius: 6px;
font-size: 0.8rem;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin: 0.75rem 0 1rem;
}
.list {
display: grid;
gap: 0.75rem;
}
.item {
display: flex;
justify-content: space-between;
gap: 0.75rem;
padding: 0.85rem;
border: 1px solid #eef2f7;
border-radius: var(--radius);
}
.webhook {
margin-top: 1rem;
padding: 0.75rem;
background: #f8fafc;
border-radius: var(--radius);
display: grid;
gap: 0.5rem;
}
.webhook code {
word-break: break-all;
font-size: 0.85rem;
}
.warn {
color: #b45309;
font-size: 0.85rem;
}
.error {
color: #b91c1c;
font-weight: 600;
}
.ok {
color: #0f766e;
font-weight: 600;
}
.table-wrap {
overflow: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th,
td {
text-align: right;
padding: 0.55rem;
border-bottom: 1px solid #eef2f7;
vertical-align: top;
}
th {
color: #64748b;
font-size: 0.8rem;
}
.summary-cell {
max-width: 16rem;
}
.summary-badge {
display: inline-block;
font-size: 0.78rem;
padding: 0.15rem 0.45rem;
border-radius: 6px;
background: #f1f5f9;
color: #475569;
}
.summary-badge[data-status='done'] {
background: #ecfdf5;
color: #047857;
}
.summary-badge[data-status='pending'],
.summary-badge[data-status='processing'] {
background: #eff6ff;
color: #1d4ed8;
}
.summary-badge[data-status='failed'] {
background: #fef2f2;
color: #b91c1c;
}
.summary-preview {
margin: 0.35rem 0 0;
font-size: 0.82rem;
color: #334155;
line-height: 1.5;
}
.note-link {
display: inline-block;
margin-top: 0.35rem;
font-size: 0.8rem;
color: #0f766e;
}
@media (max-width: 800px) {
.form-grid {
grid-template-columns: 1fr;
}
}
</style>
+204 -197
View File
@@ -9,16 +9,41 @@ import type {
WooCommerceOrderLinkDto, WooCommerceOrderLinkDto,
WooCommerceSyncResultDto, WooCommerceSyncResultDto,
} from '@mento/shared'; } from '@mento/shared';
import {
UiButton,
UiCard,
UiEmptyState,
UiField,
UiInput,
UiPageHeader,
} from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali'; import { formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
Input as AInput,
InputPassword as AInputPassword,
Row as ARow,
Space as ASpace,
Spin as ASpin,
Table as ATable,
Typography,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { CopyOutlined, ReloadOutlined } from '@ant-design/icons-vue';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const ORDER_COL_LABELS = [
'سفارش ووکامرس',
'فاکتور',
'وضعیت',
'مبلغ',
'زمان',
] as const;
registerTableColumns('woocommerce.orders', [...ORDER_COL_LABELS]);
const orderTableCols = useTableColumns(() => 'woocommerce.orders');
const loading = ref(false); const loading = ref(false);
const saving = ref(false); const saving = ref(false);
@@ -44,6 +69,17 @@ const webhookUrl = computed(() => {
return `${origin}/api/public/integrations/woocommerce/${items.value[0].id}/webhook`; return `${origin}/api/public/integrations/woocommerce/${items.value[0].id}/webhook`;
}); });
const orderColumns = computed<TableColumnsType<WooCommerceOrderLinkDto>>(() => {
const all: TableColumnsType<WooCommerceOrderLinkDto> = [
{ title: 'سفارش ووکامرس', key: 'سفارش ووکامرس' },
{ title: 'فاکتور', key: 'فاکتور' },
{ title: 'وضعیت', key: 'وضعیت' },
{ title: 'مبلغ', key: 'مبلغ' },
{ title: 'زمان', key: 'زمان' },
];
return all.filter((col) => orderTableCols.isVisible(String(col.key ?? '')));
});
async function load() { async function load() {
loading.value = true; loading.value = true;
error.value = ''; error.value = '';
@@ -156,202 +192,173 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="page"> <a-flex vertical :gap="16">
<UiPageHeader <a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
title="ووکامرس" <a-typography-title :level="3" :style="{ margin: 0 }">ووکامرس</a-typography-title>
description="همگام‌سازی سفارش‌های فروشگاه با فاکتور و مشتری در CRM" <a-button :disabled="loading" @click="load">
> <template #icon><ReloadOutlined /></template>
<template #actions>
<UiButton variant="secondary" :disabled="loading" @click="load">
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</UiButton> </a-button>
</template> </a-flex>
</UiPageHeader>
<p v-if="error" class="error">{{ error }}</p> <a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<p v-if="ok" class="ok">{{ ok }}</p> <a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<UiCard title="اتصال جدید"> <a-spin :spinning="loading">
<p class="hint"> <a-flex vertical :gap="16">
در ووکامرس: ووکامرس ← تنظیمات ← پیشرفته ← REST API یک کلید بسازید. <a-card title="اتصال جدید" :bordered="false">
برای وب‌هوک: ووکامرس ← تنظیمات ← پیشرفته ← وب‌هوک‌ها، موضوع «Order created/updated». <a-typography-paragraph type="secondary">
</p> در ووکامرس: ووکامرس ← تنظیمات ← پیشرفته ← REST API یک کلید بسازید. برای وب‌هوک: ووکامرس ←
<div class="form-grid"> تنظیمات ← پیشرفته ← وب‌هوک‌ها، موضوع «Order created/updated».
<UiField label="نام"> </a-typography-paragraph>
<UiInput v-model="form.label" placeholder="فروشگاه اصلی" /> <a-form layout="vertical" @finish="create">
</UiField> <a-row :gutter="[16, 0]">
<UiField label="آدرس فروشگاه"> <a-col :xs="24" :md="12">
<UiInput v-model="form.storeUrl" placeholder="https://shop.example.com" /> <a-form-item label="نام">
</UiField> <a-input v-model:value="form.label" placeholder="فروشگاه اصلی" style="width: 100%" />
<UiField label="Consumer Key"> </a-form-item>
<UiInput v-model="form.consumerKey" placeholder="ck_…" /> </a-col>
</UiField> <a-col :xs="24" :md="12">
<UiField label="Consumer Secret"> <a-form-item label="آدرس فروشگاه" required>
<UiInput v-model="form.consumerSecret" placeholder="cs_…" /> <a-input
</UiField> v-model:value="form.storeUrl"
<UiField label="Webhook Secret (اختیاری)"> dir="ltr"
<UiInput v-model="form.webhookSecret" placeholder="برای تأیید امضا" /> placeholder="https://shop.example.com"
</UiField> style="width: 100%"
</div>
<UiButton :loading="saving" @click="create">ذخیره اتصال</UiButton>
</UiCard>
<UiCard title="اتصال‌های ذخیره‌شده">
<UiEmptyState
v-if="!loading && !items.length"
title="اتصالی نیست"
description="کلید REST API فروشگاه را وارد کنید."
/> />
<div v-else class="list"> </a-form-item>
<article v-for="c in items" :key="c.id" class="item"> </a-col>
<div> <a-col :xs="24" :md="12">
<strong>{{ c.label }}</strong> <a-form-item label="Consumer Key" required>
<p class="muted">{{ c.storeUrl }}</p> <a-input
<p class="muted"> v-model:value="form.consumerKey"
کلید {{ c.consumerKeyMasked }} dir="ltr"
· سفارش‌های واردشده {{ toFaDigits(c.importedOrders) }} placeholder="ck_…"
· style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item label="Consumer Secret" required>
<a-input-password
v-model:value="form.consumerSecret"
dir="ltr"
placeholder="cs_…"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
<a-form-item label="Webhook Secret (اختیاری)">
<a-input-password
v-model:value="form.webhookSecret"
dir="ltr"
placeholder="برای تأیید امضا"
style="width: 100%"
/>
</a-form-item>
</a-col>
</a-row>
<a-form-item>
<a-button type="primary" html-type="submit" :loading="saving">ذخیره اتصال</a-button>
</a-form-item>
</a-form>
</a-card>
<a-card title="اتصال‌های ذخیره‌شده" :bordered="false">
<a-flex vertical :gap="12">
<a-empty
v-if="!loading && !items.length"
description="اتصالی نیست. کلید REST API فروشگاه را وارد کنید."
/>
<a-card v-for="c in items" :key="c.id" type="inner">
<a-row :gutter="[16, 12]" align="top">
<a-col :xs="24" :lg="14">
<a-flex vertical :gap="4">
<a-typography-text strong>{{ c.label }}</a-typography-text>
<a-typography-text type="secondary" dir="ltr">{{ c.storeUrl }}</a-typography-text>
<a-typography-text type="secondary">
کلید
<span dir="ltr">{{ c.consumerKeyMasked }}</span>
· سفارش‌های واردشده {{ toFaDigits(c.importedOrders) }} ·
{{ {{
c.lastSyncAt c.lastSyncAt
? `آخرین همگام‌سازی ${formatJalaliNumeric(new Date(c.lastSyncAt))}` ? `آخرین همگام‌سازی ${formatJalaliNumeric(new Date(c.lastSyncAt))}`
: 'هنوز همگام نشده' : 'هنوز همگام نشده'
}} }}
</p> </a-typography-text>
<p v-if="c.lastError" class="warn">{{ c.lastError }}</p> <a-alert
</div> v-if="c.lastError"
<div class="actions"> type="warning"
<UiButton variant="secondary" @click="test(c.id)">تست</UiButton> show-icon
<UiButton :loading="syncing" @click="sync(c.id)">همگام‌سازی</UiButton> :message="c.lastError"
<UiButton variant="secondary" @click="remove(c.id)">حذف</UiButton>
</div>
</article>
</div>
<div v-if="webhookUrl" class="webhook">
<p class="hint">آدرس وب‌هوک این اتصال:</p>
<code>{{ webhookUrl }}</code>
<UiButton variant="secondary" @click="copyWebhook">کپی</UiButton>
</div>
</UiCard>
<UiCard title="آخرین سفارش‌های واردشده">
<UiEmptyState
v-if="!orders.length"
title="سفارشی نیست"
description="همگام‌سازی را بزنید یا وب‌هوک را وصل کنید."
/> />
<div v-else class="table-wrap"> </a-flex>
<div class="tc-row"> </a-col>
<TableColumnsMenu table-key="woocommerce.orders" align="end" /> <a-col :xs="24" :lg="10">
</div> <a-space wrap>
<table v-table-cols="'woocommerce.orders'"> <a-button @click="test(c.id)">تست</a-button>
<thead> <a-button type="primary" :loading="syncing" @click="sync(c.id)">
<tr> همگام‌سازی
<th>سفارش ووکامرس</th> </a-button>
<th>فاکتور</th> <a-button danger @click="remove(c.id)">حذف</a-button>
<th>وضعیت</th> </a-space>
<th>مبلغ</th> </a-col>
<th>زمان</th> </a-row>
</tr> </a-card>
</thead>
<tbody>
<tr v-for="o in orders" :key="o.id">
<td>#{{ o.wooOrderNumber || o.wooOrderId }}</td>
<td>{{ o.invoiceNumber }}</td>
<td>{{ o.status }}</td>
<td>{{ toFaDigits(o.total) }} {{ o.currency }}</td>
<td>{{ formatJalaliNumeric(new Date(o.syncedAt)) }}</td>
</tr>
</tbody>
</table>
</div>
</UiCard>
</div>
</template>
<style scoped> <a-card v-if="webhookUrl" type="inner" title="آدرس وب‌هوک این اتصال">
.page { <a-flex vertical :gap="8">
display: grid; <a-typography-text dir="ltr" code>{{ webhookUrl }}</a-typography-text>
gap: 1rem; <div>
} <a-button @click="copyWebhook">
.hint, <template #icon><CopyOutlined /></template>
.muted { کپی
color: #64748b; </a-button>
font-size: 0.88rem; </div>
line-height: 1.7; </a-flex>
} </a-card>
.form-grid { </a-flex>
display: grid; </a-card>
grid-template-columns: 1fr 1fr;
gap: 0.75rem; <a-card title="آخرین سفارش‌های واردشده" :bordered="false">
margin: 0.75rem 0 1rem; <a-empty
} v-if="!orders.length"
.list { description="سفارشی نیست. همگام‌سازی را بزنید یا وب‌هوک را وصل کنید."
display: grid; />
gap: 0.75rem; <a-flex v-else vertical :gap="12">
} <a-flex justify="flex-end">
.item { <TableColumnsMenu table-key="woocommerce.orders" align="end" />
display: flex; </a-flex>
justify-content: space-between; <a-table
gap: 0.75rem; :columns="orderColumns"
padding: 0.85rem; :data-source="orders"
border: 1px solid #eef2f7; :pagination="false"
border-radius: var(--radius); row-key="id"
} :scroll="{ x: 'max-content' }"
.actions { >
display: flex; <template #bodyCell="{ column, record }">
gap: 0.4rem; <template v-if="column.key === 'سفارش ووکامرس'">
flex-wrap: wrap; #{{ (record as WooCommerceOrderLinkDto).wooOrderNumber || (record as WooCommerceOrderLinkDto).wooOrderId }}
align-items: start; </template>
} <template v-else-if="column.key === 'فاکتور'">
.webhook { {{ (record as WooCommerceOrderLinkDto).invoiceNumber }}
margin-top: 1rem; </template>
padding: 0.75rem; <template v-else-if="column.key === 'وضعیت'">
background: #f8fafc; {{ (record as WooCommerceOrderLinkDto).status }}
border-radius: var(--radius); </template>
display: grid; <template v-else-if="column.key === 'مبلغ'">
gap: 0.5rem; {{ toFaDigits((record as WooCommerceOrderLinkDto).total) }}
} {{ (record as WooCommerceOrderLinkDto).currency }}
.webhook code { </template>
word-break: break-all; <template v-else-if="column.key === 'زمان'">
font-size: 0.85rem; {{ formatJalaliNumeric(new Date((record as WooCommerceOrderLinkDto).syncedAt)) }}
} </template>
.warn { </template>
color: #b45309; </a-table>
font-size: 0.85rem; </a-flex>
} </a-card>
.error { </a-flex>
color: #b91c1c; </a-spin>
font-weight: 600; </a-flex>
} </template>
.ok {
color: #0f766e;
font-weight: 600;
}
.table-wrap {
overflow: auto;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th,
td {
text-align: right;
padding: 0.55rem;
border-bottom: 1px solid #eef2f7;
}
th {
color: #64748b;
font-size: 0.8rem;
}
@media (max-width: 800px) {
.form-grid,
.item {
grid-template-columns: 1fr;
flex-direction: column;
}
}
</style>
@@ -136,9 +136,6 @@ const hideHeader = computed(() => route.name === 'routine-new' || route.name ===
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
<div> <div>
<a-typography-title :level="3" :style="{ margin: 0 }">کارهای روتین</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">کارهای روتین</a-typography-title>
<a-typography-text type="secondary">
برنامه روزانه، روتین‌های تکرارشونده و پیگیری انجام کارها
</a-typography-text>
</div> </div>
<a-space :size="8" wrap> <a-space :size="8" wrap>
<a-button <a-button
@@ -144,7 +144,6 @@ const greeting = computed(() => {
<a-flex justify="space-between" align="center" wrap="wrap" :gap="16"> <a-flex justify="space-between" align="center" wrap="wrap" :gap="16">
<a-flex vertical :gap="4"> <a-flex vertical :gap="4">
<a-typography-title :level="3" :style="{ margin: 0 }">کارهای امروز</a-typography-title> <a-typography-title :level="3" :style="{ margin: 0 }">کارهای امروز</a-typography-title>
<a-typography-text type="secondary">{{ greeting }}</a-typography-text>
<a-typography-text strong :style="{ color: 'var(--ant-color-primary)' }"> <a-typography-text strong :style="{ color: 'var(--ant-color-primary)' }">
<CalendarOutlined /> <CalendarOutlined />
{{ formatDayLong(data?.date ?? todayKey()) }} {{ formatDayLong(data?.date ?? todayKey()) }}
@@ -41,7 +41,6 @@ import type {
import VChart from 'vue-echarts'; import VChart from 'vue-echarts';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import type { TreasuryDashboardDto } from '@mento/shared'; import type { TreasuryDashboardDto } from '@mento/shared';
import TreasuryNav from '@/components/treasury/TreasuryNav.vue';
import { import {
TREASURY_DASHBOARD_MOCK, TREASURY_DASHBOARD_MOCK,
isTreasuryDashboardEmpty, isTreasuryDashboardEmpty,
@@ -58,7 +57,7 @@ type ChartOption = ComposeOption<
| LegendComponentOption | LegendComponentOption
>; >;
const { Title: ATypographyTitle, Text: ATypographyText } = Typography; const { Text: ATypographyText } = Typography;
const { token } = theme.useToken(); const { token } = theme.useToken();
function num(value: string | number | null | undefined) { function num(value: string | number | null | undefined) {
@@ -306,15 +305,6 @@ onMounted(async () => {
<template> <template>
<div> <div>
<a-flex vertical :gap="token.margin"> <a-flex vertical :gap="token.margin">
<div>
<a-typography-title :level="3" :style="{ margin: 0 }">مدیریت مالی</a-typography-title>
<a-typography-text type="secondary">
دفتر داخلی درآمد، هزینه و موجودی حساب. این بخش جایگزین فاکتور فروش یا حسابداری رسمی نیست.
</a-typography-text>
</div>
<TreasuryNav />
<a-alert v-if="error" type="error" show-icon :message="error" /> <a-alert v-if="error" type="error" show-icon :message="error" />
<a-alert <a-alert
v-if="usingMock" v-if="usingMock"