3.2.0-alpha • Published 5 years ago

vue-element-crud v3.2.0-alpha

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

vue-element-crud

A wrapped vue CRUD component based on the famous vue UI componets -- element-ui.

一款基于 element-ui 组件的增删改查组件。

Here is a simple demo.

您可以阅读项目中的示例 examples 和源码文件 Crud.vue 来帮助您理解组件的具体用法。

Local development

You can download or clone this repository as long as you like it. Then you can run npm scripts

$ npm run build:watch

Usage

You can use vue-element-crud as a vue plugin or as a vue component.

If you'd like to treat it as a componet. You can import CRUD as components.

As component

import { CRUD } from 'vue-element-crud'
// or you can import from 'vue-element-crud/lib/crud.common' for en users

export default {
  components: { crud: CRUD },
}

Otherwise, you can treat it as a plugin.

As Plugin

Step-1, init project

You may need to init a vue project or take a existing one to continue as vue-loader or babel-loader or css-loader is required for element-ui.

$ vue init webpack <project-name>

Step-2, install

This component is dependent on element-ui, and element-ui will automatically installed when you install vue-element-crud, so you don't have to install element-ui in addition.

$ npm install -S vue-element-crud

Step-3, vue use

Add these lines below to your main.js

import 'element-ui/lib/theme-default/index.css'
import ElementUI from 'element-ui'
import CRUD from 'vue-element-crud'

Vue.use(ElementUI)
Vue.use(CRUD)

Step-4, refer to examples

You can read the docs or examples to find out how to implement props and methods of this vue-element-crud.

API

propstyperequireddefaultdescription
dataArraytrue---Table data array
formObjecttrue---Form object to store form item varaibles
fieldsObjecttrue---Object that describes form items structure. eg. { name: { label: 'name', length: 20, type: String, options: [{ label: 'Mike', value: 'Mike' }] }
rulesObjectfalse---Object that describes form items rules. eg. { name: [{ required: true, message: 'name is required.' }] }
sizeStringfalse'large'Size the dialog. 'full' or 'large' or small or omitted.
labelWidthStringfalse'100px'Label width of form and table.
inlineBooleanfalsefalseDetermine whether form items live inline or not.
tableObjectfalse---If table structure is not according to the form structure, you can specify it. eg. { name: 'name' }
actionsArrayfalse['create', 'destroy', 'update']The crud actions.
loadingBooleanfalsefalseCRUD is in XHR state. Submit button was disabled if true.
highlightCurrentRowBooleanfalsefalseHighlight table current row or not.
rowStyleFunctionfalse---Table row style function. Function(row, index)
eventsdescription
opendialog open event. set editing to true to show the dialog.
closedialog close event. set editing to false to close the dialog.
createform create event. You need to assign form model to the form.
updateform update event. (row, index) passed to the handler. You need to assign row to the form.
destroytable row destory event. (row, index) passed to the handler.
submitform submit event. (status, closeDialog) passed to the handler. 0 stands for creating, and 1 stands for updating. closeDialog is a function.
expandtable expand event. (row, expanded) passed to the handler. See element-ui table events.
row-clicktable row click event. (row, event, column) passed to the handler. See element-ui table events.
row-dblclicktable row dblclick event. (row, event) passed to the handler. See element-ui table events.
slotsdescription
indexTable row index slot. See element-ui table slots.
expandTable expand slot. See element-ui table slots.
prependTable prepend slot.
defaultTable append slot.
addonForm addon slot.

Your template may look like this.

<crud :data="data" :form="form" :rules="rules" :fields="fields" inline index
    :editing="editing" @open="handleOpen" @close="handleClose"
    @create="handleCreate" @update="handleUpdate" @destroy="handleDestroy" @submit="handleSubmit"/>

Here is a simple mixin that may help you to bootstrap it. Just import Simple.

import { Simple } from 'vue-element-crud'

export {
  mixins: [Simple]
}

Contribute

If you have some ideas about this component, please don't hesitate to let us konw. You can make a new issue to make it better.

3.2.0-alpha

5 years ago

3.1.6

6 years ago

3.1.5

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.6.1

6 years ago

2.6.0

6 years ago

2.5.10

6 years ago

2.5.9

6 years ago

2.5.8

6 years ago

2.5.7

6 years ago

2.5.6

6 years ago

2.5.5

6 years ago

2.5.4

6 years ago

2.5.3

6 years ago

2.5.2

6 years ago

2.5.1

6 years ago

2.5.0

6 years ago

2.4.13

6 years ago

2.4.12

6 years ago

2.4.11

6 years ago

2.4.10

6 years ago

2.4.9

6 years ago

2.4.8

6 years ago

2.4.7

6 years ago

2.4.6

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

1.4.0

6 years ago

1.3.21

6 years ago

1.2.21

6 years ago

1.1.21

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago