如题,合计后面的字段是computed里的receivableItemCnyTotal,现在我detail.receivableList里的invoiceAmountCny 改变了,但是computed不执行是怎么回事
computed: {
receivableItemCnyTotal () {
let total = 0
if (!this.detail.receivableList || this.detail.receivableList.length === 0) {
return 0
}
this.detail.receivableList.forEach(item => {
if (item.invoiceAmountCny) {
total += item.invoiceAmountCny
}
})
return total
}
},
receivableItemColumns: [{
title: '业务编号',
key: 'businessNo'
}, {
title: '费用名',
key: 'feeItemName'
}, {
title: '委托人',
key: 'receiveFromName'
}, {
title: '币别',
key: 'currency'
}, {
title: '总金额',
key: 'amount'
}, {
title: '汇率',
key: 'exchangeRate',
render: (h, params) => {
let found = _this.exchangeRateTemp.find(element => {
return element.currency === _this.detail.receivableList[params.index].currency
})
if (found) {
_this.detail.receivableList[params.index].exchangeRate = found.exchangeRate
return h('span', found.exchangeRate)
}
return h('span', '')
}
}, {
title: '未开票金额',
key: 'notInvoicedAmount',
render: (h, params) => {
let invoicedAmount = 0
if (_this.detail.receivableList[params.index].invoiceAmount) {
invoicedAmount = _this.detail.receivableList[params.index].invoiceAmount
}
let notInvoicedAmount = params.row.amount - invoicedAmount - params.row.otherInvoicedAmount
return h('span', notInvoicedAmount)
}
}, {
title: '当前开票金额',
key: 'invoiceAmount',
render: (h, params) => {
return h('div', [
h('InputNumber', {
props: {
size: 'small',
value: params.row.invoiceAmount,
min: 0,
max: params.row.amount - params.row.otherInvoicedAmount,
},
on: {
'on-change': e => {// eslint-disable-line
_this.detail.receivableList[params.index].invoiceAmount = e
},
},
}),
])
},
}, {
title: '当前开票金额(¥)',
key: 'invoiceAmountCny',
render: (h, params) => {
let invoicedAmount = 0
if (_this.detail.receivableList[params.index].invoiceAmount) {
invoicedAmount = _this.detail.receivableList[params.index].invoiceAmount
}
let invoiceAmountCny = invoicedAmount * _this.detail.receivableList[params.index].exchangeRate
_this.detail.receivableList[params.index].invoiceAmountCny = invoiceAmountCny
return h('span', invoiceAmountCny)
},
}, {
title: '税率',
key: 'taxRate'
}, {
title: '税额(¥)',
key: 'taxAmount'
}]
===========作者的答案=============
原型上的数据没有改变,因为初始化的时候这个属性不存在