From b2da61186d3ddfce2be7ebd58b9a44074b32b24f Mon Sep 17 00:00:00 2001 From: dwqs <461147874@qq.com> Date: Wed, 7 Mar 2018 18:20:29 +0800 Subject: [PATCH] feat: Seperate checkbox-list from table --- src/components/checkbox-list.vue | 120 +++++++++++++++++++++++++++++++ src/components/checkbox.vue | 18 ++--- src/components/table-column.vue | 5 +- src/components/table-header.vue | 6 +- src/components/table.vue | 89 ++++++++++++++--------- 5 files changed, 193 insertions(+), 45 deletions(-) create mode 100644 src/components/checkbox-list.vue diff --git a/src/components/checkbox-list.vue b/src/components/checkbox-list.vue new file mode 100644 index 0000000..e0ad208 --- /dev/null +++ b/src/components/checkbox-list.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/src/components/checkbox.vue b/src/components/checkbox.vue index 8782b73..b7eba9d 100644 --- a/src/components/checkbox.vue +++ b/src/components/checkbox.vue @@ -38,22 +38,22 @@ return this.table.isAll; } - if (this.table.uniqueField) { - return this.table.selectedIndex.includes(this.curRow[this.table.uniqueField]); - } + // if (this.table.uniqueField) { + // return this.table.selectedIndex.includes(this.curRow[this.table.uniqueField]); + // } - return this.table.selectedIndex.includes(curRowIndex); + return this.table.selectedIndex.includes(this.curRowIndex); }, handleChange (e) { if (this.curRowIndex === -1) { this.table.eventBus.$emit('row-select-all', this.val); } else { - let rowIndex = this.curRowIndex; - if (this.table.uniqueField) { - rowIndex = this.curRow[this.table.uniqueField]; - } - this.table.eventBus.$emit('row-select', this.val, rowIndex); + // let rowIndex = this.curRowIndex; + // if (this.table.uniqueField) { + // rowIndex = this.curRow[this.table.uniqueField]; + // } + this.table.eventBus.$emit('row-select', this.val, this.curRowIndex); } } } diff --git a/src/components/table-column.vue b/src/components/table-column.vue index 621181f..2b6050a 100644 --- a/src/components/table-column.vue +++ b/src/components/table-column.vue @@ -10,7 +10,10 @@ props: { label: String, prop: String, - width: [Number, String], + width: { + type: [Number, String], + default: 90 + }, type: String, sortable: { type: Boolean, diff --git a/src/components/table-header.vue b/src/components/table-header.vue index acc771a..b4e59a1 100644 --- a/src/components/table-header.vue +++ b/src/components/table-header.vue @@ -55,10 +55,10 @@ getColStyle (col) { const style = {}; + + style.width = !isNaN(parseInt(col.width)) ? '90px' : `${parseInt(col.width, 10)}px`; + style.height = !isNaN(parseInt(this.table.colHeight, 10)) ? '40px' : `${parseInt(this.table.colHeight, 10)}px`; - if (typeof col.width !== undefined && !isNaN(parseInt(col.width))) { - style.width = `${parseInt(col.width, 10)}px`; - } // style.textAlign = ['left', 'center', 'right'].indexOf(col.align) > -1 ? col.align : 'center'; return style; diff --git a/src/components/table.vue b/src/components/table.vue index 26685d0..9ed1645 100644 --- a/src/components/table.vue +++ b/src/components/table.vue @@ -7,6 +7,12 @@ ]" ref="table">
+ + +
+ ]" v-if="leftColumns.length > 0" :style="{width: leftContainerWidth + 'px', marginLeft: selectionColumn ? selectionColumn.width + 'px' : 0}">