4.1.8 • Published 9 days ago

ele-list-page v4.1.8

Weekly downloads
416
License
ISC
Repository
github
Last release
9 days ago

ele-list-page

超级列表页 --- 一个基于element-ui的vue插件

样式

演示图片

功能

  1. 搜索表单:输入框、单选框、日期选择器、下拉框(支持远程搜索和下拉懒加载)。支持配置每行显示个数及“更多”搜索。
  2. 按钮组:批量删除、生效、失效、新增、搜索、自定义列(显示、隐藏、排序)等功能。可分为左右布局或上下布局,支持自定义颜色,方法,按钮名称。
  3. 列表:支持单元格点击跳转、行选择、操作列(动态html及方法)、树形表格、可编辑表格、支持自定义表头颜色、配置列宽、动态高度(可配置页面一屏显示)、序号列、固定列及表头、合计行等。
  4. 分页:可配置多个每页显示最大条数、自动固定到页面底部。

适用场景

列表页面直接通过配置js对象及方法就可以使用,不涉及vuex,但是部分功能需要后端支持(如分页)。

安装

npm i ele-list-page

使用

// 组件引入
import EleListPage from 'ele-list-page'
Vue.use(EleListPage)

// 组件样式引入 import 'ele-list-page/src/lib/index.css'

// 组件是基于element-ui的,所以也需要引入element-ui import ElementUI from 'element-ui'; Vue.use(ElementUI)

> list.vue template部分

<EleListPage :searchForm="searchForm" :tableCommonOptions="tableCommonOptions" :listLoading="listLoading" :loadTableData="loadTableData"

:tableList="tableList" :onSaveCustom="onSaveCustom"

list.vue js部分

