# eiptable **Repository Path**: honestno1/eiptable ## Basic Information - **Project Name**: eiptable - **Description**: 在后端页面开发时,对table有一些共通的需求,做成基于layui table的扩展,方便使用。 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 13 - **Forks**: 3 - **Created**: 2024-08-03 - **Last Updated**: 2025-06-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: layui, table, layui插件 ## README # eiptable ## 介绍 在后端页面开发时,对table有一些共通的需求,做成基于layui table的扩展,方便使用。 ### 对table cell编辑类型的扩展 在layui table的原有的编辑类型text、textarea之外,增加对新的编辑类型的支持,新增的编辑类型如下: 1. select,下拉选择框 2. date,日期选择类型 3. number,数字输入类型 ## 在线示例 [在线示例](https://stackblitz.com/edit/layui-eiptable-sample?file=index.html) ## 例子截图    ## 示例代码 使用方式和layui table基本一致,具体请参考#layui table的官方文档。 下面是对应 例子截图 的代码。详细请参考sample文件。 ``` layui.config({ base:'./eiptable/' }).use(['eipTable'], function(){ var eipTable = layui.eipTable; var $ = layui.jquery; const testData = [ {employeeNo: '0001', name: '张三', sex: '1', yearMonth: '2024-01', checkInDate: '2023-01-01', checkOutDate: '2023-12-02'}, {employeeNo: '0002', name: '李四', sex: '2', yearMonth: '2024-02', checkInDate: '2024-01-01', checkOutDate: '2022-11-02'}, {employeeNo: '0003', name: '王五', sex: '1', yearMonth: '2024-03', checkInDate: '2023-01-01', checkOutDate: '2024-01-02'}, {employeeNo: '0004', name: '麻子1', sex: '2', yearMonth: '2024-04', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0005', name: '麻子2', sex: '2', yearMonth: '2024-05', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子3', sex: '2', yearMonth: '2024-06', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子4', sex: '2', yearMonth: '2024-07', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子5', sex: '9', yearMonth: '2024-08', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子6', sex: '2', yearMonth: '2024-09', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子7', sex: '9', yearMonth: '2024-10', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子8', sex: '2', yearMonth: '2024-11', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, {employeeNo: '0004', name: '麻子9', sex: '9', yearMonth: '2024-12', checkInDate: '2023-01-30', checkOutDate: '2023-01-10'}, ]; // 渲染表格 eipTable.render({ elem: '#test', defaultToolbar: ['filter'], toolbar: '#toolBar', cols: [[ {type:'numbers', fixed: 'left', width:50}, {field:'employeeNo', fixed: 'left', width:80, title: '工号'}, {field:'name', fixed: 'left', width:100, title: '姓名', edit: 'text'}, {field:'sex', fixed: 'left', width:80, title: '性别', edit: { type: 'select', options: [{value: '1', text: '男'}, {value: '2', text: '女'}, {value: '9', text: '保密'}] } }, {field:'yearMonth', width:110, title: '入职时间', edit: { type: 'date', options: {type: 'month', format: 'yyyy-MM'} } }, {field:'checkInDate', width:110, title: '入项时间', edit: 'date'}, {field:'checkOutDate', width:110, title: '离项时间', edit: 'date'}, {field:'workload', width:110, title: '工作量', edit: { type: 'number', options: {min: 0, max: 30, precision: 2} } }, ]], page: true, limits: [5, 10, 30], limit: 5, data: testData, }); // 绑定单元格编辑事件 eipTable.on('edit(test)', function(obj){ console.log(obj); }); }); ``` ## API layui table 组件的所有 API 均适用于 eipTable 组件,详细请参考#table组件的API文档。 | API | 描述 | | -------------------------------- | ------------------ | | var eipTable = layui.eipTable; | 获得 eipTable 模块 | | eipTable.render(options) | 渲染表格 | | eiptable.reload(id, options) | 表格重载 | | eiptable.reloadData(id, options) | 表数据重载。 | ### 渲染 eipTable.render(options); - 参数 options : 基础属性配置项。#详见 table 组件基础属性 该组件渲染的使用方式与 table 组件完全相同。 #### 基础属性 table 组件的所有基础属性均适用于 eipTable 组件。 #### 表头属性
属性 | 描述 | 类型 | 默认值 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
edit |
用于对列所在的单元格开启编辑功能。可选值有: 1. edit: 'text' 单行输入模式 2. edit: 'textarea' 多行输入模式 3. 函数写法: function(d) { return 'text' } // d 即为当前行数据,此时可根据行相关字段来开启该行是否编辑的权限 4. edit: 'date' 日期选择类型,日期选择为laydate,参数为默认参数,laydate默认参数请参考laydate属性 5. edit: {} 对象类型定义的输入模式,通过对象类型描述select、date、number等扩展属性 |
string function object | false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit.type | 编辑模式,支持select、date、number三种模式 | string | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
edit.options |
输入模式的详细属性选项,每个模式有不同的属性集合 1. select模式,options值是数组对象,定义下拉选项的值,例:options: [{value: '1', text: '男'}, {value: '2', text: '女'}, {value: '9', text: '保密'}]
|