@@ -30,7 +30,7 @@ import { getStatusHero, getTrackingFooterLabel } from '@/utils/orderTracking'
import OrderTrackingTimeline from '@/components/orders/OrderTrackingTimeline.vue'
import OrderStatusHero from '@/components/orders/OrderStatusHero.vue'
import OrderTrackingSummary from '@/components/orders/OrderTrackingSummary.vue'
import { isInvoicePriced } from '@/utils/orderInvoice'
import { canSubmitCashReceipt , isInvoicePriced } from '@/utils/orderInvoice'
const route = useRoute ( )
const router = useRouter ( )
@@ -40,7 +40,7 @@ const isDesktopLayout = useMediaQuery('(min-width: 768px)')
const orderId = computed ( ( ) => route . params . id as string )
const order = computed ( ( ) => orderStore . getOrderById ( orderId . value ) )
const showTracking = ref ( route . query . track === '1' || route . query . receipt === '1' )
const showReceiptForm = ref ( route . query . receipt === '1' )
const showReceiptForm = ref ( false )
const showTimeline = ref ( true )
const showOrderDetails = ref ( route . query . receipt === '1' )
const receiptAmount = ref ( '' )
@@ -52,6 +52,24 @@ const receiptImage = ref('')
const fieldErrors = ref < FieldErrors > ( { } )
const formError = ref ( '' )
watch (
[ order , ( ) => route . query . receipt ] ,
( [ current ] ) => {
const wantsReceipt = route . query . receipt === '1'
if ( wantsReceipt && canSubmitCashReceipt ( current ) ) {
showReceiptForm . value = true
showOrderDetails . value = true
return
}
if ( wantsReceipt && current && ! canSubmitCashReceipt ( current ) ) {
showReceiptForm . value = false
const { receipt : _receipt , ... rest } = route . query
void router . replace ( { query : { ... rest , track : '1' } } )
}
} ,
{ immediate : true } ,
)
watch (
isDesktopLayout ,
( wide ) => {
@@ -95,7 +113,11 @@ watch(
bankAccounts . value = [ ]
return
}
bankAccounts . value = await orderStore . getBankAccountsForCompany ( companyId )
try {
bankAccounts . value = await orderStore . getBankAccountsForCompany ( companyId )
} catch {
bankAccounts . value = [ ]
}
} ,
{ immediate : true } ,
)
@@ -105,7 +127,11 @@ watch(
async ( id ) => {
if ( ! id ) return
if ( ! orderStore . getOrderById ( id ) ) {
await orderStore . fetchOrder ( id )
try {
await orderStore . fetchOrder ( id )
} catch {
/* keep empty state if fetch fails */
}
}
} ,
{ immediate : true } ,
@@ -150,13 +176,21 @@ const nextAction = computed<NextAction | null>(() => {
}
} )
function openReceiptForm ( ) {
if ( ! canSubmitCashReceipt ( order . value ) ) {
formError . value = 'در وضعیت فعلی سفارش امکان ثبت رسید وجود ندارد'
return
}
showTracking . value = true
showOrderDetails . value = true
showReceiptForm . value = true
}
function runNextAction ( ) {
const action = nextAction . value
if ( ! action ) return
if ( action . receipt ) {
showTracking . value = true
showOrderDetails . value = true
showReceiptForm . value = true
openReceiptForm ( )
return
}
if ( action . to ) router . push ( action . to )
@@ -194,6 +228,11 @@ async function submitReceipt() {
fieldErrors . value = { }
formError . value = ''
if ( ! canSubmitCashReceipt ( order . value ) ) {
formError . value = 'در وضعیت فعلی سفارش امکان ثبت رسید وجود ندارد'
return
}
const amount = parseFormattedNumber ( receiptAmount . value )
const errors : FieldErrors = { }
@@ -240,7 +279,10 @@ async function submitReceipt() {
< button type = "button" class = "nav-btn" aria -label = " بازگشت " @click ="router.push('/orders')" >
< IconChevronBack :size = "20" / >
< / button >
< h1 class = "order-detail-page__title" > { { showTracking ? 'پیگیری سفارش' : 'جزئیات سفارش' } } < / h1 >
< div class = "order-detail-page__nav-center" >
< h1 class = "order-detail-page__title" > { { showTracking ? 'پیگیری سفارش' : 'جزئیات سفارش' } } < / h1 >
< p v-if = "showTracking" class="order-detail-page__order-id" > {{ order.orderNumber }} < / p >
< / div >
< button type = "button" class = "nav-btn nav-btn--ghost" aria -hidden = " true " tabindex = "-1" >
< IconChevronBack :size = "18" class = "nav-btn__flip" / >
< / button >
@@ -248,15 +290,14 @@ async function submitReceipt() {
< header class = "desktop-page__head desktop-only order-detail-page__desktop-head" >
< button type = "button" class = "order-detail-back" @click ="router.push('/orders')" >
← بازگشت به سفارشها
< IconChevronBack :size = "18" / >
بازگشت به سفارش ها
< / button >
< h1 class = "desktop-page__title" > پیگیری سفارش < / h1 >
< p class = "desktop-page__subtitle" > { { order . orderNumber } } · { { order . companyName } } < / p >
< / header >
< div class = "order-detail-page__body" >
< p v-if = "showTracking" class="order-detail-page__order-id mobile-only" > {{ order.orderNumber }} < / p >
< div v-if = "!showTracking" class="order-info-card mobile-only" >
< div class = "order-info-card__head" >
< span class = "order-info-card__label" > شماره سفارش < / span >
@@ -298,7 +339,7 @@ async function submitReceipt() {
< / div >
< div v-if = "showTracking" class="order-detail-page__tracking" >
< section class = "order-detail-page__tracking-aside " >
< section class = "order-detail-page__tracking-hero " >
< div class = "tracking-card tracking-card--hero" >
< OrderStatusHero v-if = "statusHero" :config="statusHero" / >
< OrderTrackingSummary :order = "order" / >
@@ -330,7 +371,6 @@ async function submitReceipt() {
< / button >
< div v-show = "showTimeline" class="tracking-collapse__body" >
< h2 class = "tracking-panel__title desktop-only" > پیگیری وضعیت < / h2 >
< div class = "tracking-collapse__section tracking-collapse__section--flush" >
< OrderTrackingTimeline :order = "order" / >
< / div >
@@ -354,7 +394,6 @@ async function submitReceipt() {
< / button >
< div v-show = "showOrderDetails" class="tracking-collapse__body" >
< h2 class = "tracking-panel__title desktop-only" > { { trackingFooterLabel } } < / h2 >
< div class = "tracking-collapse__section" >
< h3 class = "tracking-card__title" > اقلام سفارش < / h3 >
< div v-for = "item in order.items" :key="item.id" class="item-row" >
@@ -387,7 +426,7 @@ async function submitReceipt() {
< BaseButton
v-if = "nextAction?.receipt"
block
@click ="show ReceiptForm = true "
@click ="open ReceiptForm"
>
{ { order . cashReceipt ? 'ثبت رسید جدید' : 'ثبت رسید پرداخت' } }
< / BaseButton >
@@ -441,52 +480,91 @@ async function submitReceipt() {
< BaseButton block @click ="openTracking" > مشاهده جزئیات و پیگیری < / BaseButton >
< / div >
< div v-if = "showReceiptForm" class="dialog-overlay" @click.self="showReceiptForm = false" >
< div class = "dialog card" >
< h3 > ثبت رسید پرداخت < / h3 >
< Teleport to = "body" >
< div
v-if = "showReceiptForm"
class = "receipt-modal-overlay"
@click.self ="showReceiptForm = false"
>
< div
class = "receipt-modal card"
role = "dialog"
aria -modal = " true "
aria -labelledby = " receipt -modal -title "
>
< header class = "receipt-modal__header" >
< h3 id = "receipt-modal-title" class = "receipt-modal__title" > ثبت رسید پرداخت < / h3 >
< button
type = "button"
class = "receipt-modal__close"
aria -label = " بستن "
@click ="showReceiptForm = false"
>
×
< / button >
< / header >
< FormErrorBanner :message = "formError" / >
< div class = "receipt-modal__body" >
< FormErrorBanner :message = "formError" / >
< CurrencyInput
v-model = "receiptAmount"
label = "مبلغ واریزی"
:error = "fieldErrors.receiptAmount"
/ >
< PersianDateInput
v-model = "receiptDate"
label = "تاریخ واریز"
:error = "fieldErrors.receiptDate"
/ >
< BaseInput v-model = "receiptTime" label="ساعت واریز" type="time" / >
< BaseInput
v-model = "trackingNumber"
label = "شماره پیگیری"
:error = "fieldErrors.trackingN umb er"
/ >
< div class = "form-group" >
< label class = "form-label" > حساب مقصد < / label >
< select
v-model = "destinationAccountId"
class = "select-input"
: class = "{ 'select-input--error': fieldErrors. destinationAccountId }"
>
< option value = "" > انتخاب کنید < / option >
< option v-for = "acc in bankAccounts" :key="acc.id" :value="acc.id" >
{{ acc.bankName }} - {{ acc.cardNumber }}
< / option >
< / select >
< p v-if = "fieldErrors.destinationAccountId" class="input-error-text" >
{{ fieldErrors.destinationAccountId }}
< / p >
< CurrencyInput
v-model = "receiptAmount"
label = "مبلغ واریزی"
:error = "fieldErrors.receiptAmount"
/ >
< PersianDateInput
v-model = "receiptDate"
label = "تاریخ واریز"
:error = "fieldErrors.receiptDate"
/ >
< BaseInput v-model = "receiptTime" label="ساعت واریز" type="time" / >
< BaseInput
v-model = "trackingNumber"
label = "شماره پیگیری"
inputmode = "n umeric "
dir = "ltr"
:error = "fieldErrors.trackingNumber"
/ >
< div class = "form-group" >
< label class = "form-label" > حساب مقصد < / label >
< select
v-model = " destinationAccountId"
class = "select-input"
: class = "{ 'select-input--error': fieldErrors.destinationAccountId }"
>
< option value = "" > انتخاب کنید < / option >
< option v-for = "acc in bankAccounts" :key="acc.id" :value="acc.id" >
{{ acc.bankName }} - {{ acc.cardNumber }}
< / option >
< / select >
< p v-if = "fieldErrors.destinationAccountId" class="input-error-text" >
{{ fieldErrors.destinationAccountId }}
< / p >
< / div >
< div class = "form-group" >
< label class = "form-label" > تصویر رسید < / label >
< label class = "upload-box" : class = "{ 'upload-box--error': fieldErrors.receiptImage }" >
< input
type = "file"
accept = "image/*"
class = "upload-box__input"
@change ="handleReceiptImage"
/ >
< img
v-if = "receiptImage"
:src = "receiptImage"
class = "upload-box__preview"
alt = "تصویر رسید"
/ >
< span v-else class = "upload-box__placeholder" > انتخاب تصویر رسید < / span >
< / label >
< p v-if = "fieldErrors.receiptImage" class="input-error-text" > {{ fieldErrors.receiptImage }} < / p >
< / div >
< BaseButton block class = "mt-4" @click ="submitReceipt" > ثبت رسید < / BaseButton >
< / div >
< / div >
< div class = "form-group" >
< label class = "form-label" > تصویر رسید < / label >
< input type = "file" accept = "image/*" @change ="handleReceiptImage" / >
< p v-if = "fieldErrors.receiptImage" class="input-error-text" > {{ fieldErrors.receiptImage }} < / p >
< / div >
< BaseButton block class = "mt-4" @click ="submitReceipt" > ثبت رسید < / BaseButton >
< / div >
< / div >
< / Teleport >
< / div >
< div v-else class = "page empty-state" >
@@ -541,8 +619,17 @@ async function submitReceipt() {
display : grid ;
grid - template - columns : 40 px 1 fr 40 px ;
align - items : center ;
margin - bottom : 20 px ;
margin - bottom : 16 px ;
flex - shrink : 0 ;
gap : 4 px ;
}
. order - detail - page _ _nav - center {
min - width : 0 ;
display : flex ;
flex - direction : column ;
align - items : center ;
gap : 2 px ;
}
. order - detail - page _ _title {
@@ -551,6 +638,17 @@ async function submitReceipt() {
font - weight : 700 ;
text - align : center ;
color : var ( -- color - text ) ;
line - height : 1.35 ;
}
. order - detail - page _ _order - id {
margin : 0 ;
text - align : center ;
font - size : 0.8125 rem ;
font - weight : 600 ;
line - height : 1.3 ;
color : var ( -- color - text - muted ) ;
font - variant - numeric : tabular - nums ;
}
. nav - btn {
@@ -584,14 +682,6 @@ async function submitReceipt() {
width : 100 % ;
}
. order - detail - page _ _order - id {
margin : - 8 px 0 16 px ;
text - align : center ;
font - size : 0.875 rem ;
font - weight : 600 ;
color : var ( -- color - text - muted ) ;
}
. order - info - card {
background : var ( -- color - elevated ) ;
border - radius : 20 px ;
@@ -713,7 +803,7 @@ async function submitReceipt() {
width : 100 % ;
}
. order - detail - page _ _tracking - aside ,
. order - detail - page _ _tracking - hero ,
. order - detail - page _ _tracking - main {
display : flex ;
flex - direction : column ;
@@ -722,11 +812,6 @@ async function submitReceipt() {
width : 100 % ;
}
/* Mobile: status first (above content) */
. order - detail - page _ _tracking - aside {
order : - 1 ;
}
. tracking - card {
padding : 16 px ;
border : 1 px solid var ( -- color - border ) ;
@@ -741,10 +826,6 @@ async function submitReceipt() {
gap : 12 px ;
}
. tracking - panel _ _title {
display : none ;
}
. order - detail - page _ _tracking : deep ( . status - hero ) {
padding : 4 px 0 8 px ;
}
@@ -761,13 +842,11 @@ async function submitReceipt() {
@ media ( min - width : 768 px ) {
. order - detail - page _ _tracking : deep ( . status - hero ) {
align - items : flex - start ;
text - align : start ;
padding : 0 0 8 px ;
padding : 0 ;
}
. order - detail - page _ _tracking : deep ( . status - hero _ _desc ) {
max - width : none ;
max - width : 42 rem ;
}
}
@@ -844,26 +923,27 @@ async function submitReceipt() {
}
. order - detail - page _ _tracking {
display : grid ;
/* RTL: first column (status) sits beside sidebar on the right */
grid - template - columns : minmax ( 260 px , 320 px ) minmax ( 0 , 1 fr ) ;
gap : 20 px ;
align - items : start ;
gap : 16 px ;
margin - top : 8 px ;
}
. order - detail - page _ _tracking - aside {
order : initial ;
position : sticky ;
top : 16 px ;
}
. order - detail - page _ _tracking - main {
gap : 16 px ;
gap : 14 px ;
}
. tracking - card -- hero {
padding : 20 px ;
display : grid ;
grid - template - columns : 1 fr ;
gap : 16 px ;
align - items : stretch ;
padding : 22 px 24 px ;
}
. order - detail - page _ _tracking : deep ( . tracking - summary ) {
border - inline - start : none ;
padding - inline - start : 0 ;
border - top : 1 px solid var ( -- color - border ) ;
padding - top : 16 px ;
}
. tracking - collapse {
@@ -875,26 +955,16 @@ async function submitReceipt() {
}
. tracking - collapse _ _trigger {
display : none ;
padding : 16 px 20 px ;
}
. tracking - collapse _ _body {
display : flex ! important ;
padding : 20 px ;
border - top : none ;
padding : 0 20 px 20 px ;
gap : 16 px ;
}
. tracking - panel _ _title {
display : block ;
margin : 0 ;
font - size : 1 rem ;
font - weight : 700 ;
color : var ( -- color - text ) ;
}
. tracking - collapse _ _section {
padding - top : 0 ;
. tracking - collapse _ _section -- flush {
max - width : 520 px ;
}
. tracking - collapse _ _section + . tracking - collapse _ _section ,
@@ -909,10 +979,29 @@ async function submitReceipt() {
}
}
@ media ( min - width : 1000 px ) {
. tracking - card -- hero {
grid - template - columns : minmax ( 0 , 1.4 fr ) minmax ( 220 px , 0.75 fr ) ;
gap : 20 px ;
}
. order - detail - page _ _tracking : deep ( . tracking - summary ) {
border - top : none ;
padding - top : 0 ;
border - inline - start : 1 px solid var ( -- color - border ) ;
padding - inline - start : 20 px ;
}
}
@ media ( min - width : 1200 px ) {
. order - detail - page _ _tracking {
grid - template - columns : minmax ( 300 px , 360 px ) minmax ( 0 , 1 fr ) ;
gap : 24 px ;
. tracking - card -- hero {
grid - template - columns : minmax ( 0 , 1.5 fr ) minmax ( 260 px , 0.7 fr ) ;
gap : 28 px ;
padding : 24 px 28 px ;
}
. tracking - collapse _ _section -- flush {
max - width : 560 px ;
}
}
@@ -1008,6 +1097,96 @@ async function submitReceipt() {
overflow - y : auto ;
}
. receipt - modal - overlay {
position : fixed ;
inset : 0 ;
z - index : 1100 ;
display : flex ;
align - items : flex - end ;
justify - content : center ;
padding : 0 ;
background : rgba ( 15 , 23 , 42 , 0.52 ) ;
backdrop - filter : blur ( 8 px ) ;
- webkit - backdrop - filter : blur ( 8 px ) ;
}
. receipt - modal {
width : 100 % ;
max - height : 92 dvh ;
display : flex ;
flex - direction : column ;
overflow : hidden ;
border - radius : var ( -- radius - lg ) var ( -- radius - lg ) 0 0 ;
background : var ( -- color - surface ) ;
box - shadow : var ( -- shadow - md ) ;
}
. receipt - modal _ _header {
flex - shrink : 0 ;
display : flex ;
align - items : center ;
justify - content : space - between ;
gap : 12 px ;
padding : 14 px 16 px ;
border - bottom : 1 px solid var ( -- color - border ) ;
}
. receipt - modal _ _title {
margin : 0 ;
font - size : 1 rem ;
font - weight : 700 ;
color : var ( -- color - text ) ;
}
. receipt - modal _ _close {
width : 36 px ;
height : 36 px ;
border : none ;
border - radius : var ( -- radius - sm ) ;
background : transparent ;
color : var ( -- color - text - muted ) ;
font - size : 1.5 rem ;
line - height : 1 ;
cursor : pointer ;
display : flex ;
align - items : center ;
justify - content : center ;
}
. receipt - modal _ _close : hover {
background : var ( -- color - bg ) ;
color : var ( -- color - text ) ;
}
. receipt - modal _ _body {
flex : 1 1 auto ;
min - height : 0 ;
overflow - y : auto ;
padding : 16 px ;
padding - bottom : calc ( 16 px + env ( safe - area - inset - bottom , 0 px ) ) ;
}
@ media ( min - width : 768 px ) {
. receipt - modal - overlay {
align - items : center ;
padding : 24 px ;
}
. receipt - modal {
width : min ( 100 % , 520 px ) ;
max - height : min ( 90 dvh , 760 px ) ;
border - radius : var ( -- radius - lg ) ;
}
. receipt - modal _ _header {
padding : 16 px 20 px ;
}
. receipt - modal _ _body {
padding : 20 px ;
}
}
. select - input {
width : 100 % ;
padding : 12 px ;
@@ -1020,6 +1199,41 @@ async function submitReceipt() {
border - color : var ( -- color - danger ) ;
}
. upload - box {
display : flex ;
align - items : center ;
justify - content : center ;
min - height : 120 px ;
border : 1.5 px dashed var ( -- color - border ) ;
border - radius : var ( -- radius - md ) ;
background : var ( -- color - surface ) ;
cursor : pointer ;
overflow : hidden ;
position : relative ;
}
. upload - box -- error {
border - color : var ( -- color - danger ) ;
}
. upload - box _ _input {
position : absolute ;
inset : 0 ;
opacity : 0 ;
cursor : pointer ;
}
. upload - box _ _placeholder {
font - size : 0.875 rem ;
color : var ( -- color - text - muted ) ;
}
. upload - box _ _preview {
max - width : 100 % ;
max - height : 140 px ;
object - fit : contain ;
}
. input - error - text {
color : var ( -- color - danger ) ;
font - size : 0.8125 rem ;