perf: 优化创建storage,使用新的通用组件

perf: 优化工单创建使用新的组件
This commit is contained in:
ibuler 2021-03-16 14:18:27 +08:00 committed by Orange
parent 324db2fdae
commit 6fc8a43e34
7 changed files with 71 additions and 97 deletions

View File

@ -63,13 +63,17 @@ export default {
moreCreates: { moreCreates: {
type: Object, type: Object,
default: null default: null
},
createTitle: {
type: String,
default: () => this.$t('common.Create')
} }
}, },
data() { data() {
const defaultActions = [ const defaultActions = [
{ {
name: 'actionCreate', name: 'actionCreate',
title: this.$t('common.Create'), title: this.createTitle,
type: 'primary', type: 'primary',
has: this.hasCreate && !this.moreCreates, has: this.hasCreate && !this.moreCreates,
can: this.canCreate, can: this.canCreate,
@ -79,7 +83,7 @@ export default {
if (this.moreCreates) { if (this.moreCreates) {
const defaultMoreCreate = { const defaultMoreCreate = {
name: 'actionMoreCreate', name: 'actionMoreCreate',
title: this.$t('common.Create'), title: this.createTitle,
type: 'primary', type: 'primary',
has: true, has: true,
can: this.canCreate, can: this.canCreate,

View File

@ -93,8 +93,6 @@ export default {
hasCreate: false, hasCreate: false,
hasMoreActions: false, hasMoreActions: false,
hasBulkDelete: false, hasBulkDelete: false,
// createRoute: 'RemoteAppCreate',
moreActionsTitle: this.$t('common.Create'),
moreActionsType: 'primary', moreActionsType: 'primary',
moreCreates: { moreCreates: {
callback: (option) => { callback: (option) => {

View File

@ -22,19 +22,18 @@ export default {
hasExport: false, hasExport: false,
hasImport: false, hasImport: false,
hasRefresh: false, hasRefresh: false,
hasBulkDelete: false, hasMoreActions: false,
hasBulkUpdate: false, moreCreates: {
hasCreate: false, callback: (item) => {
extraMoreActions: [ this.$router.push({ name: 'CreateCommandStorage', query: { type: item.name }})
},
dropdown: [
{ {
name: 'Elasticsearch', name: 'es',
title: 'Elasticsearch', title: 'Elasticsearch'
type: 'primary', }
callback: this.createEs.bind(this) ]
} }
],
moreActionsTitle: this.$t('common.Create'),
moreActionsType: 'primary'
}, },
commandTableConfig: { commandTableConfig: {
title: 'command', title: 'command',

View File

@ -15,48 +15,34 @@ export default {
hasExport: false, hasExport: false,
hasImport: false, hasImport: false,
hasRefresh: false, hasRefresh: false,
hasBulkDelete: false, hasMoreActions: false,
hasCreate: false, moreCreates: {
moreActionsTitle: this.$t('common.Create'), callback: (item) => {
moreActionsType: 'primary', this.$router.push({ name: 'CreateReplayStorage', query: { type: item.name.toLowerCase() }})
extraMoreActions: [ },
dropdown: [
{ {
name: 'S3', name: 'S3',
title: 'S3', title: 'S3'
type: 'primary',
can: true,
callback: this.createS3.bind(this)
}, },
{ {
name: 'Ceph', name: 'Ceph',
title: 'Ceph', title: 'Ceph'
type: 'primary',
can: true,
callback: this.createCeph.bind(this)
}, },
{ {
name: 'Swift', name: 'swift',
title: 'Swift', title: 'Swift'
type: 'primary',
can: true,
callback: this.createSwift.bind(this)
}, },
{ {
name: 'OSS', name: 'OSS',
title: 'OSS', title: 'OSS'
type: 'primary',
can: true,
callback: this.createOSS.bind(this)
}, },
{ {
name: 'Azure', name: 'Azure',
title: 'Azure', title: 'Azure'
type: 'primary',
can: true,
callback: this.createAzure.bind(this)
} }
] ]
}
}, },
replayTableConfig: { replayTableConfig: {
url: '/api/v1/terminal/replay-storages/', url: '/api/v1/terminal/replay-storages/',
@ -110,21 +96,6 @@ export default {
} }
}, },
methods: { methods: {
createS3() {
this.$router.push({ name: 'CreateReplayStorage', query: { type: 's3' }})
},
createCeph() {
this.$router.push({ name: 'CreateReplayStorage', query: { type: 'ceph' }})
},
createSwift() {
this.$router.push({ name: 'CreateReplayStorage', query: { type: 'swift' }})
},
createOSS() {
this.$router.push({ name: 'CreateReplayStorage', query: { type: 'oss' }})
},
createAzure() {
this.$router.push({ name: 'CreateReplayStorage', query: { type: 'azure' }})
}
} }
} }
</script> </script>

View File

@ -138,7 +138,9 @@ export default {
component: Select2, component: Select2,
el: { el: {
multiple: false, multiple: false,
options: this.$store.state.users.profile.user_all_orgs options: this.$store.state.users.profile.user_all_orgs.map((item) => {
return { label: item.name, value: item.id }
})
}, },
on: { on: {
changeOptions: ([event], updateForm) => { changeOptions: ([event], updateForm) => {

View File

@ -42,7 +42,10 @@ export default {
} }
}, },
meta: { meta: {
fields: ['apply_ip_group', 'apply_hostname_group', 'apply_system_user_group', 'apply_actions', 'apply_date_start', 'apply_date_expired'], fields: [
'apply_ip_group', 'apply_hostname_group', 'apply_system_user_group',
'apply_actions', 'apply_date_start', 'apply_date_expired'
],
fieldsMeta: { fieldsMeta: {
apply_actions: { apply_actions: {
label: this.$t('perms.Actions'), label: this.$t('perms.Actions'),
@ -64,7 +67,9 @@ export default {
component: Select2, component: Select2,
el: { el: {
multiple: false, multiple: false,
options: this.$store.state.users.profile.user_all_orgs options: this.$store.state.users.profile.user_all_orgs.map((item) => {
return { label: item.name, value: item.id }
})
}, },
on: { on: {
changeOptions: ([event], updateForm) => { changeOptions: ([event], updateForm) => {

View File

@ -112,33 +112,28 @@ export default {
} }
} }
}, },
moreActionsTitle: this.$t('common.RequestTickets'), createTitle: this.$t('common.RequestTickets'),
moreActionsType: 'primary', hasMoreActions: false,
extraMoreActions: this.genExtraMoreActions() moreCreates: {
} dropdown: [
}
},
methods: {
genExtraMoreActions() {
return [
{ {
name: 'RequestAssetPerm', name: 'RequestAssetPerm',
title: this.$t('tickets.RequestAssetPerm'), title: this.$t('tickets.RequestAssetPerm'),
type: 'primary',
can: true,
callback: () => this.$router.push({ name: 'RequestAssetPermTicketCreateUpdate' }) callback: () => this.$router.push({ name: 'RequestAssetPermTicketCreateUpdate' })
}, },
{ {
name: 'RequestApplicationPerm', name: 'RequestApplicationPerm',
title: this.$t('tickets.RequestApplicationPerm'), title: this.$t('tickets.RequestApplicationPerm'),
type: 'primary',
can: true,
callback: () => this.$router.push({ name: 'RequestApplicationPermTicketCreateUpdate' }) callback: () => this.$router.push({ name: 'RequestApplicationPermTicketCreateUpdate' })
} }
] ]
} }
} }
} }
},
methods: {
}
}
</script> </script>
<style scoped> <style scoped>