kui-vue 3.2.11 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/_tool/scroll.js +1 -1
- package/components/alert/alert.jsx +10 -8
- package/components/avatar/AvatarGroup.jsx +22 -0
- package/components/avatar/avatar.jsx +10 -3
- package/components/avatar/demo/base.md +8 -8
- package/components/avatar/demo/types.md +17 -4
- package/components/avatar/styles/index.less +6 -2
- package/components/backtop/backtop.jsx +2 -1
- package/components/badge/demo/color.md +2 -2
- package/components/badge/demo/dot.md +11 -1
- package/components/badge/demo/dynamic.md +5 -3
- package/components/base/input.jsx +6 -5
- package/components/base/pop.jsx +2 -1
- package/components/breadcrumb/breadcrumbItem.jsx +1 -1
- package/components/breadcrumb/demo/icon.md +13 -3
- package/components/breadcrumb/demo/separator.md +13 -3
- package/components/breadcrumb/styles/index.less +3 -1
- package/components/button/button.jsx +3 -2
- package/components/button/demo/group.md +12 -2
- package/components/button/demo/light.md +18 -8
- package/components/button/demo/loading.md +8 -6
- package/components/button/demo/normal.md +18 -8
- package/components/button/demo/size.md +8 -6
- package/components/button/demo/with-icon.md +17 -7
- package/components/button/styles/index.less +5 -5
- package/components/card/card.jsx +1 -1
- package/components/card/demo/base.md +11 -1
- package/components/card/demo/border.md +11 -1
- package/components/carousel/carousel.jsx +4 -2
- package/components/carousel/styles/index.less +7 -1
- package/components/checkbox/checkbox.jsx +2 -1
- package/components/checkbox/demo/base.md +2 -2
- package/components/checkbox/demo/disabled.md +2 -2
- package/components/collapse/demo/accrodion.md +1 -1
- package/components/collapse/demo/base.md +1 -1
- package/components/collapse/demo/extra.md +6 -4
- package/components/collapse/demo/nesting.md +1 -1
- package/components/collapse/demo/sample.md +1 -1
- package/components/collapse/panel.jsx +2 -1
- package/components/collapse/styles/index.less +2 -2
- package/components/colorPicker/colorpicker.jsx +5 -5
- package/components/colorPicker/demo/shape.md +3 -1
- package/components/colorPicker/styles/index.less +13 -1
- package/components/datePicker/datecalendar.jsx +9 -5
- package/components/datePicker/datepicker.jsx +6 -6
- package/components/datePicker/demo/format.md +2 -2
- package/components/datePicker/demo/inside.md +4 -2
- package/components/datePicker/demo/size.md +2 -2
- package/components/datePicker/demo/theme.md +6 -4
- package/components/datePicker/styles/datepicker.less +5 -6
- package/components/descriptions/demo/size.md +2 -2
- package/components/drawer/demo/base.md +2 -2
- package/components/drawer/demo/custom.md +2 -2
- package/components/drawer/demo/form.md +2 -2
- package/components/drawer/demo/target.md +2 -2
- package/components/drawer/drawer.jsx +2 -1
- package/components/dropdown/demo/base.md +16 -6
- package/components/dropdown/demo/cascading.md +11 -1
- package/components/dropdown/demo/custom.md +3 -1
- package/components/dropdown/demo/divider.md +11 -3
- package/components/dropdown/demo/rightmenu.md +9 -3
- package/components/empty/demo/custom.md +12 -2
- package/components/empty/demo/use.md +2 -2
- package/components/empty/empty.jsx +2 -1
- package/components/form/demo/align.md +1 -1
- package/components/form/demo/base.md +3 -3
- package/components/form/demo/customvalid.md +1 -1
- package/components/form/demo/dynamicvalid.md +4 -2
- package/components/form/styles/index.less +0 -5
- package/components/grid/col.jsx +34 -5
- package/components/grid/demo/gutter.md +52 -11
- package/components/grid/index.md +7 -7
- package/components/grid/row.jsx +24 -4
- package/components/grid/styles/index.less +9 -23
- package/components/icon/demo/base.md +14 -4
- package/components/icon/demo/info.md +25 -1
- package/components/icon/demo/search.vue +43 -21
- package/components/icon/demo/stroke.md +17 -4
- package/components/icon/icon.jsx +6 -4
- package/components/icon/index.md +1 -1
- package/components/icon/lib/dist.json +1 -1
- package/components/icon/lib/kui-icons.js +1 -1
- package/components/icon/lib/sprite.svg +1 -1
- package/components/image/demo/errors.md +1 -1
- package/components/image/demo/extra.md +16 -14
- package/components/image/demo/extra_globle.md +8 -7
- package/components/image/image.jsx +3 -13
- package/components/image/preview.jsx +12 -12
- package/components/image/styles/index.less +8 -3
- package/components/input/demo/icon.md +10 -4
- package/components/input/demo/size.md +13 -3
- package/components/input/demo/suffix.md +7 -5
- package/components/input/demo/theme.md +5 -3
- package/components/input/input.jsx +1 -1
- package/components/inputNumber/demo/ffix.md +12 -2
- package/components/inputNumber/demo/format.md +1 -1
- package/components/inputNumber/demo/size.md +13 -3
- package/components/inputNumber/inputNumber.jsx +13 -7
- package/components/inputNumber/styles/index.less +7 -0
- package/components/layout/demo/layout1.md +17 -7
- package/components/layout/demo/layout2.md +18 -17
- package/components/layout/demo/layout3.md +15 -15
- package/components/layout/demo/layout4.md +16 -15
- package/components/layout/demo/layout5.md +90 -67
- package/components/layout/styles/index.less +12 -12
- package/components/menu/demo/accrodion.md +6 -4
- package/components/menu/demo/base.md +7 -5
- package/components/menu/demo/collapsed.md +8 -6
- package/components/menu/demo/inline.md +6 -4
- package/components/menu/demo/mode.md +7 -5
- package/components/menu/demo/theme.md +7 -5
- package/components/menu/demo/vertical.md +7 -5
- package/components/menu/menuitem.jsx +3 -2
- package/components/menu/styles/dropmenu.less +12 -4
- package/components/menu/styles/index.less +501 -495
- package/components/menu/submenu.jsx +4 -3
- package/components/message/demo/icon.md +8 -2
- package/components/message/inner.jsx +8 -7
- package/components/modal/demo/base.md +2 -2
- package/components/modal/demo/custom.md +5 -3
- package/components/modal/demo/global.md +9 -3
- package/components/modal/demo/more.md +2 -2
- package/components/modal/modal.jsx +3 -3
- package/components/notice/demo/icon.md +10 -4
- package/components/page/demo/sizer.md +2 -2
- package/components/page/page.jsx +5 -4
- package/components/page/styles/index.less +21 -7
- package/components/popconfirm/demo/placement.md +2 -2
- package/components/poptip/demo/closeinside.md +2 -2
- package/components/poptip/demo/placement.md +2 -2
- package/components/progress/demo/color.md +5 -3
- package/components/progress/demo/dashboard.md +3 -3
- package/components/progress/demo/dynamic.md +5 -3
- package/components/progress/demo/size.md +4 -4
- package/components/progress/progress.jsx +6 -5
- package/components/radio/demo/base.md +2 -2
- package/components/radio/demo/button.md +2 -2
- package/components/radio/demo/disabled.md +2 -2
- package/components/radio/styles/index.less +3 -0
- package/components/rate/demo/base.md +12 -2
- package/components/rate/demo/character.md +11 -1
- package/components/rate/demo/custom.md +7 -6
- package/components/rate/demo/disabled.md +11 -1
- package/components/rate/demo/tips.md +1 -1
- package/components/rate/rate.jsx +2 -2
- package/components/rate/star.jsx +4 -3
- package/components/select/demo/clearable.md +2 -2
- package/components/select/demo/filterable.md +2 -2
- package/components/select/demo/icon.md +5 -3
- package/components/select/demo/multiple.md +2 -2
- package/components/select/demo/search.md +2 -2
- package/components/select/demo/size.md +7 -5
- package/components/select/demo/theme.md +6 -4
- package/components/select/option.jsx +2 -12
- package/components/select/select.jsx +9 -12
- package/components/select/styles/index.less +4 -15
- package/components/skeleton/demo/child.md +2 -2
- package/components/skeleton/demo/custom.md +1 -1
- package/components/skeleton/demo/list.md +1 -1
- package/components/skeleton/skeletonAvatar.jsx +1 -0
- package/components/skeleton/skeletonButton.jsx +1 -0
- package/components/skeleton/skeletonImage.jsx +1 -0
- package/components/skeleton/skeletonText.jsx +1 -0
- package/components/slider/demo/base.md +11 -6
- package/components/slider/demo/marks.md +37 -26
- package/components/slider/demo/reverse.md +1 -1
- package/components/slider/slider.jsx +79 -35
- package/components/slider/styles/index.less +6 -3
- package/components/slider/thumb.jsx +23 -39
- package/components/space/demo/base.md +11 -1
- package/components/space/demo/custom-size.md +1 -6
- package/components/space/demo/size.md +2 -2
- package/components/space/demo/vertical.md +12 -2
- package/components/space/space.jsx +2 -2
- package/components/spin/demo/container.md +2 -2
- package/components/spin/demo/mode.md +2 -2
- package/components/steps/step.vue +1 -1
- package/components/styles/sys.less +22 -20
- package/components/styles/var.less +140 -149
- package/components/switch/demo/base.md +2 -2
- package/components/switch/demo/disabled.md +2 -2
- package/components/switch/demo/text.md +10 -8
- package/components/switch/switch.jsx +2 -1
- package/components/table/demo/base-render.md +41 -38
- package/components/table/demo/base.md +3 -1
- package/components/table/demo/bordered.md +1 -1
- package/components/table/demo/custom-header.md +10 -8
- package/components/table/demo/edit.md +2 -2
- package/components/table/demo/ellipsis.md +5 -3
- package/components/table/demo/embed.md +2 -2
- package/components/table/demo/expand.md +5 -3
- package/components/table/demo/filter.md +2 -2
- package/components/table/demo/fixed-col.md +5 -5
- package/components/table/demo/fixed-head.md +3 -3
- package/components/table/demo/fixed.md +14 -6
- package/components/table/demo/fixedspan.md +2 -7
- package/components/table/demo/index.vue +1 -1
- package/components/table/demo/selection.md +6 -4
- package/components/table/demo/size.md +3 -1
- package/components/table/demo/span.md +2 -2
- package/components/table/extend.jsx +157 -55
- package/components/table/index.md +1 -0
- package/components/table/styles/index.less +85 -101
- package/components/table/table.jsx +37 -176
- package/components/table/utils.js +17 -13
- package/components/tabs/demo/base.md +2 -2
- package/components/tabs/demo/card.md +2 -2
- package/components/tabs/demo/centered.md +2 -2
- package/components/tabs/demo/closable.md +4 -2
- package/components/tabs/demo/disabled.md +2 -2
- package/components/tabs/demo/extra.md +2 -2
- package/components/tabs/demo/icon.md +6 -4
- package/components/tabs/demo/sample.md +2 -2
- package/components/tabs/styles/index.less +3 -2
- package/components/tabs/tabpane.jsx +1 -1
- package/components/tabs/tabs.jsx +4 -3
- package/components/tag/demo/color.md +2 -2
- package/components/tag/demo/dynamic.md +3 -1
- package/components/tag/tag.jsx +2 -1
- package/components/timeline/demo/icon.md +12 -2
- package/components/timeline/demo/mode.md +6 -4
- package/components/timeline/styles/index.less +8 -0
- package/components/timeline/timelineitem.jsx +2 -3
- package/components/tooltip/demo/base.md +2 -2
- package/components/tooltip/demo/color.md +2 -2
- package/components/tooltip/demo/placement.md +2 -2
- package/components/tree/demo/custom-render.md +8 -7
- package/components/tree/demo/directory.md +59 -47
- package/components/tree/demo/icon.md +13 -11
- package/components/tree/demo/treenode.md +3 -1
- package/components/tree/node.jsx +3 -3
- package/components/tree/styles/index.less +2 -2
- package/components/upload/demo/accept.md +6 -4
- package/components/upload/demo/avatar.md +4 -2
- package/components/upload/demo/base.md +4 -2
- package/components/upload/demo/custom.md +4 -2
- package/components/upload/demo/directory.md +4 -2
- package/components/upload/demo/draggable.md +4 -2
- package/components/upload/demo/exceed.md +4 -2
- package/components/upload/demo/file-list.md +4 -2
- package/components/upload/demo/form.md +5 -3
- package/components/upload/demo/picture.md +1 -1
- package/components/upload/upload.jsx +9 -5
- package/dist/k-ui.css +2 -3
- package/dist/k-ui.js +2 -3
- package/dist/locale/de.js +7 -0
- package/dist/locale/el.js +7 -0
- package/dist/locale/en.js +7 -0
- package/dist/locale/fr.js +7 -0
- package/dist/locale/it.js +7 -0
- package/dist/locale/ja.js +7 -0
- package/dist/locale/ko.js +7 -0
- package/dist/locale/ru.js +7 -0
- package/dist/locale/th.js +7 -0
- package/dist/locale/ua.js +7 -0
- package/dist/locale/vi.js +7 -0
- package/dist/locale/zhCN.js +7 -0
- package/dist/locale/zhTW.js +7 -0
- package/package.json +3 -2
- package/readme.md +39 -22
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
<script>
|
|
14
14
|
export default{
|
|
15
|
-
data(){
|
|
15
|
+
data() {
|
|
16
16
|
const data = [],columns = [];
|
|
17
17
|
for(let i = 0; i < 10; i++){
|
|
18
18
|
columns.push({ title:'Col'+i, key:'address' })
|
|
19
19
|
}
|
|
20
|
-
return{
|
|
20
|
+
return {
|
|
21
21
|
data:[
|
|
22
22
|
{ key:0, name:'Li Lei', age:28, address:'Hubei Wuhan Guanggu SoftBase No.128' },
|
|
23
23
|
{ key:1, name:'Liu Hao', age:28, address:'Hubei'},
|
|
@@ -25,10 +25,10 @@ export default{
|
|
|
25
25
|
{ key:3, name:'Hu Cong', age:28, address:'Hubei Wuhan Guanggu Hongshan No.128'}
|
|
26
26
|
],
|
|
27
27
|
columns:[
|
|
28
|
-
{title:'Name', key:'name',
|
|
29
|
-
{title:'Age', key:'age' ,
|
|
28
|
+
{title:'Name', key:'name', fixed:'left' },
|
|
29
|
+
{title:'Age', key:'age' , fixed:'left' },
|
|
30
30
|
...columns,
|
|
31
|
-
{title:'Action', key:'action',
|
|
31
|
+
{title:'Action', key:'action', fixed:'right' },
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
<script>
|
|
11
11
|
export default{
|
|
12
|
-
data(){
|
|
12
|
+
data() {
|
|
13
13
|
const data = []
|
|
14
14
|
for(let i = 0; i < 15; i++){
|
|
15
15
|
data.push({ key:i, name:'Li Lei',tag:'Java', age:28, address:'Wu Han Guanggu No.'+i })
|
|
16
16
|
}
|
|
17
|
-
return{
|
|
17
|
+
return {
|
|
18
18
|
data,
|
|
19
19
|
columns:[
|
|
20
20
|
{title:'Name', key:'name' },
|
|
21
21
|
{title:'Age', key:'age' },
|
|
22
22
|
{title:'Tag', key:'tag' },
|
|
23
|
-
{title:'Address', key:'address'
|
|
23
|
+
{title:'Address', key:'address'},
|
|
24
24
|
]
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -7,24 +7,32 @@
|
|
|
7
7
|
```vue
|
|
8
8
|
<template>
|
|
9
9
|
<Table :data="data" :columns="columns" :width="1900" :height="300">
|
|
10
|
-
<a slot="
|
|
10
|
+
<a slot="action1">action1</a>
|
|
11
|
+
<a slot="action2">action2</a>
|
|
12
|
+
<a slot="action3">action3</a>
|
|
13
|
+
<a slot="action4">action4</a>
|
|
11
14
|
</Table>
|
|
12
15
|
</template>
|
|
13
16
|
<script>
|
|
14
17
|
export default{
|
|
15
|
-
data(){
|
|
18
|
+
data() {
|
|
16
19
|
const data = [],columns = [];
|
|
17
20
|
for(let i = 0; i < 10; i++){
|
|
18
21
|
columns.push({ title:'Col'+i, key:'name' })
|
|
19
22
|
data.push({ key:i, name:'Li Lei', age:28, address:'Wu Han Guanggu No.'+i })
|
|
20
23
|
}
|
|
21
|
-
return{
|
|
24
|
+
return {
|
|
22
25
|
data,
|
|
23
26
|
columns:[
|
|
24
|
-
{title:'Name', key:'name', width:
|
|
25
|
-
{title:'
|
|
27
|
+
{title:'Name', key:'name', width:110 , fixed:'left' },
|
|
28
|
+
// {title:'Name', key:'name', width:120 , fixed:'left' },
|
|
29
|
+
// {title:'Name', key:'name', width:130 , fixed:'left' },
|
|
30
|
+
// {title:'Age', key:'age' , width:140 , fixed:'left' },
|
|
26
31
|
...columns,
|
|
27
|
-
{title:'
|
|
32
|
+
{title:'Action1', key:'action1', width:110 , fixed:'right' },
|
|
33
|
+
// {title:'Action2', key:'action2', width:120 , fixed:'right' },
|
|
34
|
+
// {title:'Action3', key:'action3', width:130 , fixed:'right' },
|
|
35
|
+
// {title:'Action4', key:'action4', width:140 , fixed:'right' },
|
|
28
36
|
]
|
|
29
37
|
}
|
|
30
38
|
}
|
|
@@ -11,7 +11,7 @@ columns[n] 可以内嵌 children,以渲染分组表头。
|
|
|
11
11
|
</template>
|
|
12
12
|
<script>
|
|
13
13
|
export default{
|
|
14
|
-
data(){
|
|
14
|
+
data() {
|
|
15
15
|
const data = [];
|
|
16
16
|
for (let i = 0; i < 10; i++) {
|
|
17
17
|
data.push({
|
|
@@ -26,7 +26,7 @@ export default{
|
|
|
26
26
|
gender: 'M',
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
return{
|
|
29
|
+
return {
|
|
30
30
|
data,
|
|
31
31
|
columns:[
|
|
32
32
|
{
|
|
@@ -41,7 +41,6 @@ export default{
|
|
|
41
41
|
{
|
|
42
42
|
title: 'Age',
|
|
43
43
|
key: 'age',
|
|
44
|
-
width: 200,
|
|
45
44
|
sorter:true,
|
|
46
45
|
},
|
|
47
46
|
{
|
|
@@ -50,7 +49,6 @@ export default{
|
|
|
50
49
|
{
|
|
51
50
|
title: 'Street',
|
|
52
51
|
key: 'street',
|
|
53
|
-
width: 200,
|
|
54
52
|
},
|
|
55
53
|
{
|
|
56
54
|
title: 'Block',
|
|
@@ -58,12 +56,10 @@ export default{
|
|
|
58
56
|
{
|
|
59
57
|
title: 'Building',
|
|
60
58
|
key: 'building',
|
|
61
|
-
width: 100,
|
|
62
59
|
},
|
|
63
60
|
{
|
|
64
61
|
title: 'Door No.',
|
|
65
62
|
key: 'number',
|
|
66
|
-
width: 100,
|
|
67
63
|
},
|
|
68
64
|
],
|
|
69
65
|
},
|
|
@@ -77,7 +73,6 @@ export default{
|
|
|
77
73
|
{
|
|
78
74
|
title: 'Company Address',
|
|
79
75
|
key: 'companyAddress',
|
|
80
|
-
width: 200,
|
|
81
76
|
},
|
|
82
77
|
{
|
|
83
78
|
title: 'Company Name',
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<template slot="tags" slot-scope="tags">
|
|
15
15
|
<Tag v-for="tag in tags" :key="tag" :color="tag=='Python'?'red':'orange'">{{tag}}</Tag>
|
|
16
16
|
</template>
|
|
17
|
-
<Icon :type="text==1?
|
|
17
|
+
<Icon :type="text==1 ? Sunny : Moon" slot="gender" slot-scope="text" :color="text==1?'blue':'#f50cff'" size="15"/>
|
|
18
18
|
<template slot="action">
|
|
19
19
|
<a href="javascript:;">Edit</a>
|
|
20
20
|
<a href="javascript:;">Delete</a>
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
<Button @click="selectAll(false)">UnCheck All</Button>
|
|
27
27
|
</template>
|
|
28
28
|
<script>
|
|
29
|
+
import { Sunny, Moon } from "kui-icons";
|
|
29
30
|
export default{
|
|
30
|
-
data(){
|
|
31
|
-
return{
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
Sunny, Moon,
|
|
32
34
|
datas:[
|
|
33
35
|
{ key:'0', name:'Li Lei' ,gender: 0 , age:32 , address:'Wu Han Guanggu No. 328', tags:['Python','Java'] },
|
|
34
36
|
{ key:'1', name:'Liu Hao' ,gender: 1 , age:28 , address:'Wu Han Hongshan No. 128', tags:['Python','Java'] },
|
|
@@ -36,7 +38,7 @@ export default{
|
|
|
36
38
|
{ key:'3', name:'Chuchur' ,gender: 1 , age:28 , address:'Wu Han Nanhu No. 188', tags:['Go','Python'] , _checked:true ,_disabled:false},
|
|
37
39
|
],
|
|
38
40
|
columns:[
|
|
39
|
-
{ type: 'selection'
|
|
41
|
+
{ type: 'selection' },
|
|
40
42
|
{ title:'Name', key:'name' },
|
|
41
43
|
{ title:'Age', key:'age', },
|
|
42
44
|
{ title:'Gender', key:'gender', },
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<template v-slot:tags="values">
|
|
39
39
|
<Tag v-for="tag in values" :key="tag" :color="tag=='Python'?'red':'orange'">{{tag}}</Tag>
|
|
40
40
|
</template>
|
|
41
|
-
<Icon :type="text==1?
|
|
41
|
+
<Icon :type="text==1 ? Moon : Sunny" slot="gender" slot-scope="text" :color="text==1?'blue':'#f50cff'" size="15" />
|
|
42
42
|
<template v-slot:action>
|
|
43
43
|
<a href="javascript:;">Edit</a>
|
|
44
44
|
<a href="javascript:;">Delete</a>
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
</div>
|
|
48
48
|
</template>
|
|
49
49
|
<script>
|
|
50
|
+
import { Moon, Sunny } from "kui-icons";
|
|
50
51
|
const data = [
|
|
51
52
|
{ key: '0', name: 'Li Lei', gender: 0, age: 32, address: 'Wu Han Guanggu No. 328', tags: ['Python', 'Java'] },
|
|
52
53
|
{ key: '1', name: 'Liu Hao', gender: 1, age: 28, address: 'Wu Han Hongshan No. 128', tags: ['Python', 'Java'] },
|
|
@@ -56,6 +57,7 @@ const data = [
|
|
|
56
57
|
export default {
|
|
57
58
|
data() {
|
|
58
59
|
return {
|
|
60
|
+
Moon, Sunny,
|
|
59
61
|
size: "default",
|
|
60
62
|
checkbox: true,
|
|
61
63
|
bordered: true,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
<script>
|
|
14
14
|
export default{
|
|
15
|
-
data(){
|
|
15
|
+
data() {
|
|
16
16
|
const render = (h,row,index,key)=>{
|
|
17
17
|
return {
|
|
18
18
|
children: row[key],
|
|
@@ -21,7 +21,7 @@ export default{
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
return{
|
|
24
|
+
return {
|
|
25
25
|
data:[
|
|
26
26
|
{key:'0', name:'Li Lei' ,age:32 , night:'orange', morning:'apple' },
|
|
27
27
|
{key:'1', name:'Liu Hao' ,age:28 , night:'orange', morning:'ale' },
|
|
@@ -2,10 +2,11 @@ import { hasChild, sortHeaderCols, findItem, } from './utils'
|
|
|
2
2
|
import { measureScrollBar } from '../_tool/utils'
|
|
3
3
|
import { Checkbox } from '../checkbox'
|
|
4
4
|
import Icon from '../icon'
|
|
5
|
+
import { CaretUp, CaretDown } from 'kui-icons'
|
|
6
|
+
|
|
5
7
|
export default {
|
|
6
8
|
name: 'ExtendTable',
|
|
7
9
|
props: {
|
|
8
|
-
mode: String,
|
|
9
10
|
body: Array,
|
|
10
11
|
columns: Array,
|
|
11
12
|
columns2: Array,
|
|
@@ -18,7 +19,9 @@ export default {
|
|
|
18
19
|
data() {
|
|
19
20
|
return {
|
|
20
21
|
scrollBarHeight: 0,
|
|
21
|
-
|
|
22
|
+
// type: 'left',
|
|
23
|
+
theadSync: false,
|
|
24
|
+
tbodySync: false
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
mounted() {
|
|
@@ -27,9 +30,25 @@ export default {
|
|
|
27
30
|
// thead.style.marginBottom = `-${thead.offsetHeight - thead.scrollHeight}px`
|
|
28
31
|
let size = measureScrollBar()
|
|
29
32
|
this.scrollBarHeight = size
|
|
33
|
+
if (this.height && this.width) {
|
|
34
|
+
this.setColWidth()
|
|
35
|
+
}
|
|
30
36
|
}
|
|
31
37
|
},
|
|
32
38
|
methods: {
|
|
39
|
+
setColWidth() {
|
|
40
|
+
const cols = this.$refs.colgroup.children//[0].children
|
|
41
|
+
// console.log(cols)
|
|
42
|
+
// reset tbody's height
|
|
43
|
+
let col = this.columns2 || this.columns
|
|
44
|
+
// console.log(col)
|
|
45
|
+
for (let i = 0; i < cols.length; i++) {
|
|
46
|
+
// console.log(col[i])
|
|
47
|
+
if (col[i] && !col[i].width) {
|
|
48
|
+
col[i].width = cols[i].getBoundingClientRect().width
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
33
52
|
sorter(item) {
|
|
34
53
|
let { _order, sorter } = item
|
|
35
54
|
|
|
@@ -49,46 +68,59 @@ export default {
|
|
|
49
68
|
this.$emit('sorter', item)
|
|
50
69
|
}
|
|
51
70
|
},
|
|
52
|
-
renderCol() {
|
|
53
|
-
const isFixedHeader = this.height
|
|
71
|
+
renderCol(hasHead) {
|
|
72
|
+
const isFixedHeader = this.height != undefined
|
|
54
73
|
let cols = []
|
|
55
74
|
let columns = this.columns2 || this.columns
|
|
56
75
|
columns.forEach((col, i) => {
|
|
57
|
-
let width = col.width || (isFixedHeader ? 150 : '')
|
|
76
|
+
let width = col.width || ''//(isFixedHeader ? 150 : '')
|
|
58
77
|
let hasCheckbox = col.type == 'selection'
|
|
59
78
|
|
|
60
|
-
if (isFixedHeader && i == columns.length - 2 && columns.length > 2) width = ''
|
|
79
|
+
// if (isFixedHeader && i == columns.length - 2 && columns.length > 2) width = ''
|
|
61
80
|
|
|
62
81
|
// set Cols
|
|
63
82
|
let colProps = {
|
|
64
|
-
style: { width: `${width}px
|
|
65
|
-
class:
|
|
83
|
+
style: { width: `${width}px` },
|
|
84
|
+
class: [{
|
|
85
|
+
'k-table-selection-col': hasCheckbox,
|
|
86
|
+
// 'k-table-cell-fixed-left': col.fixed == 'left',
|
|
87
|
+
// 'k-table-cell-fixed-right': col.fixed == 'right',
|
|
88
|
+
}]
|
|
89
|
+
}
|
|
90
|
+
if (!width) {
|
|
91
|
+
delete colProps.style.width
|
|
66
92
|
}
|
|
67
93
|
|
|
68
94
|
if (col.fixed == 'right') {
|
|
69
|
-
colProps.style = { width: `${width || 100}px
|
|
95
|
+
// colProps.style = { width: `${width || 100}px`}
|
|
70
96
|
}
|
|
71
97
|
cols.push(<col {...colProps} />)
|
|
72
98
|
})
|
|
73
99
|
if (this.hasExpand) {
|
|
74
100
|
cols.unshift(<col class="k-table-expand-icon-col"></col>)
|
|
75
101
|
}
|
|
76
|
-
|
|
102
|
+
if (isFixedHeader && hasHead) {
|
|
103
|
+
cols.push(<col style={{ width: this.scrollBarHeight + 'px' }}></col>)
|
|
104
|
+
}
|
|
105
|
+
return <colgroup ref="colgroup">{cols}</colgroup>
|
|
77
106
|
},
|
|
78
107
|
renderSort(col) {
|
|
79
108
|
return (col.sorter) ? (<span class="k-table-sorter">
|
|
80
|
-
<Icon type=
|
|
81
|
-
<Icon type=
|
|
109
|
+
<Icon type={CaretUp} class={{ actived: col._order == 'asc' }} />
|
|
110
|
+
<Icon type={CaretDown} class={{ actived: col._order == 'desc' }} />
|
|
82
111
|
</span>) : null
|
|
83
112
|
},
|
|
84
|
-
renderTH(col) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const hasSort = col.sorter && hasInner
|
|
113
|
+
renderTH(col, left, right) {
|
|
114
|
+
let hasCheckbox = col.type == 'selection'
|
|
115
|
+
const hasSort = col.sorter
|
|
88
116
|
let props = {
|
|
89
117
|
class: {
|
|
90
118
|
'k-table-cell-ellipsis': col.ellipsis,
|
|
91
119
|
'k-table-cell-selection': hasCheckbox,
|
|
120
|
+
'k-table-cell-fixed-left': col.fixed == 'left',
|
|
121
|
+
'k-table-cell-fixed-right': col.fixed == 'right',
|
|
122
|
+
'k-table-cell-fixed-left-last': col.last,
|
|
123
|
+
'k-table-cell-fixed-right-first': col.first,
|
|
92
124
|
'k-table-cell-sorter': hasSort,
|
|
93
125
|
[col.className]: col.className
|
|
94
126
|
},
|
|
@@ -97,8 +129,16 @@ export default {
|
|
|
97
129
|
colSpan: col.colSpan > 1 ? col.colSpan : null,
|
|
98
130
|
rowSpan: col.rowSpan
|
|
99
131
|
},
|
|
100
|
-
on: {}
|
|
132
|
+
on: {},
|
|
133
|
+
style: {}
|
|
134
|
+
}
|
|
135
|
+
if (col.fixed == 'left') {
|
|
136
|
+
props.style.left = left + 'px'
|
|
101
137
|
}
|
|
138
|
+
if (col.fixed == 'right') {
|
|
139
|
+
props.style.right = right + 'px'
|
|
140
|
+
}
|
|
141
|
+
|
|
102
142
|
if (hasSort) {
|
|
103
143
|
props.on.click = () => this.sorter(col)
|
|
104
144
|
}
|
|
@@ -126,19 +166,39 @@ export default {
|
|
|
126
166
|
} else {
|
|
127
167
|
cols = this.columns
|
|
128
168
|
}
|
|
129
|
-
let head = [], ths = []
|
|
130
|
-
|
|
169
|
+
let head = [], ths = [], hasFR = false, left = 0,
|
|
170
|
+
right = cols.filter(c => c.fixed == 'right').map(c => c.width).reduce((a, b) => a + b, 0) + (this.height ? this.scrollBarHeight : 0)
|
|
171
|
+
|
|
172
|
+
cols.forEach((col, i) => {
|
|
131
173
|
if (Array.isArray(col)) {
|
|
132
|
-
let ths = []
|
|
133
|
-
|
|
134
|
-
|
|
174
|
+
let ths = [], r = col.filter(c => c.fixed == 'right').map(c => c.width).reduce((a, b) => a + b, 0) + (this.height ? this.scrollBarHeight : 0)
|
|
175
|
+
|
|
176
|
+
col.forEach((co, j) => {
|
|
177
|
+
if (co.fixed == 'left' && j > 0) {
|
|
178
|
+
left += col[j - 1].width
|
|
179
|
+
}
|
|
180
|
+
if (co.fixed == 'right' && i < col.length) {
|
|
181
|
+
r -= co.width
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let th = this.renderTH(co, left, r)
|
|
135
185
|
ths.push(th)
|
|
136
186
|
})
|
|
187
|
+
if (i == 0 && this.width) {
|
|
188
|
+
ths.push(<th rowSpan={col.length} class="k-table-cell-fixed-right" style={{ width: this.scrollBarHeight + 'px' }}></th>)
|
|
189
|
+
}
|
|
137
190
|
head.push(<tr>{ths}</tr>)
|
|
138
191
|
} else {
|
|
139
192
|
// set Head
|
|
193
|
+
hasFR = col.fixed == 'right'
|
|
140
194
|
if (col.colSpan !== 0) {
|
|
141
|
-
|
|
195
|
+
if (col.fixed == 'left' && i > 0) {
|
|
196
|
+
left += cols[i - 1].width
|
|
197
|
+
}
|
|
198
|
+
if (col.fixed == 'right' && i < cols.length) {
|
|
199
|
+
right -= col.width
|
|
200
|
+
}
|
|
201
|
+
let th = this.renderTH(col, left, right)
|
|
142
202
|
ths.push(th)
|
|
143
203
|
}
|
|
144
204
|
}
|
|
@@ -146,6 +206,14 @@ export default {
|
|
|
146
206
|
if (this.hasExpand) {
|
|
147
207
|
ths.unshift(<th></th>)
|
|
148
208
|
}
|
|
209
|
+
if (this.height != undefined) {
|
|
210
|
+
let cls = []
|
|
211
|
+
let hasFR = cols.filter(c => c.fixed == 'right')
|
|
212
|
+
if (hasFR) {
|
|
213
|
+
cls.push('k-table-cell-fixed-right')
|
|
214
|
+
}
|
|
215
|
+
ths.push(<th style={{ width: this.scrollBarHeight + 'px' }} class={cls}></th>)
|
|
216
|
+
}
|
|
149
217
|
if (!head.length) {
|
|
150
218
|
head.push(<tr>{ths}</tr>)
|
|
151
219
|
}
|
|
@@ -154,12 +222,10 @@ export default {
|
|
|
154
222
|
},
|
|
155
223
|
renderTable(hasHead, body) {
|
|
156
224
|
let props = {}
|
|
157
|
-
|
|
158
|
-
props.style = { width: `${this.width}px` }
|
|
159
|
-
}
|
|
225
|
+
props.style = { width: `${this.width}px` }
|
|
160
226
|
return (
|
|
161
227
|
<table {...props}>
|
|
162
|
-
{this.renderCol()}
|
|
228
|
+
{this.renderCol(hasHead)}
|
|
163
229
|
{hasHead ? this.renderHead(hasHead) : null}
|
|
164
230
|
{body ? <tbody ref="tbody">{body}</tbody> : null}
|
|
165
231
|
</table>
|
|
@@ -167,53 +233,89 @@ export default {
|
|
|
167
233
|
},
|
|
168
234
|
onSelectAll(e) {
|
|
169
235
|
this.$emit('select-all', e)
|
|
236
|
+
},
|
|
237
|
+
asyncScroll(e, target) {
|
|
238
|
+
// console.log(e.target.scrollLeft)
|
|
239
|
+
let min = 0, max = e.target.scrollWidth - e.target.offsetWidth, scrollLeft = e.target.scrollLeft;
|
|
240
|
+
scrollLeft = Math.round(scrollLeft);
|
|
241
|
+
// console.log(e, target)
|
|
242
|
+
if (target) {
|
|
243
|
+
// if (target == 'tbody') {
|
|
244
|
+
// if (!this.theadSync) {
|
|
245
|
+
// this.theadSync = true
|
|
246
|
+
this.$refs[target].scrollLeft = scrollLeft
|
|
247
|
+
// }
|
|
248
|
+
// this.theadSync = false
|
|
249
|
+
// }
|
|
250
|
+
// if (target == 'thead') {
|
|
251
|
+
// if (!this.tbodySync) {
|
|
252
|
+
// this.tbodySync = true
|
|
253
|
+
// this.$refs[target].scrollLeft = scrollLeft
|
|
254
|
+
// }
|
|
255
|
+
// this.tbodySync = false
|
|
256
|
+
// }
|
|
257
|
+
}
|
|
258
|
+
let ping = 'left'
|
|
259
|
+
// console.log(min, scrollLeft, max)
|
|
260
|
+
if (scrollLeft > min && scrollLeft < max) {
|
|
261
|
+
ping = 'middle'
|
|
262
|
+
} else if (scrollLeft == min) {
|
|
263
|
+
ping = 'left'
|
|
264
|
+
} else if (scrollLeft == max) {
|
|
265
|
+
ping = 'right'
|
|
266
|
+
}
|
|
267
|
+
this.$emit('ping', ping)
|
|
268
|
+
// this.$refs.table.setAttribute('class', `k-table11-ping-${ping}`)
|
|
170
269
|
}
|
|
171
270
|
},
|
|
172
271
|
render() {
|
|
173
|
-
let { height, width,
|
|
174
|
-
const isMain = mode == 'main'
|
|
175
|
-
|
|
272
|
+
let { height, width, body, scrollBarHeight } = this
|
|
176
273
|
let rootProps = {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
274
|
+
// ref: 'table',
|
|
275
|
+
// class: [`k-table-container`,
|
|
276
|
+
// // { [`k-table-ping-${type}`]: width != undefined },
|
|
277
|
+
// ],
|
|
278
|
+
style: {},
|
|
279
|
+
on: {}
|
|
280
|
+
}
|
|
281
|
+
if (width && !height) {
|
|
282
|
+
rootProps.style.overflow = 'auto';
|
|
283
|
+
// rootProps.on.scroll = e => this.asyncScroll(e)
|
|
184
284
|
}
|
|
185
285
|
|
|
186
286
|
const content = []
|
|
187
287
|
if (height) {
|
|
188
288
|
let headProps = {
|
|
189
|
-
class: `k-table-
|
|
190
|
-
|
|
191
|
-
'
|
|
289
|
+
class: `k-table-thead`,
|
|
290
|
+
on: {
|
|
291
|
+
scroll: e => this.asyncScroll(e, 'tbody')
|
|
192
292
|
},
|
|
193
|
-
on: {},
|
|
194
293
|
ref: 'thead',
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (isMain && width) {
|
|
198
|
-
headProps.on.scroll = ({ target }) => {
|
|
199
|
-
this.headFocus && this.$refs.body.scrollTo(target.scrollLeft, this.$refs.body.scrollTop)
|
|
294
|
+
style: {
|
|
295
|
+
// marginBottom: -scrollBarHeight + 'px'
|
|
200
296
|
}
|
|
201
|
-
|
|
202
|
-
|
|
297
|
+
}
|
|
298
|
+
if (width && height) {
|
|
299
|
+
headProps.style.marginBottom = -scrollBarHeight + 'px'
|
|
300
|
+
}
|
|
301
|
+
if (height) {
|
|
302
|
+
headProps.style.overflow = 'auto'
|
|
203
303
|
}
|
|
204
304
|
content.push(<div {...headProps}>{this.renderTable(true, false)}</div>)
|
|
205
305
|
|
|
206
306
|
const props = {
|
|
207
|
-
class: `k-table-
|
|
307
|
+
class: `k-table-body`,
|
|
208
308
|
style: {
|
|
209
|
-
height: `${isMain ? height : (height - scrollBarHeight)}px`,
|
|
210
|
-
// height: `${height}px`,
|
|
211
|
-
'overflow-x': isMain && width ? 'auto' : null,
|
|
212
|
-
'overflow-y': isMain && height ? 'auto' : null,
|
|
213
309
|
},
|
|
214
|
-
ref: 'body',
|
|
215
310
|
on: {
|
|
216
|
-
|
|
311
|
+
scroll: e => this.asyncScroll(e, 'thead')
|
|
312
|
+
},
|
|
313
|
+
ref: "tbody"
|
|
314
|
+
}
|
|
315
|
+
if (height) {
|
|
316
|
+
props.style = {
|
|
317
|
+
height: height + 'px',
|
|
318
|
+
overflow: 'auto scroll'
|
|
217
319
|
}
|
|
218
320
|
}
|
|
219
321
|
content.push(<div {...props}>{this.renderTable(false, body)}</div>)
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
| --------- | ------------------------------------------------------------------------------------------------- | ------------------------------ | ------ |
|
|
23
23
|
| title | 列头显示文字 | String | - |
|
|
24
24
|
| key | 对应列内容的字段名 | String | - |
|
|
25
|
+
| sorter | 是否取用列排序 | Boolean | - |
|
|
25
26
|
| width | 列宽 | Number | - |
|
|
26
27
|
| rowSpan | 行合并单位,为 0 时将不渲染当前行 | Number | - |
|
|
27
28
|
| colSpan | 列合并单位,为 0 时将不渲染当前列 | Number | - |
|