# QTable
# 不分页表格
提示
1.prop 支持多级命名规范。
2.此组件为搭配Q-Print进行数据打印。
<template>
<QPrint ref="QPrint" :show-print-button="false">
<QTable :columns="exportColumn"
@print="handlePrint"
:showPrint="true"
>
</QTable>
</QPrint>
</template>
<script>
export default {
methods: {
handlePrint() {
this.$refs.QPrint.print()
},
}
}
</script>
Copy
# 分页表格
Copy
# Attributes
# Q-Table
属性名 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
data | 表格数据 | Array | — | [] |
columns | 表格列名 | Array | columns | [] |
rowsPerPage | 分页大小 | Number | — | 10 |
paginate | 是否分页 | Boolean | — | true |
centerText | 文字居中 | Boolean | — | true |
ellipsis | 一行 | Boolean | — | false |
border | 边框 | Boolean | — | false |
showTotalRow | 显示合计(calculate为true ) | Boolean | — | false |
number | 保留小数(配套showTotalRow ) | Number | — | 0 |
loadAll | 加载所有 | Boolean | — | false |
showTool | 工具栏 | Boolean | — | true |
showExportAll | 全部导出工具栏 | Boolean | — | true |
showPrint | 打印工具栏 | Boolean | — | false |
fetch | 获取数据函数 | Function | — | — |
fetchParams | 数据参数 | Object | — | {pageNum: 1,pageSize: 10} |
batch | 批次 | Number | — | 5 |
timeout | 防抖时间 | Number | — | 1000 |
options | 字典对象 | Object | — | — |
resConfig | 返回数据格式 | Object | — | — |
tableStyle | 表格样式 | Object | — | — |
# columns
提示
showTotalRow
为 true
,type
为 column.type === 'index'
,开启序号列为合计
resConfig
例子
const resConfig = {
rowsPath: 'data.rows',
totalPath: 'data.total'
}
tableStyle
例子
const resConfig = {
bodyHeight: '70px',
headerHeight: '60px'
}
data
表示整个表格数据,row
表示当前行。
const columns = {
prop: 'amount',
label: '消费金额',
func: (data, row) => {
return row.operationType == 2 ? '- ' + row.amount : row.amount
},
visible: true
}
属性名 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
label | 表头 | String | — | — |
prop | 字段 | String | — | — |
type /pattern | 类型 | index /selection / dict.xxx | — | — |
visible | 可见 | Boolean | — | false |
width | 宽度 | String /Number | — | auto |
calculate | 计算合计(需开启showTotalRow 为true ) | Boolean | — | false |
func | 自定义函数 | Function | — | - |
children | 子列 | columns | — | — |
# Events
事件名 | 说明 | 回调参数 | 参数说明 |
---|---|---|---|
data | 获取全部导出的数据 | value | 全部数据 |
selection | 获取勾选导出的数据 | value | 勾选数据 |
打印按钮 | — | — | |
res | 返回数据 | value | 返回数据 |
# Slots
属性名 | 说明 | 参数 |
---|---|---|
prop | 属性插槽 | {index, row, scope} |
footer | 尾部插槽 | — |
# 安装
提示
所需要的依赖(指明依赖,无需再次install)
npm install lodash
← 快速开始 Q-Print 打印 →