perf: add update actions and detail formatters to various components

This commit is contained in:
w940853815 2025-02-19 15:33:55 +08:00 committed by w940853815
parent 2558cfa4c2
commit d5099c3a04
6 changed files with 35 additions and 22 deletions

View File

@ -88,6 +88,9 @@ export default {
if (!actions.onCreate) { if (!actions.onCreate) {
actions.onCreate = this.onCreate actions.onCreate = this.onCreate
} }
if (!actions.onUpdate) {
actions.onUpdate = this.onUpdate
}
return actions return actions
}, },
iTableConfig() { iTableConfig() {

View File

@ -9,6 +9,7 @@
import { GenericListPage } from '@/layout/components' import { GenericListPage } from '@/layout/components'
import { openTaskPage } from '@/utils/jms' import { openTaskPage } from '@/utils/jms'
import ExecutionDetailDialog from '@/views/ops/Execution/ExecutionDetail' import ExecutionDetailDialog from '@/views/ops/Execution/ExecutionDetail'
import detailFormatter from '@/components/Table/TableFormatters/DetailFormatter.vue'
export default { export default {
components: { components: {
@ -34,8 +35,10 @@ export default {
}, },
columnsMeta: { columnsMeta: {
id: { id: {
formatter(row) { formatter: detailFormatter,
return row.id.slice(0, 8) formatterArgs: {
drawer: true,
route: 'ExecutionDetail'
} }
}, },
job: { job: {
@ -77,15 +80,6 @@ export default {
hasDelete: false, hasDelete: false,
hasClone: false, hasClone: false,
extraActions: [ extraActions: [
{
title: this.$t('Detail'),
name: 'detail',
type: 'primary',
can: true,
callback: ({ row }) => {
this.$router.push({ name: 'ExecutionDetail', params: { id: row.id }})
}
},
{ {
title: this.$t('Output'), title: this.$t('Output'),
name: 'logging', name: 'logging',

View File

@ -121,6 +121,12 @@ export default {
}) })
vm.$refs.ListTable.onCreate() vm.$refs.ListTable.onCreate()
}, },
onUpdate: () => {
vm.$router.push({
query: { _type: 'adhoc' }
})
vm.$refs.ListTable.onUpdate()
},
hasRefresh: true, hasRefresh: true,
hasExport: false, hasExport: false,
hasImport: false hasImport: false

View File

@ -126,6 +126,12 @@ export default {
vm.$refs.ListTable.onCreate() vm.$refs.ListTable.onCreate()
} }
}, },
onUpdate: () => {
vm.$router.push({
query: { _type: 'playbook' }
})
vm.$refs.ListTable.onUpdate()
},
showJobRunDialog: false showJobRunDialog: false
} }
}, },

View File

@ -82,8 +82,7 @@ export default {
session: { session: {
formatter: DetailFormatter, formatter: DetailFormatter,
formatterArgs: { formatterArgs: {
openInNewPage: true, drawer: true,
removeColorOnClick: true,
can: this.$hasPerm('terminal.view_session'), can: this.$hasPerm('terminal.view_session'),
getTitle() { getTitle() {
return vm.$t('Goto') return vm.$t('Goto')

View File

@ -10,6 +10,7 @@
<script> <script>
import GenericListPage from '@/layout/components/GenericListPage' import GenericListPage from '@/layout/components/GenericListPage'
import { DetailFormatter } from '@/components/Table/TableFormatters'
export default { export default {
components: { components: {
@ -47,15 +48,19 @@ export default {
}, },
user_display: { user_display: {
label: this.$t('User'), label: this.$t('User'),
formatter: function(row) { formatter: DetailFormatter,
const to = { formatterArgs: {
name: 'UserDetail', drawer: true,
params: { id: row.user.id } can: this.$hasPerm('users.view_user'),
} getTitle: ({ row }) => { return row.user.name },
if (vm.$hasPerm('users.view_user')) { getDrawerTitle({ row }) { return row.user.name },
return <router-link to={to}>{row.user.name}</router-link> getRoute: ({ row }) => {
} else { return {
return <span>{row.user.name}</span> name: 'UserDetail',
params: {
id: row.user.id
}
}
} }
} }
}, },