2022-06-22 16:52:27 +08:00
|
|
|
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()
|
2023-03-06 20:16:31 +08:00
|
|
|
}, 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) {
|
2023-03-06 14:19:29 +08:00
|
|
|
/*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
|
|
|
|
|
}
|
2023-03-06 14:19:29 +08:00
|
|
|
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
|
|
|
|
|
}
|
2023-03-06 14:19:29 +08:00
|
|
|
}*/
|
|
|
|
|
const orderBy = (item.order === 'descending' ? '-' : '') + (chartTableOrderOptionsMapping[item.prop] || item.prop)
|
2021-06-11 10:00:22 +08:00
|
|
|
this.$emit('orderBy', orderBy)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|