2026-09-05 00:18:39 +03:30
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
import UiIcon from '@/components/UiIcon.vue';
|
2026-10-06 14:23:59 +03:30
|
|
|
import { userAvatarSrc } from '@/lib/userAvatars';
|
2026-09-15 19:13:30 +03:30
|
|
|
import type { PipelineAccent, PipelineDeal, PipelineUiCopy } from '@/lib/pipeline-board';
|
|
|
|
|
import {
|
|
|
|
|
DEAL_BOARD_COPY,
|
|
|
|
|
formatCurrencyParts,
|
|
|
|
|
PIPELINE_ACCENT,
|
|
|
|
|
} from '@/lib/pipeline-board';
|
2026-09-05 00:18:39 +03:30
|
|
|
|
2026-09-15 19:13:30 +03:30
|
|
|
const props = withDefaults(
|
|
|
|
|
defineProps<{
|
|
|
|
|
deal: PipelineDeal;
|
|
|
|
|
accent: PipelineAccent;
|
|
|
|
|
dragging?: boolean;
|
|
|
|
|
copy?: PipelineUiCopy;
|
2026-10-12 17:59:07 +03:30
|
|
|
selectMode?: boolean;
|
|
|
|
|
selected?: boolean;
|
2026-09-15 19:13:30 +03:30
|
|
|
}>(),
|
|
|
|
|
{ copy: () => DEAL_BOARD_COPY },
|
|
|
|
|
);
|
2026-09-05 00:18:39 +03:30
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
dragStart: [deal: PipelineDeal, event: DragEvent];
|
|
|
|
|
dragEnd: [];
|
|
|
|
|
open: [dealId: string];
|
|
|
|
|
menu: [dealId: string];
|
2026-10-12 17:59:07 +03:30
|
|
|
toggleSelect: [dealId: string];
|
|
|
|
|
bulkDelete: [];
|
2026-09-05 00:18:39 +03:30
|
|
|
}>();
|
|
|
|
|
|
2026-09-15 19:13:30 +03:30
|
|
|
const showAmount = computed(
|
|
|
|
|
() => !props.copy.hideAmount && props.deal.amount != null,
|
|
|
|
|
);
|
2026-09-05 00:18:39 +03:30
|
|
|
const money = computed(() =>
|
2026-10-13 14:45:29 +03:30
|
|
|
formatCurrencyParts(props.deal.amount ?? 0, props.deal.currencyUnit ?? 'ریال'),
|
2026-09-05 00:18:39 +03:30
|
|
|
);
|
|
|
|
|
const colors = computed(() => PIPELINE_ACCENT[props.accent]);
|
2026-09-27 14:25:32 +03:30
|
|
|
const assigneeTitle = computed(() =>
|
|
|
|
|
(props.deal.assigneeNames ?? []).filter(Boolean).join('، ') || 'مسئول',
|
|
|
|
|
);
|
2026-10-06 14:23:59 +03:30
|
|
|
const avatarSrc = computed(() =>
|
|
|
|
|
userAvatarSrc(props.deal.ownerId || props.deal.assigneeIds?.[0] || null),
|
|
|
|
|
);
|
2026-09-27 14:25:32 +03:30
|
|
|
const extraAssignees = computed(() =>
|
|
|
|
|
Math.max(0, (props.deal.assigneeNames?.length ?? 0) - 1),
|
|
|
|
|
);
|
2026-10-12 17:59:07 +03:30
|
|
|
const showTrash = computed(() => props.selectMode && props.selected);
|
2026-09-05 00:18:39 +03:30
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<article
|
|
|
|
|
class="deal-card"
|
2026-10-12 17:59:07 +03:30
|
|
|
:class="{
|
|
|
|
|
dragging,
|
|
|
|
|
'no-amount': !showAmount,
|
|
|
|
|
'select-mode': selectMode,
|
|
|
|
|
selected,
|
|
|
|
|
}"
|
2026-10-12 14:54:32 +03:30
|
|
|
:data-card-id="deal.id"
|
2026-10-12 17:59:07 +03:30
|
|
|
:draggable="!selectMode"
|
2026-09-05 00:18:39 +03:30
|
|
|
role="listitem"
|
|
|
|
|
:aria-grabbed="dragging ? 'true' : 'false'"
|
|
|
|
|
:style="{
|
|
|
|
|
'--badge-bg': colors.soft,
|
|
|
|
|
'--badge-fg': colors.text,
|
|
|
|
|
}"
|
2026-10-12 17:59:07 +03:30
|
|
|
@dragstart="!selectMode && emit('dragStart', deal, $event)"
|
2026-09-05 00:18:39 +03:30
|
|
|
@dragend="emit('dragEnd')"
|
2026-10-12 17:59:07 +03:30
|
|
|
@dblclick="!selectMode && emit('open', deal.id)"
|
|
|
|
|
@click="selectMode && emit('toggleSelect', deal.id)"
|
2026-09-05 00:18:39 +03:30
|
|
|
>
|
2026-10-12 17:59:07 +03:30
|
|
|
<button
|
|
|
|
|
v-if="selectMode"
|
|
|
|
|
type="button"
|
|
|
|
|
class="tick"
|
|
|
|
|
:class="{ on: selected }"
|
|
|
|
|
:aria-label="selected ? 'لغو انتخاب' : 'انتخاب معامله'"
|
|
|
|
|
:aria-pressed="selected"
|
|
|
|
|
@click.stop="emit('toggleSelect', deal.id)"
|
|
|
|
|
>
|
|
|
|
|
<UiIcon v-if="selected" name="check" :size="14" />
|
|
|
|
|
</button>
|
|
|
|
|
<span v-else class="badge" aria-hidden="true">{{ deal.initials }}</span>
|
2026-09-10 01:22:24 +03:30
|
|
|
<div class="titles">
|
2026-10-12 17:59:07 +03:30
|
|
|
<h3 @click.stop="selectMode ? emit('toggleSelect', deal.id) : emit('open', deal.id)">
|
|
|
|
|
{{ deal.title }}
|
|
|
|
|
</h3>
|
2026-09-10 01:22:24 +03:30
|
|
|
<p v-if="deal.description" class="desc">{{ deal.description }}</p>
|
2026-09-05 00:18:39 +03:30
|
|
|
</div>
|
2026-09-10 01:22:24 +03:30
|
|
|
<button
|
2026-10-12 17:59:07 +03:30
|
|
|
v-if="showTrash"
|
|
|
|
|
type="button"
|
|
|
|
|
class="menu trash"
|
|
|
|
|
aria-label="حذف انتخابشدهها"
|
|
|
|
|
@click.stop="emit('bulkDelete')"
|
|
|
|
|
>
|
|
|
|
|
<UiIcon name="trash" :size="16" />
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
v-else
|
2026-09-10 01:22:24 +03:30
|
|
|
type="button"
|
|
|
|
|
class="menu"
|
2026-09-15 19:13:30 +03:30
|
|
|
:aria-label="copy.itemMenuAria"
|
2026-09-10 01:22:24 +03:30
|
|
|
@click.stop="emit('menu', deal.id)"
|
|
|
|
|
>
|
|
|
|
|
<UiIcon name="dots-v" :size="16" />
|
|
|
|
|
</button>
|
|
|
|
|
<img
|
|
|
|
|
class="avatar"
|
2026-10-06 14:23:59 +03:30
|
|
|
:src="avatarSrc"
|
2026-09-10 01:22:24 +03:30
|
|
|
alt=""
|
|
|
|
|
width="32"
|
|
|
|
|
height="32"
|
2026-09-27 14:25:32 +03:30
|
|
|
:title="assigneeTitle"
|
2026-09-10 01:22:24 +03:30
|
|
|
/>
|
2026-09-27 14:25:32 +03:30
|
|
|
<span v-if="extraAssignees > 0" class="more-assignees" :title="assigneeTitle">
|
|
|
|
|
+{{ extraAssignees }}
|
|
|
|
|
</span>
|
2026-09-10 01:22:24 +03:30
|
|
|
<span class="date">
|
|
|
|
|
{{ deal.date }}
|
|
|
|
|
<UiIcon name="calendar" :size="13" />
|
|
|
|
|
</span>
|
2026-09-15 19:13:30 +03:30
|
|
|
<div v-if="showAmount" class="amount">
|
2026-09-10 01:22:24 +03:30
|
|
|
<strong>{{ money.number }}</strong>
|
|
|
|
|
<span>{{ money.unit }}</span>
|
2026-09-05 00:18:39 +03:30
|
|
|
</div>
|
|
|
|
|
</article>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.deal-card {
|
2026-09-10 01:22:24 +03:30
|
|
|
--face: 32px;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: var(--face) minmax(0, 1fr) auto;
|
|
|
|
|
grid-template-rows: auto auto;
|
|
|
|
|
column-gap: 0.5rem;
|
|
|
|
|
row-gap: 0.65rem;
|
|
|
|
|
align-items: center;
|
2026-09-05 00:18:39 +03:30
|
|
|
background: #fff;
|
|
|
|
|
border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
|
2026-09-10 01:22:24 +03:30
|
|
|
border-radius: var(--radius);
|
|
|
|
|
padding: 0.85rem 0.7rem 0.85rem 0.55rem;
|
2026-09-09 13:12:13 +03:30
|
|
|
min-width: 0;
|
|
|
|
|
overflow: hidden;
|
2026-09-05 00:18:39 +03:30
|
|
|
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
|
|
|
|
|
cursor: grab;
|
|
|
|
|
transition:
|
|
|
|
|
box-shadow 0.18s ease,
|
|
|
|
|
border-color 0.18s ease,
|
|
|
|
|
transform 0.18s ease,
|
2026-10-12 17:59:07 +03:30
|
|
|
opacity 0.18s ease,
|
|
|
|
|
background 0.18s ease;
|
2026-09-05 00:18:39 +03:30
|
|
|
text-align: right;
|
|
|
|
|
direction: rtl;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:59:07 +03:30
|
|
|
.deal-card.select-mode {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.deal-card.selected {
|
|
|
|
|
border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
|
|
|
|
|
background: color-mix(in srgb, var(--accent) 6%, #fff);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 00:18:39 +03:30
|
|
|
.deal-card:hover {
|
|
|
|
|
border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
|
|
|
|
|
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.deal-card:active {
|
|
|
|
|
cursor: grabbing;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:59:07 +03:30
|
|
|
.deal-card.select-mode:active {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 00:18:39 +03:30
|
|
|
.deal-card.dragging {
|
|
|
|
|
opacity: 0.95;
|
|
|
|
|
transform: scale(1.02);
|
|
|
|
|
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
|
|
|
|
|
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-15 19:13:30 +03:30
|
|
|
.deal-card.no-amount .date {
|
|
|
|
|
grid-column: 2 / -1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 00:18:39 +03:30
|
|
|
.deal-card:focus-visible {
|
|
|
|
|
outline: 2px solid var(--accent);
|
|
|
|
|
outline-offset: 2px;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 01:22:24 +03:30
|
|
|
.badge,
|
2026-10-12 17:59:07 +03:30
|
|
|
.avatar,
|
|
|
|
|
.tick {
|
2026-09-10 01:22:24 +03:30
|
|
|
width: var(--face);
|
|
|
|
|
height: var(--face);
|
|
|
|
|
max-width: var(--face);
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
justify-self: center;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.badge {
|
|
|
|
|
display: grid;
|
|
|
|
|
place-items: center;
|
|
|
|
|
background: var(--badge-bg);
|
|
|
|
|
color: var(--badge-fg);
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.65rem;
|
2026-09-12 01:33:07 +03:30
|
|
|
font-weight: 600;
|
2026-09-05 00:18:39 +03:30
|
|
|
line-height: 1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:59:07 +03:30
|
|
|
.tick {
|
|
|
|
|
display: grid;
|
|
|
|
|
place-items: center;
|
|
|
|
|
border: 2px solid #cbd5e1;
|
|
|
|
|
background: #fff;
|
|
|
|
|
color: #fff;
|
|
|
|
|
padding: 0;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tick.on {
|
|
|
|
|
border-color: var(--accent);
|
|
|
|
|
background: var(--accent);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 01:22:24 +03:30
|
|
|
.avatar {
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
border: 1px solid var(--line);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-27 14:25:32 +03:30
|
|
|
.more-assignees {
|
|
|
|
|
width: auto;
|
|
|
|
|
min-width: 1.15rem;
|
|
|
|
|
height: 1.15rem;
|
|
|
|
|
padding: 0 0.22rem;
|
|
|
|
|
margin-inline-start: -1.55rem;
|
|
|
|
|
margin-top: 1.1rem;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: #0f766e;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 0.62rem;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
display: grid;
|
|
|
|
|
place-items: center;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
justify-self: end;
|
|
|
|
|
align-self: start;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-05 00:18:39 +03:30
|
|
|
.titles {
|
|
|
|
|
min-width: 0;
|
2026-09-10 01:22:24 +03:30
|
|
|
text-align: right;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.titles h3 {
|
|
|
|
|
margin: 0;
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.82rem;
|
2026-09-12 01:33:07 +03:30
|
|
|
font-weight: 600;
|
2026-09-10 01:22:24 +03:30
|
|
|
line-height: 1.4;
|
2026-09-05 00:18:39 +03:30
|
|
|
color: var(--ink);
|
|
|
|
|
cursor: pointer;
|
2026-09-09 13:12:13 +03:30
|
|
|
overflow: hidden;
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
overflow-wrap: anywhere;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.desc {
|
2026-09-10 01:22:24 +03:30
|
|
|
margin: 0.1rem 0 0;
|
2026-09-05 00:18:39 +03:30
|
|
|
color: var(--muted);
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.7rem;
|
|
|
|
|
line-height: 1.35;
|
2026-09-09 13:12:13 +03:30
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu {
|
2026-09-10 01:22:24 +03:30
|
|
|
align-self: start;
|
|
|
|
|
justify-self: end;
|
2026-09-05 00:18:39 +03:30
|
|
|
border: 0;
|
2026-09-10 01:22:24 +03:30
|
|
|
background: none;
|
2026-09-05 00:18:39 +03:30
|
|
|
color: var(--muted);
|
2026-09-10 01:22:24 +03:30
|
|
|
width: auto;
|
|
|
|
|
height: auto;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
line-height: 0;
|
2026-09-05 00:18:39 +03:30
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu:hover,
|
|
|
|
|
.menu:focus-visible {
|
|
|
|
|
color: var(--ink);
|
2026-09-10 01:22:24 +03:30
|
|
|
background: none;
|
|
|
|
|
outline: none;
|
2026-09-09 13:12:13 +03:30
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:59:07 +03:30
|
|
|
.menu.trash {
|
|
|
|
|
color: var(--danger);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu.trash:hover,
|
|
|
|
|
.menu.trash:focus-visible {
|
|
|
|
|
color: var(--danger);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-09 13:12:13 +03:30
|
|
|
.date {
|
2026-09-10 01:22:24 +03:30
|
|
|
display: flex;
|
2026-09-09 13:12:13 +03:30
|
|
|
align-items: center;
|
2026-09-10 01:22:24 +03:30
|
|
|
justify-content: flex-start;
|
|
|
|
|
gap: 0.25rem;
|
2026-09-09 13:12:13 +03:30
|
|
|
min-width: 0;
|
2026-09-10 01:22:24 +03:30
|
|
|
width: 100%;
|
2026-09-09 13:12:13 +03:30
|
|
|
color: var(--muted);
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.68rem;
|
2026-09-09 13:12:13 +03:30
|
|
|
font-weight: 600;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.amount {
|
2026-09-05 00:18:39 +03:30
|
|
|
text-align: left;
|
|
|
|
|
display: grid;
|
2026-09-10 01:22:24 +03:30
|
|
|
justify-items: end;
|
2026-09-09 13:12:13 +03:30
|
|
|
gap: 0.02rem;
|
|
|
|
|
min-width: 0;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.amount strong {
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.88rem;
|
2026-09-12 01:33:07 +03:30
|
|
|
font-weight: 600;
|
2026-09-05 00:18:39 +03:30
|
|
|
color: var(--ink);
|
|
|
|
|
letter-spacing: -0.01em;
|
2026-09-09 13:12:13 +03:30
|
|
|
max-width: 100%;
|
|
|
|
|
overflow-wrap: anywhere;
|
2026-09-05 00:18:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.amount span {
|
2026-09-10 01:22:24 +03:30
|
|
|
font-size: 0.65rem;
|
2026-09-05 00:18:39 +03:30
|
|
|
color: var(--muted);
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
</style>
|