Skip to content

Commit 5389c18

Browse files
committed
增加table显示隐藏序号、checkbox属性
1 parent 8e3f5f8 commit 5389c18

File tree

4 files changed

+74
-32
lines changed

4 files changed

+74
-32
lines changed

Vol.Vue/src/components/basic/ViewGrid.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686
<span>{{table.cnName}}</span>
8787
</div>
8888
<div class="notice">
89-
<!-- <Tooltip content="6666666666666666" placement="bottom">
90-
<a>Bottom Center</a>
91-
</Tooltip>-->
9289
<a class="text"
9390
:title="extend.text">{{extend.text}}</a>
9491
</div>
@@ -195,7 +192,9 @@
195192
:endEditBefore="detailOptions.endEditBefore"
196193
:endEditAfter="detailOptions.endEditAfter"
197194
:summary="detailOptions.summary"
198-
:click-edit="detailOptions.clickEdit"></vol-table>
195+
:click-edit="detailOptions.clickEdit"
196+
:column-index="detailOptions.columnIndex"
197+
:ck="detailOptions.ck"></vol-table>
199198
</div>
200199
<!--明细footer自定义组件-->
201200
<modelFooter ref="modelFooter"
@@ -239,7 +238,9 @@
239238
:pagination-hide="false"
240239
:url="url"
241240
:defaultLoadPage="load"
242-
:summary="summary"></vol-table>
241+
:summary="summary"
242+
:column-index="columnIndex"
243+
:ck="ck"></vol-table>
243244
</div>
244245
</div>
245246

