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:
jarvis
2026-11-15 11:49:36 +03:30
co-authored by Claude Haiku 5.5
parent 5cf721f91e
commit 387c5c1676
35 changed files with 8668 additions and 7485 deletions
+98 -59
View File
@@ -1,17 +1,6 @@
<script setup lang="ts">
import { computed, watch } from 'vue';
import {
Alert as AAlert,
Card as ACard,
Checkbox as ACheckbox,
Flex as AFlex,
FormItem as AFormItem,
Radio as ARadio,
RadioGroup as ARadioGroup,
Select as ASelect,
Space as ASpace,
Typography,
} from 'ant-design-vue';
import { Select as ASelect } from 'ant-design-vue';
import type {
DataAccessOwnerKind,
DataAccessRule,
@@ -26,12 +15,9 @@ import {
PERSON_MOODS,
sectionHasDataAccessLimits,
} from '@mento/shared';
export type IdOption = { id: string; name: string };
type Choice = { value: string; label: string };
const { Text: ATypographyText } = Typography;
const props = withDefaults(
defineProps<{
modelValue: SectionDataAccess;
@@ -449,13 +435,17 @@ const filterSummary = computed(() => {
</script>
<template>
<a-flex vertical :gap="compact ? 8 : 12">
<a-radio-group v-model:value="mode" :disabled="disabled">
<a-flex vertical :gap="4">
<a-radio value="all">همهٔ {{ sectionLabel }}</a-radio>
<a-radio value="rules">محدود با فیلتر</a-radio>
</a-flex>
</a-radio-group>
<div class="dae" :class="{ compact }">
<div class="dae-mode">
<label>
<input v-model="mode" type="radio" value="all" :disabled="disabled" />
همهٔ {{ sectionLabel }}
</label>
<label>
<input v-model="mode" type="radio" value="rules" :disabled="disabled" />
محدود با فیلتر
</label>
</div>
<template v-if="mode === 'rules'">
<p class="hint">
@@ -471,37 +461,30 @@ const filterSummary = computed(() => {
</p>
<p class="summary">{{ filterSummary }}</p>
<a-card size="small" title="مالک / مسئول" :bordered="true">
<a-flex vertical :gap="8">
<a-typography-text type="secondary">خالی = بدون محدودیت مالک</a-typography-text>
<a-space wrap :size="8">
<a-checkbox
:checked="filter.owners?.includes('self')"
:disabled="disabled"
@change="toggleOwner('self')"
>
{{ ownerSelfLabel }}
</a-checkbox>
<a-checkbox
:checked="filter.owners?.includes('team')"
:disabled="disabled"
@change="toggleOwner('team')"
>
تیم‌های عضو
</a-checkbox>
</a-space>
</a-flex>
</a-card>
<fieldset :disabled="disabled">
<legend>مالک / مسئول</legend>
<p class="muted">خالی = بدون محدودیت مالک</p>
<label class="chip">
<input
type="checkbox"
:checked="filter.owners?.includes('self')"
@change="toggleOwner('self')"
/>
{{ ownerSelfLabel }}
</label>
<label class="chip">
<input
type="checkbox"
:checked="filter.owners?.includes('team')"
@change="toggleOwner('team')"
/>
تیم‌های عضو
</label>
</fieldset>
<a-form-item
v-for="picker in pickers"
:key="picker.legend"
:label="picker.legend"
:style="{ marginBottom: 0 }"
>
<a-typography-text v-if="picker.loading" type="secondary">
در حال بارگذاری منبع‌ها…
</a-typography-text>
<label v-for="picker in pickers" :key="picker.legend" class="pick">
<span>{{ picker.legend }}</span>
<p v-if="picker.loading" class="muted">در حال بارگذاری منبع‌ها…</p>
<a-select
v-else
:value="pickerValue(picker)"
@@ -516,14 +499,70 @@ const filterSummary = computed(() => {
style="width: 100%"
@update:value="setList(picker.key, $event)"
/>
<a-typography-text v-if="picker.hint" type="secondary">
{{ picker.hint }}
</a-typography-text>
</a-form-item>
<p v-if="picker.hint" class="muted">{{ picker.hint }}</p>
</label>
</template>
<a-typography-text v-else-if="!hasLimits" type="secondary">
<p v-else-if="!hasLimits" class="hint">
بدون محدودیت — همهٔ {{ sectionLabel }} قابل مشاهده‌اند.
</a-typography-text>
</a-flex>
</p>
</div>
</template>
<style scoped>
.dae {
display: grid;
gap: 0.75rem;
}
.dae-mode {
display: grid;
gap: 0.35rem;
}
.dae-mode label,
.chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
font-size: 0.88rem;
margin-inline-end: 0.55rem;
margin-bottom: 0.25rem;
}
.hint,
.muted,
.summary {
color: #64748b;
font-size: 0.82rem;
margin: 0;
}
.hint.warn {
color: #b45309;
}
.summary {
font-weight: 600;
color: #334155;
}
fieldset {
border: 1px dashed #e2e8f0;
border-radius: 8px;
padding: 0.5rem 0.65rem;
margin: 0;
}
legend {
padding-inline: 0.25rem;
font-size: 0.8rem;
color: #475569;
font-weight: 600;
}
.pick {
display: grid;
gap: 0.35rem;
}
.pick > span {
font-size: 0.8rem;
font-weight: 600;
color: #475569;
}
.compact fieldset {
padding: 0.45rem 0.55rem;
}
</style>
+157 -100
View File
@@ -1,15 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import {
Tabs as ATabs,
TabPane as ATabPane,
Typography,
Radio as ARadio,
RadioGroup as ARadioGroup,
Checkbox as ACheckbox,
Space as ASpace,
Input as AInput,
} from 'ant-design-vue';
import type {
DataAccessPolicy,
DataAccessSection,
@@ -28,8 +18,6 @@ import {
import { api } from '@/lib/api';
import DataAccessEditor, { type IdOption } from '@/components/DataAccessEditor.vue';
const { Text: ATypographyText } = Typography;
const props = defineProps<{
modelValue: DataAccessPolicy;
/** فقط بخش‌هایی که این مجوزها را دارند نشان بده؛ خالی = همه */
@@ -125,10 +113,6 @@ function patchTreasury(next: UserTreasuryAccess | null) {
emit('update:treasuryAccess', next);
}
function onTreasuryModeChange(e: { target: { value?: unknown } }) {
patchTreasury(e.target.value === 'role' ? null : (props.treasuryAccess ?? emptyTreasuryAccess()));
}
function toggleTreasurySection(key: RolePermissionKey) {
const current = props.treasuryAccess ?? emptyTreasuryAccess();
const sections = current.sections.includes(key)
@@ -242,102 +226,131 @@ onMounted(() => {
void loadOptions();
void loadTreasuryAccounts();
});
const editorSection = computed<DataAccessSection>(() =>
active.value === 'treasury' ? 'customers' : active.value,
);
const stagesForActive = computed(() => {
if (active.value === 'leads') return leadStages.value;
if (active.value === 'sales') return dealStages.value;
if (active.value === 'activities') return activityStages.value;
if (active.value === 'projects') return projectStages.value;
return [];
});
const boardsForActive = computed(() => {
if (active.value === 'activities') return activityBoards.value;
if (active.value === 'projects') return projectBoards.value;
return [];
});
const typesForActive = computed(() => {
if (active.value === 'activities') return activityTypes.value;
if (active.value === 'routines') return routineCategories.value;
return [];
});
</script>
<template>
<div>
<a-typography-text v-if="!visibleSections.length" type="secondary">
<div class="dap">
<p v-if="!visibleSections.length" class="muted">
برای تنظیم محدوده، ابتدا مجوز بخش مربوط را روشن کنید.
</a-typography-text>
<a-tabs v-else v-model:activeKey="active">
<a-tab-pane
v-for="s in visibleSections"
:key="s"
:tab="DATA_ACCESS_SECTION_LABELS[s]"
>
<DataAccessEditor
:section="s"
:model-value="sectionValue(s)"
:groups="customerGroups"
:stages="s === 'leads' ? leadStages : s === 'sales' ? dealStages : s === 'activities' ? activityStages : s === 'projects' ? projectStages : []"
:pipelines="pipelines"
:boards="s === 'activities' ? activityBoards : s === 'projects' ? projectBoards : []"
:activity-types="s === 'activities' ? activityTypes : s === 'routines' ? routineCategories : []"
:import-sources="importSources"
:import-sources-ready="importSourcesReady"
:import-sources-failed="importSourcesFailed"
:disabled="disabled || dataLocked"
:compact="compact"
@update:model-value="setSection(s, $event)"
/>
</a-tab-pane>
<a-tab-pane v-if="showTreasury" key="treasury" tab="مدیریت مالی">
<a-space direction="vertical">
<a-typography-text type="secondary">
این برگه فقط برای همین کاربر است. «مثل نقش» یعنی همان دسترسی مالی نقش بماند.
در حالت سفارشی، اگر هیچ بخش ریزی تیک نخورد همه بخش‌ها به‌جز حقوق باز می‌مانند و حقوق جداست.
اگر هیچ حسابی انتخاب نشود همه حساب‌ها باز است.
</a-typography-text>
<a-radio-group
:value="treasuryAccess == null ? 'role' : 'custom'"
</p>
<template v-else>
<div class="tabs" role="tablist">
<button
v-for="s in visibleSections"
:key="s"
type="button"
class="tab"
:class="{ on: active === s }"
role="tab"
:aria-selected="active === s"
@click="active = s"
>
{{ DATA_ACCESS_SECTION_LABELS[s] }}
</button>
<button
v-if="showTreasury"
type="button"
class="tab"
:class="{ on: active === 'treasury' }"
role="tab"
:aria-selected="active === 'treasury'"
@click="active = 'treasury'"
>
مدیریت مالی
</button>
</div>
<div v-if="active === 'treasury'" class="treasury">
<p class="muted">
این برگه فقط برای همین کاربر است. «مثل نقش» یعنی همان دسترسی مالی نقش بماند.
در حالت سفارشی، اگر هیچ بخش ریزی تیک نخورد همه بخش‌ها به‌جز حقوق باز می‌مانند و حقوق جداست.
اگر هیچ حسابی انتخاب نشود همه حساب‌ها باز است.
</p>
<label class="choice">
<input
type="radio"
name="user-treasury"
:checked="treasuryAccess == null"
:disabled="disabled"
@change="onTreasuryModeChange"
>
<a-space direction="vertical">
<a-radio value="role">مثل نقش</a-radio>
<a-radio value="custom">سفارشی برای این کاربر</a-radio>
</a-space>
</a-radio-group>
<template v-if="treasuryAccess">
<a-checkbox
@change="patchTreasury(null)"
/>
مثل نقش
</label>
<label class="choice">
<input
type="radio"
name="user-treasury"
:checked="treasuryAccess != null"
:disabled="disabled"
@change="patchTreasury(treasuryAccess ?? emptyTreasuryAccess())"
/>
سفارشی برای این کاربر
</label>
<template v-if="treasuryAccess">
<label class="choice">
<input
type="checkbox"
:checked="treasuryAccess.enabled"
:disabled="disabled"
@change="patchTreasury({ ...treasuryAccess, enabled: !treasuryAccess.enabled })"
>
دسترسی به مدیریت مالی
</a-checkbox>
<template v-if="treasuryAccess.enabled">
<a-space direction="vertical">
<a-checkbox
v-for="perm in treasurySections"
:key="perm.key"
:checked="treasuryAccess.sections.includes(perm.key)"
:disabled="disabled"
@change="toggleTreasurySection(perm.key)"
>
{{ perm.label }}
</a-checkbox>
</a-space>
<a-checkbox
/>
دسترسی به مدیریت مالی
</label>
<template v-if="treasuryAccess.enabled">
<label v-for="perm in treasurySections" :key="perm.key" class="choice sub">
<input
type="checkbox"
:checked="treasuryAccess.sections.includes(perm.key)"
:disabled="disabled"
@change="toggleTreasurySection(perm.key)"
/>
{{ perm.label }}
</label>
<label class="choice">
<input
type="checkbox"
:checked="treasuryAccess.ownAccounts"
:disabled="disabled"
@change="patchTreasury({ ...treasuryAccess, ownAccounts: !treasuryAccess.ownAccounts })"
>
حساب‌هایی که خودش مسئول آن‌هاست
</a-checkbox>
<a-typography-text type="secondary">حساب‌های دیگر</a-typography-text>
<a-input
v-model:value="treasuryAccountQuery"
placeholder="جستجوی حساب"
:disabled="disabled"
allow-clear
/>
<a-space direction="vertical">
<a-checkbox
v-for="account in filteredTreasuryAccounts"
:key="account.id"
:checked="treasuryAccess.accountIds.includes(account.id)"
:disabled="disabled"
@change="toggleTreasuryAccount(account.id)"
>
{{ account.name }}
<template v-if="account.responsibleName"> — مسئول: {{ account.responsibleName }}</template>
</a-checkbox>
</a-space>
<a-typography-text v-if="!treasuryAccounts.length" type="secondary">
حسابی برای انتخاب نیست.
</a-typography-text>
</template>
حساب‌هایی که خودش مسئول آن‌هاست
</label>
<p class="muted">حساب‌های دیگر</p>
<input v-model="treasuryAccountQuery" placeholder="جستجوی حساب" :disabled="disabled" />
<label v-for="account in filteredTreasuryAccounts" :key="account.id" class="choice">
<input
type="checkbox"
:checked="treasuryAccess.accountIds.includes(account.id)"
:disabled="disabled"
@change="toggleTreasuryAccount(account.id)"
/>
{{ account.name }}
<template v-if="account.responsibleName"> — مسئول: {{ account.responsibleName }}</template>
</label>
<p v-if="!treasuryAccounts.length" class="muted">حسابی برای انتخاب نیست.</p>
</template>
</template>
</div>
@@ -360,3 +373,47 @@ onMounted(() => {
</template>
</div>
</template>
<style scoped>
.dap {
display: grid;
gap: 0.75rem;
}
.tabs {
display: flex;
flex-wrap: wrap;
gap: 0.35rem;
}
.tab {
font: inherit;
border: 1px solid #e2e8f0;
background: #fff;
border-radius: 999px;
padding: 0.3rem 0.7rem;
cursor: pointer;
color: #475569;
}
.tab.on {
border-color: #0f766e;
background: #f0fdfa;
color: #0f766e;
font-weight: 600;
}
.muted {
color: #64748b;
font-size: 0.85rem;
}
.treasury {
display: grid;
gap: 0.45rem;
}
.choice {
display: grid;
grid-template-columns: auto 1fr;
gap: 0.4rem;
align-items: center;
}
.choice.sub {
padding-inline-start: 1.2rem;
}
</style>
+100 -60
View File
@@ -6,7 +6,7 @@ import {
ClockCircleOutlined,
LeftOutlined,
RightOutlined,
} from '@/icons/ant-bridge';
} from '@ant-design/icons-vue';
import {
addJalaliMonths,
dateToJalali,
@@ -58,6 +58,8 @@ const hourColRef = ref<HTMLElement | null>(null);
const minuteColRef = ref<HTMLElement | null>(null);
const top = ref(0);
const left = ref(0);
/** بالای مودال Ant (حدود ۱۰۰۰) تا تقویم پشت پنجره نماند */
const popupZ = ref(120);
const todayJ = dateToJalali(new Date());
const cursor = ref<{ jy: number; jm: number }>({ jy: todayJ.jy, jm: todayJ.jm });
const draftHour = ref(9);
@@ -325,16 +327,32 @@ function place() {
const panel = panelRef.value;
if (!trigger) return;
const rect = trigger.getBoundingClientRect();
const width = panel?.offsetWidth || (props.mode === 'time' ? (isMobile.value ? 340 : 280) : 320);
const height = panel?.offsetHeight || (props.mode === 'time' ? (isMobile.value ? 460 : 320) : 360);
const width =
panel?.offsetWidth ||
(props.mode === 'time' ? (isMobile.value ? 340 : 280) : 328);
const height =
panel?.offsetHeight ||
(props.mode === 'time' ? (isMobile.value ? 460 : 320) : 340);
const margin = 8;
let nextLeft = rect.left;
if (getComputedStyle(document.documentElement).direction === 'rtl') {
nextLeft = rect.right - width;
}
nextLeft = Math.min(Math.max(8, nextLeft), window.innerWidth - width - 8);
let nextTop = rect.bottom + 8;
if (nextTop + height > window.innerHeight - 8) {
nextTop = Math.max(8, rect.top - height - 8);
nextLeft = Math.min(
Math.max(margin, nextLeft),
Math.max(margin, window.innerWidth - width - margin),
);
const spaceBelow = window.innerHeight - rect.bottom - margin * 2;
const spaceAbove = rect.top - margin * 2;
let nextTop: number;
if (height <= spaceBelow) {
nextTop = rect.bottom + margin;
} else if (height <= spaceAbove) {
nextTop = rect.top - height - margin;
} else if (spaceBelow >= spaceAbove) {
nextTop = Math.max(margin, window.innerHeight - height - margin);
} else {
nextTop = margin;
}
left.value = nextLeft;
top.value = nextTop;
@@ -360,6 +378,7 @@ async function show() {
calView.value = props.startView;
clockFace.value = 'hour';
syncViewport();
liftAboveOverlays();
open.value = true;
await nextTick();
place();
@@ -554,7 +573,7 @@ onBeforeUnmount(() => {
'is-desktop': !isMobile,
}"
role="dialog"
:style="{ top: `${top}px`, left: `${left}px` }"
:style="{ top: `${top}px`, left: `${left}px`, zIndex: popupZ }"
>
<header v-if="mode !== 'time'" class="nav">
<a-button type="text" class="nav-btn" :aria-label="navLabels.forward" @click="navStep(1)">
@@ -742,7 +761,7 @@ onBeforeUnmount(() => {
>
پاک کردن
</a-button>
<a-button type="primary" class="done" @click="hide">تأیید</a-button>
<a-button type="primary" @click="hide">تأیید</a-button>
</footer>
</div>
</Teleport>
@@ -867,10 +886,11 @@ onBeforeUnmount(() => {
.panel {
position: fixed;
z-index: 120;
box-sizing: border-box;
width: min(20.5rem, calc(100vw - 16px));
max-height: calc(100vh - 16px);
overflow-x: hidden;
overflow-y: auto;
/* تقویم باید یکجا دیده شود؛ اسکرول داخل پنل گیج‌کننده است */
max-height: none;
overflow: hidden;
background: #fff;
border-radius: var(--radius);
box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
@@ -878,6 +898,13 @@ onBeforeUnmount(() => {
font-family: IRANSans, Tahoma, sans-serif;
}
@media (max-height: 420px) {
.panel {
max-height: calc(100vh - 16px);
overflow: auto;
}
}
.panel-time {
width: min(22.5rem, calc(100vw - 16px));
}
@@ -909,45 +936,40 @@ onBeforeUnmount(() => {
.pick-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-columns: repeat(3, 1fr);
gap: 0.35rem;
padding: 0.25rem 0;
}
.panel :deep(.ant-btn.pick-cell) {
width: 100%;
min-width: 0;
height: 44px;
margin: 0;
padding: 0 4px;
.panel :deep(.pick-cell.ant-btn) {
width: 100% !important;
min-width: 0 !important;
height: 44px !important;
padding-inline: 0 !important;
border-radius: var(--radius);
color: #0f172a;
font-size: 0.85rem;
}
.panel :deep(.ant-btn.pick-cell.today) {
.panel :deep(.pick-cell.today) {
box-shadow: inset 0 0 0 1px #99f6e4;
}
.panel :deep(.ant-btn.pick-cell.on),
.panel :deep(.ant-btn.pick-cell:hover) {
.panel :deep(.pick-cell.on),
.panel :deep(.pick-cell.ant-btn:hover) {
background: #0d9488;
color: #fff;
}
.panel :deep(.ant-btn.nav-btn) {
.nav-btn {
width: 32px;
min-width: 32px;
height: 32px;
margin: 0;
padding: 0;
border: 0;
border-radius: var(--radius);
background: #f1f5f9;
color: #0f766e;
display: inline-flex;
align-items: center;
justify-content: center;
display: grid;
place-items: center;
cursor: pointer;
}
@@ -960,6 +982,7 @@ onBeforeUnmount(() => {
display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr));
gap: 0.15rem;
width: 100%;
min-width: 0;
}
@@ -970,40 +993,43 @@ onBeforeUnmount(() => {
padding-bottom: 0.25rem;
}
.panel :deep(.ant-btn.day) {
display: inline-flex;
align-items: center;
justify-content: center;
width: 100%;
min-width: 0;
height: 34px;
margin: 0;
padding: 0;
line-height: 1;
.panel :deep(.day.ant-btn) {
width: 100% !important;
min-width: 0 !important;
height: 34px !important;
padding: 0 !important;
border: 0;
border-radius: var(--radius);
background: none;
color: #0f172a;
font: inherit;
font-size: 0.82rem;
line-height: 1;
cursor: pointer;
box-shadow: none;
}
.panel :deep(.ant-btn.day.mute) {
.panel :deep(.day.ant-btn > span) {
display: inline-flex;
align-items: center;
justify-content: center;
width: 100%;
}
.panel :deep(.day.mute) {
color: #cbd5e1;
}
.panel :deep(.ant-btn.day.today) {
.panel :deep(.day.today) {
box-shadow: inset 0 0 0 1px #99f6e4;
}
.panel :deep(.ant-btn.day.on),
.panel :deep(.ant-btn.day:hover) {
.panel :deep(.day.on),
.panel :deep(.day.ant-btn:hover) {
background: #0d9488;
color: #fff;
}
.panel :deep(.ant-btn.day.mute:hover) {
.panel :deep(.day.mute:hover) {
background: #f1f5f9;
color: #64748b;
}
@@ -1033,11 +1059,9 @@ onBeforeUnmount(() => {
margin-bottom: 0.85rem;
}
.panel :deep(.ant-btn.md-chip) {
.md-chip {
min-width: 5.1rem;
height: 4.1rem;
margin: 0;
padding: 0;
border: 0;
border-radius: var(--radius);
background: #f1f5f9;
@@ -1050,7 +1074,7 @@ onBeforeUnmount(() => {
cursor: pointer;
}
.panel :deep(.ant-btn.md-chip.on) {
.md-chip.on {
background: #ccfbf1;
color: #0f766e;
box-shadow: inset 0 0 0 2px #99f6e4;
@@ -1124,11 +1148,10 @@ onBeforeUnmount(() => {
pointer-events: none;
}
.panel :deep(.ant-btn.md-tick) {
.md-tick {
position: absolute;
z-index: 2;
width: 36px;
min-width: 36px;
height: 36px;
margin: 0;
border: 0;
@@ -1145,12 +1168,12 @@ onBeforeUnmount(() => {
padding: 0;
}
.panel :deep(.ant-btn.md-tick.inner) {
.md-tick.inner {
font-size: 0.74rem;
color: #64748b;
}
.panel :deep(.ant-btn.md-tick.on) {
.md-tick.on {
background: transparent;
color: #fff;
}
@@ -1199,12 +1222,9 @@ onBeforeUnmount(() => {
overscroll-behavior: contain;
}
.panel :deep(.ant-btn.col-item) {
.col-item {
width: 100%;
min-width: 0;
height: 36px;
margin: 0;
padding: 0;
border: 0;
border-radius: var(--radius);
background: transparent;
@@ -1215,11 +1235,11 @@ onBeforeUnmount(() => {
cursor: pointer;
}
.panel :deep(.ant-btn.col-item:hover) {
.col-item:hover {
background: #e2e8f0;
}
.panel :deep(.ant-btn.col-item.on) {
.col-item.on {
background: #0d9488;
color: #fff;
}
@@ -1231,8 +1251,28 @@ onBeforeUnmount(() => {
margin-top: 0.7rem;
}
.panel :deep(.ant-btn.done) {
.link,
.done {
border: 0;
background: none;
font: inherit;
cursor: pointer;
}
.link {
color: #0f766e;
font-size: 0.8rem;
font-weight: 700;
}
.done {
margin-inline-start: auto;
background: #14b8a6;
color: #fff;
border-radius: var(--radius);
padding: 0.4rem 0.8rem;
font-weight: 600;
font-size: 0.8rem;
}
.panel.is-mobile .time-box {
+1 -1
View File
@@ -7,7 +7,7 @@ import {
Popover as APopover,
Typography,
} from 'ant-design-vue';
import { SettingOutlined } from '@/icons/ant-bridge';
import { SettingOutlined } from '@ant-design/icons-vue';
import { useTableColumns } from '@/lib/tableColumns';
import { toFaDigits } from '@/lib/jalali';
+70 -120
View File
@@ -19,6 +19,7 @@ import {
emptySectionDataAccess,
sectionHasDataAccessLimits,
} from '@mento/shared';
import { UiButton, UiEmptyState, UiField, UiInput } from '@/components/ui';
import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue';
import { formatLocalDateInput, parseLocalInput, toFaDigits } from '@/lib/jalali';
import { matchesSearch } from '@/lib/search';
@@ -37,7 +38,7 @@ const showPriorArchive = computed(
const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false));
const selectedPriorUsers = computed(() => priorUsers.value.filter((u) => u.priorArchiveEnabled));
const priorSearch = ref('');
const priorPick = ref<string | undefined>(undefined);
const priorPick = ref('');
const priorSavingId = ref('');
const cutoffLocal = ref('');
const cutoffSaving = ref(false);
@@ -48,16 +49,10 @@ const availablePriorUsers = computed(() => {
return priorUsers.value.filter((u) => {
if (u.priorArchiveEnabled) return false;
if (!q) return true;
return [u.fullName, u.email, u.mobile]
.filter(Boolean)
.some((v) => String(v).toLowerCase().includes(q));
return [u.fullName, u.email, u.mobile].filter(Boolean).some((v) => String(v).toLowerCase().includes(q));
});
});
const availablePriorOptions = computed(() =>
availablePriorUsers.value.map((u) => ({ value: u.id, label: u.fullName })),
);
const emit = defineEmits<{
refreshUsers: [];
}>();
@@ -105,7 +100,7 @@ const filteredAccessUsers = computed(() => {
async function setPriorArchive(userId: string, enabled: boolean) {
priorSavingId.value = userId;
priorPick.value = undefined;
priorPick.value = '';
error.value = '';
ok.value = '';
try {
@@ -143,10 +138,7 @@ async function loadPriorArchiveCutoff() {
applyCutoffFromOrg(data);
} catch (e) {
error.value = axios.isAxiosError(e)
? String(
(e.response?.data as { message?: string })?.message ??
'بارگذاری تاریخ بایگانی ناموفق بود.',
)
? String((e.response?.data as { message?: string })?.message ?? 'بارگذاری تاریخ بایگانی ناموفق بود.')
: 'بارگذاری تاریخ بایگانی ناموفق بود.';
} finally {
cutoffLoading.value = false;
@@ -168,10 +160,7 @@ async function onCutoffChange(value: string) {
await auth.hydrate();
} catch (e) {
error.value = axios.isAxiosError(e)
? String(
(e.response?.data as { message?: string })?.message ??
'ذخیره تاریخ بایگانی ناموفق بود.',
)
? String((e.response?.data as { message?: string })?.message ?? 'ذخیره تاریخ بایگانی ناموفق بود.')
: 'ذخیره تاریخ بایگانی ناموفق بود.';
await loadPriorArchiveCutoff();
} finally {
@@ -179,10 +168,9 @@ async function onCutoffChange(value: string) {
}
}
function pickPriorUser(userId: unknown) {
const id = userId == null ? '' : String(userId);
if (!id) return;
void setPriorArchive(id, true);
function pickPriorUser(userId: string) {
if (!userId) return;
void setPriorArchive(userId, true);
}
async function load() {
@@ -279,19 +267,9 @@ function toggleMember(userId: string) {
}
}
function setRole(userId: string, role: unknown) {
function setRole(userId: string, role: TeamMemberRole) {
if (!memberDraft.value[userId]) return;
memberDraft.value = {
...memberDraft.value,
[userId]: String(role) as TeamMemberRole,
};
}
function teamMembersLabel(team: TeamDto) {
if (!team.members.length) return 'بدون عضو';
return team.members
.map((m) => `${m.fullName}${m.role === 'manager' ? ' (سرپرست)' : ''}`)
.join('، ');
memberDraft.value = { ...memberDraft.value, [userId]: role };
}
async function saveMembers() {
@@ -411,31 +389,22 @@ onMounted(() => {
</script>
<template>
<a-flex vertical :gap="12">
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" />
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" />
<div class="teams-panel">
<p v-if="error" class="error">{{ error }}</p>
<p v-if="ok" class="ok">{{ ok }}</p>
<a-card :bordered="false">
<a-form v-if="canEdit" layout="vertical" @finish="createTeam">
<a-divider orientation="right">تیم جدید</a-divider>
<a-row :gutter="[16, 0]" align="bottom">
<a-col :xs="24" :md="8">
<a-form-item label="نام تیم">
<a-input v-model:value="newName" placeholder="مثلاً فروش تهران" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="10">
<a-form-item label="توضیح">
<a-input v-model:value="newDesc" placeholder="اختیاری" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="6">
<a-form-item label=" ">
<a-button type="primary" html-type="submit" :loading="saving" block>افزودن</a-button>
</a-form-item>
</a-col>
</a-row>
</a-form>
<section v-if="canEdit" class="card">
<h3>تیم جدید</h3>
<div class="row">
<UiField label="نام تیم">
<UiInput v-model="newName" placeholder="مثلاً فروش تهران" />
</UiField>
<UiField label="توضیح">
<UiInput v-model="newDesc" placeholder="اختیاری" />
</UiField>
<UiButton :loading="saving" @click="createTeam">افزودن</UiButton>
</div>
</section>
<section class="card">
<header class="card-head">
@@ -530,27 +499,41 @@ onMounted(() => {
:disabled="cutoffSaving || cutoffLoading"
@update:model-value="onCutoffChange"
/>
<a-list v-else item-layout="vertical" :data-source="teams">
<template #renderItem="{ item: t }">
<a-list-item>
<template v-if="canEdit" #actions>
<a-button type="link" @click="startMetaEdit(t)">ویرایش</a-button>
<a-button type="link" @click="startEdit(t)">اعضا</a-button>
<a-button type="link" danger @click="removeTeam(t.id)">حذف</a-button>
</template>
<a-list-item-meta>
<template #title>
<a-space wrap>
<a-typography-text strong>{{ t.name }}</a-typography-text>
<a-tag :bordered="false">{{ toFaDigits(t.memberCount) }} عضو</a-tag>
</a-space>
</template>
<template #description>
<a-typography-text type="secondary">
{{ t.description || 'بدون توضیح' }} · {{ teamMembersLabel(t) }}
</a-typography-text>
</template>
</a-list-item-meta>
</header>
<p class="hint">
فقط کاربرانی که تیک می‌خورند سوئیچ کار جاری و بایگانی را می‌بینند. بقیهٔ محیط مثل قبل همهٔ
رکوردها را مطابق سطح دسترسی خودشان می‌بینند.
</p>
<div class="prior-picker">
<UiInput v-model="priorSearch" placeholder="جستجوی کاربر…" />
<select
v-model="priorPick"
:disabled="!availablePriorUsers.length || Boolean(priorSavingId)"
@change="pickPriorUser(($event.target as HTMLSelectElement).value)"
>
<option value="">
{{ availablePriorUsers.length ? 'انتخاب کاربر برای فعال‌سازی' : 'کاربر دیگری پیدا نشد' }}
</option>
<option v-for="u in availablePriorUsers" :key="u.id" :value="u.id">
{{ u.fullName }}
</option>
</select>
</div>
<div v-if="selectedPriorUsers.length" class="prior-chips">
<span v-for="u in selectedPriorUsers" :key="u.id" class="prior-chip">
{{ u.fullName }}
<button
type="button"
:disabled="priorSavingId === u.id"
:aria-label="`حذف ${u.fullName}`"
@click="setPriorArchive(u.id, false)"
>
×
</button>
</span>
</div>
<p v-else class="hint">هنوز کاربری برای دیدن سوئیچ بایگانی انتخاب نشده است.</p>
</section>
<section class="card">
<header class="card-head">
@@ -598,48 +581,15 @@ onMounted(() => {
:data-locked="accessMode === 'inherit'"
compact
/>
<a-list v-else item-layout="vertical" :data-source="editableUsers">
<template #renderItem="{ item: u }">
<a-list-item>
<template v-if="canEdit" #actions>
<a-button type="link" @click="openAccessEditor(u)">
{{ expandedAccess === u.id ? 'بستن' : 'تنظیم' }}
</a-button>
</template>
<a-list-item-meta :description="accessSummary(u)">
<template #title>
<a-typography-text strong>{{ u.fullName }}</a-typography-text>
</template>
</a-list-item-meta>
<a-flex v-if="expandedAccess === u.id" vertical :gap="8" style="width: 100%">
<a-radio-group v-model:value="accessMode">
<a-space wrap>
<a-radio value="inherit">مثل نقش</a-radio>
<a-radio value="custom">سفارشی</a-radio>
</a-space>
</a-radio-group>
<DataAccessPolicyPanel
v-model="draftAccess"
v-model:treasury-access="draftTreasury"
:show-treasury="showTreasury"
:data-locked="accessMode === 'inherit'"
compact
/>
<a-space>
<a-button type="primary" :loading="accessSaving" @click="saveUserAccess(u.id)">
ذخیره
</a-button>
<a-button @click="expandedAccess = null">انصراف</a-button>
</a-space>
</a-flex>
</a-list-item>
</template>
</a-list>
</a-flex>
</a-collapse-panel>
</a-collapse>
</a-card>
</a-flex>
<div class="actions">
<UiButton :loading="accessSaving" @click="saveUserAccess(u.id)">ذخیره</UiButton>
<UiButton variant="secondary" @click="expandedAccess = null">انصراف</UiButton>
</div>
</div>
</div>
</div>
</section>
</div>
</template>
<style scoped>
@@ -607,4 +607,9 @@ function openFullActivity(id: string) {
display: flex;
flex-direction: column;
}
.muted {
margin: 0;
color: #64748b;
}
</style>
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, ref, watch, type Component } from 'vue';
import { computed, ref, watch } from 'vue';
import axios from 'axios';
import type {
ActivityFieldDef,
@@ -20,45 +20,6 @@ import {
ACTIVITY_TYPE_LABELS,
DEFAULT_ACTIVITY_PRIORITY_SETTINGS,
} from '@mento/shared';
import {
AimOutlined,
ArrowDownOutlined,
ArrowUpOutlined,
BankOutlined,
BellOutlined,
CalendarOutlined,
CarOutlined,
CheckOutlined,
DeleteOutlined,
EnvironmentOutlined,
FileTextOutlined,
FlagOutlined,
MessageOutlined,
MailOutlined,
PhoneOutlined,
PlusOutlined,
SendOutlined,
SoundOutlined,
StarOutlined,
TeamOutlined,
ThunderboltOutlined,
ContainerOutlined,
} from '@/icons/ant-bridge';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Checkbox as ACheckbox,
Col as ACol,
Flex as AFlex,
FormItem as AFormItem,
Input as AInput,
Modal as AModal,
Row as ARow,
Select as ASelect,
Textarea as ATextarea,
} from 'ant-design-vue';
import { Modal } from 'ant-design-vue';
import { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali';
import { useActivityPriorities } from '@/lib/activity-priorities';
@@ -68,27 +29,8 @@ import {
typeColorStyle,
useActivityTypes,
} from '@/lib/activity-types';
const ACTIVITY_ICON_COMPONENTS: Record<ActivityTypeIcon, Component> = {
phone: PhoneOutlined,
users: TeamOutlined,
check: CheckOutlined,
chat: MessageOutlined,
mail: MailOutlined,
building: BankOutlined,
calendar: CalendarOutlined,
star: StarOutlined,
flag: FlagOutlined,
briefcase: ContainerOutlined,
document: FileTextOutlined,
target: AimOutlined,
truck: CarOutlined,
send: SendOutlined,
megaphone: SoundOutlined,
pin: EnvironmentOutlined,
bell: BellOutlined,
sparkle: ThunderboltOutlined,
};
import { UiButton, UiModal } from '@/components/ui';
import UiIcon from '@/components/UiIcon.vue';
const props = defineProps<{ open: boolean }>();
const emit = defineEmits<{ close: []; changed: [] }>();
@@ -157,7 +99,10 @@ function snapshot(d: Draft | null) {
const dirty = computed(() => snapshot(draft.value) !== savedSnapshot.value);
function applySelect(id: string | 'new') {
function select(id: string | 'new') {
if (dirty.value && draft.value && !window.confirm('تغییرات ذخیره نشده از بین می‌رود. ادامه می‌دهید؟')) {
return;
}
selectedId.value = id;
draft.value = toDraft(id === 'new' ? null : (types.value.find((t) => t.id === id) ?? null));
savedSnapshot.value = snapshot(draft.value);
@@ -236,7 +181,7 @@ watch(
const first = types.value[0];
selectedId.value = null;
draft.value = null;
if (first) applySelect(first.id);
if (first) select(first.id);
},
{ immediate: true },
);
@@ -274,15 +219,12 @@ function moveField(index: number, dir: -1 | 1) {
function removeField(index: number) {
const f = draft.value?.fields[index];
if (!f) return;
if (f.label.trim()) {
Modal.confirm({
title: 'حذف فیلد',
content: `فیلد «${f.label}» حذف شود؟ مقادیر ثبت‌شدهٔ آن در فعالیت‌های قبلی دیگر نمایش داده نمی‌شود.`,
okText: 'حذف',
cancelText: 'انصراف',
okButtonProps: { danger: true },
onOk: () => draft.value!.fields.splice(index, 1),
});
if (
f.label.trim() &&
!window.confirm(
`فیلد «${f.label}» حذف شود؟ مقادیر ثبت‌شدهٔ آن در فعالیت‌های قبلی دیگر نمایش داده نمی‌شود.`,
)
) {
return;
}
draft.value!.fields.splice(index, 1);
@@ -318,7 +260,14 @@ function validate(d: Draft): string {
return '';
}
async function performSave(d: Draft) {
async function save() {
const d = draft.value;
if (!d) return;
const msg = validate(d);
if (msg) {
error.value = msg;
return;
}
busy.value = 'save';
error.value = '';
notice.value = '';
@@ -331,6 +280,18 @@ async function performSave(d: Draft) {
};
try {
if (d.id) {
const prev = types.value.find((t) => t.id === d.id);
if (
prev &&
!d.isSystem &&
prev.baseType !== d.baseType &&
!window.confirm(
'با تغییر نوع پایه، فعالیت‌های قبلی این نوع هم در گزارش‌ها با نوع پایهٔ جدید شمرده می‌شوند. ادامه می‌دهید؟',
)
) {
busy.value = '';
return;
}
await api.patch(`/activities/types/${d.id}`, body);
} else {
const { data } = await api.post<ActivityTypeDefDto>('/activities/types', body);
@@ -350,56 +311,31 @@ async function performSave(d: Draft) {
}
}
async function save() {
const d = draft.value;
if (!d) return;
const msg = validate(d);
if (msg) {
error.value = msg;
return;
}
const prev = d.id ? types.value.find((t) => t.id === d.id) : undefined;
if (prev && !d.isSystem && prev.baseType !== d.baseType) {
Modal.confirm({
title: 'تغییر نوع پایه',
content:
'با تغییر نوع پایه، فعالیت‌های قبلی این نوع هم در گزارش‌ها با نوع پایهٔ جدید شمرده می‌شوند. ادامه می‌دهید؟',
okText: 'ادامه',
cancelText: 'انصراف',
onOk: () => performSave(d),
});
return;
}
await performSave(d);
}
async function remove() {
const d = draft.value;
if (!d?.id || d.isSystem) return;
Modal.confirm({
title: 'حذف نوع فعالیت',
content: `نوع «${d.name}» حذف شود؟ فعالیت‌های این نوع به نوع اصلی «${ACTIVITY_TYPE_LABELS[d.baseType]}» برمی‌گردند. برای نگه داشتن سوابق، می‌توانید به‌جای حذف آن را غیرفعال کنید.`,
okText: 'حذف',
cancelText: 'انصراف',
okButtonProps: { danger: true },
async onOk() {
busy.value = 'remove';
error.value = '';
try {
await api.delete(`/activities/types/${d.id!}`);
await load(true);
savedSnapshot.value = snapshot(null);
draft.value = null;
const first = types.value[0];
if (first) applySelect(first.id);
emit('changed');
} catch (e) {
error.value = apiMessage(e, 'حذف نوع فعالیت ناموفق بود.');
} finally {
busy.value = '';
}
},
});
if (
!window.confirm(
`نوع «${d.name}» حذف شود؟ فعالیت‌های این نوع به نوع اصلی «${ACTIVITY_TYPE_LABELS[d.baseType]}» برمی‌گردند. برای نگه داشتن سوابق، می‌توانید به‌جای حذف آن را غیرفعال کنید.`,
)
) {
return;
}
busy.value = 'remove';
error.value = '';
try {
await api.delete(`/activities/types/${d.id}`);
await load(true);
savedSnapshot.value = snapshot(null);
draft.value = null;
const first = types.value[0];
if (first) select(first.id);
emit('changed');
} catch (e) {
error.value = apiMessage(e, 'حذف نوع فعالیت ناموفق بود.');
} finally {
busy.value = '';
}
}
async function moveType(index: number, dir: -1 | 1) {
@@ -430,10 +366,6 @@ function close() {
}
emit('close');
}
function showPlaceholder(type: ActivityFieldType) {
return !['checkbox', 'participants', 'select', 'multiselect', 'date'].includes(type);
}
</script>
<template>
@@ -465,71 +397,172 @@ function showPlaceholder(type: ActivityFieldType) {
برای هر نوع فعالیت فیلدهای مخصوص خودش را تعریف کنید؛ مثلاً «موضوع جلسه» و «شرکت‌کنندگان» برای جلسه
یا «لیست کارها» برای وظیفه. «نوع پایه» مشخص می‌کند فعالیت در گزارش‌ها جزو تماس، جلسه، وظیفه یا پیام
شمرده شود.
</a-typography-text>
</p>
<a-row :gutter="[16, 16]">
<a-col :xs="24" :md="7">
<a-flex vertical gap="small">
<a-flex
v-for="(t, index) in types"
:key="t.id"
align="center"
gap="small"
>
<a-button
block
:type="selectedId === t.id ? 'primary' : 'default'"
:ghost="selectedId === t.id"
:style="{ opacity: t.isActive ? 1 : 0.65, textAlign: 'start', height: 'auto', padding: '8px 12px' }"
@click="select(t.id)"
<div class="layout">
<aside class="list">
<div
v-for="(t, index) in types"
:key="t.id"
class="type-row"
:class="{ on: selectedId === t.id, off: !t.isActive }"
>
<button type="button" class="pick" @click="select(t.id)">
<span class="ico" :style="typeColorStyle(t.color)">
<UiIcon :name="t.icon" :size="14" />
</span>
<span class="txt">
<b>{{ t.name }}</b>
<small>
{{ ACTIVITY_TYPE_LABELS[t.baseType] }} · {{ toFaDigits(t.fields.length) }} فیلد
<template v-if="!t.isActive"> · غیرفعال</template>
</small>
</span>
</button>
<div class="order">
<button
type="button"
:disabled="index === 0 || Boolean(busy)"
aria-label="انتقال به بالا"
@click="moveType(index, -1)"
>
<a-flex align="center" gap="small">
<span
:style="{
...typeColorStyle(t.color),
width: '30px',
height: '30px',
borderRadius: '999px',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}"
>
<component :is="ACTIVITY_ICON_COMPONENTS[t.icon]" />
</span>
<a-flex vertical :style="{ minWidth: 0, flex: 1 }">
<a-typography-text strong :ellipsis="true">{{ t.name }}</a-typography-text>
<a-typography-text type="secondary" :style="{ fontSize: '12px' }">
{{ ACTIVITY_TYPE_LABELS[t.baseType] }} · {{ toFaDigits(t.fields.length) }} فیلد
<template v-if="!t.isActive"> · غیرفعال</template>
</a-typography-text>
</a-flex>
</a-flex>
</a-button>
<a-flex vertical>
<a-button
type="text"
:disabled="index === 0 || Boolean(busy)"
aria-label="انتقال به بالا"
@click="moveType(index, -1)"
▲
</button>
<button
type="button"
:disabled="index === types.length - 1 || Boolean(busy)"
aria-label="انتقال به پایین"
@click="moveType(index, 1)"
>
▼
</button>
</div>
</div>
<button type="button" class="add-type" :class="{ on: selectedId === 'new' }" @click="select('new')">
<UiIcon name="plus" :size="15" />
نوع فعالیت جدید
</button>
</aside>
<section v-if="draft" class="editor">
<div class="grid">
<label class="f">
<span>نام نوع</span>
<input v-model="draft.name" maxlength="60" placeholder="مثلاً: بازدید حضوری" />
</label>
<label class="f">
<span>نوع پایه (برای گزارش‌ها)</span>
<select v-model="draft.baseType" :disabled="draft.isSystem">
<option v-for="b in BASE_TYPES" :key="b" :value="b">{{ ACTIVITY_TYPE_LABELS[b] }}</option>
</select>
</label>
<label class="f">
<span>رنگ</span>
<select v-model="draft.color">
<option v-for="c in ACTIVITY_STAGE_COLORS" :key="c" :value="c">
{{ ACTIVITY_STAGE_COLOR_LABELS[c] }}
</option>
</select>
</label>
<label v-if="!draft.isSystem && draft.id" class="f toggle">
<input v-model="draft.isActive" type="checkbox" />
<span>فعال (در فرم فعالیت قابل انتخاب باشد)</span>
</label>
</div>
<div class="f">
<span>آیکون</span>
<div class="icons">
<button
v-for="ic in ACTIVITY_TYPE_ICONS"
:key="ic"
type="button"
:class="{ on: draft.icon === ic }"
:style="draft.icon === ic ? typeColorStyle(draft.color) : undefined"
:title="ACTIVITY_TYPE_ICON_LABELS[ic]"
:aria-label="ACTIVITY_TYPE_ICON_LABELS[ic]"
@click="draft.icon = ic"
>
<UiIcon :name="ic" :size="16" />
</button>
</div>
</div>
<p v-if="draft.isSystem" class="sys-note">
این نوع اصلی است: حذف و غیرفعال نمی‌شود، ولی نام، ظاهر و فیلدهایش قابل تغییر است.
</p>
<div class="fields-head">
<strong>فیلدهای اختصاصی</strong>
<small>{{ toFaDigits(draft.fields.length) }} فیلد</small>
</div>
<p v-if="!draft.fields.length" class="empty">
هنوز فیلدی تعریف نشده؛ فعالیت‌های این نوع فقط فیلدهای عمومی (عنوان، زمان، مسئول، مشتری…) را دارند.
</p>
<div v-for="(f, index) in draft.fields" :key="f.key" class="field-card">
<div class="field-top">
<span class="num">{{ toFaDigits(index + 1) }}</span>
<input v-model="f.label" class="label-input" maxlength="80" placeholder="عنوان فیلد (مثلاً: موضوع جلسه)" />
<select v-model="f.type" aria-label="نوع فیلد">
<option v-for="ft in ACTIVITY_FIELD_TYPES" :key="ft" :value="ft">
{{ ACTIVITY_FIELD_TYPE_LABELS[ft] }}
</option>
</select>
<div class="field-actions">
<button type="button" :disabled="index === 0" aria-label="بالا" @click="moveField(index, -1)">▲</button>
<button
type="button"
:disabled="index === draft.fields.length - 1"
aria-label="پایین"
@click="moveField(index, 1)"
>
<template #icon><ArrowUpOutlined /></template>
</a-button>
<a-button
type="text"
:disabled="index === types.length - 1 || Boolean(busy)"
aria-label="انتقال به پایین"
@click="moveType(index, 1)"
>
<template #icon><ArrowDownOutlined /></template>
</a-button>
</a-flex>
</a-flex>
<a-button
block
:type="selectedId === 'new' ? 'primary' : 'dashed'"
@click="select('new')"
▼
</button>
<button type="button" class="danger" aria-label="حذف فیلد" @click="removeField(index)">
<UiIcon name="trash" :size="14" />
</button>
</div>
</div>
<div class="field-extra">
<textarea
v-if="needsOptions(f.type)"
v-model="f.optionsText"
rows="3"
placeholder="گزینه‌ها — هر گزینه در یک خط"
/>
<input
v-if="!['checkbox', 'participants', 'select', 'multiselect', 'date'].includes(f.type)"
v-model="f.placeholder"
maxlength="200"
placeholder="متن راهنما داخل فیلد (اختیاری)"
/>
<label v-if="f.type !== 'checkbox'" class="req">
<input v-model="f.required" type="checkbox" />
اجباری
</label>
<small v-if="f.type === 'participants'" class="tip">
همکارانی که به‌عنوان شرکت‌کننده انتخاب شوند، این فعالیت را در لیست خودشان هم می‌بینند و اعلان
دریافت می‌کنند.
</small>
</div>
</div>
<button type="button" class="add-field" @click="addField">
<UiIcon name="plus" :size="15" />
افزودن فیلد
</button>
<p v-if="error" class="error">{{ error }}</p>
<p v-else-if="notice" class="notice">{{ notice }}</p>
<div class="actions">
<UiButton
variant="primary"
type="button"
:disabled="!dirty || Boolean(busy)"
:loading="busy === 'save'"
@click="save"
>
{{ draft.id ? 'ذخیرهٔ تغییرات' : 'ساخت نوع فعالیت' }}
</UiButton>
@@ -1,16 +1,6 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { RouterLink } from 'vue-router';
import { GiftOutlined } from '@/icons/ant-bridge';
import {
Button as AButton,
Flex as AFlex,
List as AList,
Modal as AModal,
Space as ASpace,
Tag as ATag,
Typography,
} from 'ant-design-vue';
import { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali';
import { hasSectionPermission } from '@/lib/section-permissions';
@@ -74,78 +64,63 @@ onMounted(async () => {
</script>
<template>
<section v-if="data" class="bg-white rounded-2xl border border-slate-200/80 p-4 shadow-sm">
<a-flex align="center" wrap="wrap" gap="middle" justify="space-between">
<a-flex align="center" gap="middle">
<a-typography-text type="secondary"><GiftOutlined /></a-typography-text>
<div>
<a-typography-text strong>تولدهای {{ data.monthName }}</a-typography-text>
<br />
<a-typography-text type="secondary">
{{ toFaDigits(data.total) }} مشتری این ماه تولد دارند
</a-typography-text>
</div>
</a-flex>
<section v-if="data" class="birthdays">
<div class="head">
<span class="ico"><UiIcon name="gift" :size="18" /></span>
<div>
<strong>تولدهای {{ data.monthName }}</strong>
<p>{{ toFaDigits(data.total) }} مشتری این ماه تولد دارند</p>
</div>
</div>
<a-space wrap>
<RouterLink
v-for="person in data.preview"
:key="person.id"
:to="{ name: 'person-detail', params: { id: person.id } }"
<div class="chips">
<RouterLink
v-for="person in data.preview"
:key="person.id"
class="chip"
:title="person.fullName"
:to="{ name: 'person-detail', params: { id: person.id } }"
>
<b>{{ toFaDigits(person.day) }}</b>
<span>{{ person.fullName }}</span>
</RouterLink>
</div>
<button type="button" class="more" @click="listOpen = true">
{{ data.total > data.preview.length ? 'همه' : 'فهرست' }}
</button>
<UiModal :open="listOpen" :title="`تولدهای ${data.monthName}`" @close="listOpen = false">
<div class="days">
<section
v-for="[day, people] in groups"
:key="day"
class="day"
:class="{ past: day < data.today, today: day === data.today }"
>
<a-tag>
{{ toFaDigits(person.day) }} — {{ person.fullName }}
</a-tag>
</RouterLink>
<a-button type="link" @click="listOpen = true">
{{ data.total > data.preview.length ? 'همه' : 'فهرست' }}
</a-button>
</a-space>
</a-flex>
<a-modal
v-model:open="listOpen"
:title="`تولدهای ${data.monthName}`"
:footer="null"
destroy-on-close
>
<a-list item-layout="vertical" :data-source="groups">
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a-tag v-if="item[0] < data!.today">گذشته</a-tag>
<a-tag v-else-if="item[0] === data!.today" color="processing">امروز</a-tag>
</template>
<a-list-item-meta>
<template #title>
{{ toFaDigits(item[0]) }} {{ data!.monthName }}
</template>
</a-list-item-meta>
<a-list :data-source="item[1]">
<template #renderItem="{ item: person }">
<a-list-item>
<RouterLink
:to="{ name: 'person-detail', params: { id: person.id } }"
@click="listOpen = false"
>
{{ person.fullName }}
</RouterLink>
<template #actions>
<a-button
type="link"
:disabled="!person.mobile"
@click="openSms(person)"
>
{{ person.mobile ? 'پیامک تبریک' : 'بدون شماره' }}
</a-button>
</template>
</a-list-item>
</template>
</a-list>
</a-list-item>
</template>
</a-list>
</a-modal>
<h3>
<b>{{ toFaDigits(day) }}</b>
<span>{{ data.monthName }}</span>
<em v-if="day < data.today">گذشته</em>
<em v-else-if="day === data.today">امروز</em>
</h3>
<ul>
<li v-for="person in people" :key="person.id">
<RouterLink :to="{ name: 'person-detail', params: { id: person.id } }" @click="listOpen = false">
{{ person.fullName }}
</RouterLink>
<button
type="button"
class="sms"
:disabled="!person.mobile"
@click="openSms(person)"
>
{{ person.mobile ? 'پیامک تبریک' : 'بدون شماره' }}
</button>
</li>
</ul>
</section>
</div>
</UiModal>
<SmsComposeModal
nest
@@ -161,3 +136,289 @@ onMounted(async () => {
/>
</section>
</template>
<style scoped>
.birthdays {
display: flex;
align-items: center;
gap: 0.75rem;
min-width: 0;
max-width: 100%;
background:
linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent 42%),
linear-gradient(100deg, var(--accent-subtle) 0%, #fff 58%, #fff7f4 100%);
border: 1px solid color-mix(in srgb, var(--accent) 22%, #fff);
border-radius: var(--radius);
box-shadow: 0 6px 18px rgba(15, 118, 110, 0.05);
padding: 0.55rem 0.75rem;
}
.head {
display: flex;
align-items: center;
gap: 0.55rem;
flex-shrink: 0;
}
.ico {
width: 32px;
height: 32px;
border-radius: 10px;
display: grid;
place-items: center;
background: #fff;
color: #e11d48;
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, #fff);
}
.head strong {
display: block;
color: var(--accent-deep);
font-size: 0.88rem;
font-weight: 700;
}
.head p {
margin: 0.05rem 0 0;
color: #64748b;
font-size: 0.75rem;
}
.chips {
display: flex;
flex: 1 1 auto;
flex-wrap: nowrap;
gap: 0.35rem;
min-width: 0;
max-width: 100%;
overflow: hidden;
}
.chip {
display: inline-flex;
flex-shrink: 0;
align-items: center;
gap: 0.35rem;
max-width: 11.5rem;
min-width: 0;
border-radius: 999px;
border: 1px solid color-mix(in srgb, var(--accent) 24%, #fff);
background: rgba(255, 255, 255, 0.86);
color: #134e4a;
padding: 0.22rem 0.55rem 0.22rem 0.28rem;
text-decoration: none;
font-size: 0.78rem;
}
.chip b {
flex-shrink: 0;
font-weight: 700;
font-size: 0.72rem;
color: var(--accent-deep);
background: var(--accent-soft);
border-radius: 999px;
padding: 0.12rem 0.38rem;
}
.chip span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.more {
flex-shrink: 0;
border: 0;
border-radius: 999px;
background: var(--accent);
color: #fff;
padding: 0.32rem 0.7rem;
font: inherit;
font-size: 0.78rem;
cursor: pointer;
}
.more:hover {
background: var(--accent-hover);
}
.days {
display: grid;
gap: 0.85rem;
max-height: 62vh;
overflow: auto;
padding-inline-end: 0.15rem;
}
.day {
background: #fff;
border: 1px solid #e7eef2;
border-radius: 14px;
overflow: hidden;
}
.day h3 {
display: flex;
align-items: center;
gap: 0.4rem;
margin: 0;
padding: 0.55rem 0.8rem;
background: var(--accent-subtle);
border-bottom: 1px solid color-mix(in srgb, var(--accent) 16%, #fff);
font-size: 0.86rem;
font-weight: 600;
color: var(--accent-deep);
}
.day h3 b {
display: grid;
place-items: center;
min-width: 1.7rem;
height: 1.7rem;
padding: 0 0.3rem;
border-radius: 999px;
background: var(--accent);
color: #fff;
font-size: 0.78rem;
}
.day em {
margin-inline-start: auto;
font-style: normal;
font-size: 0.72rem;
font-weight: 600;
color: #94a3b8;
background: #fff;
border-radius: 999px;
padding: 0.1rem 0.45rem;
}
.day.today h3 {
background: color-mix(in srgb, var(--accent-soft) 70%, #fff);
}
.day.today em {
color: var(--accent-deep);
}
.day.past {
opacity: 0.82;
}
.day ul {
list-style: none;
margin: 0;
padding: 0;
}
.day li {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
padding: 0.62rem 0.85rem;
border-top: 1px solid #eef2f6;
}
.day li:first-child {
border-top: 0;
}
.day a {
flex: 1 1 auto;
color: #0f172a;
text-decoration: none;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.day a:hover {
color: var(--accent-deep);
}
.sms {
flex-shrink: 0;
border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff);
background: #fff;
color: var(--accent-deep);
border-radius: 999px;
padding: 0.28rem 0.65rem;
font: inherit;
font-size: 0.75rem;
cursor: pointer;
}
.sms:hover:not(:disabled) {
background: var(--accent-subtle);
}
.sms:disabled {
border-color: #e2e8f0;
color: #94a3b8;
cursor: default;
}
.lead {
margin: 0 0 0.6rem;
}
.hint,
.err,
.ok {
margin: 0.55rem 0 0;
font-size: 0.82rem;
}
.hint {
color: #94a3b8;
}
.err {
color: #dc2626;
}
.ok {
color: #16a34a;
}
@media (max-width: 720px) {
.birthdays {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: 0.45rem 0.6rem;
}
.head {
min-width: 0;
}
.head p {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.more {
grid-column: 2;
grid-row: 1;
}
.chips {
grid-column: 1 / -1;
overflow-x: auto;
scrollbar-width: none;
}
.chips::-webkit-scrollbar {
display: none;
}
.day li {
gap: 0.45rem;
padding-inline: 0.7rem;
}
}
</style>
@@ -7,7 +7,7 @@ import {
FlagFilled,
LeftOutlined,
MoreOutlined,
} from '@/icons/ant-bridge';
} from '@ant-design/icons-vue';
import {
Avatar as AAvatar,
Button as AButton,
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { nextTick, ref } from 'vue';
import { PlusOutlined } from '@/icons/ant-bridge';
import { PlusOutlined } from '@ant-design/icons-vue';
import {
Button as AButton,
Card as ACard,
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, nextTick, ref } from 'vue';
import { HolderOutlined, MoreOutlined } from '@/icons/ant-bridge';
import { HolderOutlined, MoreOutlined } from '@ant-design/icons-vue';
import {
Button as AButton,
Dropdown as ADropdown,
@@ -5,7 +5,7 @@ import {
CheckOutlined,
DeleteOutlined,
MoreOutlined,
} from '@/icons/ant-bridge';
} from '@ant-design/icons-vue';
import {
Avatar as AAvatar,
Button as AButton,
@@ -19,7 +19,7 @@ import {
FlagOutlined,
MoreOutlined,
WarningOutlined,
} from '@/icons/ant-bridge';
} from '@ant-design/icons-vue';
const AMenuItem = AMenu.Item;
import UserAvatar from '@/components/UserAvatar.vue';
@@ -1,8 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { Menu as AMenu } from 'ant-design-vue';
import type { MenuProps } from 'ant-design-vue';
import { Segmented as ASegmented } from 'ant-design-vue';
import { treasurySectionAllowed, type TreasurySectionKey } from '@mento/shared';
import { useAuthStore } from '@/stores/auth';
@@ -14,29 +13,33 @@ const scroller = ref<HTMLElement | null>(null);
const links = computed(() => {
const role = auth.user?.role;
const permissions = auth.user?.permissions;
const all: Array<{ to: string; label: string; exact?: boolean; section: TreasurySectionKey }> = [
{ to: '/finance', label: 'داشبورد', exact: true, section: 'treasury_dashboard' },
{ to: '/finance/incomes', label: 'دریافت‌ها و درآمدها', section: 'treasury_incomes' },
{ to: '/finance/expenses', label: 'پرداخت‌ها و هزینه‌ها', section: 'treasury_expenses' },
{ to: '/finance/receivables', label: 'اقساط و مطالبات', section: 'treasury_receivables' },
{ to: '/finance/accounts', label: 'صندوق و حساب‌ها', section: 'treasury_accounts' },
{ to: '/finance/payroll', label: 'حقوق', section: 'treasury_payroll' },
{ to: '/finance/recurring', label: 'تکرارشونده', section: 'treasury_recurring' },
{ to: '/finance/reports', label: 'گزارش', section: 'treasury_reports' },
{ to: '/finance/audit', label: 'سوابق', section: 'treasury_audit' },
{ to: '/finance/categories', label: 'دسته‌بندی', section: 'treasury_categories' },
const all: Array<{ value: string; label: string; exact?: boolean; section: TreasurySectionKey }> = [
{ value: '/finance', label: 'داشبورد', exact: true, section: 'treasury_dashboard' },
{ value: '/finance/incomes', label: 'دریافت‌ها و درآمدها', section: 'treasury_incomes' },
{ value: '/finance/expenses', label: 'پرداخت‌ها و هزینه‌ها', section: 'treasury_expenses' },
{ value: '/finance/receivables', label: 'اقساط و مطالبات', section: 'treasury_receivables' },
{ value: '/finance/accounts', label: 'صندوق و حساب‌ها', section: 'treasury_accounts' },
{ value: '/finance/payroll', label: 'حقوق', section: 'treasury_payroll' },
{ value: '/finance/recurring', label: 'تکرارشونده', section: 'treasury_recurring' },
{ value: '/finance/reports', label: 'گزارش', section: 'treasury_reports' },
{ value: '/finance/audit', label: 'سوابق', section: 'treasury_audit' },
{ value: '/finance/categories', label: 'دسته‌بندی', section: 'treasury_categories' },
];
return all.filter((link) => treasurySectionAllowed(role, permissions, link.section));
});
function on(path: string, exact?: boolean) {
if (exact) return route.path === path;
return route.path === path || route.path.startsWith(`${path}/`);
}
const options = computed(() => links.value.map((l) => ({ value: l.value, label: l.label })));
const selectedKeys = computed(() => {
const match = links.value.find((link) => on(link.to, link.exact));
return match ? [match.to] : [];
const active = computed(() => {
const path = route.path;
for (const link of links.value) {
if (link.exact) {
if (path === link.value) return link.value;
} else if (path === link.value || path.startsWith(`${link.value}/`)) {
return link.value;
}
}
return '/finance';
});
watch(
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4 -6
View File
@@ -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"
+7 -6
View File
@@ -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>
+48 -118
View File
@@ -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>
File diff suppressed because it is too large Load Diff
+7 -10
View File
@@ -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
+2 -15
View File
@@ -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"
+136 -235
View File
@@ -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>
+249 -223
View File
@@ -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
+21 -57
View File
@@ -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
+311 -282
View File
@@ -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>
+181 -74
View File
@@ -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>
+382 -332
View File
@@ -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>
+15 -153
View File
@@ -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';