Unify the web UI on shared controls and let pipeline columns be managed on the board.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-10 01:22:24 +03:30
co-authored by Cursor
parent f1aba1b386
commit b8ad4037b6
40 changed files with 2334 additions and 788 deletions
+58 -14
View File
@@ -51,11 +51,23 @@ type InstallmentDraft = {
amount: string;
};
const props = withDefaults(
defineProps<{
embedded?: boolean;
entityId?: string;
initialKind?: 'invoice' | 'credit' | 'quote';
initialFromDealId?: string;
}>(),
{ embedded: false },
);
const emit = defineEmits<{ saved: []; cancel: [] }>();
const route = useRoute();
const router = useRouter();
const loadedInvoiceKind = ref<'invoice' | 'credit' | null>(null);
const docMode = computed<DocMode>(() => {
if (props.embedded && props.initialKind) return props.initialKind;
const name = String(route.name || '');
if (name.includes('quote')) return 'quote';
if (route.query.kind === 'credit' || route.query.doc === 'credit') return 'credit';
@@ -64,12 +76,14 @@ const docMode = computed<DocMode>(() => {
return 'invoice';
});
const id = computed(() =>
typeof route.params.id === 'string' ? route.params.id : '',
);
const isNew = computed(
() => route.name === 'invoice-new' || route.name === 'quote-new',
);
const id = computed(() => {
if (props.embedded) return props.entityId ?? '';
return typeof route.params.id === 'string' ? route.params.id : '';
});
const isNew = computed(() => {
if (props.embedded) return !props.entityId;
return route.name === 'invoice-new' || route.name === 'quote-new';
});
const isInvoiceDoc = computed(() => docMode.value !== 'quote');
const listRouteName = 'invoices';
@@ -376,11 +390,12 @@ async function prefillFromSources() {
const fromQuoteId =
typeof route.query.fromQuoteId === 'string' ? route.query.fromQuoteId : '';
const fromDealId =
typeof route.query.fromDealId === 'string'
props.initialFromDealId ||
(typeof route.query.fromDealId === 'string'
? route.query.fromDealId
: typeof route.query.dealId === 'string'
? route.query.dealId
: '';
: '');
const qPersonId =
typeof route.query.personId === 'string' ? route.query.personId : '';
@@ -528,8 +543,10 @@ async function load() {
function invoicePayload(): CreateInvoiceRequest {
const fromDealId =
isNew.value && typeof route.query.fromDealId === 'string'
? route.query.fromDealId
isNew.value &&
(props.initialFromDealId || typeof route.query.fromDealId === 'string')
? (props.initialFromDealId ||
(typeof route.query.fromDealId === 'string' ? route.query.fromDealId : ''))
: undefined;
const fromQuoteId =
isNew.value && typeof route.query.fromQuoteId === 'string'
@@ -558,8 +575,10 @@ function invoicePayload(): CreateInvoiceRequest {
function quotePayload(): CreateQuoteRequest {
const fromDealId =
isNew.value && typeof route.query.fromDealId === 'string'
? route.query.fromDealId
isNew.value &&
(props.initialFromDealId || typeof route.query.fromDealId === 'string')
? (props.initialFromDealId ||
(typeof route.query.fromDealId === 'string' ? route.query.fromDealId : ''))
: undefined;
if (validityMode.value === 'days') {
applyValidityDays(validityDays.value);
@@ -619,6 +638,10 @@ async function save() {
} else {
await api.patch(`/invoices/${id.value}`, invoicePayload());
}
if (props.embedded) {
emit('saved');
return;
}
await router.push({ name: listRouteName });
} catch (e) {
error.value = axiosMessage(e, 'ذخیره ناموفق بود');
@@ -709,6 +732,10 @@ function printDoc() {
}
function goBack() {
if (props.embedded) {
emit('cancel');
return;
}
void router.push({ name: listRouteName });
}
@@ -742,8 +769,14 @@ onMounted(load);
</script>
<template>
<section class="page">
<header class="page-head no-print">
<section class="page" :class="{ embedded }">
<div v-if="embedded" class="embed-actions no-print">
<button class="btn primary" type="button" :disabled="saving" @click="save">
{{ saving ? 'در حال ذخیره…' : 'ذخیره' }}
</button>
<button class="btn cancel" type="button" :disabled="saving" @click="goBack">انصراف</button>
</div>
<header v-if="!embedded" class="page-head no-print">
<div class="head-copy">
<div class="title-row">
<span class="doc-ico">
@@ -1571,6 +1604,17 @@ onMounted(load);
max-width: 1180px;
}
.page.embedded {
--radius: 10px;
max-width: none;
}
.embed-actions {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.page-head {
display: flex;
flex-direction: row;