修改列表的操作按钮

This commit is contained in:
qq787203167
2022-02-25 15:13:00 +08:00
parent 58761dd2ea
commit 59aaf52dda
2 changed files with 17 additions and 7 deletions
+16 -6
View File
@@ -27,7 +27,7 @@
</a> </a>
</span> </span>
<span slot="detailClick" slot-scope="text,record"> <span slot="detailClick" slot-scope="text,record">
<a class="text" @click="detailClick(record)">{{text}}</a> <a class="text" :title="text" @click="detailClick(record)">{{text}}</a>
</span> </span>
</a-table> </a-table>
</div> </div>
@@ -110,6 +110,14 @@
this.getTableList() this.getTableList()
}, },
methods: { methods: {
getTextWith(text, fontStyle) {
var canvas = document.createElement('canvas')
var context = canvas.getContext('2d')
context.font = fontStyle || '14px' // 设置字体样式
var dimension = context.measureText(text)
return dimension.width + 40
},
getData() { getData() {
let params = { let params = {
flag: this.flag flag: this.flag
@@ -134,10 +142,12 @@
}) })
let width = 0 let width = 0
if (this.OperationList.length > 0) { if (this.OperationList.length > 0) {
this.OperationList.forEach((res) => { for (let i = 0; i < this.OperationList.length; i++) {
width += res.text.length * 5 + width console.log(width)
}) width += this.getTextWith(this.OperationList[i].text)
}
} }
console.log(width)
if (this.showAction) { if (this.showAction) {
this.columns.push({ this.columns.push({
title: this.$t('operation'), title: this.$t('operation'),
@@ -171,7 +181,7 @@
this.dataSource = res.result.records this.dataSource = res.result.records
this.total = res.result.total this.total = res.result.total
this.loading = false this.loading = false
}else{ } else {
this.loading = false this.loading = false
} }
}) })
@@ -192,7 +202,7 @@
this.$emit(ol.ClickEvent, item) this.$emit(ol.ClickEvent, item)
}, },
detailClick(item, index) { detailClick(item, index) {
this.$emit('detailClick',item) this.$emit('detailClick', item)
} }
} }
} }
@@ -103,7 +103,7 @@
{ {
text: '删除', text: '删除',
ClickEvent: 'deleteTable' ClickEvent: 'deleteTable'
} },
], ],
selectedRowKeys: [], selectedRowKeys: [],
loading: false, loading: false,