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

View File

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