merge: bring latest origin/main into dev (design local, logic main)
Keep local template/style for conflicted Vue pages; take main script/API/shared logic.
This commit is contained in:
@@ -0,0 +1,412 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import {
|
||||
ACCOUNT_BALANCE_EVALUATE_BATCH_SIZE,
|
||||
ACCOUNT_BALANCE_WEIGHT_KEYS,
|
||||
ACCOUNT_BALANCE_WEIGHT_LABELS,
|
||||
type AccountBalanceCriterionMode,
|
||||
type AccountBalanceEvaluateResultDto,
|
||||
type AccountBalanceRangeDto,
|
||||
type AccountBalanceSettingsDto,
|
||||
type UpdateAccountBalanceSettingsRequest,
|
||||
} from '@mento/shared';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
import { UiButton, UiCard, UiField, UiInput, UiPageHeader } from '@/components/ui';
|
||||
|
||||
type RangeDraft = {
|
||||
enabled: boolean;
|
||||
mode: AccountBalanceCriterionMode;
|
||||
min: string;
|
||||
max: string;
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const evaluating = ref(false);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const firstStageName = ref('مطالبه مشتریان');
|
||||
const rial = reactive<RangeDraft>({
|
||||
enabled: false,
|
||||
mode: 'all_debtors',
|
||||
min: '',
|
||||
max: '',
|
||||
});
|
||||
const weights = reactive<Record<string, RangeDraft>>(
|
||||
Object.fromEntries(
|
||||
ACCOUNT_BALANCE_WEIGHT_KEYS.map((key) => [
|
||||
key,
|
||||
{ enabled: false, mode: 'all_debtors', min: '', max: '' } satisfies RangeDraft,
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
const weightKeys = computed(() =>
|
||||
[...new Set([...ACCOUNT_BALANCE_WEIGHT_KEYS, ...Object.keys(weights)])].sort((a, b) =>
|
||||
weightLabel(a).localeCompare(weightLabel(b), 'fa'),
|
||||
),
|
||||
);
|
||||
|
||||
function weightLabel(key: string) {
|
||||
const base = ACCOUNT_BALANCE_WEIGHT_LABELS[key] ?? key;
|
||||
return /گرم/.test(base) ? base : `${base} (گرم)`;
|
||||
}
|
||||
|
||||
function emptyDraft(): RangeDraft {
|
||||
return { enabled: false, mode: 'all_debtors', min: '', max: '' };
|
||||
}
|
||||
|
||||
function toDraft(range: AccountBalanceRangeDto | null | undefined): RangeDraft {
|
||||
if (!range) return emptyDraft();
|
||||
if (range.mode === 'all_debtors') {
|
||||
return { enabled: true, mode: 'all_debtors', min: '', max: '' };
|
||||
}
|
||||
return {
|
||||
enabled: true,
|
||||
mode: 'range',
|
||||
min: range.min == null ? '' : String(range.min),
|
||||
max: range.max == null ? '' : String(range.max),
|
||||
};
|
||||
}
|
||||
|
||||
function parseBound(raw: string, decimals: number): number | null {
|
||||
return parseMoneyNumber(String(raw ?? ''), decimals);
|
||||
}
|
||||
|
||||
function parseDraft(draft: RangeDraft, decimals: number): AccountBalanceRangeDto | null {
|
||||
if (!draft.enabled) return null;
|
||||
if (draft.mode === 'all_debtors') return { mode: 'all_debtors' };
|
||||
const min = parseBound(draft.min, decimals);
|
||||
const max = parseBound(draft.max, decimals);
|
||||
if (min == null || max == null) {
|
||||
throw new Error('بازه نامعتبر');
|
||||
}
|
||||
return { mode: 'range', min, max: Math.max(min, max) };
|
||||
}
|
||||
|
||||
function applySettings(data: AccountBalanceSettingsDto) {
|
||||
firstStageName.value = data.firstStageName || 'مطالبه مشتریان';
|
||||
Object.assign(rial, toDraft(data.rial));
|
||||
for (const key of Object.keys(weights)) {
|
||||
delete weights[key];
|
||||
}
|
||||
for (const key of ACCOUNT_BALANCE_WEIGHT_KEYS) {
|
||||
weights[key] = toDraft(null);
|
||||
}
|
||||
for (const [key, range] of Object.entries(data.weights ?? {})) {
|
||||
weights[key] = toDraft(range);
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const { data } = await api.get<AccountBalanceSettingsDto>('/account-balances/settings');
|
||||
applySettings(data);
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? Array.isArray(e.response?.data?.message)
|
||||
? e.response.data.message.join('، ')
|
||||
: String(e.response?.data?.message || 'بارگذاری تنظیمات ناموفق بود.')
|
||||
: 'بارگذاری تنظیمات ناموفق بود.';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
const weightPayload: Record<string, AccountBalanceRangeDto | null> = {};
|
||||
for (const key of weightKeys.value) {
|
||||
weightPayload[key] = parseDraft(
|
||||
weights[key] ?? emptyDraft(),
|
||||
3,
|
||||
);
|
||||
}
|
||||
const body: UpdateAccountBalanceSettingsRequest = {
|
||||
firstStageName: firstStageName.value.trim() || 'مطالبه مشتریان',
|
||||
rial: parseDraft(rial, 0),
|
||||
weights: weightPayload,
|
||||
};
|
||||
const { data } = await api.put<AccountBalanceSettingsDto>('/account-balances/settings', body);
|
||||
applySettings(data);
|
||||
ok.value = 'تنظیمات ذخیره شد. کاریز مطالبات آماده است.';
|
||||
} catch (e) {
|
||||
error.value =
|
||||
e instanceof Error && e.message === 'بازه نامعتبر'
|
||||
? 'برای حالت بازه، حداقل و حداکثر عددی وارد کنید.'
|
||||
: axios.isAxiosError(e)
|
||||
? Array.isArray(e.response?.data?.message)
|
||||
? e.response.data.message.join('، ')
|
||||
: String(e.response?.data?.message || 'ذخیره ناموفق بود.')
|
||||
: 'ذخیره ناموفق بود.';
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function mergeEvaluate(
|
||||
a: AccountBalanceEvaluateResultDto | null,
|
||||
b: AccountBalanceEvaluateResultDto,
|
||||
): AccountBalanceEvaluateResultDto {
|
||||
if (!a) return b;
|
||||
return {
|
||||
linkedPeople: Math.max(a.linkedPeople, b.linkedPeople),
|
||||
candidates: Math.max(a.candidates, b.candidates),
|
||||
skippedNoAssignee: Math.max(a.skippedNoAssignee, b.skippedNoAssignee),
|
||||
matched: a.matched + b.matched,
|
||||
created: a.created + b.created,
|
||||
reopened: a.reopened + b.reopened,
|
||||
canceled: a.canceled + b.canceled,
|
||||
unchanged: a.unchanged + b.unchanged,
|
||||
errors: a.errors + b.errors,
|
||||
message: b.message,
|
||||
offset: a.offset,
|
||||
limit: a.limit,
|
||||
batchProcessed: a.batchProcessed + b.batchProcessed,
|
||||
done: b.done,
|
||||
nextOffset: b.nextOffset,
|
||||
};
|
||||
}
|
||||
|
||||
async function runEvaluate() {
|
||||
evaluating.value = true;
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
let offset = 0;
|
||||
let merged: AccountBalanceEvaluateResultDto | null = null;
|
||||
let guard = 0;
|
||||
while (guard < 100) {
|
||||
guard += 1;
|
||||
ok.value =
|
||||
offset === 0
|
||||
? 'در حال اجرای مطالبات…'
|
||||
: `در حال اجرای مطالبات… (${offset.toLocaleString('fa-IR')} نفر پردازششده)`;
|
||||
const { data } = await api.post<AccountBalanceEvaluateResultDto>(
|
||||
'/account-balances/evaluate',
|
||||
{ offset, limit: ACCOUNT_BALANCE_EVALUATE_BATCH_SIZE },
|
||||
);
|
||||
merged = mergeEvaluate(merged, data);
|
||||
if (data.done || data.nextOffset == null) break;
|
||||
offset = data.nextOffset;
|
||||
}
|
||||
const final = merged!;
|
||||
final.message =
|
||||
final.message && !final.message.includes('ادامه')
|
||||
? final.message
|
||||
: [
|
||||
`${final.candidates} واجد شرایط`,
|
||||
`${final.matched} منطبق`,
|
||||
`${final.created} ساخته`,
|
||||
`${final.reopened} بازگشایی`,
|
||||
`${final.canceled} خارج از معیار`,
|
||||
].join(' · ');
|
||||
ok.value = final.message;
|
||||
if (final.matched === 0 && final.created === 0) {
|
||||
error.value =
|
||||
final.candidates === 0
|
||||
? 'برای ساخت فعالیت، مشتری باید به تهحساب لینک باشد و حداقل در یک گروه با مسئول باشد.'
|
||||
: 'هیچ مشتریای با معیارهای فعال منطبق نبود. حالت تمام بدهکاران یا بازه و علامت بد/بس را بررسی کنید.';
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = axios.isAxiosError(e)
|
||||
? String(
|
||||
Array.isArray(e.response?.data?.message)
|
||||
? e.response.data.message.join('، ')
|
||||
: e.response?.data?.message || 'اجرای ارزیابی ناموفق بود.',
|
||||
)
|
||||
: 'اجرای ارزیابی ناموفق بود.';
|
||||
} finally {
|
||||
evaluating.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<UiPageHeader
|
||||
title="تعیین محدوده مانده"
|
||||
description="بازه مانده مالی و وزنی مشتریان تهحساب برای ساخت فعالیت در کاریز مطالبات."
|
||||
/>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<p v-if="ok" class="ok">{{ ok }}</p>
|
||||
<p v-if="loading" class="muted">در حال بارگذاری…</p>
|
||||
|
||||
<UiCard v-else title="محدودهها">
|
||||
<p class="hint">
|
||||
برای هر معیار میتوانید «تمام بدهکاران» (مانده منفی / بد) را بدون بازه بگیرید، یا بازهٔ سفارشی
|
||||
بگذارید. اعداد با همان علامت تهحساب هستند: منفی = بد، مثبت = بس. مانده مالی به ریال و
|
||||
ماندههای وزنی به <strong>گرم</strong> است. اگر حداقل یکی از معیارهای فعال با مانده مشتری
|
||||
بخورد، فعالیت پیگیری ساخته میشود.
|
||||
</p>
|
||||
|
||||
<UiField label="عنوان ستون اول کاریز مطالبات">
|
||||
<UiInput v-model="firstStageName" maxlength="80" placeholder="مطالبه مشتریان" />
|
||||
</UiField>
|
||||
|
||||
<div class="range-block">
|
||||
<label class="toggle">
|
||||
<input v-model="rial.enabled" type="checkbox" />
|
||||
<span>مانده مالی (ریال)</span>
|
||||
</label>
|
||||
<div v-if="rial.enabled" class="criterion-body">
|
||||
<div class="mode-row" role="radiogroup" aria-label="حالت مانده مالی">
|
||||
<label class="mode-option">
|
||||
<input v-model="rial.mode" type="radio" value="all_debtors" />
|
||||
<span>تمام بدهکاران</span>
|
||||
</label>
|
||||
<label class="mode-option">
|
||||
<input v-model="rial.mode" type="radio" value="range" />
|
||||
<span>بازه</span>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="rial.mode === 'range'" class="range-row">
|
||||
<UiField label="از">
|
||||
<MoneyInput
|
||||
v-model="rial.min"
|
||||
:decimals="0"
|
||||
addon-after="ریال"
|
||||
placeholder="مثلاً ۱٬۰۰۰٬۰۰۰-"
|
||||
/>
|
||||
</UiField>
|
||||
<UiField label="تا">
|
||||
<MoneyInput
|
||||
v-model="rial.max"
|
||||
:decimals="0"
|
||||
addon-after="ریال"
|
||||
placeholder="مثلاً ۰"
|
||||
/>
|
||||
</UiField>
|
||||
</div>
|
||||
<p v-else class="muted tiny">همهٔ مشتریانی که مانده مالیشان منفی (بد) باشد.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="key in weightKeys" :key="key" class="range-block">
|
||||
<label class="toggle">
|
||||
<input v-model="weights[key].enabled" type="checkbox" />
|
||||
<span>{{ weightLabel(key) }}</span>
|
||||
</label>
|
||||
<div v-if="weights[key]?.enabled" class="criterion-body">
|
||||
<div class="mode-row" role="radiogroup" :aria-label="`حالت ${weightLabel(key)}`">
|
||||
<label class="mode-option">
|
||||
<input v-model="weights[key].mode" type="radio" value="all_debtors" />
|
||||
<span>تمام بدهکاران</span>
|
||||
</label>
|
||||
<label class="mode-option">
|
||||
<input v-model="weights[key].mode" type="radio" value="range" />
|
||||
<span>بازه</span>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="weights[key].mode === 'range'" class="range-row">
|
||||
<UiField label="از (گرم)">
|
||||
<MoneyInput
|
||||
v-model="weights[key].min"
|
||||
:decimals="3"
|
||||
addon-after="گرم"
|
||||
placeholder="مثلاً ۱۰-"
|
||||
/>
|
||||
</UiField>
|
||||
<UiField label="تا (گرم)">
|
||||
<MoneyInput
|
||||
v-model="weights[key].max"
|
||||
:decimals="3"
|
||||
addon-after="گرم"
|
||||
placeholder="مثلاً ۰"
|
||||
/>
|
||||
</UiField>
|
||||
</div>
|
||||
<p v-else class="muted tiny">همهٔ مشتریانی که این مانده وزنیشان منفی (بد) باشد.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<UiButton type="button" :disabled="saving" @click="save">
|
||||
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
|
||||
</UiButton>
|
||||
<UiButton type="button" variant="ghost" :disabled="evaluating" @click="runEvaluate">
|
||||
{{ evaluating ? 'در حال اجرا…' : 'اجرای الانِ مطالبات' }}
|
||||
</UiButton>
|
||||
</div>
|
||||
<p class="muted tiny">
|
||||
جاب خودکار هر روز ساعت ۸ و ۱۳ به وقت تهران اجرا میشود. دکمهٔ دستی همان ارزیابی را فوری میزند.
|
||||
</p>
|
||||
</UiCard>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
.hint,
|
||||
.muted {
|
||||
color: var(--muted, #64748b);
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.tiny {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.error {
|
||||
color: #b91c1c;
|
||||
}
|
||||
.ok {
|
||||
color: #047857;
|
||||
}
|
||||
.range-block {
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
padding: 0.75rem 0;
|
||||
border-top: 1px solid var(--border, #e2e8f0);
|
||||
}
|
||||
.toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.criterion-body {
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
.mode-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
}
|
||||
.mode-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.range-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.6rem;
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.range-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||
import ActivitiesKanban from '@/components/activities/ActivitiesKanban.vue';
|
||||
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||
import ActivityDeskFilters from '@/components/activities/ActivityDeskFilters.vue';
|
||||
import ActivityStagesManager from '@/components/activities/ActivityStagesManager.vue';
|
||||
import ActivityTypesManager from '@/components/activities/ActivityTypesManager.vue';
|
||||
@@ -335,7 +336,8 @@ const sharedParams = computed<Record<string, string | undefined>>(() => ({
|
||||
boardId: board.value || undefined,
|
||||
filter: filter.value,
|
||||
q: typeof route.query.q === 'string' && route.query.q.trim() ? route.query.q.trim() : undefined,
|
||||
desk: showDeskTabs.value ? desk.value : undefined,
|
||||
// همیشه desk بفرست تا سهمِ انجامشده از میز «من» حذف شود (حتی بدون تب تیم/من)
|
||||
desk: desk.value,
|
||||
typeDefId: typeof route.query.typeDefId === 'string' && route.query.typeDefId.trim()
|
||||
? route.query.typeDefId.trim()
|
||||
: undefined,
|
||||
@@ -455,7 +457,7 @@ function deskDetailQuery(columnStageId?: string): Record<string, string> {
|
||||
filter: filter.value,
|
||||
};
|
||||
if (board.value) query.board = board.value;
|
||||
if (showDeskTabs.value) query.desk = desk.value;
|
||||
query.desk = desk.value;
|
||||
const search = typeof route.query.q === 'string' ? route.query.q.trim() : '';
|
||||
if (search) query.q = search;
|
||||
if (typeFilter.value !== 'all') query.typeDefId = typeFilter.value;
|
||||
@@ -549,7 +551,7 @@ function openCreateBoard() {
|
||||
}
|
||||
|
||||
function openEditBoard() {
|
||||
if (!currentBoard.value) return;
|
||||
if (!currentBoard.value || currentBoard.value.systemKey) return;
|
||||
boardMemberQuery.value = '';
|
||||
boardModal.value = {
|
||||
mode: 'edit',
|
||||
@@ -1562,7 +1564,12 @@ onUnmounted(() => {
|
||||
<UiIcon name="plus" :size="14" />
|
||||
گروه جدید
|
||||
</button>
|
||||
<button type="button" class="board-menu-action" @click="openEditBoard">
|
||||
<button
|
||||
v-if="!currentBoard?.systemKey"
|
||||
type="button"
|
||||
class="board-menu-action"
|
||||
@click="openEditBoard"
|
||||
>
|
||||
<UiIcon name="pencil" :size="14" />
|
||||
ویرایش این گروه
|
||||
</button>
|
||||
@@ -1768,6 +1775,11 @@ onUnmounted(() => {
|
||||
{{ item.title }}
|
||||
</RouterLink>
|
||||
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
||||
<ActivityAccountBalances
|
||||
v-if="item.accountBalance"
|
||||
:balance="item.accountBalance"
|
||||
compact
|
||||
/>
|
||||
<p v-if="item.tags?.length" class="row-tags">
|
||||
<span v-for="t in item.tags.slice(0, 3)" :key="t">#{{ t }}</span>
|
||||
<span v-if="item.tags.length > 3">+{{ toFaDigits(item.tags.length - 3) }}</span>
|
||||
@@ -1900,6 +1912,11 @@ onUnmounted(() => {
|
||||
<UiIcon name="star" :size="14" class="star" />
|
||||
</RouterLink>
|
||||
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
||||
<ActivityAccountBalances
|
||||
v-if="item.accountBalance"
|
||||
:balance="item.accountBalance"
|
||||
compact
|
||||
/>
|
||||
<p class="meta-line">
|
||||
<span v-if="item.person">
|
||||
<UiIcon name="user" :size="13" />
|
||||
@@ -2111,7 +2128,7 @@ onUnmounted(() => {
|
||||
</li>
|
||||
</ul>
|
||||
<UiButton
|
||||
v-if="boardModal.mode === 'edit' && currentBoard && !currentBoard.isDefault"
|
||||
v-if="boardModal.mode === 'edit' && currentBoard && !currentBoard.isDefault && !currentBoard.systemKey"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
type="button"
|
||||
|
||||
@@ -17,6 +17,7 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
|
||||
import ActivityPostponeSheet from '@/components/activities/ActivityPostponeSheet.vue';
|
||||
import ActivityFieldsView from '@/components/activities/ActivityFieldsView.vue';
|
||||
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||
import StagePathStrip from '@/components/StagePathStrip.vue';
|
||||
import { Button as AButton, message, Modal } from 'ant-design-vue';
|
||||
import type {
|
||||
@@ -841,7 +842,8 @@ function moveToStage(stageId: string) {
|
||||
message.info(
|
||||
'سهم شما ثبت شد. فعالیت وقتی انجامشده میشود که همهٔ مسئولها سهم خود را بزنند.',
|
||||
);
|
||||
await load();
|
||||
discardDrafts();
|
||||
await advanceAfterLeavingColumn(leftId);
|
||||
return;
|
||||
}
|
||||
discardDrafts();
|
||||
@@ -865,16 +867,20 @@ async function loadActivityImages(row: ActivityDto) {
|
||||
clearImageUrls();
|
||||
const next: NoteMedia[] = [];
|
||||
for (const image of row.images ?? []) {
|
||||
const mime = image.mimeType.toLowerCase();
|
||||
const mime = (image.mimeType || 'application/octet-stream').toLowerCase();
|
||||
const kind = mime.startsWith('audio/') ? 'audio' : mime.startsWith('image/') ? 'image' : 'file';
|
||||
try {
|
||||
const { data } = await api.get<Blob>(`/activities/${row.id}/images/${image.id}`, {
|
||||
responseType: 'blob',
|
||||
});
|
||||
const blob =
|
||||
data.type && data.type !== 'application/octet-stream' && !data.type.includes('json')
|
||||
? data
|
||||
: new Blob([data], { type: mime });
|
||||
next.push({
|
||||
id: image.id,
|
||||
name: image.fileName,
|
||||
url: URL.createObjectURL(data),
|
||||
url: URL.createObjectURL(blob),
|
||||
kind,
|
||||
createdAt: image.createdAt,
|
||||
});
|
||||
@@ -885,6 +891,20 @@ async function loadActivityImages(row: ActivityDto) {
|
||||
imageUrls.value = next;
|
||||
}
|
||||
|
||||
function viewMedia(item: NoteMedia) {
|
||||
window.open(item.url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
|
||||
function downloadMedia(item: NoteMedia) {
|
||||
const link = document.createElement('a');
|
||||
link.href = item.url;
|
||||
link.download = item.name || 'file';
|
||||
link.rel = 'noopener';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
}
|
||||
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
@@ -919,6 +939,12 @@ async function complete(kind: 'share' | 'force' | 'undo' = 'share') {
|
||||
await advanceAfterLeavingColumn(leftId);
|
||||
return;
|
||||
}
|
||||
// سهم شخصی ثبت شد ولی فعالیت هنوز باز است — از میزکار این نفر خارج شو
|
||||
if (kind === 'share' && data.completionMode === 'all') {
|
||||
discardDrafts();
|
||||
await advanceAfterLeavingColumn(leftId);
|
||||
return;
|
||||
}
|
||||
activity.value = data;
|
||||
} catch {
|
||||
error.value =
|
||||
@@ -1004,8 +1030,12 @@ async function postponeTo(iso: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function submitComment(payload: { text: string; photoOnly: boolean }) {
|
||||
const body = payload.text.trim() || (payload.photoOnly ? 'عکس پیوست شد.' : '');
|
||||
async function submitComment(payload: {
|
||||
text: string;
|
||||
photoOnly: boolean;
|
||||
attachmentIds?: string[];
|
||||
}) {
|
||||
const body = payload.text.trim() || (payload.photoOnly ? 'فایل پیوست شد.' : '');
|
||||
if (!id.value || !activity.value || !body) return;
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
@@ -1014,7 +1044,9 @@ async function submitComment(payload: { text: string; photoOnly: boolean }) {
|
||||
const now = new Date();
|
||||
const author = auth.user?.fullName?.trim();
|
||||
const stamp = `[${formatJalaliNumeric(now)} ساعت ${formatClockFa(now)}${author ? ` — ${author}` : ''}]`;
|
||||
const entry = `${stamp}\n${body}`;
|
||||
const ids = [...new Set((payload.attachmentIds ?? []).filter(Boolean))];
|
||||
const attachLine = ids.length ? `\n[[attachments:${ids.join(',')}]]` : '';
|
||||
const entry = `${stamp}\n${body}${attachLine}`;
|
||||
const next = prev ? `${prev}\n\n${entry}` : entry;
|
||||
await api.patch(`/activities/${id.value}`, { description: next });
|
||||
commentOpen.value = false;
|
||||
@@ -1213,6 +1245,9 @@ onUnmounted(() => {
|
||||
#{{ t }}
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="activity.accountBalance" class="claim-balances">
|
||||
<ActivityAccountBalances :balance="activity.accountBalance" />
|
||||
</div>
|
||||
</div>
|
||||
<span class="type-ico" :style="typeColorStyle(draftTypeView!.color)">
|
||||
<UiIcon :name="draftTypeView!.icon" :size="22" />
|
||||
@@ -1663,7 +1698,11 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<ul v-if="entry.media.some((image) => image.kind === 'file')" class="note-files">
|
||||
<li v-for="image in entry.media.filter((item) => item.kind === 'file')" :key="image.id">
|
||||
<a :href="image.url" :download="image.name">{{ image.name }}</a>
|
||||
<span class="note-file-name">{{ image.name }}</span>
|
||||
<span class="note-file-actions">
|
||||
<button type="button" class="note-file-btn" @click="viewMedia(image)">مشاهده</button>
|
||||
<button type="button" class="note-file-btn" @click="downloadMedia(image)">دانلود</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -1746,7 +1785,11 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<ul v-if="looseMedia.some((image) => image.kind === 'file')" class="note-files">
|
||||
<li v-for="image in looseMedia.filter((item) => item.kind === 'file')" :key="image.id">
|
||||
<a :href="image.url" :download="image.name">{{ image.name }}</a>
|
||||
<span class="note-file-name">{{ image.name }}</span>
|
||||
<span class="note-file-actions">
|
||||
<button type="button" class="note-file-btn" @click="viewMedia(image)">مشاهده</button>
|
||||
<button type="button" class="note-file-btn" @click="downloadMedia(image)">دانلود</button>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1847,8 +1890,15 @@ onUnmounted(() => {
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 32px;
|
||||
position: relative;
|
||||
z-index: 4;
|
||||
/* زیر هدر دسکتاپ اپ (۱۶ + control + ۱۶) بماند تا با اسکرول در دسترس باشد */
|
||||
position: sticky;
|
||||
top: calc(16px + var(--control-h) + 16px);
|
||||
z-index: 15;
|
||||
margin-inline: -16px;
|
||||
padding: 0.4rem 16px;
|
||||
background: color-mix(in srgb, var(--bg, #f8fafc) 92%, transparent);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.nav h1 {
|
||||
@@ -1998,6 +2048,10 @@ onUnmounted(() => {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.claim-balances {
|
||||
margin-top: 0.65rem;
|
||||
}
|
||||
|
||||
.tag {
|
||||
background: #f0fdfa;
|
||||
color: #0f766e;
|
||||
@@ -2677,8 +2731,35 @@ dd {
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.note-files a {
|
||||
.note-files li {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.note-file-name {
|
||||
color: #0f766e;
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.note-file-actions {
|
||||
display: inline-flex;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.note-file-btn {
|
||||
border: 1px solid #99f6e4;
|
||||
background: #fff;
|
||||
color: #0f766e;
|
||||
border-radius: 0.45rem;
|
||||
font: inherit;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
padding: 0.2rem 0.55rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dock {
|
||||
@@ -2716,6 +2797,13 @@ dd {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.nav {
|
||||
/* زیر هدر موبایل اپ (۰٫۷۵rem + control + ۰٫۷۵rem) */
|
||||
top: calc(0.75rem + var(--control-h) + 0.75rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 899px) {
|
||||
.page {
|
||||
padding-bottom: calc(1rem + var(--mobile-tabbar-h));
|
||||
|
||||
@@ -35,6 +35,7 @@ import ActivityFieldsEditor from '@/components/activities/ActivityFieldsEditor.v
|
||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||
import { typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
||||
import type {
|
||||
ActivityAccountBalanceDto,
|
||||
ActivityBoardDto,
|
||||
ActivityDto,
|
||||
ActivityImageDto,
|
||||
@@ -51,6 +52,7 @@ import type {
|
||||
PipelineBoardDto,
|
||||
TeamDto,
|
||||
} from '@mento/shared';
|
||||
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -101,6 +103,8 @@ const keepTypeId = ref('');
|
||||
const priority = ref<ActivityPriority>('medium');
|
||||
const description = ref('');
|
||||
const tagsRaw = ref('');
|
||||
/** فقط فعالیتهای کاریز مطالبات از API میآید */
|
||||
const accountBalance = ref<ActivityAccountBalanceDto | null>(null);
|
||||
const PHOTO_TOO_LARGE = 'حجم عکس باید زیر 200 کیلوبایت باشد';
|
||||
const PHOTO_LIMIT = 8;
|
||||
type PendingPhoto = { localId: string; name: string; dataUrl: string; file: File };
|
||||
@@ -438,6 +442,7 @@ function resetForm() {
|
||||
priority.value = 'medium';
|
||||
description.value = '';
|
||||
tagsRaw.value = '';
|
||||
accountBalance.value = null;
|
||||
clearPhotos();
|
||||
createdActivityId.value = '';
|
||||
defaultDue();
|
||||
@@ -515,6 +520,7 @@ async function load() {
|
||||
description.value = data.description ?? '';
|
||||
needsNote.value = Boolean(data.description?.trim());
|
||||
tagsRaw.value = (data.tags ?? []).join('، ');
|
||||
accountBalance.value = data.accountBalance ?? null;
|
||||
splitDue(data.dueAt);
|
||||
durationMinutes.value = data.durationMinutes ?? 30;
|
||||
reminderAt.value = data.reminderAt
|
||||
@@ -1641,6 +1647,12 @@ watch([id, isNew], () => void load(), { immediate: true });
|
||||
<dt>مشتری مرتبط</dt>
|
||||
<dd>{{ selectedPerson?.fullName || '—' }}</dd>
|
||||
</div>
|
||||
<div v-if="accountBalance">
|
||||
<dt>مانده حساب</dt>
|
||||
<dd>
|
||||
<ActivityAccountBalances :balance="accountBalance" />
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>وضعیت انجام</dt>
|
||||
<dd>
|
||||
|
||||
+1054
-282
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@ import {
|
||||
Space as ASpace,
|
||||
Spin as ASpin,
|
||||
Tag as ATag,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
@@ -62,6 +63,17 @@ const addLost = ref(false);
|
||||
const addUnqualified = ref(false);
|
||||
const deleteTarget = ref<LeadStageDto | null>(null);
|
||||
const moveConfirm = ref<{ stageIds: string[]; message: string } | null>(null);
|
||||
const pendingLeadMove = ref<{
|
||||
leadId: string;
|
||||
stageId: string;
|
||||
position: number;
|
||||
fromStageName: string;
|
||||
toStageName: string;
|
||||
prev: LeadBoardColumnDto[];
|
||||
nextColumns: LeadBoardColumnDto[];
|
||||
} | null>(null);
|
||||
const stageMoveReason = ref('');
|
||||
const stageMoveError = ref('');
|
||||
const draggingId = ref<string | null>(null);
|
||||
const insertAt = ref<number | null>(null);
|
||||
const bodyEls = new Map<string, HTMLElement>();
|
||||
@@ -201,7 +213,8 @@ async function load() {
|
||||
try {
|
||||
const [board, stageRows] = await Promise.all([
|
||||
api.get<LeadBoardColumnDto[]>('/leads/board'),
|
||||
api.get<LeadStageDto[]>('/leads/stages'),
|
||||
// بدون شمارش لید روی هر مرحله — total ستونها از خود board میآید
|
||||
api.get<LeadStageDto[]>('/leads/stages', { params: { counts: '0' } }),
|
||||
]);
|
||||
columns.value = board.data;
|
||||
stages.value = stageRows.data;
|
||||
@@ -521,7 +534,7 @@ async function onDrop(stageId: string, event: DragEvent, index?: number) {
|
||||
draggingId.value = null;
|
||||
dropStageId.value = null;
|
||||
clearDragUi();
|
||||
if (!leadId || moving.value) return;
|
||||
if (!leadId || moving.value || pendingLeadMove.value) return;
|
||||
|
||||
const fromCol = columns.value.find((c) =>
|
||||
c.leads.some((l) => l.id === leadId),
|
||||
@@ -547,7 +560,7 @@ async function onDrop(stageId: string, event: DragEvent, index?: number) {
|
||||
leads: [...c.leads],
|
||||
}));
|
||||
|
||||
columns.value = columns.value.map((c) => {
|
||||
const nextColumns = columns.value.map((c) => {
|
||||
if (same && c.stage.id === stageId) return { ...c, leads: nextLeads };
|
||||
if (c.stage.id === fromCol.stage.id) {
|
||||
return {
|
||||
@@ -562,13 +575,66 @@ async function onDrop(stageId: string, event: DragEvent, index?: number) {
|
||||
return c;
|
||||
});
|
||||
|
||||
// جابهجایی داخل همان ستون: بدون دلیل
|
||||
if (same) {
|
||||
columns.value = nextColumns;
|
||||
moving.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
await api.patch(`/leads/${leadId}/move`, { stageId, position: insertIndex });
|
||||
} catch {
|
||||
columns.value = prev;
|
||||
error.value = 'جابهجایی لید ناموفق بود.';
|
||||
} finally {
|
||||
moving.value = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// تغییر ستون: اول دلیل، بعد اعمال
|
||||
stageMoveReason.value = '';
|
||||
stageMoveError.value = '';
|
||||
pendingLeadMove.value = {
|
||||
leadId,
|
||||
stageId,
|
||||
position: insertIndex,
|
||||
fromStageName: fromCol.stage.name,
|
||||
toStageName: target.stage.name,
|
||||
prev,
|
||||
nextColumns,
|
||||
};
|
||||
}
|
||||
|
||||
function cancelPendingLeadMove() {
|
||||
pendingLeadMove.value = null;
|
||||
stageMoveReason.value = '';
|
||||
stageMoveError.value = '';
|
||||
}
|
||||
|
||||
async function confirmPendingLeadMove() {
|
||||
const pending = pendingLeadMove.value;
|
||||
if (!pending || moving.value) return Promise.reject();
|
||||
const reason = stageMoveReason.value.trim();
|
||||
if (!reason) {
|
||||
stageMoveError.value = 'دلیل تغییر وضعیت را بنویسید.';
|
||||
return Promise.reject();
|
||||
}
|
||||
columns.value = pending.nextColumns;
|
||||
moving.value = true;
|
||||
error.value = '';
|
||||
stageMoveError.value = '';
|
||||
try {
|
||||
await api.patch(`/leads/${leadId}/move`, { stageId, position: insertIndex });
|
||||
} catch {
|
||||
columns.value = prev;
|
||||
error.value = 'جابهجایی لید ناموفق بود.';
|
||||
await api.patch(`/leads/${pending.leadId}/move`, {
|
||||
stageId: pending.stageId,
|
||||
position: pending.position,
|
||||
reason,
|
||||
});
|
||||
cancelPendingLeadMove();
|
||||
} catch (e) {
|
||||
columns.value = pending.prev;
|
||||
stageMoveError.value = apiMessage(e, 'جابهجایی لید ناموفق بود.');
|
||||
error.value = stageMoveError.value;
|
||||
return Promise.reject(e);
|
||||
} finally {
|
||||
moving.value = false;
|
||||
}
|
||||
@@ -981,6 +1047,31 @@ onMounted(load);
|
||||
>
|
||||
<a-alert v-if="moveConfirm" type="warning" show-icon :message="moveConfirm.message" />
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
:open="!!pendingLeadMove"
|
||||
title="دلیل تغییر وضعیت"
|
||||
ok-text="ثبت و انتقال"
|
||||
cancel-text="انصراف"
|
||||
:confirm-loading="moving"
|
||||
:ok-button-props="{ disabled: !stageMoveReason.trim() }"
|
||||
@ok="confirmPendingLeadMove"
|
||||
@cancel="cancelPendingLeadMove"
|
||||
>
|
||||
<a-flex vertical :gap="12">
|
||||
<a-typography-text v-if="pendingLeadMove" type="secondary">
|
||||
انتقال از «{{ pendingLeadMove.fromStageName }}» به «{{ pendingLeadMove.toStageName }}»
|
||||
</a-typography-text>
|
||||
<a-textarea
|
||||
v-model:value="stageMoveReason"
|
||||
:rows="4"
|
||||
:maxlength="1000"
|
||||
show-count
|
||||
placeholder="دلیل تغییر وضعیت را بنویسید…"
|
||||
/>
|
||||
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
|
||||
</a-flex>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
List as AList,
|
||||
ListItem as AListItem,
|
||||
ListItemMeta as AListItemMeta,
|
||||
Modal,
|
||||
Modal as AModal,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
Space as ASpace,
|
||||
@@ -46,7 +46,13 @@ import {
|
||||
UserAddOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import { isBirthDateAnswer, leadNoteFileIsImage, parseLeadFormNotes } from '@/lib/lead-form-notes';
|
||||
import {
|
||||
isActivityExperienceAnswer,
|
||||
isBirthDateAnswer,
|
||||
leadNoteFileIsImage,
|
||||
parseLeadFormNotes,
|
||||
} from '@/lib/lead-form-notes';
|
||||
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
|
||||
import {
|
||||
formatClockFa,
|
||||
formatJalaliNumeric,
|
||||
@@ -87,6 +93,18 @@ const canBehavior = computed(() => canUseBehavior(auth.user));
|
||||
const copilotOpen = ref(false);
|
||||
|
||||
const id = computed(() => String(route.params.id));
|
||||
|
||||
/** برگشت به همان جایی که از آن آمدهایم (فهرست یا مسیر/بورد لیدها). */
|
||||
function goBack() {
|
||||
const back = String((window.history.state as { back?: string | null } | null)?.back ?? '');
|
||||
const path = back.split('?')[0];
|
||||
if (path === '/leads' || path === '/leads/board') {
|
||||
router.back();
|
||||
return;
|
||||
}
|
||||
void router.push({ name: 'leads' });
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
@@ -97,6 +115,9 @@ const users = ref<OrgUserDto[]>([]);
|
||||
const activities = ref<ActivityDto[]>([]);
|
||||
|
||||
const stageId = ref('');
|
||||
const stageMoveOpen = ref(false);
|
||||
const stageMoveReason = ref('');
|
||||
const stageMoveError = ref('');
|
||||
const assigneeId = ref('');
|
||||
const callOutcome = ref('');
|
||||
const callBody = ref('');
|
||||
@@ -125,9 +146,15 @@ const editForm = ref({
|
||||
instagram: '',
|
||||
birthDate: '',
|
||||
trade: '',
|
||||
activityExperience: '' as string,
|
||||
notes: '',
|
||||
});
|
||||
|
||||
const activityExperienceOptions = [
|
||||
{ value: '', label: '—' },
|
||||
...ACTIVITY_EXPERIENCE_OPTIONS.map((value) => ({ value, label: value })),
|
||||
];
|
||||
|
||||
function formatDate(value: string | null | undefined) {
|
||||
if (!value) return '—';
|
||||
try {
|
||||
@@ -145,8 +172,18 @@ const shownBirthDate = computed(() => {
|
||||
if (lead.value?.birthDate) return formatDate(lead.value.birthDate);
|
||||
return formBirthDate.value || '—';
|
||||
});
|
||||
const formActivityExperience = computed(
|
||||
() =>
|
||||
noteView.value.rows.find((row) => isActivityExperienceAnswer(row.label) && !row.file)?.text ??
|
||||
'',
|
||||
);
|
||||
const shownActivityExperience = computed(
|
||||
() => lead.value?.activityExperience || formActivityExperience.value || '—',
|
||||
);
|
||||
const answerRows = computed(() =>
|
||||
noteView.value.rows.filter((row) => !isBirthDateAnswer(row.label)),
|
||||
noteView.value.rows.filter(
|
||||
(row) => !isBirthDateAnswer(row.label) && !isActivityExperienceAnswer(row.label),
|
||||
),
|
||||
);
|
||||
|
||||
const genderOptions = PERSON_GENDERS.map((key) => ({
|
||||
@@ -231,6 +268,7 @@ function startEdit() {
|
||||
? formatLocalDateInput(new Date(lead.value.birthDate))
|
||||
: '',
|
||||
trade: lead.value.trade ?? '',
|
||||
activityExperience: lead.value.activityExperience ?? '',
|
||||
notes: lead.value.notes ?? '',
|
||||
};
|
||||
}
|
||||
@@ -257,6 +295,7 @@ async function saveEdit() {
|
||||
instagram: editForm.value.instagram.trim() || null,
|
||||
birthDate: editForm.value.birthDate || null,
|
||||
trade: editForm.value.trade.trim() || null,
|
||||
activityExperience: editForm.value.activityExperience.trim() || null,
|
||||
notes: editForm.value.notes.trim() || null,
|
||||
});
|
||||
okMsg.value = 'لید ویرایش شد.';
|
||||
@@ -270,18 +309,48 @@ async function saveEdit() {
|
||||
}
|
||||
}
|
||||
|
||||
async function changeStage() {
|
||||
function openStageMove() {
|
||||
if (!stageId.value || stageId.value === lead.value?.stageId) return;
|
||||
stageMoveReason.value = '';
|
||||
stageMoveError.value = '';
|
||||
stageMoveOpen.value = true;
|
||||
}
|
||||
|
||||
function cancelStageMove() {
|
||||
stageMoveOpen.value = false;
|
||||
stageMoveReason.value = '';
|
||||
stageMoveError.value = '';
|
||||
if (lead.value) stageId.value = lead.value.stageId;
|
||||
}
|
||||
|
||||
async function changeStage() {
|
||||
if (!stageId.value || stageId.value === lead.value?.stageId) {
|
||||
return Promise.reject();
|
||||
}
|
||||
const reason = stageMoveReason.value.trim();
|
||||
if (!reason) {
|
||||
stageMoveError.value = 'دلیل تغییر وضعیت را بنویسید.';
|
||||
return Promise.reject();
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
stageMoveError.value = '';
|
||||
try {
|
||||
await api.patch(`/leads/${id.value}/move`, { stageId: stageId.value });
|
||||
await api.patch(`/leads/${id.value}/move`, {
|
||||
stageId: stageId.value,
|
||||
reason,
|
||||
});
|
||||
okMsg.value = 'وضعیت بهروز شد.';
|
||||
message.success(okMsg.value);
|
||||
moreOpen.value = false;
|
||||
stageMoveOpen.value = false;
|
||||
stageMoveReason.value = '';
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiError(e, 'تغییر وضعیت ناموفق بود.');
|
||||
const msg = apiError(e, 'تغییر وضعیت ناموفق بود.');
|
||||
stageMoveError.value = msg;
|
||||
error.value = msg;
|
||||
return Promise.reject(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
@@ -378,7 +447,7 @@ async function setFollowUp() {
|
||||
}
|
||||
|
||||
function convertLead() {
|
||||
Modal.confirm({
|
||||
AModal.confirm({
|
||||
title: 'این لید به مشتری تبدیل شود؟',
|
||||
okText: 'تبدیل',
|
||||
cancelText: 'انصراف',
|
||||
@@ -407,7 +476,7 @@ function convertLead() {
|
||||
}
|
||||
|
||||
function archiveLead() {
|
||||
Modal.confirm({
|
||||
AModal.confirm({
|
||||
title: 'این لید بایگانی شود؟',
|
||||
okText: 'بایگانی',
|
||||
cancelText: 'انصراف',
|
||||
@@ -438,10 +507,15 @@ function openTel() {
|
||||
const feed = computed(() => {
|
||||
const rows: Array<{ key: string; title: string; by: string; at: string }> = [];
|
||||
for (const ev of lead.value?.events ?? []) {
|
||||
const body = ev.body?.trim();
|
||||
rows.push({
|
||||
key: `ev-${ev.id}`,
|
||||
title: ev.title,
|
||||
by: ev.body?.trim() || 'توسط سیستم',
|
||||
by: body
|
||||
? ev.type === 'stage_changed'
|
||||
? `دلیل: ${body}`
|
||||
: body
|
||||
: 'توسط سیستم',
|
||||
at: ev.createdAt,
|
||||
});
|
||||
}
|
||||
@@ -496,11 +570,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<a-col :span="24">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="token.marginSM">
|
||||
<a-space :size="12" align="start">
|
||||
<RouterLink :to="{ name: 'leads-board' }" custom v-slot="{ navigate }">
|
||||
<a-button @click="navigate">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
</a-button>
|
||||
</RouterLink>
|
||||
<a-button aria-label="بازگشت" @click="goBack">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
</a-button>
|
||||
<div>
|
||||
<a-typography-title :level="3" :style="{ margin: 0 }">
|
||||
{{ lead?.title || 'جزئیات لید' }}
|
||||
@@ -662,6 +734,17 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<a-input v-model:value="editForm.trade" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="سابقه فعالیت">
|
||||
<a-select
|
||||
v-model:value="editForm.activityExperience"
|
||||
allow-clear
|
||||
placeholder="اختیاری"
|
||||
style="width: 100%"
|
||||
:options="activityExperienceOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="یادداشت">
|
||||
<a-textarea
|
||||
@@ -734,6 +817,9 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
<span dir="ltr">{{ lead.instagram || '—' }}</span>
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="صنف">{{ lead.trade || '—' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="سابقه فعالیت">
|
||||
{{ shownActivityExperience }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item label="منبع">
|
||||
{{ lead.source || '—' }}
|
||||
</a-descriptions-item>
|
||||
@@ -866,7 +952,7 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-typography-paragraph v-if="ev.body" type="secondary">
|
||||
{{ ev.body }}
|
||||
<template v-if="ev.type === 'stage_changed'">دلیل: </template>{{ ev.body }}
|
||||
</a-typography-paragraph>
|
||||
</a-timeline-item>
|
||||
</a-timeline>
|
||||
@@ -936,7 +1022,12 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-button block :disabled="busy" :loading="busy" @click="changeStage">
|
||||
<a-button
|
||||
block
|
||||
:disabled="busy || stageId === lead.stageId"
|
||||
:loading="busy"
|
||||
@click="openStageMove"
|
||||
>
|
||||
اعمال وضعیت
|
||||
</a-button>
|
||||
|
||||
@@ -1082,7 +1173,13 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
:options="stages.map((s) => ({ value: s.id, label: s.name }))"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-button block :disabled="busy" @click="changeStage">اعمال وضعیت</a-button>
|
||||
<a-button
|
||||
block
|
||||
:disabled="busy || stageId === lead.stageId"
|
||||
@click="openStageMove"
|
||||
>
|
||||
اعمال وضعیت
|
||||
</a-button>
|
||||
|
||||
<template v-if="canAssignOthers">
|
||||
<a-divider orientation="right">تخصیص کارشناس</a-divider>
|
||||
@@ -1170,20 +1267,47 @@ onBeforeUnmount(() => narrowMq?.removeEventListener('change', syncNarrow));
|
||||
</a-button>
|
||||
</a-form>
|
||||
</a-drawer>
|
||||
|
||||
<SmsComposeModal
|
||||
:open="smsOpen"
|
||||
title="ارسال پیامک"
|
||||
:endpoint="`/leads/${lead.id}/sms`"
|
||||
:history-endpoint="`/leads/${lead.id}/sms-history`"
|
||||
:name="lead.contactName || lead.title"
|
||||
:phone="lead.mobile || lead.phone || ''"
|
||||
:record-title="lead.title"
|
||||
:company="lead.trade ?? ''"
|
||||
@close="smsOpen = false"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</a-spin>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-modal
|
||||
v-model:open="stageMoveOpen"
|
||||
title="دلیل تغییر وضعیت"
|
||||
ok-text="ثبت و انتقال"
|
||||
cancel-text="انصراف"
|
||||
destroy-on-close
|
||||
:confirm-loading="busy"
|
||||
:ok-button-props="{ disabled: !stageMoveReason.trim() }"
|
||||
@ok="changeStage"
|
||||
@cancel="cancelStageMove"
|
||||
>
|
||||
<a-flex vertical :gap="12">
|
||||
<a-typography-text type="secondary">
|
||||
انتقال از «{{ lead?.stageName || '—' }}» به «{{ stages.find((s) => s.id === stageId)?.name || '—' }}»
|
||||
</a-typography-text>
|
||||
<a-textarea
|
||||
v-model:value="stageMoveReason"
|
||||
:rows="4"
|
||||
:maxlength="1000"
|
||||
show-count
|
||||
placeholder="دلیل تغییر وضعیت را بنویسید…"
|
||||
/>
|
||||
<a-alert v-if="stageMoveError" type="error" show-icon :message="stageMoveError" />
|
||||
</a-flex>
|
||||
</a-modal>
|
||||
|
||||
<SmsComposeModal
|
||||
v-if="lead"
|
||||
:open="smsOpen"
|
||||
title="ارسال پیامک"
|
||||
:endpoint="`/leads/${lead.id}/sms`"
|
||||
:history-endpoint="`/leads/${lead.id}/sms-history`"
|
||||
:name="lead.contactName || lead.title"
|
||||
:phone="lead.mobile || lead.phone || ''"
|
||||
:record-title="lead.title"
|
||||
:company="lead.trade ?? ''"
|
||||
@close="smsOpen = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch, type Component } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { api } from '@/lib/api';
|
||||
import UiIcon from '@/components/UiIcon.vue';
|
||||
import { UiButton, UiPageHeader } from '@/components/ui';
|
||||
import type {
|
||||
LeadFormDto,
|
||||
LeadFormDuplicateMode,
|
||||
@@ -16,99 +18,16 @@ import type {
|
||||
OrgUserDto,
|
||||
PipelineDto,
|
||||
} from '@mento/shared';
|
||||
import { ACTIVITY_EXPERIENCE_OPTIONS } from '@mento/shared';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { prepareFormCover } from '@/lib/form-cover';
|
||||
import { useEscClose } from '@/lib/modal-stack';
|
||||
import {
|
||||
Affix as AAffix,
|
||||
Alert as AAlert,
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Checkbox as ACheckbox,
|
||||
CheckboxGroup as ACheckboxGroup,
|
||||
Col as ACol,
|
||||
Collapse as ACollapse,
|
||||
CollapsePanel as ACollapsePanel,
|
||||
Descriptions as ADescriptions,
|
||||
DescriptionsItem as ADescriptionsItem,
|
||||
Divider as ADivider,
|
||||
Drawer as ADrawer,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
Modal as AModal,
|
||||
Popover as APopover,
|
||||
RadioGroup as ARadioGroup,
|
||||
Rate as ARate,
|
||||
Row as ARow,
|
||||
Select as ASelect,
|
||||
SelectOption as ASelectOption,
|
||||
SelectOptGroup as ASelectOptGroup,
|
||||
Space as ASpace,
|
||||
Statistic as AStatistic,
|
||||
Switch as ASwitch,
|
||||
Tabs as ATabs,
|
||||
TabPane as ATabPane,
|
||||
Tag as ATag,
|
||||
Textarea as ATextarea,
|
||||
Typography,
|
||||
Upload as AUpload,
|
||||
theme,
|
||||
} from 'ant-design-vue';
|
||||
import { CrmSkeleton, CrmSkeletonCard } from '@/components/skeleton';
|
||||
import type { UploadProps } from 'ant-design-vue';
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
BarChartOutlined,
|
||||
CalendarOutlined,
|
||||
CheckOutlined,
|
||||
CommentOutlined,
|
||||
CopyOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
EyeOutlined,
|
||||
FileOutlined,
|
||||
HolderOutlined,
|
||||
MailOutlined,
|
||||
NotificationOutlined,
|
||||
PhoneOutlined,
|
||||
PlusOutlined,
|
||||
SaveOutlined,
|
||||
SendOutlined,
|
||||
StarOutlined,
|
||||
UnorderedListOutlined,
|
||||
UserOutlined,
|
||||
} from '@/icons/ant-bridge';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Link: ATypographyLink, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
const ASpaceCompact = ASpace.Compact;
|
||||
const ACheckableTag = ATag.CheckableTag;
|
||||
const { token } = theme.useToken();
|
||||
|
||||
type Tab = 'edit' | 'settings' | 'share' | 'responses';
|
||||
type IconName =
|
||||
| 'user' | 'chat' | 'mail' | 'phone' | 'list' | 'layers' | 'calendar'
|
||||
| 'check' | 'chart' | 'document' | 'star' | 'megaphone' | 'building';
|
||||
|
||||
const ICON_MAP: Record<IconName, Component> = {
|
||||
user: UserOutlined,
|
||||
chat: CommentOutlined,
|
||||
mail: MailOutlined,
|
||||
phone: PhoneOutlined,
|
||||
list: UnorderedListOutlined,
|
||||
layers: AppstoreOutlined,
|
||||
calendar: CalendarOutlined,
|
||||
check: CheckOutlined,
|
||||
chart: BarChartOutlined,
|
||||
document: FileOutlined,
|
||||
star: StarOutlined,
|
||||
megaphone: NotificationOutlined,
|
||||
building: AppstoreOutlined,
|
||||
};
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const id = computed(() => String(route.params.id || ''));
|
||||
@@ -121,7 +40,7 @@ const tab = ref<Tab>('edit');
|
||||
const desktopPreviewOpen = ref(false);
|
||||
const publishOpen = ref(false);
|
||||
const advancedOpen = ref(false);
|
||||
const readyOpen = ref<string[]>(['lead']);
|
||||
const readyOpen = ref<string | null>('lead');
|
||||
const editFieldKey = ref<string | null>(null);
|
||||
const dragKey = ref<string | null>(null);
|
||||
|
||||
@@ -146,6 +65,7 @@ const users = ref<OrgUserDto[]>([]);
|
||||
const pipelines = ref<PipelineDto[]>([]);
|
||||
const leadStages = ref<LeadStageDto[]>([]);
|
||||
const submissions = ref<LeadFormSubmissionDto[]>([]);
|
||||
const coverInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const toolbox: Array<{ type: LeadFormFieldType; label: string; icon: IconName }> = [
|
||||
{ type: 'text', label: 'متن کوتاه', icon: 'user' },
|
||||
@@ -177,6 +97,12 @@ const readyGroups = [
|
||||
{ label: 'شهر', fieldType: 'text' as const, mapTo: 'lead.city' as const },
|
||||
{ label: 'منطقه', fieldType: 'text' as const, mapTo: 'lead.region' as const },
|
||||
{ label: 'صنف', fieldType: 'text' as const, mapTo: 'lead.trade' as const },
|
||||
{
|
||||
label: 'سابقه فعالیت',
|
||||
fieldType: 'select' as const,
|
||||
mapTo: 'lead.activityExperience' as const,
|
||||
options: [...ACTIVITY_EXPERIENCE_OPTIONS],
|
||||
},
|
||||
{ label: 'توضیحات', fieldType: 'textarea' as const, mapTo: 'lead.notes' as const },
|
||||
],
|
||||
},
|
||||
@@ -186,6 +112,12 @@ const readyGroups = [
|
||||
{ label: 'نام و نام خانوادگی', fieldType: 'text' as const, mapTo: 'person.fullName' as const },
|
||||
{ label: 'ایمیل', fieldType: 'email' as const, mapTo: 'person.email' as const },
|
||||
{ label: 'موبایل', fieldType: 'phone' as const, mapTo: 'person.mobile' as const },
|
||||
{
|
||||
label: 'سابقه فعالیت',
|
||||
fieldType: 'select' as const,
|
||||
mapTo: 'person.activityExperience' as const,
|
||||
options: [...ACTIVITY_EXPERIENCE_OPTIONS],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -312,14 +244,7 @@ function applyHex() {
|
||||
else hexDraft.value = submitColor.value;
|
||||
}
|
||||
|
||||
const titleInput = ref<{ focus: () => void; $el?: HTMLElement } | null>(null);
|
||||
|
||||
function focusTitle() {
|
||||
titleInput.value?.focus();
|
||||
const el = titleInput.value?.$el?.querySelector?.('input') as HTMLInputElement | null | undefined;
|
||||
el?.select?.();
|
||||
}
|
||||
|
||||
const titleInput = ref<HTMLInputElement | null>(null);
|
||||
const conversionRate = computed(() => {
|
||||
const submits = form.value?.submitCount ?? 0;
|
||||
const leads = form.value?.leadCreateCount ?? 0;
|
||||
@@ -337,28 +262,6 @@ const crmSummary = computed(() => {
|
||||
return parts.join(' · ') || 'اتصال CRM تنظیم نشده';
|
||||
});
|
||||
|
||||
const leadStageOptions = computed(() => [
|
||||
{ value: '', label: 'اولین مرحله فعال' },
|
||||
...leadStages.value.map((s) => ({ value: s.id, label: s.name })),
|
||||
]);
|
||||
const pipelineOptions = computed(() => [
|
||||
{ value: '', label: 'پیشفرض سازمان' },
|
||||
...pipelines.value.map((p) => ({ value: p.id, label: p.name })),
|
||||
]);
|
||||
const duplicateOptions = [
|
||||
{ value: 'update', label: 'بهروزرسانی لید موجود' },
|
||||
{ value: 'skip', label: 'رد کردن (ثبت نشود)' },
|
||||
{ value: 'activity', label: 'فقط ثبت رویداد روی لید موجود' },
|
||||
];
|
||||
const settingsSummaryItems = computed(() => [
|
||||
{ label: 'وضعیت', value: isActive.value ? 'فعال' : 'غیرفعال' },
|
||||
{ label: 'ثبت لید', value: createLead.value ? 'بله' : 'خیر' },
|
||||
{ label: 'ساخت شخص', value: createPerson.value ? 'بله' : 'خیر' },
|
||||
{ label: 'ساخت معامله', value: createDeal.value ? 'بله' : 'خیر' },
|
||||
{ label: 'منبع', value: source.value || '—' },
|
||||
{ label: 'مسئولان', value: toFaDigits(assigneeIds.value.length) },
|
||||
]);
|
||||
|
||||
function newKey(label: string) {
|
||||
const base = label.replace(/\s+/g, '_').slice(0, 24) || 'field';
|
||||
let key = `${base}_${Math.random().toString(36).slice(2, 6)}`;
|
||||
@@ -496,7 +399,8 @@ async function load() {
|
||||
if (route.query.new && !error.value) {
|
||||
tab.value = 'edit';
|
||||
await nextTick();
|
||||
focusTitle();
|
||||
titleInput.value?.focus();
|
||||
titleInput.value?.select();
|
||||
void router.replace({ query: {} });
|
||||
}
|
||||
}
|
||||
@@ -518,7 +422,7 @@ async function save() {
|
||||
if (!name.value.trim()) {
|
||||
tab.value = 'edit';
|
||||
await nextTick();
|
||||
focusTitle();
|
||||
titleInput.value?.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -559,7 +463,11 @@ async function save() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCoverFile(file: File) {
|
||||
async function uploadCover(ev: Event) {
|
||||
const input = ev.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = '';
|
||||
if (!file) return;
|
||||
error.value = '';
|
||||
coverUploading.value = true;
|
||||
try {
|
||||
@@ -576,11 +484,6 @@ async function handleCoverFile(file: File) {
|
||||
}
|
||||
}
|
||||
|
||||
const beforeCoverUpload: UploadProps['beforeUpload'] = (file) => {
|
||||
void handleCoverFile(file as File);
|
||||
return false;
|
||||
};
|
||||
|
||||
async function clearCover() {
|
||||
try {
|
||||
const { data } = await api.delete<LeadFormDto>(`/lead-forms/${id.value}/cover`);
|
||||
@@ -650,15 +553,6 @@ function toggleAssignee(uid: string) {
|
||||
: [...assigneeIds.value, uid];
|
||||
}
|
||||
|
||||
function onTabChange(key: string | number) {
|
||||
const next = String(key) as Tab;
|
||||
if (next === 'responses') {
|
||||
void loadResponses();
|
||||
return;
|
||||
}
|
||||
tab.value = next;
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
@@ -1428,3 +1322,345 @@ onMounted(load);
|
||||
</a-modal>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page { --teal: #14b8a6; display: grid; gap: 0.85rem; }
|
||||
.top-ghosts { display: flex; gap: 0.45rem; flex-wrap: nowrap; }
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; min-height: var(--control-h); height: var(--control-h); padding: 0 0.9rem; border-radius: var(--radius); font: inherit; font-weight: 700; border: 1px solid transparent; cursor: pointer; text-decoration: none; box-sizing: border-box; white-space: nowrap; }
|
||||
.btn.primary { background: var(--teal); color: #fff; }
|
||||
.btn.ghost { background: #fff; color: #0f766e; border-color: #99f6e4; }
|
||||
.banner { margin: 0; padding: 0.6rem 0.8rem; border-radius: var(--radius); }
|
||||
.banner.err { background: #fef2f2; color: #b91c1c; }
|
||||
.banner.ok { background: #ecfdf5; color: #047857; }
|
||||
.tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; background: #fff; padding: 0.35rem; border-radius: var(--radius); }
|
||||
.tabs button { border: 0; background: transparent; min-height: 38px; padding: 0 0.85rem; border-radius: var(--radius); font: inherit; font-weight: 700; color: #0f766e; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; }
|
||||
.tabs button.on { background: var(--teal); color: #fff; }
|
||||
.workspace { display: grid; grid-template-columns: 280px minmax(0,1fr) 240px; gap: 0.85rem; align-items: start; }
|
||||
.preview-col, .canvas, .toolbox, .panel { background: #fff; border-radius: var(--radius); padding: 0.9rem; box-shadow: 0 8px 22px rgba(15,23,42,.04); }
|
||||
.device-toggle { display: flex; gap: 0.3rem; margin-bottom: 0.7rem; }
|
||||
.device-toggle button { flex: 1; border: 0; min-height: 34px; border-radius: var(--radius); font: inherit; font-weight: 700; background: #f1f5f9; cursor: pointer; }
|
||||
.device-toggle button.on { background: var(--teal); color: #fff; }
|
||||
.phone { border: 8px solid #0f172a; border-radius: var(--radius); overflow: hidden; background: #fff; max-width: 260px; margin: 0 auto; }
|
||||
.desk-overlay { padding: 1.2rem; }
|
||||
.desk-sheet {
|
||||
width: min(920px, 100%);
|
||||
max-height: calc(100vh - 2.4rem);
|
||||
overflow: auto;
|
||||
background: #eef2f6;
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem 1.1rem 1.2rem;
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.desk-sheet header { display: flex; justify-content: space-between; align-items: center; }
|
||||
.desk-form { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 16px 40px rgba(15,23,42,.08); }
|
||||
.desk-form .cover { height: auto; aspect-ratio: 3 / 1; max-height: 260px; }
|
||||
.desk-body { padding: 1.2rem 1.4rem 1.4rem; }
|
||||
.desk-body h3 { font-size: 1.35rem; }
|
||||
.desk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
|
||||
.desk-fields .wide { grid-column: 1 / -1; }
|
||||
.desk-form .send { justify-self: start; min-width: 200px; }
|
||||
.cover { aspect-ratio: 3 / 1; display: grid; place-items: center; color: #fff; overflow: hidden; }
|
||||
.cover img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.preview-body { padding: 0.8rem; display: grid; gap: 0.5rem; }
|
||||
.preview-body h3 { margin: 0; font-size: 1rem; }
|
||||
.preview-body p, .preview-body small { margin: 0; color: #64748b; font-size: 0.78rem; }
|
||||
.preview-body label { display: grid; gap: 0.25rem; font-size: 0.78rem; color: #475569; }
|
||||
.preview-body input, .preview-body textarea, .preview-body select { border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.45rem 0.6rem; font: inherit; background: #f8fafc; }
|
||||
.send { border: 0; color: #fff; border-radius: var(--radius); min-height: var(--control-h); height: var(--control-h); font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; box-sizing: border-box; }
|
||||
.opts, .stars { color: #64748b; font-size: 0.75rem; display: grid; gap: 0.2rem; }
|
||||
.cover-box { position: relative; width: 100%; aspect-ratio: 3 / 1; max-height: 200px; border: 1.5px dashed #99f6e4; border-radius: var(--radius); background: #f0fdfa; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; overflow: hidden; display: grid; place-items: center; padding: 0; }
|
||||
.cover-box.has { border-style: solid; border-color: transparent; }
|
||||
.cover-box:disabled { cursor: progress; opacity: 0.75; }
|
||||
.cover-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||
.cover-empty { display: grid; gap: 0.25rem; justify-items: center; padding: 0.5rem; }
|
||||
.cover-empty small { font-weight: 500; font-size: 0.74rem; color: #64748b; }
|
||||
.cover-change { position: absolute; inset-inline-start: 0.5rem; bottom: 0.5rem; background: rgba(15,23,42,.65); color: #fff; font-size: 0.74rem; padding: 0.2rem 0.55rem; border-radius: 999px; opacity: 0; transition: opacity .15s; }
|
||||
.cover-box:hover .cover-change, .cover-box:disabled .cover-change { opacity: 1; }
|
||||
.title-card, .field-card, .submit-card, .adv-box { border: 1px solid #eef2f7; border-radius: var(--radius); padding: 0.8rem; display: grid; gap: 0.45rem; }
|
||||
.title { font: inherit; font-size: 1.1rem; font-weight: 700; color: #0f172a; border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.55rem 0.7rem; background: #fff; width: 100%; box-sizing: border-box; }
|
||||
.title:hover { border-color: #99f6e4; }
|
||||
.title:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,184,166,.15); }
|
||||
.title-label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 700; color: #64748b; }
|
||||
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: 0.88rem; font-weight: 700; color: #334155; }
|
||||
.color-pick { position: relative; }
|
||||
.swatch-btn { display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid #e2e8f0; background: #fff; border-radius: var(--radius); padding: 0.3rem 0.5rem; font: inherit; cursor: pointer; }
|
||||
.swatch-btn:hover { border-color: #99f6e4; }
|
||||
.swatch { width: 26px; height: 26px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(15,23,42,.12); }
|
||||
.hex { font-size: 0.8rem; color: #475569; font-family: ui-monospace, monospace; }
|
||||
.palette { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 30; width: 236px; background: #fff; border: 1px solid #e2e8f0; border-radius: var(--radius); box-shadow: 0 16px 40px rgba(15,23,42,.16); padding: 0.65rem; display: grid; gap: 0.6rem; }
|
||||
.presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.35rem; }
|
||||
.preset { width: 100%; aspect-ratio: 1; border: 0; border-radius: 8px; cursor: pointer; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 1px rgba(15,23,42,.1); }
|
||||
.preset.on { outline: 2px solid #0f172a; outline-offset: 2px; }
|
||||
.custom { display: flex; align-items: center; gap: 0.4rem; }
|
||||
.native { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; color: #475569; cursor: pointer; white-space: nowrap; }
|
||||
.palette-backdrop { position: fixed; inset: 0; z-index: 29; }
|
||||
.sheet-warn { font-size: 0.76rem; font-weight: 600; color: #b45309; }
|
||||
.fbody { cursor: pointer; min-width: 0; }
|
||||
.req { color: #ef4444; margin-inline-start: 0.15rem; }
|
||||
.submit-card .native input { width: 28px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
|
||||
.submit-card .hex-input { flex: 1; min-width: 0; padding: 0.35rem 0.5rem; font-family: ui-monospace, monospace; font-size: 0.82rem; }
|
||||
.palette-done { border: 0; background: var(--teal); color: #fff; border-radius: var(--radius); min-height: 32px; font: inherit; font-weight: 700; cursor: pointer; }
|
||||
.sheet-hint { font-size: 0.74rem; font-weight: 500; color: #94a3b8; }
|
||||
.sheet-error { margin: 0; color: #b91c1c; font-size: 0.84rem; }
|
||||
.title-card textarea, .submit-card input, .panel input, .panel select, .sheet input, .sheet select, .sheet textarea {
|
||||
border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.55rem 0.7rem; font: inherit; width: 100%;
|
||||
}
|
||||
.field-card { grid-template-columns: auto 1fr auto; align-items: center; cursor: grab; }
|
||||
.field-card small { color: #94a3b8; display: block; }
|
||||
.fops { display: flex; gap: 0.2rem; }
|
||||
.fops button { width: 30px; height: 30px; border: 0; border-radius: var(--radius); background: #f8fafc; cursor: pointer; color: #64748b; }
|
||||
.fops .danger { color: #dc2626; }
|
||||
.add-field { width: 100%; min-height: var(--control-h); height: var(--control-h); border: 1.5px dashed #14b8a6; background: #f0fdfa; color: #0f766e; border-radius: var(--radius); font: inherit; font-weight: 700; cursor: pointer; box-sizing: border-box; }
|
||||
.adv { background: none; border: 0; font: inherit; font-weight: 700; color: #0f766e; cursor: pointer; text-align: right; }
|
||||
.toolbox h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
|
||||
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-bottom: 1rem; }
|
||||
.tools button {
|
||||
border: 1px solid #eef2f7;
|
||||
background: #f8fafc;
|
||||
border-radius: var(--radius);
|
||||
min-height: 52px;
|
||||
padding: 0.35rem 0.4rem;
|
||||
font: inherit;
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
gap: 0.15rem;
|
||||
color: #334155;
|
||||
text-align: center;
|
||||
}
|
||||
.ready { margin-bottom: 0.35rem; }
|
||||
.ready-toggle {
|
||||
width: 100%;
|
||||
background: none;
|
||||
border: 0;
|
||||
text-align: right;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
padding: 0.45rem 0;
|
||||
cursor: pointer;
|
||||
color: #0f172a;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.ready-caret { color: #94a3b8; font-size: 0.85rem; }
|
||||
.ready-tools { margin: 0 0 0.65rem; }
|
||||
.panel { display: grid; gap: 0.7rem; }
|
||||
.panel label, .sheet label { display: grid; gap: 0.3rem; font-size: 0.88rem; font-weight: 700; color: #334155; }
|
||||
.chk { display: flex !important; align-items: center; gap: 0.4rem; font-weight: 600 !important; }
|
||||
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
|
||||
.chip { border: 1px solid #e2e8f0; background: #fff; border-radius: 999px; padding: 0.3rem 0.7rem; font: inherit; cursor: pointer; }
|
||||
.chip.on { background: #ccfbf1; border-color: #99f6e4; color: #0f766e; font-weight: 700; }
|
||||
.row { display: flex; gap: 0.4rem; align-items: stretch; }
|
||||
.row input { flex: 1; min-width: 0; }
|
||||
.sub { border-bottom: 1px solid #f1f5f9; padding: 0.5rem 0; }
|
||||
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: grid; place-items: center; z-index: 40; padding: 1rem; }
|
||||
.sheet { width: min(420px,100%); max-height: calc(100dvh - 2rem); overflow-y: auto; background: #fff; border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.65rem; box-sizing: border-box; }
|
||||
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
|
||||
.sheet-head h3 { margin: 0; }
|
||||
.sheet-actions { display: flex; gap: 0.5rem; }
|
||||
.sheet-actions .btn { flex: 1; }
|
||||
.x-btn { width: 36px; height: 36px; flex-shrink: 0; border: 1px solid #e2e8f0; border-radius: var(--radius); background: #fff; color: #64748b; display: grid; place-items: center; cursor: pointer; }
|
||||
.x-btn:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
|
||||
.link { background: none; border: 0; color: #0f766e; font: inherit; font-weight: 700; cursor: pointer; text-align: right; padding: 0; }
|
||||
.panel-title {
|
||||
margin: 0.2rem 0 0;
|
||||
padding-top: 0.55rem;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
font-size: 0.95rem;
|
||||
color: #0f766e;
|
||||
}
|
||||
.panel > .panel-title:first-child {
|
||||
border-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
.settings-panel {
|
||||
gap: 0.85rem;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
padding: 0;
|
||||
}
|
||||
.settings-card {
|
||||
background: #fff;
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: var(--radius);
|
||||
padding: 1rem 1.05rem;
|
||||
display: grid;
|
||||
gap: 0.85rem;
|
||||
box-shadow: 0 8px 22px rgba(15,23,42,.04);
|
||||
}
|
||||
.settings-card.optional {
|
||||
background: #f8fafc;
|
||||
border-style: dashed;
|
||||
}
|
||||
.settings-card-head h3 {
|
||||
margin: 0;
|
||||
font-size: 0.98rem;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
}
|
||||
.settings-card-head p {
|
||||
margin: 0.2rem 0 0;
|
||||
font-size: 0.8rem;
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
}
|
||||
.toggle-list { display: grid; gap: 0.45rem; }
|
||||
.toggle-row {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0.7rem 0.8rem;
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: var(--radius);
|
||||
background: #fff;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
.toggle-list.compact .toggle-row { padding: 0.55rem 0.7rem; }
|
||||
.toggle-row span {
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
min-width: 0;
|
||||
}
|
||||
.toggle-row strong {
|
||||
font-size: 0.9rem;
|
||||
color: #0f172a;
|
||||
font-weight: 700;
|
||||
}
|
||||
.toggle-row small {
|
||||
font-size: 0.75rem;
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.toggle-row input[type='checkbox'] {
|
||||
width: 1.15rem;
|
||||
height: 1.15rem;
|
||||
flex: 0 0 auto;
|
||||
accent-color: #14b8a6;
|
||||
cursor: pointer;
|
||||
}
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.75rem 0.85rem;
|
||||
}
|
||||
.settings-grid .field,
|
||||
.settings-card .field {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
font-size: 0.84rem;
|
||||
font-weight: 700;
|
||||
color: #334155;
|
||||
}
|
||||
.settings-grid .span-2 { grid-column: 1 / -1; }
|
||||
.settings-card .field input,
|
||||
.settings-card .field select,
|
||||
.settings-grid .field input,
|
||||
.settings-grid .field select {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.55rem 0.7rem;
|
||||
font: inherit;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
font-weight: 500;
|
||||
color: #0f172a;
|
||||
}
|
||||
.settings-empty {
|
||||
margin: 0;
|
||||
font-size: 0.8rem;
|
||||
color: #94a3b8;
|
||||
}
|
||||
.pipeline-field { margin-top: 0.15rem; }
|
||||
.settings-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
position: sticky;
|
||||
bottom: 0.5rem;
|
||||
padding-top: 0.25rem;
|
||||
}
|
||||
.settings-actions .btn { min-width: 160px; }
|
||||
.share-actions { display: flex; gap: 0.4rem; }
|
||||
.iframe-code { flex: 1; border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 0.55rem 0.7rem; font: inherit; width: 100%; resize: vertical; min-width: 0; }
|
||||
.row.col { flex-direction: column; align-items: stretch; }
|
||||
.crm-hint {
|
||||
margin: 0;
|
||||
color: #64748b;
|
||||
font-size: 0.85rem;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.65rem 0.75rem;
|
||||
}
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.85rem;
|
||||
}
|
||||
.stat {
|
||||
background: #f0fdfa;
|
||||
border: 1px solid #ccfbf1;
|
||||
border-radius: var(--radius);
|
||||
padding: 0.6rem 0.55rem;
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
text-align: center;
|
||||
}
|
||||
.stat b { font-size: 1.05rem; color: #0f766e; }
|
||||
.stat span { font-size: 0.72rem; color: #64748b; line-height: 1.3; }
|
||||
.publish-sheet { width: min(520px, 100%); gap: 0.75rem; max-height: calc(100vh - 2rem); overflow: auto; }
|
||||
.publish-head { display: flex; justify-content: space-between; align-items: center; }
|
||||
.publish-preview {
|
||||
display: grid;
|
||||
grid-template-columns: 72px 1fr;
|
||||
gap: 0.75rem;
|
||||
align-items: center;
|
||||
padding: 0.65rem;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
.publish-preview h4 { margin: 0 0 0.25rem; }
|
||||
.publish-preview p { margin: 0 0 0.35rem; color: #64748b; font-size: 0.82rem; }
|
||||
.publish-preview a { color: #0f766e; font-weight: 700; font-size: 0.85rem; }
|
||||
.mini-cover {
|
||||
width: 108px;
|
||||
aspect-ratio: 3 / 1;
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
.mini-cover img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.publish-qr { justify-self: start; border-radius: 8px; border: 1px solid #eef2f7; }
|
||||
@media (max-width: 1100px) {
|
||||
.workspace { grid-template-columns: 1fr; }
|
||||
.preview-col { order: 3; }
|
||||
.toolbox { order: 1; }
|
||||
.canvas { order: 2; }
|
||||
.tools { grid-template-columns: repeat(3, 1fr); }
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.top-ghosts {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.45rem;
|
||||
width: 100%;
|
||||
}
|
||||
.top-ghosts :deep(.ui-btn) { width: 100%; }
|
||||
.tabs { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.publish-preview { grid-template-columns: 56px 1fr; }
|
||||
.mini-cover { width: 84px; }
|
||||
.settings-grid { grid-template-columns: 1fr; }
|
||||
.settings-grid .span-2 { grid-column: auto; }
|
||||
.settings-card { padding: 0.85rem; }
|
||||
.toggle-row { align-items: flex-start; }
|
||||
.settings-actions { justify-content: stretch; }
|
||||
.settings-actions .btn { width: 100%; min-width: 0; }
|
||||
}
|
||||
</style>
|
||||
|
||||
+545
-380
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,12 @@ import {
|
||||
} from '@ant-design/icons-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { CompanyDto, CreatePersonRequest, PersonDto, PersonGender, PersonMood } from '@mento/shared';
|
||||
import { PERSON_GENDER_LABELS, PERSON_GENDERS, splitPersonHonorific } from '@mento/shared';
|
||||
import {
|
||||
ACTIVITY_EXPERIENCE_OPTIONS,
|
||||
PERSON_GENDER_LABELS,
|
||||
PERSON_GENDERS,
|
||||
splitPersonHonorific,
|
||||
} from '@mento/shared';
|
||||
import { PERSON_MOOD_LABELS, PERSON_MOODS } from '@/lib/person-mood';
|
||||
import { formatLocalDateInput, toFaDigits } from '@/lib/jalali';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
@@ -97,6 +102,7 @@ const website = ref('');
|
||||
const instagram = ref('');
|
||||
const birthDate = ref('');
|
||||
const referrer = ref('');
|
||||
const activityExperience = ref('');
|
||||
const nationalId = ref('');
|
||||
const city = ref('');
|
||||
const rasteh = ref('');
|
||||
@@ -279,6 +285,7 @@ function fill(p: PersonDto) {
|
||||
instagram.value = p.instagram ?? '';
|
||||
birthDate.value = p.birthDate ? formatLocalDateInput(new Date(p.birthDate)) : '';
|
||||
referrer.value = p.referrer ?? '';
|
||||
activityExperience.value = p.activityExperience ?? '';
|
||||
addresses.value = p.addresses?.length ? [...p.addresses] : [''];
|
||||
notes.value = p.notes ?? '';
|
||||
tagsRaw.value = (p.tags ?? []).join('، ');
|
||||
@@ -382,6 +389,7 @@ function payload(): CreatePersonRequest {
|
||||
instagram: instagram.value || undefined,
|
||||
birthDate: birthDate.value || null,
|
||||
referrer: referrer.value || undefined,
|
||||
activityExperience: activityExperience.value || null,
|
||||
addresses: addresses.value.map((a) => a.trim()).filter(Boolean),
|
||||
notes: notes.value || undefined,
|
||||
tags: parseTags(tagsRaw.value),
|
||||
@@ -570,6 +578,20 @@ onMounted(load);
|
||||
<a-input v-model:value="referrer" placeholder="نام معرف" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="سابقه فعالیت">
|
||||
<a-select
|
||||
v-model:value="activityExperience"
|
||||
allow-clear
|
||||
placeholder="اختیاری"
|
||||
style="width: 100%"
|
||||
:options="[
|
||||
{ value: '', label: '—' },
|
||||
...ACTIVITY_EXPERIENCE_OPTIONS.map((value) => ({ value, label: value })),
|
||||
]"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="کد ملی">
|
||||
<a-input v-model:value="nationalId" dir="ltr" placeholder="کد ملی (تهحساب)" />
|
||||
|
||||
@@ -454,6 +454,7 @@ const infoEmpty = computed(() => {
|
||||
!p.position &&
|
||||
!p.website &&
|
||||
!p.instagram &&
|
||||
!p.activityExperience &&
|
||||
!p.birthDate &&
|
||||
!p.referrer &&
|
||||
!nationalIdLabel.value &&
|
||||
@@ -829,6 +830,10 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
||||
<dt>اینستاگرام</dt>
|
||||
<dd dir="ltr">{{ person.instagram }}</dd>
|
||||
</div>
|
||||
<div v-if="person.activityExperience" class="fact">
|
||||
<dt>سابقه فعالیت</dt>
|
||||
<dd>{{ person.activityExperience }}</dd>
|
||||
</div>
|
||||
<div v-if="person.addresses?.length" class="fact wide">
|
||||
<dt>آدرسها</dt>
|
||||
<dd>
|
||||
@@ -1145,6 +1150,7 @@ watch(() => route.query.tab, readTab, { immediate: true });
|
||||
<div><dt>نام قبلی</dt><dd>{{ person.previousFullName || '—' }}</dd></div>
|
||||
<div><dt>وبسایت</dt><dd>{{ person.website || '—' }}</dd></div>
|
||||
<div><dt>اینستاگرام</dt><dd dir="ltr">{{ person.instagram || '—' }}</dd></div>
|
||||
<div><dt>سابقه فعالیت</dt><dd>{{ person.activityExperience || '—' }}</dd></div>
|
||||
<div><dt>معرف</dt><dd>{{ person.referrer || '—' }}</dd></div>
|
||||
<div>
|
||||
<dt>کد ملی</dt>
|
||||
|
||||
+913
-273
File diff suppressed because it is too large
Load Diff
@@ -86,6 +86,7 @@ const PERMISSION_MODULES: Partial<Record<RolePermissionKey, OrgModuleKey[]>> = {
|
||||
treasury_reports: ['treasury'],
|
||||
treasury_audit: ['treasury'],
|
||||
treasury_categories: ['treasury'],
|
||||
treasury_documents_manage: ['treasury'],
|
||||
behavior: ['behavior'],
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ import type { TableColumnsType } from 'ant-design-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { FinancialAccountDto, FinancialMovementDto } from '@mento/shared';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
@@ -43,6 +45,15 @@ const busy = ref(false);
|
||||
|
||||
const isMobile = useTreasuryMobile();
|
||||
const AListItem = AList.Item;
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => items.value, 'treasury.account-ledger');
|
||||
const columns: TableColumnsType<FinancialMovementDto> = [
|
||||
{
|
||||
title: 'تاریخ',
|
||||
@@ -196,7 +207,7 @@ onUnmounted(() => {
|
||||
|
||||
<a-divider orientation="right">گردش حساب</a-divider>
|
||||
<a-empty v-if="!items.length" description="گردشی ثبت نشده است." />
|
||||
<a-list v-else-if="isMobile" :data-source="items">
|
||||
<a-list v-else-if="isMobile" :data-source="pagedRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-card :title="formatJalaliNumeric(new Date(item.occurredAt))" style="width: 100%">
|
||||
@@ -220,11 +231,19 @@ onUnmounted(() => {
|
||||
<a-table
|
||||
v-else-if="items.length"
|
||||
:columns="columns"
|
||||
:data-source="items"
|
||||
:data-source="pagedRows"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
:scroll="{ x: true }"
|
||||
/>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -26,7 +26,9 @@ import { api } from '@/lib/api';
|
||||
import type { FinancialAccountDto, FinancialAccountType, OrgUserDto } from '@mento/shared';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
|
||||
@@ -40,6 +42,15 @@ const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const users = ref<OrgUserDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total: listTotal,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => accounts.value, 'treasury.accounts');
|
||||
const openForm = ref(false);
|
||||
const editingId = ref<string | null>(null);
|
||||
const responsibleKey = ref<string | undefined>(undefined);
|
||||
@@ -422,7 +433,7 @@ onMounted(() => {
|
||||
|
||||
<a-divider orientation="right">فهرست حسابها</a-divider>
|
||||
<a-empty v-if="!accounts.length" description="حسابی ثبت نشده است." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="accounts">
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -444,6 +455,14 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="listTotal"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -9,7 +9,9 @@ import {
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
|
||||
const { Paragraph: ATypographyParagraph } = Typography;
|
||||
const AListItem = AList.Item;
|
||||
@@ -26,6 +28,15 @@ type Row = {
|
||||
|
||||
const rows = ref<Row[]>([]);
|
||||
const error = ref('');
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => rows.value, 'treasury.audit');
|
||||
const actionLabel: Record<string, string> = {
|
||||
settle: 'تسویه سند',
|
||||
cash_post: 'نشستن وجه در حساب',
|
||||
@@ -47,7 +58,7 @@ onMounted(async () => {
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-empty v-if="!error && !rows.length" description="سابقهای نیست." />
|
||||
<a-list v-else item-layout="vertical" :data-source="rows">
|
||||
<a-list v-else item-layout="vertical" :data-source="pagedRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-list-item-meta>
|
||||
@@ -67,6 +78,14 @@ onMounted(async () => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { FinancialCategoryDto } from '@mento/shared';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
@@ -42,6 +44,26 @@ const edit = ref({ id: '', name: '', isActive: true });
|
||||
const incomeRows = computed(() => rows.value.filter((row) => row.kind === 'income'));
|
||||
const expenseRows = computed(() => rows.value.filter((row) => row.kind === 'expense'));
|
||||
|
||||
const {
|
||||
page: incomePage,
|
||||
pageSize: incomePageSize,
|
||||
pageSizeOptions: incomePageSizeOptions,
|
||||
total: incomeTotal,
|
||||
pagedRows: pagedIncomeRows,
|
||||
onPageSizeChange: onIncomePageSizeChange,
|
||||
showTotal: incomeShowTotal,
|
||||
} = useTreasuryListPaging(() => incomeRows.value, 'treasury.categories-income');
|
||||
|
||||
const {
|
||||
page: expensePage,
|
||||
pageSize: expensePageSize,
|
||||
pageSizeOptions: expensePageSizeOptions,
|
||||
total: expenseTotal,
|
||||
pagedRows: pagedExpenseRows,
|
||||
onPageSizeChange: onExpensePageSizeChange,
|
||||
showTotal: expenseShowTotal,
|
||||
} = useTreasuryListPaging(() => expenseRows.value, 'treasury.categories-expense');
|
||||
|
||||
function apiMessage(e: unknown) {
|
||||
if (!axios.isAxiosError(e)) return 'ذخیره ناموفق بود.';
|
||||
const msg = (e.response?.data as { message?: string | string[] })?.message;
|
||||
@@ -153,7 +175,11 @@ onMounted(() => {
|
||||
|
||||
<a-divider orientation="right">درآمد</a-divider>
|
||||
<a-empty v-if="!incomeRows.length" description="دسته درآمدی نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="incomeRows">
|
||||
<a-list
|
||||
v-else
|
||||
:item-layout="isMobile ? 'vertical' : 'horizontal'"
|
||||
:data-source="pagedIncomeRows"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -175,10 +201,22 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="incomePage"
|
||||
:total="incomeTotal"
|
||||
:page-size="incomePageSize"
|
||||
:page-size-options="incomePageSizeOptions"
|
||||
:show-total="incomeShowTotal"
|
||||
@update:page-size="onIncomePageSizeChange"
|
||||
/>
|
||||
|
||||
<a-divider orientation="right">هزینه</a-divider>
|
||||
<a-empty v-if="!expenseRows.length" description="دسته هزینهای نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="expenseRows">
|
||||
<a-list
|
||||
v-else
|
||||
:item-layout="isMobile ? 'vertical' : 'horizontal'"
|
||||
:data-source="pagedExpenseRows"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -200,6 +238,14 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="expensePage"
|
||||
:total="expenseTotal"
|
||||
:page-size="expensePageSize"
|
||||
:page-size-options="expensePageSizeOptions"
|
||||
:show-total="expenseShowTotal"
|
||||
@update:page-size="onExpensePageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
|
||||
<a-modal
|
||||
|
||||
@@ -6,15 +6,21 @@ import type { FinancialAccountDto, FinancialCategoryDto, FinancialDocumentDto }
|
||||
import { UiButton, UiCard, UiField, UiInput, UiPageHeader } from '@/components/ui';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import TreasuryNav from '@/components/treasury/TreasuryNav.vue';
|
||||
import { FormFileTooLargeError, prepareFormFieldFile } from '@/lib/form-file-compress';
|
||||
import { toman } from './treasury-format';
|
||||
|
||||
const props = defineProps<{ kind: 'income' | 'expense' }>();
|
||||
const PHOTO_LIMIT = 8;
|
||||
type PendingPhoto = { localId: string; name: string; dataUrl: string; file: File };
|
||||
|
||||
const rows = ref<FinancialDocumentDto[]>([]);
|
||||
const categories = ref<FinancialCategoryDto[]>([]);
|
||||
const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const photoBusy = ref(false);
|
||||
const pendingPhotos = ref<PendingPhoto[]>([]);
|
||||
const q = ref('');
|
||||
const form = ref({
|
||||
title: '',
|
||||
@@ -43,6 +49,76 @@ function apiMessage(e: unknown) {
|
||||
return Array.isArray(msg) ? msg.join('، ') : msg || 'ذخیره ناموفق بود.';
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = {
|
||||
title: '',
|
||||
amount: '',
|
||||
categoryId: '',
|
||||
partyName: '',
|
||||
accountId: '',
|
||||
settleAmount: '',
|
||||
method: 'transfer',
|
||||
reference: '',
|
||||
notes: '',
|
||||
};
|
||||
pendingPhotos.value = [];
|
||||
}
|
||||
|
||||
async function prepareTreasuryImage(file: File) {
|
||||
if (!file.type.startsWith('image/')) {
|
||||
throw new Error('فقط فایل تصویری مجاز است.');
|
||||
}
|
||||
try {
|
||||
return await prepareFormFieldFile(file);
|
||||
} catch (e) {
|
||||
if (e instanceof FormFileTooLargeError) {
|
||||
throw new Error('حجم عکس باید زیر ۲۰۰ کیلوبایت باشد');
|
||||
}
|
||||
throw new Error('فشردهسازی عکس ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
async function onPhotosPicked(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const files = Array.from(input.files ?? []);
|
||||
input.value = '';
|
||||
if (!files.length) return;
|
||||
error.value = '';
|
||||
for (const file of files) {
|
||||
if (pendingPhotos.value.length >= PHOTO_LIMIT) {
|
||||
error.value = `حداکثر ${PHOTO_LIMIT} عکس برای هر سند.`;
|
||||
break;
|
||||
}
|
||||
photoBusy.value = true;
|
||||
try {
|
||||
const prepared = await prepareTreasuryImage(file);
|
||||
pendingPhotos.value = [
|
||||
...pendingPhotos.value,
|
||||
{
|
||||
localId: crypto.randomUUID(),
|
||||
name: prepared.name,
|
||||
dataUrl: prepared.dataUrl,
|
||||
file: prepared.file,
|
||||
},
|
||||
];
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : 'افزودن عکس ناموفق بود.';
|
||||
} finally {
|
||||
photoBusy.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removePendingPhoto(localId: string) {
|
||||
pendingPhotos.value = pendingPhotos.value.filter((photo) => photo.localId !== localId);
|
||||
}
|
||||
|
||||
async function uploadPreparedFile(documentId: string, file: File) {
|
||||
const body = new FormData();
|
||||
body.append('file', file);
|
||||
await api.post(`/treasury/documents/${documentId}/attachments`, body);
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const [docs, cats, acc] = await Promise.all([
|
||||
api.get<FinancialDocumentDto[]>('/treasury/documents', { params: { kind: props.kind, q: q.value || undefined } }),
|
||||
@@ -59,7 +135,7 @@ async function createDoc() {
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
try {
|
||||
await api.post('/treasury/documents', {
|
||||
const { data } = await api.post<FinancialDocumentDto>('/treasury/documents', {
|
||||
kind: props.kind,
|
||||
title: form.value.title,
|
||||
amount: form.value.amount,
|
||||
@@ -71,18 +147,22 @@ async function createDoc() {
|
||||
reference: form.value.reference || null,
|
||||
notes: form.value.notes || null,
|
||||
});
|
||||
form.value = {
|
||||
title: '',
|
||||
amount: '',
|
||||
categoryId: '',
|
||||
partyName: '',
|
||||
accountId: '',
|
||||
settleAmount: '',
|
||||
method: 'transfer',
|
||||
reference: '',
|
||||
notes: '',
|
||||
};
|
||||
ok.value = 'سند ثبت شد. اگر مبلغ دریافت/پرداخت صفر باشد موجودی حساب تغییر نمیکند.';
|
||||
const photos = [...pendingPhotos.value];
|
||||
let attached = 0;
|
||||
for (const photo of photos) {
|
||||
try {
|
||||
await uploadPreparedFile(data.id, photo.file);
|
||||
attached += 1;
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
resetForm();
|
||||
ok.value =
|
||||
attached > 0
|
||||
? `سند ثبت شد و ${attached} عکس پیوست شد.`
|
||||
: 'سند ثبت شد. اگر مبلغ دریافت/پرداخت صفر باشد موجودی حساب تغییر نمیکند.';
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
@@ -115,16 +195,22 @@ async function downloadAttachment(id: string, fileName: string) {
|
||||
}
|
||||
|
||||
async function upload(id: string, event: Event) {
|
||||
const file = (event.target as HTMLInputElement).files?.[0];
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = '';
|
||||
if (!file) return;
|
||||
const body = new FormData();
|
||||
body.append('file', file);
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
photoBusy.value = true;
|
||||
try {
|
||||
await api.post(`/treasury/documents/${id}/attachments`, body);
|
||||
ok.value = 'پیوست ذخیره شد.';
|
||||
const prepared = await prepareTreasuryImage(file);
|
||||
await uploadPreparedFile(id, prepared.file);
|
||||
ok.value = 'عکس پیوست ذخیره شد.';
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
error.value = e instanceof Error && !(axios.isAxiosError(e)) ? e.message : apiMessage(e);
|
||||
} finally {
|
||||
photoBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +225,9 @@ async function voidDoc(id: string) {
|
||||
}
|
||||
|
||||
watch(() => props.kind, () => {
|
||||
resetForm();
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
void load();
|
||||
});
|
||||
|
||||
@@ -184,8 +273,30 @@ onMounted(() => {
|
||||
</UiField>
|
||||
<UiField label="پیگیری"><UiInput v-model="form.reference" /></UiField>
|
||||
</div>
|
||||
<UiButton :loading="saving" @click="createDoc">ثبت</UiButton>
|
||||
<UiButton variant="secondary" @click="downloadExcel">خروجی اکسل</UiButton>
|
||||
<div class="photos">
|
||||
<div class="photos-head">
|
||||
<strong>عکس فاکتور / رسید</strong>
|
||||
<small>اختیاری · فشردهسازی خودکار · حداکثر ۲۰۰ کیلوبایت برای هر عکس · تا {{ PHOTO_LIMIT }} عکس</small>
|
||||
</div>
|
||||
<div v-if="pendingPhotos.length" class="thumbs">
|
||||
<figure v-for="photo in pendingPhotos" :key="photo.localId">
|
||||
<img :src="photo.dataUrl" :alt="photo.name" />
|
||||
<button type="button" :disabled="saving || photoBusy" @click="removePendingPhoto(photo.localId)">حذف</button>
|
||||
</figure>
|
||||
</div>
|
||||
<label class="add-photo" :class="{ busy: photoBusy || saving || pendingPhotos.length >= PHOTO_LIMIT }">
|
||||
{{ photoBusy ? 'در حال آمادهسازی…' : 'افزودن عکس' }}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
:disabled="saving || photoBusy || pendingPhotos.length >= PHOTO_LIMIT"
|
||||
@change="onPhotosPicked"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<UiButton :loading="saving || photoBusy" @click="createDoc">ثبت</UiButton>
|
||||
<UiButton variant="secondary" :disabled="saving || photoBusy" @click="downloadExcel">خروجی اکسل</UiButton>
|
||||
</UiCard>
|
||||
<UiField label="جستجو"><UiInput v-model="q" @change="load" /></UiField>
|
||||
<div class="list">
|
||||
@@ -210,9 +321,9 @@ onMounted(() => {
|
||||
>
|
||||
{{ file.fileName }}
|
||||
</button>
|
||||
<label v-if="row.status !== 'void'" class="file">
|
||||
پیوست
|
||||
<input type="file" @change="upload(row.id, $event)" />
|
||||
<label v-if="row.status !== 'void'" class="file" :class="{ busy: photoBusy }">
|
||||
{{ photoBusy ? '…' : 'عکس پیوست' }}
|
||||
<input type="file" accept="image/*" :disabled="photoBusy || saving" @change="upload(row.id, $event)" />
|
||||
</label>
|
||||
</div>
|
||||
</article>
|
||||
@@ -231,7 +342,51 @@ onMounted(() => {
|
||||
.side { display: grid; justify-items: end; gap: 0.3rem; }
|
||||
.side button, .file { border: 0; background: transparent; color: #b91c1c; cursor: pointer; font: inherit; }
|
||||
.file { color: #0f766e; font-weight: 700; }
|
||||
.file.busy { opacity: 0.6; pointer-events: none; }
|
||||
.file input { display: none; }
|
||||
.photos { display: grid; gap: 0.55rem; margin-bottom: 0.85rem; }
|
||||
.photos-head { display: grid; gap: 0.15rem; }
|
||||
.photos-head small { color: #64748b; font-size: 0.82rem; }
|
||||
.thumbs { display: flex; flex-wrap: wrap; gap: 0.55rem; }
|
||||
.thumbs figure {
|
||||
margin: 0;
|
||||
width: 88px;
|
||||
display: grid;
|
||||
gap: 0.25rem;
|
||||
justify-items: center;
|
||||
}
|
||||
.thumbs img {
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
object-fit: cover;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
.thumbs button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #b91c1c;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.add-photo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: fit-content;
|
||||
min-height: var(--control-h);
|
||||
padding: 0 0.9rem;
|
||||
border: 1px dashed #94a3b8;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
color: #0f766e;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
.add-photo.busy { opacity: 0.55; pointer-events: none; }
|
||||
.add-photo input { display: none; }
|
||||
.err { color: #b91c1c; font-weight: 700; }
|
||||
.ok { color: #0f766e; font-weight: 700; }
|
||||
</style>
|
||||
|
||||
@@ -6,13 +6,10 @@ import {
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Input as AInput,
|
||||
List as AList,
|
||||
Row as ARow,
|
||||
Segmented as ASegmented,
|
||||
Select as ASelect,
|
||||
@@ -30,16 +27,20 @@ import type {
|
||||
} from '@mento/shared';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import TreasuryDocPhotoField from '@/components/treasury/TreasuryDocPhotoField.vue';
|
||||
import TreasuryDocumentsPanel from '@/components/treasury/TreasuryDocumentsPanel.vue';
|
||||
import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue';
|
||||
import TreasuryPartySelect from '@/components/treasury/TreasuryPartySelect.vue';
|
||||
import { useSettleDefault } from '@/components/treasury/useSettleDefault';
|
||||
import { partyNetPosition, toman } from './treasury-format';
|
||||
import {
|
||||
uploadTreasuryDocumentPhotos,
|
||||
type TreasuryPendingPhoto,
|
||||
} from '@/lib/treasury-doc-photos';
|
||||
import { accountBalanceTone, partyNetPosition, toman } from './treasury-format';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const AListItem = AList.Item;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
const ASelectOption = ASelect.Option;
|
||||
|
||||
const isMobile = useTreasuryMobile();
|
||||
@@ -52,6 +53,7 @@ const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const pendingPhotos = ref<TreasuryPendingPhoto[]>([]);
|
||||
const q = ref('');
|
||||
const form = ref({
|
||||
title: '',
|
||||
@@ -95,17 +97,6 @@ function apiMessage(e: unknown) {
|
||||
return Array.isArray(msg) ? msg.join('، ') : msg || 'ذخیره ناموفق بود.';
|
||||
}
|
||||
|
||||
function docLine(item: FinancialDocumentDto) {
|
||||
const parts = [
|
||||
item.reference ? `پیگیری ${item.reference}` : '',
|
||||
item.partyName || 'بدون طرف حساب',
|
||||
statusLabel[item.status] ?? item.status,
|
||||
`مانده ${toman(item.remaining)}`,
|
||||
].filter(Boolean);
|
||||
if (item.categoryName) parts.push(item.categoryName);
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const [docs, cats, acc, bals, receivables] = await Promise.all([
|
||||
api.get<FinancialDocumentDto[]>('/treasury/documents', { params: { kind, q: q.value || undefined } }),
|
||||
@@ -202,7 +193,17 @@ async function createDoc() {
|
||||
notes: form.value.notes || null,
|
||||
bookedAt: form.value.bookedAt || undefined,
|
||||
});
|
||||
const photos = [...pendingPhotos.value];
|
||||
let attached = 0;
|
||||
if (photos.length) {
|
||||
try {
|
||||
attached = await uploadTreasuryDocumentPhotos(data.id, photos);
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
}
|
||||
}
|
||||
settleMirror.reset();
|
||||
pendingPhotos.value = [];
|
||||
form.value = {
|
||||
title: '',
|
||||
amount: '',
|
||||
@@ -215,11 +216,12 @@ async function createDoc() {
|
||||
notes: '',
|
||||
bookedAt: formatLocalDateInput(new Date()),
|
||||
};
|
||||
ok.value = collectsBalance
|
||||
const base = collectsBalance
|
||||
? `${toman(settleAmount)} از ماندهٔ طرف حساب کم شد.`
|
||||
: data.reference
|
||||
? `سند ثبت شد. شماره پیگیری: ${data.reference}`
|
||||
: 'سند ثبت شد.';
|
||||
ok.value = attached > 0 ? `${base} ${attached} عکس پیوست شد.` : base;
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
@@ -279,15 +281,13 @@ const partyPosition = computed(() => {
|
||||
return partyNetPosition(receivable, payable);
|
||||
});
|
||||
|
||||
async function voidDoc(id: string) {
|
||||
if (!window.confirm('این سند و گردش متصل به آن باطل شود؟')) return;
|
||||
try {
|
||||
await api.post(`/treasury/documents/${id}/void`, { reason: 'ابطال توسط مدیر' });
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
}
|
||||
}
|
||||
const selectedAccountBalance = computed(() => {
|
||||
const id = form.value.accountId;
|
||||
if (!id) return null;
|
||||
const account = accounts.value.find((row) => row.id === id);
|
||||
if (!account) return null;
|
||||
return accountBalanceTone(account.balance);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
void load().catch(() => {
|
||||
@@ -298,190 +298,165 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" />
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-flex align="center" justify="space-between" wrap="wrap" gap="small">
|
||||
<a-typography-text strong>سند جدید</a-typography-text>
|
||||
<a-segmented v-model:value="entryMode" :options="entryOptions" />
|
||||
</a-flex>
|
||||
<a-form
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
@finish="createDoc"
|
||||
@finishFailed="onFinishFailed"
|
||||
>
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="طرف حساب" name="partyKind" :rules="partyRules">
|
||||
<a-row :gutter="8" align="middle">
|
||||
<a-col :span="partyPosition ? 16 : 24">
|
||||
<TreasuryPartySelect
|
||||
v-model:kind="form.partyKind"
|
||||
v-model:party-id="form.partyId"
|
||||
:allow-other="!isSettlement"
|
||||
:placeholder="isSettlement ? 'مشتری، شرکت یا کاربر' : undefined"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col v-if="partyPosition" :span="8">
|
||||
<a-typography-text :type="partyPosition.type">{{ partyPosition.text }}</a-typography-text>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="عنوان"
|
||||
name="title"
|
||||
:rules="[{ required: true, message: 'عنوان الزامی است' }]"
|
||||
<a-card :bordered="false" title="سند جدید">
|
||||
<template #extra>
|
||||
<a-segmented v-model:value="entryMode" :options="entryOptions" />
|
||||
</template>
|
||||
<a-form
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
@finish="createDoc"
|
||||
@finishFailed="onFinishFailed"
|
||||
>
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="طرف حساب" name="partyKind" :rules="partyRules">
|
||||
<a-row :gutter="8" align="middle">
|
||||
<a-col :span="partyPosition ? 16 : 24">
|
||||
<TreasuryPartySelect
|
||||
v-model:kind="form.partyKind"
|
||||
v-model:party-id="form.partyId"
|
||||
:allow-other="!isSettlement"
|
||||
:placeholder="isSettlement ? 'مشتری، شرکت یا کاربر' : undefined"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col v-if="partyPosition" :span="8">
|
||||
<a-typography-text :type="partyPosition.type">{{ partyPosition.text }}</a-typography-text>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="عنوان"
|
||||
name="title"
|
||||
:rules="[{ required: true, message: 'عنوان الزامی است' }]"
|
||||
>
|
||||
<a-input v-model:value="form.title" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item
|
||||
label="مبلغ کل"
|
||||
name="amount"
|
||||
:rules="[{ required: true, message: 'مبلغ الزامی است' }]"
|
||||
>
|
||||
<MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item
|
||||
:label="settleLabel"
|
||||
name="settleAmount"
|
||||
:rules="isSettlement ? [{ required: true, message: 'مبلغ را وارد کنید' }] : []"
|
||||
>
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
v-model="form.settleAmount"
|
||||
:decimals="0"
|
||||
:disabled="!isSettlement && form.partyKind === 'other'"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="مانده این سند">
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
:model-value="remainingAmount"
|
||||
:decimals="0"
|
||||
disabled
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="دستهبندی" name="categoryId">
|
||||
<a-select
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
v-model:value="form.categoryId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="بدون دسته"
|
||||
>
|
||||
<a-input v-model:value="form.title" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item
|
||||
label="مبلغ کل"
|
||||
name="amount"
|
||||
:rules="[{ required: true, message: 'مبلغ الزامی است' }]"
|
||||
>
|
||||
<MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item
|
||||
:label="settleLabel"
|
||||
name="settleAmount"
|
||||
:rules="isSettlement ? [{ required: true, message: 'مبلغ را وارد کنید' }] : []"
|
||||
>
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
v-model="form.settleAmount"
|
||||
:decimals="0"
|
||||
:disabled="!isSettlement && form.partyKind === 'other'"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item label="مانده این سند">
|
||||
<a-typography-text>{{ toman(remainingAmount) }}</a-typography-text>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item label="دستهبندی" name="categoryId">
|
||||
<a-select show-search option-filter-prop="label"
|
||||
v-model:value="form.categoryId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="بدون دسته"
|
||||
>
|
||||
<a-select-option v-for="cat in categories" :key="cat.id" :value="cat.id" :label="cat.name">
|
||||
{{ cat.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="حساب" name="accountId" :rules="accountRules">
|
||||
<a-select show-search option-filter-prop="label"
|
||||
v-model:value="form.accountId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="انتخاب حساب"
|
||||
>
|
||||
<a-select-option v-for="account in accounts" :key="account.id" :value="account.id" :label="account.name">
|
||||
{{ account.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="روش" name="method">
|
||||
<a-select show-search option-filter-prop="label" v-model:value="form.method" style="width: 100%">
|
||||
<a-select-option v-for="opt in methodOptions" :key="opt.value" :value="opt.value" :label="opt.label">
|
||||
{{ opt.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="تاریخ" name="bookedAt">
|
||||
<JalaliDateInput v-model="form.bookedAt" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :span="24">
|
||||
<a-form-item label="توضیحات" name="notes">
|
||||
<a-input v-model:value="form.notes" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-button type="primary" html-type="submit" :block="isMobile" :loading="saving">ثبت</a-button>
|
||||
</a-form>
|
||||
|
||||
<a-divider orientation="right">مانده پرداختنی</a-divider>
|
||||
<TreasuryPartyBalanceTable :rows="balances" settled-label="پرداختشده" />
|
||||
|
||||
<a-divider orientation="right">فهرست اسناد</a-divider>
|
||||
<a-form layout="vertical">
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="جستجو">
|
||||
<a-input
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
placeholder="عنوان یا شماره پیگیری"
|
||||
@press-enter="load"
|
||||
@change="load"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
|
||||
<a-empty v-if="!rows.length" description="سندی نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="rows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template v-if="!isMobile" #actions>
|
||||
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
|
||||
<a-button
|
||||
v-if="item.status !== 'void'"
|
||||
type="link"
|
||||
danger
|
||||
@click="voidDoc(item.id)"
|
||||
>
|
||||
ابطال
|
||||
</a-button>
|
||||
</template>
|
||||
<a-flex v-if="isMobile" vertical :gap="4" style="width: 100%">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8">
|
||||
<a-typography-text strong>{{ item.title }}</a-typography-text>
|
||||
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
|
||||
</a-flex>
|
||||
<a-typography-text type="secondary">
|
||||
{{ item.partyName || 'بدون طرف حساب' }} · {{ statusLabel[item.status] ?? item.status }}
|
||||
</a-typography-text>
|
||||
<a-typography-text v-if="item.reference" type="secondary">پیگیری {{ item.reference }}</a-typography-text>
|
||||
<a-typography-text v-if="item.categoryName" type="secondary">{{ item.categoryName }}</a-typography-text>
|
||||
<a-flex justify="space-between" align="center">
|
||||
<a-typography-text>مانده {{ toman(item.remaining) }}</a-typography-text>
|
||||
<a-button
|
||||
v-if="item.status !== 'void'"
|
||||
type="link"
|
||||
danger
|
||||
@click="voidDoc(item.id)"
|
||||
<a-select-option v-for="cat in categories" :key="cat.id" :value="cat.id" :label="cat.name">
|
||||
{{ cat.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item name="accountId" :rules="accountRules">
|
||||
<template #label>
|
||||
<a-flex align="center" justify="space-between" gap="small" style="width: 100%">
|
||||
<span>حساب</span>
|
||||
<a-typography-text
|
||||
v-if="selectedAccountBalance"
|
||||
:type="selectedAccountBalance.type"
|
||||
>
|
||||
ابطال
|
||||
</a-button>
|
||||
{{ selectedAccountBalance.text }}
|
||||
</a-typography-text>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
<a-list-item-meta v-else>
|
||||
<template #title>{{ item.title }}</template>
|
||||
<template #description>{{ docLine(item) }}</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-card>
|
||||
</template>
|
||||
<a-select
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
v-model:value="form.accountId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="انتخاب حساب"
|
||||
>
|
||||
<a-select-option v-for="account in accounts" :key="account.id" :value="account.id" :label="account.name">
|
||||
{{ account.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="روش" name="method">
|
||||
<a-select show-search option-filter-prop="label" v-model:value="form.method" style="width: 100%">
|
||||
<a-select-option v-for="opt in methodOptions" :key="opt.value" :value="opt.value" :label="opt.label">
|
||||
{{ opt.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="تاریخ" name="bookedAt">
|
||||
<JalaliDateInput v-model="form.bookedAt" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="توضیحات" name="notes">
|
||||
<a-input v-model:value="form.notes" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="عکس فاکتور / رسید">
|
||||
<TreasuryDocPhotoField v-model="pendingPhotos" :disabled="saving" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" :block="isMobile" :loading="saving">ثبت</a-button>
|
||||
</a-space>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<a-card :bordered="false" title="مانده پرداختنی">
|
||||
<TreasuryPartyBalanceTable :rows="balances" settled-label="پرداختشده" />
|
||||
</a-card>
|
||||
|
||||
<TreasuryDocumentsPanel
|
||||
v-model:q="q"
|
||||
:rows="rows"
|
||||
:categories="categories"
|
||||
:status-label="statusLabel"
|
||||
@reload="load"
|
||||
/>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -14,7 +14,9 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import { api } from '@/lib/api';
|
||||
import type { TreasuryDashboardDto } from '@mento/shared';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
@@ -36,6 +38,42 @@ const cards = [
|
||||
{ key: 'totalBalance', label: 'موجودی حسابها', hint: 'صندوق و بانک' },
|
||||
] as const;
|
||||
|
||||
const {
|
||||
page: installmentPage,
|
||||
pageSize: installmentPageSize,
|
||||
pageSizeOptions: installmentPageSizeOptions,
|
||||
total: installmentTotal,
|
||||
pagedRows: pagedInstallments,
|
||||
onPageSizeChange: onInstallmentPageSizeChange,
|
||||
showTotal: installmentShowTotal,
|
||||
} = useTreasuryListPaging(
|
||||
() => data.value?.upcomingInstallments ?? [],
|
||||
'treasury.home-installments',
|
||||
);
|
||||
|
||||
const {
|
||||
page: payablePage,
|
||||
pageSize: payablePageSize,
|
||||
pageSizeOptions: payablePageSizeOptions,
|
||||
total: payableTotal,
|
||||
pagedRows: pagedPayables,
|
||||
onPageSizeChange: onPayablePageSizeChange,
|
||||
showTotal: payableShowTotal,
|
||||
} = useTreasuryListPaging(
|
||||
() => data.value?.upcomingPayables ?? [],
|
||||
'treasury.home-payables',
|
||||
);
|
||||
|
||||
const {
|
||||
page: recentPage,
|
||||
pageSize: recentPageSize,
|
||||
pageSizeOptions: recentPageSizeOptions,
|
||||
total: recentTotal,
|
||||
pagedRows: pagedRecent,
|
||||
onPageSizeChange: onRecentPageSizeChange,
|
||||
showTotal: recentShowTotal,
|
||||
} = useTreasuryListPaging(() => data.value?.recent ?? [], 'treasury.home-recent');
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await api.get<TreasuryDashboardDto>('/treasury/dashboard');
|
||||
@@ -78,7 +116,7 @@ onMounted(async () => {
|
||||
<a-list
|
||||
v-else
|
||||
:item-layout="isMobile ? 'vertical' : 'horizontal'"
|
||||
:data-source="data.upcomingInstallments"
|
||||
:data-source="pagedInstallments"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
@@ -94,6 +132,14 @@ onMounted(async () => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="installmentPage"
|
||||
:total="installmentTotal"
|
||||
:page-size="installmentPageSize"
|
||||
:page-size-options="installmentPageSizeOptions"
|
||||
:show-total="installmentShowTotal"
|
||||
@update:page-size="onInstallmentPageSizeChange"
|
||||
/>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :lg="12">
|
||||
@@ -105,7 +151,7 @@ onMounted(async () => {
|
||||
<a-list
|
||||
v-else
|
||||
:item-layout="isMobile ? 'vertical' : 'horizontal'"
|
||||
:data-source="data.upcomingPayables"
|
||||
:data-source="pagedPayables"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
@@ -119,6 +165,14 @@ onMounted(async () => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="payablePage"
|
||||
:total="payableTotal"
|
||||
:page-size="payablePageSize"
|
||||
:page-size-options="payablePageSizeOptions"
|
||||
:show-total="payableShowTotal"
|
||||
@update:page-size="onPayablePageSizeChange"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
@@ -130,7 +184,7 @@ onMounted(async () => {
|
||||
<a-list
|
||||
v-else
|
||||
:item-layout="isMobile ? 'vertical' : 'horizontal'"
|
||||
:data-source="data.recent"
|
||||
:data-source="pagedRecent"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
@@ -146,6 +200,14 @@ onMounted(async () => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="recentPage"
|
||||
:total="recentTotal"
|
||||
:page-size="recentPageSize"
|
||||
:page-size-options="recentPageSizeOptions"
|
||||
:show-total="recentShowTotal"
|
||||
@update:page-size="onRecentPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
</template>
|
||||
</a-flex>
|
||||
|
||||
@@ -6,14 +6,11 @@ import {
|
||||
Button as AButton,
|
||||
Card as ACard,
|
||||
Col as ACol,
|
||||
Divider as ADivider,
|
||||
Empty as AEmpty,
|
||||
Flex as AFlex,
|
||||
Form as AForm,
|
||||
FormItem as AFormItem,
|
||||
Grid,
|
||||
Input as AInput,
|
||||
List as AList,
|
||||
Row as ARow,
|
||||
Segmented as ASegmented,
|
||||
Select as ASelect,
|
||||
@@ -31,15 +28,19 @@ import type {
|
||||
} from '@mento/shared';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import TreasuryDocPhotoField from '@/components/treasury/TreasuryDocPhotoField.vue';
|
||||
import TreasuryDocumentsPanel from '@/components/treasury/TreasuryDocumentsPanel.vue';
|
||||
import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue';
|
||||
import TreasuryPartySelect from '@/components/treasury/TreasuryPartySelect.vue';
|
||||
import { useSettleDefault } from '@/components/treasury/useSettleDefault';
|
||||
import { partyNetPosition, toman } from './treasury-format';
|
||||
import {
|
||||
uploadTreasuryDocumentPhotos,
|
||||
type TreasuryPendingPhoto,
|
||||
} from '@/lib/treasury-doc-photos';
|
||||
import { accountBalanceTone, partyNetPosition, toman } from './treasury-format';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const AListItem = AList.Item;
|
||||
const AListItemMeta = AList.Item.Meta;
|
||||
const ASelectOption = ASelect.Option;
|
||||
const screens = Grid.useBreakpoint();
|
||||
const isMobile = computed(() => !screens.value.md);
|
||||
@@ -53,6 +54,7 @@ const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const pendingPhotos = ref<TreasuryPendingPhoto[]>([]);
|
||||
const q = ref('');
|
||||
|
||||
function emptyForm() {
|
||||
@@ -130,6 +132,14 @@ const partyPosition = computed(() => {
|
||||
return partyNetPosition(receivable, payable);
|
||||
});
|
||||
|
||||
const selectedAccountBalance = computed(() => {
|
||||
const id = form.value.accountId;
|
||||
if (!id) return null;
|
||||
const account = accounts.value.find((row) => row.id === id);
|
||||
if (!account) return null;
|
||||
return accountBalanceTone(account.balance);
|
||||
});
|
||||
|
||||
watch(entryMode, () => {
|
||||
settleMirror.reset();
|
||||
form.value.amount = '';
|
||||
@@ -156,17 +166,6 @@ function apiMessage(e: unknown) {
|
||||
return Array.isArray(msg) ? msg.join('، ') : msg || 'ذخیره ناموفق بود.';
|
||||
}
|
||||
|
||||
function docLine(item: FinancialDocumentDto) {
|
||||
const parts = [
|
||||
item.reference ? `پیگیری ${item.reference}` : '',
|
||||
item.partyName || 'بدون طرف حساب',
|
||||
statusLabel[item.status] ?? item.status,
|
||||
`مانده ${toman(item.remaining)}`,
|
||||
].filter(Boolean);
|
||||
if (item.categoryName) parts.push(item.categoryName);
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
async function load() {
|
||||
const [docs, cats, acc, bals, payables] = await Promise.all([
|
||||
api.get<FinancialDocumentDto[]>('/treasury/documents', { params: { kind, q: q.value || undefined } }),
|
||||
@@ -201,6 +200,7 @@ async function load() {
|
||||
function resetForm() {
|
||||
settleMirror.reset();
|
||||
form.value = emptyForm();
|
||||
pendingPhotos.value = [];
|
||||
error.value = '';
|
||||
ok.value = '';
|
||||
}
|
||||
@@ -266,12 +266,22 @@ async function createDoc() {
|
||||
notes: form.value.notes || null,
|
||||
bookedAt: form.value.bookedAt || undefined,
|
||||
});
|
||||
const photos = [...pendingPhotos.value];
|
||||
let attached = 0;
|
||||
if (photos.length) {
|
||||
try {
|
||||
attached = await uploadTreasuryDocumentPhotos(data.id, photos);
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
}
|
||||
}
|
||||
resetForm();
|
||||
ok.value = collectsBalance
|
||||
const base = collectsBalance
|
||||
? `${toman(settleAmount)} از ماندهٔ طرف حساب کم شد.`
|
||||
: data.reference
|
||||
? `سند ثبت شد. شماره پیگیری: ${data.reference}`
|
||||
: 'سند ثبت شد.';
|
||||
ok.value = attached > 0 ? `${base} ${attached} عکس پیوست شد.` : base;
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
@@ -280,16 +290,6 @@ async function createDoc() {
|
||||
}
|
||||
}
|
||||
|
||||
async function voidDoc(id: string) {
|
||||
if (!window.confirm('این سند و گردش متصل به آن باطل شود؟')) return;
|
||||
try {
|
||||
await api.post(`/treasury/documents/${id}/void`, { reason: 'ابطال توسط مدیر' });
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load().catch(() => {
|
||||
error.value = 'بارگذاری ناموفق بود.';
|
||||
@@ -299,199 +299,175 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<a-flex vertical :gap="16">
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" />
|
||||
<a-alert v-if="error" type="error" show-icon :message="error" />
|
||||
<a-alert v-if="ok" type="success" show-icon :message="ok" />
|
||||
|
||||
<a-card :bordered="false">
|
||||
<a-flex align="center" justify="space-between" wrap="wrap" gap="small">
|
||||
<a-typography-text strong>سند جدید</a-typography-text>
|
||||
<a-segmented v-model:value="entryMode" :options="entryOptions" />
|
||||
</a-flex>
|
||||
<a-form
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
@finish="createDoc"
|
||||
@finishFailed="onFinishFailed"
|
||||
>
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="طرف حساب" name="partyKind" :rules="partyRules">
|
||||
<a-row :gutter="8" align="middle">
|
||||
<a-col :span="partyPosition ? 16 : 24">
|
||||
<TreasuryPartySelect
|
||||
v-model:kind="form.partyKind"
|
||||
v-model:party-id="form.partyId"
|
||||
:allow-other="!isSettlement"
|
||||
:placeholder="isSettlement ? 'مشتری، شرکت یا کاربر' : undefined"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col v-if="partyPosition" :span="8">
|
||||
<a-typography-text :type="partyPosition.type">{{ partyPosition.text }}</a-typography-text>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="عنوان"
|
||||
name="title"
|
||||
:rules="[{ required: true, message: 'عنوان الزامی است' }]"
|
||||
>
|
||||
<a-input v-model:value="form.title" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item
|
||||
label="مبلغ کل"
|
||||
name="amount"
|
||||
:rules="[{ required: true, message: 'مبلغ الزامی است' }]"
|
||||
>
|
||||
<MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item
|
||||
:label="settleLabel"
|
||||
name="settleAmount"
|
||||
:rules="isSettlement ? [{ required: true, message: 'مبلغ را وارد کنید' }] : []"
|
||||
>
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
v-model="form.settleAmount"
|
||||
:decimals="0"
|
||||
:disabled="!isSettlement && form.partyKind === 'other'"
|
||||
<a-card :bordered="false" title="سند جدید">
|
||||
<template #extra>
|
||||
<a-segmented v-model:value="entryMode" :options="entryOptions" />
|
||||
</template>
|
||||
<a-form
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
@finish="createDoc"
|
||||
@finishFailed="onFinishFailed"
|
||||
>
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="طرف حساب" name="partyKind" :rules="partyRules">
|
||||
<a-row :gutter="8" align="middle">
|
||||
<a-col :span="partyPosition ? 16 : 24">
|
||||
<TreasuryPartySelect
|
||||
v-model:kind="form.partyKind"
|
||||
v-model:party-id="form.partyId"
|
||||
:allow-other="!isSettlement"
|
||||
:placeholder="isSettlement ? 'مشتری، شرکت یا کاربر' : undefined"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item label="مانده این سند">
|
||||
<a-typography-text>{{ toman(remainingAmount) }}</a-typography-text>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="8">
|
||||
<a-form-item label="دستهبندی" name="categoryId">
|
||||
<a-select show-search option-filter-prop="label"
|
||||
v-model:value="form.categoryId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="بدون دسته"
|
||||
>
|
||||
<a-select-option v-for="cat in categories" :key="cat.id" :value="cat.id" :label="cat.name">
|
||||
{{ cat.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="حساب" name="accountId" :rules="accountRules">
|
||||
<a-select show-search option-filter-prop="label"
|
||||
v-model:value="form.accountId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="انتخاب حساب"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="account in accounts"
|
||||
:key="account.id"
|
||||
:value="account.id"
|
||||
:label="account.name"
|
||||
>
|
||||
{{ account.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="روش" name="method">
|
||||
<a-select show-search option-filter-prop="label" v-model:value="form.method" style="width: 100%">
|
||||
<a-select-option
|
||||
v-for="opt in methodOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:label="opt.label"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="8">
|
||||
<a-form-item label="تاریخ" name="bookedAt">
|
||||
<JalaliDateInput v-model="form.bookedAt" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :md="16">
|
||||
<a-form-item label="توضیحات" name="notes">
|
||||
<a-input v-model:value="form.notes" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-button type="primary" html-type="submit" :block="isMobile" :loading="saving">ثبت</a-button>
|
||||
</a-form>
|
||||
</a-col>
|
||||
<a-col v-if="partyPosition" :span="8">
|
||||
<a-typography-text :type="partyPosition.type">{{ partyPosition.text }}</a-typography-text>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="عنوان"
|
||||
name="title"
|
||||
:rules="[{ required: true, message: 'عنوان الزامی است' }]"
|
||||
>
|
||||
<a-input v-model:value="form.title" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-divider orientation="right">مانده دریافتنی</a-divider>
|
||||
<TreasuryPartyBalanceTable :rows="balances" settled-label="دریافتشده" />
|
||||
<a-divider orientation="right">فهرست اسناد</a-divider>
|
||||
<a-form layout="vertical">
|
||||
<a-row :gutter="[16, 0]">
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="جستجو">
|
||||
<a-input
|
||||
v-model:value="q"
|
||||
allow-clear
|
||||
placeholder="عنوان یا شماره پیگیری"
|
||||
@press-enter="load"
|
||||
@change="load"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item
|
||||
label="مبلغ کل"
|
||||
name="amount"
|
||||
:rules="[{ required: true, message: 'مبلغ الزامی است' }]"
|
||||
>
|
||||
<MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item
|
||||
:label="settleLabel"
|
||||
name="settleAmount"
|
||||
:rules="isSettlement ? [{ required: true, message: 'مبلغ را وارد کنید' }] : []"
|
||||
>
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
v-model="form.settleAmount"
|
||||
:decimals="0"
|
||||
:disabled="!isSettlement && form.partyKind === 'other'"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="مانده این سند">
|
||||
<MoneyInput
|
||||
addon-after="تومان"
|
||||
:model-value="remainingAmount"
|
||||
:decimals="0"
|
||||
disabled
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-empty v-if="!rows.length" description="سندی نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="rows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template v-if="!isMobile" #actions>
|
||||
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
|
||||
<a-button
|
||||
v-if="item.status !== 'void'"
|
||||
type="link"
|
||||
danger
|
||||
@click="voidDoc(item.id)"
|
||||
<a-col v-if="!isSettlement" :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="دستهبندی" name="categoryId">
|
||||
<a-select
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
v-model:value="form.categoryId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="بدون دسته"
|
||||
>
|
||||
<a-select-option v-for="cat in categories" :key="cat.id" :value="cat.id" :label="cat.name">
|
||||
{{ cat.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item name="accountId" :rules="accountRules">
|
||||
<template #label>
|
||||
<a-flex align="center" justify="space-between" gap="small" style="width: 100%">
|
||||
<span>حساب</span>
|
||||
<a-typography-text
|
||||
v-if="selectedAccountBalance"
|
||||
:type="selectedAccountBalance.type"
|
||||
>
|
||||
ابطال
|
||||
</a-button>
|
||||
</template>
|
||||
<a-flex v-if="isMobile" vertical :gap="4" style="width: 100%">
|
||||
<a-flex justify="space-between" align="center" wrap="wrap" :gap="8">
|
||||
<a-typography-text strong>{{ item.title }}</a-typography-text>
|
||||
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
|
||||
</a-flex>
|
||||
<a-typography-text type="secondary">
|
||||
{{ item.partyName || 'بدون طرف حساب' }} · {{ statusLabel[item.status] ?? item.status }}
|
||||
{{ selectedAccountBalance.text }}
|
||||
</a-typography-text>
|
||||
<a-typography-text v-if="item.reference" type="secondary">پیگیری {{ item.reference }}</a-typography-text>
|
||||
<a-typography-text v-if="item.categoryName" type="secondary">{{ item.categoryName }}</a-typography-text>
|
||||
<a-flex justify="space-between" align="center">
|
||||
<a-typography-text>مانده {{ toman(item.remaining) }}</a-typography-text>
|
||||
<a-button
|
||||
v-if="item.status !== 'void'"
|
||||
type="link"
|
||||
danger
|
||||
@click="voidDoc(item.id)"
|
||||
>
|
||||
ابطال
|
||||
</a-button>
|
||||
</a-flex>
|
||||
</a-flex>
|
||||
<a-list-item-meta v-else>
|
||||
<template #title>{{ item.title }}</template>
|
||||
<template #description>{{ docLine(item) }}</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-card>
|
||||
</template>
|
||||
<a-select
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
v-model:value="form.accountId"
|
||||
allow-clear
|
||||
style="width: 100%"
|
||||
placeholder="انتخاب حساب"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="account in accounts"
|
||||
:key="account.id"
|
||||
:value="account.id"
|
||||
:label="account.name"
|
||||
>
|
||||
{{ account.name }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="روش" name="method">
|
||||
<a-select show-search option-filter-prop="label" v-model:value="form.method" style="width: 100%">
|
||||
<a-select-option
|
||||
v-for="opt in methodOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:label="opt.label"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="تاریخ" name="bookedAt">
|
||||
<JalaliDateInput v-model="form.bookedAt" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="توضیحات" name="notes">
|
||||
<a-input v-model:value="form.notes" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :sm="12" :md="8">
|
||||
<a-form-item label="عکس فاکتور / رسید">
|
||||
<TreasuryDocPhotoField v-model="pendingPhotos" :disabled="saving" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" :block="isMobile" :loading="saving">ثبت</a-button>
|
||||
</a-space>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<a-card :bordered="false" title="مانده دریافتنی">
|
||||
<TreasuryPartyBalanceTable :rows="balances" settled-label="دریافتشده" />
|
||||
</a-card>
|
||||
|
||||
<TreasuryDocumentsPanel
|
||||
v-model:q="q"
|
||||
:rows="rows"
|
||||
:categories="categories"
|
||||
:status-label="statusLabel"
|
||||
@reload="load"
|
||||
/>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
@@ -42,7 +42,9 @@ import {
|
||||
toFaDigits,
|
||||
formatJalaliNumeric,
|
||||
} from '@/lib/jalali';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
@@ -189,6 +191,31 @@ const filtered = computed(() => {
|
||||
});
|
||||
});
|
||||
|
||||
const {
|
||||
page: reportPage,
|
||||
pageSize: reportPageSize,
|
||||
pageSizeOptions: reportPageSizeOptions,
|
||||
total: reportTotal,
|
||||
pagedRows: pagedReportRows,
|
||||
onPageSizeChange: onReportPageSizeChange,
|
||||
showTotal: reportShowTotal,
|
||||
resetPage: resetReportPage,
|
||||
} = useTreasuryListPaging(() => filtered.value, 'treasury.payroll-report');
|
||||
|
||||
const {
|
||||
page: paymentPage,
|
||||
pageSize: paymentPageSize,
|
||||
pageSizeOptions: paymentPageSizeOptions,
|
||||
total: paymentTotal,
|
||||
pagedRows: pagedPayments,
|
||||
onPageSizeChange: onPaymentPageSizeChange,
|
||||
showTotal: paymentShowTotal,
|
||||
resetPage: resetPaymentPage,
|
||||
} = useTreasuryListPaging(() => selectedPay.value?.payments ?? [], 'treasury.payroll-payments');
|
||||
|
||||
watch(selectedPay, () => resetPaymentPage());
|
||||
watch(filtered, () => resetReportPage());
|
||||
|
||||
const moneyKeys = ['baseAmount', 'benefits', 'bonus', 'deductions', 'payable', 'paidAmount', 'remaining'] as const;
|
||||
|
||||
const reportColumns: TableColumnsType<PayrollRow> = [
|
||||
@@ -653,7 +680,7 @@ onMounted(() => {
|
||||
</a-space>
|
||||
</a-form>
|
||||
|
||||
<a-list v-if="isMobile && selectedPay?.payments.length" :data-source="selectedPay.payments">
|
||||
<a-list v-if="isMobile && selectedPay?.payments.length" :data-source="pagedPayments">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-card style="width: 100%">
|
||||
@@ -672,7 +699,7 @@ onMounted(() => {
|
||||
<a-table
|
||||
v-else-if="selectedPay?.payments.length"
|
||||
:columns="paymentColumns"
|
||||
:data-source="selectedPay.payments"
|
||||
:data-source="pagedPayments"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
>
|
||||
@@ -700,6 +727,15 @@ onMounted(() => {
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
<TreasuryListPagination
|
||||
v-if="selectedPay?.payments.length"
|
||||
v-model:page="paymentPage"
|
||||
:total="paymentTotal"
|
||||
:page-size="paymentPageSize"
|
||||
:page-size-options="paymentPageSizeOptions"
|
||||
:show-total="paymentShowTotal"
|
||||
@update:page-size="onPaymentPageSizeChange"
|
||||
/>
|
||||
</a-flex>
|
||||
</a-card>
|
||||
|
||||
@@ -765,7 +801,7 @@ onMounted(() => {
|
||||
<a-empty v-if="!filtered.length" description="رکوردی با این فیلتر نیست." />
|
||||
<a-flex v-else vertical :gap="8">
|
||||
<a-card
|
||||
v-for="row in filtered"
|
||||
v-for="row in pagedReportRows"
|
||||
:key="row.id"
|
||||
hoverable
|
||||
@click="detail = row"
|
||||
@@ -851,7 +887,8 @@ onMounted(() => {
|
||||
<a-col :xs="0" :md="24">
|
||||
<a-table
|
||||
:columns="reportColumns"
|
||||
:data-source="filtered"
|
||||
:data-source="pagedReportRows"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
:scroll="{ x: 'max-content' }"
|
||||
:locale="{ emptyText: 'رکوردی با این فیلتر نیست.' }"
|
||||
@@ -907,6 +944,14 @@ onMounted(() => {
|
||||
</a-table>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<TreasuryListPagination
|
||||
v-model:page="reportPage"
|
||||
:total="reportTotal"
|
||||
:page-size="reportPageSize"
|
||||
:page-size-options="reportPageSizeOptions"
|
||||
:show-total="reportShowTotal"
|
||||
@update:page-size="onReportPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
|
||||
<a-modal
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
Alert as AAlert,
|
||||
@@ -29,10 +29,13 @@ import { api } from '@/lib/api';
|
||||
import type { FinancialAccountDto, FinancialReceivableDto } from '@mento/shared';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
const ASelectOption = ASelect.Option;
|
||||
@@ -44,6 +47,25 @@ const accounts = ref<FinancialAccountDto[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => rows.value, 'treasury.receivables');
|
||||
const installmentPageSize = usePageSize('treasury.receivables-installments', 10);
|
||||
const installmentPageSizeOptions = PAGE_SIZE_OPTIONS.map(String);
|
||||
const installmentTablePagination = computed(() => ({
|
||||
pageSize: installmentPageSize.value,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: installmentPageSizeOptions,
|
||||
onShowSizeChange: (_current: number, size: number) => {
|
||||
installmentPageSize.value = size;
|
||||
},
|
||||
}));
|
||||
const form = ref({
|
||||
title: '',
|
||||
partyName: '',
|
||||
@@ -361,7 +383,7 @@ onMounted(() => {
|
||||
<a-divider orientation="right">قراردادها</a-divider>
|
||||
<a-empty v-if="!rows.length" description="قراردادی ثبت نشده است." />
|
||||
<template v-else>
|
||||
<div v-for="row in rows" :key="row.id">
|
||||
<div v-for="row in pagedRows" :key="row.id">
|
||||
<a-flex justify="space-between" align="flex-start" wrap="wrap" :gap="8">
|
||||
<div>
|
||||
<a-typography-text strong>{{ row.title }}</a-typography-text>
|
||||
@@ -372,7 +394,11 @@ onMounted(() => {
|
||||
</div>
|
||||
<a-typography-text strong>{{ toman(row.totalAmount) }}</a-typography-text>
|
||||
</a-flex>
|
||||
<a-list v-if="isMobile" :data-source="row.installments">
|
||||
<a-list
|
||||
v-if="isMobile"
|
||||
:data-source="row.installments"
|
||||
:pagination="installmentTablePagination"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-card :title="`قسط ${item.position}`" style="width: 100%">
|
||||
@@ -401,7 +427,7 @@ onMounted(() => {
|
||||
v-else
|
||||
:columns="installmentColumns"
|
||||
:data-source="row.installments"
|
||||
:pagination="false"
|
||||
:pagination="installmentTablePagination"
|
||||
row-key="id"
|
||||
:scroll="{ x: true }"
|
||||
>
|
||||
@@ -422,6 +448,14 @@ onMounted(() => {
|
||||
</a-table>
|
||||
<a-divider />
|
||||
</div>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
import { api } from '@/lib/api';
|
||||
import MoneyInput from '@/components/MoneyInput.vue';
|
||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
import { formatJalaliNumeric } from '@/lib/jalali';
|
||||
import { parseMoneyNumber } from '@/lib/money';
|
||||
@@ -45,6 +47,15 @@ const rows = ref<Row[]>([]);
|
||||
const error = ref('');
|
||||
const ok = ref('');
|
||||
const saving = ref(false);
|
||||
const {
|
||||
page,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pagedRows,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
} = useTreasuryListPaging(() => rows.value, 'treasury.recurring');
|
||||
const form = ref({ title: '', kind: 'expense', amount: '', interval: 'monthly', startDate: '' });
|
||||
|
||||
async function load() {
|
||||
@@ -148,7 +159,7 @@ onMounted(() => {
|
||||
|
||||
<a-divider orientation="right">فهرست الگوها</a-divider>
|
||||
<a-empty v-if="!rows.length" description="الگویی ثبت نشده است." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="rows">
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -165,6 +176,14 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="page"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
:show-total="showTotal"
|
||||
@update:page-size="onPageSizeChange"
|
||||
/>
|
||||
</a-card>
|
||||
</a-flex>
|
||||
</template>
|
||||
|
||||
@@ -20,8 +20,10 @@ import { DownloadOutlined } from '@ant-design/icons-vue';
|
||||
import * as XLSX from 'xlsx';
|
||||
import type { TreasuryPartyBalanceDto } from '@mento/shared';
|
||||
import { api } from '@/lib/api';
|
||||
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
|
||||
import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue';
|
||||
import { toman } from './treasury-format';
|
||||
import { useTreasuryListPaging } from './useTreasuryListPaging';
|
||||
import { useTreasuryMobile } from './useTreasuryMobile';
|
||||
|
||||
const { Text: ATypographyText } = Typography;
|
||||
@@ -92,6 +94,39 @@ const metricRows = computed<MetricRow[]>(() => {
|
||||
}));
|
||||
});
|
||||
|
||||
const {
|
||||
page: partyPage,
|
||||
pageSize: partyPageSize,
|
||||
pageSizeOptions: partyPageSizeOptions,
|
||||
total: partyTotal,
|
||||
pagedRows: pagedPartyRows,
|
||||
onPageSizeChange: onPartyPageSizeChange,
|
||||
showTotal: partyShowTotal,
|
||||
} = useTreasuryListPaging(() => receivablesByParty.value, 'treasury.reports-party');
|
||||
|
||||
const {
|
||||
page: monthPage,
|
||||
pageSize: monthPageSize,
|
||||
pageSizeOptions: monthPageSizeOptions,
|
||||
total: monthTotal,
|
||||
pagedRows: pagedMonthRows,
|
||||
onPageSizeChange: onMonthPageSizeChange,
|
||||
showTotal: monthShowTotal,
|
||||
} = useTreasuryListPaging(() => payablesByMonth.value, 'treasury.reports-month');
|
||||
|
||||
const {
|
||||
page: expenseCatPage,
|
||||
pageSize: expenseCatPageSize,
|
||||
pageSizeOptions: expenseCatPageSizeOptions,
|
||||
total: expenseCatTotal,
|
||||
pagedRows: pagedExpenseCats,
|
||||
onPageSizeChange: onExpenseCatPageSizeChange,
|
||||
showTotal: expenseCatShowTotal,
|
||||
} = useTreasuryListPaging(
|
||||
() => current.value?.expenseCategories ?? [],
|
||||
'treasury.reports-expense-cats',
|
||||
);
|
||||
|
||||
async function load() {
|
||||
const { data } = await api.get<{
|
||||
current: Period;
|
||||
@@ -213,7 +248,7 @@ onMounted(() => {
|
||||
|
||||
<a-divider orientation="right">مطالبات به تفکیک طرف حساب</a-divider>
|
||||
<a-empty v-if="!receivablesByParty.length" description="مورد بازی نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="receivablesByParty">
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedPartyRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -225,10 +260,18 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="partyPage"
|
||||
:total="partyTotal"
|
||||
:page-size="partyPageSize"
|
||||
:page-size-options="partyPageSizeOptions"
|
||||
:show-total="partyShowTotal"
|
||||
@update:page-size="onPartyPageSizeChange"
|
||||
/>
|
||||
|
||||
<a-divider orientation="right">تعهدات به تفکیک ماه</a-divider>
|
||||
<a-empty v-if="!payablesByMonth.length" description="تعهد بازی نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="payablesByMonth">
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedMonthRows">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -240,11 +283,19 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="monthPage"
|
||||
:total="monthTotal"
|
||||
:page-size="monthPageSize"
|
||||
:page-size-options="monthPageSizeOptions"
|
||||
:show-total="monthShowTotal"
|
||||
@update:page-size="onMonthPageSizeChange"
|
||||
/>
|
||||
|
||||
<template v-if="current">
|
||||
<a-divider orientation="right">سهم هزینهها</a-divider>
|
||||
<a-empty v-if="!current.expenseCategories.length" description="دستهای نیست." />
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="current.expenseCategories">
|
||||
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedExpenseCats">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<template #actions>
|
||||
@@ -258,6 +309,14 @@ onMounted(() => {
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
<TreasuryListPagination
|
||||
v-model:page="expenseCatPage"
|
||||
:total="expenseCatTotal"
|
||||
:page-size="expenseCatPageSize"
|
||||
:page-size-options="expenseCatPageSizeOptions"
|
||||
:show-total="expenseCatShowTotal"
|
||||
@update:page-size="onExpenseCatPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</a-flex>
|
||||
</a-tab-pane>
|
||||
|
||||
@@ -11,3 +11,13 @@ export function partyNetPosition(receivable: number, payable: number) {
|
||||
if (net < 0) return { text: `بس ${toman(-net)}`, type: 'success' as const };
|
||||
return { text: `مانده ${toman(0)}`, type: 'secondary' as const };
|
||||
}
|
||||
|
||||
/** موجودی حساب: مثبت سبز، منفی قرمز، صفر خاکستری. */
|
||||
export function accountBalanceTone(balance: string | number | null | undefined) {
|
||||
const n = Number(balance ?? 0);
|
||||
if (!Number.isFinite(n) || n === 0) {
|
||||
return { text: `موجودی ${toman(0)}`, type: 'secondary' as const };
|
||||
}
|
||||
if (n > 0) return { text: `موجودی ${toman(n)}`, type: 'success' as const };
|
||||
return { text: `موجودی ${toman(n)}`, type: 'danger' as const };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { computed, ref, watch, type Ref } from 'vue';
|
||||
import { toFaDigits } from '@/lib/jalali';
|
||||
import { PAGE_SIZE_OPTIONS, usePageSize } from '@/lib/pageSize';
|
||||
|
||||
/** صفحهبندی مشترک فهرستها و جداول مدیریت مالی (۱۰/۲۰/۵۰/۱۰۰). */
|
||||
export function useTreasuryListPaging<T>(getRows: () => readonly T[], storageKey: string, fallback = 10) {
|
||||
const page = ref(1);
|
||||
const pageSize = usePageSize(storageKey, fallback);
|
||||
const pageSizeOptions = PAGE_SIZE_OPTIONS.map(String);
|
||||
|
||||
const total = computed(() => getRows().length);
|
||||
const pageCount = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value) || 1));
|
||||
const pagedRows = computed(() => {
|
||||
const start = (page.value - 1) * pageSize.value;
|
||||
return getRows().slice(start, start + pageSize.value) as T[];
|
||||
});
|
||||
|
||||
watch([total, pageSize], () => {
|
||||
if (page.value > pageCount.value) page.value = pageCount.value;
|
||||
if (page.value < 1) page.value = 1;
|
||||
});
|
||||
|
||||
function resetPage() {
|
||||
page.value = 1;
|
||||
}
|
||||
|
||||
function onPageSizeChange(size: number) {
|
||||
pageSize.value = size;
|
||||
page.value = 1;
|
||||
}
|
||||
|
||||
function showTotal(count: number) {
|
||||
return `مجموع: ${toFaDigits(count)} مورد (صفحه ${toFaDigits(page.value)} از ${toFaDigits(pageCount.value)})`;
|
||||
}
|
||||
|
||||
return {
|
||||
page,
|
||||
pageSize: pageSize as Ref<number>,
|
||||
pageSizeOptions,
|
||||
total,
|
||||
pageCount,
|
||||
pagedRows,
|
||||
resetPage,
|
||||
onPageSizeChange,
|
||||
showTotal,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user