data() {
  const tableCommonOptions = {
    searchOptions: {
      isAllHidden: false,// 为true时隐藏搜索条件
      // 超过8个 自动隐藏,右侧此时出现更多,单击下拉
      searchData: [
        {
          name: '编号',
          searchField: 'code',
        },
        {
          name: '状态',
          searchField: 'status',
          searchType: 'select',
          selectList: [{text: 1, value: 1}]
        }
      ],
    },
    filterOptions: {
      // 为true时隐藏中间按钮
      isAllHidden: false,
      // left为左侧, right为右侧按钮
      left: [
        {
          filterType: 'add',
          disabled: false,
          type: 'info'
        },
        {
          filterType: 'invalid',
          disabled: false
        },
        {
          filterType: 'valid',
          disabled: false
        },
        {
          filterType: 'export',
          disabled: true
        },
        {
          filterType: 'customColumns'
        }
      ],
      right: [
        {
          filterType: 'search', // 搜索按钮
          fn: () => {
            this.loadTableData();
          }
        },
        {
          filterType: 'clear', // 搜索按钮
          fn: () => {
            this.searchForm = {};
            // 看是否需要调用搜索
            this.loadTableData();
          }
        },
      ]
    },
    tableOptions: {
      underlineHandles: {
        code: ({row}) => {
          const params = {
            code: row.code || null 
          }
          alert('gotoDetail');
        }
      },
      columnsData: {
        showColumns: [],
        hiddenColumns: []
      },
      headerHandleOperation: {
        prop: 'operation',
        label: '操作',
        operationOptions: [{
          name: '修改',
          fn: ({row: {code}}) => {
            const params = {
              code
            }
            alert('gotoDetail');
          },
          disabled: false
        }, {
          name: '删除',
          type: 'danger',
          fn() {
            console.log('删除')
          },
          disabled: true,
        }]
      }
    },
    pagination: {
      total: 0,
      pageNo: 1,
      pageSize: 20
    }
  };
  return {
    tableCommonOptions,
    listLoading: false,
    searchForm: {},
    tableList: [],
  }
},
methods: {
  onSaveCustom(selectedNumber, closeDialog) {
    // 保存自定义列
    const request = {
      userModuleColumnsReqs: (selectedNumber || []).map((item, index) => {
        return {
          columnId: item,
          seq: index + 1
        }
      })
    };
    // 此处需要自己处理@TODO
    this.$store.dispatch('page/saveCustomColumns', request).then(() => {
      this.loadCustomColumnsList();
      // 更新列表数据
      this.loadTableData();
      closeDialog && closeDialog();
    })
    // 保存自定义列
  },
  loadSearchList() {
    // 初始化搜索项
    const searchData = this.tableCommonOptions.searchOptions.searchData;
    const newSearchData = [...searchData];
    // 搜索项下拉框列表填充
  },
  loadTableData() {
    const searchForm = this.searchForm;
    const request = {
      ...searchForm,
      startPage: this.tableCommonOptions.pagination.pageNo,
      pageSize: this.tableCommonOptions.pagination.pageSize
    }
// 表格数据更新
//this.listLoading = true
//getTableList(request).then(({data: {data: tableList, total}}) => {
//  this.tableList = tableList || [],
//  this.tableCommonOptions.pagination = {
//    ...this.tableCommonOptions.pagination,
//    total
//  }
//}).finally(() => {
//  this.listLoading = false
//})

}, loadCustomColumnsList() { // 获取自定义列列表 //getCustomizedColumnsList().then(({data}) => { // // 接口的数据结构showColumns = {showName, showField, id, refField} // // table表头所需 // const columnsMatchParams = { // prop: 'showField', // label: 'showName' // }; // // 自定义列所需 // const customColumnsMatchParams = { // key: 'id', // label: 'showName' // } // const tableCommonOptions = this.tableCommonOptions;

//  tableCommonOptions.tableOptions = {
//    ...tableCommonOptions.tableOptions,
//      columnsData: data,
//      columnsMatchParams,
//      customColumnsMatchParams
//  }
//})

}, }, mounted() { // // 初始化搜索项 this.loadSearchList(); // // 加载自定义列数据 this.loadCustomColumnsList(); // 加载表格数据 this.loadTableData(); }

## Build Setup

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

For detailed explanation on how things work, consult the docs for vue-loader.

4.1.8

9 days ago

4.1.7

9 days ago

4.1.6

9 days ago

4.1.4

2 months ago

4.1.3

2 months ago

4.1.5

2 months ago

4.1.2

2 months ago

4.1.1

2 months ago

4.1.0

3 months ago

4.0.12

4 months ago

4.0.14

4 months ago

4.0.13

4 months ago

4.0.11

4 months ago

4.0.9

4 months ago

4.0.10

4 months ago

4.0.5

5 months ago

4.0.4

5 months ago

4.0.7

5 months ago

4.0.6

5 months ago

4.0.8

5 months ago

4.0.5-debug.3

5 months ago

4.0.5-debug.1

5 months ago

4.0.5-debug.2

5 months ago

4.0.3

5 months ago

4.0.2

5 months ago

4.0.0

5 months ago

4.0.0-beta.2.debug

5 months ago

4.0.0-beta.1.debug

5 months ago

3.1.10

6 months ago

3.1.9

6 months ago

3.1.8

9 months ago

3.1.6

1 year ago

3.1.3

1 year ago

3.1.5

1 year ago

3.1.4

1 year ago

3.1.2

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.28

2 years ago

3.0.24

2 years ago

3.0.27

2 years ago

3.0.25

2 years ago

3.0.26

2 years ago

3.0.23

2 years ago

3.0.21

2 years ago

3.0.22

2 years ago

3.0.16

2 years ago

3.0.17

2 years ago

3.0.14

2 years ago

3.0.15

2 years ago

3.0.20

2 years ago

3.0.18

2 years ago

3.0.19

2 years ago

3.0.13

3 years ago

3.0.12

3 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.24

3 years ago

2.1.23

3 years ago

2.1.22

3 years ago

2.1.21

3 years ago

2.1.16

3 years ago

2.1.17

3 years ago

2.1.14

3 years ago

2.1.15

3 years ago

2.1.12

3 years ago

2.1.13

3 years ago

2.1.11

3 years ago

2.1.18

3 years ago

2.1.19

3 years ago

2.1.20

3 years ago

2.1.10

3 years ago

2.1.9

3 years ago

2.1.8

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.11

3 years ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.0

3 years ago

1.2.30

3 years ago

1.2.29

3 years ago

1.2.27

3 years ago

1.2.28

3 years ago

1.2.26

3 years ago

1.2.23

3 years ago

1.2.24

3 years ago

1.2.21

3 years ago

1.2.22

3 years ago

1.2.25

3 years ago

1.2.19

3 years ago

1.2.20

3 years ago

1.2.18

3 years ago

1.2.17

3 years ago

1.2.16

3 years ago

1.2.15

3 years ago

1.2.14

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.9

3 years ago

1.2.10

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago