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:
@@ -1,27 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
|
||||
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 & {
|
||||
noteId: string;
|
||||
noteTitle: string;
|
||||
};
|
||||
|
||||
const ATT_COL_LABELS = ['نام فایل', 'یادداشت', 'حجم', 'تاریخ'] as const;
|
||||
|
||||
registerTableColumns('attachments', [...ATT_COL_LABELS]);
|
||||
const tableCols = useTableColumns(() => 'attachments');
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
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) {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
function rowKey(row: Row) {
|
||||
return `${row.noteId}-${row.id}`;
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
@@ -62,62 +104,54 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page" dir="rtl">
|
||||
<header class="head">
|
||||
<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>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">پیوستها</a-typography-title>
|
||||
|
||||
<style scoped>
|
||||
.page { display: grid; gap: 1rem; }
|
||||
h1 { margin: 0; font-size: 1.25rem; }
|
||||
.sub, .muted { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
|
||||
.error { color: var(--danger, #dc2626); font-weight: 600; }
|
||||
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
|
||||
table { width: 100%; border-collapse: collapse; min-width: 640px; }
|
||||
th, td { padding: 0.7rem 0.65rem; border-bottom: 1px solid #eef2f7; text-align: right; }
|
||||
th { background: #f8fafc; color: #64748b; font-size: 0.82rem; }
|
||||
a { color: #0f766e; font-weight: 700; }
|
||||
button {
|
||||
min-height: var(--control-h); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: 0 0.75rem; background: #fff; cursor: pointer; font: inherit;
|
||||
}
|
||||
</style>
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
<a-spin :spinning="loading">
|
||||
<a-card v-if="listEmpty && !error" :bordered="false">
|
||||
<a-empty description="پیوستی ثبت نشده." />
|
||||
</a-card>
|
||||
|
||||
<a-card v-else-if="!error && items.length" :bordered="false">
|
||||
<a-flex justify="flex-end" :style="{ marginBottom: '12px' }">
|
||||
<TableColumnsMenu table-key="attachments" align="end" />
|
||||
</a-flex>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
: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>
|
||||
|
||||
Reference in New Issue
Block a user