Skip to content

Commit fdd881e

Browse files
committed
重构 表单,优化 菜单
1 parent 4075487 commit fdd881e

26 files changed

+282
-95
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# vue-layui
22
去年没有时间进行开发,加上自己水平过低,暂缓了一阵,从今天开始继续。
33
208/8/27
4+
点击预览: [demo演示](http://vue-layui.jskou.com)
45

56
版本 开发中...
67

package-lock.json

Lines changed: 19 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"dependencies": {
1010
"@fortawesome/fontawesome-free": "^5.2.0",
11+
"async-validator": "^1.8.5",
1112
"vue": "^2.5.17",
1213
"vue-router": "^3.0.1",
1314
"vuex": "^3.0.1"

src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
<span>基本元素</span>
6666
</template>
6767
<lay-menu-child-item title="按钮" :to="{name: 'button'}"></lay-menu-child-item>
68+
<lay-menu-child-item title="表单" :to="{name: 'form'}"></lay-menu-child-item>
69+
6870
</lay-menu-item>
6971
</lay-menu>
7072
</lay-side>

src/components/checkbox/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayCheckbox from './src/checkbox';
6+
7+
/* istanbul ignore next */
8+
LayCheckbox.install = function(Vue) {
9+
Vue.component(LayCheckbox.name, LayCheckbox);
10+
};
11+
12+
export default LayCheckbox;

src/components/form/checkbox.vue renamed to src/components/checkbox/src/checkbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<script>
2424
export default {
25-
name: 'layui-checkbox',
25+
name: 'LayCheckbox',
2626
data: function () {
2727
return {
2828
hasValue: false,

src/components/form-item/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayFormItem from '../form/src/form-item';
6+
7+
/* istanbul ignore next */
8+
LayFormItem.install = function(Vue) {
9+
Vue.component(LayFormItem.name, LayFormItem);
10+
};
11+
12+
export default LayFormItem;

src/components/form/form.vue

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/form/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayForm from './src/form';
6+
7+
/* istanbul ignore next */
8+
LayForm.install = function(Vue) {
9+
Vue.component(LayForm.name, LayForm);
10+
};
11+
12+
export default LayForm;

src/components/form/form-item.vue renamed to src/components/form/src/form-item.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<script>
1616
export default {
17-
name: 'layui-form-item',
17+
name: 'LayFormItem',
1818
props: {
1919
label: String,
2020
block: Boolean,

src/components/form/src/form.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<form class="layui-form"
3+
:class="{
4+
'layui-form-pane': border
5+
}">
6+
<slot></slot>
7+
</form>
8+
</template>
9+
10+
<script>
11+
import schema from 'async-validator'
12+
13+
export default {
14+
name: 'LayForm',
15+
props: {
16+
border: Boolean,
17+
model: Object,
18+
rules: Object
19+
},
20+
provide() {
21+
return {
22+
rootForm: this
23+
};
24+
},
25+
methods: {
26+
handlerChange(){
27+
let validator = new schema(this.rules);
28+
validator.validate(this.model, (errors, fields) => {
29+
if(errors) {
30+
console.log(errors)
31+
}
32+
});
33+
}
34+
},
35+
watch: {
36+
model: {
37+
deep: true,
38+
handler(){
39+
this.handlerChange()
40+
}
41+
42+
}
43+
}
44+
}
45+
</script>
46+
47+
<style>
48+
49+
</style>

src/components/input/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayInput from './src/input';
6+
7+
/* istanbul ignore next */
8+
LayInput.install = function(Vue) {
9+
Vue.component(LayInput.name, LayInput);
10+
};
11+
12+
export default LayInput;

src/components/form/input.vue renamed to src/components/input/src/input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<script>
1515
export default {
16-
name: 'layui-input',
16+
name: 'LayInput',
1717
props: {
1818
value: [String, Number],
1919
placeholder: String,

src/components/menu/src/menu-child-item.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
</template>
44

55
<script>
6-
import Menu from './menu-mixin';
76
import eventHub from '@/mixins/eventHub';
87
export default {
98
name: "LayMenuChildItem",
@@ -15,7 +14,8 @@
1514
type: Object
1615
}
1716
},
18-
mixins: [Menu, eventHub],
17+
mixins: [eventHub],
18+
inject: ['rootMenu'],
1919
methods: {
2020
handleClick() {
2121
if(this.$route && this.to){

src/components/menu/src/menu-item.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
</template>
2323

2424
<script>
25-
import Menu from './menu-mixin';
2625
import eventHub from '@/mixins/eventHub';
2726
export default {
2827
name: "LayMenuItem",
@@ -36,7 +35,8 @@
3635
}
3736
},
3837
39-
mixins: [Menu, eventHub],
38+
mixins: [eventHub],
39+
inject: ['rootMenu'],
4040
methods: {
4141
handleClick() {
4242
if(this.$slots.default && this.rootMenu.mode == 'vertical'){

src/components/menu/src/menu-mixin.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/components/radio/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayRadio from './src/radio';
6+
7+
/* istanbul ignore next */
8+
LayRadio.install = function(Vue) {
9+
Vue.component(LayRadio.name, LayRadio);
10+
};
11+
12+
export default LayRadio;

src/components/form/radio.vue renamed to src/components/radio/src/radio.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<script>
2323
export default {
24-
name: 'layui-radio',
24+
name: 'LayRadio',
2525
props: {
2626
value: [String, Number],
2727
label: [String, Number],

src/components/select/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LaySelect from './src/select';
6+
7+
/* istanbul ignore next */
8+
LaySelect.install = function(Vue) {
9+
Vue.component(LaySelect.name, LaySelect);
10+
};
11+
12+
export default LaySelect;

src/components/form/select.vue renamed to src/components/select/src/select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<script>
2525
export default {
26-
name: 'layui-select',
26+
name: 'LaySelect',
2727
props: {
2828
disabled: Boolean,
2929
value: [String, Number],

src/components/textarea/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* kouchao 创建于 2018/8/27
3+
*/
4+
5+
import LayTextarea from './src/textarea';
6+
7+
/* istanbul ignore next */
8+
LayTextarea.install = function(Vue) {
9+
Vue.component(LayTextarea.name, LayTextarea);
10+
};
11+
12+
export default LayTextarea;

src/components/form/textarea.vue renamed to src/components/textarea/src/textarea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<script>
1515
export default {
16-
name: 'layui-textarea',
16+
name: 'LayTextarea',
1717
props: {
1818
value: [String, Number],
1919
placeholder: String,

src/index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import LayButton from '@/components/button'
1111
import LayButtonGroup from '@/components/button-group'
1212
import LayButtonContainer from '@/components/button-container'
1313

14-
import form from '@/components/form/form'
15-
import formItem from '@/components/form/form-item'
16-
import radio from '@/components/form/radio'
17-
import input from '@/components/form/input'
18-
import checkbox from '@/components/form/checkbox'
19-
import select from '@/components/form/select'
20-
import textarea from '@/components/form/textarea'
14+
import LayForm from '@/components/form'
15+
import LayFormItem from '@/components/form-item'
16+
import LayRadio from '@/components/radio'
17+
import LayInput from '@/components/input'
18+
import LayCheckbox from '@/components/checkbox'
19+
import LaySelect from '@/components/select'
20+
import LayTextarea from '@/components/textarea'
2121

2222
import tabs from '@/components/tabs/tabs'
2323
import tabPane from '@/components/tabs/tab-pane'
@@ -50,13 +50,13 @@ const layui = {
5050
LayButton,
5151
LayButtonContainer,
5252
LayButtonGroup,
53-
form,
54-
formItem,
55-
radio,
56-
input,
57-
checkbox,
58-
select,
59-
textarea,
53+
LayForm,
54+
LayFormItem,
55+
LayRadio,
56+
LayInput,
57+
LayCheckbox,
58+
LaySelect,
59+
LayTextarea,
6060
tabs,
6161
tabPane,
6262
hr,

0 commit comments

Comments
 (0)