| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <page-list
- :list="list"
- :columns="templateListColumns || columns"
- :show-tag-columns="true"
- :show-tag-columns2="true"
- :show-tag-filter="true"
- :export-data-options="exportDataOptions"
- :group-actions="groupActions"
- :showSearchbox="showSearchbox"
- :showGroupActions="showGroupActions"
- :single-actions="singleActions"
- :show-single-actions="!isTemplate"
- :show-page="!isTemplate" />
- </template>
- <script>
- import * as R from 'ramda'
- import { mapGetters } from 'vuex'
- import ListMixin from '@/mixins/list'
- import ResTemplateListMixin from '@/mixins/resTemplateList'
- import expectStatus from '@/constants/expectStatus'
- import {
- getStatusFilter,
- getBrandFilter,
- getAccountFilter,
- getDomainFilter,
- getCloudProviderFilter,
- getDescriptionFilter,
- getCreatedAtFilter,
- getTenantFilter,
- } from '@/utils/common/tableFilter'
- import { disableDeleteAction } from '@/utils/common/tableActions'
- import WindowsMixin from '@/mixins/windows'
- import i18n from '@/locales'
- import GlobalSearchMixin from '@/mixins/globalSearch'
- import SingleActionsMixin from '../mixins/singleActions'
- import ColumnsMixin from '../mixins/columns'
- export default {
- name: 'DomainList',
- mixins: [WindowsMixin, ListMixin, GlobalSearchMixin, ColumnsMixin, SingleActionsMixin, ResTemplateListMixin],
- props: {
- id: String,
- getParams: {
- type: [Function, Object],
- },
- hiddenActions: {
- type: Array,
- default: () => ([]),
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- ctx: this,
- id: this.id,
- resource: 'cdn_domains',
- getParams: this.getParam,
- isTemplate: this.isTemplate,
- templateLimit: this.templateLimit,
- steadyStatus: Object.values(expectStatus.cdnDomain).flat(),
- filterOptions: {
- external_id: {
- label: this.$t('table.title.external_id'),
- },
- id: {
- label: this.$t('table.title.id'),
- },
- name: {
- label: this.$t('network.text_21'),
- filter: true,
- formatter: val => {
- return `name.contains("${val}")`
- },
- },
- description: getDescriptionFilter(),
- status: getStatusFilter('cdnDomain'),
- cloudaccount: getAccountFilter(),
- manager: getCloudProviderFilter(),
- brand: getBrandFilter('cdn_brands'),
- projects: getTenantFilter(),
- project_domains: getDomainFilter(),
- created_at: getCreatedAtFilter(),
- },
- responseData: this.responseData,
- hiddenColumns: ['created_at'],
- }),
- groupActions: [
- {
- label: this.$t('common.create'),
- action: () => {
- this.$router.push({
- path: '/cdn/create',
- })
- },
- meta: () => {
- return {
- buttonType: 'primary',
- validate: true,
- }
- },
- },
- {
- label: this.$t('network.text_201'),
- permission: 'cdn_domains_perform_syncstatus',
- action: () => {
- this.onManager('batchPerformAction', {
- steadyStatus: ['online', 'offline'],
- managerArgs: {
- action: 'syncstatus',
- },
- })
- },
- meta: () => {
- if (this.list.selectedItems.some(item => !this.isOwner(item))) {
- return {
- validate: false,
- tooltip: this.$t('network.text_627'),
- }
- }
- return {
- validate: this.list.selectedItems.length,
- }
- },
- },
- {
- label: this.$t('network.text_200'),
- actions: (obj) => {
- const isOwner = this.list.selectedItems.every(item => this.isOwner(item))
- return [
- {
- label: this.$t('network.text_225', [this.$t('dictionary.project')]),
- action: () => {
- this.createDialog('ChangeOwenrDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- onManager: this.onManager,
- name: this.$t('dictionary.cdn_domain'),
- resource: 'cdn_domains',
- })
- },
- meta: () => {
- return {
- validate: this.list.selectedItems.length,
- }
- },
- },
- {
- label: this.$t('compute.text_283'),
- permission: 'cdn_domains_perform_set_user_metadata',
- action: () => {
- this.createDialog('SetTagDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- onManager: this.onManager,
- params: {
- resources: 'cdn_domains',
- },
- mode: 'add',
- })
- },
- },
- disableDeleteAction(Object.assign(this, {
- permission: 'cdn_domains_update',
- }), {
- name: this.$t('dictionary.cdn_domain'),
- meta: () => {
- if (!isOwner) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- },
- }),
- {
- label: this.$t('network.text_131'),
- permission: 'cdn_domains_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('network.text_131'),
- name: this.$t('dictionary.cdn_domain'),
- requestData: { force: true },
- onManager: this.onManager,
- })
- },
- meta: () => {
- if (!isOwner) {
- return {
- validate: false,
- tooltip: i18n.t('network.text_627'),
- }
- }
- return {
- validate: this.list.allowDelete(),
- }
- },
- },
- ]
- },
- meta: () => {
- const selectedLength = this.list.selectedItems.length
- return {
- validate: selectedLength,
- tooltip: '',
- }
- },
- },
- ],
- }
- },
- computed: {
- ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo']),
- exportDataOptions () {
- return {
- items: [
- { label: 'ID', key: 'id' },
- ...this.columns,
- ],
- downloadType: 'local',
- title: this.$t('dictionary.cdn_domain'),
- }
- },
- },
- created () {
- this.initSidePageTab('cdn-detail')
- this.list.fetchData()
- },
- methods: {
- isOwner (obj) {
- if (this.isAdminMode) return true
- if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
- return false
- },
- getParam () {
- const ret = {
- ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
- detail: true,
- }
- return ret
- },
- handleOpenSidepage (row, tab) {
- this.sidePageTriggerHandle(this, 'CDNSidePage', {
- id: row.id,
- resource: 'cdn_domains',
- getParams: this.getParam,
- }, {
- list: this.list,
- tab,
- })
- },
- },
- }
- </script>
|