22 <div >
33 <div class =" site-demo-container" >
44 <div class =" operation" >
5- {{ currentLocal["columnFixed"] }}
6- <el-switch
7- v-model =" columnFixed"
8- active-color =" #1890ff"
9- inactive-color =" rgba(0,0,0,.25)"
10- >
11- </el-switch >
5+ <el-row :gutter =" 20" >
6+ <el-col :span =" 3" >
7+ {{ currentLocal["columnFixed"] }}
8+ <el-switch
9+ v-model =" enableColumnFixed"
10+ :active-color =" switchActiveColor"
11+ :inactive-color =" switchInactiveColor"
12+ >
13+ </el-switch >
14+ </el-col >
15+ <el-col :span =" 3" >
16+ {{ currentLocal["loading"] }}
17+ <el-switch
18+ v-model =" enableLoading"
19+ :active-color =" switchActiveColor"
20+ :inactive-color =" switchInactiveColor"
21+ @change =" switchLoading"
22+ >
23+ </el-switch >
24+ </el-col >
25+ <el-col :span =" 3"
26+ >{{ currentLocal["expand"] }}
27+ <el-switch
28+ v-model =" enableExpand"
29+ :active-color =" switchActiveColor"
30+ :inactive-color =" switchInactiveColor"
31+ @change =" switchLoading"
32+ >
33+ </el-switch
34+ ></el-col >
35+ <el-col :span =" 3" ><div ></div ></el-col >
36+ <el-col :span =" 3" ><div ></div ></el-col >
37+ <el-col :span =" 3" ><div ></div ></el-col >
38+ <el-col :span =" 3" ><div ></div ></el-col >
39+ <el-col :span =" 3" ><div ></div ></el-col >
40+ </el-row >
1241 </div >
1342
1443 <ve-table
44+ id =" demo-loading-container"
1545 fixed-header
1646 border-y
1747 :max-height =" 600"
2151 :table-data =" tableData"
2252 row-key-field-name =" rowKey"
2353 :cell-style-option =" cellStyleOption"
54+ :expand-option =" expandOption"
2455 />
2556 </div >
2657 <!-- <Footer /> -->
@@ -39,9 +70,15 @@ export default {
3970 mixins: [I18nMixins],
4071 data () {
4172 return {
42- columnFixed: true ,
73+ switchActiveColor: " #1890ff" ,
74+ switchInactiveColor: " rgba(0,0,0,.25)" ,
75+
76+ enableColumnFixed: true ,
77+ enableLoading: false ,
78+ enableExpand: true ,
4379
4480 // ---------------table options---------------
81+ tableData: [],
4582 cellStyleOption: {
4683 bodyCellClass : ({ row, column, rowIndex }) => {
4784 if (column .field === " proficiency" ) {
@@ -53,7 +90,18 @@ export default {
5390 // 是否开启
5491 enable: true
5592 },
56- tableData: []
93+ expandOption: {
94+ render : ({ row, column, rowIndex }, h ) => {
95+ return (
96+ < p>
97+ Hello everyone, My name is{" " }
98+ < span style= " font-weight:bold;" > {row .name }< / span> ,
99+ I ' m a {row.profession}.<br /> And I' m living in {" " }
100+ {row .address }.
101+ < / p>
102+ );
103+ }
104+ }
57105 };
58106 },
59107 computed: {
@@ -63,17 +111,31 @@ export default {
63111 },
64112
65113 columns () {
66- let columns = [
67- {
68- field: " rowIndex" ,
69- key: " a" ,
70- title: " #" ,
71- width: 50 ,
72- fixed: this .columnFixed ? " left" : " "
73- },
114+ let columns = [];
115+
116+ if (this .enableExpand ) {
117+ columns .push ({
118+ field: " expand" ,
119+ key: " expand" ,
120+ title: " " ,
121+ width: 30 ,
122+ fixed: this .enableColumnFixed ? " left" : " " ,
123+ type: " expand"
124+ });
125+ }
126+
127+ columns .push ({
128+ field: " rowIndex" ,
129+ key: " a" ,
130+ title: " #" ,
131+ width: 30 ,
132+ fixed: this .enableColumnFixed ? " left" : " "
133+ });
134+
135+ columns = columns .concat ([
74136 {
75137 title: " Basic Info" ,
76- fixed: this .columnFixed ? " left" : " " ,
138+ fixed: this .enableColumnFixed ? " left" : " " ,
77139 children: [
78140 {
79141 field: " name" ,
@@ -215,7 +277,7 @@ export default {
215277 key: " h" ,
216278 title: " Status" ,
217279 width: 55 ,
218- fixed: this .columnFixed ? " right" : " " ,
280+ fixed: this .enableColumnFixed ? " right" : " " ,
219281 align: " left" ,
220282 renderBodyCell : ({ row, column, rowIndex }, h ) => {
221283 const cellData = row[column .field ];
@@ -244,14 +306,25 @@ export default {
244306 );
245307 }
246308 }
247- ];
309+ ]) ;
248310
249311 return columns;
250312 }
251313 },
252314 methods: {
253- // column fixed change
254- columnFixedChange () {},
315+ /* showLoading() {
316+ this.loadingInstance.show();
317+ },
318+ closeLoading() {
319+ this.loadingInstance.close();
320+ }, */
321+ switchLoading () {
322+ if (this .enableLoading ) {
323+ this .loadingInstance .show ();
324+ } else {
325+ this .loadingInstance .close ();
326+ }
327+ },
255328
256329 initData () {
257330 const PROFESSIONS = [
@@ -283,6 +356,14 @@ export default {
283356 },
284357 created () {
285358 this .initData ();
359+ },
360+ mounted () {
361+ this .loadingInstance = this .$veLoading ({
362+ target: document .querySelector (" #demo-loading-container" ),
363+ // 等同于
364+ // target:"#loading-container"
365+ name: " grid"
366+ });
286367 }
287368};
288369 </script >
0 commit comments