This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/mixin/table.js

119 lines
2.7 KiB
JavaScript
Raw Normal View History

export default {
props: {
tableData: {
type: Array
},
customTableTitle: {
type: Array
},
height: {
type: String,
default: '100%'
},
api: {
type: String
},
tableId: {
type: String
},
orderByFa: {}
},
data () {
return {
operationWidth: '165', // 操作列宽
orderBy: {}
}
},
methods: {
tableOperation ([command, row, param]) {
switch (command) {
case 'delete': {
this.$emit('del', row)
break
}
case 'recordTab': {
this.$emit('showBottomBox', 'recordTab', row)
2021-04-13 20:33:12 +08:00
break
}
2021-05-19 23:17:24 +08:00
case 'endpointQuery': {
this.$emit('showBottomBox', 'endpointQuery', row)
break
}
case 'sync': {
// this.$emit('copy', row)
this.$emit('sync', row)
break
}
case 'fastSilence': {
// this.$emit('copy', row)
this.$emit('addSilence', row, param)
break
}
default:
2021-05-19 23:17:24 +08:00
this.$emit(command, row)
break
}
},
2021-04-13 10:00:48 +08:00
selectionChange (objs) {
this.$emit('selectionChange', objs)
},
isBuiltIn (row) {
return (row.buildIn && row.buildIn == 1) || (row.builtIn && row.builtIn == 1)
},
dragend () {
this.$nextTick(() => {
this.$refs.dataTable.doLayout()
})
},
showBottomBox (targetTab, row) {
this.$emit('showBottomBox', targetTab, JSON.parse(JSON.stringify(row)))
},
tableDataSort (item) {
let orderBy = ''
let str = item.prop
if (str === 'dc') {
str = 'datacenter'
}
if (item.order === 'ascending') {
orderBy = str
}
if (item.order === 'descending') {
orderBy = '-' + str
}
this.$emit('orderBy', orderBy)
}
},
watch: {
orderByFa: {
immediate: true,
handler (n) {
if (n) {
const index = n.indexOf('-')
if (index !== -1) {
this.orderBy[n.slice(index + 1)] = 'descending'
} else {
this.orderBy[n] = 'descending'
}
}
}
2022-01-17 16:32:00 +08:00
},
tableData: {
immediate: true,
handler (n) {
if (n && n.length) {
const id = this.$store.getters.getGlobalSearchId
if (id) {
setTimeout(() => {
if (document.getElementById('globalSearch' + id)) {
document.getElementById('globalSearch' + id).scrollIntoView(true)
this.$store.commit('setGlobalSearchId', '')
}
}, 500)
}
}
}
}
2022-01-17 16:32:00 +08:00
// document.querySelector("#header").scrollIntoView(true);
}
}