Track CLIN type change

- emit a new event when CLIN type changes
- update totals based on new CLIN type
This commit is contained in:
dandds 2019-06-17 10:10:42 -04:00 committed by montana
parent 23b7df2153
commit 0c58ad07fb
2 changed files with 18 additions and 14 deletions

View File

@ -37,6 +37,7 @@ export default {
indexOffset: this.initialLoaCount,
loas: loas,
clinType: this.initialClinType,
amount: this.initialAmount || 0,
}
},
@ -61,17 +62,22 @@ export default {
return index + this.indexOffset - 1
},
clinChangeEvent: function() {
emitEvent('clin-change', this, {
id: this._uid,
clinType: this.clinType,
amount: this.amount,
})
},
handleFieldChange: function(event) {
if (this._uid === event.parent_uid) {
if (event.name.includes(JEDI_CLIN_TYPE)) {
this.clinType = event.value
}
else if (event.name.includes(OBLIGATED_AMOUNT)) {
emitEvent('clin-change', this, {
id: this._uid,
clinType: this.clinType,
amount: parseFloat(event.value),
})
this.clinChangeEvent()
} else if (event.name.includes(OBLIGATED_AMOUNT)) {
this.amount = parseFloat(event.value)
this.clinChangeEvent()
}
}
},

View File

@ -61,14 +61,12 @@ export default {
let newTotal = 0
let newObligated = 0
Object.values(this.clinChildren).forEach(
function(clin) {
newTotal += clin.amount
if (clin.type.includes('1', '3')) {
newObligated += clin.amount
}
Object.values(this.clinChildren).forEach(function(clin) {
newTotal += clin.amount
if (clin.type.includes('1', '3')) {
newObligated += clin.amount
}
)
})
this.total = newTotal
this.obligated = newObligated
},