Refactor Part and Product models to change 'disabled' property to 'readOnly' for margin fields. Implement value calculation for margin based on price and cost when priceMode is 'amount', enhancing data handling and user experience.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
This commit is contained in:
parent
156d2a8baf
commit
8fbcc67230
@ -224,11 +224,23 @@ export const Part = {
|
||||
label: 'Margin',
|
||||
required: true,
|
||||
type: 'number',
|
||||
disabled: (objectData) => objectData?.priceMode == 'amount',
|
||||
readOnly: (objectData) => objectData?.priceMode == 'amount',
|
||||
suffix: '%',
|
||||
min: 0,
|
||||
max: 100,
|
||||
step: 0.01,
|
||||
value: (objectData) => {
|
||||
const priceMode = objectData?.priceMode
|
||||
const cost = objectData?.cost
|
||||
if (priceMode == 'amount') {
|
||||
const price = objectData?.price
|
||||
if (price != null && cost != null) {
|
||||
return Number(((price / cost - 1) * 100).toFixed(2)) || undefined
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
return objectData?.margin
|
||||
},
|
||||
columnWidth: 85
|
||||
},
|
||||
{
|
||||
|
||||
@ -254,11 +254,23 @@ export const Product = {
|
||||
label: 'Margin',
|
||||
required: true,
|
||||
type: 'number',
|
||||
disabled: (objectData) => objectData?.priceMode == 'amount',
|
||||
readOnly: (objectData) => objectData?.priceMode == 'amount',
|
||||
suffix: '%',
|
||||
min: 0,
|
||||
max: 100,
|
||||
step: 0.01,
|
||||
value: (objectData) => {
|
||||
const priceMode = objectData?.priceMode
|
||||
const cost = objectData?.cost
|
||||
if (priceMode == 'amount') {
|
||||
const price = objectData?.price
|
||||
if (price != null && cost != null) {
|
||||
return Number(((price / cost - 1) * 100).toFixed(2)) || undefined
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
return objectData?.margin
|
||||
},
|
||||
columnWidth: 85
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user