Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -262,6 +262,16 @@
|
||||
@click="openNewRowEditor"
|
||||
:disable="isClosedRow || isViewOnly || !canMutateRows"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="isEditMode && canBulkUpdateLineDueDates"
|
||||
label="SATIR TERMINLERINI TOPLU GUNCELLE"
|
||||
color="warning"
|
||||
icon="event"
|
||||
class="q-ml-sm"
|
||||
:loading="orderStore.loading"
|
||||
:disable="orderStore.loading || !canBulkUpdateLineDueDates"
|
||||
@click="openBulkDueDateDialog"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="canSubmitOrder"
|
||||
:label="isEditMode ? 'TÜMÜNÜ GÜNCELLE' : 'TÜMÜNÜ KAYDET'"
|
||||
@@ -450,6 +460,41 @@
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<!-- =======================================================
|
||||
🔹 TOPLU TERMIN GUNCELLEME
|
||||
======================================================== -->
|
||||
<q-dialog v-model="showBulkDueDateDialog" persistent>
|
||||
<q-card style="min-width: 420px; max-width: 90vw;">
|
||||
<q-card-section class="text-subtitle1 text-weight-bold">
|
||||
Satir Terminlerini Toplu Guncelle
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section class="q-pt-none">
|
||||
<div class="q-mb-md">
|
||||
Tum siparis satiri terminlerini sectiginiz tarihi koyarak guncellemek istediginize emin misiniz?
|
||||
</div>
|
||||
<q-input
|
||||
v-model="bulkDueDateValue"
|
||||
type="date"
|
||||
label="Yeni Termin Tarihi"
|
||||
filled
|
||||
dense
|
||||
autofocus
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn flat label="Iptal" v-close-popup />
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="Evet"
|
||||
:loading="orderStore.loading"
|
||||
@click="confirmBulkDueDateUpdate"
|
||||
/>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<!-- =======================================================
|
||||
🔹 SATIR DÜZENLEYİCİ FORM (EDITOR)
|
||||
======================================================== -->
|
||||
@@ -883,6 +928,8 @@ console.log('🧩 Route parametresi alındı (setup başında):', orderHeaderID.
|
||||
const aktifPB = ref('USD') // Varsayılan para birimi (Cari seçimiyle değişebilir)
|
||||
// 🔹 Model detayları cache (product-detail API verilerini tutar)
|
||||
const productCache = reactive({})
|
||||
const showBulkDueDateDialog = ref(false)
|
||||
const bulkDueDateValue = ref('')
|
||||
const confirmAndSubmit = async () => {
|
||||
if (orderStore.loading) return
|
||||
|
||||
@@ -918,6 +965,43 @@ const confirmAndSubmit = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
function openBulkDueDateDialog() {
|
||||
if (!canBulkUpdateLineDueDates.value) return
|
||||
|
||||
const firstRowDate = summaryRows.value?.find?.(row => !!row?.terminTarihi)?.terminTarihi || ''
|
||||
bulkDueDateValue.value = toDateOnly(form.AverageDueDate || firstRowDate || dayjs().format('YYYY-MM-DD'))
|
||||
showBulkDueDateDialog.value = true
|
||||
}
|
||||
|
||||
async function confirmBulkDueDateUpdate() {
|
||||
const dueDate = toDateOnly(bulkDueDateValue.value)
|
||||
if (!dueDate) {
|
||||
$q.notify({
|
||||
type: 'warning',
|
||||
message: 'Lutfen bir termin tarihi seciniz.'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await orderStore.bulkUpdateOrderLineDueDate(orderHeaderID.value, dueDate)
|
||||
orderStore.applyBulkLineDueDateLocally(dueDate)
|
||||
form.AverageDueDate = dueDate
|
||||
showBulkDueDateDialog.value = false
|
||||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: `Tum siparis satiri terminleri guncellendi (${Number(result?.updatedLines || 0)} satir).`
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('❌ confirmBulkDueDateUpdate hata:', err)
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: err?.message || 'Satir terminleri guncellenemedi.'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ===========================================================
|
||||
🗓️ SİPARİŞ TARİHLERİ — Varsayılan Değerler
|
||||
@@ -939,6 +1023,14 @@ const canMutateRows = computed(() => {
|
||||
if (isViewOnly.value) return false
|
||||
return isEditMode.value ? canUpdateOrder.value : canWriteOrder.value
|
||||
})
|
||||
const canBulkUpdateLineDueDates = computed(() => {
|
||||
if (!isEditMode.value) return false
|
||||
if (isViewOnly.value) return false
|
||||
if (isClosedOrder.value) return false
|
||||
if (!canUpdateOrder.value) return false
|
||||
if (!orderHeaderID.value) return false
|
||||
return Array.isArray(orderStore.summaryRows) && orderStore.summaryRows.length > 0
|
||||
})
|
||||
|
||||
function notifyNoPermission(message) {
|
||||
$q.notify({
|
||||
|
||||
@@ -668,6 +668,77 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
}
|
||||
,
|
||||
|
||||
async bulkUpdateOrderLineDueDate(orderId, dueDate) {
|
||||
const id = String(orderId || this.header?.OrderHeaderID || '').trim()
|
||||
const dateText = String(dueDate || '').trim()
|
||||
if (!id) {
|
||||
throw new Error('Siparis ID bulunamadi')
|
||||
}
|
||||
if (!dateText) {
|
||||
throw new Error('Termin tarihi secilmedi')
|
||||
}
|
||||
|
||||
try {
|
||||
this.loading = true
|
||||
const res = await api.post(`/order/${encodeURIComponent(id)}/bulk-due-date`, {
|
||||
dueDate: dateText
|
||||
})
|
||||
return res?.data || {}
|
||||
} catch (err) {
|
||||
const detail = await extractApiErrorDetail(err)
|
||||
const status = err?.status || err?.response?.status || '-'
|
||||
console.error(`❌ bulkUpdateOrderLineDueDate hata [${status}] order=${id}: ${detail}`)
|
||||
throw new Error(detail)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
,
|
||||
|
||||
applyBulkLineDueDateLocally(dueDate) {
|
||||
const dateText = String(dueDate || '').trim()
|
||||
if (!dateText) return
|
||||
|
||||
const hadUnsavedChanges = this.hasUnsavedChanges
|
||||
const patchRow = (row) => ({
|
||||
...row,
|
||||
terminTarihi: dateText,
|
||||
DueDate: dateText,
|
||||
DeliveryDate: dateText,
|
||||
PlannedDateOfLading: dateText
|
||||
})
|
||||
|
||||
this.orders = Array.isArray(this.orders)
|
||||
? this.orders.map(patchRow)
|
||||
: []
|
||||
|
||||
this.summaryRows = Array.isArray(this.summaryRows)
|
||||
? this.summaryRows.map(patchRow)
|
||||
: []
|
||||
|
||||
this.header = {
|
||||
...(this.header || {}),
|
||||
AverageDueDate: dateText
|
||||
}
|
||||
|
||||
if (this.originalHeader && typeof this.originalHeader === 'object') {
|
||||
this.originalHeader = {
|
||||
...this.originalHeader,
|
||||
AverageDueDate: dateText
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(this.originalLines)) {
|
||||
this.originalLines = this.originalLines.map(patchRow)
|
||||
}
|
||||
|
||||
this.persistLocalStorage?.()
|
||||
if (!hadUnsavedChanges) {
|
||||
this.markAsSaved?.()
|
||||
}
|
||||
}
|
||||
,
|
||||
|
||||
async downloadOrderPdf(id = null) {
|
||||
try {
|
||||
const orderId = id || this.header?.OrderHeaderID
|
||||
@@ -3216,6 +3287,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
if (!serverOrderId) {
|
||||
throw new Error('OrderHeaderID backend’den dönmedi')
|
||||
}
|
||||
const mailPayload = this.buildOrderMailPayload(lines, isNew)
|
||||
purgeNewDraftOnExit = isNew
|
||||
|
||||
/* =======================================================
|
||||
@@ -3275,7 +3347,6 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
|
||||
// 📧 Piyasa eşleşen alıcılara sipariş PDF gönderimi (kayıt başarılı olduktan sonra)
|
||||
try {
|
||||
const mailPayload = this.buildOrderMailPayload(lines, isNew)
|
||||
// UPDATE durumunda da mail gönderimi istendiği için isNew kontrolü kaldırıldı (v3.5)
|
||||
const mailRes = await this.sendOrderToMarketMails(serverOrderId, mailPayload)
|
||||
const sentCount = Number(mailRes?.sentCount || 0)
|
||||
|
||||
Reference in New Issue
Block a user