Skip to content

Commit

Permalink
feat:TSelectTable组件新增虚拟列表功能
Browse files Browse the repository at this point in the history
  • Loading branch information
wocwin committed Sep 27, 2024
1 parent 9e2f97e commit 248c70c
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 51 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default defineConfig({
text: "下拉选择表格组件",
link: "/components/TSelectTable/base.md"
},
{ text: "Virtualized TSelectTable<el-tag type='danger'>v1.4.13</el-tag>", link: "/components/multipleVirtual/base.md" },
{
text: "条件查询组件",
link: "/components/TQueryCondition/base.md"
Expand Down
90 changes: 48 additions & 42 deletions docs/components/TSelectTable/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ TSelectTable/slotUse
TSelectTable/isShowInput
:::


### TSelectTable 参数配置

---
Expand All @@ -147,48 +148,53 @@ TSelectTable/isShowInput

### 2、配置参数(Attributes)继承 el-table 及 el-select 属性

| 参数 | 说明 | 类型 | 默认值 |
| :------------------ | :-------------------------------------------------------------------------------------- | :------------------------ | :--------- |
| v-model | 绑定值 | boolean / string / number | 仅显示 |
| v-model:input-value | 输入框回显值 | boolean / string / number | - |
| isShowInput | 是否输入框显示 | Boolean | false |
| table | 表格数据对象 | Object | {} |
| ---data | 展示下拉数据源 | Array | [] |
| ---total | 数据总条数 | Number | - |
| ---pageSize | 每页显示条目个数 | Number | - |
| ---currentPage | 当前页数 | Number | - |
| columns | 表头信息 | Array | [] |
| ----bind | el-table-column Attributes | Object | - |
| ----fixed | 列是否固定( left, right) | string, boolean | - |
| ----align | 对齐方式(left/center/right) | String | center |
| ----render | 返回三个参数(text:当前值,row:当前整条数据 ,index:当前行) | function | - |
| ----slotName | 插槽显示此列数据(其值是具名作用域插槽) | String | - |
| ------scope | 具名插槽获取此行数据必须用解构接收{scope} | Object | 当前行数据 |
| keywords | 关键字配置(value-key 配置) | Object ||
| ------label | 选项的标签 | String | ‘label’ |
| ------value | 选项的值 | String / number | ‘value’ |
| radioTxt | 单选文案 | String | 单选 |
| multiple | 是否开启多选 | Boolean | false |
| filterMethod | 自定义过滤 | function | - |
| rowClickRadio | 是否开启整行选中(单选) | boolean | true |
| isShowFirstColumn | 是否显示首列(单选) | boolean | true |
| defaultSelectVal | 设置第一页默认选中项--keywords.value 值 | Array | [] |
| filterable | 是否开启过滤(根据 keywords 的 label 值进行过滤) | Boolean | true |
| reserveSelection | 是否支持翻页选中 | Boolean | true |
| isShowPagination | 开启分页 | Boolean | false |
| tableWidth | table 宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| selectWidth | select 宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| inputWidth | input 输入框的宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| inputAttr | 继承所有 el-input 的属性 | Object | - |
| isKeyup | 单选是否开启键盘事件 | Boolean | false |
| isShowQuery | 是否允许配置查询条件(继承 TQueryCondition 的所有属性、事件、插槽) | Boolean | false |
| isShowBlurBtn | 条件查询组件是否显示隐藏下拉框按钮 | Boolean | false |
| btnBind | 显示下拉框按钮配置,继承`el-button`所有属性;`默认值{type:'danger',btnTxt:'关闭下拉框'}` | Object | - |
| isClearQuery | 关闭下拉框是否清空搜索条件 | Boolean | false |
| selfExpanded | 是否始终显示下拉框 | Boolean | false |
| isExpanded | 是否显示下拉框 | Boolean | false |
| toolbar | el-table 头部插槽(位置:查询条件下面) | slot | - |
| footer | el-table 底部插槽(位置:分页器上面) | slot | - |
| 参数 | 说明 | 类型 | 默认值 |
| :------------------------------------- | :-------------------------------------------------------------------------------------- | :------------------------ | :--------- |
| v-model | 绑定值 | boolean / string / number | 仅显示 |
| v-model:input-value | 输入框回显值 | boolean / string / number | - |
| isShowInput | 是否输入框显示 | Boolean | false |
| table | 表格数据对象 | Object | {} |
| ---data | 展示下拉数据源 | Array | [] |
| ---total | 数据总条数 | Number | - |
| ---pageSize | 每页显示条目个数 | Number | - |
| ---currentPage | 当前页数 | Number | - |
| columns | 表头信息 | Array | [] |
| ----bind | el-table-column Attributes | Object | - |
| ----fixed | 列是否固定( left, right) | string, boolean | - |
| ----align | 对齐方式(left/center/right) | String | center |
| ----render | 返回三个参数(text:当前值,row:当前整条数据 ,index:当前行) | function | - |
| ----slotName | 插槽显示此列数据(其值是具名作用域插槽) | String | - |
| ------scope | 具名插槽获取此行数据必须用解构接收{scope} | Object | 当前行数据 |
| keywords | 关键字配置(value-key 配置) | Object ||
| ------label | 选项的标签 | String | ‘label’ |
| ------value | 选项的值 | String / number | ‘value’ |
| radioTxt | 单选文案 | String | 单选 |
| multiple | 是否开启多选 | Boolean | false |
| filterMethod | 自定义过滤 | function | - |
| rowClickRadio | 是否开启整行选中(单选) | boolean | true |
| isShowFirstColumn | 是否显示首列(单选) | boolean | true |
| defaultSelectVal | 设置第一页默认选中项--keywords.value 值 | Array | [] |
| filterable | 是否开启过滤(根据 keywords 的 label 值进行过滤) | Boolean | true |
| reserveSelection | 是否支持翻页选中 | Boolean | true |
| isShowPagination | 开启分页 | Boolean | false |
| tableWidth | table 宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| selectWidth | select 宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| inputWidth | input 输入框的宽度(单位:px) 若设置 0,宽度 100% | Number/String | 550 |
| inputAttr | 继承所有 el-input 的属性 | Object | - |
| isKeyup | 单选是否开启键盘事件 | Boolean | false |
| isShowQuery | 是否允许配置查询条件(继承 TQueryCondition 的所有属性、事件、插槽) | Boolean | false |
| isShowBlurBtn | 条件查询组件是否显示隐藏下拉框按钮 | Boolean | false |
| btnBind | 显示下拉框按钮配置,继承`el-button`所有属性;`默认值{type:'danger',btnTxt:'关闭下拉框'}` | Object | - |
| isClearQuery | 关闭下拉框是否清空搜索条件 | Boolean | false |
| selfExpanded | 是否始终显示下拉框 | Boolean | false |
| isExpanded | 是否显示下拉框 | Boolean | false |
| toolbar | el-table 头部插槽(位置:查询条件下面) | slot | - |
| footer | el-table 底部插槽(位置:分页器上面) | slot | - |
| multipleFixed<el-tag>1.4.13</el-tag> | table 是否固定多选 | Boolean | false |
| radioFixed<el-tag>1.4.13</el-tag> | table 是否固定单选 | Boolean | false |
| useVirtual<el-tag>1.4.13</el-tag> | table 是否开启虚拟滚动 | Boolean | false |
| virtualShowSize<el-tag>1.4.13</el-tag> | 虚拟列表的渲染行数 | Number | 30 |


### 3、事件(events)继承 el-table 及 el-select 属性

Expand Down
19 changes: 19 additions & 0 deletions docs/components/multipleVirtual/base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Virtualized TSelectTable
>默认显示`30`条数据,可以设置`virtualShowSize`属性来控制显示条数

### 单选--虚拟滚动Table<el-tag>1.4.13</el-tag>

:::demo `TSelectTable组件`标签添加属性`useVirtual`--开启虚拟滚动;`columns`中的项宽度需要使用`minWidth`;`单选`开启虚拟滚动`将自动隐藏单选项首列`

TSelectTable/radioVirtual
:::


### 多选--虚拟滚动Table<el-tag>1.4.13</el-tag>

:::demo `TSelectTable组件`标签添加属性`useVirtual`--开启虚拟滚动。

TSelectTable/multipleVirtual
:::

47 changes: 47 additions & 0 deletions docs/examples/TSelectTable/multipleVirtual.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<t-layout-page>
<t-layout-page-item>
<t-select-table
:table="table"
:columns="table.columns"
:max-height="400"
:keywords="{ label: 'name', value: 'id' }"
multiple
:virtualShowSize="50"
placeholder="请选择(虚拟滚动--多选)"
useVirtual
@selectionChange="selectionChange"
/>
</t-layout-page-item>
</t-layout-page>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue"
let table = ref({
data: [] as any,
columns: [
{ label: "物料编号", width: "100px", prop: "code" },
{ label: "物料名称", width: "149px", prop: "name" },
{ label: "规格", width: "149px", prop: "spec" },
{ label: "单位", width: "110px", prop: "unitName" }
]
})
onMounted(() => {
initDate()
})
const initDate = () => {
table.value.data = []
const tableData = Array.from({ length: 1000 }, (_, i) => ({
id: i + 1,
code: i + 1,
name: `物料名称${i}`,
spec: `物料规格 ${i}`,
unitName: `吨 ${i}`
}))
table.value.data = tableData
}
const selectionChange = (val, ids) => {
console.log("复选框", val)
console.log("复选框--id", ids)
}
</script>
45 changes: 45 additions & 0 deletions docs/examples/TSelectTable/radioVirtual.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<t-layout-page>
<t-layout-page-item>
<t-select-table
:table="table"
:columns="table.columns"
:max-height="400"
useVirtual
:virtualShowSize="20"
placeholder="请选择(虚拟滚动--单选)"
:keywords="{ label: 'name', value: 'id' }"
@radioChange="(...args) => radioChange(args, '单选')"
/>
</t-layout-page-item>
</t-layout-page>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue"
const table = ref({
data: [] as any[],
columns: [
{ label: "物料编号", minWidth: "100px", prop: "code" },
{ label: "物料名称", minWidth: "149px", prop: "name" },
{ label: "规格", minWidth: "149px", prop: "spec" },
{ label: "单位", minWidth: "110px", prop: "unitName" }
]
})
onMounted(() => {
initDate()
})
const initDate = () => {
table.value.data = []
const tableData = Array.from({ length: 1000 }, (_, i) => ({
id: i + 1,
code: i + 1,
name: `物料名称${i + 1}`,
spec: `物料规格 ${i + 1}`,
unitName: `吨 ${i + 1}`
}))
table.value.data = tableData
}
const radioChange = (args, type) => {
console.log("单选--传给后台的值", args, type)
}
</script>
Loading

0 comments on commit 248c70c

Please sign in to comment.