我需要在最后将自定义行(与之前的行不同)添加到我的网格 b 表中。我怎样才能做到这一点?我有项目的网格 | 金额 | 价格和最后一行我需要计算项目的总金额和总价格。
<template>
<div>
<b-table
striped hover :busy="isBusy" :fields="fields" :items="items" :show-empty="true"
:empty-text="'Nebyly nalezeny žádné záznamy'" class="mb-0"
>
<template slot="name" slot-scope="data">
<div class="form-group">
<b-form-input type="text" class="form-control w-100" size="sm" v-model.lazy="data.item.name">
</b-form-input>
</div>
</template>
<template slot="unit_price" slot-scope="data">
<div class="form-group">
<b-form-input type="number" class="form-control w-100" size="sm" v-model.number="data.item.unit_price" @change="updatePriceTogether(data.item)">
</b-form-input>
</div>
</template>
<template slot="amount" slot-scope="data">
<div class="form-group">
<b-form-input type="number" class="form-control w-100" size="sm" v-model.number="data.item.amount" @change="updatePriceTogether(data.item)">
</b-form-input>
</div>
</template>
<div slot="table-busy" class="text-center text-danger my-2">
<b-spinner class="align-middle"></b-spinner>
<strong>Načítání...</strong>
</div>
<template slot="actions" slot-scope="data">
<slot name="action-buttons" :data="data"></slot>
</template>
</b-table>
</div>
</template>
<script>
export default {
name: "CustomItemGrid",
props: {
isBusy: {
type: Boolean,
required: true
},
fields: {
type: Array,
required: true
},
items: {
type: Array,
required: true
}
},
methods: {
updatePriceTogether(item){
item.total_price = (item.unit_price * item.amount).toFixed(2);
}
}
}
</script>
所以我需要这样的东西:
Item_name | Price | Amount | total_ price
Item1 | 12€ | 123 | 1400€
Item2 | 12€ | 123 | 1400€
**EMPTY | Total: | XXX T| XXXX€**
如何添加最后一行(它必须始终在底部)