@@ -344,6 +345,8 @@ var vueParam = {
344345
//需要从远程绑定数据源的字典编号,如果字典数据源的查询结果较多,请在onInit中将字典编号添加进来
345346
//只对自定sql有效
346347
remoteKeys: [],
348+
columnIndex: false,//2020.11.01是否显示行号
349+
ck: true,//2020.11.01是否显示checkbox
347350
// detailUrl: "",
348351
detailOptions: {
349352
//弹出框从表(明细)对象
@@ -375,6 +378,8 @@ var vueParam = {
375378
endEditAfter: (row, column, index) => {
376379
return true;
377380
},
381+
columnIndex: false,//2020.11.01明细是否显示行号
382+
ck: true,//2020.11.01明细是否显示checkbox
378383
},
379384
auditParam: {
380385
//审核对象

Vol.Vue/src/components/basic/VolTable.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
border
3030
:row-class-name="initIndex"
3131
style="width: 100%">
32+
<el-table-column v-if="columnIndex"
33+
type="index"
34+
width="55"></el-table-column>
3235
<el-table-column v-if="ck"
3336
type="selection"
3437
width="55"></el-table-column>
3538
<!-- 2020.10.10移除table第一行强制排序 -->
36-
<el-table-column v-for="(column, cindex) in filterColumns()"
39+
<el-table-column v-for="(column, cindex) in filterColumns"
3740
:key="cindex"
3841
:prop="column.field"
3942
:label="column.title"
@@ -350,6 +353,11 @@ export default {
350353
type: Boolean,
351354
default: true,
352355
},
356+
columnIndex: {
357+
//是否显示行号(2020..11.1)
358+
type: Boolean,
359+
default: true,
360+
}
353361
},
354362
data () {
355363
return {
@@ -414,17 +422,18 @@ export default {
414422
let keys = [];
415423
let columnBind = [];
416424
this.summaryData.push("合计");
425+
if (this.columnIndex) {
426+
this.summaryData.push(" ");
427+
}
417428
this.columns.forEach((x, _index) => {
418429
if (!x.hidden) {
419430
//this.summaryIndex[x.field] = _index;
420431
//2020.10.11修复求和列错位的问题
421432
this.summaryData.push("");
422-
this.summaryIndex[x.field] = this.summaryData.length;
433+
this.summaryIndex[x.field] = this.summaryData.length - 1;
423434
}
424435
//求和
425436
if (x.summary && !this.summary) {
426-
//强制开启选择框
427-
this.ck = true;
428437
this.summary = true;
429438
}
430439
if (x.bind && x.bind.key && (!x.bind.data || x.bind.data.length == 0)) {
@@ -480,6 +489,13 @@ export default {
480489
// this.$emit
481490
this.defaultLoadPage && this.load();
482491
},
492+
computed: {
493+
filterColumns () {
494+
return this.columns.filter((x) => {
495+
return !x.hidden;
496+
});
497+
},
498+
},
483499
methods: {
484500
headerClick (column, event) {
485501
if (this.clickEdit && this.edit.rowIndex != -1) {
@@ -945,10 +961,15 @@ export default {
945961
getSummaries (data) {
946962
if (!this.summary || !data.summary) return;
947963
this.summaryData.splice(0);
964+
//开启了行号的,+1
965+
if (this.columnIndex) {
966+
this.summaryData.push("");
967+
}
948968
//如果有checkbox,应该算作是第一行
949969
if (this.ck) {
950-
this.summaryData.push(0);
970+
this.summaryData.push("");
951971
}
972+
952973
this.columns.forEach((col) => {
953974
if (!col.hidden) {
954975
if (data.summary.hasOwnProperty(col.field)) {
@@ -963,11 +984,6 @@ export default {
963984
}
964985
},
965986
getInputChangeSummaries () { },
966-
filterColumns () {
967-
return this.columns.filter((x) => {
968-
return !x.hidden;
969-
});
970-
},
971987
handleSizeChange (val) {
972988
this.paginations.rows = val;
973989
this.load();
@@ -1098,7 +1114,7 @@ export default {
10981114
sum += x[column.field] * 1;
10991115
}
11001116
});
1101-
this.$set(this.summaryData, this.summaryIndex[column.field] - 1, sum);
1117+
this.$set(this.summaryData, this.summaryIndex[column.field], sum);
11021118
},
11031119
},
11041120
};

开发版dev/Vue.NetCore/Vol.Vue/src/components/basic/ViewGrid.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686
<span>{{table.cnName}}</span>
8787
</div>
8888
<div class="notice">
89-
<!-- <Tooltip content="6666666666666666" placement="bottom">
90-
<a>Bottom Center</a>
91-
</Tooltip>-->
9289
<a class="text"
9390
:title="extend.text">{{extend.text}}</a>
9491
</div>
@@ -195,7 +192,9 @@
195192
:endEditBefore="detailOptions.endEditBefore"
196193
:endEditAfter="detailOptions.endEditAfter"
197194
:summary="detailOptions.summary"
198-
:click-edit="detailOptions.clickEdit"></vol-table>
195+
:click-edit="detailOptions.clickEdit"
196+
:column-index="detailOptions.columnIndex"
197+
:ck="detailOptions.ck"></vol-table>
199198
</div>
200199
<!--明细footer自定义组件-->
201200
<modelFooter ref="modelFooter"
@@ -239,7 +238,9 @@
239238
:pagination-hide="false"
240239
:url="url"
241240
:defaultLoadPage="load"
242-
:summary="summary"></vol-table>
241+
:summary="summary"
242+
:column-index="columnIndex"
243+
:ck="ck"></vol-table>
243244
</div>
244245
</div>
245246

@@ -344,6 +345,8 @@ var vueParam = {
344345
//需要从远程绑定数据源的字典编号,如果字典数据源的查询结果较多,请在onInit中将字典编号添加进来
345346
//只对自定sql有效
346347
remoteKeys: [],
348+
columnIndex: false,//2020.11.01是否显示行号
349+
ck: true,//2020.11.01是否显示checkbox
347350
// detailUrl: "",
348351
detailOptions: {
349352
//弹出框从表(明细)对象
@@ -375,6 +378,8 @@ var vueParam = {
375378
endEditAfter: (row, column, index) => {
376379
return true;
377380
},
381+
columnIndex: false,//2020.11.01明细是否显示行号
382+
ck: true,//2020.11.01明细是否显示checkbox
378383
},
379384
auditParam: {
380385
//审核对象

开发版dev/Vue.NetCore/Vol.Vue/src/components/basic/VolTable.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
border
3030
:row-class-name="initIndex"
3131
style="width: 100%">
32+
<el-table-column v-if="columnIndex"
33+
type="index"
34+
width="55"></el-table-column>
3235
<el-table-column v-if="ck"
3336
type="selection"
3437
width="55"></el-table-column>
3538
<!-- 2020.10.10移除table第一行强制排序 -->
36-
<el-table-column v-for="(column, cindex) in filterColumns()"
39+
<el-table-column v-for="(column, cindex) in filterColumns"
3740
:key="cindex"
3841
:prop="column.field"
3942
:label="column.title"
@@ -350,6 +353,11 @@ export default {
350353
type: Boolean,
351354
default: true,
352355
},
356+
columnIndex: {
357+
//是否显示行号(2020..11.1)
358+
type: Boolean,
359+
default: true,
360+
}
353361
},
354362
data () {
355363
return {
@@ -414,17 +422,18 @@ export default {
414422
let keys = [];
415423
let columnBind = [];
416424
this.summaryData.push("合计");
425+
if (this.columnIndex) {
426+
this.summaryData.push(" ");
427+
}
417428
this.columns.forEach((x, _index) => {
418429
if (!x.hidden) {
419430
//this.summaryIndex[x.field] = _index;
420431
//2020.10.11修复求和列错位的问题
421432
this.summaryData.push("");
422-
this.summaryIndex[x.field] = this.summaryData.length;
433+
this.summaryIndex[x.field] = this.summaryData.length - 1;
423434
}
424435
//求和
425436
if (x.summary && !this.summary) {
426-
//强制开启选择框
427-
this.ck = true;
428437
this.summary = true;
429438
}
430439
if (x.bind && x.bind.key && (!x.bind.data || x.bind.data.length == 0)) {
@@ -480,6 +489,13 @@ export default {
480489
// this.$emit
481490
this.defaultLoadPage && this.load();
482491
},
492+
computed: {
493+
filterColumns () {
494+
return this.columns.filter((x) => {
495+
return !x.hidden;
496+
});
497+
},
498+
},
483499
methods: {
484500
headerClick (column, event) {
485501
if (this.clickEdit && this.edit.rowIndex != -1) {
@@ -945,10 +961,15 @@ export default {
945961
getSummaries (data) {
946962
if (!this.summary || !data.summary) return;
947963
this.summaryData.splice(0);
964+
//开启了行号的,+1
965+
if (this.columnIndex) {
966+
this.summaryData.push("");
967+
}
948968
//如果有checkbox,应该算作是第一行
949969
if (this.ck) {
950-
this.summaryData.push(0);
970+
this.summaryData.push("");
951971
}
972+
952973
this.columns.forEach((col) => {
953974
if (!col.hidden) {
954975
if (data.summary.hasOwnProperty(col.field)) {
@@ -963,11 +984,6 @@ export default {
963984
}
964985
},
965986
getInputChangeSummaries () { },
966-
filterColumns () {
967-
return this.columns.filter((x) => {
968-
return !x.hidden;
969-
});
970-
},
971987
handleSizeChange (val) {
972988
this.paginations.rows = val;
973989
this.load();
@@ -1098,7 +1114,7 @@ export default {
10981114
sum += x[column.field] * 1;
10991115
}
11001116
});
1101-
this.$set(this.summaryData, this.summaryIndex[column.field] - 1, sum);
1117+
this.$set(this.summaryData, this.summaryIndex[column.field], sum);
11021118
},
11031119
},
11041120
};

0 commit comments

Comments
 (0)