From 3dd0b2fd8a7643d8b4ce22f11407017f5b5f609a Mon Sep 17 00:00:00 2001 From: linxin <2981207131@qq.com> Date: Sat, 17 Aug 2019 11:47:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B0=E5=AF=8C=E8=A1=A8=E6=A0=BC=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/css/main.css | 6 +- src/components/page/BaseTable.vue | 126 +++++++++++++++--------------- 2 files changed, 67 insertions(+), 65 deletions(-) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 40bc1ac..cb71802 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -56,6 +56,10 @@ a { margin: 10px 0; } +.el-table th { + background-color: #f5f7fa !important; +} + .pagination { margin: 20px 0; text-align: right; @@ -170,4 +174,4 @@ a { .v-note-wrapper .v-note-panel { min-height: 500px; -} +} \ No newline at end of file diff --git a/src/components/page/BaseTable.vue b/src/components/page/BaseTable.vue index 6046fc9..eddf97c 100644 --- a/src/components/page/BaseTable.vue +++ b/src/components/page/BaseTable.vue @@ -27,12 +27,34 @@ border class="table" ref="multipleTable" + header-cell-class-name="table-header" @selection-change="handleSelectionChange" > - - - + + + + + + + + + + + + + + @@ -107,13 +113,12 @@ export default { select_cate: '', select_word: '', del_list: [], - is_search: false, editVisible: false, - delVisible: false, - form: { - name: '', - date: '', - address: '' + form: {}, + page: { + index: 1, + size: 10, + total: 50 }, idx: -1, id: -1 @@ -157,30 +162,32 @@ export default { this.tableData = res.list; }); }, - search() { - this.is_search = true; - }, - formatter(row, column) { - return row.address; - }, - filterTag(value, row) { - return row.tag === value; - }, + search() {}, handleEdit(index, row) { this.idx = index; this.id = row.id; - this.form = { - id: row.id, - name: row.name, - date: row.date, - address: row.address - }; + this.form = row; this.editVisible = true; }, handleDelete(index, row) { - this.idx = index; - this.id = row.id; - this.delVisible = true; + // 二次确认删除 + this.$confirm('确定要删除吗?', '提示', { + type: 'warning' + }) + .then(() => { + this.$message.success('删除成功'); + if (this.tableData[index].id === row.id) { + this.tableData.splice(index, 1); + } else { + for (let i = 0; i < this.tableData.length; i++) { + if (this.tableData[i].id === row.id) { + this.tableData.splice(i, 1); + return; + } + } + } + }) + .catch(() => {}); }, delAll() { const length = this.multipleSelection.length; @@ -209,21 +216,6 @@ export default { } } } - }, - // 确定删除 - deleteRow() { - this.$message.success('删除成功'); - this.delVisible = false; - if (this.tableData[this.idx].id === this.id) { - this.tableData.splice(this.idx, 1); - } else { - for (let i = 0; i < this.tableData.length; i++) { - if (this.tableData[i].id === this.id) { - this.tableData.splice(i, 1); - return; - } - } - } } } }; @@ -256,4 +248,10 @@ export default { .mr10 { margin-right: 10px; } +.table-td-thumb { + display: block; + margin: auto; + width: 40px; + height: 40px; +}