Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -126,12 +126,16 @@
|
||||
dense
|
||||
filled
|
||||
use-input
|
||||
fill-input
|
||||
hide-selected
|
||||
input-debounce="0"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="label"
|
||||
option-value="value"
|
||||
:options="productCodeSelectOptions"
|
||||
label="Eski Kod Sec"
|
||||
@filter="onFilterProductCode"
|
||||
@update:model-value="val => onSelectProduct(props.row, val)"
|
||||
/>
|
||||
|
||||
@@ -419,12 +423,36 @@ const newItemEntryModeOptions = [
|
||||
{ label: 'Eski Kod Sec', value: 'selected' },
|
||||
{ label: 'Yeni Kod Ekle', value: 'typed' }
|
||||
]
|
||||
const productCodeSelectOptions = computed(() =>
|
||||
const productCodeAllOptions = computed(() =>
|
||||
(productOptions.value || []).map(p => {
|
||||
const code = String(p?.ProductCode || '').trim().toUpperCase()
|
||||
return { label: code, value: code }
|
||||
}).filter(x => !!x.value && x.value.length === 13)
|
||||
)
|
||||
const productCodeSelectOptions = ref([])
|
||||
|
||||
watch(
|
||||
productCodeAllOptions,
|
||||
(list) => {
|
||||
productCodeSelectOptions.value = Array.isArray(list) ? [...list] : []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function onFilterProductCode (val, update) {
|
||||
const needle = normalizeSearchText(val)
|
||||
update(() => {
|
||||
if (!needle) {
|
||||
productCodeSelectOptions.value = [...productCodeAllOptions.value]
|
||||
return
|
||||
}
|
||||
productCodeSelectOptions.value = (productCodeAllOptions.value || []).filter(opt => {
|
||||
const label = normalizeSearchText(opt?.label || '')
|
||||
const value = normalizeSearchText(opt?.value || '')
|
||||
return label.includes(needle) || value.includes(needle)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function applyNewItemVisualState (row, source = 'typed') {
|
||||
const info = store.classifyItemCode(row?.NewItemCode || '')
|
||||
@@ -923,9 +951,7 @@ async function openAttributeDialog (itemCode) {
|
||||
return
|
||||
}
|
||||
const modeInfo = store.classifyItemCode(code)
|
||||
const dbCurrent = modeInfo.mode === 'existing'
|
||||
? await store.fetchProductItemAttributes(code, 1)
|
||||
: []
|
||||
const dbCurrent = await store.fetchProductItemAttributes(code, 1, true)
|
||||
|
||||
const dbMap = new Map(
|
||||
(dbCurrent || []).map(x => [
|
||||
@@ -934,12 +960,22 @@ async function openAttributeDialog (itemCode) {
|
||||
]).filter(x => x[0] > 0)
|
||||
)
|
||||
|
||||
const baseRows = fromLookup.map(row => ({
|
||||
...row,
|
||||
AttributeCode: dbMap.get(Number(row.AttributeTypeCodeNumber || 0)) || ''
|
||||
}))
|
||||
const baseRows = fromLookup.map(row => {
|
||||
const currentCode = dbMap.get(Number(row.AttributeTypeCodeNumber || 0)) || ''
|
||||
const currentOptions = Array.isArray(row.options) ? [...row.options] : []
|
||||
if (currentCode && !currentOptions.some(opt => String(opt?.value || '').trim() === currentCode)) {
|
||||
currentOptions.unshift({ value: currentCode, label: `${currentCode} - (Mevcut)` })
|
||||
}
|
||||
return {
|
||||
...row,
|
||||
AttributeCode: currentCode,
|
||||
AllOptions: currentOptions,
|
||||
Options: [...currentOptions]
|
||||
}
|
||||
})
|
||||
|
||||
attributeRows.value = Array.isArray(existingDraft) && existingDraft.length
|
||||
const useDraft = modeInfo.mode !== 'existing' && Array.isArray(existingDraft) && existingDraft.length
|
||||
attributeRows.value = useDraft
|
||||
? JSON.parse(JSON.stringify(existingDraft))
|
||||
: JSON.parse(JSON.stringify(baseRows))
|
||||
for (const row of (attributeRows.value || [])) {
|
||||
@@ -950,7 +986,7 @@ async function openAttributeDialog (itemCode) {
|
||||
row.Options = [...row.AllOptions]
|
||||
}
|
||||
}
|
||||
if ((!existingDraft || !existingDraft.length) && baseRows.length) {
|
||||
if ((!existingDraft || !existingDraft.length || modeInfo.mode === 'existing') && baseRows.length) {
|
||||
store.setProductAttributeDraft(code, JSON.parse(JSON.stringify(baseRows)))
|
||||
}
|
||||
attributeDialogOpen.value = true
|
||||
|
||||
Reference in New Issue
Block a user