一、el-table指定汇总列
<el-table :row-key="(row) => row.Id" :data="listData" border show-summary :summary-method="summaryColumn" style="width: 100%"> <!-- <el-table-column prop="Id" label="ID" > </el-table-column> --> <el-table-column prop="CostName" label="费用名称" width="120px"></el-table-column> <el-table-column prop="AgentName" sortable label="供应商"></el-table-column> <el-table-column prop="Qty" sortable label="数量" width="85px"></el-table-column> <el-table-column prop="Price" sortable label="单价" width="85px"></el-table-column> <el-table-column prop="Curr" sortable label="币别" width="85px"></el-table-column> <el-table-column prop="Amount" sortable label="金额" width="85px"></el-table-column> <el-table-column prop="SettleCurr" sortable label="核算币别" width="85px"></el-table-column> <el-table-column prop="SettleAmount" sortable label="核算金额" width="85px"></el-table-column> </el-table> htmlhtml
summaryColumn(param) { const { columns, data } = param const sums = [] columns.forEach((column, index) => { if (index === 0) { sums[index] = '合计'; return; } const values = data.map(item => Number(item[column.property])); if (column.property == 'Qty'||column.property == 'Amount'||column.property == 'SettleAmount') { sums[index] = values.reduce((prev, curr) => { const value = Number(curr); if (!isNaN(value)) { return prev + curr; } else { return prev; } }, 0); sums[index]; } }); return sums },js
二、取 el-select 选择的name
<el-select v-model="value" filterable placeholder="请选择收费车型" @change="selectChange" > <el-option v-for="item in options" :key="item.DicValue" :label="item.DicName" :value="item.DicValue"> </el-option> </el-select>html
selectChange(index){ let listData=[]; listData = this.options; for (let i = 0; i <listData.length ; i++) { if ( listData[i].DicValue==this.value){ this.label=listData[i].DicName; alert(listData[i].DicName); } } },js
标签:index,const,column,sums,element,使用,return,property From: https://www.cnblogs.com/xbding/p/18009203