Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -164,7 +164,7 @@
|
||||
@click="openCdItemDialog(props.row.NewItemCode)"
|
||||
/>
|
||||
<q-btn
|
||||
v-if="props.row.NewItemMode === 'new'"
|
||||
v-if="props.row.NewItemMode && props.row.NewItemMode !== 'empty'"
|
||||
class="q-ml-xs"
|
||||
dense
|
||||
flat
|
||||
@@ -535,6 +535,8 @@ function onNewItemChange (row, val, source = 'typed') {
|
||||
}
|
||||
if (row.NewItemMode === 'new' && isValidBaggiModelCode(row.NewItemCode) && row.NewItemCode !== prevCode) {
|
||||
openNewCodeSetupFlow(row.NewItemCode)
|
||||
} else if (row.NewItemMode === 'existing' && isValidBaggiModelCode(row.NewItemCode) && row.NewItemCode !== prevCode) {
|
||||
openAttributeDialog(row.NewItemCode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,17 +915,33 @@ async function openAttributeDialog (itemCode) {
|
||||
const code = String(itemCode || '').trim().toUpperCase()
|
||||
if (!code) return
|
||||
attributeTargetCode.value = code
|
||||
const existing = store.getProductAttributeDraft(code)
|
||||
const existingDraft = store.getProductAttributeDraft(code)
|
||||
const fetched = await store.fetchProductAttributes(1)
|
||||
const fromLookup = buildAttributeRowsFromLookup(fetched)
|
||||
if (!fromLookup.length) {
|
||||
$q.notify({ type: 'negative', message: 'Urun ozellikleri listesi alinamadi. Lutfen daha sonra tekrar deneyin.' })
|
||||
return
|
||||
}
|
||||
const baseRows = fromLookup
|
||||
attributeRows.value = Array.isArray(existing) && existing.length
|
||||
? JSON.parse(JSON.stringify(existing))
|
||||
: baseRows
|
||||
const modeInfo = store.classifyItemCode(code)
|
||||
const dbCurrent = modeInfo.mode === 'existing'
|
||||
? await store.fetchProductItemAttributes(code, 1)
|
||||
: []
|
||||
|
||||
const dbMap = new Map(
|
||||
(dbCurrent || []).map(x => [
|
||||
Number(x?.attribute_type_code || x?.AttributeTypeCode || 0),
|
||||
String(x?.attribute_code || x?.AttributeCode || '').trim()
|
||||
]).filter(x => x[0] > 0)
|
||||
)
|
||||
|
||||
const baseRows = fromLookup.map(row => ({
|
||||
...row,
|
||||
AttributeCode: dbMap.get(Number(row.AttributeTypeCodeNumber || 0)) || ''
|
||||
}))
|
||||
|
||||
attributeRows.value = Array.isArray(existingDraft) && existingDraft.length
|
||||
? JSON.parse(JSON.stringify(existingDraft))
|
||||
: JSON.parse(JSON.stringify(baseRows))
|
||||
for (const row of (attributeRows.value || [])) {
|
||||
if (!Array.isArray(row.AllOptions)) {
|
||||
row.AllOptions = Array.isArray(row.Options) ? [...row.Options] : []
|
||||
@@ -932,6 +950,9 @@ async function openAttributeDialog (itemCode) {
|
||||
row.Options = [...row.AllOptions]
|
||||
}
|
||||
}
|
||||
if ((!existingDraft || !existingDraft.length) && baseRows.length) {
|
||||
store.setProductAttributeDraft(code, JSON.parse(JSON.stringify(baseRows)))
|
||||
}
|
||||
attributeDialogOpen.value = true
|
||||
}
|
||||
|
||||
@@ -950,7 +971,7 @@ function saveAttributeDraft () {
|
||||
$q.notify({ type: 'positive', message: 'Urun ozellikleri taslagi kaydedildi.' })
|
||||
}
|
||||
|
||||
function collectProductAttributesFromSelectedRows (selectedRows) {
|
||||
async function collectProductAttributesFromSelectedRows (selectedRows) {
|
||||
const codeSet = [...new Set(
|
||||
(selectedRows || [])
|
||||
.map(r => String(r?.NewItemCode || '').trim().toUpperCase())
|
||||
@@ -959,7 +980,23 @@ function collectProductAttributesFromSelectedRows (selectedRows) {
|
||||
const out = []
|
||||
|
||||
for (const code of codeSet) {
|
||||
const rows = store.getProductAttributeDraft(code)
|
||||
let rows = store.getProductAttributeDraft(code)
|
||||
if (!Array.isArray(rows) || !rows.length) {
|
||||
const lookup = await store.fetchProductAttributes(1)
|
||||
const baseRows = buildAttributeRowsFromLookup(lookup)
|
||||
const dbCurrent = await store.fetchProductItemAttributes(code, 1)
|
||||
const dbMap = new Map(
|
||||
(dbCurrent || []).map(x => [
|
||||
Number(x?.attribute_type_code || x?.AttributeTypeCode || 0),
|
||||
String(x?.attribute_code || x?.AttributeCode || '').trim()
|
||||
]).filter(x => x[0] > 0)
|
||||
)
|
||||
rows = baseRows.map(row => ({
|
||||
...row,
|
||||
AttributeCode: dbMap.get(Number(row.AttributeTypeCodeNumber || 0)) || ''
|
||||
}))
|
||||
store.setProductAttributeDraft(code, JSON.parse(JSON.stringify(rows)))
|
||||
}
|
||||
if (!Array.isArray(rows) || !rows.length) {
|
||||
return { errMsg: `${code} icin urun ozellikleri secilmedi`, productAttributes: [] }
|
||||
}
|
||||
@@ -1185,7 +1222,7 @@ async function onBulkSubmit () {
|
||||
if (firstCode) openCdItemDialog(firstCode)
|
||||
return
|
||||
}
|
||||
const { errMsg: attrErrMsg, productAttributes } = collectProductAttributesFromSelectedRows(selectedRows)
|
||||
const { errMsg: attrErrMsg, productAttributes } = await collectProductAttributesFromSelectedRows(selectedRows)
|
||||
if (attrErrMsg) {
|
||||
$q.notify({ type: 'negative', message: attrErrMsg })
|
||||
const firstCode = String(attrErrMsg.split(' ')[0] || '').trim()
|
||||
|
||||
Reference in New Issue
Block a user