| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions"
- :export-data-options="exportDataOptions" />
- </template>
- <script>
- import ColumnsMixin from '../mixins/columns'
- import SingleActionsMixin from '../mixins/singleActions'
- import { NOTIFY_SUBSCRIBER_TYPES_MAP } from '../../../constants'
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import { getEnabledFilter } from '@/utils/common/tableFilter'
- import { getEnabledSwitchActions } from '@/utils/common/tableActions'
- export default {
- name: 'NotifySubscriberList',
- mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
- props: {
- id: {
- type: String,
- },
- resId: {
- type: String,
- },
- getParams: {
- type: Object,
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'subscribers',
- apiVersion: 'v1',
- getParams: this.getParam,
- filterOptions: {
- resource_scope: {
- label: this.$t('system.notify.topic.receiver.resource_scope'),
- dropdown: true,
- distinctField: {
- type: 'extra_field',
- key: 'resource_scope',
- },
- },
- enabled: getEnabledFilter(),
- type: {
- label: this.$t('system.text_48'),
- filter: true,
- dropdown: true,
- distinctField: {
- type: 'field',
- key: 'type',
- getParams: this.getParam,
- },
- formatter: val => {
- return `type.contains("${val}")`
- },
- mapper: list => {
- return list.map(({ key, label }) => {
- return {
- key,
- label: NOTIFY_SUBSCRIBER_TYPES_MAP[key] ? NOTIFY_SUBSCRIBER_TYPES_MAP[key].label : label,
- }
- })
- },
- },
- },
- }),
- groupActions: [
- // 新建
- {
- label: this.$t('system.text_128'),
- permission: 'subscribers_create',
- action: () => {
- this.createDialog('SetupNotifyReceiverDialog', {
- resId: this.resId,
- columns: this.columns,
- success: (res) => {
- this.list.fetchData()
- },
- })
- },
- meta: () => {
- return {
- buttonType: 'primary',
- }
- },
- },
- {
- label: this.$t('common.batchAction'),
- actions: obj => {
- return [
- // 启用禁用
- ...getEnabledSwitchActions(this, undefined, undefined, {
- resourceName: this.$t('system.notify.subscriber.receivers'),
- fields: ['resource_scope', 'enabled', 'type', 'receivers'],
- actions: [
- async (obj) => {
- const ids = this.list.selectedItems.map(item => item.id)
- await this.onManager('batchPerformAction', {
- id: ids,
- managerArgs: {
- action: 'enable',
- },
- })
- },
- async (obj) => {
- const ids = this.list.selectedItems.map(item => item.id)
- await this.onManager('batchPerformAction', {
- id: ids,
- managerArgs: {
- action: 'disable',
- },
- })
- },
- ],
- }),
- // 删除
- {
- label: this.$t('system.text_129'),
- permission: 'subscribers_delete',
- fields: ['resource_scope', 'enabled', 'type', 'receivers'],
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- fields: ['resource_scope', 'enabled', 'type', 'receivers'],
- title: this.$t('common.delete'),
- name: this.$t('system.notify.subscriber.receivers'),
- onManager: this.onManager,
- })
- },
- meta: () => this.$getDeleteResult(this.list.selectedItems),
- },
- ]
- },
- meta: () => {
- let validate = true
- if (this.list.selectedItems.length <= 0) {
- validate = false
- }
- return { validate }
- },
- },
- ],
- }
- },
- computed: {
- exportDataOptions () {
- return {
- title: this.$t('system.notify.topic.receiver.management'),
- downloadType: 'local',
- items: this.columns,
- }
- },
- },
- created () {
- this.list.fetchData()
- },
- methods: {
- getParam () {
- const ret = {
- ...this.getParams,
- topic_id: this.resId,
- details: true,
- }
- return ret
- },
- },
- }
- </script>
- <style scoped>
- </style>
|