init
This commit is contained in:
parent
a5321e843e
commit
8135a8c341
3 changed files with 34 additions and 1 deletions
|
@ -24,17 +24,23 @@
|
||||||
:column="column"
|
:column="column"
|
||||||
:index="index"
|
:index="index"
|
||||||
:render="column.render"></table-expand>
|
:render="column.render"></table-expand>
|
||||||
|
<table-slot
|
||||||
|
v-if="renderType === 'slot'"
|
||||||
|
:row="row"
|
||||||
|
:column="column"
|
||||||
|
:index="index"></table-slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import TableExpand from './expand';
|
import TableExpand from './expand';
|
||||||
|
import TableSlot from './slot';
|
||||||
import Icon from '../icon/icon.vue';
|
import Icon from '../icon/icon.vue';
|
||||||
import Checkbox from '../checkbox/checkbox.vue';
|
import Checkbox from '../checkbox/checkbox.vue';
|
||||||
import Tooltip from '../tooltip/tooltip.vue';
|
import Tooltip from '../tooltip/tooltip.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TableCell',
|
name: 'TableCell',
|
||||||
components: { Icon, Checkbox, TableExpand, Tooltip },
|
components: { Icon, Checkbox, TableExpand, TableSlot, Tooltip },
|
||||||
props: {
|
props: {
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
row: Object,
|
row: Object,
|
||||||
|
@ -107,6 +113,8 @@
|
||||||
this.renderType = 'expand';
|
this.renderType = 'expand';
|
||||||
} else if (this.column.render) {
|
} else if (this.column.render) {
|
||||||
this.renderType = 'render';
|
this.renderType = 'render';
|
||||||
|
} else if (this.column.slot) {
|
||||||
|
this.renderType = 'slot';
|
||||||
} else {
|
} else {
|
||||||
this.renderType = 'normal';
|
this.renderType = 'normal';
|
||||||
}
|
}
|
||||||
|
|
20
src/components/table/slot.js
Normal file
20
src/components/table/slot.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
export default {
|
||||||
|
name: 'TableSlot',
|
||||||
|
functional: true,
|
||||||
|
inject: ['tableRoot'],
|
||||||
|
props: {
|
||||||
|
row: Object,
|
||||||
|
index: Number,
|
||||||
|
column: {
|
||||||
|
type: Object,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render: (h, ctx) => {
|
||||||
|
return h('div', ctx.injections.tableRoot.$scopedSlots[ctx.props.column.slot]({
|
||||||
|
row: ctx.props.row,
|
||||||
|
column: ctx.props.column,
|
||||||
|
index: ctx.props.index
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
|
@ -114,6 +114,11 @@
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
mixins: [ Locale ],
|
mixins: [ Locale ],
|
||||||
components: { tableHead, tableBody, Spin },
|
components: { tableHead, tableBody, Spin },
|
||||||
|
provide () {
|
||||||
|
return {
|
||||||
|
tableRoot: this
|
||||||
|
};
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
Loading…
Add table
Reference in a new issue