| | |
| | | @selection-change="handleSelectionChange" |
| | | :header-cell-style="{ background: '#ECF4FF', color: '#666' }" |
| | | > |
| | | <el-table-column type="selection" width="40"> </el-table-column> |
| | | <el-table-column v-if="selectBox" type="selection" width="40"> </el-table-column> |
| | | |
| | | <el-table-column |
| | | v-for="(item, i) in tableList.tableColumn" |
| | | :key="i" |
| | |
| | | :label="item.label" |
| | | :width="item.width" |
| | | :min-width="item.min" |
| | | sortable |
| | | show-overflow-tooltip |
| | | :sortable="item.sortable" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <span v-if="item.price">{{ "¥" + number_format(scope.row[item.prop], 2, ".", ",") }}</span> |
| | | <div v-else-if="item.status" :class="scope.row.status">{{ scope.row[item.prop] }}</div> |
| | | <span v-else>{{ scope.row[item.prop] }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <slot name="tableButton" /> |
| | | <div slot="empty"> |
| | | <el-empty description="暂无数据"></el-empty> |
| | | </div> |
| | | </el-table> |
| | | </div> |
| | | </template> |
| | |
| | | export default { |
| | | name: "TableCommonView", |
| | | props: { |
| | | selectBox: { |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | |
| | | tableList: { |
| | | type: Object, |
| | | default: () => { |
| | | return { |
| | | selectBox: true, |
| | | tableInfomation: [], // 接口返回数据 |
| | | tableColumn: [ |
| | | // table表单 |
| | |
| | | getSummaries(param) { |
| | | if (this.showSummary.show) { |
| | | const { columns, data } = param |
| | | console.log(param) |
| | | const sums = [] |
| | | columns.forEach((column, index) => { |
| | | if (index === this.showSummary.mergeNumber) { |
| | | sums[index] = "本页总计" |
| | | } |
| | | const values = data.map((item) => Number(item[column.property])) |
| | | // if (column.property === this.showSummary.sumProp) { |
| | | if (this.showSummary.sumProp.includes(column.property)) { |
| | | sums[index + 1] = values.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return this.number_format(prev + curr, 2, ".", ",") |
| | | return prev + curr |
| | | } else { |
| | | return this.number_format(prev, 2, ".", ",") |
| | | return prev |
| | | } |
| | | }, 0) |
| | | sums[index + 1] |
| | | } |
| | | }) |
| | | console.log(sums) |
| | | return sums |
| | | } |
| | | }, |
| | | //定义number_format方法 |
| | | // 数字换行为金额显示格式 |
| | | number_format(number, decimals, dec_point, thousands_sep) { |
| | | decimals = 2 //这里默认设置保留两位小数,也可以注释这句采用传入的参数 |
| | | /* |
| | |
| | | margin-top: 20px; |
| | | margin-right: 10px; |
| | | margin-bottom: 40px; |
| | | .blue { |
| | | width: 70px; |
| | | text-align: center; |
| | | color: #fff; |
| | | background-color: $color-primary; |
| | | border-radius: 4px; |
| | | } |
| | | } |
| | | ::v-deep { |
| | | .el-table__footer-wrapper tbody td.el-table__cell { |