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
+237 -315
View File
@@ -5,13 +5,38 @@ import axios from 'axios';
import type {
AuditLogDto,
AuditLogListResponse,
DeletionArchiveDto,
DeletionArchiveListResponse,
DeletionRetention,
} from '@mento/shared';
import { api } from '@/lib/api';
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 {
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';
@@ -102,6 +127,19 @@ function rowNo(index: number) {
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) {
if (axios.isAxiosError(e)) {
const msg = (e.response?.data as { message?: string | string[] })?.message;
@@ -352,25 +390,26 @@ async function loadActors() {
}
}
function onPage(next: number) {
page.value = next;
void load();
function onPaginationChange(nextPage: number, nextSize: number) {
const sizeChanged = nextSize !== pageSize.value;
page.value = nextPage;
if (sizeChanged) {
pageSize.value = nextSize;
page.value = 1;
}
void load(sizeChanged);
}
function onPageSize(size: number) {
pageSize.value = size;
if (page.value === 1) void load();
}
function selectTab(next: HistoryTab) {
if (next === tab.value) return;
function selectTab(next: string | number) {
const key = String(next) as HistoryTab;
if (key === tab.value) return;
q.value = '';
page.value = 1;
data.value = null;
audit.value = null;
error.value = '';
okMsg.value = '';
void router.replace({ query: next === 'deletes' ? {} : { tab: next } });
void router.replace({ query: key === 'deletes' ? {} : { tab: key } });
}
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, () => {
void load();
}, { immediate: true });
@@ -462,319 +516,187 @@ void loadActors();
</script>
<template>
<section class="page">
<UiPageHeader
title="تاریخچه کارها"
lead="هر ایجاد، ویرایش و حذف اینجا ثبت می‌شود."
/>
<a-flex vertical :gap="16">
<a-typography-title :level="3" :style="{ margin: 0 }">تاریخچه کارها</a-typography-title>
<nav class="tabs" aria-label="نوع تاریخچه">
<button
v-for="item in TABS"
:key="item.key"
type="button"
:class="{ on: tab === item.key }"
@click="selectTab(item.key)"
>
{{ item.label }}
</button>
</nav>
<a-tabs :active-key="tab" @change="selectTab">
<a-tab-pane v-for="item in TABS" :key="item.key" :tab="item.label" />
</a-tabs>
<p v-if="okMsg" class="ok">{{ okMsg }}</p>
<p v-if="error" class="error">{{ error }}</p>
<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 = ''" />
<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">
<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>
</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>
</UiCard>
</a-typography-text>
</a-card>
<form class="search" @submit.prevent="load(true)">
<input v-model="q" type="search" placeholder="جستجو در عنوان یا نوع" />
<label class="actor">
<span>انجام‌دهنده</span>
<select v-model="actorId">
<option value="">همه</option>
<option v-for="user in actors" :key="user.id" :value="user.id">{{ user.fullName }}</option>
</select>
</label>
<UiButton type="submit" variant="secondary" size="sm">جستجو</UiButton>
</form>
<a-card :bordered="false">
<a-form layout="vertical" @finish="load(true)">
<a-row :gutter="[16, 0]">
<a-col :xs="24" :md="12">
<a-form-item label="جستجو">
<a-input
v-model:value="q"
type="search"
placeholder="جستجو در عنوان یا نوع"
allow-clear
/>
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<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>
<p v-if="loading" class="muted">در حال بارگذاری…</p>
<UiEmptyState
v-else-if="tab === 'deletes' && !error && !data?.items.length"
title="حذفی ثبت نشده."
description="از این به بعد حذف‌ها با نام کاربر و زمان اینجا دیده می‌شوند."
/>
<UiEmptyState
v-else-if="tab !== 'deletes' && !error && !audit?.items.length"
:title="tab === 'creates' ? 'ایجاد جدیدی ثبت نشده.' : 'ویرایشی ثبت نشده.'"
description="با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود. روی مورد بزنید تا خود پرونده باز شود."
/>
<a-spin :spinning="loading">
<a-card v-if="showDeletesEmpty" :bordered="false">
<a-empty description="حذفی ثبت نشده. از این به بعد حذف‌ها با نام کاربر و زمان اینجا دیده می‌شوند." />
</a-card>
<div v-else-if="tab === 'deletes' && data?.items.length" class="list">
<article v-for="(item, index) in data.items" :key="item.id" class="row">
<span class="idx">{{ toFaDigits(rowNo(index)) }}</span>
<div class="info">
<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>
<a-card v-else-if="showAuditEmpty" :bordered="false">
<a-empty
:description="
tab === 'creates'
? 'ایجاد جدیدی ثبت نشده. با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود.'
: 'ویرایشی ثبت نشده. با انجام کار در سامانه، نام کاربر و زمان اینجا دیده می‌شود.'
"
/>
</a-card>
<div v-else-if="audit?.items.length" class="list">
<component
:is="recordPath(row) ? 'button' : 'div'"
v-for="(row, index) in audit.items"
:key="row.id"
class="row"
:class="{ link: !!recordPath(row) }"
:type="recordPath(row) ? 'button' : undefined"
@click="openRecord(row)"
>
<span class="idx">{{ toFaDigits(rowNo(index)) }}</span>
<div class="info">
<strong>{{ rowHeading(row) }}</strong>
<span v-if="rowDetail(row)" class="detail">{{ rowDetail(row) }}</span>
<span>
<template v-if="pathPhrase(row) !== rowHeading(row)">{{ pathPhrase(row) }} · </template>
{{ row.actor?.fullName || 'سیستم' }}
·
{{ formatJalaliDateTime(new Date(row.createdAt)) }}
</span>
</div>
<span v-if="recordPath(row)" class="open">مشاهده</span>
</component>
</div>
<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)"
>
بازگردانی
</a-button>
<a-button
danger
:disabled="busyId === item.id"
@click="purgeId = item.id"
>
حذف کامل
</a-button>
</a-space>
</template>
<a-list-item-meta :description="deletionDescription(item)">
<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>
<UiPagination
<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"
: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"
/>
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>
<UiModal :open="!!purgeItem" title="حذف کامل" @close="purgeId = null">
<p v-if="purgeItem" class="confirm">
<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 }}» برای همیشه پاک شود؟ بعد از این دیگر قابل بازگشت نیست.
</p>
<template #footer>
<UiButton variant="ghost" :disabled="!!busyId" @click="purgeId = null">انصراف</UiButton>
<UiButton variant="danger" :loading="!!busyId" @click="confirmPurge">حذف کامل</UiButton>
</template>
</UiModal>
</section>
</a-typography-text>
</a-modal>
</a-flex>
</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>