1.0.7 • Published 3 years ago

vue-common-com v1.0.7

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

super_admin

我们在开发页面的功能的时候,其实主要是表单和表格。但是每次写表单或者表格的时候会发现有很多重复的代码。所以我们可以带着封装的思想来进行封装。里面引入了 element 的组件。

Project setup

npm i vue-common-com

项目中引入

import vueCommonCom from 'vue-common-com/lib/vue-common-com.common'
import 'vue-common-com/lib/vue-common-com.css'

Vue.use(vueCommonCom)

1. 表格组件

  • (1)引入表格组件
import pageTable from '@/components/table/pageTable.vue';

components: { pageTable }
  • (2)传入表格的参数和方法
  <page-table
    :table-data="data"
    :table-list="tableList"
    :page_size="page_size"
    :page_index="page_index"
    :total="total"
    class="table-content"
    @handleSizeChange="handleSizeChange"
    @handleCurrentChange="handleCurrentChange"
    @buttonClick="buttonClick"
    @tableChange="tableChange"
  />
参数含义默认值数据类型
tableData表格的数据[]array
tableList表头的数据[]array
tableConfig表格的属性配置{}object
page_index分页参数,第一页1number
page_size分页参数,一页多少条数据10number
total分页参数,表格的总数0number
layout分页参数,分页的布局sizes, total, prev, pager, nextstring
prevText分页参数上一页string
nextText分页参数下一页string
smallPaginate分页参数,是否显示小的分页样式falseboolean
isPagination是否显示分页trueboolean
pageSizes分页参数,每页显示个数选择器的选项设置10, 20, 30, 50, 100array
方法含义传入的参数
tableChange表格组件自带的方法,例如多选,取消选中等方法自带的参数,类型代表
handleSizeChange分页方法
handleCurrentChange分页方法页 数
buttonClick表格里面若是组件,例如按钮,则按钮点击的方法prop(表头的内部值), row(这一行 的数据)

2. 表单组件

  • (1)引入表格组件
import AlForm from '@/components/form/AlForm.vue';

components: { AlForm }
  • (2)传入表格的参数和方法
   <al-form
    :form-list="saleFormList"
    :form-data="form"
    :form-config="formConfig"
    @buttonClick="buttonClick"
    @change="change"
  />
参数含义默认值数据类型
formConfig表单的属性配置{}object
formList表单表单项[]array
formData表单的数据[]array
方法名含义方法参数
buttonClick表格里面若是组件,例如按钮,则按钮点击的方法prop(表头的内部值), row(这一行的数据)
handleFormBtn表格保存按钮和重置按钮的触发prop(按钮类型)