| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions"
- :export-data-options="exportDataOptions" />
- </template>
- <script>
- import * as R from 'ramda'
- import { mapGetters } from 'vuex'
- import { getProjectDomainFilter, getCreatedAtFilter } from '@/utils/common/tableFilter'
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import CommonMixin from '../mixins/common'
- import ColumnsMixin from '../mixins/columns'
- import SingleActionsMixin from '../mixins/singleActions'
- export default {
- name: 'ContactList',
- mixins: [CommonMixin, WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
- props: {
- id: String,
- getParams: {
- type: Object,
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'receivers',
- apiVersion: 'v1',
- getParams: this.getParam,
- filterOptions: {
- name: {
- label: this.$t('system.text_126'),
- filter: true,
- formatter: val => {
- return `name.contains(${val})`
- },
- },
- project_domains: getProjectDomainFilter(),
- created_at: getCreatedAtFilter(),
- },
- }),
- exportDataOptions: {
- items: [
- { label: 'ID', key: 'id' },
- { label: this.$t('system.text_126'), key: 'name' },
- { label: this.$t('system.text_127'), key: 'created_at' },
- { label: this.$t('system.text_131'), key: 'mobile' },
- { label: this.$t('system.text_146'), key: 'email' },
- { label: this.$t('common_599'), key: 'enabled_contact_types' },
- ],
- },
- groupActions: [
- {
- label: this.$t('system.text_128'),
- permission: 'contacts_create',
- action: () => {
- this.createDialog('ContactCreateDialog', {
- success: () => {
- this.refresh()
- },
- })
- },
- meta: () => {
- return {
- buttonType: 'primary',
- }
- },
- },
- {
- label: this.$t('system.text_166'),
- actions: () => {
- return [
- {
- label: this.$t('system.management_notify_channels'),
- permission: 'contacts_update',
- action: () => {
- this.createDialog('SetupNotifyChannelsDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- success: () => {
- this.list.refresh()
- },
- onManager: this.onManager,
- })
- },
- meta: () => {
- const ret = {
- validate: true,
- tooltip: null,
- }
- const domain = this.list.selectedItems[0] ? this.list.selectedItems[0].domain_id : ''
- if (!this.list.selectedItems.every(item => { return item.domain_id === domain })) {
- ret.validate = false
- ret.tooltip = this.$t('system.management_notify_channels.domain.tips')
- return ret
- }
- return ret
- },
- },
- {
- label: this.$t('system.text_129'),
- permission: 'contacts_delete',
- action: (obj) => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('system.text_129'),
- name: this.$t('dictionary.receiver'),
- onManager: this.onManager,
- })
- },
- meta: () => this.$getDeleteResult(this.list.selectedItems),
- },
- ]
- },
- meta: () => {
- return {
- validate: !!this.list.selectedItems.length,
- }
- },
- },
- ],
- }
- },
- computed: {
- ...mapGetters(['userInfo']),
- },
- created () {
- this.list.fetchData()
- this.initSidePageTab('contact-detail')
- this.$bus.$on('ContactListSingleRefresh', id => {
- this.list.singleRefresh(id)
- }, this)
- },
- methods: {
- getParam () {
- const ret = {
- ...this.getParams,
- details: true,
- with_meta: true,
- }
- return ret
- },
- parseDetail (detail) {
- const ret = {
- enabled: true,
- email: {
- enabled: false,
- verified: false,
- contact: '',
- },
- mobile: {
- enabled: false,
- verified: false,
- contact: '',
- },
- }
- if (!R.is(String, detail)) return ret
- const arr = JSON.parse(detail)
- arr.forEach(item => {
- ret[item.contact_type] = item
- if (!item.enabled) {
- ret.enabled = false
- }
- })
- return ret
- },
- handleOpenSidepage (row) {
- this.sidePageTriggerHandle(this, 'ContactSidePage', {
- id: row.id,
- resource: 'receivers',
- apiVersion: 'v1',
- getParams: this.getParam,
- }, {
- list: this.list,
- })
- },
- },
- }
- </script>
|