Commit 6c99b9fe5918506af4cbb5938856f110488b4210

Authored by 梁灏
1 parent 97edb2eb

update Table

update Table
src/components/table/table-head.vue
... ... @@ -68,13 +68,18 @@
68 68 style: Object,
69 69 columns: Array,
70 70 objData: Object,
  71 + data: Array, // rebuildData
71 72 fixed: Boolean
72 73 },
73 74 computed: {
74 75 isSelectAll () {
75 76 let isSelectAll = true;
76   - for (let i in this.objData) {
77   - if (!this.objData[i]._isChecked) isSelectAll = false;
  77 +
  78 + for (let i = 0; i < this.data.length; i++) {
  79 + if (!this.objData[this.data[i]._index]._isChecked) {
  80 + isSelectAll = false;
  81 + break;
  82 + }
78 83 }
79 84  
80 85 return isSelectAll;
... ...
src/components/table/table.vue
... ... @@ -7,7 +7,8 @@
7 7 :prefix-cls="prefixCls"
8 8 :style="tableStyle"
9 9 :columns="cloneColumns"
10   - :obj-data="objData"></table-head>
  10 + :obj-data="objData"
  11 + :data="rebuildData"></table-head>
11 12 </div>
12 13 <div :class="[prefixCls + '-body']" :style="bodyStyle" v-el:body @scroll="handleBodyScroll">
13 14 <table-body
... ... @@ -25,7 +26,8 @@
25 26 :prefix-cls="prefixCls"
26 27 :style="fixedTableStyle"
27 28 :columns="leftFixedColumns"
28   - :obj-data="objData"></table-head>
  29 + :obj-data="objData"
  30 + :data="rebuildData"></table-head>
29 31 </div>
30 32 <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" v-el:fixed-body>
31 33 <table-body
... ... @@ -44,7 +46,8 @@
44 46 :prefix-cls="prefixCls"
45 47 :style="fixedRightTableStyle"
46 48 :columns="rightFixedColumns"
47   - :obj-data="objData"></table-head>
  49 + :obj-data="objData"
  50 + :data="rebuildData"></table-head>
48 51 </div>
49 52 <div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" v-el:fixed-right-body>
50 53 <table-body
... ... @@ -282,9 +285,9 @@
282 285 this.$emit('on-selection-change', selection);
283 286 },
284 287 selectAll (status) {
285   - for (let i in this.objData) {
286   - this.objData[i]._isChecked = status;
287   - }
  288 + this.rebuildData.forEach((data) => {
  289 + this.objData[data._index]._isChecked = status;
  290 + });
288 291  
289 292 const selection = this.getSelection();
290 293 if (status) {
... ...
test/routers/table.vue
... ... @@ -198,8 +198,8 @@
198 198 this.$Message.info(this.data[index].name);
199 199 },
200 200 current (newData, oldData) {
201   - console.log(newData);
202   - console.log(oldData);
  201 +// console.log(newData);
  202 +// console.log(oldData);
203 203 },
204 204 select (a,b){
205 205 // console.log(a);
... ... @@ -209,7 +209,7 @@
209 209 // console.log(a)
210 210 },
211 211 sall (a) {
212   -// console.log(a)
  212 + console.log(a)
213 213 },
214 214 rowClsName (row, index) {
215 215 if (index == 1) {
... ... @@ -238,7 +238,7 @@
238 238 // edit: false
239 239 // });
240 240 // this.data.splice(0, 1);
241   - this.columns.splice(2,1)
  241 +// this.columns.splice(2,1)
242 242 }, 3000);
243 243 }
244 244 }
... ...