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
cyber-narrator-cn-ui/src/mixins/table.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

import { chartTableOrderOptionsMapping } from '@/utils/constants'
2021-06-11 10:00:22 +08:00
export default {
props: {
tableData: {
type: Array
},
customTableTitle: {
type: Array
},
height: {
type: String,
default: '100%'
},
api: {
type: String
},
tableId: {
type: String
}
},
2021-06-23 15:57:34 +08:00
computed: {
customTableTitles () {
return this.customTableTitle.filter(item => item.show)
}
},
watch: {
customTableTitle (n) {
if (n) {
setTimeout(() => {
this.$refs.dataTable.doLayout()
}, 200)
2021-06-23 15:57:34 +08:00
}
}
},
2021-06-11 10:00:22 +08:00
data () {
return {
2021-06-23 15:57:34 +08:00
operationWidth: '165', // 操作列宽
show: true
2021-06-11 10:00:22 +08:00
}
},
methods: {
2022-06-06 17:37:01 +08:00
tableOperation ([command, row]) {
2021-06-11 10:00:22 +08:00
switch (command) {
default:
2022-06-06 17:37:01 +08:00
this.$emit(command, row)
2021-06-11 10:00:22 +08:00
break
}
},
selectionChange (objs) {
this.$emit('selectionChange', objs)
},
dragend () {
this.$nextTick(() => {
this.$refs.dataTable.doLayout()
})
},
tableDataSort (item) {
/*let orderBy = ''
2021-06-11 10:00:22 +08:00
if (item.order === 'ascending') {
2022-06-24 09:25:15 +08:00
if (item.prop === 'lastTime') {
orderBy = chartTableOrderOptionsMapping[item.prop]
} else {
orderBy = item.prop
}
orderBy = chartTableOrderOptionsMapping[item.prop] || item.prop
2021-06-11 10:00:22 +08:00
}
if (item.order === 'descending') {
2022-06-24 09:25:15 +08:00
if (item.prop === 'lastTime') {
orderBy = '-' + chartTableOrderOptionsMapping[item.prop]
} else {
orderBy = '-' + item.prop
}
}*/
const orderBy = (item.order === 'descending' ? '-' : '') + (chartTableOrderOptionsMapping[item.prop] || item.prop)
2021-06-11 10:00:22 +08:00
this.$emit('orderBy', orderBy)
}
}
}