0.0.4 • Published 3 years ago

config-form-table v0.0.4

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

通用配置表格

用于搭建简单的表单表格,支持分页能力。可以通过简单的配置实现分页表格

特点

  • 简单配置
  • 易用

在线demo

e.g. https://codepen.io/mr-wang007s/pen/JjbjdRe

Attribute

参数说明类型可选值默认值
fetch-data查询接口地址/接口函数Function(formObj, pager)--
form-items必须参数Array
table-columns必须参数Array

table-columns

参数说明类型可选值默认值
type操作Stringhandle
prop表格数据对应字段值String
label字段对应中文名String
formatter自定义字段渲染函数Function(row, column, cellValue, index)--
...Table-column AttributesElement-ui table中的align, fixed, width

form-items

参数说明类型可选值默认值
label名称string
key字段值
options下拉框属性 {label:xx, value: xx}Array
type输入类型input/inputNumber/select/dateTime

示例

<template>
    <div>
      <config-form-table :table-action="actionFun" :form-items="formItems" :table-columns="tableColumns"></config-form-table>
    </div>
</template>
var Main = {
  data() {
    return {
      formItems: [
        {
          label: "姓名",
          key: "name",
          type: 'input'
        }
      ],
      tableColumns: [
        { prop: "name", label: "姓名", align: "left", width: 200 },
        { prop: "date", label: "时间", align: "left", width: 200, formatter: this.formatterStatus },
        {
          prop: "address",
          label: "地址",
          align: "center"
        },
        {
          type: "handle",
          label: "操作",
          width: 80,
          buttons: [{ label: '查看', fn: this.handleView }]
        }
      ]
    }
  },
  methods: {
    handleView (row, key, value, index, scope) {
      alert(row)
    },
    formatterStatus (row, column, cellValue, index) {
      return "<span style='color:red'>"+cellValue+"</span>"
    },
    actionFun (formObj) {
      // e.g. 此处根据自己业务写入对应接口
      return new Promise((resolve, reject) => {
        axios.get('//mr-wang007s.xyz:3000/tables/'+formObj.pageIndex+'/'+formObj.pageSize+'/1').then(res => {
          resolve({
            dataList: res.data.tableList,
            total: res.data.total
          })
        })
      })
    }
  }
}
0.0.2-rc.6

3 years ago

0.0.2-rc.7

3 years ago

0.0.3

3 years ago

0.0.2-rc.4

3 years ago

0.0.2-rc.5

3 years ago

0.0.2-rc.3

3 years ago

0.0.4

3 years ago

0.0.2-rc.2

3 years ago

0.0.2-rc.1

3 years ago

0.0.2-rc.0

3 years ago

0.0.2-beta.0

3 years ago

0.0.1-beta.16

3 years ago

0.0.1-beta.12

3 years ago

0.0.1-beta.13

3 years ago

0.0.1-beta.11

3 years ago

0.0.1-beta.5

3 years ago

0.0.1-beta.4

3 years ago

0.0.1-beta.3

3 years ago