0.1.8 • Published 3 years ago

yjfm-table-pro v0.1.8

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

安装该组件

依赖

依赖版本dev
core-js^3.6.5false
element-ui^2.15.3false
vue^2.6.11false
@vue/cli-service~4.5.0true

安装

npm install yjfm-table-pro

引入

...
import tablePro from 'yjfm-table-pro'
import 'yjfm-table-pro/lib/yjfm-table-pro.css'
...
Vue.use(tablePro)
...

创建配置文件 table.js

export function getConf() {
  const that = this;
  const tableProps = {};
  const getHeaderActions = () => {
    return [
      {
        label: "新增",
        onClick: () => {
          alert("新增");
        },
        type: "primary",
        icon: "el-icon-plus",
      },
    ];
  };
  const getTableConf = () => {
    return [
      {
        label: "项目名称",
        prop: "projectName",
        tooltip: true,
      },
      {
        label: "操作",
        prop: "id",
        fixed: "right",
        width: 200,
        dontVisible: true,
        getContent(row) {
          return (
            <div>
              <el-popconfirm title="确定删除该记录?" onOnConfirm={() => {}}>
                <span class="danger link-text" slot="reference">
                  删除
                </span>
              </el-popconfirm>
            </div>
          );
        },
      },
    ];
  };
  const tableItem = getTableConf();
  return {
    api: this.api,
    tableConf: {
      tableProps,
      tableItem,
    },
    headerConf: {
      actions: getHeaderActions(),
      title: "项目",
    },
    filterConf: {
      options: [{ label: "项目名称", prop: "projectName" }],
      actions: [],
      params: {
        projectName: null,
        manager: null,
        workingTime: null,
      },
    },
  };
}

创建 demo.vue

<template>
  <div>
    <yjmf-table-pro-page v-bind="tableConf" />
  </div>
</template>
<script>
import { getConf } from './table'
const reqFetchList = ()=>{
  return new Promise((resolve,reject)=>{
    const list = []
    for(let i=0;i<15;i++){
      list.push({
        id:(i+1),
        projectName:`项目名称${i}`
      })
    }
    resolve({
      list,
      total:1000
    })
  })
}
export default {
  data() {
    const tableConf = getConf.call(this, reqFetchList)
    return {
      tableConf,
    }
  }
}
</script>

运行代码将看到一个简单的列表页

组件介绍

组件名称描述
yjmf-table-pro-page列表页组件
yjmf-table-pro列表组件
yjmf-table-pro-header列表页头部组件
yjmf-table-pro-filter列表页筛选项组件

yjmf-table-pro-page 列表页组件

属性

参数说明类型可选值默认值
api列表请求接口方法Function 该方法返回一个 Promise 对象
headerConf列表页页头参数Object{}
filterConf筛选项参数Object{}
tableConf列表参数Object{}

方法

方法名说明参数
setData设置组件 data 属性key:string,val:any
onSearch设置查询参数并进行查询val:object
fetchData查询列表null

data 属性

属性名类型说明

|page|Object|内含size,current| |page.size|Number|每页的记录数| |total||

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago