1.0.122 • Published 10 months ago

tw-vue-el v1.0.122

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

tw-vue-el

这个组件是基于在Vite中使用Vue 3和ElmentPlus(二次封装)进行开发,可以帮助您快速开发form和列表页面。默认引入了ElmentPlus基本多少有的组件。可以直接使用

自定义配置

请参见 Vite配置参考

项目使用

npm install tw-vue-el

mian.ts
import twVueEl from 'tw-vue-el'
import 'tw-vue-el/dist/style.css'

完整引入

import { createApp } from "vue"
import App from './App.vue'
import router from "./router/index"
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import twVueEl from 'tw-vue-el'
// 因为表格组件和form组件需要引入相关css
import 'tw-vue-el/dist/style.css'

const app = createApp(App)

app.use(ElementPlus,{locale: zhCn})
app.use(router)
app.use(twVueEl)
app.use(store)
app.mount('#app')

相关组件

<ContentMain></ContentMain>                             // --- 表格搜索
<ContentMainVirtualized></ContentMainVirtualized>       // --- 表格虚拟列表搜索
<CountTo></CountTo>                                     // --- 计步器
<TwForm></TwForm>                                       // --- form组件
<TwCustomForm></TwCustomForm>                           // --- 自定义form组件
<TwDialog></TwDialog>                                   // --- 弹框组件
<TwDrawer></TwDrawer>                                   // --- 抽屉组件
<TwFormItem></TwFormItem>                               // --- 自定义显示控件(基于formItem) 
<TwPagination></TwPagination>                           // --- 分页组件
<TwTable></TwTable>                                     // --- 表格组件
<TwVirtualizedTable></TwVirtualizedTable>               // --- 虚拟表格组件

表格搜索(ContentMain)

ContentMain 是tw-form和tw-table的集合它只接收一个参数mainData,内部的参数才是使用规则.此处只有基础配置属性,详情请跳转相关组件属性查看

ContentMain 使用示例
<template>
    <content-main ref="contentMainRef" :mainData="mainData"></content-main>
</template>

<script setup lang="tsx">
    let contentMainRef = $ref(null)
    
    let mainData = reactive({
        tableUrl: '/operation/appealHand/page',
        isCheck: true,
        columns: [
            {prop: 'appealTimeStr', label: '反馈时间', width: 180},
            {prop: 'alarmTypeName', label: '报警类型', width: 120},
            {prop: 'durationStr', label: '持续时长', width: 120},
            {prop: 'appealStatusName', label: '处理状态', width: 120},
            {prop: 'appealResultName', label: '处理结果', width: 120},
            {prop: 'processPerson', label: '处理人', width: 120},
            {prop: 'processTimeStr', label: '处理时间', width: 120},
        ],
        headBtns: [],
        tableBtns: {
            prop: 'btns',
            label: '操作',
            fixed: 'right',
            width: 100,
            btns: [
            ],
        },
        formData: {
            alarmLevel: 0,
            pageNumber: 1,
            pageSize: 50,
        },
        lists: [],
    })
</script> 

ContentMain 属性

