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
+92 -53
View File
@@ -1,17 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, watch } from 'vue'; import { computed, watch } from 'vue';
import { import { Select as ASelect } from 'ant-design-vue';
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 type { import type {
DataAccessOwnerKind, DataAccessOwnerKind,
DataAccessRule, DataAccessRule,
@@ -26,12 +15,9 @@ import {
PERSON_MOODS, PERSON_MOODS,
sectionHasDataAccessLimits, sectionHasDataAccessLimits,
} from '@mento/shared'; } from '@mento/shared';
export type IdOption = { id: string; name: string }; export type IdOption = { id: string; name: string };
type Choice = { value: string; label: string }; type Choice = { value: string; label: string };
const { Text: ATypographyText } = Typography;
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
modelValue: SectionDataAccess; modelValue: SectionDataAccess;
@@ -449,13 +435,17 @@ const filterSummary = computed(() => {
</script> </script>
<template> <template>
<a-flex vertical :gap="compact ? 8 : 12"> <div class="dae" :class="{ compact }">
<a-radio-group v-model:value="mode" :disabled="disabled"> <div class="dae-mode">
<a-flex vertical :gap="4"> <label>
<a-radio value="all">همهٔ {{ sectionLabel }}</a-radio> <input v-model="mode" type="radio" value="all" :disabled="disabled" />
<a-radio value="rules">محدود با فیلتر</a-radio> همهٔ {{ sectionLabel }}
</a-flex> </label>
</a-radio-group> <label>
<input v-model="mode" type="radio" value="rules" :disabled="disabled" />
محدود با فیلتر
</label>
</div>
<template v-if="mode === 'rules'"> <template v-if="mode === 'rules'">
<p class="hint"> <p class="hint">
@@ -471,37 +461,30 @@ const filterSummary = computed(() => {
</p> </p>
<p class="summary">{{ filterSummary }}</p> <p class="summary">{{ filterSummary }}</p>
<a-card size="small" title="مالک / مسئول" :bordered="true"> <fieldset :disabled="disabled">
<a-flex vertical :gap="8"> <legend>مالک / مسئول</legend>
<a-typography-text type="secondary">خالی = بدون محدودیت مالک</a-typography-text> <p class="muted">خالی = بدون محدودیت مالک</p>
<a-space wrap :size="8"> <label class="chip">
<a-checkbox <input
type="checkbox"
:checked="filter.owners?.includes('self')" :checked="filter.owners?.includes('self')"
:disabled="disabled"
@change="toggleOwner('self')" @change="toggleOwner('self')"
> />
{{ ownerSelfLabel }} {{ ownerSelfLabel }}
</a-checkbox> </label>
<a-checkbox <label class="chip">
<input
type="checkbox"
:checked="filter.owners?.includes('team')" :checked="filter.owners?.includes('team')"
:disabled="disabled"
@change="toggleOwner('team')" @change="toggleOwner('team')"
> />
تیم‌های عضو تیم‌های عضو
</a-checkbox> </label>
</a-space> </fieldset>
</a-flex>
</a-card>
<a-form-item <label v-for="picker in pickers" :key="picker.legend" class="pick">
v-for="picker in pickers" <span>{{ picker.legend }}</span>
:key="picker.legend" <p v-if="picker.loading" class="muted">در حال بارگذاری منبع‌ها…</p>
:label="picker.legend"
:style="{ marginBottom: 0 }"
>
<a-typography-text v-if="picker.loading" type="secondary">
در حال بارگذاری منبع‌ها…
</a-typography-text>
<a-select <a-select
v-else v-else
:value="pickerValue(picker)" :value="pickerValue(picker)"
@@ -516,14 +499,70 @@ const filterSummary = computed(() => {
style="width: 100%" style="width: 100%"
@update:value="setList(picker.key, $event)" @update:value="setList(picker.key, $event)"
/> />
<a-typography-text v-if="picker.hint" type="secondary"> <p v-if="picker.hint" class="muted">{{ picker.hint }}</p>
{{ picker.hint }} </label>
</a-typography-text>
</a-form-item>
</template> </template>
<a-typography-text v-else-if="!hasLimits" type="secondary"> <p v-else-if="!hasLimits" class="hint">
بدون محدودیت — همهٔ {{ sectionLabel }} قابل مشاهده‌اند. بدون محدودیت — همهٔ {{ sectionLabel }} قابل مشاهده‌اند.
</a-typography-text> </p>
</a-flex> </div>
</template> </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>
+139 -82
View File
@@ -1,15 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue'; 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 { import type {
DataAccessPolicy, DataAccessPolicy,
DataAccessSection, DataAccessSection,
@@ -28,8 +18,6 @@ import {
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import DataAccessEditor, { type IdOption } from '@/components/DataAccessEditor.vue'; import DataAccessEditor, { type IdOption } from '@/components/DataAccessEditor.vue';
const { Text: ATypographyText } = Typography;
const props = defineProps<{ const props = defineProps<{
modelValue: DataAccessPolicy; modelValue: DataAccessPolicy;
/** فقط بخش‌هایی که این مجوزها را دارند نشان بده؛ خالی = همه */ /** فقط بخش‌هایی که این مجوزها را دارند نشان بده؛ خالی = همه */
@@ -125,10 +113,6 @@ function patchTreasury(next: UserTreasuryAccess | null) {
emit('update:treasuryAccess', next); emit('update:treasuryAccess', next);
} }
function onTreasuryModeChange(e: { target: { value?: unknown } }) {
patchTreasury(e.target.value === 'role' ? null : (props.treasuryAccess ?? emptyTreasuryAccess()));
}
function toggleTreasurySection(key: RolePermissionKey) { function toggleTreasurySection(key: RolePermissionKey) {
const current = props.treasuryAccess ?? emptyTreasuryAccess(); const current = props.treasuryAccess ?? emptyTreasuryAccess();
const sections = current.sections.includes(key) const sections = current.sections.includes(key)
@@ -242,102 +226,131 @@ onMounted(() => {
void loadOptions(); void loadOptions();
void loadTreasuryAccounts(); 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> </script>
<template> <template>
<div> <div class="dap">
<a-typography-text v-if="!visibleSections.length" type="secondary"> <p v-if="!visibleSections.length" class="muted">
برای تنظیم محدوده، ابتدا مجوز بخش مربوط را روشن کنید. برای تنظیم محدوده، ابتدا مجوز بخش مربوط را روشن کنید.
</a-typography-text> </p>
<a-tabs v-else v-model:activeKey="active"> <template v-else>
<a-tab-pane <div class="tabs" role="tablist">
<button
v-for="s in visibleSections" v-for="s in visibleSections"
:key="s" :key="s"
:tab="DATA_ACCESS_SECTION_LABELS[s]" type="button"
class="tab"
:class="{ on: active === s }"
role="tab"
:aria-selected="active === s"
@click="active = s"
> >
<DataAccessEditor {{ DATA_ACCESS_SECTION_LABELS[s] }}
:section="s" </button>
:model-value="sectionValue(s)" <button
:groups="customerGroups" v-if="showTreasury"
:stages="s === 'leads' ? leadStages : s === 'sales' ? dealStages : s === 'activities' ? activityStages : s === 'projects' ? projectStages : []" type="button"
:pipelines="pipelines" class="tab"
:boards="s === 'activities' ? activityBoards : s === 'projects' ? projectBoards : []" :class="{ on: active === 'treasury' }"
:activity-types="s === 'activities' ? activityTypes : s === 'routines' ? routineCategories : []" role="tab"
:import-sources="importSources" :aria-selected="active === 'treasury'"
:import-sources-ready="importSourcesReady" @click="active = 'treasury'"
:import-sources-failed="importSourcesFailed" >
:disabled="disabled || dataLocked" مدیریت مالی
:compact="compact" </button>
@update:model-value="setSection(s, $event)" </div>
/> <div v-if="active === 'treasury'" class="treasury">
</a-tab-pane> <p class="muted">
<a-tab-pane v-if="showTreasury" key="treasury" tab="مدیریت مالی">
<a-space direction="vertical">
<a-typography-text type="secondary">
این برگه فقط برای همین کاربر است. «مثل نقش» یعنی همان دسترسی مالی نقش بماند. این برگه فقط برای همین کاربر است. «مثل نقش» یعنی همان دسترسی مالی نقش بماند.
در حالت سفارشی، اگر هیچ بخش ریزی تیک نخورد همه بخش‌ها به‌جز حقوق باز می‌مانند و حقوق جداست. در حالت سفارشی، اگر هیچ بخش ریزی تیک نخورد همه بخش‌ها به‌جز حقوق باز می‌مانند و حقوق جداست.
اگر هیچ حسابی انتخاب نشود همه حساب‌ها باز است. اگر هیچ حسابی انتخاب نشود همه حساب‌ها باز است.
</a-typography-text> </p>
<a-radio-group <label class="choice">
:value="treasuryAccess == null ? 'role' : 'custom'" <input
type="radio"
name="user-treasury"
:checked="treasuryAccess == null"
:disabled="disabled" :disabled="disabled"
@change="onTreasuryModeChange" @change="patchTreasury(null)"
> />
<a-space direction="vertical"> مثل نقش
<a-radio value="role">مثل نقش</a-radio> </label>
<a-radio value="custom">سفارشی برای این کاربر</a-radio> <label class="choice">
</a-space> <input
</a-radio-group> type="radio"
name="user-treasury"
:checked="treasuryAccess != null"
:disabled="disabled"
@change="patchTreasury(treasuryAccess ?? emptyTreasuryAccess())"
/>
سفارشی برای این کاربر
</label>
<template v-if="treasuryAccess"> <template v-if="treasuryAccess">
<a-checkbox <label class="choice">
<input
type="checkbox"
:checked="treasuryAccess.enabled" :checked="treasuryAccess.enabled"
:disabled="disabled" :disabled="disabled"
@change="patchTreasury({ ...treasuryAccess, enabled: !treasuryAccess.enabled })" @change="patchTreasury({ ...treasuryAccess, enabled: !treasuryAccess.enabled })"
> />
دسترسی به مدیریت مالی دسترسی به مدیریت مالی
</a-checkbox> </label>
<template v-if="treasuryAccess.enabled"> <template v-if="treasuryAccess.enabled">
<a-space direction="vertical"> <label v-for="perm in treasurySections" :key="perm.key" class="choice sub">
<a-checkbox <input
v-for="perm in treasurySections" type="checkbox"
:key="perm.key"
:checked="treasuryAccess.sections.includes(perm.key)" :checked="treasuryAccess.sections.includes(perm.key)"
:disabled="disabled" :disabled="disabled"
@change="toggleTreasurySection(perm.key)" @change="toggleTreasurySection(perm.key)"
> />
{{ perm.label }} {{ perm.label }}
</a-checkbox> </label>
</a-space> <label class="choice">
<a-checkbox <input
type="checkbox"
:checked="treasuryAccess.ownAccounts" :checked="treasuryAccess.ownAccounts"
:disabled="disabled" :disabled="disabled"
@change="patchTreasury({ ...treasuryAccess, ownAccounts: !treasuryAccess.ownAccounts })" @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 </label>
v-for="account in filteredTreasuryAccounts" <p class="muted">حساب‌های دیگر</p>
:key="account.id" <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)" :checked="treasuryAccess.accountIds.includes(account.id)"
:disabled="disabled" :disabled="disabled"
@change="toggleTreasuryAccount(account.id)" @change="toggleTreasuryAccount(account.id)"
> />
{{ account.name }} {{ account.name }}
<template v-if="account.responsibleName"> — مسئول: {{ account.responsibleName }}</template> <template v-if="account.responsibleName"> — مسئول: {{ account.responsibleName }}</template>
</a-checkbox> </label>
</a-space> <p v-if="!treasuryAccounts.length" class="muted">حسابی برای انتخاب نیست.</p>
<a-typography-text v-if="!treasuryAccounts.length" type="secondary">
حسابی برای انتخاب نیست.
</a-typography-text>
</template>
</template> </template>
</template> </template>
</div> </div>
@@ -360,3 +373,47 @@ onMounted(() => {
</template> </template>
</div> </div>
</template> </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, ClockCircleOutlined,
LeftOutlined, LeftOutlined,
RightOutlined, RightOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { import {
addJalaliMonths, addJalaliMonths,
dateToJalali, dateToJalali,
@@ -58,6 +58,8 @@ const hourColRef = ref<HTMLElement | null>(null);
const minuteColRef = ref<HTMLElement | null>(null); const minuteColRef = ref<HTMLElement | null>(null);
const top = ref(0); const top = ref(0);
const left = ref(0); const left = ref(0);
/** بالای مودال Ant (حدود ۱۰۰۰) تا تقویم پشت پنجره نماند */
const popupZ = ref(120);
const todayJ = dateToJalali(new Date()); const todayJ = dateToJalali(new Date());
const cursor = ref<{ jy: number; jm: number }>({ jy: todayJ.jy, jm: todayJ.jm }); const cursor = ref<{ jy: number; jm: number }>({ jy: todayJ.jy, jm: todayJ.jm });
const draftHour = ref(9); const draftHour = ref(9);
@@ -325,16 +327,32 @@ function place() {
const panel = panelRef.value; const panel = panelRef.value;
if (!trigger) return; if (!trigger) return;
const rect = trigger.getBoundingClientRect(); const rect = trigger.getBoundingClientRect();
const width = panel?.offsetWidth || (props.mode === 'time' ? (isMobile.value ? 340 : 280) : 320); const width =
const height = panel?.offsetHeight || (props.mode === 'time' ? (isMobile.value ? 460 : 320) : 360); 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; let nextLeft = rect.left;
if (getComputedStyle(document.documentElement).direction === 'rtl') { if (getComputedStyle(document.documentElement).direction === 'rtl') {
nextLeft = rect.right - width; nextLeft = rect.right - width;
} }
nextLeft = Math.min(Math.max(8, nextLeft), window.innerWidth - width - 8); nextLeft = Math.min(
let nextTop = rect.bottom + 8; Math.max(margin, nextLeft),
if (nextTop + height > window.innerHeight - 8) { Math.max(margin, window.innerWidth - width - margin),
nextTop = Math.max(8, rect.top - height - 8); );
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; left.value = nextLeft;
top.value = nextTop; top.value = nextTop;
@@ -360,6 +378,7 @@ async function show() {
calView.value = props.startView; calView.value = props.startView;
clockFace.value = 'hour'; clockFace.value = 'hour';
syncViewport(); syncViewport();
liftAboveOverlays();
open.value = true; open.value = true;
await nextTick(); await nextTick();
place(); place();
@@ -554,7 +573,7 @@ onBeforeUnmount(() => {
'is-desktop': !isMobile, 'is-desktop': !isMobile,
}" }"
role="dialog" 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"> <header v-if="mode !== 'time'" class="nav">
<a-button type="text" class="nav-btn" :aria-label="navLabels.forward" @click="navStep(1)"> <a-button type="text" class="nav-btn" :aria-label="navLabels.forward" @click="navStep(1)">
@@ -742,7 +761,7 @@ onBeforeUnmount(() => {
> >
پاک کردن پاک کردن
</a-button> </a-button>
<a-button type="primary" class="done" @click="hide">تأیید</a-button> <a-button type="primary" @click="hide">تأیید</a-button>
</footer> </footer>
</div> </div>
</Teleport> </Teleport>
@@ -867,10 +886,11 @@ onBeforeUnmount(() => {
.panel { .panel {
position: fixed; position: fixed;
z-index: 120; z-index: 120;
box-sizing: border-box;
width: min(20.5rem, calc(100vw - 16px)); width: min(20.5rem, calc(100vw - 16px));
max-height: calc(100vh - 16px); /* تقویم باید یکجا دیده شود؛ اسکرول داخل پنل گیج‌کننده است */
overflow-x: hidden; max-height: none;
overflow-y: auto; overflow: hidden;
background: #fff; background: #fff;
border-radius: var(--radius); border-radius: var(--radius);
box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18); box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
@@ -878,6 +898,13 @@ onBeforeUnmount(() => {
font-family: IRANSans, Tahoma, sans-serif; font-family: IRANSans, Tahoma, sans-serif;
} }
@media (max-height: 420px) {
.panel {
max-height: calc(100vh - 16px);
overflow: auto;
}
}
.panel-time { .panel-time {
width: min(22.5rem, calc(100vw - 16px)); width: min(22.5rem, calc(100vw - 16px));
} }
@@ -909,45 +936,40 @@ onBeforeUnmount(() => {
.pick-grid { .pick-grid {
display: grid; display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-columns: repeat(3, 1fr);
gap: 0.35rem; gap: 0.35rem;
padding: 0.25rem 0; padding: 0.25rem 0;
} }
.panel :deep(.ant-btn.pick-cell) { .panel :deep(.pick-cell.ant-btn) {
width: 100%; width: 100% !important;
min-width: 0; min-width: 0 !important;
height: 44px; height: 44px !important;
margin: 0; padding-inline: 0 !important;
padding: 0 4px;
border-radius: var(--radius); border-radius: var(--radius);
color: #0f172a; color: #0f172a;
font-size: 0.85rem; font-size: 0.85rem;
} }
.panel :deep(.ant-btn.pick-cell.today) { .panel :deep(.pick-cell.today) {
box-shadow: inset 0 0 0 1px #99f6e4; box-shadow: inset 0 0 0 1px #99f6e4;
} }
.panel :deep(.ant-btn.pick-cell.on), .panel :deep(.pick-cell.on),
.panel :deep(.ant-btn.pick-cell:hover) { .panel :deep(.pick-cell.ant-btn:hover) {
background: #0d9488; background: #0d9488;
color: #fff; color: #fff;
} }
.panel :deep(.ant-btn.nav-btn) { .nav-btn {
width: 32px; width: 32px;
min-width: 32px;
height: 32px; height: 32px;
margin: 0;
padding: 0;
border: 0; border: 0;
border-radius: var(--radius); border-radius: var(--radius);
background: #f1f5f9; background: #f1f5f9;
color: #0f766e; color: #0f766e;
display: inline-flex; display: grid;
align-items: center; place-items: center;
justify-content: center;
cursor: pointer; cursor: pointer;
} }
@@ -960,6 +982,7 @@ onBeforeUnmount(() => {
display: grid; display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-columns: repeat(7, minmax(0, 1fr));
gap: 0.15rem; gap: 0.15rem;
width: 100%;
min-width: 0; min-width: 0;
} }
@@ -970,40 +993,43 @@ onBeforeUnmount(() => {
padding-bottom: 0.25rem; padding-bottom: 0.25rem;
} }
.panel :deep(.ant-btn.day) { .panel :deep(.day.ant-btn) {
display: inline-flex; width: 100% !important;
align-items: center; min-width: 0 !important;
justify-content: center; height: 34px !important;
width: 100%; padding: 0 !important;
min-width: 0;
height: 34px;
margin: 0;
padding: 0;
line-height: 1;
border: 0; border: 0;
border-radius: var(--radius); border-radius: var(--radius);
background: none; background: none;
color: #0f172a; color: #0f172a;
font: inherit; font: inherit;
font-size: 0.82rem;
line-height: 1;
cursor: pointer; 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; color: #cbd5e1;
} }
.panel :deep(.ant-btn.day.today) { .panel :deep(.day.today) {
box-shadow: inset 0 0 0 1px #99f6e4; box-shadow: inset 0 0 0 1px #99f6e4;
} }
.panel :deep(.ant-btn.day.on), .panel :deep(.day.on),
.panel :deep(.ant-btn.day:hover) { .panel :deep(.day.ant-btn:hover) {
background: #0d9488; background: #0d9488;
color: #fff; color: #fff;
} }
.panel :deep(.ant-btn.day.mute:hover) { .panel :deep(.day.mute:hover) {
background: #f1f5f9; background: #f1f5f9;
color: #64748b; color: #64748b;
} }
@@ -1033,11 +1059,9 @@ onBeforeUnmount(() => {
margin-bottom: 0.85rem; margin-bottom: 0.85rem;
} }
.panel :deep(.ant-btn.md-chip) { .md-chip {
min-width: 5.1rem; min-width: 5.1rem;
height: 4.1rem; height: 4.1rem;
margin: 0;
padding: 0;
border: 0; border: 0;
border-radius: var(--radius); border-radius: var(--radius);
background: #f1f5f9; background: #f1f5f9;
@@ -1050,7 +1074,7 @@ onBeforeUnmount(() => {
cursor: pointer; cursor: pointer;
} }
.panel :deep(.ant-btn.md-chip.on) { .md-chip.on {
background: #ccfbf1; background: #ccfbf1;
color: #0f766e; color: #0f766e;
box-shadow: inset 0 0 0 2px #99f6e4; box-shadow: inset 0 0 0 2px #99f6e4;
@@ -1124,11 +1148,10 @@ onBeforeUnmount(() => {
pointer-events: none; pointer-events: none;
} }
.panel :deep(.ant-btn.md-tick) { .md-tick {
position: absolute; position: absolute;
z-index: 2; z-index: 2;
width: 36px; width: 36px;
min-width: 36px;
height: 36px; height: 36px;
margin: 0; margin: 0;
border: 0; border: 0;
@@ -1145,12 +1168,12 @@ onBeforeUnmount(() => {
padding: 0; padding: 0;
} }
.panel :deep(.ant-btn.md-tick.inner) { .md-tick.inner {
font-size: 0.74rem; font-size: 0.74rem;
color: #64748b; color: #64748b;
} }
.panel :deep(.ant-btn.md-tick.on) { .md-tick.on {
background: transparent; background: transparent;
color: #fff; color: #fff;
} }
@@ -1199,12 +1222,9 @@ onBeforeUnmount(() => {
overscroll-behavior: contain; overscroll-behavior: contain;
} }
.panel :deep(.ant-btn.col-item) { .col-item {
width: 100%; width: 100%;
min-width: 0;
height: 36px; height: 36px;
margin: 0;
padding: 0;
border: 0; border: 0;
border-radius: var(--radius); border-radius: var(--radius);
background: transparent; background: transparent;
@@ -1215,11 +1235,11 @@ onBeforeUnmount(() => {
cursor: pointer; cursor: pointer;
} }
.panel :deep(.ant-btn.col-item:hover) { .col-item:hover {
background: #e2e8f0; background: #e2e8f0;
} }
.panel :deep(.ant-btn.col-item.on) { .col-item.on {
background: #0d9488; background: #0d9488;
color: #fff; color: #fff;
} }
@@ -1231,8 +1251,28 @@ onBeforeUnmount(() => {
margin-top: 0.7rem; 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; 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 { .panel.is-mobile .time-box {
+1 -1
View File
@@ -7,7 +7,7 @@ import {
Popover as APopover, Popover as APopover,
Typography, Typography,
} from 'ant-design-vue'; } from 'ant-design-vue';
import { SettingOutlined } from '@/icons/ant-bridge'; import { SettingOutlined } from '@ant-design/icons-vue';
import { useTableColumns } from '@/lib/tableColumns'; import { useTableColumns } from '@/lib/tableColumns';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
+70 -120
View File
@@ -19,6 +19,7 @@ import {
emptySectionDataAccess, emptySectionDataAccess,
sectionHasDataAccessLimits, sectionHasDataAccessLimits,
} from '@mento/shared'; } from '@mento/shared';
import { UiButton, UiEmptyState, UiField, UiInput } from '@/components/ui';
import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue'; import DataAccessPolicyPanel from '@/components/DataAccessPolicyPanel.vue';
import { formatLocalDateInput, parseLocalInput, toFaDigits } from '@/lib/jalali'; import { formatLocalDateInput, parseLocalInput, toFaDigits } from '@/lib/jalali';
import { matchesSearch } from '@/lib/search'; import { matchesSearch } from '@/lib/search';
@@ -37,7 +38,7 @@ const showPriorArchive = computed(
const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false)); const priorUsers = computed(() => props.users.filter((u) => u.isActive !== false));
const selectedPriorUsers = computed(() => priorUsers.value.filter((u) => u.priorArchiveEnabled)); const selectedPriorUsers = computed(() => priorUsers.value.filter((u) => u.priorArchiveEnabled));
const priorSearch = ref(''); const priorSearch = ref('');
const priorPick = ref<string | undefined>(undefined); const priorPick = ref('');
const priorSavingId = ref(''); const priorSavingId = ref('');
const cutoffLocal = ref(''); const cutoffLocal = ref('');
const cutoffSaving = ref(false); const cutoffSaving = ref(false);
@@ -48,16 +49,10 @@ const availablePriorUsers = computed(() => {
return priorUsers.value.filter((u) => { return priorUsers.value.filter((u) => {
if (u.priorArchiveEnabled) return false; if (u.priorArchiveEnabled) return false;
if (!q) return true; if (!q) return true;
return [u.fullName, u.email, u.mobile] return [u.fullName, u.email, u.mobile].filter(Boolean).some((v) => String(v).toLowerCase().includes(q));
.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<{ const emit = defineEmits<{
refreshUsers: []; refreshUsers: [];
}>(); }>();
@@ -105,7 +100,7 @@ const filteredAccessUsers = computed(() => {
async function setPriorArchive(userId: string, enabled: boolean) { async function setPriorArchive(userId: string, enabled: boolean) {
priorSavingId.value = userId; priorSavingId.value = userId;
priorPick.value = undefined; priorPick.value = '';
error.value = ''; error.value = '';
ok.value = ''; ok.value = '';
try { try {
@@ -143,10 +138,7 @@ async function loadPriorArchiveCutoff() {
applyCutoffFromOrg(data); applyCutoffFromOrg(data);
} catch (e) { } catch (e) {
error.value = axios.isAxiosError(e) error.value = axios.isAxiosError(e)
? String( ? String((e.response?.data as { message?: string })?.message ?? 'بارگذاری تاریخ بایگانی ناموفق بود.')
(e.response?.data as { message?: string })?.message ??
'بارگذاری تاریخ بایگانی ناموفق بود.',
)
: 'بارگذاری تاریخ بایگانی ناموفق بود.'; : 'بارگذاری تاریخ بایگانی ناموفق بود.';
} finally { } finally {
cutoffLoading.value = false; cutoffLoading.value = false;
@@ -168,10 +160,7 @@ async function onCutoffChange(value: string) {
await auth.hydrate(); await auth.hydrate();
} catch (e) { } catch (e) {
error.value = axios.isAxiosError(e) error.value = axios.isAxiosError(e)
? String( ? String((e.response?.data as { message?: string })?.message ?? 'ذخیره تاریخ بایگانی ناموفق بود.')
(e.response?.data as { message?: string })?.message ??
'ذخیره تاریخ بایگانی ناموفق بود.',
)
: 'ذخیره تاریخ بایگانی ناموفق بود.'; : 'ذخیره تاریخ بایگانی ناموفق بود.';
await loadPriorArchiveCutoff(); await loadPriorArchiveCutoff();
} finally { } finally {
@@ -179,10 +168,9 @@ async function onCutoffChange(value: string) {
} }
} }
function pickPriorUser(userId: unknown) { function pickPriorUser(userId: string) {
const id = userId == null ? '' : String(userId); if (!userId) return;
if (!id) return; void setPriorArchive(userId, true);
void setPriorArchive(id, true);
} }
async function load() { 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; if (!memberDraft.value[userId]) return;
memberDraft.value = { memberDraft.value = { ...memberDraft.value, [userId]: role };
...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('، ');
} }
async function saveMembers() { async function saveMembers() {
@@ -411,31 +389,22 @@ onMounted(() => {
</script> </script>
<template> <template>
<a-flex vertical :gap="12"> <div class="teams-panel">
<a-alert v-if="error" type="error" show-icon :message="error" closable @close="error = ''" /> <p v-if="error" class="error">{{ error }}</p>
<a-alert v-if="ok" type="success" show-icon :message="ok" closable @close="ok = ''" /> <p v-if="ok" class="ok">{{ ok }}</p>
<a-card :bordered="false"> <section v-if="canEdit" class="card">
<a-form v-if="canEdit" layout="vertical" @finish="createTeam"> <h3>تیم جدید</h3>
<a-divider orientation="right">تیم جدید</a-divider> <div class="row">
<a-row :gutter="[16, 0]" align="bottom"> <UiField label="نام تیم">
<a-col :xs="24" :md="8"> <UiInput v-model="newName" placeholder="مثلاً فروش تهران" />
<a-form-item label="نام تیم"> </UiField>
<a-input v-model:value="newName" placeholder="مثلاً فروش تهران" style="width: 100%" /> <UiField label="توضیح">
</a-form-item> <UiInput v-model="newDesc" placeholder="اختیاری" />
</a-col> </UiField>
<a-col :xs="24" :md="10"> <UiButton :loading="saving" @click="createTeam">افزودن</UiButton>
<a-form-item label="توضیح"> </div>
<a-input v-model:value="newDesc" placeholder="اختیاری" style="width: 100%" /> </section>
</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 class="card"> <section class="card">
<header class="card-head"> <header class="card-head">
@@ -530,27 +499,41 @@ onMounted(() => {
:disabled="cutoffSaving || cutoffLoading" :disabled="cutoffSaving || cutoffLoading"
@update:model-value="onCutoffChange" @update:model-value="onCutoffChange"
/> />
<a-list v-else item-layout="vertical" :data-source="teams"> </header>
<template #renderItem="{ item: t }"> <p class="hint">
<a-list-item> فقط کاربرانی که تیک می‌خورند سوئیچ کار جاری و بایگانی را می‌بینند. بقیهٔ محیط مثل قبل همهٔ
<template v-if="canEdit" #actions> رکوردها را مطابق سطح دسترسی خودشان می‌بینند.
<a-button type="link" @click="startMetaEdit(t)">ویرایش</a-button> </p>
<a-button type="link" @click="startEdit(t)">اعضا</a-button> <div class="prior-picker">
<a-button type="link" danger @click="removeTeam(t.id)">حذف</a-button> <UiInput v-model="priorSearch" placeholder="جستجوی کاربر…" />
</template> <select
<a-list-item-meta> v-model="priorPick"
<template #title> :disabled="!availablePriorUsers.length || Boolean(priorSavingId)"
<a-space wrap> @change="pickPriorUser(($event.target as HTMLSelectElement).value)"
<a-typography-text strong>{{ t.name }}</a-typography-text> >
<a-tag :bordered="false">{{ toFaDigits(t.memberCount) }} عضو</a-tag> <option value="">
</a-space> {{ availablePriorUsers.length ? 'انتخاب کاربر برای فعال‌سازی' : 'کاربر دیگری پیدا نشد' }}
</template> </option>
<template #description> <option v-for="u in availablePriorUsers" :key="u.id" :value="u.id">
<a-typography-text type="secondary"> {{ u.fullName }}
{{ t.description || 'بدون توضیح' }} · {{ teamMembersLabel(t) }} </option>
</a-typography-text> </select>
</template> </div>
</a-list-item-meta> <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"> <section class="card">
<header class="card-head"> <header class="card-head">
@@ -598,48 +581,15 @@ onMounted(() => {
:data-locked="accessMode === 'inherit'" :data-locked="accessMode === 'inherit'"
compact compact
/> />
<a-list v-else item-layout="vertical" :data-source="editableUsers"> <div class="actions">
<template #renderItem="{ item: u }"> <UiButton :loading="accessSaving" @click="saveUserAccess(u.id)">ذخیره</UiButton>
<a-list-item> <UiButton variant="secondary" @click="expandedAccess = null">انصراف</UiButton>
<template v-if="canEdit" #actions> </div>
<a-button type="link" @click="openAccessEditor(u)"> </div>
{{ expandedAccess === u.id ? 'بستن' : 'تنظیم' }} </div>
</a-button> </div>
</template> </section>
<a-list-item-meta :description="accessSummary(u)"> </div>
<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>
</template> </template>
<style scoped> <style scoped>
@@ -607,4 +607,9 @@ function openFullActivity(id: string) {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.muted {
margin: 0;
color: #64748b;
}
</style> </style>
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch, type Component } from 'vue'; import { computed, ref, watch } from 'vue';
import axios from 'axios'; import axios from 'axios';
import type { import type {
ActivityFieldDef, ActivityFieldDef,
@@ -20,45 +20,6 @@ import {
ACTIVITY_TYPE_LABELS, ACTIVITY_TYPE_LABELS,
DEFAULT_ACTIVITY_PRIORITY_SETTINGS, DEFAULT_ACTIVITY_PRIORITY_SETTINGS,
} from '@mento/shared'; } 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 { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { useActivityPriorities } from '@/lib/activity-priorities'; import { useActivityPriorities } from '@/lib/activity-priorities';
@@ -68,27 +29,8 @@ import {
typeColorStyle, typeColorStyle,
useActivityTypes, useActivityTypes,
} from '@/lib/activity-types'; } from '@/lib/activity-types';
import { UiButton, UiModal } from '@/components/ui';
const ACTIVITY_ICON_COMPONENTS: Record<ActivityTypeIcon, Component> = { import UiIcon from '@/components/UiIcon.vue';
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,
};
const props = defineProps<{ open: boolean }>(); const props = defineProps<{ open: boolean }>();
const emit = defineEmits<{ close: []; changed: [] }>(); const emit = defineEmits<{ close: []; changed: [] }>();
@@ -157,7 +99,10 @@ function snapshot(d: Draft | null) {
const dirty = computed(() => snapshot(draft.value) !== savedSnapshot.value); 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; selectedId.value = id;
draft.value = toDraft(id === 'new' ? null : (types.value.find((t) => t.id === id) ?? null)); draft.value = toDraft(id === 'new' ? null : (types.value.find((t) => t.id === id) ?? null));
savedSnapshot.value = snapshot(draft.value); savedSnapshot.value = snapshot(draft.value);
@@ -236,7 +181,7 @@ watch(
const first = types.value[0]; const first = types.value[0];
selectedId.value = null; selectedId.value = null;
draft.value = null; draft.value = null;
if (first) applySelect(first.id); if (first) select(first.id);
}, },
{ immediate: true }, { immediate: true },
); );
@@ -274,15 +219,12 @@ function moveField(index: number, dir: -1 | 1) {
function removeField(index: number) { function removeField(index: number) {
const f = draft.value?.fields[index]; const f = draft.value?.fields[index];
if (!f) return; if (!f) return;
if (f.label.trim()) { if (
Modal.confirm({ f.label.trim() &&
title: 'حذف فیلد', !window.confirm(
content: `فیلد «${f.label}» حذف شود؟ مقادیر ثبت‌شدهٔ آن در فعالیت‌های قبلی دیگر نمایش داده نمی‌شود.`, `فیلد «${f.label}» حذف شود؟ مقادیر ثبت‌شدهٔ آن در فعالیت‌های قبلی دیگر نمایش داده نمی‌شود.`,
okText: 'حذف', )
cancelText: 'انصراف', ) {
okButtonProps: { danger: true },
onOk: () => draft.value!.fields.splice(index, 1),
});
return; return;
} }
draft.value!.fields.splice(index, 1); draft.value!.fields.splice(index, 1);
@@ -318,7 +260,14 @@ function validate(d: Draft): string {
return ''; 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'; busy.value = 'save';
error.value = ''; error.value = '';
notice.value = ''; notice.value = '';
@@ -331,6 +280,18 @@ async function performSave(d: Draft) {
}; };
try { try {
if (d.id) { 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); await api.patch(`/activities/types/${d.id}`, body);
} else { } else {
const { data } = await api.post<ActivityTypeDefDto>('/activities/types', body); 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() { async function remove() {
const d = draft.value; const d = draft.value;
if (!d?.id || d.isSystem) return; if (!d?.id || d.isSystem) return;
Modal.confirm({ if (
title: 'حذف نوع فعالیت', !window.confirm(
content: `نوع «${d.name}» حذف شود؟ فعالیت‌های این نوع به نوع اصلی «${ACTIVITY_TYPE_LABELS[d.baseType]}» برمی‌گردند. برای نگه داشتن سوابق، می‌توانید به‌جای حذف آن را غیرفعال کنید.`, `نوع «${d.name}» حذف شود؟ فعالیت‌های این نوع به نوع اصلی «${ACTIVITY_TYPE_LABELS[d.baseType]}» برمی‌گردند. برای نگه داشتن سوابق، می‌توانید به‌جای حذف آن را غیرفعال کنید.`,
okText: 'حذف', )
cancelText: 'انصراف', ) {
okButtonProps: { danger: true }, return;
async onOk() { }
busy.value = 'remove'; busy.value = 'remove';
error.value = ''; error.value = '';
try { try {
await api.delete(`/activities/types/${d.id!}`); await api.delete(`/activities/types/${d.id}`);
await load(true); await load(true);
savedSnapshot.value = snapshot(null); savedSnapshot.value = snapshot(null);
draft.value = null; draft.value = null;
const first = types.value[0]; const first = types.value[0];
if (first) applySelect(first.id); if (first) select(first.id);
emit('changed'); emit('changed');
} catch (e) { } catch (e) {
error.value = apiMessage(e, 'حذف نوع فعالیت ناموفق بود.'); error.value = apiMessage(e, 'حذف نوع فعالیت ناموفق بود.');
} finally { } finally {
busy.value = ''; busy.value = '';
} }
},
});
} }
async function moveType(index: number, dir: -1 | 1) { async function moveType(index: number, dir: -1 | 1) {
@@ -430,10 +366,6 @@ function close() {
} }
emit('close'); emit('close');
} }
function showPlaceholder(type: ActivityFieldType) {
return !['checkbox', 'participants', 'select', 'multiselect', 'date'].includes(type);
}
</script> </script>
<template> <template>
@@ -465,71 +397,172 @@ function showPlaceholder(type: ActivityFieldType) {
برای هر نوع فعالیت فیلدهای مخصوص خودش را تعریف کنید؛ مثلاً «موضوع جلسه» و «شرکت‌کنندگان» برای جلسه برای هر نوع فعالیت فیلدهای مخصوص خودش را تعریف کنید؛ مثلاً «موضوع جلسه» و «شرکت‌کنندگان» برای جلسه
یا «لیست کارها» برای وظیفه. «نوع پایه» مشخص می‌کند فعالیت در گزارش‌ها جزو تماس، جلسه، وظیفه یا پیام یا «لیست کارها» برای وظیفه. «نوع پایه» مشخص می‌کند فعالیت در گزارش‌ها جزو تماس، جلسه، وظیفه یا پیام
شمرده شود. شمرده شود.
</a-typography-text> </p>
<a-row :gutter="[16, 16]"> <div class="layout">
<a-col :xs="24" :md="7"> <aside class="list">
<a-flex vertical gap="small"> <div
<a-flex
v-for="(t, index) in types" v-for="(t, index) in types"
:key="t.id" :key="t.id"
align="center" class="type-row"
gap="small" :class="{ on: selectedId === t.id, off: !t.isActive }"
> >
<a-button <button type="button" class="pick" @click="select(t.id)">
block <span class="ico" :style="typeColorStyle(t.color)">
:type="selectedId === t.id ? 'primary' : 'default'" <UiIcon :name="t.icon" :size="14" />
:ghost="selectedId === t.id"
:style="{ opacity: t.isActive ? 1 : 0.65, textAlign: 'start', height: 'auto', padding: '8px 12px' }"
@click="select(t.id)"
>
<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> </span>
<a-flex vertical :style="{ minWidth: 0, flex: 1 }"> <span class="txt">
<a-typography-text strong :ellipsis="true">{{ t.name }}</a-typography-text> <b>{{ t.name }}</b>
<a-typography-text type="secondary" :style="{ fontSize: '12px' }"> <small>
{{ ACTIVITY_TYPE_LABELS[t.baseType] }} · {{ toFaDigits(t.fields.length) }} فیلد {{ ACTIVITY_TYPE_LABELS[t.baseType] }} · {{ toFaDigits(t.fields.length) }} فیلد
<template v-if="!t.isActive"> · غیرفعال</template> <template v-if="!t.isActive"> · غیرفعال</template>
</a-typography-text> </small>
</a-flex> </span>
</a-flex> </button>
</a-button> <div class="order">
<a-flex vertical> <button
<a-button type="button"
type="text"
:disabled="index === 0 || Boolean(busy)" :disabled="index === 0 || Boolean(busy)"
aria-label="انتقال به بالا" aria-label="انتقال به بالا"
@click="moveType(index, -1)" @click="moveType(index, -1)"
> >
<template #icon><ArrowUpOutlined /></template> ▲
</a-button> </button>
<a-button <button
type="text" type="button"
:disabled="index === types.length - 1 || Boolean(busy)" :disabled="index === types.length - 1 || Boolean(busy)"
aria-label="انتقال به پایین" aria-label="انتقال به پایین"
@click="moveType(index, 1)" @click="moveType(index, 1)"
> >
<template #icon><ArrowDownOutlined /></template> ▼
</a-button> </button>
</a-flex> </div>
</a-flex> </div>
<a-button <button type="button" class="add-type" :class="{ on: selectedId === 'new' }" @click="select('new')">
block <UiIcon name="plus" :size="15" />
:type="selectedId === 'new' ? 'primary' : 'dashed'" نوع فعالیت جدید
@click="select('new')" </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)"
>
▼
</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 ? 'ذخیرهٔ تغییرات' : 'ساخت نوع فعالیت' }} {{ draft.id ? 'ذخیرهٔ تغییرات' : 'ساخت نوع فعالیت' }}
</UiButton> </UiButton>
@@ -1,16 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { RouterLink } from 'vue-router'; 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 { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { hasSectionPermission } from '@/lib/section-permissions'; import { hasSectionPermission } from '@/lib/section-permissions';
@@ -74,78 +64,63 @@ onMounted(async () => {
</script> </script>
<template> <template>
<section v-if="data" class="bg-white rounded-2xl border border-slate-200/80 p-4 shadow-sm"> <section v-if="data" class="birthdays">
<a-flex align="center" wrap="wrap" gap="middle" justify="space-between"> <div class="head">
<a-flex align="center" gap="middle"> <span class="ico"><UiIcon name="gift" :size="18" /></span>
<a-typography-text type="secondary"><GiftOutlined /></a-typography-text>
<div> <div>
<a-typography-text strong>تولدهای {{ data.monthName }}</a-typography-text> <strong>تولدهای {{ data.monthName }}</strong>
<br /> <p>{{ toFaDigits(data.total) }} مشتری این ماه تولد دارند</p>
<a-typography-text type="secondary"> </div>
{{ toFaDigits(data.total) }} مشتری این ماه تولد دارند
</a-typography-text>
</div> </div>
</a-flex>
<a-space wrap> <div class="chips">
<RouterLink <RouterLink
v-for="person in data.preview" v-for="person in data.preview"
:key="person.id" :key="person.id"
class="chip"
:title="person.fullName"
:to="{ name: 'person-detail', params: { id: person.id } }" :to="{ name: 'person-detail', params: { id: person.id } }"
> >
<a-tag> <b>{{ toFaDigits(person.day) }}</b>
{{ toFaDigits(person.day) }} — {{ person.fullName }} <span>{{ person.fullName }}</span>
</a-tag>
</RouterLink> </RouterLink>
<a-button type="link" @click="listOpen = true"> </div>
<button type="button" class="more" @click="listOpen = true">
{{ data.total > data.preview.length ? 'همه' : 'فهرست' }} {{ data.total > data.preview.length ? 'همه' : 'فهرست' }}
</a-button> </button>
</a-space>
</a-flex>
<a-modal <UiModal :open="listOpen" :title="`تولدهای ${data.monthName}`" @close="listOpen = false">
v-model:open="listOpen" <div class="days">
:title="`تولدهای ${data.monthName}`" <section
:footer="null" v-for="[day, people] in groups"
destroy-on-close :key="day"
> class="day"
<a-list item-layout="vertical" :data-source="groups"> :class="{ past: day < data.today, today: day === data.today }"
<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"
> >
<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 }} {{ person.fullName }}
</RouterLink> </RouterLink>
<template #actions> <button
<a-button type="button"
type="link" class="sms"
:disabled="!person.mobile" :disabled="!person.mobile"
@click="openSms(person)" @click="openSms(person)"
> >
{{ person.mobile ? 'پیامک تبریک' : 'بدون شماره' }} {{ person.mobile ? 'پیامک تبریک' : 'بدون شماره' }}
</a-button> </button>
</template> </li>
</a-list-item> </ul>
</template> </section>
</a-list> </div>
</a-list-item> </UiModal>
</template>
</a-list>
</a-modal>
<SmsComposeModal <SmsComposeModal
nest nest
@@ -161,3 +136,289 @@ onMounted(async () => {
/> />
</section> </section>
</template> </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, FlagFilled,
LeftOutlined, LeftOutlined,
MoreOutlined, MoreOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { import {
Avatar as AAvatar, Avatar as AAvatar,
Button as AButton, Button as AButton,
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, ref } from 'vue'; import { nextTick, ref } from 'vue';
import { PlusOutlined } from '@/icons/ant-bridge'; import { PlusOutlined } from '@ant-design/icons-vue';
import { import {
Button as AButton, Button as AButton,
Card as ACard, Card as ACard,
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, ref } from 'vue'; import { computed, nextTick, ref } from 'vue';
import { HolderOutlined, MoreOutlined } from '@/icons/ant-bridge'; import { HolderOutlined, MoreOutlined } from '@ant-design/icons-vue';
import { import {
Button as AButton, Button as AButton,
Dropdown as ADropdown, Dropdown as ADropdown,
@@ -5,7 +5,7 @@ import {
CheckOutlined, CheckOutlined,
DeleteOutlined, DeleteOutlined,
MoreOutlined, MoreOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { import {
Avatar as AAvatar, Avatar as AAvatar,
Button as AButton, Button as AButton,
@@ -19,7 +19,7 @@ import {
FlagOutlined, FlagOutlined,
MoreOutlined, MoreOutlined,
WarningOutlined, WarningOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
const AMenuItem = AMenu.Item; const AMenuItem = AMenu.Item;
import UserAvatar from '@/components/UserAvatar.vue'; import UserAvatar from '@/components/UserAvatar.vue';
@@ -1,8 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue'; import { computed, nextTick, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { Menu as AMenu } from 'ant-design-vue'; import { Segmented as ASegmented } from 'ant-design-vue';
import type { MenuProps } from 'ant-design-vue';
import { treasurySectionAllowed, type TreasurySectionKey } from '@mento/shared'; import { treasurySectionAllowed, type TreasurySectionKey } from '@mento/shared';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
@@ -14,29 +13,33 @@ const scroller = ref<HTMLElement | null>(null);
const links = computed(() => { const links = computed(() => {
const role = auth.user?.role; const role = auth.user?.role;
const permissions = auth.user?.permissions; const permissions = auth.user?.permissions;
const all: Array<{ to: string; label: string; exact?: boolean; section: TreasurySectionKey }> = [ const all: Array<{ value: string; label: string; exact?: boolean; section: TreasurySectionKey }> = [
{ to: '/finance', label: 'داشبورد', exact: true, section: 'treasury_dashboard' }, { value: '/finance', label: 'داشبورد', exact: true, section: 'treasury_dashboard' },
{ to: '/finance/incomes', label: 'دریافت‌ها و درآمدها', section: 'treasury_incomes' }, { value: '/finance/incomes', label: 'دریافت‌ها و درآمدها', section: 'treasury_incomes' },
{ to: '/finance/expenses', label: 'پرداخت‌ها و هزینه‌ها', section: 'treasury_expenses' }, { value: '/finance/expenses', label: 'پرداخت‌ها و هزینه‌ها', section: 'treasury_expenses' },
{ to: '/finance/receivables', label: 'اقساط و مطالبات', section: 'treasury_receivables' }, { value: '/finance/receivables', label: 'اقساط و مطالبات', section: 'treasury_receivables' },
{ to: '/finance/accounts', label: 'صندوق و حساب‌ها', section: 'treasury_accounts' }, { value: '/finance/accounts', label: 'صندوق و حساب‌ها', section: 'treasury_accounts' },
{ to: '/finance/payroll', label: 'حقوق', section: 'treasury_payroll' }, { value: '/finance/payroll', label: 'حقوق', section: 'treasury_payroll' },
{ to: '/finance/recurring', label: 'تکرارشونده', section: 'treasury_recurring' }, { value: '/finance/recurring', label: 'تکرارشونده', section: 'treasury_recurring' },
{ to: '/finance/reports', label: 'گزارش', section: 'treasury_reports' }, { value: '/finance/reports', label: 'گزارش', section: 'treasury_reports' },
{ to: '/finance/audit', label: 'سوابق', section: 'treasury_audit' }, { value: '/finance/audit', label: 'سوابق', section: 'treasury_audit' },
{ to: '/finance/categories', label: 'دسته‌بندی', section: 'treasury_categories' }, { value: '/finance/categories', label: 'دسته‌بندی', section: 'treasury_categories' },
]; ];
return all.filter((link) => treasurySectionAllowed(role, permissions, link.section)); return all.filter((link) => treasurySectionAllowed(role, permissions, link.section));
}); });
function on(path: string, exact?: boolean) { const options = computed(() => links.value.map((l) => ({ value: l.value, label: l.label })));
if (exact) return route.path === path;
return route.path === path || route.path.startsWith(`${path}/`);
}
const selectedKeys = computed(() => { const active = computed(() => {
const match = links.value.find((link) => on(link.to, link.exact)); const path = route.path;
return match ? [match.to] : []; 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( 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, Select as ASelect,
Space, Space,
Space as ASpace, Space as ASpace,
Spin as ASpin,
Textarea as ATextarea, Textarea as ATextarea,
Typography, Typography,
} from 'ant-design-vue'; } from 'ant-design-vue';
@@ -35,8 +36,7 @@ import {
FileTextOutlined, FileTextOutlined,
PlusOutlined, PlusOutlined,
UserAddOutlined, UserAddOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
import { canAssignToOthers } from '@/lib/assign-access'; import { canAssignToOthers } from '@/lib/assign-access';
@@ -648,8 +648,7 @@ onMounted(load);
<template> <template>
<div dir="rtl"> <div dir="rtl">
<CrmSkeleton :loading="loading"> <a-spin :spinning="loading">
<CrmSkeletonCard :rows="8">
<a-flex <a-flex
v-if="!embedded" v-if="!embedded"
justify="space-between" justify="space-between"
@@ -1090,8 +1089,7 @@ onMounted(load);
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
</CrmSkeletonCard> </a-spin>
</CrmSkeleton>
<a-modal <a-modal
v-model:open="newPersonOpen" v-model:open="newPersonOpen"
+7 -6
View File
@@ -26,6 +26,7 @@ import {
Row as ARow, Row as ARow,
Select as ASelect, Select as ASelect,
Space as ASpace, Space as ASpace,
Spin as ASpin,
Tag as ATag, Tag as ATag,
Textarea as ATextarea, Textarea as ATextarea,
Timeline as ATimeline, Timeline as ATimeline,
@@ -43,8 +44,7 @@ import {
PhoneOutlined, PhoneOutlined,
PlusOutlined, PlusOutlined,
UserAddOutlined, UserAddOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { isBirthDateAnswer, leadNoteFileIsImage, parseLeadFormNotes } from '@/lib/lead-form-notes'; import { isBirthDateAnswer, leadNoteFileIsImage, parseLeadFormNotes } from '@/lib/lead-form-notes';
import { import {
@@ -505,6 +505,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
<a-typography-title :level="3" :style="{ margin: 0 }"> <a-typography-title :level="3" :style="{ margin: 0 }">
{{ lead?.title || 'جزئیات لید' }} {{ lead?.title || 'جزئیات لید' }}
</a-typography-title> </a-typography-title>
<a-typography-text type="secondary">
{{ lead ? `موبایل ${lead.mobile}` : 'در حال بارگذاری…' }}
</a-typography-text>
</div> </div>
</a-space> </a-space>
<a-space v-if="lead" :size="8" wrap> <a-space v-if="lead" :size="8" wrap>
@@ -568,8 +571,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<CrmSkeleton :loading="loading"> <a-spin :spinning="loading">
<CrmSkeletonCard :rows="8">
<template v-if="lead"> <template v-if="lead">
<a-row :gutter="[24, 24]"> <a-row :gutter="[24, 24]">
<a-col :xs="24" :lg="17" :xl="18"> <a-col :xs="24" :lg="17" :xl="18">
@@ -1181,8 +1183,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
@close="smsOpen = false" @close="smsOpen = false"
/> />
</template> </template>
</CrmSkeletonCard> </a-spin>
</CrmSkeleton>
</a-col> </a-col>
</a-row> </a-row>
</template> </template>
+30 -100
View File
@@ -9,7 +9,6 @@ import {
Card as ACard, Card as ACard,
Checkbox as ACheckbox, Checkbox as ACheckbox,
Col as ACol, Col as ACol,
Divider as ADivider,
Dropdown as ADropdown, Dropdown as ADropdown,
Empty as AEmpty, Empty as AEmpty,
Flex as AFlex, Flex as AFlex,
@@ -66,7 +65,6 @@ import TableColumnsMenu from '@/components/TableColumnsMenu.vue';
import JalaliDateInput from '@/components/JalaliDateInput.vue'; import JalaliDateInput from '@/components/JalaliDateInput.vue';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue'; import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import PhoneContactsImport from '@/components/PhoneContactsImport.vue'; import PhoneContactsImport from '@/components/PhoneContactsImport.vue';
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
import { import {
filterPhoneContacts, filterPhoneContacts,
isContactPickerSupported, isContactPickerSupported,
@@ -92,7 +90,6 @@ const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyPa
const { token } = theme.useToken(); const { token } = theme.useToken();
const screens = Grid.useBreakpoint(); const screens = Grid.useBreakpoint();
const isMobile = computed(() => !screens.value.md); const isMobile = computed(() => !screens.value.md);
const emptySimple = AEmpty.PRESENTED_IMAGE_SIMPLE;
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
@@ -1514,20 +1511,6 @@ const tintColor = (tint: StageTint) => {
return map[tint] ?? 'default'; 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 tableColumns = computed<TableColumnsType<LeadDto>>(() => {
const all: TableColumnsType<LeadDto> = [ const all: TableColumnsType<LeadDto> = [
{ {
@@ -1684,9 +1667,9 @@ onBeforeUnmount(() => {
<template #icon><PlusOutlined /></template> <template #icon><PlusOutlined /></template>
{{ isMobile ? 'جدید' : 'لید جدید' }} {{ isMobile ? 'جدید' : 'لید جدید' }}
</a-button> </a-button>
</a-space>
</a-flex> </a-flex>
</a-col> </a-col>
</a-row>
<a-col :span="24" @click.stop> <a-col :span="24" @click.stop>
<a-card :bordered="true"> <a-card :bordered="true">
@@ -1967,79 +1950,17 @@ onBeforeUnmount(() => {
</a-card> </a-card>
</a-col> </a-col>
<a-row :gutter="[12, 12]"> <a-col v-if="selectedIds.length" :span="24" @click.stop>
<a-col :xs="24" :sm="12" :md="8" :lg="5"> <a-card :bordered="false" :style="{ background: token.colorPrimaryBg }">
<a-select <a-space :size="8" wrap>
: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"
allow-clear
placeholder="جستجو در لیدها…"
enter-button="جستجو"
style="width: 100%"
@search="onSearch"
/>
</a-col>
<a-col :xs="12" :sm="8" :md="8" :lg="4">
<a-select
:value="cityFilter || undefined"
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-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> <a-typography-text>
{{ toFaDigits(selectedIds.length) }} مورد انتخاب‌شده {{ toFaDigits(selectedIds.length) }} مورد انتخاب‌شده
</a-typography-text> </a-typography-text>
</a-col>
<a-col :xs="24" :md="18">
<a-flex wrap="wrap" :gap="8" justify="end">
<template v-if="canAssignOthers"> <template v-if="canAssignOthers">
<a-select <a-select
v-model:value="assignUserId" v-model:value="assignUserId"
placeholder="تخصیص به کارشناس" placeholder="تخصیص به کارشناس"
style="min-width: 12rem; flex: 1 1 12rem" style="min-width: 12rem"
allow-clear allow-clear
:options="users.map((u) => ({ value: u.id, label: u.fullName }))" :options="users.map((u) => ({ value: u.id, label: u.fullName }))"
/> />
@@ -2049,27 +1970,41 @@ onBeforeUnmount(() => {
<a-select <a-select
v-model:value="bulkStageId" v-model:value="bulkStageId"
placeholder="تغییر وضعیت" placeholder="تغییر وضعیت"
style="min-width: 12rem; flex: 1 1 12rem" style="min-width: 12rem"
allow-clear allow-clear
:options="stages.map((s) => ({ value: s.id, label: s.name }))" :options="stages.map((s) => ({ value: s.id, label: s.name }))"
/> />
<a-button :disabled="!bulkStageId || busy" @click="bulkStageSelected">اعمال وضعیت</a-button> <a-button :disabled="!bulkStageId || busy" @click="bulkStageSelected">اعمال وضعیت</a-button>
</template> </template>
<a-button danger :disabled="busy" @click="archiveSelected">بایگانی</a-button> <a-button danger :disabled="busy" @click="archiveSelected">بایگانی</a-button>
</a-flex> </a-space>
</a-col>
</a-row>
</a-card> </a-card>
</a-col>
<a-divider :style="{ marginTop: `${token.marginSM}px`, marginBottom: `${token.marginSM}px` }" /> <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-spin :spinning="pageBusy" :tip="busyMessage"> <a-col :span="24">
<CrmSkeleton :loading="loading"> <a-spin :spinning="loading || pageBusy" :tip="pageBusy ? busyMessage : undefined">
<CrmSkeletonTable :rows="8" :columns="9" :card="false">
<template v-if="data?.items.length"> <template v-if="data?.items.length">
<a-row v-if="isMobile" :gutter="[12, 12]"> <a-row v-if="isMobile" :gutter="[12, 12]">
<a-col v-for="(lead, idx) in data.items" :key="`m-${lead.id}`" :span="24"> <a-col v-for="(lead, idx) in data.items" :key="`m-${lead.id}`" :span="24">
<a-card <a-card
:bordered="true"
hoverable hoverable
:style="{ :style="{
borderColor: selected.has(lead.id) ? token.colorPrimary : undefined, borderColor: selected.has(lead.id) ? token.colorPrimary : undefined,
@@ -2176,7 +2111,7 @@ onBeforeUnmount(() => {
:data-source="data.items" :data-source="data.items"
:pagination="false" :pagination="false"
:row-key="(r: LeadDto) => r.id" :row-key="(r: LeadDto) => r.id"
:scroll="screens.xl ? undefined : { x: 960 }" :scroll="{ x: 1100 }"
:custom-row="(record: LeadDto) => ({ onClick: () => goDetail(record.id) })" :custom-row="(record: LeadDto) => ({ onClick: () => goDetail(record.id) })"
> >
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@@ -2280,9 +2215,7 @@ onBeforeUnmount(() => {
<a-empty <a-empty
v-else-if="!loading" v-else-if="!loading"
:image="emptySimple"
description="لیدی ثبت نشده است. از ورود فایل استفاده کنید یا لید جدید بسازید." description="لیدی ثبت نشده است. از ورود فایل استفاده کنید یا لید جدید بسازید."
:style="{ paddingBlock: `${token.paddingXS}px` }"
> >
<a-space :size="8"> <a-space :size="8">
<a-button type="primary" @click="openCreate">ثبت لید جدید</a-button> <a-button type="primary" @click="openCreate">ثبت لید جدید</a-button>
@@ -2302,10 +2235,8 @@ onBeforeUnmount(() => {
</ExcelImportFlow> </ExcelImportFlow>
</a-space> </a-space>
</a-empty> </a-empty>
</CrmSkeletonTable>
</CrmSkeleton>
</a-spin> </a-spin>
</a-card> </a-col>
<a-modal <a-modal
v-model:open="createOpen" v-model:open="createOpen"
@@ -2519,6 +2450,5 @@ onBeforeUnmount(() => {
</a-button> </a-button>
</template> </template>
</a-modal> </a-modal>
</a-flex> </a-row>
</div>
</template> </template>
File diff suppressed because it is too large Load Diff
+7 -10
View File
@@ -20,6 +20,7 @@ import {
Select as ASelect, Select as ASelect,
Space, Space,
Space as ASpace, Space as ASpace,
Spin as ASpin,
Textarea as ATextarea, Textarea as ATextarea,
Typography, Typography,
Upload as AUpload, Upload as AUpload,
@@ -32,8 +33,7 @@ import {
PhoneOutlined, PhoneOutlined,
PlusOutlined, PlusOutlined,
SearchOutlined, SearchOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared'; import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared'; import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared';
@@ -491,9 +491,8 @@ onMounted(load);
</a-space> </a-space>
</a-flex> </a-flex>
<CrmSkeleton :loading="loading"> <a-spin :spinning="loading">
<CrmSkeletonCard :rows="8"> <a-form v-if="!loading" layout="vertical" @finish="submit">
<a-form layout="vertical" @finish="submit">
<a-card :bordered="false"> <a-card :bordered="false">
<a-divider orientation="right">اطلاعات اصلی</a-divider> <a-divider orientation="right">اطلاعات اصلی</a-divider>
<a-row :gutter="[16, 0]"> <a-row :gutter="[16, 0]">
@@ -524,11 +523,10 @@ onMounted(load);
</a-col> </a-col>
<a-col :xs="24" :md="12"> <a-col :xs="24" :md="12">
<a-form-item label="موبایل"> <a-form-item label="موبایل">
<a-space-compact block> <a-space-compact block style="width: 100%">
<a-input v-model:value="mobile" type="tel" /> <a-input v-model:value="mobile" type="tel" style="width: 100%" />
<a-button <a-button
:disabled="pickingContact || saving" :disabled="pickingContact || saving"
:style="{ flex: 'none', display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }"
@click="fillFromPhoneContact" @click="fillFromPhoneContact"
> >
<template #icon><PhoneOutlined /></template> <template #icon><PhoneOutlined /></template>
@@ -729,8 +727,7 @@ onMounted(load);
<a-button v-if="!isNew" danger :disabled="saving" @click="remove">حذف</a-button> <a-button v-if="!isNew" danger :disabled="saving" @click="remove">حذف</a-button>
</a-space> </a-space>
</a-form> </a-form>
</CrmSkeletonCard> </a-spin>
</CrmSkeleton>
<a-upload <a-upload
ref="vcfUploadRef" ref="vcfUploadRef"
File diff suppressed because it is too large Load Diff
+2 -15
View File
@@ -23,7 +23,7 @@ import {
DeleteOutlined, DeleteOutlined,
DownloadOutlined, DownloadOutlined,
UploadOutlined, UploadOutlined,
} from '@/icons/ant-bridge'; } from '@ant-design/icons-vue';
import { import {
Alert as AAlert, Alert as AAlert,
Button as AButton, Button as AButton,
@@ -48,7 +48,6 @@ import {
} from '@mento/shared'; } from '@mento/shared';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
import { canManageSettings } from '@/lib/roles'; import { canManageSettings } from '@/lib/roles';
import { CrmSkeletonCard } from '@/components/skeleton';
import { bindMenuDismiss, cardMenuStyle } from '@/lib/anchored-menu'; import { bindMenuDismiss, cardMenuStyle } from '@/lib/anchored-menu';
const dealExcelFields = DEAL_EXCEL_COLUMNS.filter((c) => c.key !== '_type').map((c) => ({ 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="error" type="error" show-icon :message="error" />
<a-alert v-if="importMsg" type="success" show-icon :message="importMsg" /> <a-alert v-if="importMsg" type="success" show-icon :message="importMsg" />
<a-flex <a-spin v-if="loading && !stages.length" tip="در حال بارگذاری مسیر فروش…" />
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-alert <a-alert
v-if="selectMode" v-if="selectMode"
+137 -236
View File
@@ -8,68 +8,27 @@ import axios from 'axios';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { formatClockFa, formatJalaliNumeric, toFaDigits } from '@/lib/jalali'; import { formatClockFa, formatJalaliNumeric, toFaDigits } from '@/lib/jalali';
import { currencySuffix, formatMoney } from '@/lib/money'; import { currencySuffix, formatMoney } from '@/lib/money';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import { import {
Alert as AAlert, UiBadge,
Avatar as AAvatar, UiBusyOverlay,
Button as AButton, UiButton,
Card as ACard, UiDropdownMenu,
Col as ACol, UiEmptyState,
Divider as ADivider, UiInput,
Dropdown as ADropdown, UiModal,
Empty as AEmpty, UiPageHeader,
Flex as AFlex, UiPagination,
Form as AForm, UiSelect,
FormItem as AFormItem, } from '@/components/ui';
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';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue'; import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
import UiIcon from '@/components/UiIcon.vue';
import ProductFormView from '@/views/ProductFormView.vue'; import ProductFormView from '@/views/ProductFormView.vue';
import { CrmSkeleton, CrmSkeletonTable } from '@/components/skeleton';
import type { ImportContactsResult, ProductDto } from '@mento/shared'; import type { ImportContactsResult, ProductDto } from '@mento/shared';
import { brand } from '@mento/shared'; import { brand } from '@mento/shared';
type SortKey = 'name' | 'newest' | 'price'; type SortKey = 'name' | 'newest' | 'price';
type StatusFilter = 'all' | 'active' | 'inactive'; 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 pageSize = usePageSize('products', 10);
const router = useRouter(); const router = useRouter();
@@ -83,6 +42,7 @@ const sort = ref<SortKey>('name');
const page = ref(1); const page = ref(1);
const selected = ref<Set<string>>(new Set()); const selected = ref<Set<string>>(new Set());
const menuId = ref<string | null>(null); const menuId = ref<string | null>(null);
const sortOpen = ref(false);
const moreOpen = ref(false); const moreOpen = ref(false);
const productModal = ref(false); const productModal = ref(false);
const busy = ref(false); const busy = ref(false);
@@ -98,23 +58,6 @@ const categories = computed(() => {
return Array.from(set).sort((a, b) => a.localeCompare(b, 'fa')); 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(() => { const filtered = computed(() => {
let list = [...products.value]; let list = [...products.value];
if (q.value.trim()) { if (q.value.trim()) {
@@ -148,53 +91,6 @@ const allPageSelected = computed(
pageItems.value.every((p) => selected.value.has(p.id)), 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], () => { watch([q, category, statusFilter, sort], () => {
page.value = 1; page.value = 1;
closeMenus(); closeMenus();
@@ -202,6 +98,7 @@ watch([q, category, statusFilter, sort], () => {
function closeMenus() { function closeMenus() {
menuId.value = null; menuId.value = null;
sortOpen.value = false;
moreOpen.value = false; moreOpen.value = false;
} }
@@ -222,27 +119,6 @@ function toggleSelect(id: string) {
selected.value = next; 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) { function formatPrice(value: number | null, currency: string) {
if (value == null) return '—'; if (value == null) return '—';
return formatMoney(value, currency); return formatMoney(value, currency);
@@ -349,49 +225,22 @@ async function toggleActive(product: ProductDto) {
await load(); await load();
} }
function removeProduct(product: ProductDto) { async function removeProduct(product: ProductDto) {
closeMenus(); closeMenus();
Modal.confirm({ if (!confirm(`محصول «${product.name}» حذف شود؟`)) return;
title: `محصول «${product.name}» حذف شود؟`,
okText: 'حذف',
cancelText: 'انصراف',
okButtonProps: { danger: true },
onOk: async () => {
await api.delete(`/products/${product.id}`); await api.delete(`/products/${product.id}`);
selected.value.delete(product.id); selected.value.delete(product.id);
await load(); await load();
},
});
} }
function removeSelected() { async function removeSelected() {
closeMenus(); closeMenus();
const ids = Array.from(selected.value); const ids = Array.from(selected.value);
if (!ids.length) return; if (!ids.length) return;
Modal.confirm({ if (!confirm(`${toFaDigits(ids.length)} محصول انتخاب‌شده حذف شوند؟`)) return;
title: `${toFaDigits(ids.length)} محصول انتخاب‌شده حذف شوند؟`,
okText: 'حذف',
cancelText: 'انصراف',
okButtonProps: { danger: true },
onOk: async () => {
await Promise.all(ids.map((id) => api.delete(`/products/${id}`))); await Promise.all(ids.map((id) => api.delete(`/products/${id}`)));
selected.value = new Set(); selected.value = new Set();
await load(); 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) { function goEdit(id: string) {
@@ -403,17 +252,16 @@ onMounted(load);
</script> </script>
<template> <template>
<div @click="closeMenus"> <section class="crm-page" @click="closeMenus">
<a-flex vertical :gap="16"> <UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<a-flex justify="space-between" align="center" wrap="wrap" :gap="12"> <UiPageHeader
<div> title="محصولات"
<a-typography-title :level="3" :style="{ margin: 0 }">محصولات</a-typography-title> lead="مدیریت محصولات، قیمت‌ها و موجودی"
</div> >
<a-space :size="8" wrap @click.stop> <template #actions>
<a-button :disabled="busy" :loading="pageBusy" @click="exportExcel"> <UiButton variant="ghost" type="button" :disabled="busy" :loading="pageBusy" @click="exportExcel">
<template #icon><DownloadOutlined /></template>
خروجی اکسل خروجی اکسل
</a-button> </UiButton>
<ExcelImportFlow <ExcelImportFlow
preview-path="/products/import/preview" preview-path="/products/import/preview"
import-path="/products/import" import-path="/products/import"
@@ -423,62 +271,111 @@ onMounted(load);
@fail="onImportFail" @fail="onImportFail"
@settled="onImportSettled" @settled="onImportSettled"
> >
<template #default="{ loading: importLoading }"> <template #default="{ loading }">
<a-button :disabled="busy" :loading="importLoading"> <UiButton variant="ghost" type="button" :disabled="busy" :loading="loading">ورود از اکسل</UiButton>
<template #icon><UploadOutlined /></template>
ورود از اکسل
</a-button>
</template> </template>
</ExcelImportFlow> </ExcelImportFlow>
<a-button type="primary" @click="productModal = true"> <UiButton variant="primary" @click="productModal = true">
<template #icon><PlusOutlined /></template> <UiIcon name="plus" :size="16" />
محصول جدید محصول جدید
</a-button> </UiButton>
<a-dropdown v-model:open="moreOpen" trigger="click"> <UiDropdownMenu v-model:open="moreOpen" align="end">
<a-button aria-label="عملیات بیشتر"> <template #trigger="{ toggle }">
<template #icon><MoreOutlined /></template> <UiButton
</a-button> variant="ghost"
<template #overlay> size="md"
<a-menu @click="onMoreMenu"> aria-label="عملیات بیشتر"
<a-menu-item key="remove-selected" :disabled="!selected.size"> @click.stop="toggle"
حذف انتخاب‌شده‌ها >
</a-menu-item> <UiIcon name="dots" :size="18" />
<a-menu-item key="reload">بروزرسانی لیست</a-menu-item> </UiButton>
</a-menu>
</template> </template>
</a-dropdown> <button type="button" :disabled="!selected.size" @click="removeSelected">
</a-space> حذف انتخاب‌شده‌ها
</a-flex> </button>
<button type="button" @click="load">بروزرسانی لیست</button>
</UiDropdownMenu>
</template>
</UiPageHeader>
<a-card :bordered="false"> <div class="crm-toolbar" @click.stop>
<a-form layout="vertical" @click.stop> <div class="search-box">
<a-row :gutter="[16, 0]"> <UiInput
<a-col :xs="24" :md="12" :lg="9"> v-model="q"
<a-form-item label="جستجو"> type="search"
<a-input
v-model:value="q"
allow-clear
placeholder="جستجو در نام، کد یا توضیحات..." placeholder="جستجو در نام، کد یا توضیحات..."
> >
<template #prefix><SearchOutlined /></template> <template #prefix>
</a-input> <UiIcon name="search" :size="16" />
</a-form-item> </template>
</a-col> </UiInput>
<a-col :xs="24" :sm="12" :md="8" :lg="5"> </div>
<a-form-item label="دسته‌بندی"> <UiSelect v-model="category">
<a-select <option value="">همه دسته‌بندی‌ها</option>
v-model:value="category" <option v-for="c in categories" :key="c" :value="c">{{ c }}</option>
:options="categoryOptions" </UiSelect>
style="width: 100%" <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> </th>
</a-col> <th class="num-col">#</th>
<a-col :xs="24" :sm="12" :md="8" :lg="5"> <th>نام محصول</th>
<a-form-item label="وضعیت"> <th>کد</th>
<a-select <th>دسته‌بندی</th>
v-model:value="statusFilter" <th>قیمت</th>
:options="statusOptions" <th>موجودی</th>
style="width: 100%" <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>
<td class="num-col">{{ toFaDigits((page - 1) * pageSize + idx + 1) }}</td> <td class="num-col">{{ toFaDigits((page - 1) * pageSize + idx + 1) }}</td>
@@ -596,21 +493,25 @@ onMounted(load);
/> />
</div> </div>
<a-modal <UiPagination
v-model:open="productModal" v-if="filtered.length"
title="محصول جدید" v-model:page="page"
:footer="null" :total-items="filtered.length"
width="960px" :page-size="pageSize"
destroy-on-close :page-size-options="PAGE_SIZE_OPTIONS"
> @update:page-size="pageSize = $event; page = 1"
/>
</template>
<UiModal :open="productModal" title="محصول جدید" @close="productModal = false">
<ProductFormView <ProductFormView
v-if="productModal" v-if="productModal"
embedded embedded
@saved="productModal = false; void load()" @saved="productModal = false; void load()"
@cancel="productModal = false" @cancel="productModal = false"
/> />
</a-modal> </UiModal>
</div> </section>
</template> </template>
<style scoped> <style scoped>
+184 -158
View File
@@ -18,28 +18,11 @@ import {
updateDealStage, updateDealStage,
} from '@/lib/pipeline-board'; } from '@/lib/pipeline-board';
import ExcelImportFlow from '@/components/ExcelImportFlow.vue'; 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 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 { import type {
ImportContactsResult, ImportContactsResult,
ProjectBoardBoardDto, ProjectBoardBoardDto,
@@ -48,26 +31,8 @@ import type {
import { brand } from '@mento/shared'; import { brand } from '@mento/shared';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
import { canManageSettings } from '@/lib/roles'; import { canManageSettings } from '@/lib/roles';
import { CrmSkeletonCard } from '@/components/skeleton';
import { bindMenuDismiss, cardMenuStyle } from '@/lib/anchored-menu'; 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 route = useRoute();
const router = useRouter(); const router = useRouter();
const auth = useAuthStore(); const auth = useAuthStore();
@@ -85,6 +50,7 @@ const mineOnly = ref(route.query.mine === '1');
const showCreate = ref(false); const showCreate = ref(false);
const newName = ref(''); const newName = ref('');
const cardModal = ref<{ cardId?: string; stageId?: string } | null>(null); const cardModal = ref<{ cardId?: string; stageId?: string } | null>(null);
const deleteStageId = ref<string | null>(null);
const stageBusy = ref(false); const stageBusy = ref(false);
const busy = ref(false); const busy = ref(false);
const importMsg = ref(''); const importMsg = ref('');
@@ -399,28 +365,28 @@ async function onAddStage(name: string) {
} }
function onDeleteStage(stageId: string) { function onDeleteStage(stageId: string) {
const title = stages.value.find((s) => s.id === stageId)?.title ?? ''; deleteStageId.value = stageId;
Modal.confirm({ }
title: 'حذف ستون',
content: `ستون «${title}» حذف شود؟ اگر کارتی داخل آن باشد باید اول آن‌ها را جابه‌جا کنید.`, const deleteStageTitle = computed(() => {
okText: 'حذف', const id = deleteStageId.value;
cancelText: 'انصراف', return stages.value.find((s) => s.id === id)?.title ?? '';
okButtonProps: { danger: true }, });
async onOk() {
if (!currentBoardId.value || stageBusy.value) return; async function confirmDeleteStage() {
const stageId = deleteStageId.value;
if (!stageId || !currentBoardId.value || stageBusy.value) return;
stageBusy.value = true; stageBusy.value = true;
error.value = ''; error.value = '';
try { try {
await api.delete(`/project-boards/${currentBoardId.value}/stages/${stageId}`); await api.delete(`/project-boards/${currentBoardId.value}/stages/${stageId}`);
deleteStageId.value = null;
await load(); await load();
} catch (e) { } catch (e) {
error.value = apiMessage(e, 'حذف ستون ناموفق بود.'); error.value = apiMessage(e, 'حذف ستون ناموفق بود.');
throw e;
} finally { } finally {
stageBusy.value = false; stageBusy.value = false;
} }
},
});
} }
async function onCardSaved() { 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( const unbindMenuDismiss = bindMenuDismiss(
() => menuOpenId.value != null, () => menuOpenId.value != null,
() => (menuOpenId.value = null), () => (menuOpenId.value = null),
@@ -547,9 +497,8 @@ onBeforeUnmount(() => {
</script> </script>
<template> <template>
<div class="project-board-page" dir="rtl" :style="pageStyle"> <section class="page" dir="rtl">
<a-row :gutter="[GAP, GAP]" :style="{ flexShrink: 0 }"> <UiBusyOverlay :open="pageBusy" :message="busyMessage" />
<a-col :span="24">
<PipelineToolbar <PipelineToolbar
pipeline-name="تابلوی پروژه — کارهای تیمی" pipeline-name="تابلوی پروژه — کارهای تیمی"
icon="grid" icon="grid"
@@ -563,12 +512,13 @@ onBeforeUnmount(() => {
@create="showCreate = true" @create="showCreate = true"
> >
<template #excel> <template #excel>
<a-space> <label class="mine-toggle">
<a-checkbox v-model:checked="mineOnly">فقط کارهای من</a-checkbox> <input v-model="mineOnly" type="checkbox" />
<a-button :disabled="loading || busy" @click="exportExcel"> <span>فقط کارهای من</span>
<template #icon><DownloadOutlined /></template> </label>
<button class="btn-ghost-sm" type="button" :disabled="loading || busy" @click="exportExcel">
خروجی اکسل خروجی اکسل
</a-button> </button>
<ExcelImportFlow <ExcelImportFlow
preview-path="/project-cards/import/preview" preview-path="/project-cards/import/preview"
import-path="/project-cards/import" import-path="/project-cards/import"
@@ -578,53 +528,16 @@ onBeforeUnmount(() => {
@fail="onImportFail" @fail="onImportFail"
@settled="onImportSettled" @settled="onImportSettled"
> >
<a-button :disabled="loading || busy"> <button class="btn-ghost-sm" type="button" :disabled="loading || busy">
<template #icon><UploadOutlined /></template>
ورود از اکسل ورود از اکسل
</a-button> </button>
</ExcelImportFlow> </ExcelImportFlow>
</a-space>
</template> </template>
</PipelineToolbar> </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 <p v-if="error" class="error">{{ error }}</p>
:style="{ <p v-if="importMsg" class="ok">{{ importMsg }}</p>
position: 'relative', <p v-else-if="loading && !stages.length" class="muted">در حال بارگذاری تابلو…</p>
flex: '1 1 auto',
minHeight: 0,
display: 'flex',
flexDirection: 'column',
}"
>
<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>
<PipelineList <PipelineList
v-if="viewMode === 'list' && (!loading || stages.length)" v-if="viewMode === 'list' && (!loading || stages.length)"
@@ -655,7 +568,6 @@ onBeforeUnmount(() => {
@column-drag-end="onColumnDragEnd" @column-drag-end="onColumnDragEnd"
@add-stage="onAddStage" @add-stage="onAddStage"
/> />
</div>
<Teleport to="body"> <Teleport to="body">
<DealCardOverlay <DealCardOverlay
@@ -669,55 +581,79 @@ onBeforeUnmount(() => {
</Teleport> </Teleport>
<Teleport to="body"> <Teleport to="body">
<div <div v-if="menuOpenId" class="menu-pop" role="menu" :style="menuStyle ?? undefined">
v-if="menuOpenId" <button type="button" role="menuitem" @click="onOpenCard(menuOpenId)">
class="menu-pop" مشاهده کارت
:style="{ </button>
position: 'fixed', <button
zIndex: 1080, type="button"
...(menuStyle ?? {}), role="menuitem"
}" @click="cardModal = { cardId: menuOpenId ?? undefined }; menuOpenId = null"
> >
<a-menu ویرایش
:style="{ minWidth: '160px', boxShadow: token.boxShadowSecondary }" </button>
@click="onCardMenuClick" <button type="button" role="menuitem" @click="menuOpenId = null">بستن</button>
>
<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>
</div> </div>
</Teleport> </Teleport>
<a-modal <UiModal
:open="showCreate && canCreateBoard" :open="showCreate && canCreateBoard"
title="تابلوی جدید" title="تابلوی جدید"
:confirm-loading="saving" @close="showCreate = false"
ok-text="ساخت"
cancel-text="انصراف"
:ok-button-props="{ disabled: newName.trim().length < 2 }"
destroy-on-close
@ok="createBoard"
@cancel="showCreate = false"
> >
<a-form layout="vertical" @finish="createBoard"> <form class="create-form" @submit.prevent="createBoard">
<a-form-item label="نام تابلو" required> <label class="field">
<a-input <span>نام تابلو</span>
v-model:value="newName" <UiInput
v-model="newName"
placeholder="نام تابلوی جدید…" placeholder="نام تابلوی جدید…"
:maxlength="120" :maxlength="120"
required
:minlength="2"
/> />
</a-form-item> </label>
</a-form> </form>
</a-modal> <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)" :open="Boolean(cardModal)"
:title="cardModal?.cardId ? 'ویرایش کارت' : 'کارت جدید'" :title="cardModal?.cardId ? 'ویرایش کارت' : 'کارت جدید'"
:footer="null" @close="cardModal = null"
destroy-on-close
width="720px"
@cancel="cardModal = null"
> >
<ProjectCardFormView <ProjectCardFormView
v-if="cardModal" v-if="cardModal"
@@ -728,13 +664,103 @@ onBeforeUnmount(() => {
@saved="onCardSaved" @saved="onCardSaved"
@cancel="cardModal = null" @cancel="cardModal = null"
/> />
</a-modal> </UiModal>
</div> </section>
</template> </template>
<style scoped> <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; 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> </style>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+20 -56
View File
@@ -9,43 +9,16 @@ import type {
VoipCallLogDto, VoipCallLogDto,
VoipConnectionDto, VoipConnectionDto,
} from '@mento/shared'; } from '@mento/shared';
import { formatJalaliNumeric, rewriteGregorianDates, toFaDigits } from '@/lib/jalali';
import { registerTableColumns, useTableColumns } from '@/lib/tableColumns';
import { import {
Alert as AAlert, UiButton,
Button as AButton, UiCard,
Card as ACard, UiEmptyState,
Col as ACol, UiField,
Empty as AEmpty, UiInput,
Flex as AFlex, UiPageHeader,
Form as AForm, } from '@/components/ui';
FormItem as AFormItem, import UiIcon from '@/components/UiIcon.vue';
Input as AInput, import { formatJalaliNumeric, rewriteGregorianDates, toFaDigits } from '@/lib/jalali';
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');
type TabKey = 'generic' | 'daftareshoma'; type TabKey = 'generic' | 'daftareshoma';
@@ -124,19 +97,6 @@ const summaryLabel: Record<string, string> = {
skipped: 'رد شده', 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 { function noteLink(c: VoipCallLogDto): string | null {
if (!c.summaryNoteId) return null; if (!c.summaryNoteId) return null;
if (c.personId) return `/contacts/people/${c.personId}`; if (c.personId) return `/contacts/people/${c.personId}`;
@@ -307,14 +267,18 @@ onMounted(async () => {
</script> </script>
<template> <template>
<a-flex vertical :gap="16"> <div class="page">
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="12"> <UiPageHeader
<a-typography-title :level="3" :style="{ margin: 0 }">تلفن سازمانی</a-typography-title> title="تلفن سازمانی"
<a-button :disabled="loading" @click="load"> description="ثبت خودکار تماس، خلاصه گفتگو و اعلان تماس ورودی"
<template #icon><ReloadOutlined /></template> >
<template #actions>
<UiButton variant="secondary" :disabled="loading" @click="load">
<UiIcon name="refresh" />
بروزرسانی بروزرسانی
</a-button> </UiButton>
</a-flex> </template>
</UiPageHeader>
<nav class="tabs" aria-label="نوع اتصال تلفن"> <nav class="tabs" aria-label="نوع اتصال تلفن">
<button <button
+306 -277
View File
@@ -1,41 +1,26 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, inject, onMounted, reactive, ref, watch } from 'vue'; import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
import { RouterLink, useRoute, useRouter } from 'vue-router'; import { 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 type { ActivityPriority, RoutineDto, RoutineEntityLink, SaveRoutineRequest } from '@mento/shared'; import type { ActivityPriority, RoutineDto, RoutineEntityLink, SaveRoutineRequest } from '@mento/shared';
import { ROUTINE_ENTITY_LINK_LABELS, ROUTINE_WEEKDAY_LABELS } 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 JalaliDateInput from '@/components/JalaliDateInput.vue';
import RecurrencePicker, { type RecurrenceValue } from '@/components/routines/RecurrencePicker.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 { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { useActivityPriorities } from '@/lib/activity-priorities'; import { useActivityPriorities } from '@/lib/activity-priorities';
import { ROUTINES_CTX, apiError, formatDayNumeric, todayKey } from '@/lib/routines'; import { ROUTINES_CTX, apiError, formatDayNumeric, todayKey } from '@/lib/routines';
import { useAuthStore } from '@/stores/auth'; import { useAuthStore } from '@/stores/auth';
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
Typography;
const shell = inject(ROUTINES_CTX)!; const shell = inject(ROUTINES_CTX)!;
const auth = useAuthStore(); const auth = useAuthStore();
const route = useRoute(); 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 id = computed(() => (typeof route.params.id === 'string' ? route.params.id : null));
const isEdit = computed(() => !!id.value); const isEdit = computed(() => !!id.value);
const pageTitle = computed(() => (isEdit.value ? 'ویرایش روتین' : 'روتین جدید'));
const form = reactive({ const form = reactive({
title: '', title: '',
@@ -57,7 +41,7 @@ const form = reactive({
categoryId: '', categoryId: '',
priority: 'medium' as ActivityPriority, priority: 'medium' as ActivityPriority,
timeOfDay: '09:00', timeOfDay: '09:00',
durationMinutes: null as number | null, durationMinutes: '' as string | number,
startDate: todayKey(), startDate: todayKey(),
endDate: '', endDate: '',
isMandatory: true, isMandatory: true,
@@ -96,24 +80,6 @@ const priorities = computed(() =>
activityPriorities.items.value.map((r) => [r.key, r.label] as [ActivityPriority, string]), 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 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 = [ const reminderOptions = [
{ value: '', label: 'طبق تنظیمات هر کاربر' }, { value: '', label: 'طبق تنظیمات هر کاربر' },
{ value: '0', label: 'سر ساعت' }, { value: '0', label: 'سر ساعت' },
@@ -134,7 +100,7 @@ function fill(r: RoutineDto) {
categoryId: r.category?.id ?? '', categoryId: r.category?.id ?? '',
priority: r.priority, priority: r.priority,
timeOfDay: r.timeOfDay, timeOfDay: r.timeOfDay,
durationMinutes: r.durationMinutes ?? null, durationMinutes: r.durationMinutes ?? '',
startDate: r.startDate, startDate: r.startDate,
endDate: r.endDate ?? '', endDate: r.endDate ?? '',
isMandatory: r.isMandatory, isMandatory: r.isMandatory,
@@ -302,247 +268,310 @@ async function save() {
</script> </script>
<template> <template>
<a-flex vertical :gap="16"> <div class="rform">
<a-flex vertical :gap="4"> <UiPageHeader
<a-breadcrumb> :title="isEdit ? 'ویرایش روتین' : 'روتین جدید'"
<a-breadcrumb-item> lead="کاری که باید به‌صورت منظم انجام شود؛ هر روزِ تکرار، یک کار برای مسئول ساخته می‌شود."
<RouterLink :to="backTo">{{ isManager ? 'مدیریت روتین‌ها' : 'روتین‌های من' }}</RouterLink> :back-to="backTo"
</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>
<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"> <form v-else class="grid" @submit.prevent="save">
<CrmSkeletonCard :rows="8"> <div class="col">
<a-form layout="vertical" @finish="save"> <UiCard>
<a-row :gutter="[16, 16]"> <h3 class="sec-title">اطلاعات پایه</h3>
<a-col :xs="24" :lg="16"> <div class="fields">
<a-flex vertical :gap="16"> <UiField label="عنوان" required>
<a-card :bordered="false" title="اطلاعات پایه"> <UiInput v-model="form.title" placeholder="مثلاً: تماس با لیدهای جدید" :maxlength="200" />
<a-row :gutter="[16, 0]"> </UiField>
<a-col :span="24"> <UiField label="توضیحات">
<a-form-item label="عنوان" required> <UiTextarea v-model="form.description" :rows="3" placeholder="جزئیات یا دستورالعمل انجام کار" />
<a-input </UiField>
v-model:value="form.title" <div class="grid-2">
placeholder="مثلاً: تماس با لیدهای جدید" <UiField label="دسته‌بندی">
:maxlength="200" <UiSelect v-model="form.categoryId">
/> <option value="">بدون دسته</option>
</a-form-item> <option v-for="c in categories" :key="c.id" :value="c.id">{{ c.name }}</option>
</a-col> </UiSelect>
<a-col :span="24"> </UiField>
<a-form-item label="توضیحات"> <UiField label="اولویت">
<a-textarea <UiSelect v-model="form.priority">
v-model:value="form.description" <option v-for="[k, label] in priorities" :key="k" :value="k">{{ label }}</option>
:rows="3" </UiSelect>
placeholder="جزئیات یا دستورالعمل انجام کار" </UiField>
/> </div>
</a-form-item> </div>
</a-col> </UiCard>
<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>
<a-card :bordered="false" title="مسئول"> <UiCard>
<a-typography-text v-if="!isManager" type="secondary"> <h3 class="sec-title">مسئول</h3>
این روتین فقط برای خودتان ساخته می‌شود. <p v-if="!isManager" class="self-note">این روتین فقط برای خودتان ساخته می‌شود.</p>
</a-typography-text> <div v-else class="fields">
<template v-else> <UiSegmented v-model="form.target" :options="targetOptions" />
<a-form-item> <UiField v-if="form.target === 'user'" label="کاربر" required>
<a-radio-group v-model:value="form.target" button-style="solid"> <UiSelect v-model="form.assigneeId">
<a-radio-button value="user">یک کاربر</a-radio-button> <option value="" disabled>انتخاب کنید</option>
<a-radio-button value="team">همه اعضای یک تیم</a-radio-button> <option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
</a-radio-group> </UiSelect>
</a-form-item> </UiField>
<a-form-item v-if="form.target === 'user'" label="کاربر" required> <UiField v-else label="تیم" required hint="برای هر عضو فعال تیم یک کار جداگانه ساخته می‌شود.">
<a-select <UiSelect v-model="form.teamId">
v-model:value="form.assigneeId" <option value="" disabled>انتخاب کنید</option>
:options="userOptions" <option v-for="t in teams" :key="t.id" :value="t.id">{{ t.name }}</option>
placeholder="انتخاب کنید" </UiSelect>
show-search </UiField>
option-filter-prop="label" </div>
style="width: 100%" </UiCard>
/>
</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>
<a-card :bordered="false" title="زمان‌بندی و تکرار"> <UiCard>
<a-row :gutter="[16, 0]"> <h3 class="sec-title">زمان‌بندی و تکرار</h3>
<a-col :xs="24" :md="12"> <div class="fields">
<a-form-item label="ساعت انجام" required> <div class="grid-2">
<UiField label="ساعت انجام" required>
<JalaliDateInput v-model="form.timeOfDay" mode="time" :clearable="false" /> <JalaliDateInput v-model="form.timeOfDay" mode="time" :clearable="false" />
</a-form-item> </UiField>
</a-col> <UiField label="مدت تقریبی (دقیقه)">
<a-col :xs="24" :md="12"> <UiInput v-model="form.durationMinutes" type="number" placeholder="اختیاری" />
<a-form-item label="مدت تقریبی (دقیقه)"> </UiField>
<a-input-number <UiField label="تاریخ شروع" required>
: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" /> <JalaliDateInput v-model="form.startDate" mode="date" :clearable="false" />
</a-form-item> </UiField>
</a-col> <UiField label="تاریخ پایان" hint="خالی = بدون پایان">
<a-col :xs="24" :md="12">
<a-form-item label="تاریخ پایان" extra="خالی = بدون پایان">
<JalaliDateInput v-model="form.endDate" mode="date" /> <JalaliDateInput v-model="form.endDate" mode="date" />
</a-form-item> </UiField>
</a-col> </div>
<a-col :span="24"> <UiField label="الگوی تکرار" required>
<a-form-item label="الگوی تکرار" required>
<RecurrencePicker v-model="recurrence" /> <RecurrencePicker v-model="recurrence" />
</a-form-item> </UiField>
</a-col> </div>
</a-row> </UiCard>
</a-card> </div>
</a-flex>
</a-col>
<a-col :xs="24" :lg="8"> <div class="col side">
<a-flex vertical :gap="16"> <UiCard>
<a-card :bordered="false" title="قوانین انجام"> <h3 class="sec-title">قوانین انجام</h3>
<a-flex vertical :gap="12"> <div class="toggles">
<a-checkbox v-model:checked="form.isMandatory"> <label class="tg">
<a-flex vertical :gap="0"> <input v-model="form.isMandatory" type="checkbox" />
<a-typography-text>اجباری</a-typography-text> <span>
<a-typography-text type="secondary"> <strong>اجباری</strong>
در امتیاز روزانه و روزهای پیاپی کامل حساب می‌شود. <small>در امتیاز روزانه و روزهای پیاپی کامل حساب می‌شود.</small>
</a-typography-text> </span>
</a-flex> </label>
</a-checkbox> <label class="tg">
<a-checkbox v-model:checked="form.allowSkip"> <input v-model="form.allowSkip" type="checkbox" />
<a-flex vertical :gap="0"> <span>
<a-typography-text>امکان رد کردن</a-typography-text> <strong>امکان رد کردن</strong>
<a-typography-text type="secondary"> <small>کاربر می‌تواند این کار را برای یک روز رد کند.</small>
کاربر می‌تواند این کار را برای یک روز رد کند. </span>
</a-typography-text> </label>
</a-flex> <label v-if="form.allowSkip" class="tg nested">
</a-checkbox> <input v-model="form.skipReasonRequired" type="checkbox" />
<a-checkbox <span><strong>ثبت دلیل رد کردن الزامی باشد</strong></span>
v-if="form.allowSkip" </label>
v-model:checked="form.skipReasonRequired" <label class="tg">
:style="{ marginInlineStart: '24px' }" <input v-model="form.reportRequired" type="checkbox" />
> <span>
<a-typography-text>ثبت دلیل رد کردن الزامی باشد</a-typography-text> <strong>گزارش نتیجه الزامی</strong>
</a-checkbox> <small>قبل از انجام‌شدن، کاربر باید نتیجه را بنویسد.</small>
<a-checkbox v-model:checked="form.reportRequired"> </span>
<a-flex vertical :gap="0"> </label>
<a-typography-text>گزارش نتیجه الزامی</a-typography-text> <label class="tg">
<a-typography-text type="secondary"> <input v-model="form.allowAfterDeadline" type="checkbox" />
قبل از انجام‌شدن، کاربر باید نتیجه را بنویسد. <span>
</a-typography-text> <strong>انجام بعد از مهلت مجاز باشد</strong>
</a-flex> <small>اگر خاموش باشد، کار عقب‌افتاده فقط توسط مدیر بسته می‌شود.</small>
</a-checkbox> </span>
<a-checkbox v-model:checked="form.allowAfterDeadline"> </label>
<a-flex vertical :gap="0"> <label class="tg">
<a-typography-text>انجام بعد از مهلت مجاز باشد</a-typography-text> <input v-model="form.carryOverOverdue" type="checkbox" />
<a-typography-text type="secondary"> <span>
اگر خاموش باشد، کار عقب‌افتاده فقط توسط مدیر بسته می‌شود. <strong>انتقال به روز بعد</strong>
</a-typography-text> <small>کار انجام‌نشده در فهرست «کارهای امروز» روز بعد هم نمایش داده می‌شود.</small>
</a-flex> </span>
</a-checkbox> </label>
<a-checkbox v-model:checked="form.carryOverOverdue"> </div>
<a-flex vertical :gap="0"> <UiField label="اتصال به پرونده" class="mt">
<a-typography-text>انتقال به روز بعد</a-typography-text> <UiSelect v-model="form.entityLink">
<a-typography-text type="secondary"> <option v-for="[k, label] in entityLinks" :key="k" :value="k">{{ label }}</option>
کار انجام‌نشده در فهرست «کارهای امروز» روز بعد هم نمایش داده می‌شود. </UiSelect>
</a-typography-text> </UiField>
</a-flex> </UiCard>
</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>
<a-card :bordered="false" title="یادآوری و وضعیت"> <UiCard>
<a-form-item label="یادآوری"> <h3 class="sec-title">یادآوری و وضعیت</h3>
<a-select <div class="fields">
v-model:value="form.reminderMinutesBefore" <UiField label="یادآوری">
:options="reminderOptions" <UiSelect v-model="form.reminderMinutesBefore">
style="width: 100%" <option v-for="o in reminderOptions" :key="o.value" :value="o.value">{{ o.label }}</option>
/> </UiSelect>
</a-form-item> </UiField>
<a-checkbox v-model:checked="form.isActive"> <label class="tg">
<a-typography-text>روتین فعال است</a-typography-text> <input v-model="form.isActive" type="checkbox" />
</a-checkbox> <span><strong>روتین فعال است</strong></span>
</a-card> </label>
</div>
</UiCard>
<a-alert type="info" show-icon> <div class="summary">
<template #message>خلاصه</template> <span>خلاصه</span>
<template #description> <p>{{ summary }}</p>
<a-typography-paragraph :style="{ marginBottom: 0 }"> </div>
{{ summary }}
</a-typography-paragraph> <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> </template>
</a-alert>
<a-alert v-if="error" type="error" show-icon :message="error" /> <style scoped>
.rform {
display: grid;
gap: var(--sp-4);
}
<a-space direction="vertical" style="width: 100%"> .state {
<a-button type="primary" html-type="submit" block :loading="saving"> padding: var(--sp-8);
{{ isEdit ? 'ذخیره تغییرات' : 'ایجاد روتین' }} text-align: center;
</a-button> color: var(--muted);
<a-button block :disabled="saving" @click="router.push(backTo)"> }
انصراف
</a-button> .grid {
</a-space> display: grid;
</a-flex> grid-template-columns: minmax(0, 1fr) 360px;
</a-col> gap: var(--sp-4);
</a-row> align-items: start;
</a-form> }
</CrmSkeletonCard>
</CrmSkeleton> .col {
</a-flex> display: grid;
</template> 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>
+180 -73
View File
@@ -2,8 +2,10 @@
import { computed, inject, onMounted, ref, watch } from 'vue'; import { computed, inject, onMounted, ref, watch } from 'vue';
import { RouterLink } from 'vue-router'; import { RouterLink } from 'vue-router';
import type { RoutineDto } from '@mento/shared'; 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 { api } from '@/lib/api';
import { useAuthStore } from '@/stores/auth';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { useActivityPriorities } from '@/lib/activity-priorities'; import { useActivityPriorities } from '@/lib/activity-priorities';
import { import {
@@ -14,27 +16,6 @@ import {
formatPercent, formatPercent,
percentTone, percentTone,
} from '@/lib/routines'; } 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 shell = inject(ROUTINES_CTX)!;
const activityPriorities = useActivityPriorities(); const activityPriorities = useActivityPriorities();
@@ -68,62 +49,23 @@ const filtered = computed(() => {
if (!term) return items.value; if (!term) return items.value;
return items.value.filter((r) => r.title.includes(term) || (r.description ?? '').includes(term)); 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> </script>
<template> <template>
<a-card :bordered="false"> <div class="rlist">
<a-flex vertical :gap="16"> <div class="toolbar">
<a-row :gutter="[16, 12]" align="middle"> <p class="lead">روتین‌های شما. کارهای هر روز از روی این‌ها ساخته می‌شوند. با «روتین جدید» می‌توانید برای خودتان برنامه تکراری بسازید.</p>
<a-col :xs="24" :md="16"> <UiSearch v-model="q" placeholder="جستجوی روتین…" class="search" />
<a-typography-text type="secondary"> </div>
روتین‌های شما. کارهای هر روز از روی این‌ها ساخته می‌شوند. با «روتین جدید» می‌توانید برای خودتان برنامه تکراری بسازید.
</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>
<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"> <UiEmptyState
<template v-if="loading"> v-else-if="!filtered.length"
<a-row :gutter="[16, 16]"> icon="refresh"
<a-col v-for="i in 6" :key="i" :xs="24" :sm="12" :xl="8"> :title="q ? 'روتینی با این عنوان پیدا نشد' : 'هنوز روتینی برای شما نیست'"
<CrmSkeletonCard :rows="4" :min-height="180" /> description="با دکمه «روتین جدید» یک برنامه تکراری برای خودتان بسازید. روتینی که مدیر برای شما تعریف کرده هم اینجا دیده می‌شود."
</a-col>
</a-row>
</template>
<template v-else>
<a-empty
v-if="!filtered.length"
:description="
q
? 'روتینی با این عنوان پیدا نشد'
: 'هنوز روتینی برای شما نیست. با دکمه «روتین جدید» یک برنامه تکراری برای خودتان بسازید. روتینی که مدیر برای شما تعریف کرده هم اینجا دیده می‌شود.'
"
/> />
<div v-else class="cards"> <div v-else class="cards">
@@ -162,3 +104,168 @@ const TONE_COLORS: Record<string, string> = {
</div> </div>
</div> </div>
</template> </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>
+374 -324
View File
@@ -3,67 +3,23 @@ import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { Select as ASelect } from 'ant-design-vue'; import { Select as ASelect } from 'ant-design-vue';
import type { RoutineCategoryDto, RoutineDto } from '@mento/shared'; import type { RoutineCategoryDto, RoutineDto } from '@mento/shared';
import UiIcon from '@/components/UiIcon.vue';
import UserAvatar from '@/components/UserAvatar.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 { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { ROUTINES_CTX, apiError, formatPercent, percentTone } from '@/lib/routines'; 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 shell = inject(ROUTINES_CTX)!;
const router = useRouter(); const router = useRouter();
@@ -100,37 +56,6 @@ const statusOptions = [
{ value: 'inactive' as const, label: 'غیرفعال' }, { 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 filtered = computed(() => {
const term = q.value.trim(); const term = q.value.trim();
return items.value.filter((r) => { return items.value.filter((r) => {
@@ -148,36 +73,6 @@ const counts = computed(() => ({
active: items.value.filter((r) => r.isActive).length, 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) { function replace(updated: RoutineDto) {
const i = items.value.findIndex((r) => r.id === updated.id); const i = items.value.findIndex((r) => r.id === updated.id);
if (i >= 0) items.value[i] = updated; 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 users = computed(() => shell.context.value?.users ?? []);
const teams = computed(() => shell.context.value?.teams ?? []); const teams = computed(() => shell.context.value?.teams ?? []);
@@ -388,14 +274,12 @@ function selectPopupContainer(node: HTMLElement) {
</UiButton> </UiButton>
</div> </div>
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8"> <p class="summary">
<a-typography-text type="secondary">
{{ toFaDigits(counts.total) }} روتین · {{ toFaDigits(counts.active) }} فعال {{ toFaDigits(counts.total) }} روتین · {{ toFaDigits(counts.active) }} فعال
</a-typography-text> </p>
<TableColumnsMenu table-key="routines-manage" align="end" />
</a-flex>
<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 <UiEmptyState
v-else-if="!filtered.length" v-else-if="!filtered.length"
@@ -463,208 +347,374 @@ function selectPopupContainer(node: HTMLElement) {
:aria-label="r.isActive ? 'غیرفعال کردن' : 'فعال کردن'" :aria-label="r.isActive ? 'غیرفعال کردن' : 'فعال کردن'"
@click="toggle(r)" @click="toggle(r)"
> >
<a-button <i />
v-if="!items.length" </button>
type="primary" <UiBadge size="sm" :variant="r.isActive ? 'success' : 'neutral'">
@click="router.push('/routines/manage/new')" {{ r.isActive ? 'فعال' : 'غیرفعال' }}
> </UiBadge>
ساخت اولین روتین </td>
</a-button> <td>
</a-empty> <div class="exec" :class="`tone-${percentTone(r.executionRate)}`">
</template> <strong>{{ formatPercent(r.executionRate) }}</strong>
<template #bodyCell="{ column, record }"> <i class="bar"><b :style="{ width: `${r.executionRate ?? 0}%` }" /></i>
<template v-if="column.key === 'عنوان'"> <small v-if="r.executionTotal">
<a-space :size="8" align="start"> {{ toFaDigits(r.executionDone) }} از {{ toFaDigits(r.executionTotal) }}
<a-badge :color="record.category?.color ?? undefined" /> </small>
<a-flex vertical :gap="0"> </div>
<a-typography-text strong :type="record.isActive ? undefined : 'secondary'"> </td>
{{ record.title }} <td class="actions-cell">
</a-typography-text> <div class="crm-table-actions">
<a-typography-text type="secondary"> <UiButton
{{ record.category?.name ?? 'بدون دسته' }} variant="icon"
<template v-if="record.isMandatory"> · اجباری</template> size="sm"
</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="ویرایش" aria-label="ویرایش"
@click="router.push(`/routines/manage/${record.id}/edit`)" @click="router.push(`/routines/manage/${r.id}/edit`)"
> >
<template #icon><EditOutlined /></template> <UiIcon name="pencil" :size="15" />
</a-button> </UiButton>
<a-dropdown <UiDropdownMenu
:open="menuFor === record.id" :open="menuFor === r.id"
trigger="click" @update:open="(v: boolean) => (menuFor = v ? r.id : null)"
@update:open="(v: boolean) => (menuFor = v ? record.id : null)"
> >
<a-button type="text" aria-label="عملیات بیشتر"> <template #trigger="{ toggle: t }">
<template #icon><MoreOutlined /></template> <UiButton variant="icon" size="sm" aria-label="عملیات بیشتر" @click="t">
</a-button> <UiIcon name="dots" :size="16" />
<template #overlay> </UiButton>
<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> </template>
</a-dropdown> <button type="button" @click="router.push(`/routines/manage/${r.id}/edit`)">ویرایش</button>
</a-space> <button type="button" @click="openReassign(r)">تغییر مسئول</button>
</template> <button type="button" @click="duplicate(r)">کپی روتین</button>
</template> <button type="button" @click="toggle(r)">{{ r.isActive ? 'غیرفعال کردن' : 'فعال کردن' }}</button>
</a-table> <button type="button" class="danger" @click="removing = r">حذف</button>
</CrmSkeletonTable> </UiDropdownMenu>
</CrmSkeleton> </div>
</a-flex> </td>
</tr>
</tbody>
</table>
</div>
<a-modal <!-- حذف -->
:open="!!removing" <UiModal :open="!!removing" title="حذف روتین" @close="removing = null">
title="حذف روتین" <p class="confirm">
:confirm-loading="removeBusy"
ok-text="حذف روتین"
cancel-text="انصراف"
:ok-button-props="{ danger: true }"
@ok="confirmRemove"
@cancel="removing = null"
>
<a-typography-text>
روتین «{{ removing?.title }}» حذف شود؟ کارهای انجام‌نشده امروزِ آن لغو می‌شوند؛ سوابق قبلی در گزارش‌ها باقی روتین «{{ removing?.title }}» حذف شود؟ کارهای انجام‌نشده امروزِ آن لغو می‌شوند؛ سوابق قبلی در گزارش‌ها باقی
می‌ماند. می‌ماند.
</a-typography-text> </p>
</a-modal> <template #footer>
<UiButton variant="danger" :loading="removeBusy" @click="confirmRemove">حذف روتین</UiButton>
<UiButton variant="ghost" @click="removing = null">انصراف</UiButton>
</template>
</UiModal>
<a-modal <!-- تغییر مسئول -->
:open="!!reassign.routine" <UiModal :open="!!reassign.routine" title="تغییر مسئول روتین" @close="reassign.routine = null">
title="تغییر مسئول روتین" <div class="form">
:confirm-loading="reassign.saving" <p class="confirm">{{ reassign.routine?.title }}</p>
ok-text="ذخیره" <UiField label="مسئول جدید" hint="کارهای انجام‌نشده امروز به مسئول جدید منتقل می‌شوند.">
cancel-text="انصراف" <UiSelect v-model="reassign.target">
@ok="saveReassign" <option value="" disabled>انتخاب کنید</option>
@cancel="reassign.routine = null" <optgroup label="کاربران">
> <option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
<a-form layout="vertical"> </optgroup>
<a-typography-text strong>{{ reassign.routine?.title }}</a-typography-text> <optgroup v-if="teams.length" label="کل اعضای تیم">
<a-form-item <option v-for="t in teams" :key="t.id" :value="`team:${t.id}`">{{ t.name }}</option>
label="مسئول جدید" </optgroup>
extra="کارهای انجام‌نشده امروز به مسئول جدید منتقل می‌شوند." </UiSelect>
:style="{ marginTop: '16px' }" </UiField>
> <p v-if="reassign.error" class="error">{{ reassign.error }}</p>
<a-select </div>
v-model:value="reassign.target" <template #footer>
:options="reassignOptions" <UiButton :loading="reassign.saving" @click="saveReassign">ذخیره</UiButton>
placeholder="انتخاب کنید" <UiButton variant="ghost" @click="reassign.routine = null">انصراف</UiButton>
style="width: 100%" </template>
/> </UiModal>
</a-form-item>
<a-alert v-if="reassign.error" type="error" show-icon :message="reassign.error" />
</a-form>
</a-modal>
<a-modal <!-- دسته‌بندی‌ها -->
v-model:open="catsOpen" <UiModal :open="catsOpen" title="دسته‌بندی کارها" @close="catsOpen = false">
title="دسته‌بندی کارها" <div class="form">
:confirm-loading="catForm.saving" <ul class="cat-list">
:ok-text="catForm.id ? 'ذخیره تغییرات' : 'افزودن دسته'" <li v-for="c in categories" :key="c.id">
cancel-text="بستن" <span class="cat-dot" :style="{ background: c.color }" />
@ok="saveCat" <span class="cat-name">{{ c.name }}</span>
> <UiButton variant="icon" size="sm" aria-label="ویرایش" @click="editCat(c)">
<a-flex vertical :gap="16"> <UiIcon name="pencil" :size="14" />
<a-flex vertical :gap="4"> </UiButton>
<a-flex <UiButton variant="icon" size="sm" aria-label="حذف" @click="deleteCat(c)">
v-for="c in categories" <UiIcon name="trash" :size="14" />
:key="c.id" </UiButton>
align="center" </li>
:gap="8" </ul>
> <div class="cat-form">
<a-badge :color="c.color" /> <UiField :label="catForm.id ? 'ویرایش دسته' : 'دسته جدید'">
<a-typography-text :style="{ flex: 1 }">{{ c.name }}</a-typography-text> <UiInput v-model="catForm.name" placeholder="مثلاً: پشتیبانی" :maxlength="60" />
<a-button type="text" aria-label="ویرایش" @click="editCat(c)"> </UiField>
<template #icon><EditOutlined /></template> <div class="swatches" role="radiogroup" aria-label="رنگ">
</a-button> <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" v-for="col in CAT_COLORS"
:key="col" :key="col"
shape="circle" type="button"
:style="{ class="swatch"
background: col, :class="{ on: catForm.color === col }"
borderColor: col, :style="{ background: col }"
color: token.colorWhite,
}"
:aria-label="col" :aria-label="col"
@click="catForm.color = col" @click="catForm.color = col"
> />
<template v-if="catForm.color === col" #icon><CheckOutlined /></template> </div>
</a-button> <p v-if="catForm.error" class="error">{{ catForm.error }}</p>
</a-space> </div>
</a-form-item> </div>
<a-alert v-if="catForm.error" type="error" show-icon :message="catForm.error" /> <template #footer>
<a-button v-if="catForm.id" @click="editCat(null)">انصراف از ویرایش</a-button> <UiButton :loading="catForm.saving" @click="saveCat">{{ catForm.id ? 'ذخیره تغییرات' : 'افزودن دسته' }}</UiButton>
</a-form> <UiButton v-if="catForm.id" variant="ghost" @click="editCat(null)">انصراف از ویرایش</UiButton>
</a-flex> <UiButton variant="ghost" @click="catsOpen = false">بستن</UiButton>
</a-modal>
</a-card>
</template> </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 { computed, inject, onMounted, ref, watch } from 'vue';
import { RouterLink } from 'vue-router'; import { RouterLink } from 'vue-router';
import type { RoutineTaskDto } from '@mento/shared'; import type { RoutineTaskDto } from '@mento/shared';
import UiIcon from '@/components/UiIcon.vue';
import UserAvatar from '@/components/UserAvatar.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 RoutineTaskModals from '@/components/routines/RoutineTaskModals.vue';
import { UiBadge, UiButton, UiEmptyState, UiSelect } from '@/components/ui';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import { toFaDigits } from '@/lib/jalali'; import { toFaDigits } from '@/lib/jalali';
import { useActivityPriorities } from '@/lib/activity-priorities'; import { useActivityPriorities } from '@/lib/activity-priorities';
@@ -20,40 +22,6 @@ import {
hasExplicitTime, hasExplicitTime,
} from '@/lib/routines'; } from '@/lib/routines';
import { useRoutineTaskActions } from '@/lib/useRoutineTaskActions'; 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 shell = inject(ROUTINES_CTX)!;
const activityPriorities = useActivityPriorities(); const activityPriorities = useActivityPriorities();
@@ -67,12 +35,6 @@ const who = ref('');
const isManager = computed(() => !!shell.context.value?.isManager); const isManager = computed(() => !!shell.context.value?.isManager);
const users = computed(() => shell.context.value?.users ?? []); 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) { async function load(silent = false) {
if (!silent) loading.value = true; if (!silent) loading.value = true;
error.value = ''; error.value = '';
@@ -102,87 +64,36 @@ const actions = useRoutineTaskActions((updated) => {
shell.notifyChanged(); 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 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> </script>
<template> <template>
<a-flex vertical :gap="16"> <div class="overdue">
<a-card :bordered="false"> <div class="toolbar">
<a-row :gutter="[16, 0]" align="middle"> <p class="lead">
<a-col :xs="24" :md="showAssignee || isManager ? 16 : 24"> <UiIcon name="warning" :size="16" />
<a-typography-text type="secondary">
<WarningOutlined :style="{ color: 'var(--ant-color-error)' }" />
<template v-if="items.length">{{ toFaDigits(items.length) }} کار از مهلتش گذشته است.</template> <template v-if="items.length">{{ toFaDigits(items.length) }} کار از مهلتش گذشته است.</template>
<template v-else>کار عقب‌افتاده‌ای ندارید.</template> <template v-else>کار عقب‌افتاده‌ای ندارید.</template>
</a-typography-text> </p>
</a-col> <UiSelect v-if="isManager" v-model="who" size="sm" class="who">
<a-col v-if="isManager" :xs="24" :md="8"> <option value="">کارهای خودم</option>
<a-select <option value="all">همه اعضای تیم</option>
v-model:value="who" <option v-for="u in users" :key="u.id" :value="u.id">{{ u.fullName }}</option>
:options="whoOptions" </UiSelect>
style="width: 100%" </div>
/>
</a-col>
</a-row>
<a-alert <p v-if="error" class="error">{{ error }}</p>
v-if="error" <p v-if="actions.error.value" class="error">{{ actions.error.value }}</p>
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' }"
/>
<a-flex justify="flex-end" :style="{ marginTop: '16px' }"> <div v-if="loading" class="state">در حال بارگذاری…</div>
<TableColumnsMenu table-key="routines-overdue" align="end" />
</a-flex>
<UiEmptyState <UiEmptyState
v-else-if="!items.length" v-else-if="!items.length"
@@ -247,18 +158,164 @@ function rowProps(record: RoutineTaskDto) {
@click="actions.toggle(t)" @click="actions.toggle(t)"
> >
انجام شد انجام شد
</a-button> </UiButton>
<a-button @click="actions.moveToday(record as RoutineTaskDto)">به امروز</a-button> <UiButton size="sm" variant="ghost" @click="actions.moveToday(t)">به امروز</UiButton>
<a-button @click="actions.openReschedule(record as RoutineTaskDto)">تغییر زمان</a-button> <UiButton size="sm" variant="ghost" @click="actions.openReschedule(t)">تغییر زمان</UiButton>
<a-button danger @click="actions.openCancel(record as RoutineTaskDto)">لغو</a-button> <UiButton size="sm" variant="ghost" class="danger-text" @click="actions.openCancel(t)">لغو</UiButton>
</a-space> </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> </template>
</template>
</a-table>
</CrmSkeletonTable>
</CrmSkeleton>
</a-card>
<RoutineTaskModals :actions="actions" /> <RoutineTaskModals :actions="actions" />
</a-flex> </div>
</template> </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>
+14 -152
View File
@@ -1,65 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { import {
Alert as AAlert, Alert as AAlert,
Avatar as AAvatar,
Card as ACard, Card as ACard,
Col as ACol, Col as ACol,
Divider as ADivider,
Empty as AEmpty, Empty as AEmpty,
Flex as AFlex, Flex as AFlex,
List as AList,
Row as ARow, Row as ARow,
Statistic as AStatistic,
Typography, Typography,
theme,
} from 'ant-design-vue'; } 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 { api } from '@/lib/api';
import axios from 'axios';
import type { TreasuryDashboardDto } from '@mento/shared'; import type { TreasuryDashboardDto } from '@mento/shared';
import { toman } from './treasury-format'; import { toman } from './treasury-format';
import { useTreasuryMobile } from './useTreasuryMobile'; import { useTreasuryMobile } from './useTreasuryMobile';
use([CanvasRenderer, BarChart, PieChart, GridComponent, TooltipComponent, LegendComponent]);
type ChartOption = ComposeOption<
| BarSeriesOption
| PieSeriesOption
| GridComponentOption
| TooltipComponentOption
| LegendComponentOption
>;
const { Text: ATypographyText } = Typography; const { Text: ATypographyText } = Typography;
const isMobile = useTreasuryMobile(); const isMobile = useTreasuryMobile();
const AListItem = AList.Item; const AListItem = AList.Item;
@@ -67,7 +24,6 @@ const AListItemMeta = AList.Item.Meta;
const data = ref<TreasuryDashboardDto | null>(null); const data = ref<TreasuryDashboardDto | null>(null);
const error = ref(''); const error = ref('');
const loading = ref(true);
const cards = [ const cards = [
{ key: 'bookedIncome', label: 'درآمد ثبت‌شده', hint: 'تعهدی' }, { key: 'bookedIncome', label: 'درآمد ثبت‌شده', hint: 'تعهدی' },
@@ -81,127 +37,33 @@ const cards = [
] as const; ] as const;
onMounted(async () => { onMounted(async () => {
loading.value = true;
error.value = '';
try { try {
const res = await api.get<TreasuryDashboardDto>('/treasury/dashboard'); const res = await api.get<TreasuryDashboardDto>('/treasury/dashboard');
data.value = res.data; data.value = res.data;
} catch (e) { } catch {
data.value = null; error.value = 'بارگذاری داشبورد مالی ناموفق بود.';
error.value = axios.isAxiosError(e)
? String(
(e.response?.data as { message?: string })?.message ??
'بارگذاری داشبورد خزانه ناموفق بود.',
)
: 'بارگذاری داشبورد خزانه ناموفق بود.';
} finally {
loading.value = false;
} }
}); });
</script> </script>
<template> <template>
<div> <a-flex vertical :gap="16">
<a-flex vertical :gap="token.margin">
<a-alert v-if="error" type="error" show-icon :message="error" /> <a-alert v-if="error" type="error" show-icon :message="error" />
<CrmSkeleton :loading="loading"> <template v-if="data">
<a-row :gutter="[token.marginSM, token.marginSM]"> <a-row :gutter="[16, 16]">
<a-col <a-col
v-for="card in heroCards" v-for="card in cards"
: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"
:key="card.key" :key="card.key"
:xs="24" :xs="24"
:sm="12" :sm="12"
:md="8" :md="8"
:lg="8" :xl="6"
> >
<CrmSkeletonKpi> <a-card :bordered="false">
<a-card <a-statistic :title="card.label" :value="toman(data[card.key])" />
v-if="data" <a-typography-text type="secondary">{{ card.hint }}</a-typography-text>
: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> </a-card>
</CrmSkeletonKpi>
</a-col> </a-col>
</a-row> </a-row>
@@ -16,7 +16,7 @@ import {
Typography, Typography,
} from 'ant-design-vue'; } from 'ant-design-vue';
import type { TableColumnsType } 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 * as XLSX from 'xlsx';
import type { TreasuryPartyBalanceDto } from '@mento/shared'; import type { TreasuryPartyBalanceDto } from '@mento/shared';
import { api } from '@/lib/api'; import { api } from '@/lib/api';