normal.vue
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<el-table :data="tableData" :size="tableSize" v-bind="_props">
<slot name="left"></slot>
<template v-for="(item, index) in columns">
<el-table-column v-bind="item" :key="index">
<slot :name="`header-${item.prop}`" slot="header"></slot>
<template v-if="$scopedSlots[`cell-${item.prop}`]" #default="{ row, column, $index }">
<slot :name="`cell-${item.prop}`" :value="row[column.property]" :row="row" :index="$index"></slot>
</template>
</el-table-column>
</template>
<slot></slot>
<slot name="append"></slot>
</el-table>
</template>
<script>
import tableProps from './props';
export default {
name: 'TableNormal',
inject: {
elForm: {
default: '',
},
elFormItem: {
default: '',
},
},
props: {
value: {
type: Array,
default() {
return [];
},
},
columns: {
type: Array,
default() {
return [];
},
},
...tableProps,
},
data() {
return {
tableData: this.value.length > 0 ? this.value : this.data,
};
},
watch: {
value(val) {
this.tableData = val || [];
},
data(val) {
this.tableData = val || [];
},
},
computed: {
_elFormItemSize() {
return (this.elFormItem || {}).elFormItemSize;
},
tableSize() {
return this.size || this._elFormItemSize || (this.elForm || {}).size || (this.$ELEMENT || {}).size;
},
},
};
</script>