a3547c1b
梁灏
update Table
|
1
|
<template>
|
87a400d8
梁灏
update Table
|
2
|
<div :class="classes" ref="cell">
|
d9d1dbbd
梁灏
Table Column add ...
|
3
|
<template v-if="renderType === 'index'"><span>{{ column.indexMethod ? column.indexMethod(row) : (naturalIndex + 1) }}</span></template>
|
3ef4dfb9
梁灏
update Table
|
4
|
<template v-if="renderType === 'selection'">
|
afea484f
梁灏
fixed #1271
|
5
|
<Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
|
3ef4dfb9
梁灏
update Table
|
6
|
</template>
|
b3dbdba9
anykno
impove table rend...
|
7
|
<template v-if="renderType === 'html'"><span v-html="row[column.key]"></span></template>
|
8c51d57d
梁灏
Table Column add ...
|
8
9
10
11
12
13
14
15
|
<template v-if="renderType === 'normal'">
<template v-if="column.tooltip">
<Tooltip transfer :content="row[column.key]" :disabled="!showTooltip" :max-width="300" class="ivu-table-cell-tooltip">
<span ref="content" @mouseenter="handleTooltipIn" @mouseleave="handleTooltipOut" class="ivu-table-cell-tooltip-content">{{ row[column.key] }}</span>
</Tooltip>
</template>
<span v-else>{{row[column.key]}}</span>
</template>
|
e4e8711d
Aresn
Table support dis...
|
16
|
<template v-if="renderType === 'expand' && !row._disableExpand">
|
08fd628d
Aresn
Table support expand
|
17
|
<div :class="expandCls" @click="toggleExpand">
|
021bbec2
梁灏
update Table Icons
|
18
|
<Icon type="ios-arrow-forward"></Icon>
|
08fd628d
Aresn
Table support expand
|
19
20
|
</div>
</template>
|
4098c176
Aresn
update Table
|
21
22
23
24
25
26
|
<Cell
v-if="renderType === 'render'"
:row="row"
:column="column"
:index="index"
:render="column.render"></Cell>
|
a3547c1b
梁灏
update Table
|
27
28
29
|
</div>
</template>
<script>
|
4098c176
Aresn
update Table
|
30
|
import Cell from './expand';
|
08fd628d
Aresn
Table support expand
|
31
|
import Icon from '../icon/icon.vue';
|
3ef4dfb9
梁灏
update Table
|
32
|
import Checkbox from '../checkbox/checkbox.vue';
|
8c51d57d
梁灏
Table Column add ...
|
33
|
import Tooltip from '../tooltip/tooltip.vue';
|
3ef4dfb9
梁灏
update Table
|
34
|
|
a3547c1b
梁灏
update Table
|
35
|
export default {
|
486d4fda
梁灏
update Table
|
36
|
name: 'TableCell',
|
8c51d57d
梁灏
Table Column add ...
|
37
|
components: { Icon, Checkbox, Cell, Tooltip },
|
a3547c1b
梁灏
update Table
|
38
39
40
41
|
props: {
prefixCls: String,
row: Object,
column: Object,
|
741b987a
梁灏
update Table
|
42
43
|
naturalIndex: Number, // index of rebuildData
index: Number, // _index of data
|
7f34c510
梁灏
update Table
|
44
|
checked: Boolean,
|
87379c82
leonine
去掉禁用行的 tr>td 的dis...
|
45
|
disabled: Boolean,
|
08fd628d
Aresn
Table support expand
|
46
|
expanded: Boolean,
|
5d0499ce
梁灏
update Table
|
47
48
49
50
|
fixed: {
type: [Boolean, String],
default: false
}
|
a3547c1b
梁灏
update Table
|
51
52
53
54
|
},
data () {
return {
renderType: '',
|
d0e206c5
梁灏
Table add content...
|
55
|
uid: -1,
|
8c51d57d
梁灏
Table Column add ...
|
56
57
|
context: this.$parent.$parent.$parent.currentContext,
showTooltip: false, // 鼠标滑过overflow文本时,再检查是否需要显示
|
b0893113
jingsam
add eslint
|
58
|
};
|
a3547c1b
梁灏
update Table
|
59
|
},
|
3ef4dfb9
梁灏
update Table
|
60
61
62
63
64
|
computed: {
classes () {
return [
`${this.prefixCls}-cell`,
{
|
eedcba58
Rijn
Added ellipsis pr...
|
65
|
[`${this.prefixCls}-hidden`]: !this.fixed && this.column.fixed && (this.column.fixed === 'left' || this.column.fixed === 'right'),
|
08fd628d
Aresn
Table support expand
|
66
|
[`${this.prefixCls}-cell-ellipsis`]: this.column.ellipsis || false,
|
fc3e16cf
梁灏
update Table sele...
|
67
68
|
[`${this.prefixCls}-cell-with-expand`]: this.renderType === 'expand',
[`${this.prefixCls}-cell-with-selection`]: this.renderType === 'selection'
|
3ef4dfb9
梁灏
update Table
|
69
|
}
|
b0893113
jingsam
add eslint
|
70
|
];
|
08fd628d
Aresn
Table support expand
|
71
72
73
74
75
76
77
|
},
expandCls () {
return [
`${this.prefixCls}-cell-expand`,
{
[`${this.prefixCls}-cell-expand-expanded`]: this.expanded
}
|
af6e81cd
Aresn
update Table
|
78
|
];
|
3ef4dfb9
梁灏
update Table
|
79
80
|
}
},
|
a3547c1b
梁灏
update Table
|
81
|
methods: {
|
741b987a
梁灏
update Table
|
82
|
toggleSelect () {
|
e40c5352
Aresn
fixed #1195
|
83
|
this.$parent.$parent.$parent.toggleSelect(this.index);
|
08fd628d
Aresn
Table support expand
|
84
85
|
},
toggleExpand () {
|
e40c5352
Aresn
fixed #1195
|
86
|
this.$parent.$parent.$parent.toggleExpand(this.index);
|
afea484f
梁灏
fixed #1271
|
87
88
89
|
},
handleClick () {
// 放置 Checkbox 冒泡
|
8c51d57d
梁灏
Table Column add ...
|
90
91
92
93
94
95
96
|
},
handleTooltipIn () {
const $content = this.$refs.content;
this.showTooltip = $content.scrollWidth > $content.offsetWidth;
},
handleTooltipOut () {
this.showTooltip = false;
|
a3547c1b
梁灏
update Table
|
97
98
|
}
},
|
486d4fda
梁灏
update Table
|
99
|
created () {
|
a3547c1b
梁灏
update Table
|
100
101
|
if (this.column.type === 'index') {
this.renderType = 'index';
|
3ef4dfb9
梁灏
update Table
|
102
103
|
} else if (this.column.type === 'selection') {
this.renderType = 'selection';
|
b3dbdba9
anykno
impove table rend...
|
104
105
|
} else if (this.column.type === 'html') {
this.renderType = 'html';
|
08fd628d
Aresn
Table support expand
|
106
107
|
} else if (this.column.type === 'expand') {
this.renderType = 'expand';
|
a3547c1b
梁灏
update Table
|
108
109
110
111
112
|
} else if (this.column.render) {
this.renderType = 'render';
} else {
this.renderType = 'normal';
}
|
a3547c1b
梁灏
update Table
|
113
|
}
|
b0893113
jingsam
add eslint
|
114
115
|
};
</script>
|