merge: take origin/main for conflicting Vue files (main priority)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
5cf721f91e
commit
387c5c1676
+1862
-734
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ import {
|
||||
Select as ASelect,
|
||||
Space,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
@@ -35,8 +36,7 @@ import {
|
||||
FileTextOutlined,
|
||||
PlusOutlined,
|
||||
UserAddOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canAssignToOthers } from '@/lib/assign-access';
|
||||
@@ -648,8 +648,7 @@ onMounted(load);
|
||||
|
||||
<template>
|
||||
<div dir="rtl">
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
<a-spin :spinning="loading">
|
||||
<a-flex
|
||||
v-if="!embedded"
|
||||
justify="space-between"
|
||||
@@ -1090,8 +1089,7 @@ onMounted(load);
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</CrmSkeletonCard>
|
||||
</CrmSkeleton>
|
||||
</a-spin>
|
||||
|
||||
<a-modal
|
||||
v-model:open="newPersonOpen"
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Tag as ATag,
|
||||
Textarea as ATextarea,
|
||||
Timeline as ATimeline,
|
||||
@@ -43,8 +44,7 @@ import {
|
||||
PhoneOutlined,
|
||||
PlusOutlined,
|
||||
UserAddOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { isBirthDateAnswer, leadNoteFileIsImage, parseLeadFormNotes } from '@/lib/lead-form-notes';
|
||||
import {
|
||||
@@ -505,6 +505,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ lead?.title || 'جزئیات لید' }}
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
{{ lead ? `موبایل ${lead.mobile}` : 'در حال بارگذاری…' }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
</a-space>
|
||||
<a-space v-if="lead" :size="8" wrap>
|
||||
@@ -568,8 +571,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
<a-spin :spinning="loading">
|
||||
<template v-if="lead">
|
||||
<a-row :gutter="[24, 24]">
|
||||
<a-col :xs="24" :lg="17" :xl="18">
|
||||
@@ -1181,8 +1183,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
@close="smsOpen = false"
|
||||
/>
|
||||
</template>
|
||||
</CrmSkeletonCard>
|
||||
</CrmSkeleton>
|
||||
</a-spin>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Dropdown as ADropdown,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
@@ -66,7 +65,6 @@ import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import PhoneContactsImport from '@/components/PhoneContactsImport.vue';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import {
|
||||
filterPhoneContacts,
|
||||
isContactPickerSupported,
|
||||
@@ -92,7 +90,6 @@ const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyPa
|
||||
const { token } = theme.useToken();
|
||||
const screens = Grid.useBreakpoint();
|
||||
const isMobile = computed(() => !screens.value.md);
|
||||
const emptySimple = AEmpty.PRESENTED_IMAGE_SIMPLE;
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
|
||||
@@ -1514,20 +1511,6 @@ const tintColor = (tint: StageTint) => {
|
||||
return map[tint] ?? 'default';
|
||||
};
|
||||
|
||||
function tintAccent(tint: StageTint) {
|
||||
const t = token.value;
|
||||
const map: Record<StageTint, string> = {
|
||||
mint: t.colorSuccess,
|
||||
teal: t.colorInfo,
|
||||
amber: t.colorWarning,
|
||||
peach: t.colorWarning,
|
||||
sky: t.colorInfo,
|
||||
violet: t.colorPrimary,
|
||||
rose: t.colorError,
|
||||
};
|
||||
return map[tint] ?? t.colorPrimary;
|
||||
}
|
||||
|
||||
const tableColumns = computed<TableColumnsType<LeadDto>>(() => {
|
||||
const all: TableColumnsType<LeadDto> = [
|
||||
{
|
||||
@@ -1684,9 +1667,9 @@ onBeforeUnmount(() => {
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ isMobile ? 'جدید' : 'لید جدید' }}
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24" @click.stop>
|
||||
<a-card :bordered="true">
|
||||
@@ -1967,109 +1950,61 @@ onBeforeUnmount(() => {
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-row :gutter="[12, 12]">
|
||||
<a-col :xs="24" :sm="12" :md="8" :lg="5">
|
||||
<a-col v-if="selectedIds.length" :span="24" @click.stop>
|
||||
<a-card :bordered="false" :style="{ background: token.colorPrimaryBg }">
|
||||
<a-space :size="8" wrap>
|
||||
<a-typography-text>
|
||||
{{ toFaDigits(selectedIds.length) }} مورد انتخابشده
|
||||
</a-typography-text>
|
||||
<template v-if="canAssignOthers">
|
||||
<a-select
|
||||
:value="sort"
|
||||
style="width: 100%"
|
||||
:options="Object.entries(sortLabels).map(([value, label]) => ({ value, label }))"
|
||||
@update:value="(v) => setSort(String(v ?? 'updated') as SortKey)"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8" :lg="7">
|
||||
<a-input-search
|
||||
v-model:value="q"
|
||||
v-model:value="assignUserId"
|
||||
placeholder="تخصیص به کارشناس"
|
||||
style="min-width: 12rem"
|
||||
allow-clear
|
||||
placeholder="جستجو در لیدها…"
|
||||
enter-button="جستجو"
|
||||
style="width: 100%"
|
||||
@search="onSearch"
|
||||
:options="users.map((u) => ({ value: u.id, label: u.fullName }))"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col :xs="12" :sm="8" :md="8" :lg="4">
|
||||
<a-button :disabled="!assignUserId || busy" @click="assignSelected">اعمال تخصیص</a-button>
|
||||
</template>
|
||||
<template v-if="isAdmin">
|
||||
<a-select
|
||||
:value="cityFilter || undefined"
|
||||
v-model:value="bulkStageId"
|
||||
placeholder="تغییر وضعیت"
|
||||
style="min-width: 12rem"
|
||||
allow-clear
|
||||
placeholder="همه مناطق"
|
||||
style="width: 100%"
|
||||
:options="cityOptions.map((c) => ({ value: c, label: c }))"
|
||||
@update:value="(v) => setCityFilter(v == null ? '' : String(v))"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col :xs="12" :sm="8" :md="8" :lg="4">
|
||||
<a-select
|
||||
:value="sourceFilter || undefined"
|
||||
allow-clear
|
||||
placeholder="همه منابع"
|
||||
style="width: 100%"
|
||||
:options="sourceOptions.map((s) => ({ value: s, label: s }))"
|
||||
@update:value="(v) => setSourceFilter(v == null ? '' : String(v))"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="8" :md="8" :lg="4">
|
||||
<a-select
|
||||
:value="stageId || undefined"
|
||||
allow-clear
|
||||
placeholder="همه وضعیت"
|
||||
style="width: 100%"
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
@update:value="(v) => setStageFilter(v == null ? '' : String(v))"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-button :disabled="!bulkStageId || busy" @click="bulkStageSelected">اعمال وضعیت</a-button>
|
||||
</template>
|
||||
<a-button danger :disabled="busy" @click="archiveSelected">بایگانی</a-button>
|
||||
</a-space>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-card
|
||||
v-if="selectedIds.length"
|
||||
:bordered="false"
|
||||
:style="{
|
||||
background: token.colorPrimaryBg,
|
||||
marginTop: `${token.marginMD}px`,
|
||||
marginBottom: `${token.marginSM}px`,
|
||||
}"
|
||||
>
|
||||
<a-row :gutter="[12, 12]" align="middle">
|
||||
<a-col :xs="24" :md="6">
|
||||
<a-typography-text>
|
||||
{{ toFaDigits(selectedIds.length) }} مورد انتخابشده
|
||||
</a-typography-text>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="18">
|
||||
<a-flex wrap="wrap" :gap="8" justify="end">
|
||||
<template v-if="canAssignOthers">
|
||||
<a-select
|
||||
v-model:value="assignUserId"
|
||||
placeholder="تخصیص به کارشناس"
|
||||
style="min-width: 12rem; flex: 1 1 12rem"
|
||||
allow-clear
|
||||
:options="users.map((u) => ({ value: u.id, label: u.fullName }))"
|
||||
/>
|
||||
<a-button :disabled="!assignUserId || busy" @click="assignSelected">اعمال تخصیص</a-button>
|
||||
</template>
|
||||
<template v-if="isAdmin">
|
||||
<a-select
|
||||
v-model:value="bulkStageId"
|
||||
placeholder="تغییر وضعیت"
|
||||
style="min-width: 12rem; flex: 1 1 12rem"
|
||||
allow-clear
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
<a-button :disabled="!bulkStageId || busy" @click="bulkStageSelected">اعمال وضعیت</a-button>
|
||||
</template>
|
||||
<a-button danger :disabled="busy" @click="archiveSelected">بایگانی</a-button>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-col
|
||||
v-if="importJob && importJob.status !== 'done' && importJob.status !== 'completed' && importJob.status !== 'failed'"
|
||||
:span="24"
|
||||
>
|
||||
<a-alert
|
||||
type="info"
|
||||
show-icon
|
||||
:message="`ورود فایل: ${toFaDigits(importJob.processedCount)} / ${toFaDigits(importJob.totalCount)}`"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col v-if="okMsg" :span="24">
|
||||
<a-alert type="success" show-icon :message="okMsg" closable @close="okMsg = ''" />
|
||||
</a-col>
|
||||
<a-col v-if="error" :span="24">
|
||||
<a-alert type="error" show-icon :message="error" closable @close="error = ''" />
|
||||
</a-col>
|
||||
|
||||
<a-divider :style="{ marginTop: `${token.marginSM}px`, marginBottom: `${token.marginSM}px` }" />
|
||||
|
||||
<a-spin :spinning="pageBusy" :tip="busyMessage">
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonTable :rows="8" :columns="9" :card="false">
|
||||
<a-col :span="24">
|
||||
<a-spin :spinning="loading || pageBusy" :tip="pageBusy ? busyMessage : undefined">
|
||||
<template v-if="data?.items.length">
|
||||
<a-row v-if="isMobile" :gutter="[12, 12]">
|
||||
<a-col v-for="(lead, idx) in data.items" :key="`m-${lead.id}`" :span="24">
|
||||
<a-card
|
||||
:bordered="true"
|
||||
hoverable
|
||||
:style="{
|
||||
borderColor: selected.has(lead.id) ? token.colorPrimary : undefined,
|
||||
@@ -2176,7 +2111,7 @@ onBeforeUnmount(() => {
|
||||
:data-source="data.items"
|
||||
:pagination="false"
|
||||
:row-key="(r: LeadDto) => r.id"
|
||||
:scroll="screens.xl ? undefined : { x: 960 }"
|
||||
:scroll="{ x: 1100 }"
|
||||
:custom-row="(record: LeadDto) => ({ onClick: () => goDetail(record.id) })"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
@@ -2280,9 +2215,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
<a-empty
|
||||
v-else-if="!loading"
|
||||
:image="emptySimple"
|
||||
description="لیدی ثبت نشده است. از ورود فایل استفاده کنید یا لید جدید بسازید."
|
||||
:style="{ paddingBlock: `${token.paddingXS}px` }"
|
||||
>
|
||||
<a-space :size="8">
|
||||
<a-button type="primary" @click="openCreate">ثبت لید جدید</a-button>
|
||||
@@ -2302,10 +2235,8 @@ onBeforeUnmount(() => {
|
||||
</ExcelImportFlow>
|
||||
</a-space>
|
||||
</a-empty>
|
||||
</CrmSkeletonTable>
|
||||
</CrmSkeleton>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-modal
|
||||
v-model:open="createOpen"
|
||||
@@ -2519,6 +2450,5 @@ onBeforeUnmount(() => {
|
||||
</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</a-flex>
|
||||
</div>
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
+709
-942
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import {
|
||||
Select as ASelect,
|
||||
Space,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
Upload as AUpload,
|
||||
@@ -32,8 +33,7 @@ import {
|
||||
PhoneOutlined,
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
||||
import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared';
|
||||
@@ -491,9 +491,8 @@ onMounted(load);
|
||||
</a-space>
|
||||
</a-flex>
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
<a-form layout="vertical" @finish="submit">
|
||||
<a-spin :spinning="loading">
|
||||
<a-form v-if="!loading" layout="vertical" @finish="submit">
|
||||
<a-card :bordered="false">
|
||||
<a-divider orientation="right">اطلاعات اصلی</a-divider>
|
||||
<a-row :gutter="[16, 0]">
|
||||
@@ -524,11 +523,10 @@ onMounted(load);
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="موبایل">
|
||||
<a-space-compact block>
|
||||
<a-input v-model:value="mobile" type="tel" />
|
||||
<a-space-compact block style="width: 100%">
|
||||
<a-input v-model:value="mobile" type="tel" style="width: 100%" />
|
||||
<a-button
|
||||
:disabled="pickingContact || saving"
|
||||
:style="{ flex: 'none', display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }"
|
||||
@click="fillFromPhoneContact"
|
||||
>
|
||||
<template #icon><PhoneOutlined /></template>
|
||||
@@ -729,8 +727,7 @@ onMounted(load);
|
||||
<a-button v-if="!isNew" danger :disabled="saving" @click="remove">حذف</a-button>
|
||||
</a-space>
|
||||
</a-form>
|
||||
</CrmSkeletonCard>
|
||||
</CrmSkeleton>
|
||||
</a-spin>
|
||||
|
||||
<a-upload
|
||||
ref="vcfUploadRef"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ import {
|
||||
DeleteOutlined,
|
||||
DownloadOutlined,
|
||||
UploadOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
} from '@ant-design/icons-vue';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
@@ -48,7 +48,6 @@ import {
|
||||
} from '@mento/shared';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
import { CrmSkeletonCard } from '@/components/skeleton';
|
||||
import { bindMenuDismiss, cardMenuStyle } from '@/lib/anchored-menu';
|
||||
|
||||
const dealExcelFields = DEAL_EXCEL_COLUMNS.filter((c) => c.key !== '_type').map((c) => ({
|
||||
@@ -761,19 +760,7 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="importMsg" type="success" show-icon :message="importMsg" />
|
||||
<a-flex
|
||||
v-if="loading && !stages.length"
|
||||
:gap="GAP"
|
||||
:style="{ overflowX: 'auto', paddingBottom: `${GAP}px` }"
|
||||
>
|
||||
<div
|
||||
v-for="i in 4"
|
||||
:key="i"
|
||||
:style="{ width: '280px', flex: '0 0 280px' }"
|
||||
>
|
||||
<CrmSkeletonCard :loading="true" :rows="5" :min-height="360" />
|
||||
</div>
|
||||
</a-flex>
|
||||
<a-spin v-if="loading && !stages.length" tip="در حال بارگذاری مسیر فروش…" />
|
||||
|
||||
<a-alert
|
||||
v-if="selectMode"
|
||||
|
||||
@@ -8,68 +8,27 @@ import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import { formatClockFa, formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
|
||||
import { currencySuffix, formatMoney } from '@/lib/money';
|
||||
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Avatar as AAvatar,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Dropdown as ADropdown,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
Menu as AMenu,
|
||||
MenuItem as AMenuItem,
|
||||
Modal,
|
||||
Modal as AModal,
|
||||
Pagination as APagination,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Table as ATable,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText } = Typography;
|
||||
import {
|
||||
DownloadOutlined,
|
||||
MoreOutlined,
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
ShoppingOutlined,
|
||||
ToolOutlined,
|
||||
UploadOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
UiBadge,
|
||||
UiBusyOverlay,
|
||||
UiButton,
|
||||
UiDropdownMenu,
|
||||
UiEmptyState,
|
||||
UiInput,
|
||||
UiModal,
|
||||
UiPageHeader,
|
||||
UiPagination,
|
||||
UiSelect,
|
||||
} from '@/components/ui';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import ProductFormView from '@/views/ProductFormView.vue';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
import type { ImportContactsResult, ProductDto } from '@mento/shared';
|
||||
import { brand } from '@mento/shared';
|
||||
|
||||
type SortKey = 'name' | 'newest' | 'price';
|
||||
type StatusFilter = 'all' | 'active' | 'inactive';
|
||||
|
||||
const PRODUCT_COL_LABELS = [
|
||||
'نام محصول',
|
||||
'کد',
|
||||
'دستهبندی',
|
||||
'قیمت',
|
||||
'موجودی',
|
||||
'وضعیت',
|
||||
'تاریخ ایجاد',
|
||||
'عملیات',
|
||||
] as const;
|
||||
|
||||
registerTableColumns('products', [...PRODUCT_COL_LABELS]);
|
||||
const tableCols = useTableColumns(() => 'products');
|
||||
|
||||
const pageSize = usePageSize('products', 10);
|
||||
const router = useRouter();
|
||||
|
||||
@@ -83,6 +42,7 @@ const sort = ref<SortKey>('name');
|
||||
const page = ref(1);
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
const menuId = ref<string | null>(null);
|
||||
const sortOpen = ref(false);
|
||||
const moreOpen = ref(false);
|
||||
const productModal = ref(false);
|
||||
const busy = ref(false);
|
||||
@@ -98,23 +58,6 @@ const categories = computed(() => {
|
||||
return Array.from(set).sort((a, b) => a.localeCompare(b, 'fa'));
|
||||
});
|
||||
|
||||
const categoryOptions = computed(() => [
|
||||
{ value: '', label: 'همه دستهبندیها' },
|
||||
...categories.value.map((c) => ({ value: c, label: c })),
|
||||
]);
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 'all', label: 'همه وضعیتها' },
|
||||
{ value: 'active', label: 'فعال' },
|
||||
{ value: 'inactive', label: 'غیرفعال' },
|
||||
];
|
||||
|
||||
const sortOptions = [
|
||||
{ value: 'name', label: 'مرتبسازی: نام' },
|
||||
{ value: 'newest', label: 'مرتبسازی: جدیدترین' },
|
||||
{ value: 'price', label: 'مرتبسازی: قیمت' },
|
||||
];
|
||||
|
||||
const filtered = computed(() => {
|
||||
let list = [...products.value];
|
||||
if (q.value.trim()) {
|
||||
@@ -148,53 +91,6 @@ const allPageSelected = computed(
|
||||
pageItems.value.every((p) => selected.value.has(p.id)),
|
||||
);
|
||||
|
||||
const selectedKeys = computed({
|
||||
get: () => [...selected.value],
|
||||
set: (keys: string[]) => {
|
||||
selected.value = new Set(keys);
|
||||
},
|
||||
});
|
||||
|
||||
const columns = computed<TableColumnsType<ProductDto>>(() => {
|
||||
const all: TableColumnsType<ProductDto> = [
|
||||
{
|
||||
title: '#',
|
||||
key: 'index',
|
||||
width: 56,
|
||||
customRender: ({ index }) =>
|
||||
toFaDigits((page.value - 1) * pageSize.value + index + 1),
|
||||
},
|
||||
{ title: 'نام محصول', key: 'نام محصول' },
|
||||
{
|
||||
title: 'کد',
|
||||
key: 'کد',
|
||||
customRender: ({ record }) => ({
|
||||
children: record.sku || '—',
|
||||
props: { dir: 'ltr' },
|
||||
}),
|
||||
},
|
||||
{ title: 'دستهبندی', key: 'دستهبندی' },
|
||||
{ title: 'قیمت', key: 'قیمت' },
|
||||
{
|
||||
title: 'موجودی',
|
||||
key: 'موجودی',
|
||||
customRender: ({ record }) =>
|
||||
record.stockQty != null ? toFaDigits(record.stockQty) : '—',
|
||||
},
|
||||
{ title: 'وضعیت', key: 'وضعیت' },
|
||||
{ title: 'تاریخ ایجاد', key: 'تاریخ ایجاد' },
|
||||
{ title: 'عملیات', key: 'عملیات', fixed: 'left', width: 72 },
|
||||
];
|
||||
return all.filter((col) => {
|
||||
const key = String(col.key ?? '');
|
||||
if (key === 'index') return true;
|
||||
if (!PRODUCT_COL_LABELS.includes(key as (typeof PRODUCT_COL_LABELS)[number])) {
|
||||
return true;
|
||||
}
|
||||
return tableCols.isVisible(key);
|
||||
});
|
||||
});
|
||||
|
||||
watch([q, category, statusFilter, sort], () => {
|
||||
page.value = 1;
|
||||
closeMenus();
|
||||
@@ -202,6 +98,7 @@ watch([q, category, statusFilter, sort], () => {
|
||||
|
||||
function closeMenus() {
|
||||
menuId.value = null;
|
||||
sortOpen.value = false;
|
||||
moreOpen.value = false;
|
||||
}
|
||||
|
||||
@@ -222,27 +119,6 @@ function toggleSelect(id: string) {
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
function onTableSelectChange(keys: (string | number)[]) {
|
||||
const next = keys.map(String);
|
||||
const prev = selected.value;
|
||||
if (Math.abs(next.length - prev.size) === 1) {
|
||||
const nextSet = new Set(next);
|
||||
for (const id of nextSet) {
|
||||
if (!prev.has(id)) {
|
||||
toggleSelect(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const id of prev) {
|
||||
if (!nextSet.has(id)) {
|
||||
toggleSelect(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedKeys.value = next;
|
||||
}
|
||||
|
||||
function formatPrice(value: number | null, currency: string) {
|
||||
if (value == null) return '—';
|
||||
return formatMoney(value, currency);
|
||||
@@ -349,49 +225,22 @@ async function toggleActive(product: ProductDto) {
|
||||
await load();
|
||||
}
|
||||
|
||||
function removeProduct(product: ProductDto) {
|
||||
async function removeProduct(product: ProductDto) {
|
||||
closeMenus();
|
||||
Modal.confirm({
|
||||
title: `محصول «${product.name}» حذف شود؟`,
|
||||
okText: 'حذف',
|
||||
cancelText: 'انصراف',
|
||||
okButtonProps: { danger: true },
|
||||
onOk: async () => {
|
||||
if (!confirm(`محصول «${product.name}» حذف شود؟`)) return;
|
||||
await api.delete(`/products/${product.id}`);
|
||||
selected.value.delete(product.id);
|
||||
await load();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function removeSelected() {
|
||||
async function removeSelected() {
|
||||
closeMenus();
|
||||
const ids = Array.from(selected.value);
|
||||
if (!ids.length) return;
|
||||
Modal.confirm({
|
||||
title: `${toFaDigits(ids.length)} محصول انتخابشده حذف شوند؟`,
|
||||
okText: 'حذف',
|
||||
cancelText: 'انصراف',
|
||||
okButtonProps: { danger: true },
|
||||
onOk: async () => {
|
||||
if (!confirm(`${toFaDigits(ids.length)} محصول انتخابشده حذف شوند؟`)) return;
|
||||
await Promise.all(ids.map((id) => api.delete(`/products/${id}`)));
|
||||
selected.value = new Set();
|
||||
await load();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function onMoreMenu({ key }: { key: string | number }) {
|
||||
if (String(key) === 'remove-selected') removeSelected();
|
||||
else if (String(key) === 'reload') void load();
|
||||
moreOpen.value = false;
|
||||
}
|
||||
|
||||
function onRowMenu({ key }: { key: string | number }, record: ProductDto) {
|
||||
if (String(key) === 'edit') goEdit(record.id);
|
||||
else if (String(key) === 'toggle-active') void toggleActive(record);
|
||||
else if (String(key) === 'remove') removeProduct(record);
|
||||
menuId.value = null;
|
||||
}
|
||||
|
||||
function goEdit(id: string) {
|
||||
@@ -403,17 +252,16 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div @click="closeMenus">
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12">
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">محصولات</a-typography-title>
|
||||
</div>
|
||||
<a-space :size="8" wrap @click.stop>
|
||||
<a-button :disabled="busy" :loading="pageBusy" @click="exportExcel">
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
<section class="crm-page" @click="closeMenus">
|
||||
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
|
||||
<UiPageHeader
|
||||
title="محصولات"
|
||||
lead="مدیریت محصولات، قیمتها و موجودی"
|
||||
>
|
||||
<template #actions>
|
||||
<UiButton variant="ghost" type="button" :disabled="busy" :loading="pageBusy" @click="exportExcel">
|
||||
خروجی اکسل
|
||||
</a-button>
|
||||
</UiButton>
|
||||
<ExcelImportFlow
|
||||
preview-path="/products/import/preview"
|
||||
import-path="/products/import"
|
||||
@@ -423,62 +271,111 @@ onMounted(load);
|
||||
@fail="onImportFail"
|
||||
@settled="onImportSettled"
|
||||
>
|
||||
<template #default="{ loading: importLoading }">
|
||||
<a-button :disabled="busy" :loading="importLoading">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
ورود از اکسل
|
||||
</a-button>
|
||||
<template #default="{ loading }">
|
||||
<UiButton variant="ghost" type="button" :disabled="busy" :loading="loading">ورود از اکسل</UiButton>
|
||||
</template>
|
||||
</ExcelImportFlow>
|
||||
<a-button type="primary" @click="productModal = true">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
<UiButton variant="primary" @click="productModal = true">
|
||||
<UiIcon name="plus" :size="16" />
|
||||
محصول جدید
|
||||
</a-button>
|
||||
<a-dropdown v-model:open="moreOpen" trigger="click">
|
||||
<a-button aria-label="عملیات بیشتر">
|
||||
<template #icon><MoreOutlined /></template>
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu @click="onMoreMenu">
|
||||
<a-menu-item key="remove-selected" :disabled="!selected.size">
|
||||
</UiButton>
|
||||
<UiDropdownMenu v-model:open="moreOpen" align="end">
|
||||
<template #trigger="{ toggle }">
|
||||
<UiButton
|
||||
variant="ghost"
|
||||
size="md"
|
||||
aria-label="عملیات بیشتر"
|
||||
@click.stop="toggle"
|
||||
>
|
||||
<UiIcon name="dots" :size="18" />
|
||||
</UiButton>
|
||||
</template>
|
||||
<button type="button" :disabled="!selected.size" @click="removeSelected">
|
||||
حذف انتخابشدهها
|
||||
</a-menu-item>
|
||||
<a-menu-item key="reload">بروزرسانی لیست</a-menu-item>
|
||||
</a-menu>
|
||||
</button>
|
||||
<button type="button" @click="load">بروزرسانی لیست</button>
|
||||
</UiDropdownMenu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</UiPageHeader>
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-form layout="vertical" @click.stop>
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12" :lg="9">
|
||||
<a-form-item label="جستجو">
|
||||
<a-input
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
<div class="crm-toolbar" @click.stop>
|
||||
<div class="search-box">
|
||||
<UiInput
|
||||
v-model="q"
|
||||
type="search"
|
||||
placeholder="جستجو در نام، کد یا توضیحات..."
|
||||
>
|
||||
<template #prefix><SearchOutlined /></template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8" :lg="5">
|
||||
<a-form-item label="دستهبندی">
|
||||
<a-select
|
||||
v-model:value="category"
|
||||
:options="categoryOptions"
|
||||
style="width: 100%"
|
||||
<template #prefix>
|
||||
<UiIcon name="search" :size="16" />
|
||||
</template>
|
||||
</UiInput>
|
||||
</div>
|
||||
<UiSelect v-model="category">
|
||||
<option value="">همه دستهبندیها</option>
|
||||
<option v-for="c in categories" :key="c" :value="c">{{ c }}</option>
|
||||
</UiSelect>
|
||||
<UiSelect v-model="statusFilter">
|
||||
<option value="all">همه وضعیتها</option>
|
||||
<option value="active">فعال</option>
|
||||
<option value="inactive">غیرفعال</option>
|
||||
</UiSelect>
|
||||
<UiDropdownMenu v-model:open="sortOpen" align="end">
|
||||
<template #trigger="{ toggle }">
|
||||
<UiButton variant="outline" @click.stop="toggle">
|
||||
<UiIcon name="filter" :size="16" />
|
||||
مرتبسازی
|
||||
</UiButton>
|
||||
</template>
|
||||
<button type="button" :class="{ on: sort === 'name' }" @click="sort = 'name'">
|
||||
نام
|
||||
</button>
|
||||
<button type="button" :class="{ on: sort === 'newest' }" @click="sort = 'newest'">
|
||||
جدیدترین
|
||||
</button>
|
||||
<button type="button" :class="{ on: sort === 'price' }" @click="sort = 'price'">
|
||||
قیمت
|
||||
</button>
|
||||
</UiDropdownMenu>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="importMsg" class="ok">{{ importMsg }}</p>
|
||||
<p v-if="loading" class="muted">در حال بارگذاری…</p>
|
||||
|
||||
<template v-else>
|
||||
<!-- Desktop table -->
|
||||
<div class="tc-row desk">
|
||||
<TableColumnsMenu table-key="products" align="end" />
|
||||
</div>
|
||||
<div class="table-wrap desk">
|
||||
<table v-table-cols="'products'" class="crm-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allPageSelected"
|
||||
@change="toggleSelectAll"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8" :lg="5">
|
||||
<a-form-item label="وضعیت">
|
||||
<a-select
|
||||
v-model:value="statusFilter"
|
||||
:options="statusOptions"
|
||||
style="width: 100%"
|
||||
</th>
|
||||
<th class="num-col">#</th>
|
||||
<th>نام محصول</th>
|
||||
<th>کد</th>
|
||||
<th>دستهبندی</th>
|
||||
<th>قیمت</th>
|
||||
<th>موجودی</th>
|
||||
<th>وضعیت</th>
|
||||
<th>تاریخ ایجاد</th>
|
||||
<th class="ops">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(p, idx) in pageItems" :key="p.id">
|
||||
<td class="check">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(p.id)"
|
||||
@change="toggleSelect(p.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="num-col">{{ toFaDigits((page - 1) * pageSize + idx + 1) }}</td>
|
||||
@@ -596,21 +493,25 @@ onMounted(load);
|
||||
/>
|
||||
</div>
|
||||
|
||||
<a-modal
|
||||
v-model:open="productModal"
|
||||
title="محصول جدید"
|
||||
:footer="null"
|
||||
width="960px"
|
||||
destroy-on-close
|
||||
>
|
||||
<UiPagination
|
||||
v-if="filtered.length"
|
||||
v-model:page="page"
|
||||
:total-items="filtered.length"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="PAGE_SIZE_OPTIONS"
|
||||
@update:page-size="pageSize = $event; page = 1"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<UiModal :open="productModal" title="محصول جدید" @close="productModal = false">
|
||||
<ProductFormView
|
||||
v-if="productModal"
|
||||
embedded
|
||||
@saved="productModal = false; void load()"
|
||||
@cancel="productModal = false"
|
||||
/>
|
||||
</a-modal>
|
||||
</div>
|
||||
</UiModal>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -18,28 +18,11 @@ import {
|
||||
updateDealStage,
|
||||
} from '@/lib/pipeline-board';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import UiBusyOverlay from '@/components/ui/UiBusyOverlay.vue';
|
||||
import UiButton from '@/components/ui/UiButton.vue';
|
||||
import UiInput from '@/components/ui/UiInput.vue';
|
||||
import UiModal from '@/components/ui/UiModal.vue';
|
||||
import ProjectCardFormView from '@/views/ProjectCardFormView.vue';
|
||||
import {
|
||||
DownloadOutlined,
|
||||
UploadOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
Checkbox as ACheckbox,
|
||||
Col as ACol,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
Menu as AMenu,
|
||||
MenuItem as AMenuItem,
|
||||
Modal,
|
||||
Modal as AModal,
|
||||
Row as ARow,
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import type {
|
||||
ImportContactsResult,
|
||||
ProjectBoardBoardDto,
|
||||
@@ -48,26 +31,8 @@ import type {
|
||||
import { brand } from '@mento/shared';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { canManageSettings } from '@/lib/roles';
|
||||
import { CrmSkeletonCard } from '@/components/skeleton';
|
||||
import { bindMenuDismiss, cardMenuStyle } from '@/lib/anchored-menu';
|
||||
|
||||
const { token } = theme.useToken();
|
||||
const GAP = 16;
|
||||
|
||||
const pageStyle = {
|
||||
boxSizing: 'border-box' as const,
|
||||
display: 'flex',
|
||||
flexDirection: 'column' as const,
|
||||
gap: `${GAP}px`,
|
||||
flex: '1 1 auto',
|
||||
minHeight: 0,
|
||||
minWidth: 0,
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
};
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
@@ -85,6 +50,7 @@ const mineOnly = ref(route.query.mine === '1');
|
||||
const showCreate = ref(false);
|
||||
const newName = ref('');
|
||||
const cardModal = ref<{ cardId?: string; stageId?: string } | null>(null);
|
||||
const deleteStageId = ref<string | null>(null);
|
||||
const stageBusy = ref(false);
|
||||
const busy = ref(false);
|
||||
const importMsg = ref('');
|
||||
@@ -399,28 +365,28 @@ async function onAddStage(name: string) {
|
||||
}
|
||||
|
||||
function onDeleteStage(stageId: string) {
|
||||
const title = stages.value.find((s) => s.id === stageId)?.title ?? '';
|
||||
Modal.confirm({
|
||||
title: 'حذف ستون',
|
||||
content: `ستون «${title}» حذف شود؟ اگر کارتی داخل آن باشد باید اول آنها را جابهجا کنید.`,
|
||||
okText: 'حذف',
|
||||
cancelText: 'انصراف',
|
||||
okButtonProps: { danger: true },
|
||||
async onOk() {
|
||||
if (!currentBoardId.value || stageBusy.value) return;
|
||||
stageBusy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
await api.delete(`/project-boards/${currentBoardId.value}/stages/${stageId}`);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'حذف ستون ناموفق بود.');
|
||||
throw e;
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
deleteStageId.value = stageId;
|
||||
}
|
||||
|
||||
const deleteStageTitle = computed(() => {
|
||||
const id = deleteStageId.value;
|
||||
return stages.value.find((s) => s.id === id)?.title ?? '';
|
||||
});
|
||||
|
||||
async function confirmDeleteStage() {
|
||||
const stageId = deleteStageId.value;
|
||||
if (!stageId || !currentBoardId.value || stageBusy.value) return;
|
||||
stageBusy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
await api.delete(`/project-boards/${currentBoardId.value}/stages/${stageId}`);
|
||||
deleteStageId.value = null;
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'حذف ستون ناموفق بود.');
|
||||
} finally {
|
||||
stageBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function onCardSaved() {
|
||||
@@ -504,22 +470,6 @@ function onMenuCard(cardId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
function onCardMenuClick(info: { key: string | number }) {
|
||||
const cardId = menuOpenId.value;
|
||||
if (!cardId) return;
|
||||
const key = String(info.key);
|
||||
if (key === 'view') {
|
||||
onOpenCard(cardId);
|
||||
return;
|
||||
}
|
||||
if (key === 'edit') {
|
||||
cardModal.value = { cardId };
|
||||
menuOpenId.value = null;
|
||||
return;
|
||||
}
|
||||
menuOpenId.value = null;
|
||||
}
|
||||
|
||||
const unbindMenuDismiss = bindMenuDismiss(
|
||||
() => menuOpenId.value != null,
|
||||
() => (menuOpenId.value = null),
|
||||
@@ -547,115 +497,77 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="project-board-page" dir="rtl" :style="pageStyle">
|
||||
<a-row :gutter="[GAP, GAP]" :style="{ flexShrink: 0 }">
|
||||
<a-col :span="24">
|
||||
<PipelineToolbar
|
||||
pipeline-name="تابلوی پروژه — کارهای تیمی"
|
||||
icon="grid"
|
||||
create-option-label="تابلوی جدید…"
|
||||
:pipeline-options="boardOptions"
|
||||
v-model:selected-pipeline-id="selectedBoardId"
|
||||
v-model:view-mode="viewMode"
|
||||
v-model:search="search"
|
||||
:show-amount-filters="false"
|
||||
:can-create="canCreateBoard"
|
||||
@create="showCreate = true"
|
||||
>
|
||||
<template #excel>
|
||||
<a-space>
|
||||
<a-checkbox v-model:checked="mineOnly">فقط کارهای من</a-checkbox>
|
||||
<a-button :disabled="loading || busy" @click="exportExcel">
|
||||
<template #icon><DownloadOutlined /></template>
|
||||
خروجی اکسل
|
||||
</a-button>
|
||||
<ExcelImportFlow
|
||||
preview-path="/project-cards/import/preview"
|
||||
import-path="/project-cards/import"
|
||||
:disabled="loading || busy"
|
||||
@start="onImportStart"
|
||||
@done="onImportDone"
|
||||
@fail="onImportFail"
|
||||
@settled="onImportSettled"
|
||||
>
|
||||
<a-button :disabled="loading || busy">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
ورود از اکسل
|
||||
</a-button>
|
||||
</ExcelImportFlow>
|
||||
</a-space>
|
||||
</template>
|
||||
</PipelineToolbar>
|
||||
</a-col>
|
||||
<a-col v-if="error" :span="24">
|
||||
<a-alert type="error" show-icon :message="error" />
|
||||
</a-col>
|
||||
<a-col v-if="importMsg" :span="24">
|
||||
<a-alert type="success" show-icon :message="importMsg" />
|
||||
</a-col>
|
||||
<a-col v-if="loading && !stages.length" :span="24">
|
||||
<a-row :gutter="[GAP, GAP]">
|
||||
<a-col v-for="i in 4" :key="i" :xs="24" :sm="12" :md="6">
|
||||
<CrmSkeletonCard :loading="true" :rows="5" :min-height="360" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<div
|
||||
:style="{
|
||||
position: 'relative',
|
||||
flex: '1 1 auto',
|
||||
minHeight: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}"
|
||||
<section class="page" dir="rtl">
|
||||
<UiBusyOverlay :open="pageBusy" :message="busyMessage" />
|
||||
<PipelineToolbar
|
||||
pipeline-name="تابلوی پروژه — کارهای تیمی"
|
||||
icon="grid"
|
||||
create-option-label="تابلوی جدید…"
|
||||
:pipeline-options="boardOptions"
|
||||
v-model:selected-pipeline-id="selectedBoardId"
|
||||
v-model:view-mode="viewMode"
|
||||
v-model:search="search"
|
||||
:show-amount-filters="false"
|
||||
:can-create="canCreateBoard"
|
||||
@create="showCreate = true"
|
||||
>
|
||||
<div
|
||||
v-if="pageBusy"
|
||||
:style="{
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
zIndex: 2,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
background: token.colorBgMask,
|
||||
}"
|
||||
>
|
||||
<a-spin :tip="busyMessage" />
|
||||
</div>
|
||||
<template #excel>
|
||||
<label class="mine-toggle">
|
||||
<input v-model="mineOnly" type="checkbox" />
|
||||
<span>فقط کارهای من</span>
|
||||
</label>
|
||||
<button class="btn-ghost-sm" type="button" :disabled="loading || busy" @click="exportExcel">
|
||||
خروجی اکسل
|
||||
</button>
|
||||
<ExcelImportFlow
|
||||
preview-path="/project-cards/import/preview"
|
||||
import-path="/project-cards/import"
|
||||
:disabled="loading || busy"
|
||||
@start="onImportStart"
|
||||
@done="onImportDone"
|
||||
@fail="onImportFail"
|
||||
@settled="onImportSettled"
|
||||
>
|
||||
<button class="btn-ghost-sm" type="button" :disabled="loading || busy">
|
||||
ورود از اکسل
|
||||
</button>
|
||||
</ExcelImportFlow>
|
||||
</template>
|
||||
</PipelineToolbar>
|
||||
|
||||
<PipelineList
|
||||
v-if="viewMode === 'list' && (!loading || stages.length)"
|
||||
:stages="visibleStages"
|
||||
:copy="PROJECT_BOARD_COPY"
|
||||
@open-deal="onOpenCard"
|
||||
@menu-deal="onMenuCard"
|
||||
/>
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="importMsg" class="ok">{{ importMsg }}</p>
|
||||
<p v-else-if="loading && !stages.length" class="muted">در حال بارگذاری تابلو…</p>
|
||||
|
||||
<PipelineBoard
|
||||
v-else-if="viewMode === 'kanban' && stages.length"
|
||||
:stages="visibleStages"
|
||||
:dragging-id="draggingId"
|
||||
:drop-stage-id="dropStageId"
|
||||
:can-manage="canCreateBoard"
|
||||
:copy="PROJECT_BOARD_COPY"
|
||||
@drag-start="onDragStart"
|
||||
@drag-end="onDragEnd"
|
||||
@drag-over="onDragOver"
|
||||
@drop="onDrop"
|
||||
@add-deal="onAddCard"
|
||||
@open-deal="onOpenCard"
|
||||
@menu-deal="onMenuCard"
|
||||
@rename-stage="onRenameStage"
|
||||
@delete-stage="onDeleteStage"
|
||||
@move-stage="onMoveStage"
|
||||
@column-drag-start="onColumnDragStart"
|
||||
@column-drag-end="onColumnDragEnd"
|
||||
@add-stage="onAddStage"
|
||||
/>
|
||||
</div>
|
||||
<PipelineList
|
||||
v-if="viewMode === 'list' && (!loading || stages.length)"
|
||||
:stages="visibleStages"
|
||||
:copy="PROJECT_BOARD_COPY"
|
||||
@open-deal="onOpenCard"
|
||||
@menu-deal="onMenuCard"
|
||||
/>
|
||||
|
||||
<PipelineBoard
|
||||
v-else-if="viewMode === 'kanban' && stages.length"
|
||||
:stages="visibleStages"
|
||||
:dragging-id="draggingId"
|
||||
:drop-stage-id="dropStageId"
|
||||
:can-manage="canCreateBoard"
|
||||
:copy="PROJECT_BOARD_COPY"
|
||||
@drag-start="onDragStart"
|
||||
@drag-end="onDragEnd"
|
||||
@drag-over="onDragOver"
|
||||
@drop="onDrop"
|
||||
@add-deal="onAddCard"
|
||||
@open-deal="onOpenCard"
|
||||
@menu-deal="onMenuCard"
|
||||
@rename-stage="onRenameStage"
|
||||
@delete-stage="onDeleteStage"
|
||||
@move-stage="onMoveStage"
|
||||
@column-drag-start="onColumnDragStart"
|
||||
@column-drag-end="onColumnDragEnd"
|
||||
@add-stage="onAddStage"
|
||||
/>
|
||||
|
||||
<Teleport to="body">
|
||||
<DealCardOverlay
|
||||
@@ -669,55 +581,79 @@ onBeforeUnmount(() => {
|
||||
</Teleport>
|
||||
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="menuOpenId"
|
||||
class="menu-pop"
|
||||
:style="{
|
||||
position: 'fixed',
|
||||
zIndex: 1080,
|
||||
...(menuStyle ?? {}),
|
||||
}"
|
||||
>
|
||||
<a-menu
|
||||
:style="{ minWidth: '160px', boxShadow: token.boxShadowSecondary }"
|
||||
@click="onCardMenuClick"
|
||||
<div v-if="menuOpenId" class="menu-pop" role="menu" :style="menuStyle ?? undefined">
|
||||
<button type="button" role="menuitem" @click="onOpenCard(menuOpenId)">
|
||||
مشاهده کارت
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
@click="cardModal = { cardId: menuOpenId ?? undefined }; menuOpenId = null"
|
||||
>
|
||||
<a-menu-item key="view">مشاهده کارت</a-menu-item>
|
||||
<a-menu-item key="edit">ویرایش</a-menu-item>
|
||||
<a-menu-item key="close">بستن</a-menu-item>
|
||||
</a-menu>
|
||||
ویرایش
|
||||
</button>
|
||||
<button type="button" role="menuitem" @click="menuOpenId = null">بستن</button>
|
||||
</div>
|
||||
</Teleport>
|
||||
|
||||
<a-modal
|
||||
<UiModal
|
||||
:open="showCreate && canCreateBoard"
|
||||
title="تابلوی جدید"
|
||||
:confirm-loading="saving"
|
||||
ok-text="ساخت"
|
||||
cancel-text="انصراف"
|
||||
:ok-button-props="{ disabled: newName.trim().length < 2 }"
|
||||
destroy-on-close
|
||||
@ok="createBoard"
|
||||
@cancel="showCreate = false"
|
||||
@close="showCreate = false"
|
||||
>
|
||||
<a-form layout="vertical" @finish="createBoard">
|
||||
<a-form-item label="نام تابلو" required>
|
||||
<a-input
|
||||
v-model:value="newName"
|
||||
<form class="create-form" @submit.prevent="createBoard">
|
||||
<label class="field">
|
||||
<span>نام تابلو</span>
|
||||
<UiInput
|
||||
v-model="newName"
|
||||
placeholder="نام تابلوی جدید…"
|
||||
:maxlength="120"
|
||||
required
|
||||
:minlength="2"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</label>
|
||||
</form>
|
||||
<template #footer>
|
||||
<UiButton
|
||||
type="button"
|
||||
:disabled="saving || newName.trim().length < 2"
|
||||
@click="createBoard"
|
||||
>
|
||||
{{ saving ? 'در حال ساخت…' : 'ساخت' }}
|
||||
</UiButton>
|
||||
<UiButton variant="ghost" type="button" @click="showCreate = false">
|
||||
انصراف
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiModal>
|
||||
|
||||
<a-modal
|
||||
<UiModal
|
||||
:open="Boolean(deleteStageId)"
|
||||
title="حذف ستون"
|
||||
@close="deleteStageId = null"
|
||||
>
|
||||
<p class="delete-copy">
|
||||
ستون «{{ deleteStageTitle }}» حذف شود؟ اگر کارتی داخل آن باشد باید
|
||||
اول آنها را جابهجا کنید.
|
||||
</p>
|
||||
<template #footer>
|
||||
<UiButton
|
||||
type="button"
|
||||
:disabled="stageBusy"
|
||||
@click="confirmDeleteStage"
|
||||
>
|
||||
{{ stageBusy ? 'در حال حذف…' : 'حذف' }}
|
||||
</UiButton>
|
||||
<UiButton variant="ghost" type="button" @click="deleteStageId = null">
|
||||
انصراف
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiModal>
|
||||
|
||||
<UiModal
|
||||
:open="Boolean(cardModal)"
|
||||
:title="cardModal?.cardId ? 'ویرایش کارت' : 'کارت جدید'"
|
||||
:footer="null"
|
||||
destroy-on-close
|
||||
width="720px"
|
||||
@cancel="cardModal = null"
|
||||
@close="cardModal = null"
|
||||
>
|
||||
<ProjectCardFormView
|
||||
v-if="cardModal"
|
||||
@@ -728,13 +664,103 @@ onBeforeUnmount(() => {
|
||||
@saved="onCardSaved"
|
||||
@cancel="cardModal = null"
|
||||
/>
|
||||
</a-modal>
|
||||
</div>
|
||||
</UiModal>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.project-board-page {
|
||||
.page {
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
direction: rtl;
|
||||
text-align: right;
|
||||
container-type: inline-size;
|
||||
container-name: pipeline;
|
||||
}
|
||||
|
||||
.mine-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin-inline-end: 0.35rem;
|
||||
padding: 0.4rem 0.7rem;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
color: #0f172a;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.mine-toggle input {
|
||||
accent-color: #0f766e;
|
||||
}
|
||||
|
||||
.btn-ghost-sm {
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #0f766e;
|
||||
border-radius: 10px;
|
||||
padding: 0.45rem 0.75rem;
|
||||
font-weight: 700;
|
||||
font-size: 0.85rem;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.create-form .field {
|
||||
display: grid;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.create-form .field span {
|
||||
font-size: 0.85rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.ok {
|
||||
color: #0f766e;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.delete-copy {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
line-height: 1.7;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.menu-pop {
|
||||
position: fixed;
|
||||
z-index: 80;
|
||||
background: #fff;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 0.35rem;
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
}
|
||||
|
||||
.menu-pop button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0.45rem 0.85rem;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -9,43 +9,16 @@ import type {
|
||||
VoipCallLogDto,
|
||||
VoipConnectionDto,
|
||||
} from '@mento/shared';
|
||||
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,
|
||||
Table as ATable,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { CopyOutlined, ReloadOutlined } from '@/icons/ant-bridge';
|
||||
|
||||
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');
|
||||
UiButton,
|
||||
UiCard,
|
||||
UiEmptyState,
|
||||
UiField,
|
||||
UiInput,
|
||||
UiPageHeader,
|
||||
} from '@/components/ui';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { formatJalaliNumeric, rewriteGregorianDates, toFaDigits } from '@/lib/jalali';
|
||||
|
||||
type TabKey = 'generic' | 'daftareshoma';
|
||||
|
||||
@@ -124,19 +97,6 @@ const summaryLabel: Record<string, string> = {
|
||||
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 {
|
||||
if (!c.summaryNoteId) return null;
|
||||
if (c.personId) return `/contacts/people/${c.personId}`;
|
||||
@@ -307,14 +267,18 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12">
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">تلفن سازمانی</a-typography-title>
|
||||
<a-button :disabled="loading" @click="load">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</a-flex>
|
||||
<div class="page">
|
||||
<UiPageHeader
|
||||
title="تلفن سازمانی"
|
||||
description="ثبت خودکار تماس، خلاصه گفتگو و اعلان تماس ورودی"
|
||||
>
|
||||
<template #actions>
|
||||
<UiButton variant="secondary" :disabled="loading" @click="load">
|
||||
<UiIcon name="refresh" />
|
||||
بروزرسانی
|
||||
</UiButton>
|
||||
</template>
|
||||
</UiPageHeader>
|
||||
|
||||
<nav class="tabs" aria-label="نوع اتصال تلفن">
|
||||
<button
|
||||
|
||||
@@ -1,41 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Breadcrumb as ABreadcrumb,
|
||||
BreadcrumbItem as ABreadcrumbItem,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
Col as ACol,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
InputNumber as AInputNumber,
|
||||
RadioButton as ARadioButton,
|
||||
RadioGroup as ARadioGroup,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import type { ActivityPriority, RoutineDto, RoutineEntityLink, SaveRoutineRequest } from '@mento/shared';
|
||||
import { ROUTINE_ENTITY_LINK_LABELS, ROUTINE_WEEKDAY_LABELS } from '@mento/shared';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import RecurrencePicker, { type RecurrenceValue } from '@/components/routines/RecurrencePicker.vue';
|
||||
import {
|
||||
UiButton,
|
||||
UiCard,
|
||||
UiField,
|
||||
UiInput,
|
||||
UiPageHeader,
|
||||
UiSegmented,
|
||||
UiSelect,
|
||||
UiTextarea,
|
||||
} from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { ROUTINES_CTX, apiError, formatDayNumeric, todayKey } from '@/lib/routines';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const auth = useAuthStore();
|
||||
const route = useRoute();
|
||||
@@ -46,7 +31,6 @@ const backTo = computed(() => (isManager.value ? '/routines/manage' : '/routines
|
||||
|
||||
const id = computed(() => (typeof route.params.id === 'string' ? route.params.id : null));
|
||||
const isEdit = computed(() => !!id.value);
|
||||
const pageTitle = computed(() => (isEdit.value ? 'ویرایش روتین' : 'روتین جدید'));
|
||||
|
||||
const form = reactive({
|
||||
title: '',
|
||||
@@ -57,7 +41,7 @@ const form = reactive({
|
||||
categoryId: '',
|
||||
priority: 'medium' as ActivityPriority,
|
||||
timeOfDay: '09:00',
|
||||
durationMinutes: null as number | null,
|
||||
durationMinutes: '' as string | number,
|
||||
startDate: todayKey(),
|
||||
endDate: '',
|
||||
isMandatory: true,
|
||||
@@ -96,24 +80,6 @@ const priorities = computed(() =>
|
||||
activityPriorities.items.value.map((r) => [r.key, r.label] as [ActivityPriority, string]),
|
||||
);
|
||||
const entityLinks = Object.entries(ROUTINE_ENTITY_LINK_LABELS) as Array<[RoutineEntityLink, string]>;
|
||||
|
||||
const categoryOptions = computed(() => [
|
||||
{ value: '', label: 'بدون دسته' },
|
||||
...categories.value.map((c) => ({ value: c.id, label: c.name })),
|
||||
]);
|
||||
|
||||
const priorityOptions = priorities.map(([value, label]) => ({ value, label }));
|
||||
|
||||
const userOptions = computed(() =>
|
||||
users.value.map((u) => ({ value: u.id, label: u.fullName })),
|
||||
);
|
||||
|
||||
const teamOptions = computed(() =>
|
||||
teams.value.map((t) => ({ value: t.id, label: t.name })),
|
||||
);
|
||||
|
||||
const entityLinkOptions = entityLinks.map(([value, label]) => ({ value, label }));
|
||||
|
||||
const reminderOptions = [
|
||||
{ value: '', label: 'طبق تنظیمات هر کاربر' },
|
||||
{ value: '0', label: 'سر ساعت' },
|
||||
@@ -134,7 +100,7 @@ function fill(r: RoutineDto) {
|
||||
categoryId: r.category?.id ?? '',
|
||||
priority: r.priority,
|
||||
timeOfDay: r.timeOfDay,
|
||||
durationMinutes: r.durationMinutes ?? null,
|
||||
durationMinutes: r.durationMinutes ?? '',
|
||||
startDate: r.startDate,
|
||||
endDate: r.endDate ?? '',
|
||||
isMandatory: r.isMandatory,
|
||||
@@ -302,247 +268,310 @@ async function save() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex vertical :gap="4">
|
||||
<a-breadcrumb>
|
||||
<a-breadcrumb-item>
|
||||
<RouterLink :to="backTo">{{ isManager ? 'مدیریت روتینها' : 'روتینهای من' }}</RouterLink>
|
||||
</a-breadcrumb-item>
|
||||
<a-breadcrumb-item>{{ pageTitle }}</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ pageTitle }}
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
کاری که باید بهصورت منظم انجام شود؛ هر روزِ تکرار، یک کار برای مسئول ساخته میشود.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
<div class="rform">
|
||||
<UiPageHeader
|
||||
:title="isEdit ? 'ویرایش روتین' : 'روتین جدید'"
|
||||
lead="کاری که باید بهصورت منظم انجام شود؛ هر روزِ تکرار، یک کار برای مسئول ساخته میشود."
|
||||
:back-to="backTo"
|
||||
/>
|
||||
|
||||
<a-alert v-if="foreign" type="error" show-icon :message="error" />
|
||||
<div v-if="loading" class="state">در حال بارگذاری…</div>
|
||||
<p v-else-if="foreign" class="error">{{ error }}</p>
|
||||
|
||||
<CrmSkeleton v-if="!foreign" :loading="loading">
|
||||
<CrmSkeletonCard :rows="8">
|
||||
<a-form layout="vertical" @finish="save">
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col :xs="24" :lg="16">
|
||||
<a-flex vertical :gap="16">
|
||||
<a-card :bordered="false" title="اطلاعات پایه">
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :span="24">
|
||||
<a-form-item label="عنوان" required>
|
||||
<a-input
|
||||
v-model:value="form.title"
|
||||
placeholder="مثلاً: تماس با لیدهای جدید"
|
||||
:maxlength="200"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="توضیحات">
|
||||
<a-textarea
|
||||
v-model:value="form.description"
|
||||
:rows="3"
|
||||
placeholder="جزئیات یا دستورالعمل انجام کار"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="دستهبندی">
|
||||
<a-select
|
||||
v-model:value="form.categoryId"
|
||||
:options="categoryOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="اولویت">
|
||||
<a-select
|
||||
v-model:value="form.priority"
|
||||
:options="priorityOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<form v-else class="grid" @submit.prevent="save">
|
||||
<div class="col">
|
||||
<UiCard>
|
||||
<h3 class="sec-title">اطلاعات پایه</h3>
|
||||
<div class="fields">
|
||||
<UiField label="عنوان" required>
|
||||
<UiInput v-model="form.title" placeholder="مثلاً: تماس با لیدهای جدید" :maxlength="200" />
|
||||
</UiField>
|
||||
<UiField label="توضیحات">
|
||||
<UiTextarea v-model="form.description" :rows="3" placeholder="جزئیات یا دستورالعمل انجام کار" />
|
||||
</UiField>
|
||||
<div class="grid-2">
|
||||
<UiField label="دستهبندی">
|
||||
<UiSelect v-model="form.categoryId">
|
||||
<option value="">بدون دسته</option>
|
||||
<option v-for="c in categories" :key="c.id" :value="c.id">{{ c.name }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
<UiField label="اولویت">
|
||||
<UiSelect v-model="form.priority">
|
||||
<option v-for="[k, label] in priorities" :key="k" :value="k">{{ label }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
</div>
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<a-card :bordered="false" title="مسئول">
|
||||
<a-typography-text v-if="!isManager" type="secondary">
|
||||
این روتین فقط برای خودتان ساخته میشود.
|
||||
</a-typography-text>
|
||||
<template v-else>
|
||||
<a-form-item>
|
||||
<a-radio-group v-model:value="form.target" button-style="solid">
|
||||
<a-radio-button value="user">یک کاربر</a-radio-button>
|
||||
<a-radio-button value="team">همه اعضای یک تیم</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="form.target === 'user'" label="کاربر" required>
|
||||
<a-select
|
||||
v-model:value="form.assigneeId"
|
||||
:options="userOptions"
|
||||
placeholder="انتخاب کنید"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-else
|
||||
label="تیم"
|
||||
required
|
||||
extra="برای هر عضو فعال تیم یک کار جداگانه ساخته میشود."
|
||||
>
|
||||
<a-select
|
||||
v-model:value="form.teamId"
|
||||
:options="teamOptions"
|
||||
placeholder="انتخاب کنید"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-card>
|
||||
<UiCard>
|
||||
<h3 class="sec-title">مسئول</h3>
|
||||
<p v-if="!isManager" class="self-note">این روتین فقط برای خودتان ساخته میشود.</p>
|
||||
<div v-else class="fields">
|
||||
<UiSegmented v-model="form.target" :options="targetOptions" />
|
||||
<UiField v-if="form.target === 'user'" label="کاربر" required>
|
||||
<UiSelect v-model="form.assigneeId">
|
||||
<option value="" disabled>انتخاب کنید</option>
|
||||
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
<UiField v-else label="تیم" required hint="برای هر عضو فعال تیم یک کار جداگانه ساخته میشود.">
|
||||
<UiSelect v-model="form.teamId">
|
||||
<option value="" disabled>انتخاب کنید</option>
|
||||
<option v-for="t in teams" :key="t.id" :value="t.id">{{ t.name }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<a-card :bordered="false" title="زمانبندی و تکرار">
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="ساعت انجام" required>
|
||||
<JalaliDateInput v-model="form.timeOfDay" mode="time" :clearable="false" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="مدت تقریبی (دقیقه)">
|
||||
<a-input-number
|
||||
:value="form.durationMinutes ?? undefined"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
placeholder="اختیاری"
|
||||
style="width: 100%"
|
||||
@update:value="(v: number | string | null) => { form.durationMinutes = typeof v === 'number' && v > 0 ? Math.floor(v) : null }"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="تاریخ شروع" required>
|
||||
<JalaliDateInput v-model="form.startDate" mode="date" :clearable="false" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="تاریخ پایان" extra="خالی = بدون پایان">
|
||||
<JalaliDateInput v-model="form.endDate" mode="date" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="الگوی تکرار" required>
|
||||
<RecurrencePicker v-model="recurrence" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
<UiCard>
|
||||
<h3 class="sec-title">زمانبندی و تکرار</h3>
|
||||
<div class="fields">
|
||||
<div class="grid-2">
|
||||
<UiField label="ساعت انجام" required>
|
||||
<JalaliDateInput v-model="form.timeOfDay" mode="time" :clearable="false" />
|
||||
</UiField>
|
||||
<UiField label="مدت تقریبی (دقیقه)">
|
||||
<UiInput v-model="form.durationMinutes" type="number" placeholder="اختیاری" />
|
||||
</UiField>
|
||||
<UiField label="تاریخ شروع" required>
|
||||
<JalaliDateInput v-model="form.startDate" mode="date" :clearable="false" />
|
||||
</UiField>
|
||||
<UiField label="تاریخ پایان" hint="خالی = بدون پایان">
|
||||
<JalaliDateInput v-model="form.endDate" mode="date" />
|
||||
</UiField>
|
||||
</div>
|
||||
<UiField label="الگوی تکرار" required>
|
||||
<RecurrencePicker v-model="recurrence" />
|
||||
</UiField>
|
||||
</div>
|
||||
</UiCard>
|
||||
</div>
|
||||
|
||||
<a-col :xs="24" :lg="8">
|
||||
<a-flex vertical :gap="16">
|
||||
<a-card :bordered="false" title="قوانین انجام">
|
||||
<a-flex vertical :gap="12">
|
||||
<a-checkbox v-model:checked="form.isMandatory">
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text>اجباری</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
در امتیاز روزانه و روزهای پیاپی کامل حساب میشود.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-checkbox>
|
||||
<a-checkbox v-model:checked="form.allowSkip">
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text>امکان رد کردن</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
کاربر میتواند این کار را برای یک روز رد کند.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-checkbox>
|
||||
<a-checkbox
|
||||
v-if="form.allowSkip"
|
||||
v-model:checked="form.skipReasonRequired"
|
||||
:style="{ marginInlineStart: '24px' }"
|
||||
>
|
||||
<a-typography-text>ثبت دلیل رد کردن الزامی باشد</a-typography-text>
|
||||
</a-checkbox>
|
||||
<a-checkbox v-model:checked="form.reportRequired">
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text>گزارش نتیجه الزامی</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
قبل از انجامشدن، کاربر باید نتیجه را بنویسد.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-checkbox>
|
||||
<a-checkbox v-model:checked="form.allowAfterDeadline">
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text>انجام بعد از مهلت مجاز باشد</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
اگر خاموش باشد، کار عقبافتاده فقط توسط مدیر بسته میشود.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-checkbox>
|
||||
<a-checkbox v-model:checked="form.carryOverOverdue">
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text>انتقال به روز بعد</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
کار انجامنشده در فهرست «کارهای امروز» روز بعد هم نمایش داده میشود.
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-checkbox>
|
||||
</a-flex>
|
||||
<a-form-item label="اتصال به پرونده" :style="{ marginTop: '16px', marginBottom: 0 }">
|
||||
<a-select
|
||||
v-model:value="form.entityLink"
|
||||
:options="entityLinkOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-card>
|
||||
<div class="col side">
|
||||
<UiCard>
|
||||
<h3 class="sec-title">قوانین انجام</h3>
|
||||
<div class="toggles">
|
||||
<label class="tg">
|
||||
<input v-model="form.isMandatory" type="checkbox" />
|
||||
<span>
|
||||
<strong>اجباری</strong>
|
||||
<small>در امتیاز روزانه و روزهای پیاپی کامل حساب میشود.</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="tg">
|
||||
<input v-model="form.allowSkip" type="checkbox" />
|
||||
<span>
|
||||
<strong>امکان رد کردن</strong>
|
||||
<small>کاربر میتواند این کار را برای یک روز رد کند.</small>
|
||||
</span>
|
||||
</label>
|
||||
<label v-if="form.allowSkip" class="tg nested">
|
||||
<input v-model="form.skipReasonRequired" type="checkbox" />
|
||||
<span><strong>ثبت دلیل رد کردن الزامی باشد</strong></span>
|
||||
</label>
|
||||
<label class="tg">
|
||||
<input v-model="form.reportRequired" type="checkbox" />
|
||||
<span>
|
||||
<strong>گزارش نتیجه الزامی</strong>
|
||||
<small>قبل از انجامشدن، کاربر باید نتیجه را بنویسد.</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="tg">
|
||||
<input v-model="form.allowAfterDeadline" type="checkbox" />
|
||||
<span>
|
||||
<strong>انجام بعد از مهلت مجاز باشد</strong>
|
||||
<small>اگر خاموش باشد، کار عقبافتاده فقط توسط مدیر بسته میشود.</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="tg">
|
||||
<input v-model="form.carryOverOverdue" type="checkbox" />
|
||||
<span>
|
||||
<strong>انتقال به روز بعد</strong>
|
||||
<small>کار انجامنشده در فهرست «کارهای امروز» روز بعد هم نمایش داده میشود.</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<UiField label="اتصال به پرونده" class="mt">
|
||||
<UiSelect v-model="form.entityLink">
|
||||
<option v-for="[k, label] in entityLinks" :key="k" :value="k">{{ label }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
</UiCard>
|
||||
|
||||
<a-card :bordered="false" title="یادآوری و وضعیت">
|
||||
<a-form-item label="یادآوری">
|
||||
<a-select
|
||||
v-model:value="form.reminderMinutesBefore"
|
||||
:options="reminderOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-checkbox v-model:checked="form.isActive">
|
||||
<a-typography-text>روتین فعال است</a-typography-text>
|
||||
</a-checkbox>
|
||||
</a-card>
|
||||
<UiCard>
|
||||
<h3 class="sec-title">یادآوری و وضعیت</h3>
|
||||
<div class="fields">
|
||||
<UiField label="یادآوری">
|
||||
<UiSelect v-model="form.reminderMinutesBefore">
|
||||
<option v-for="o in reminderOptions" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
<label class="tg">
|
||||
<input v-model="form.isActive" type="checkbox" />
|
||||
<span><strong>روتین فعال است</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
</UiCard>
|
||||
|
||||
<a-alert type="info" show-icon>
|
||||
<template #message>خلاصه</template>
|
||||
<template #description>
|
||||
<a-typography-paragraph :style="{ marginBottom: 0 }">
|
||||
{{ summary }}
|
||||
</a-typography-paragraph>
|
||||
</template>
|
||||
</a-alert>
|
||||
<div class="summary">
|
||||
<span>خلاصه</span>
|
||||
<p>{{ summary }}</p>
|
||||
</div>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
<a-space direction="vertical" style="width: 100%">
|
||||
<a-button type="primary" html-type="submit" block :loading="saving">
|
||||
{{ isEdit ? 'ذخیره تغییرات' : 'ایجاد روتین' }}
|
||||
</a-button>
|
||||
<a-button block :disabled="saving" @click="router.push(backTo)">
|
||||
انصراف
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-flex>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</CrmSkeletonCard>
|
||||
</CrmSkeleton>
|
||||
</a-flex>
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<div class="actions">
|
||||
<UiButton type="submit" :loading="saving" block>{{ isEdit ? 'ذخیره تغییرات' : 'ایجاد روتین' }}</UiButton>
|
||||
<UiButton variant="ghost" block @click="router.push('/routines/manage')">انصراف</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.rform {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: var(--sp-8);
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 360px;
|
||||
gap: var(--sp-4);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.col {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.side {
|
||||
position: sticky;
|
||||
top: var(--sp-4);
|
||||
}
|
||||
|
||||
.sec-title {
|
||||
margin: 0 0 var(--sp-4);
|
||||
font-size: var(--fs-md);
|
||||
font-weight: var(--fw-semibold);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.fields {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.grid-2 {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.toggles {
|
||||
display: grid;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.tg {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--sp-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tg.nested {
|
||||
margin-inline-start: 26px;
|
||||
}
|
||||
|
||||
.tg input {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin-top: 2px;
|
||||
accent-color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tg span {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.tg strong {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: var(--fw-medium);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.tg small {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.mt {
|
||||
margin-top: var(--sp-4);
|
||||
}
|
||||
|
||||
.summary {
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border-radius: var(--radius);
|
||||
background: var(--accent-subtle);
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
|
||||
}
|
||||
|
||||
.summary span {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--accent-deep);
|
||||
font-weight: var(--fw-semibold);
|
||||
}
|
||||
|
||||
.summary p {
|
||||
margin: 4px 0 0;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--ink);
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
|
||||
.self-note {
|
||||
margin: 0;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--muted);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.side {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.grid-2 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
import { computed, inject, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import type { RoutineDto } from '@mento/shared';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { UiBadge, UiEmptyState, UiSearch } from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import {
|
||||
@@ -14,27 +16,6 @@ import {
|
||||
formatPercent,
|
||||
percentTone,
|
||||
} from '@/lib/routines';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Avatar as AAvatar,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Input as AInput,
|
||||
Progress as AProgress,
|
||||
Row as ARow,
|
||||
Space as ASpace,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import { SearchOutlined, SyncOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const activityPriorities = useActivityPriorities();
|
||||
@@ -68,63 +49,24 @@ const filtered = computed(() => {
|
||||
if (!term) return items.value;
|
||||
return items.value.filter((r) => r.title.includes(term) || (r.description ?? '').includes(term));
|
||||
});
|
||||
|
||||
const PRIORITY_TAG_COLORS: Record<string, string> = {
|
||||
neutral: 'default',
|
||||
info: 'processing',
|
||||
warning: 'warning',
|
||||
danger: 'error',
|
||||
success: 'success',
|
||||
accent: 'cyan',
|
||||
};
|
||||
|
||||
function priorityColor(priority: RoutineDto['priority']) {
|
||||
return PRIORITY_TAG_COLORS[PRIORITY_VARIANTS[priority]] ?? 'default';
|
||||
}
|
||||
|
||||
const TONE_COLORS: Record<string, string> = {
|
||||
good: 'var(--ant-color-success)',
|
||||
mid: 'var(--ant-color-warning)',
|
||||
low: 'var(--ant-color-error)',
|
||||
none: 'var(--ant-color-text-quaternary)',
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-card :bordered="false">
|
||||
<a-flex vertical :gap="16">
|
||||
<a-row :gutter="[16, 12]" align="middle">
|
||||
<a-col :xs="24" :md="16">
|
||||
<a-typography-text type="secondary">
|
||||
روتینهای شما. کارهای هر روز از روی اینها ساخته میشوند. با «روتین جدید» میتوانید برای خودتان برنامه تکراری بسازید.
|
||||
</a-typography-text>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-input v-model:value="q" allow-clear placeholder="جستجوی روتین…">
|
||||
<template #prefix><SearchOutlined /></template>
|
||||
</a-input>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="rlist">
|
||||
<div class="toolbar">
|
||||
<p class="lead">روتینهای شما. کارهای هر روز از روی اینها ساخته میشوند. با «روتین جدید» میتوانید برای خودتان برنامه تکراری بسازید.</p>
|
||||
<UiSearch v-model="q" placeholder="جستجوی روتین…" class="search" />
|
||||
</div>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<div v-if="loading" class="state">در حال بارگذاری…</div>
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<template v-if="loading">
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col v-for="i in 6" :key="i" :xs="24" :sm="12" :xl="8">
|
||||
<CrmSkeletonCard :rows="4" :min-height="180" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-empty
|
||||
v-if="!filtered.length"
|
||||
:description="
|
||||
q
|
||||
? 'روتینی با این عنوان پیدا نشد'
|
||||
: 'هنوز روتینی برای شما نیست. با دکمه «روتین جدید» یک برنامه تکراری برای خودتان بسازید. روتینی که مدیر برای شما تعریف کرده هم اینجا دیده میشود.'
|
||||
"
|
||||
/>
|
||||
<UiEmptyState
|
||||
v-else-if="!filtered.length"
|
||||
icon="refresh"
|
||||
:title="q ? 'روتینی با این عنوان پیدا نشد' : 'هنوز روتینی برای شما نیست'"
|
||||
description="با دکمه «روتین جدید» یک برنامه تکراری برای خودتان بسازید. روتینی که مدیر برای شما تعریف کرده هم اینجا دیده میشود."
|
||||
/>
|
||||
|
||||
<div v-else class="cards">
|
||||
<article v-for="r in filtered" :key="r.id" class="rcard">
|
||||
@@ -162,3 +104,168 @@ const TONE_COLORS: Record<string, string> = {
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.rlist {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.lead {
|
||||
margin: 0;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.search {
|
||||
width: 260px;
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: var(--sp-8);
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.rcard {
|
||||
display: grid;
|
||||
gap: var(--sp-3);
|
||||
align-content: start;
|
||||
padding: var(--sp-4);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface);
|
||||
box-shadow: var(--shadow-xs);
|
||||
}
|
||||
|
||||
.rcard header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.ico {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: #fff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.titles {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.titles h3 {
|
||||
margin: 0;
|
||||
font-size: var(--fs-base);
|
||||
font-weight: var(--fw-semibold);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.titles p {
|
||||
margin: 2px 0 0;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.desc {
|
||||
margin: 0;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--ink-secondary);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.rcard footer {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding-top: var(--sp-3);
|
||||
border-top: 1px solid var(--line-light);
|
||||
}
|
||||
|
||||
.exec {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 4px;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.exec strong {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.bar {
|
||||
grid-column: 1 / -1;
|
||||
height: 5px;
|
||||
border-radius: 99px;
|
||||
background: var(--surface-subtle);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bar b {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--line-strong);
|
||||
}
|
||||
|
||||
.tone-good .bar b {
|
||||
background: var(--success);
|
||||
}
|
||||
|
||||
.tone-mid .bar b {
|
||||
background: var(--warning);
|
||||
}
|
||||
|
||||
.tone-low .bar b {
|
||||
background: var(--danger);
|
||||
}
|
||||
|
||||
.since {
|
||||
color: var(--muted-light);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.edit {
|
||||
justify-self: start;
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: var(--fw-medium);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,67 +3,23 @@ import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { Select as ASelect } from 'ant-design-vue';
|
||||
import type { RoutineCategoryDto, RoutineDto } from '@mento/shared';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import UserAvatar from '@/components/UserAvatar.vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import {
|
||||
UiBadge,
|
||||
UiButton,
|
||||
UiDropdownMenu,
|
||||
UiEmptyState,
|
||||
UiField,
|
||||
UiInput,
|
||||
UiModal,
|
||||
UiSearch,
|
||||
UiSegmented,
|
||||
UiSelect,
|
||||
} from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { ROUTINES_CTX, apiError, formatPercent, percentTone } from '@/lib/routines';
|
||||
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Badge as ABadge,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Dropdown as ADropdown,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
Menu as AMenu,
|
||||
MenuItem as AMenuItem,
|
||||
Modal as AModal,
|
||||
Progress as AProgress,
|
||||
Row as ARow,
|
||||
Segmented as ASegmented,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Switch as ASwitch,
|
||||
Table as ATable,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import {
|
||||
CheckOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
AppstoreOutlined,
|
||||
MoreOutlined,
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
TeamOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const MANAGE_COL_LABELS = [
|
||||
'عنوان',
|
||||
'مسئول',
|
||||
'تکرار',
|
||||
'ساعت',
|
||||
'وضعیت',
|
||||
'درصد انجام',
|
||||
'عملیات',
|
||||
] as const;
|
||||
|
||||
registerTableColumns('routines-manage', [...MANAGE_COL_LABELS]);
|
||||
const tableCols = useTableColumns(() => 'routines-manage');
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const router = useRouter();
|
||||
@@ -100,37 +56,6 @@ const statusOptions = [
|
||||
{ value: 'inactive' as const, label: 'غیرفعال' },
|
||||
];
|
||||
|
||||
const assigneeOptions = computed(() => [
|
||||
{ value: '', label: 'همه مسئولها' },
|
||||
{
|
||||
label: 'کاربران',
|
||||
options: users.value.map((u) => ({ value: u.id, label: u.fullName })),
|
||||
},
|
||||
...(teams.value.length
|
||||
? [
|
||||
{
|
||||
label: 'تیمها',
|
||||
options: teams.value.map((t) => ({ value: `team:${t.id}`, label: t.name })),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]);
|
||||
|
||||
const reassignOptions = computed(() => [
|
||||
{
|
||||
label: 'کاربران',
|
||||
options: users.value.map((u) => ({ value: u.id, label: u.fullName })),
|
||||
},
|
||||
...(teams.value.length
|
||||
? [
|
||||
{
|
||||
label: 'کل اعضای تیم',
|
||||
options: teams.value.map((t) => ({ value: `team:${t.id}`, label: t.name })),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]);
|
||||
|
||||
const filtered = computed(() => {
|
||||
const term = q.value.trim();
|
||||
return items.value.filter((r) => {
|
||||
@@ -148,36 +73,6 @@ const counts = computed(() => ({
|
||||
active: items.value.filter((r) => r.isActive).length,
|
||||
}));
|
||||
|
||||
const columns = computed<TableColumnsType<RoutineDto>>(() => {
|
||||
const all: TableColumnsType<RoutineDto> = [
|
||||
{ title: 'عنوان', key: 'عنوان' },
|
||||
{ title: 'مسئول', key: 'مسئول' },
|
||||
{ title: 'تکرار', dataIndex: 'recurrenceLabel', key: 'تکرار' },
|
||||
{
|
||||
title: 'ساعت',
|
||||
key: 'ساعت',
|
||||
customRender: ({ record }) => toFaDigits(record.timeOfDay),
|
||||
},
|
||||
{ title: 'وضعیت', key: 'وضعیت' },
|
||||
{ title: 'درصد انجام', key: 'درصد انجام', width: 180 },
|
||||
{ title: 'عملیات', key: 'عملیات', fixed: 'left', width: 110 },
|
||||
];
|
||||
return all.filter((col) => {
|
||||
const key = String(col.key ?? '');
|
||||
if (!MANAGE_COL_LABELS.includes(key as (typeof MANAGE_COL_LABELS)[number])) {
|
||||
return true;
|
||||
}
|
||||
return tableCols.isVisible(key);
|
||||
});
|
||||
});
|
||||
|
||||
const TONE_COLORS: Record<string, string> = {
|
||||
good: 'var(--ant-color-success)',
|
||||
mid: 'var(--ant-color-warning)',
|
||||
low: 'var(--ant-color-error)',
|
||||
none: 'var(--ant-color-text-quaternary)',
|
||||
};
|
||||
|
||||
function replace(updated: RoutineDto) {
|
||||
const i = items.value.findIndex((r) => r.id === updated.id);
|
||||
if (i >= 0) items.value[i] = updated;
|
||||
@@ -314,15 +209,6 @@ async function deleteCat(c: RoutineCategoryDto) {
|
||||
}
|
||||
}
|
||||
|
||||
function onRowMenu({ key }: { key: string | number }, r: RoutineDto) {
|
||||
if (String(key) === 'edit') void router.push(`/routines/manage/${r.id}/edit`);
|
||||
else if (String(key) === 'reassign') openReassign(r);
|
||||
else if (String(key) === 'duplicate') void duplicate(r);
|
||||
else if (String(key) === 'toggle') void toggle(r);
|
||||
else if (String(key) === 'remove') removing.value = r;
|
||||
menuFor.value = null;
|
||||
}
|
||||
|
||||
const users = computed(() => shell.context.value?.users ?? []);
|
||||
const teams = computed(() => shell.context.value?.teams ?? []);
|
||||
|
||||
@@ -388,14 +274,12 @@ function selectPopupContainer(node: HTMLElement) {
|
||||
</UiButton>
|
||||
</div>
|
||||
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8">
|
||||
<a-typography-text type="secondary">
|
||||
{{ toFaDigits(counts.total) }} روتین · {{ toFaDigits(counts.active) }} فعال
|
||||
</a-typography-text>
|
||||
<TableColumnsMenu table-key="routines-manage" align="end" />
|
||||
</a-flex>
|
||||
<p class="summary">
|
||||
{{ toFaDigits(counts.total) }} روتین · {{ toFaDigits(counts.active) }} فعال
|
||||
</p>
|
||||
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<div v-if="loading" class="state">در حال بارگذاری…</div>
|
||||
|
||||
<UiEmptyState
|
||||
v-else-if="!filtered.length"
|
||||
@@ -463,208 +347,374 @@ function selectPopupContainer(node: HTMLElement) {
|
||||
:aria-label="r.isActive ? 'غیرفعال کردن' : 'فعال کردن'"
|
||||
@click="toggle(r)"
|
||||
>
|
||||
<a-button
|
||||
v-if="!items.length"
|
||||
type="primary"
|
||||
@click="router.push('/routines/manage/new')"
|
||||
<i />
|
||||
</button>
|
||||
<UiBadge size="sm" :variant="r.isActive ? 'success' : 'neutral'">
|
||||
{{ r.isActive ? 'فعال' : 'غیرفعال' }}
|
||||
</UiBadge>
|
||||
</td>
|
||||
<td>
|
||||
<div class="exec" :class="`tone-${percentTone(r.executionRate)}`">
|
||||
<strong>{{ formatPercent(r.executionRate) }}</strong>
|
||||
<i class="bar"><b :style="{ width: `${r.executionRate ?? 0}%` }" /></i>
|
||||
<small v-if="r.executionTotal">
|
||||
{{ toFaDigits(r.executionDone) }} از {{ toFaDigits(r.executionTotal) }}
|
||||
</small>
|
||||
</div>
|
||||
</td>
|
||||
<td class="actions-cell">
|
||||
<div class="crm-table-actions">
|
||||
<UiButton
|
||||
variant="icon"
|
||||
size="sm"
|
||||
aria-label="ویرایش"
|
||||
@click="router.push(`/routines/manage/${r.id}/edit`)"
|
||||
>
|
||||
ساخت اولین روتین
|
||||
</a-button>
|
||||
</a-empty>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'عنوان'">
|
||||
<a-space :size="8" align="start">
|
||||
<a-badge :color="record.category?.color ?? undefined" />
|
||||
<a-flex vertical :gap="0">
|
||||
<a-typography-text strong :type="record.isActive ? undefined : 'secondary'">
|
||||
{{ record.title }}
|
||||
</a-typography-text>
|
||||
<a-typography-text type="secondary">
|
||||
{{ record.category?.name ?? 'بدون دسته' }}
|
||||
<template v-if="record.isMandatory"> · اجباری</template>
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'مسئول'">
|
||||
<a-space v-if="record.team" :size="8">
|
||||
<a-typography-text :style="{ color: 'var(--ant-color-primary)' }">
|
||||
<TeamOutlined />
|
||||
</a-typography-text>
|
||||
<a-typography-text>تیم {{ record.team.name }}</a-typography-text>
|
||||
</a-space>
|
||||
<a-space v-else-if="record.assignee" :size="8">
|
||||
<UserAvatar :name="record.assignee.fullName" :user-id="record.assignee.id" :size="24" />
|
||||
<a-typography-text>{{ record.assignee.fullName }}</a-typography-text>
|
||||
</a-space>
|
||||
<a-typography-text v-else type="secondary">—</a-typography-text>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'وضعیت'">
|
||||
<a-space :size="8">
|
||||
<a-switch
|
||||
:checked="record.isActive"
|
||||
:loading="busyId === record.id"
|
||||
:aria-label="record.isActive ? 'غیرفعال کردن' : 'فعال کردن'"
|
||||
@change="toggle(record as RoutineDto)"
|
||||
/>
|
||||
<a-tag :color="record.isActive ? 'success' : 'default'" :bordered="false">
|
||||
{{ record.isActive ? 'فعال' : 'غیرفعال' }}
|
||||
</a-tag>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'درصد انجام'">
|
||||
<a-flex vertical :gap="0" :style="{ minWidth: '8rem' }">
|
||||
<a-flex align="center" :gap="8">
|
||||
<a-typography-text strong>{{ formatPercent(record.executionRate) }}</a-typography-text>
|
||||
<a-progress
|
||||
:percent="Math.max(0, Math.min(100, Math.round(record.executionRate ?? 0)))"
|
||||
:show-info="false"
|
||||
:stroke-color="TONE_COLORS[percentTone(record.executionRate)]"
|
||||
:style="{ flex: 1 }"
|
||||
/>
|
||||
</a-flex>
|
||||
<a-typography-text v-if="record.executionTotal" type="secondary">
|
||||
{{ toFaDigits(record.executionDone) }} از {{ toFaDigits(record.executionTotal) }}
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'عملیات'">
|
||||
<a-space :size="4">
|
||||
<a-button
|
||||
type="text"
|
||||
aria-label="ویرایش"
|
||||
@click="router.push(`/routines/manage/${record.id}/edit`)"
|
||||
>
|
||||
<template #icon><EditOutlined /></template>
|
||||
</a-button>
|
||||
<a-dropdown
|
||||
:open="menuFor === record.id"
|
||||
trigger="click"
|
||||
@update:open="(v: boolean) => (menuFor = v ? record.id : null)"
|
||||
>
|
||||
<a-button type="text" aria-label="عملیات بیشتر">
|
||||
<template #icon><MoreOutlined /></template>
|
||||
</a-button>
|
||||
<template #overlay>
|
||||
<a-menu @click="(info) => onRowMenu(info, record as RoutineDto)">
|
||||
<a-menu-item key="edit">ویرایش</a-menu-item>
|
||||
<a-menu-item key="reassign">تغییر مسئول</a-menu-item>
|
||||
<a-menu-item key="duplicate">کپی روتین</a-menu-item>
|
||||
<a-menu-item key="toggle">
|
||||
{{ record.isActive ? 'غیرفعال کردن' : 'فعال کردن' }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="remove" danger>حذف</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</CrmSkeletonTable>
|
||||
</CrmSkeleton>
|
||||
</a-flex>
|
||||
<UiIcon name="pencil" :size="15" />
|
||||
</UiButton>
|
||||
<UiDropdownMenu
|
||||
:open="menuFor === r.id"
|
||||
@update:open="(v: boolean) => (menuFor = v ? r.id : null)"
|
||||
>
|
||||
<template #trigger="{ toggle: t }">
|
||||
<UiButton variant="icon" size="sm" aria-label="عملیات بیشتر" @click="t">
|
||||
<UiIcon name="dots" :size="16" />
|
||||
</UiButton>
|
||||
</template>
|
||||
<button type="button" @click="router.push(`/routines/manage/${r.id}/edit`)">ویرایش</button>
|
||||
<button type="button" @click="openReassign(r)">تغییر مسئول</button>
|
||||
<button type="button" @click="duplicate(r)">کپی روتین</button>
|
||||
<button type="button" @click="toggle(r)">{{ r.isActive ? 'غیرفعال کردن' : 'فعال کردن' }}</button>
|
||||
<button type="button" class="danger" @click="removing = r">حذف</button>
|
||||
</UiDropdownMenu>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<a-modal
|
||||
:open="!!removing"
|
||||
title="حذف روتین"
|
||||
:confirm-loading="removeBusy"
|
||||
ok-text="حذف روتین"
|
||||
cancel-text="انصراف"
|
||||
:ok-button-props="{ danger: true }"
|
||||
@ok="confirmRemove"
|
||||
@cancel="removing = null"
|
||||
>
|
||||
<a-typography-text>
|
||||
<!-- حذف -->
|
||||
<UiModal :open="!!removing" title="حذف روتین" @close="removing = null">
|
||||
<p class="confirm">
|
||||
روتین «{{ removing?.title }}» حذف شود؟ کارهای انجامنشده امروزِ آن لغو میشوند؛ سوابق قبلی در گزارشها باقی
|
||||
میماند.
|
||||
</a-typography-text>
|
||||
</a-modal>
|
||||
</p>
|
||||
<template #footer>
|
||||
<UiButton variant="danger" :loading="removeBusy" @click="confirmRemove">حذف روتین</UiButton>
|
||||
<UiButton variant="ghost" @click="removing = null">انصراف</UiButton>
|
||||
</template>
|
||||
</UiModal>
|
||||
|
||||
<a-modal
|
||||
:open="!!reassign.routine"
|
||||
title="تغییر مسئول روتین"
|
||||
:confirm-loading="reassign.saving"
|
||||
ok-text="ذخیره"
|
||||
cancel-text="انصراف"
|
||||
@ok="saveReassign"
|
||||
@cancel="reassign.routine = null"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-typography-text strong>{{ reassign.routine?.title }}</a-typography-text>
|
||||
<a-form-item
|
||||
label="مسئول جدید"
|
||||
extra="کارهای انجامنشده امروز به مسئول جدید منتقل میشوند."
|
||||
:style="{ marginTop: '16px' }"
|
||||
>
|
||||
<a-select
|
||||
v-model:value="reassign.target"
|
||||
:options="reassignOptions"
|
||||
placeholder="انتخاب کنید"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-alert v-if="reassign.error" type="error" show-icon :message="reassign.error" />
|
||||
</a-form>
|
||||
</a-modal>
|
||||
<!-- تغییر مسئول -->
|
||||
<UiModal :open="!!reassign.routine" title="تغییر مسئول روتین" @close="reassign.routine = null">
|
||||
<div class="form">
|
||||
<p class="confirm">{{ reassign.routine?.title }}</p>
|
||||
<UiField label="مسئول جدید" hint="کارهای انجامنشده امروز به مسئول جدید منتقل میشوند.">
|
||||
<UiSelect v-model="reassign.target">
|
||||
<option value="" disabled>انتخاب کنید</option>
|
||||
<optgroup label="کاربران">
|
||||
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
|
||||
</optgroup>
|
||||
<optgroup v-if="teams.length" label="کل اعضای تیم">
|
||||
<option v-for="t in teams" :key="t.id" :value="`team:${t.id}`">{{ t.name }}</option>
|
||||
</optgroup>
|
||||
</UiSelect>
|
||||
</UiField>
|
||||
<p v-if="reassign.error" class="error">{{ reassign.error }}</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
<UiButton :loading="reassign.saving" @click="saveReassign">ذخیره</UiButton>
|
||||
<UiButton variant="ghost" @click="reassign.routine = null">انصراف</UiButton>
|
||||
</template>
|
||||
</UiModal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="catsOpen"
|
||||
title="دستهبندی کارها"
|
||||
:confirm-loading="catForm.saving"
|
||||
:ok-text="catForm.id ? 'ذخیره تغییرات' : 'افزودن دسته'"
|
||||
cancel-text="بستن"
|
||||
@ok="saveCat"
|
||||
>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-flex vertical :gap="4">
|
||||
<a-flex
|
||||
v-for="c in categories"
|
||||
:key="c.id"
|
||||
align="center"
|
||||
:gap="8"
|
||||
>
|
||||
<a-badge :color="c.color" />
|
||||
<a-typography-text :style="{ flex: 1 }">{{ c.name }}</a-typography-text>
|
||||
<a-button type="text" aria-label="ویرایش" @click="editCat(c)">
|
||||
<template #icon><EditOutlined /></template>
|
||||
</a-button>
|
||||
<a-button type="text" danger aria-label="حذف" @click="deleteCat(c)">
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
</a-button>
|
||||
</a-flex>
|
||||
<a-empty v-if="!categories.length" description="دستهای تعریف نشده است." />
|
||||
</a-flex>
|
||||
|
||||
<a-divider :style="{ margin: 0 }" />
|
||||
|
||||
<a-form layout="vertical">
|
||||
<a-form-item :label="catForm.id ? 'ویرایش دسته' : 'دسته جدید'">
|
||||
<a-input v-model:value="catForm.name" placeholder="مثلاً: پشتیبانی" :maxlength="60" />
|
||||
</a-form-item>
|
||||
<a-form-item label="رنگ">
|
||||
<a-space :size="8" wrap>
|
||||
<a-button
|
||||
v-for="col in CAT_COLORS"
|
||||
:key="col"
|
||||
shape="circle"
|
||||
:style="{
|
||||
background: col,
|
||||
borderColor: col,
|
||||
color: token.colorWhite,
|
||||
}"
|
||||
:aria-label="col"
|
||||
@click="catForm.color = col"
|
||||
>
|
||||
<template v-if="catForm.color === col" #icon><CheckOutlined /></template>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-alert v-if="catForm.error" type="error" show-icon :message="catForm.error" />
|
||||
<a-button v-if="catForm.id" @click="editCat(null)">انصراف از ویرایش</a-button>
|
||||
</a-form>
|
||||
</a-flex>
|
||||
</a-modal>
|
||||
</a-card>
|
||||
<!-- دستهبندیها -->
|
||||
<UiModal :open="catsOpen" title="دستهبندی کارها" @close="catsOpen = false">
|
||||
<div class="form">
|
||||
<ul class="cat-list">
|
||||
<li v-for="c in categories" :key="c.id">
|
||||
<span class="cat-dot" :style="{ background: c.color }" />
|
||||
<span class="cat-name">{{ c.name }}</span>
|
||||
<UiButton variant="icon" size="sm" aria-label="ویرایش" @click="editCat(c)">
|
||||
<UiIcon name="pencil" :size="14" />
|
||||
</UiButton>
|
||||
<UiButton variant="icon" size="sm" aria-label="حذف" @click="deleteCat(c)">
|
||||
<UiIcon name="trash" :size="14" />
|
||||
</UiButton>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cat-form">
|
||||
<UiField :label="catForm.id ? 'ویرایش دسته' : 'دسته جدید'">
|
||||
<UiInput v-model="catForm.name" placeholder="مثلاً: پشتیبانی" :maxlength="60" />
|
||||
</UiField>
|
||||
<div class="swatches" role="radiogroup" aria-label="رنگ">
|
||||
<button
|
||||
v-for="col in CAT_COLORS"
|
||||
:key="col"
|
||||
type="button"
|
||||
class="swatch"
|
||||
:class="{ on: catForm.color === col }"
|
||||
:style="{ background: col }"
|
||||
:aria-label="col"
|
||||
@click="catForm.color = col"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="catForm.error" class="error">{{ catForm.error }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<UiButton :loading="catForm.saving" @click="saveCat">{{ catForm.id ? 'ذخیره تغییرات' : 'افزودن دسته' }}</UiButton>
|
||||
<UiButton v-if="catForm.id" variant="ghost" @click="editCat(null)">انصراف از ویرایش</UiButton>
|
||||
<UiButton variant="ghost" @click="catsOpen = false">بستن</UiButton>
|
||||
</template>
|
||||
</UiModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.manage {
|
||||
display: grid;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
|
||||
.search {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.who {
|
||||
width: 190px;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin: 0;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: var(--sp-8);
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
tr.inactive td {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
tr.inactive .title-cell strong {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.title-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.title-cell div {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.title-cell strong {
|
||||
font-weight: var(--fw-semibold);
|
||||
}
|
||||
|
||||
.title-cell small {
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.cat-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.who-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.team-ico {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--accent-subtle);
|
||||
color: var(--accent-deep);
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td:has(.switch) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.switch {
|
||||
width: 34px;
|
||||
height: 20px;
|
||||
padding: 2px;
|
||||
margin-inline-end: 8px;
|
||||
border: 0;
|
||||
border-radius: 99px;
|
||||
background: var(--line-strong);
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
transition: background var(--transition-fast);
|
||||
}
|
||||
|
||||
.switch i {
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
box-shadow: var(--shadow-xs);
|
||||
transition: transform var(--transition-fast);
|
||||
}
|
||||
|
||||
.switch.on {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
/* RTL: روشن = دکمه سمت چپ */
|
||||
.switch.on i {
|
||||
transform: translateX(-14px);
|
||||
}
|
||||
|
||||
.exec {
|
||||
display: grid;
|
||||
grid-template-columns: auto 80px;
|
||||
align-items: center;
|
||||
gap: 2px 8px;
|
||||
min-width: 130px;
|
||||
}
|
||||
|
||||
.exec small {
|
||||
grid-column: 1 / -1;
|
||||
color: var(--muted);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.bar {
|
||||
height: 6px;
|
||||
border-radius: 99px;
|
||||
background: var(--surface-subtle);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bar b {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--line-strong);
|
||||
}
|
||||
|
||||
.tone-good .bar b {
|
||||
background: var(--success);
|
||||
}
|
||||
|
||||
.tone-mid .bar b {
|
||||
background: var(--warning);
|
||||
}
|
||||
|
||||
.tone-low .bar b {
|
||||
background: var(--danger);
|
||||
}
|
||||
|
||||
:global(.ui-dd-panel button.danger) {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.confirm {
|
||||
margin: 0;
|
||||
line-height: 1.8;
|
||||
color: var(--ink-secondary);
|
||||
}
|
||||
|
||||
.form {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.cat-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cat-list li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 6px 10px;
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface-subtle);
|
||||
}
|
||||
|
||||
.cat-name {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.cat-form {
|
||||
display: grid;
|
||||
gap: var(--sp-3);
|
||||
padding-top: var(--sp-3);
|
||||
border-top: 1px solid var(--line-light);
|
||||
}
|
||||
|
||||
.swatches {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.swatch {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--surface);
|
||||
box-shadow: 0 0 0 1px var(--line);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.swatch.on {
|
||||
box-shadow: 0 0 0 2px var(--ink);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.search,
|
||||
.who {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
import { computed, inject, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import type { RoutineTaskDto } from '@mento/shared';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import UserAvatar from '@/components/UserAvatar.vue';
|
||||
import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
|
||||
import RoutineTaskRow, { type RoutineTaskRowAction } from '@/components/routines/RoutineTaskRow.vue';
|
||||
import RoutineTaskModals from '@/components/routines/RoutineTaskModals.vue';
|
||||
import { UiBadge, UiButton, UiEmptyState, UiSelect } from '@/components/ui';
|
||||
import { api } from '@/lib/api';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
@@ -20,40 +22,6 @@ import {
|
||||
hasExplicitTime,
|
||||
} from '@/lib/routines';
|
||||
import { useRoutineTaskActions } from '@/lib/useRoutineTaskActions';
|
||||
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Badge as ABadge,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
Table as ATable,
|
||||
Tag as ATag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { WarningOutlined } from '@/icons/ant-bridge';
|
||||
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
|
||||
|
||||
const { Text: ATypographyText, Link: ATypographyLink } = Typography;
|
||||
|
||||
const OVERDUE_COL_LABELS = [
|
||||
'کار',
|
||||
'مهلت',
|
||||
'تأخیر',
|
||||
'مسئول',
|
||||
'اولویت',
|
||||
'پرونده',
|
||||
'عملیات',
|
||||
] as const;
|
||||
|
||||
registerTableColumns('routines-overdue', [...OVERDUE_COL_LABELS]);
|
||||
const tableCols = useTableColumns(() => 'routines-overdue');
|
||||
|
||||
const shell = inject(ROUTINES_CTX)!;
|
||||
const activityPriorities = useActivityPriorities();
|
||||
@@ -67,12 +35,6 @@ const who = ref('');
|
||||
const isManager = computed(() => !!shell.context.value?.isManager);
|
||||
const users = computed(() => shell.context.value?.users ?? []);
|
||||
|
||||
const whoOptions = computed(() => [
|
||||
{ value: '', label: 'کارهای خودم' },
|
||||
{ value: 'all', label: 'همه اعضای تیم' },
|
||||
...users.value.map((u) => ({ value: u.id, label: u.fullName })),
|
||||
]);
|
||||
|
||||
async function load(silent = false) {
|
||||
if (!silent) loading.value = true;
|
||||
error.value = '';
|
||||
@@ -102,87 +64,36 @@ const actions = useRoutineTaskActions((updated) => {
|
||||
shell.notifyChanged();
|
||||
});
|
||||
|
||||
function onAction(kind: RoutineTaskRowAction, task: RoutineTaskDto) {
|
||||
if (kind === 'complete-note') actions.openComplete(task);
|
||||
else if (kind === 'reschedule') actions.openReschedule(task);
|
||||
else if (kind === 'move-today') void actions.moveToday(task);
|
||||
else if (kind === 'skip') actions.openSkip(task);
|
||||
else if (kind === 'cancel') actions.openCancel(task);
|
||||
}
|
||||
|
||||
const showAssignee = computed(() => isManager.value && who.value !== '');
|
||||
|
||||
const PRIORITY_TAG_COLORS: Record<string, string> = {
|
||||
neutral: 'default',
|
||||
info: 'processing',
|
||||
warning: 'warning',
|
||||
danger: 'error',
|
||||
success: 'success',
|
||||
};
|
||||
|
||||
function priorityColor(priority: RoutineTaskDto['priority']) {
|
||||
return PRIORITY_TAG_COLORS[PRIORITY_VARIANTS[priority]] ?? 'default';
|
||||
}
|
||||
|
||||
const columns = computed<TableColumnsType<RoutineTaskDto>>(() => {
|
||||
const all: TableColumnsType<RoutineTaskDto> = [
|
||||
{ title: 'کار', key: 'کار' },
|
||||
{ title: 'مهلت', key: 'مهلت' },
|
||||
{ title: 'تأخیر', key: 'تأخیر' },
|
||||
...(showAssignee.value
|
||||
? [{ title: 'مسئول', key: 'مسئول' } as const]
|
||||
: []),
|
||||
{ title: 'اولویت', key: 'اولویت' },
|
||||
{ title: 'پرونده', key: 'پرونده' },
|
||||
{ title: 'عملیات', key: 'عملیات', fixed: 'left', width: 340 },
|
||||
];
|
||||
return all.filter((col) => {
|
||||
const key = String(col.key ?? '');
|
||||
if (!OVERDUE_COL_LABELS.includes(key as (typeof OVERDUE_COL_LABELS)[number])) {
|
||||
return true;
|
||||
}
|
||||
return tableCols.isVisible(key);
|
||||
});
|
||||
});
|
||||
|
||||
function rowProps(record: RoutineTaskDto) {
|
||||
return {
|
||||
onClick: () => shell.openTask(record.id),
|
||||
style: { cursor: 'pointer' },
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-card :bordered="false">
|
||||
<a-row :gutter="[16, 0]" align="middle">
|
||||
<a-col :xs="24" :md="showAssignee || isManager ? 16 : 24">
|
||||
<a-typography-text type="secondary">
|
||||
<WarningOutlined :style="{ color: 'var(--ant-color-error)' }" />
|
||||
<template v-if="items.length">{{ toFaDigits(items.length) }} کار از مهلتش گذشته است.</template>
|
||||
<template v-else>کار عقبافتادهای ندارید.</template>
|
||||
</a-typography-text>
|
||||
</a-col>
|
||||
<a-col v-if="isManager" :xs="24" :md="8">
|
||||
<a-select
|
||||
v-model:value="who"
|
||||
:options="whoOptions"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="overdue">
|
||||
<div class="toolbar">
|
||||
<p class="lead">
|
||||
<UiIcon name="warning" :size="16" />
|
||||
<template v-if="items.length">{{ toFaDigits(items.length) }} کار از مهلتش گذشته است.</template>
|
||||
<template v-else>کار عقبافتادهای ندارید.</template>
|
||||
</p>
|
||||
<UiSelect v-if="isManager" v-model="who" size="sm" class="who">
|
||||
<option value="">کارهای خودم</option>
|
||||
<option value="all">همه اعضای تیم</option>
|
||||
<option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
|
||||
</UiSelect>
|
||||
</div>
|
||||
|
||||
<a-alert
|
||||
v-if="error"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="error"
|
||||
:style="{ marginTop: '16px' }"
|
||||
/>
|
||||
<a-alert
|
||||
v-if="actions.error.value"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="actions.error.value"
|
||||
:style="{ marginTop: '16px' }"
|
||||
/>
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="actions.error.value" class="error">{{ actions.error.value }}</p>
|
||||
|
||||
<a-flex justify="flex-end" :style="{ marginTop: '16px' }">
|
||||
<TableColumnsMenu table-key="routines-overdue" align="end" />
|
||||
</a-flex>
|
||||
<div v-if="loading" class="state">در حال بارگذاری…</div>
|
||||
|
||||
<UiEmptyState
|
||||
v-else-if="!items.length"
|
||||
@@ -247,18 +158,164 @@ function rowProps(record: RoutineTaskDto) {
|
||||
@click="actions.toggle(t)"
|
||||
>
|
||||
انجام شد
|
||||
</a-button>
|
||||
<a-button @click="actions.moveToday(record as RoutineTaskDto)">به امروز</a-button>
|
||||
<a-button @click="actions.openReschedule(record as RoutineTaskDto)">تغییر زمان</a-button>
|
||||
<a-button danger @click="actions.openCancel(record as RoutineTaskDto)">لغو</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</CrmSkeletonTable>
|
||||
</CrmSkeleton>
|
||||
</a-card>
|
||||
</UiButton>
|
||||
<UiButton size="sm" variant="ghost" @click="actions.moveToday(t)">به امروز</UiButton>
|
||||
<UiButton size="sm" variant="ghost" @click="actions.openReschedule(t)">تغییر زمان</UiButton>
|
||||
<UiButton size="sm" variant="ghost" class="danger-text" @click="actions.openCancel(t)">لغو</UiButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- موبایل: کارت -->
|
||||
<div class="mobile rows">
|
||||
<RoutineTaskRow
|
||||
v-for="t in items"
|
||||
:key="t.id"
|
||||
:task="t"
|
||||
:busy="actions.busyId.value === t.id"
|
||||
show-date
|
||||
show-delay
|
||||
:show-assignee="showAssignee"
|
||||
@toggle="actions.toggle"
|
||||
@open="shell.openTask(t.id)"
|
||||
@action="onAction"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<RoutineTaskModals :actions="actions" />
|
||||
</a-flex>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.overdue {
|
||||
display: grid;
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.lead {
|
||||
margin: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--ink-secondary);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.lead :deep(svg) {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.who {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.state {
|
||||
padding: var(--sp-8);
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.title-cell {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.title-cell strong {
|
||||
font-weight: var(--fw-semibold);
|
||||
}
|
||||
|
||||
.cat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.cat i {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.late {
|
||||
color: var(--danger);
|
||||
font-weight: var(--fw-semibold);
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.who-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ent {
|
||||
display: block;
|
||||
color: var(--accent-deep);
|
||||
font-size: var(--fs-xs);
|
||||
white-space: nowrap;
|
||||
max-width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.ent:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.danger-text {
|
||||
color: var(--danger) !important;
|
||||
}
|
||||
|
||||
.rows {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
|
||||
.mobile {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.desk {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.who {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,65 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
Avatar as AAvatar,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
List as AList,
|
||||
Row as ARow,
|
||||
Statistic as AStatistic,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import type { Component } from 'vue';
|
||||
import {
|
||||
AccountBookOutlined,
|
||||
ArrowDownOutlined,
|
||||
ArrowUpOutlined,
|
||||
BankOutlined,
|
||||
CalendarOutlined,
|
||||
FallOutlined,
|
||||
RiseOutlined,
|
||||
WalletOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
import {
|
||||
CrmSkeleton,
|
||||
CrmSkeletonCard,
|
||||
CrmSkeletonKpi,
|
||||
CrmSkeletonList,
|
||||
} from '@/components/skeleton';
|
||||
import { use } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { BarChart, PieChart } from 'echarts/charts';
|
||||
import {
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
TooltipComponent,
|
||||
} from 'echarts/components';
|
||||
import type { ComposeOption } from 'echarts/core';
|
||||
import type { BarSeriesOption, PieSeriesOption } from 'echarts/charts';
|
||||
import type {
|
||||
GridComponentOption,
|
||||
LegendComponentOption,
|
||||
TooltipComponentOption,
|
||||
} from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import { api } from '@/lib/api';
|
||||
import axios from 'axios';
|
||||
import type { TreasuryDashboardDto } from '@mento/shared';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
|
||||
use([CanvasRenderer, BarChart, PieChart, GridComponent, TooltipComponent, LegendComponent]);
|
||||
|
||||
type ChartOption = ComposeOption<
|
||||
| BarSeriesOption
|
||||
| PieSeriesOption
|
||||
| GridComponentOption
|
||||
| TooltipComponentOption
|
||||
| LegendComponentOption
|
||||
>;
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const isMobile = useTreasuryMobile();
|
||||
const AListItem = AList.Item;
|
||||
@@ -67,7 +24,6 @@ const AListItemMeta = AList.Item.Meta;
|
||||
|
||||
const data = ref<TreasuryDashboardDto | null>(null);
|
||||
const error = ref('');
|
||||
const loading = ref(true);
|
||||
|
||||
const cards = [
|
||||
{ key: 'bookedIncome', label: 'درآمد ثبتشده', hint: 'تعهدی' },
|
||||
@@ -81,127 +37,33 @@ const cards = [
|
||||
] as const;
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const res = await api.get<TreasuryDashboardDto>('/treasury/dashboard');
|
||||
data.value = res.data;
|
||||
} catch (e) {
|
||||
data.value = null;
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String(
|
||||
(e.response?.data as { message?: string })?.message ??
|
||||
'بارگذاری داشبورد خزانه ناموفق بود.',
|
||||
)
|
||||
: 'بارگذاری داشبورد خزانه ناموفق بود.';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
} catch {
|
||||
error.value = 'بارگذاری داشبورد مالی ناموفق بود.';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<a-flex vertical :gap="token.margin">
|
||||
<a-flex vertical :gap="16">
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
|
||||
<CrmSkeleton :loading="loading">
|
||||
<a-row :gutter="[token.marginSM, token.marginSM]">
|
||||
<template v-if="data">
|
||||
<a-row :gutter="[16, 16]">
|
||||
<a-col
|
||||
v-for="card in heroCards"
|
||||
:key="card.key"
|
||||
:xs="24"
|
||||
:sm="12"
|
||||
:lg="8"
|
||||
>
|
||||
<CrmSkeletonKpi>
|
||||
<a-card
|
||||
v-if="data"
|
||||
:bordered="false"
|
||||
:body-style="{ padding: `${token.padding}px` }"
|
||||
:style="softCardStyle"
|
||||
>
|
||||
<a-flex align="center" justify="space-between" :gap="token.marginSM">
|
||||
<div :style="{ minWidth: 0, flex: 1 }">
|
||||
<a-typography-text type="secondary">{{ card.label }}</a-typography-text>
|
||||
<div>
|
||||
<a-typography-text
|
||||
strong
|
||||
:style="{
|
||||
fontSize: '22px',
|
||||
lineHeight: 1.3,
|
||||
color: token.colorPrimary,
|
||||
}"
|
||||
>
|
||||
{{ toman(data[card.key]) }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-typography-text type="secondary" :style="{ fontSize: '12px' }">
|
||||
{{ card.hint }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-avatar
|
||||
:size="48"
|
||||
:style="{
|
||||
background: token.colorPrimary,
|
||||
color: token.colorTextLightSolid,
|
||||
flexShrink: 0,
|
||||
}"
|
||||
>
|
||||
<template #icon><component :is="card.icon" /></template>
|
||||
</a-avatar>
|
||||
</a-flex>
|
||||
</a-card>
|
||||
</CrmSkeletonKpi>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="[token.marginSM, token.marginSM]" :style="{ marginTop: `${token.margin}px` }">
|
||||
<a-col
|
||||
v-for="card in secondaryCards"
|
||||
v-for="card in cards"
|
||||
:key="card.key"
|
||||
:xs="24"
|
||||
:sm="12"
|
||||
:md="8"
|
||||
:lg="8"
|
||||
:xl="6"
|
||||
>
|
||||
<CrmSkeletonKpi>
|
||||
<a-card
|
||||
v-if="data"
|
||||
:bordered="false"
|
||||
:body-style="{ padding: `${token.paddingSM}px` }"
|
||||
:style="secondaryCardStyle"
|
||||
>
|
||||
<a-flex align="center" justify="space-between" :gap="8">
|
||||
<div :style="{ minWidth: 0, flex: 1 }">
|
||||
<a-typography-text type="secondary" :style="{ fontSize: '12px' }">
|
||||
{{ card.label }}
|
||||
</a-typography-text>
|
||||
<div>
|
||||
<a-typography-text
|
||||
strong
|
||||
:style="{ fontSize: '15px', color: token.colorPrimary }"
|
||||
>
|
||||
{{ toman(data[card.key]) }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-typography-text type="secondary" :style="{ fontSize: '11px' }">
|
||||
{{ card.hint }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-avatar
|
||||
:size="36"
|
||||
:style="{
|
||||
background: token.colorPrimaryBg,
|
||||
color: token.colorPrimary,
|
||||
flexShrink: 0,
|
||||
}"
|
||||
>
|
||||
<template #icon><component :is="card.icon" /></template>
|
||||
</a-avatar>
|
||||
</a-flex>
|
||||
</a-card>
|
||||
</CrmSkeletonKpi>
|
||||
<a-card :bordered="false">
|
||||
<a-statistic :title="card.label" :value="toman(data[card.key])" />
|
||||
<a-typography-text type="secondary">{{ card.hint }}</a-typography-text>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { DownloadOutlined } from '@/icons/ant-bridge';
|
||||
import { DownloadOutlined } from '@ant-design/icons-vue';
|
||||
import * as XLSX from 'xlsx';
|
||||
import type { TreasuryPartyBalanceDto } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
Reference in New Issue
Block a user