perf: 优化 account tasks

This commit is contained in:
ibuler
2023-02-20 17:59:57 +08:00
parent b2cf5c3442
commit fea6155306
6 changed files with 58 additions and 49 deletions

View File

@@ -232,6 +232,16 @@ export default {
}
return col
},
addOrderingIfNeed(col) {
if (col.prop) {
const column = this.meta[col.prop] || {}
if (column.order) {
col.sortable = 'custom'
col['column-key'] = col.prop
}
}
return col
},
setDefaultFormatterIfNeed(col) {
if (!col.formatter) {
col.formatter = (row, column, cellValue) => {
@@ -247,6 +257,7 @@ export default {
}
return col
},
generateColumn(name) {
const colMeta = this.meta[name] || {}
const customMeta = this.config.columnsMeta ? this.config.columnsMeta[name] : {}
@@ -258,6 +269,7 @@ export default {
col = Object.assign(col, customMeta)
col = this.addHelpTipsIfNeed(col)
col = this.addFilterIfNeed(col)
col = this.addOrderingIfNeed(col)
return col
},
generateTotalColumns() {

View File

@@ -1,36 +0,0 @@
<template>
<el-row :gutter="20">
<el-col :md="12" :sm="24">
<TimelineCard :title="activityTitle" :url="activityUrl" />
</el-col>
</el-row>
</template>
<script>
import TimelineCard from '@/components/TimelineCard'
export default {
name: 'AssetActivity',
components: {
TimelineCard
},
props: {
object: {
type: Object,
default: () => {}
}
},
data() {
return {
activityUrl: `/api/v1/audits/activities/?resource_id=${this.object.id}`,
activityTitle: `${this.$t('common.Activity')} - ${this.$t('audits.OperateRecord')} (${this.$t('common.Last30')})`
}
},
mounted() {
}
}
</script>
<style scoped>
</style>

View File

@@ -1,10 +1,10 @@
<template>
<el-row :gutter="20">
<el-col :md="14" :sm="24">
<AutoDetailCard :url="url" :excludes="excludes" :object="object" />
<AutoDetailCard :excludes="excludes" :object="object" :url="url" />
</el-col>
<el-col :md="10" :sm="24">
<QuickActions type="primary" :actions="quickActions" />
<QuickActions :actions="quickActions" type="primary" />
</el-col>
</el-row>
</template>
@@ -78,8 +78,29 @@ export default {
callbacks: Object.freeze({
click: () => {
this.$axios.post(
`/api/v1/accounts/accounts/${this.object.id}/verify/`,
{ action: 'test' }
`/api/v1/accounts/accounts/tasks/`,
{
action: 'test',
accounts: [this.object.id]
}
).then(res => {
openTaskPage(res['task'])
})
}
})
},
{
title: this.$t('assets.PushAccount'),
attrs: {
type: 'primary',
label: this.$t('assets.Push'),
disabled: !vm.$hasPerm('accounts.create_account')
},
callbacks: Object.freeze({
click: () => {
this.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [this.object.id] }
).then(res => {
openTaskPage(res['task'])
})
@@ -124,5 +145,5 @@ export default {
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
</style>

View File

@@ -1,6 +1,6 @@
<template>
<IBox v-if="!loading">
<GenericCreateUpdateForm v-bind="$data" />
<GenericCreateUpdateForm class="form" v-bind="$data" />
</IBox>
</template>
@@ -69,5 +69,8 @@ export default {
</script>
<style scoped>
.form >>> .el-select {
width: 100%;
}
</style>

View File

@@ -1,27 +1,27 @@
<template>
<Dialog
:title="$tc('setting.SyncSetting')"
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
width="50%"
:title="$tc('setting.SyncSetting')"
top="10%"
v-bind="$attrs"
width="50%"
v-on="$listeners"
>
<GenericCreateUpdateForm
v-bind="settings"
:has-detail-in-msg="false"
v-bind="settings"
@submitSuccess="onSuccess"
/>
</Dialog>
</template>
<script>
import { GenericCreateUpdateForm } from '@/layout/components'
import { Dialog } from '@/components'
import { CronTab, Dialog } from '@/components'
import Select2 from '@/components/FormFields/Select2'
import { Required } from '@/components/DataForm/rules'
import { CronTab } from '@/components'
export default {
name: 'SyncSettingDialog',
@@ -67,6 +67,11 @@ export default {
submitMethod: () => 'patch'
}
}
},
methods: {
onSuccess() {
this.$emit('update:visible', false)
}
}
}
</script>

View File

@@ -1,5 +1,5 @@
<template>
<ListTable ref="list" :table-config="tableConfig" :header-actions="headerActions" />
<ListTable ref="list" :header-actions="headerActions" :table-config="tableConfig" />
</template>
<script type="text/jsx">
@@ -24,8 +24,12 @@ export default {
hasSelection: false,
url: `/api/v1/ops/task-executions/?task_id=${this.object.id}`,
columns: [
'id', 'is_finished', 'is_success', 'time_cost', 'date_start', 'actions'
'id', 'is_finished', 'is_success', 'time_cost', 'date_start',
'date_published', 'date_finished', 'actions'
],
columnsShow: {
default: ['id', 'is_finished', 'is_success', 'time_cost', 'date_start', 'actions']
},
columnsMeta: {
is_finished: {
label: this.$t('ops.isFinished'),