| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions"
- :export-data-options="exportDataOptions" />
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { NOTIFY_TOPIC_TYPES_MAP } from '@IAM/constants'
- import ColumnsMixin from '../mixins/columns'
- import SingleActionsMixin from '../mixins/singleActions'
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import { getEnabledFilter } from '@/utils/common/tableFilter'
- export default {
- name: 'NotifyTopicList',
- mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
- props: {
- id: String,
- getParams: {
- type: Object,
- default: () => {},
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'topics',
- apiVersion: 'v1',
- getParams: this.getParam,
- filterOptions: {
- 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_TOPIC_TYPES_MAP[key] ? NOTIFY_TOPIC_TYPES_MAP[key].label : label,
- }
- })
- },
- },
- enabled: getEnabledFilter(),
- },
- }),
- exportDataOptions: {
- items: [
- { label: 'ID', key: 'id' },
- { label: this.$t('system.notify.topic.name'), key: 'name' },
- { label: this.$t('system.notify.topic.type'), key: 'type' },
- { label: this.$t('system.text_163'), key: 'enabled' },
- ],
- },
- groupActions: [
- {
- label: this.$t('system.text_225'),
- permission: 'topics_perform_enable',
- action: () => {
- this.createDialog('DisableDialog', {
- title: this.$t('system.text_225'),
- name: this.$t('dictionary.notify-topic'),
- columns: this.columns,
- data: this.list.selectedItems,
- ok: async () => {
- try {
- const response = await this.list.batchPerformAction('enable', null)
- return response
- } catch (error) {
- throw error
- }
- },
- })
- },
- meta: () => {
- let validate = true
- if (this.list.selectedItems.length <= 0) {
- validate = false
- }
- if (this.list.selectedItems.some(item => item.enabled === true)) {
- validate = false
- }
- if (!this.isAdminMode) {
- validate = false
- }
- return {
- validate,
- }
- },
- },
- {
- label: this.$t('system.text_226'),
- permission: 'topics_perform_disable',
- action: () => {
- this.createDialog('DisableDialog', {
- title: this.$t('system.text_226'),
- name: this.$t('dictionary.notify-topic'),
- columns: this.columns,
- data: this.list.selectedItems,
- ok: async () => {
- try {
- const response = await this.list.batchPerformAction('disable', null)
- return response
- } catch (error) {
- throw error
- }
- },
- })
- },
- meta: () => {
- let validate = true
- if (this.list.selectedItems.length <= 0) {
- validate = false
- }
- if (this.list.selectedItems.some(item => item.enabled === false)) {
- validate = false
- }
- if (!this.isAdminMode) {
- validate = false
- }
- return {
- validate,
- }
- },
- },
- ],
- }
- },
- computed: {
- ...mapGetters(['isAdminMode']),
- },
- created () {
- this.list.fetchData()
- },
- methods: {
- getParam () {
- return {
- ...this.getParams,
- details: true,
- }
- },
- handleOpenSidepage (row) {
- this.sidePageTriggerHandle(this, 'NotifyTopicSidePage', {
- id: row.id,
- resource: 'topics',
- apiVersion: 'v1',
- getParams: this.getParam,
- }, {
- list: this.list,
- })
- },
- },
- }
- </script>
- <style scoped>
- </style>
|