Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -216,6 +216,7 @@
|
||||
filled
|
||||
label="Yeni 2. Renk"
|
||||
:disable="isColorSelectionLocked(props.row)"
|
||||
@update:model-value="() => onNewDim2Change(props.row)"
|
||||
/>
|
||||
</q-td>
|
||||
</template>
|
||||
@@ -331,6 +332,13 @@ const store = useOrderProductionItemStore()
|
||||
const BAGGI_CODE_PATTERN = /^[A-Z][0-9]{3}-[A-Z]{3}[0-9]{5}$/
|
||||
const BAGGI_CODE_ERROR = 'Girdiginiz kod BAGGI kod sistemine uyumlu degil. Format: X999-XXX99999'
|
||||
|
||||
function nowMs () {
|
||||
if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
|
||||
return performance.now()
|
||||
}
|
||||
return Date.now()
|
||||
}
|
||||
|
||||
const orderHeaderID = computed(() => String(route.params.orderHeaderID || '').trim())
|
||||
const header = computed(() => store.header || {})
|
||||
const cariLabel = computed(() => {
|
||||
@@ -517,8 +525,13 @@ function onNewItemChange (row, val, source = 'typed') {
|
||||
applyNewItemVisualState(row, source)
|
||||
row.NewColor = ''
|
||||
row.NewDim2 = ''
|
||||
row.NewDesc = mergeDescWithAutoNote(row, row.NewDesc || row.OldDesc)
|
||||
if (row.NewItemCode) {
|
||||
store.fetchColors(row.NewItemCode)
|
||||
if (row.NewItemMode === 'new') {
|
||||
store.fetchNewColors(row.NewItemCode)
|
||||
} else {
|
||||
store.fetchColors(row.NewItemCode)
|
||||
}
|
||||
}
|
||||
if (row.NewItemMode === 'new' && isValidBaggiModelCode(row.NewItemCode) && row.NewItemCode !== prevCode) {
|
||||
openNewCodeSetupFlow(row.NewItemCode)
|
||||
@@ -560,14 +573,27 @@ function openNewCodeSetupFlow (itemCode) {
|
||||
function onNewColorChange (row) {
|
||||
row.NewColor = normalizeShortCode(row.NewColor, 3)
|
||||
row.NewDim2 = ''
|
||||
row.NewDesc = mergeDescWithAutoNote(row, row.NewDesc || row.OldDesc)
|
||||
if (row.NewItemCode && row.NewColor) {
|
||||
store.fetchSecondColors(row.NewItemCode, row.NewColor)
|
||||
if (String(row?.NewItemMode || '').trim() === 'new') {
|
||||
store.fetchNewSecondColors(row.NewItemCode, row.NewColor)
|
||||
} else {
|
||||
store.fetchSecondColors(row.NewItemCode, row.NewColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onNewDim2Change (row) {
|
||||
row.NewDim2 = normalizeShortCode(row.NewDim2, 3)
|
||||
row.NewDesc = mergeDescWithAutoNote(row, row.NewDesc || row.OldDesc)
|
||||
}
|
||||
|
||||
function getColorOptions (row) {
|
||||
const code = row?.NewItemCode || ''
|
||||
const list = store.colorOptionsByCode[code] || []
|
||||
const isNewMode = String(row?.NewItemMode || '').trim() === 'new'
|
||||
const list = isNewMode
|
||||
? (store.newColorOptionsByCode[code] || [])
|
||||
: (store.colorOptionsByCode[code] || [])
|
||||
return list.map(c => ({
|
||||
...c,
|
||||
colorLabel: `${c.color_code} - ${c.color_description || ''}`.trim()
|
||||
@@ -578,7 +604,10 @@ function getSecondColorOptions (row) {
|
||||
const code = row?.NewItemCode || ''
|
||||
const color = row?.NewColor || ''
|
||||
const key = `${code}::${color}`
|
||||
const list = store.secondColorOptionsByKey[key] || []
|
||||
const isNewMode = String(row?.NewItemMode || '').trim() === 'new'
|
||||
const list = isNewMode
|
||||
? (store.newSecondColorOptionsByKey[key] || [])
|
||||
: (store.secondColorOptionsByKey[key] || [])
|
||||
return list.map(c => ({
|
||||
...c,
|
||||
item_dim2_label: `${c.item_dim2_code} - ${c.color_description || ''}`.trim()
|
||||
@@ -609,6 +638,55 @@ function isValidBaggiModelCode (code) {
|
||||
return BAGGI_CODE_PATTERN.test(code)
|
||||
}
|
||||
|
||||
function formatCodeColorDim2 (itemCode, color, dim2) {
|
||||
const item = String(itemCode || '').trim().toUpperCase()
|
||||
const c1 = normalizeShortCode(color, 3)
|
||||
const c2 = normalizeShortCode(dim2, 3)
|
||||
const c1Safe = c1 || '-'
|
||||
const c2Safe = c2 || '-'
|
||||
return `${item}/${c1Safe}/${c2Safe}`
|
||||
}
|
||||
|
||||
function buildAutoUpdateNote (row) {
|
||||
const oldInfo = formatCodeColorDim2(row?.OldItemCode, row?.OldColor, row?.OldDim2)
|
||||
const nextInfo = formatCodeColorDim2(row?.NewItemCode, row?.NewColor, row?.NewDim2)
|
||||
return `Bu siparis satirinda kod ${oldInfo} bilgisinden ${nextInfo} bilgisine guncellenmistir.`
|
||||
}
|
||||
|
||||
function isSelectionCompleteByOldShape (row) {
|
||||
const hasModel = String(row?.NewItemCode || '').trim().length > 0
|
||||
if (!hasModel) return false
|
||||
|
||||
const oldHasColor = String(row?.OldColor || '').trim().length > 0
|
||||
const oldHasDim2 = String(row?.OldDim2 || '').trim().length > 0
|
||||
const hasNewColor = normalizeShortCode(row?.NewColor, 3).length === 3
|
||||
const hasNewDim2 = normalizeShortCode(row?.NewDim2, 3).length === 3
|
||||
|
||||
if (oldHasDim2) return hasNewColor && hasNewDim2
|
||||
if (oldHasColor) return hasNewColor
|
||||
return true
|
||||
}
|
||||
|
||||
function stripAutoUpdateNote (text) {
|
||||
const desc = String(text || '').trim()
|
||||
if (!desc) return ''
|
||||
const marker = ' Bu siparis satirinda kod '
|
||||
const idx = desc.indexOf(marker)
|
||||
if (idx > -1) return desc.slice(0, idx).trim()
|
||||
if (desc.startsWith('Bu siparis satirinda kod ')) return ''
|
||||
return desc
|
||||
}
|
||||
|
||||
function mergeDescWithAutoNote (row, baseDesc) {
|
||||
const desc = stripAutoUpdateNote(baseDesc)
|
||||
if (!isSelectionCompleteByOldShape(row)) return desc
|
||||
const note = buildAutoUpdateNote(row)
|
||||
if (!note) return desc
|
||||
if (desc.includes(note)) return desc
|
||||
if (!desc) return note
|
||||
return `${desc} ${note}`
|
||||
}
|
||||
|
||||
function validateRowInput (row) {
|
||||
const entryMode = String(row?.NewItemEntryMode || '').trim()
|
||||
const newItemCode = String(row.NewItemCode || '').trim().toUpperCase()
|
||||
@@ -631,6 +709,7 @@ function validateRowInput (row) {
|
||||
row.NewItemCode = newItemCode
|
||||
row.NewColor = newColor
|
||||
row.NewDim2 = newDim2
|
||||
row.NewDesc = mergeDescWithAutoNote(row, row.NewDesc || row.OldDesc)
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -646,7 +725,7 @@ function collectLinesFromRows (selectedRows) {
|
||||
NewItemCode: String(row.NewItemCode || '').trim().toUpperCase(),
|
||||
NewColor: normalizeShortCode(row.NewColor, 3),
|
||||
NewDim2: normalizeShortCode(row.NewDim2, 3),
|
||||
NewDesc: String((row.NewDesc || row.OldDesc) || '').trim()
|
||||
NewDesc: mergeDescWithAutoNote(row, row.NewDesc || row.OldDesc)
|
||||
}
|
||||
|
||||
for (const id of (row.OrderLineIDs || [])) {
|
||||
@@ -668,7 +747,7 @@ function createEmptyCdItemDraft (itemCode) {
|
||||
ProductHierarchyID: '',
|
||||
UnitOfMeasureCode1: 'AD',
|
||||
ItemAccountGrCode: '',
|
||||
ItemTaxGrCode: '10%',
|
||||
ItemTaxGrCode: '%10',
|
||||
ItemPaymentPlanGrCode: '',
|
||||
ItemDiscountGrCode: '',
|
||||
ItemVendorGrCode: '',
|
||||
@@ -715,11 +794,6 @@ function isDummyLookupOption (key, codeRaw, descRaw) {
|
||||
if (code === '0' || code === '00' || code === '000' || code === '0000') return true
|
||||
if (desc.includes('DUMMY')) return true
|
||||
|
||||
// Is plani dokumanindaki sari/default alanlar
|
||||
if (key === 'unitOfMeasureCode1List' && code === 'AD') return true
|
||||
if (key === 'itemTaxGrCodes' && code === '10%') return true
|
||||
if (key === 'companyCodes' && code === '1') return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -755,19 +829,19 @@ function normalizeCdItemDraftForPayload (draftRaw) {
|
||||
ItemTypeCode: toIntOrNil(d.ItemTypeCode) || 1,
|
||||
ItemCode: String(d.ItemCode || '').trim().toUpperCase(),
|
||||
ItemDimTypeCode: toIntOrNil(d.ItemDimTypeCode) || 1,
|
||||
ProductTypeCode: 1,
|
||||
ProductTypeCode: null,
|
||||
ProductHierarchyID: toIntOrNil(d.ProductHierarchyID),
|
||||
UnitOfMeasureCode1: 'AD',
|
||||
ItemAccountGrCode: null,
|
||||
ItemTaxGrCode: '10%',
|
||||
ItemTaxGrCode: '%10',
|
||||
ItemPaymentPlanGrCode: null,
|
||||
ItemDiscountGrCode: null,
|
||||
ItemVendorGrCode: null,
|
||||
PromotionGroupCode: null,
|
||||
ProductCollectionGrCode: '0',
|
||||
StorePriceLevelCode: '0',
|
||||
PerceptionOfFashionCode: '0',
|
||||
CommercialRoleCode: '0',
|
||||
ProductCollectionGrCode: null,
|
||||
StorePriceLevelCode: null,
|
||||
PerceptionOfFashionCode: null,
|
||||
CommercialRoleCode: null,
|
||||
StoreCapacityLevelCode: null,
|
||||
CustomsTariffNumberCode: null,
|
||||
CompanyCode: '1'
|
||||
@@ -956,6 +1030,11 @@ function buildProductionUpdateMailPayload (selectedRows) {
|
||||
async function sendUpdateMailAfterApply (selectedRows) {
|
||||
const orderId = String(orderHeaderID.value || '').trim()
|
||||
if (!orderId) return
|
||||
const host = String(window?.location?.hostname || '').trim().toLowerCase()
|
||||
const isLocalHost = host === 'localhost' || host === '127.0.0.1'
|
||||
if (isLocalHost) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const payload = buildProductionUpdateMailPayload(selectedRows)
|
||||
@@ -1082,12 +1161,14 @@ async function refreshAll () {
|
||||
}
|
||||
|
||||
async function onBulkSubmit () {
|
||||
const flowStart = nowMs()
|
||||
const selectedRows = rows.value.filter(r => !!selectedMap.value[r.RowKey])
|
||||
if (!selectedRows.length) {
|
||||
$q.notify({ type: 'warning', message: 'Lutfen en az bir satir seciniz.' })
|
||||
return
|
||||
}
|
||||
|
||||
const prepStart = nowMs()
|
||||
const { errMsg, lines } = collectLinesFromRows(selectedRows)
|
||||
if (errMsg) {
|
||||
$q.notify({ type: 'negative', message: errMsg })
|
||||
@@ -1112,8 +1193,24 @@ async function onBulkSubmit () {
|
||||
return
|
||||
}
|
||||
|
||||
console.info('[OrderProductionUpdate] onBulkSubmit prepared', {
|
||||
orderHeaderID: orderHeaderID.value,
|
||||
selectedRowCount: selectedRows.length,
|
||||
lineCount: lines.length,
|
||||
cdItemCount: cdItems.length,
|
||||
attributeCount: productAttributes.length,
|
||||
prepDurationMs: Math.round(nowMs() - prepStart)
|
||||
})
|
||||
|
||||
try {
|
||||
const validateStart = nowMs()
|
||||
const validate = await store.validateUpdates(orderHeaderID.value, lines)
|
||||
console.info('[OrderProductionUpdate] validate finished', {
|
||||
orderHeaderID: orderHeaderID.value,
|
||||
lineCount: lines.length,
|
||||
missingCount: Number(validate?.missingCount || 0),
|
||||
durationMs: Math.round(nowMs() - validateStart)
|
||||
})
|
||||
const missingCount = validate?.missingCount || 0
|
||||
if (missingCount > 0) {
|
||||
const missingList = (validate?.missing || []).map(v => (
|
||||
@@ -1126,7 +1223,13 @@ async function onBulkSubmit () {
|
||||
ok: { label: 'Ekle ve Guncelle', color: 'primary' },
|
||||
cancel: { label: 'Vazgec', flat: true }
|
||||
}).onOk(async () => {
|
||||
const applyStart = nowMs()
|
||||
await store.applyUpdates(orderHeaderID.value, lines, true, cdItems, productAttributes)
|
||||
console.info('[OrderProductionUpdate] apply finished', {
|
||||
orderHeaderID: orderHeaderID.value,
|
||||
insertMissing: true,
|
||||
durationMs: Math.round(nowMs() - applyStart)
|
||||
})
|
||||
await store.fetchItems(orderHeaderID.value)
|
||||
selectedMap.value = {}
|
||||
await sendUpdateMailAfterApply(selectedRows)
|
||||
@@ -1134,7 +1237,13 @@ async function onBulkSubmit () {
|
||||
return
|
||||
}
|
||||
|
||||
const applyStart = nowMs()
|
||||
await store.applyUpdates(orderHeaderID.value, lines, false, cdItems, productAttributes)
|
||||
console.info('[OrderProductionUpdate] apply finished', {
|
||||
orderHeaderID: orderHeaderID.value,
|
||||
insertMissing: false,
|
||||
durationMs: Math.round(nowMs() - applyStart)
|
||||
})
|
||||
await store.fetchItems(orderHeaderID.value)
|
||||
selectedMap.value = {}
|
||||
await sendUpdateMailAfterApply(selectedRows)
|
||||
@@ -1148,6 +1257,10 @@ async function onBulkSubmit () {
|
||||
})
|
||||
$q.notify({ type: 'negative', message: store.error || 'Toplu kayit islemi basarisiz.' })
|
||||
}
|
||||
console.info('[OrderProductionUpdate] onBulkSubmit total', {
|
||||
orderHeaderID: orderHeaderID.value,
|
||||
durationMs: Math.round(nowMs() - flowStart)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user