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:
@@ -2,23 +2,37 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
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 {
|
||||
CreateCustomFieldRequest,
|
||||
CustomFieldDefinitionDto,
|
||||
CustomFieldEntity,
|
||||
CustomFieldType,
|
||||
} 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 saving = ref(false);
|
||||
@@ -47,12 +61,44 @@ const typeLabels: Record<CustomFieldType, string> = {
|
||||
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(() =>
|
||||
filter.value === 'all'
|
||||
? fields.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() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
@@ -124,258 +170,114 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="crm-page narrow">
|
||||
<UiPageHeader
|
||||
title="فیلدهای سفارشی"
|
||||
lead="فیلدهای اختصاصی سازمان را برای شخص، شرکت، معامله یا یادداشت تعریف کنید."
|
||||
/>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">فیلدهای سفارشی</a-typography-title>
|
||||
|
||||
<form class="crm-form" @submit.prevent="createField">
|
||||
<UiCard>
|
||||
<template #header>
|
||||
<div class="card-title">
|
||||
<UiIcon name="settings" :size="18" />
|
||||
<h3>فیلد جدید</h3>
|
||||
</div>
|
||||
</template>
|
||||
<div class="crm-form-grid-3">
|
||||
<UiField label="عنوان" required for-id="cf-label">
|
||||
<UiInput id="cf-label" v-model="label" required placeholder="مثلاً صنعت" />
|
||||
</UiField>
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
|
||||
<UiField label="روی چه چیزی؟" for-id="cf-entity">
|
||||
<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"
|
||||
<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>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="نوع فیلد">
|
||||
<a-select
|
||||
v-model:value="fieldType"
|
||||
:options="typeOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="fieldType === 'select'" :span="24">
|
||||
<a-form-item label="گزینهها (با کاما جدا کنید)">
|
||||
<a-input
|
||||
v-model:value="optionsRaw"
|
||||
placeholder="مثلاً فناوری، تولید، خدمات"
|
||||
/>
|
||||
</UiField>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item>
|
||||
<a-checkbox v-model:checked="required">فیلد اجباری است</a-checkbox>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-button type="primary" html-type="submit" :loading="saving" :disabled="saving">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ saving ? 'در حال ثبت…' : 'افزودن فیلد' }}
|
||||
</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
|
||||
<div class="crm-col-span-full check-row">
|
||||
<label class="check">
|
||||
<input v-model="required" type="checkbox" />
|
||||
<span>فیلد اجباری است</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<UiButton
|
||||
variant="primary"
|
||||
type="submit"
|
||||
:disabled="saving"
|
||||
:loading="saving"
|
||||
>
|
||||
<UiIcon name="plus" :size="16" />
|
||||
{{ saving ? 'در حال ثبت…' : 'افزودن فیلد' }}
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiCard>
|
||||
</form>
|
||||
<a-divider orientation="right">فهرست فیلدها</a-divider>
|
||||
|
||||
<div class="crm-toolbar">
|
||||
<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>
|
||||
<a-row :gutter="[16, 16]" :style="{ marginBottom: '16px' }">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-select
|
||||
v-model:value="filter"
|
||||
:options="filterOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-button @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<p v-if="error" class="error-msg">{{ error }}</p>
|
||||
<p v-if="loading" class="muted">در حال بارگذاری…</p>
|
||||
<a-spin :spinning="loading">
|
||||
<a-empty
|
||||
v-if="!loading && !visible.length"
|
||||
description="فیلدی تعریف نشده است. هیچ فیلد سفارشی برای این موجودیت وجود ندارد."
|
||||
/>
|
||||
|
||||
<div v-else class="list">
|
||||
<UiCard v-for="field in visible" :key="field.id" padding="sm" class="field-item-card">
|
||||
<div class="field-item">
|
||||
<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>
|
||||
</section>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user