属性名说明类型默认值
lists用于渲染表格上面搜索Array[]
foldNumber第一行默认显示数量Number3
rules验证规则(同el-formObject{}
formData同lists的key绑定使用,同时也会默认和表格api绑定获取数据Object{}
labelWidth搜索区域文字描述宽度String'120px'
isFormBnts是否显示tw-form相关的操作按钮Booleantrue
beforeChange点击搜索按钮时间前触发的事件Function-
url表格请求地址String-
idtable的唯一id,一页面多表格场景须赋值,否则无法动态计算高度String-
method表格动态url请求类型Stringpost
columns表格每一列渲染数据Array[]
lists表格每一行渲染数据Array[]
tableParams表格默认请求数据,这里代指mainData.formData。他们是绑定关系Object{ pageNumber: 1, pageSize: 25 }
tableHeight表格固定高度Number0
isRradio单选Booleanfalse
showPagination分页显示开关Booleantrue
botHeight是分页栏加上边距加底部空白位置高度Number50
indexFixed索引左侧定位开关Booleanfalse
isCheckcheckbox显示开关Booleanfalse
checkFixedcheckbox左侧定位开关String'left'
showIndex索引显示开关Booleanfalse
size表格大小配置String'large'
stripe斑马纹显示开关Booleantrue
border边框线显示开关Booleanfalse
pageSizesArr分页页码Array25, 50, 100
tableBtns单例按钮渲染数据Object-
small每页显示条数Booleanfalse
headBtns顶部操作按钮Array[]
isTableHeader默认显示表格顶部操作栏Booleantrue
isLoadStatus默认首次不加载table数据Booleanfalse
highlightCurrentRow是否高亮显示当前选中行Booleantrue
rowClassName行样式名称,同elTable一样Function-
selectableisCheck必须为true 用于判断选项是否可以点击,返回true或falseFunction{ return true}
autoScrollToTop请求数据后是否自动滚动到顶部Booleantrue
layout表格分页布局默认配置,依赖elPaginationStringtotal, prev, pager, next, sizes, jumper
background表格的背景颜色Booleantrue
loadingBg表格接口加载状态下背景颜色Stringrabg(225,225,225)
emptyText列表无数据时展示的文字String暂无数据

ContentMain 事件

事件名说明类型
tableCallback表格api加载完成后响应的事件Function
checkSelect表格点击checkbox响应的事件,对应elTable - select事件Function
rowCheck表格点击行数据响应的事件Function
tableCurrentChange当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性Function
resetFormform点击重置按钮响应的事件Function
submitFormform点击搜索按钮响应的事件Function
selectionChange表格的check选择, 对应elTable - selection-change事件Function

ContentMain Exposes

事件名说明类型
getTable主动触发表格加载Function
seekTable模拟触发form搜索事件功能Function
getAllCheck获取表格已勾选数据Function
getTableLists获取表格已渲染行数据Function
setTableLists设置表格待渲染的行数据Function
setCurrentRow设置表格行高亮Function
clearSelection清空表格已勾选数据Function
toggleRowSelection设置表格行数据选择Function
setTableTotal设置表格Total数值Function
setTableDataHeight重新计算表格的自适应高度Function

ContentMain 插槽

tw-form lists单个对象自定义key就是自定义插槽,适场景使用。虽然提供此功能,但不建议使用

事件名说明
tableHeader表格按钮上方自定义区域
table-l同表格按钮一行,左侧可操作区域
table-c同表格按钮一行,中间可操作区域
table-r同表格按钮一行,右侧可操作区域
tableBotHeader表格按钮下方自定义区域

表格虚拟列表搜索(ContentMainVirtualized)

ContentMainVirtualized 如需使用查看如下描述后在使用 1. 是tw-form和TwVirtualizedTable的集合它只接收一个参数mainData, 2. 本质如同contentMain,只是加载行为是滚动加载更多数据并且处理了keep-alive切换页面后的部分兼容问题 3. 其次因为大批量数据一般不会每次提供总数,所以数据接口和总数接口是做了分离的

ContentMainVirtualized 使用示例
<template>
    <content-main-virtualized ref="contentMainRef" :mainData="mainData"></content-main-virtualized>
</template>

<script setup lang="tsx">
    let contentMainRef = $ref(null)
    
    let mainData = reactive({
        tableUrl: '/operation/appealHand/page',
        totalUrl: '/operation/appealHand/pageCount',
        isCheck: true,
        selectable: (row, index) => {
            return row.appealStatusCode !== 300
        },
        columns: [
            {prop: 'appealTimeStr', label: '反馈时间', width: 180},
            {prop: 'alarmTypeName', label: '报警类型', width: 120},
            {prop: 'durationStr', label: '持续时长', width: 120},
            {prop: 'appealStatusName', label: '处理状态', width: 120},
            {prop: 'appealResultName', label: '处理结果', width: 120},
            {prop: 'processPerson', label: '处理人', width: 120},
            {prop: 'processTimeStr', label: '处理时间', width: 120},
        ],
        headBtns: [],
        tableBtns: {
            prop: 'btns',
            label: '操作',
            fixed: 'right',
            width: 100,
            btns: [
            ],
        },
        formData: {
            alarmLevel: 0,
            pageNumber: 1,
            pageSize: 50,
        },
        lists: [],
    })
</script> 

统计(CountTo)

显示统计数据。

CountTo 属性

属性名说明类型默认值
startVal动画开始值Number0
endVal动画结束值Number0
duration动画滚动时间Number3000
autoplay是否自动播放Booleantrue
decimals保留几位小数Number0
decimal小数String.
separator千分位符号String,
prefix统计值前置自定义文本String-
suffix统计值后置自定义文本String-
useEasing使用缓和Booleantrue
easingFn缓和回调Function-

CountTo 方法

方法名说明类型
mountedCallback挂载后返回的回调Function
callback动画后返回的回调Function

form组件(TwForm)

此组件只服务于contentMain,核心用法请综合TwCustomForm和contentMain描述区域使用。 注意:请不要混淆TwForm和TwCustomForm组件。 TwCustomForm会更轻量,便于更复杂的form场景使用

自定义form组件(TwCustomForm)

注意:请不要混淆TwForm和TwCustomForm组件。 TwCustomForm会更轻量,便于更复杂的form场景使用。请合理使用TwCustomForm组件

TwCustomForm组件自带placeholder,同时placeholder是跟label强关联的。并且可以自定义使用slot 1. 输入框提示:请输入年龄 2. 选择框提示:请选择年龄 3. 自定义使用slot需先声明slot为true,然后自定义编写具名template 4. 公共属性配置有type(定义需要显示的控件)和col(默认24,24等分同el-row的el-col)

基础使用示例
// 虽然vue3的模板语言说可以不在用div包着了,但是如果不包很有很多隐性的bug。请不要节省这个时间
// 虽然vue3的模板语言说可以不在用div包着了,但是如果不包很有很多隐性的bug。请不要节省这个时间
// 虽然vue3的模板语言说可以不在用div包着了,但是如果不包很有很多隐性的bug。请不要节省这个时间

<template>
    <div>
        <tw-custom-form
                ref="fromDataRef"
                :lists="mainData.lists"
                :rules="mainData.rules"
                :formData="mainData.formData"
            >
               <template #securityProtocol>
                  这里是持续时长的自定义
               </template>
            </tw-custom-form>
        <el-button @click="save">保存</el-button>
    </div>
     
</template>

<script setup lang="tsx">
    let fromDataRef = $ref(null)
    let mainData = reactive({
        lists: [
            {key: 'entryPointName', label: '反馈时间'},
            {key: 'basicProtocol', label: '报警类型'},
            {key: 'securityProtocol', label: '持续时长', slot: true},  // 自定义slot
        ],
        rules: {
            entryPointName: [
                { required: true, message: '请输入配置名称', trigger: 'blur'},
            ],
            basicProtocol: [
                { required: true, message: '请选择协议版本', trigger: 'blur'},
            ],
            securityProtocol: [
                { required: true, message: '请选择主动安全', trigger: 'blur'},
            ],
        },
    })
    
    // 组件内置有svae方法,详情请查看配置。
    const save = () => {
        fromDataRef.submitForm(false).then((form) => {
            loading = true
            addOrUpdate(form).then(() => {
                loading = false
            }).catch(() => {
                loading = false
            })
        })
    }
</script> 

自定义form组件最关键的就是lists参数,lists又是根据type来转义到相关内部组件,以下是能使用的type属性。type属性默认就是twInput(输入框)如上示例

TwCustomForm 属性

属性名说明类型默认值
lists用于渲染表格上面搜索。Array[]
rules验证规则(同el-formObject{}
formData同lists的key绑定使用,同时也会默认和表格api绑定获取数据Object{}
labelWidth搜索区域文字描述宽度String'120px'
isFormBnts是否显示tw-form相关的操作按钮Booleanfalse
beforeChange点击保存按钮时间前触发的Function-

TwCustomForm 属性 Lists type

label 和 key 是必传字段。其次type除了input框,也都是必传字段(具体请看下面配置)

1. twInput 输入框类型
{key: 'securityProtocol', label: '持续时长'}

col(默认24,24等分同el-row的el-col

属性名说明类型默认值
col响应式宽度设置Number24
labelWidth标签单个宽度String'120px'
maxlength同原生 maxlength 属性String/Number-
minlength原生属性,最小输入长度String/Number-
max原生 max 属性,设置最大值--
min原生属性,设置最小值--
showWordLimit是否显示统计字数, 只在 type 为 'text' 或 'textarea' 的时候生效BooleanBoolean
placeholder输入框占位文本String-
showPassword是否显示切换密码图标Booleanfalse
disabled是否禁用Booleanfalse
size输入框尺寸,只在 type 不为 'textarea' 时有效Enum-
prefixIcon自定义前缀图标(el引入的icon)Component-
suffixIcon自定义后缀图标(el引入的icon)Component-
rows输入框行数,仅 type 为 'textarea' 时有效NumberNumber
minRowstextarea 高度是否自适应,仅 type 为 'textarea' 时生效。 可以接受一个对象,比如: { minRows: 2, maxRows: 6 }Number-
maxRowstextarea 高度是否自适应,仅 type 为 'textarea' 时生效。 可以接受一个对象,比如: { minRows: 2, maxRows: 6 }Number-
readonly原生 readonly 属性,是否只读Booleanfalse
resize控制是否能被用户缩放Enum-
validateEvent输入时是否触发表单的校验Booleantrue
inputStyleinput 元素或 textarea 元素的 stylestring/object{}
clearable是否显示清除按钮,只有当 type 不是 textarea时生效Boolean-
props.type类型string等原生 input 类型text
2. select 选择框类型
// 基础
{key: 'securityProtocol', label: '持续时长', type: 'select', children: [ {label: '北京', value: 1'}]}

// 自定义label value
{key: 'securityProtocol', label: '持续时长', type: 'select', children: [ {labelZdy: '北京', valueZdy: 1'}], props: {label: 'labelZdy', value: 'valueZdy'}}

// 接口请求
{label: '车牌号', key: 'vehicleCode', type: 'select', remote: true, url: '/business/vehicle/associationPlateNum', method: 'post', loadMore: true, params: { keyword: route.query.plateNum ||'', pageNumber: 1, pageSize: 25, havePermission: true }, props: { label: 'plateNum', value: 'vehicleCode' }, placeholder: '请选择车牌号码',},

配置维度是依赖el-select

属性名说明类型默认值
col响应式宽度设置Number24
url接口地址,只有在remote: true情况使用String-
method接口请求类型String'post'
params接口请求参数Object{}
labelWidth标签单个宽度String'120px'
multiple是否多选Boolean-
collapseTags多选时是否将选中值按文字的形式展示,不等于false就默认为trueBoolean-
clearable是否可以清空选项Booleanfalse
disabled是否禁用Booleanfalse
remote其中的选项是否从服务器远程加载Booleanfalse
defaultFirstOption是否在输入框按下回车时,选择第一个匹配项。 需配合 filterable 或 remote 使用Booleanfalse
filterableSelect 组件是否可筛选Booleanfalse
allowCreate是否允许用户创建新条目, 只有当 filterable 设置为 true 时才会生效Booleanfalse
multipleLimitmultiple 属性设置为 true 时,代表多选场景下用户最多可以选择的项目数, 为 0 则不限制Number0
reserveKeyword当 multiple 和 filterable被设置为 true 时,是否在选中一个选项后保留当前的搜索关键词Booleantrue
children自定义下拉渲染数据Array[]
change选中值发生变化时触发Function-
3. date 日期选择器
// 基础
{label: '活动时间', key: 'date1', type:'date', showPassword: true },


// 日期时间选择
{label: '日期时间', key: 'date2', type:'date', data: {type: 'datetime'} },

// 时间格式
{ key: 'issueDate', label: '初次领证日期',col:12, type:'date', placeholder: '请输入初次领证日期', data: {valueFormat: 'YYYY-MM-DD'} },

配置维度是依赖el-date-picker

属性名说明类型默认值
col响应式宽度设置Number24
data.type显示类型Stringdate
data.format显示在输入框中的格式StringYYYY-MM-DD HH:mm:ss
disabled禁用Booleanfalse
placeholder非范围选择时的占位内容String-
clearable是否显示清除按钮Booleanfalse
disabledDate一个用来判断该日期是否被禁用的函数,接受一个 Date 对象作为参数。 应该返回一个 Boolean 值Function-
change选中值发生变化时触发Function-
4. time 时间选择器
// 基础
{label: '开始时间', key: 'startTime', type: 'time'}

// 时间选择
{label: '开始时间', key: 'startTime', type: 'time', data: {valueFormat: 'HH:mm:ss'}}

配置维度是依赖el-time-picker

属性名说明类型默认值
col响应式宽度设置Number24
defaultValue可选,选择器打开时默认显示的时间Date/object-
data.format显示在输入框中的格式StringYYYY-MM-DD HH:mm:ss
disabled禁用Booleanfalse
placeholder非范围选择时的占位内容String-
clearable是否显示清除按钮Booleanfalse
disabledHours禁止选择部分小时选项Function-
disabledMinutes禁止选择部分分钟选项Function-
disabledSeconds禁止选择部分秒选项Function-
change选中值发生变化时触发Function-
5. switch 开关
// 基础
{label: '状态', key: 'state', col: 6, type: 'switch'},


// 自定义名称
{label: '状态', key: 'state', col: 6, type: 'switch', activeText: '启用', inactiveText: '禁用', filter: 'valid'},

配置维度是依赖el-switch

属性名说明类型默认值
col响应式宽度设置Number24
activeTextswitch 打开时的文字描述Stringt
inactiveTextswitch 的状态为 off 时的文字描述String
disabled禁用Booleanfalse
activeValueswitch 状态为 on 时的值Booleantrue
inactiveValueswitch的状态为 off 时的值Booleanfalse
inlinePrompt无论图标或文本是否显示在点内,只会呈现文本的第一个字符Booleanfalse
change选中值发生变化时触发Function-
6. checkbox 多选框
// 基础
{label: '活动类型', key: 'type', type:'checkbox', children:[ {label:'在线活动'},{label:'促销活动'},{label:'线下活动'}] },

配置维度是依赖el-switch

属性名说明类型默认值
col响应式宽度设置Number24
props.trueLabel选中时的值Stringt-
props.falseLabel没有选中时的值String-
disabled禁用Booleanfalse
props.trueValue选中时的值Boolean-
props.falseValue没有选中时的值Boolean-
change选中值发生变化时触发Function-
7. radio 单选框
// 基础
{ key: 'openStatus', label: '模板状态', type: 'radio', children: [{ label: '启用', value: 1 }, { label: '禁用', value: 0 },] }

配置维度是依赖el-radio

属性名说明类型默认值
col响应式宽度设置Number24
props.value单选框的值Stringt-
props.label单选框的 labelString-
disabled禁用Booleanfalse
width所有单个 radio的宽度Number-
change选中值发生变化时触发Function-
8. cascader 级联选择器
// 基础
{key: 'dataPermissionCode', label: '所属区域', type: 'cascader', children: [{ label: '启用', value: 1 }, { label: '禁用', value: 0 },]}

// 接口请求
{key: 'dataPermissionCode', label: '所属区域', col: 12, placeholder: '请选择所属区域', remote: true, type: 'cascader', url: '/system/area/getAreaDtoListByParentCode/', method: 'get', params: { default: 0 },paramsType: 'url', props: { label: 'name', value: 'code' },}

配置维度是依赖el-cascader

属性名说明类型默认值
col响应式宽度设置Number24
props详情配置请看propsObject-
options选项的数据源, value 和 label 可以通过 CascaderProps 自定义.Object[]
disabled禁用Booleanfalse
collapseTags多选模式下是否折叠TagBoolean-
change选中值发生变化时触发Function-

弹框组件(TwDialog)

基于ElDialog二次封装。内置了全屏和默认高度,底部按钮等操作。可配合自定义form动态开发

// 基础(默认不显示底部操作开关)
<tw-dialog title="消息列表" v-model="dialogFlag">
   内容
</tw-dialog>

// 接口请求 (显示底部操作按钮)
<tw-dialog title="消息列表" v-model="dialogFlag" isBtns>
   内容
</tw-dialog>

TwDialog 属性

属性名说明类型默认值
titledialog弹框title配置String新增
modelValuedialog弹框显示隐藏变量Booleanfalse
cancelBtn取消按钮自定义文字配置String取消
confirmBtn确定按钮自定义文字配置String确定
cancelLoading取消按钮loading配置Booleanfalse
loading确定按钮loading配置Booleanfalse
width自定义宽度Number/String80%
height自定义高度Number/String100%
btns底部自定义操作按钮 { type:'默认: primary',key:'事件名称',name:'按钮名称'}Array[]
isBtns底部操作按钮显示开关Booleanfalse
bodyPadding内容内填充Number20
closeOnClickModal是否可以通过点击modal关闭DialogBooleantrue
isFull是否显示全屏开关Booleantrue
appendToBody是否插入bodyBooleanfalse
dialogTop顶部距离-特殊场景使用Number100
leftHeight剩余距离-特殊场景使用leftHeight140

TwDialog 事件

事件名说明类型
onScreenfull全屏事件Function
save确定事件Function
cancel取消事件Function
handleClose关闭弹框事件Function

抽屉组件(TwDrawer)

基于ElDrawer二次封装。内置了全屏和默认高度,底部按钮等操作。可配合自定义form动态开发

// 基础(默认显示底部操作开关)且默认高度全屏
<tw-drawer :loading="loading" :title="title" v-model="drawerFlag">
   内容
</tw-drawer>

// 接口请求 (不显示底部操作按钮)
<tw-drawer @handleClose="handleClose" :loading="loading" :title="title" :isBtns="false" v-model="drawerFlag">
   内容
</tw-drawer>

TwDrawer 属性

属性名说明类型默认值
titledialog弹框title配置String新增
modelValuedialog弹框显示隐藏变量Booleanfalse
cancelBtn取消按钮自定义文字配置String取消
confirmBtn确定按钮自定义文字配置String确定
cancelLoading取消按钮loading配置Booleanfalse
loading确定按钮loading配置Booleanfalse
width自定义宽度Number/String800px
top自定义高度String60px
btns底部自定义操作按钮 { type:'默认: primary',key:'事件名称',name:'按钮名称'}Array[]
isBtns底部操作按钮显示开关Booleantrue
isScreenfull内容内填充Booleantrue
defaultScreenfull是否可以通过点击modal关闭DialogBooleanfalse

TwDrawer 事件

事件名说明类型
onScreenfull全屏事件Function
save确定事件Function
handleClose取消事件Function
beforeClose关闭抽屉前的事件Function
cancel关闭弹框事件Function

描述组件(TwFormItem)

基于TwFormrender函数二次封装。核心用于动态显示

<template>
   <tw-form-item label-width="86px" size="small" :lists="mainData.aduitResultList" :row="mainData.formData"></tw-form-item>
</template>

<script setup lang="tsx">
let mainData = reactive({
    aduitResultList:[
        { key: 'plateNum', label: '车牌号:', col: 8 ,labelWidth:'76px'},
        { key: 'plateColorName', label: '车牌颜色:', col: 8 },
        { key: 'alarmTypeName', label: '报警类型:', col: 8 },
        { key: 'eventStartTime', label: '报警开始时间:' , col: 8,labelWidth:'110px'},
        { key: 'eventEndTime', label: '报警结束时间:' , col: 8,labelWidth:'110px'},
        { key: 'eventPersistSecondsStr', label: '持续时长:' , col: 8},
        { key: 'companyName', label: '企业信息:' , col: 8},
    ]
    formData: {
        plateNum: 1,
        plateColorName: 25,
        "alarmTypeName": "3",
        "eventStartTime": "4",
        "eventEndTime": "5",
        "eventPersistSecondsStr": "6",
        "companyName": "7",
    }
})

</script>

TwFormItem 属性

属性名说明类型默认值
lists渲染数据配置Array[]
labelWidth默认label宽度String100px
size默认显示格式String-
mb底部外边距String4px
lists 属性
属性名说明类型默认值
col列宽比例依赖Layout 布局Number12
labellabel的描述字段String-
labelWidth自定义label宽度String100px
slot自定义显示内容状态Booleanfalse
key显示对应的keyString-
formatter自定义显示内容Function-

分页组件(TwPagination)

基于ElPagination二次封装,内置只能中文。注意:此组件并没有集成所有配置,请适应场景使用

TwFormItem 属性

属性名说明类型默认值
currentPage当前页Number1
pageSize每页显示条数Number25
total总页数Number0
sizetable 大小配置Stringdefault
disabled每页显示条数Booleanfalse
pageSizesArr每页显示个数选择器的选项设置Array25, 50, 100
layout组件布局,子组件名用逗号分隔Stringtotal, prev, pager, next, sizes, jumper
background是否为分页按钮添加背景色Booleantrue

表格(TwTable)TwTable

基于TwTable二次封装且是和分页组件合并使用。内置自动计算高度,api请求,自定义data数据等功能。ContentMain组件也是当前组件组合使用。组件内部没有集成表格树(因为大批量行列数据会容易照成卡顿)。请适应场景使用

<template>
    // 基础渲染
   <TwTable :columns="columns" :lists="mainData.dataLists"></TwTable>
   
   // api渲染
   <TwTable
        ref="TwTable"
        id="regulators_acopy_releasedetails_table_view"
        url="/business/noticePublishScopeEntity/page"
        method="post"
        :tableParams="{ noticeId: rowData.id }"
        :botHeight="100"
        :columns="mainData.columns"
    ></TwTable>
</template>

<script setup lang="tsx">
let TwTable = $ref(null)

let mainData = reactive({
    // tableUrl: '/business/noticePublishScopeEntity/page',
    formData: {
        noticeId: 0,
        order: '',
        orderField: '',
        pageNumber: 1,
        pageSize:25,
    },
    columns: [
        { prop: 'businessName', label: '发布对象' },
        { prop: 'createTime', label: '创建时间' },
        { prop: 'lastModifyTime', label: '发布时间' },
    ],
    dataLists:[ {businessName:'1', createTime:'2', lastModifyTime:'3',}]
})

// 重新请求表格数据(url场景使用)
const getTable = () => {
    TwTable.getTable()
}
</script>

TwTable 属性

属性名说明类型默认值
url表格请求地址String-
idtable的唯一id,一页面多表格场景须赋值,否则无法动态计算高度String-
method表格动态url请求类型Stringpost
columns表格每一列渲染数据Array[]
lists表格每一行渲染数据Array[]
tableParams表格默认请求数据,这里代指mainData.formData。他们是绑定关系Object{ pageNumber: 1, pageSize: 25 }
tableHeight表格固定高度Number0
isRradio单选Booleanfalse
showPagination分页显示开关Booleantrue
botHeight是分页栏加上边距加底部空白位置高度Number50
indexFixed索引左侧定位开关Booleanfalse
isCheckcheckbox显示开关Booleanfalse
checkFixedcheckbox左侧定位开关String'left'
showIndex索引显示开关Booleanfalse
size表格大小配置String'large'
stripe斑马纹显示开关Booleantrue
border边框线显示开关Booleanfalse
pageSizesArr分页页码Array25, 50, 100
tableBtns单例按钮渲染数据Object-
small每页显示条数Booleanfalse
headBtns顶部操作按钮Array[]
isTableHeader默认显示表格顶部操作栏Booleantrue
isLoadStatus默认首次不加载table数据Booleanfalse
highlightCurrentRow是否高亮显示当前选中行Booleantrue
rowClassName行样式名称,同elTable一样Function-
selectableisCheck必须为true 用于判断选项是否可以点击,返回true或falseFunction{ return true}
autoScrollToTop请求数据后是否自动滚动到顶部Booleantrue
layout表格分页布局默认配置,依赖elPaginationStringtotal, prev, pager, next, sizes, jumper
background表格的背景颜色Booleantrue
loadingBg表格接口加载状态下背景颜色Stringrabg(225,225,225)
emptyText列表无数据时展示的文字String暂无数据

TwTable 事件

事件名说明类型
tableCallback表格api加载完成后响应的事件Function
checkSelect表格点击checkbox响应的事件,对应elTable - select事件Function
rowCheck表格点击行数据响应的事件Function
tableCurrentChange当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性Function
selectionChange表格的check选择, 对应elTable - selection-change事件Function
1.0.122

10 months ago

1.0.121

1 year ago

1.0.120

1 year ago

1.0.119

1 year ago

1.0.118

1 year ago

1.0.117

1 year ago

1.0.41

1 year ago

1.0.110

1 year ago

1.0.112

1 year ago

1.0.111

1 year ago

1.0.107

1 year ago

1.0.106

1 year ago

1.0.109

1 year ago

1.0.108

1 year ago

1.0.114

1 year ago

1.0.113

1 year ago

1.0.116

1 year ago

1.0.105

1 year ago

1.0.115

1 year ago

1.0.104

1 year ago

1.0.2

1 year ago

1.0.101

1 year ago

1.0.103

1 year ago

1.0.102

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago