| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import { mapGetters } from 'vuex'
- import { disableDeleteAction } from '@/utils/common/tableActions'
- import i18n from '@/locales'
- import { checkReadOnly } from '../utils'
- export default {
- created () {
- this.singleActions = [
- {
- label: i18n.t('network.text_201'),
- permission: 'natgateways_perform_syncstatus',
- action: obj => {
- this.onManager('performAction', {
- steadyStatus: ['available'],
- id: obj.id,
- managerArgs: {
- action: 'syncstatus',
- },
- })
- },
- meta: (obj) => {
- // const ret = checkReadOnly(obj, i18n.t('network.text_201'))
- // if (!ret.validate) return ret
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return {
- validate: true,
- }
- },
- },
- {
- label: i18n.t('network.text_129'),
- actions: (obj) => {
- const { status } = obj
- const isAvailable = status.toLowerCase() === 'available'
- const notAvailableTip = !isAvailable ? i18n.t('network.instance.not.available.tooltip') : null
- return [
- {
- label: i18n.t('network.expired_release'),
- permission: 'natgateways_perform_postpaid_expire',
- action: () => {
- this.createDialog('SetDurationDialog', {
- data: [obj],
- alert: this.$t('network.text_764'),
- columns: this.columns,
- onManager: this.onManager,
- name: this.$t('dictionary.nat'),
- refresh: this.refresh,
- })
- },
- meta: () => {
- const ret = checkReadOnly(obj, i18n.t('network.expired_release'))
- if (!ret.validate) return ret
- if (obj.billing_type === 'prepaid') {
- ret.validate = false
- ret.tooltip = i18n.t('network.nat.prepaid.unsupported')
- return ret
- }
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return ret
- },
- },
- {
- label: i18n.t('network.renew'),
- permission: 'natgateways_perform_renew',
- action: () => {
- this.createDialog('RenewDialog', {
- name: this.$t('dictionary.nat'),
- data: [obj],
- alert: this.$t('network.text_765'),
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const ret = checkReadOnly(obj, i18n.t('network.renew'))
- if (!ret.validate) return ret
- if (obj.billing_type === 'postpaid') {
- ret.validate = false
- ret.tooltip = i18n.t('network.nat.postpaid.unsupported')
- return ret
- }
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return ret
- },
- },
- {
- label: i18n.t('network.auto.renew'),
- permission: 'natgateways_perform_set_auto_renew',
- action: () => {
- this.createDialog('AutoRenewDialog', {
- name: i18n.t('dictionary.nat'),
- data: [obj],
- alert: this.$t('network.text_766'),
- columns: this.columns,
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- const isPrepaid = obj.billing_type === 'prepaid'
- const validate = (isAvailable && isPrepaid)
- const ret = checkReadOnly(obj, i18n.t('network.auto.renew'))
- if (!ret.validate) return ret
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return {
- validate: validate,
- tooltip: notAvailableTip || (!isPrepaid ? i18n.t('network.nat.postpaid.unsupported') : null),
- }
- },
- },
- disableDeleteAction(this, {
- name: this.$t('dictionary.nat'),
- permission: 'natgateways_update',
- hidden: () => {
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- },
- }),
- {
- label: i18n.t('network.text_131'),
- permission: 'natgateways_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- title: i18n.t('network.text_131'),
- name: this.$t('dictionary.nat'),
- data: [obj],
- columns: this.columns,
- onManager: this.onManager,
- requestData: { force: true },
- refresh: this.refresh,
- })
- },
- meta: () => {
- const ret = checkReadOnly(obj, i18n.t('network.text_131'))
- if (!ret.validate) return ret
- if (!this.isOwner(obj)) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return this.$getDeleteResult(obj)
- },
- },
- ]
- },
- },
- ]
- },
- computed: {
- ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
- },
- methods: {
- isOwner (obj) {
- if (this.isAdminMode) return true
- if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
- return false
- },
- },
- }
|