| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :group-actions="groupActions"
- :single-actions="singleActions"
- :export-data-options="exportDataOptions" />
- </template>
- <script>
- import get from 'lodash/get'
- import * as R from 'ramda'
- import { mapGetters } from 'vuex'
- import WindowsMixin from '@/mixins/windows'
- import ListMixin from '@/mixins/list'
- import expectStatus from '@/constants/expectStatus'
- import { getDistinctFieldFilter } from '@/utils/common/tableFilter'
- import ColumnsMixin from '../mixins/columns'
- import SingleActionsMixin from '../mixins/singleActions'
- export default {
- name: 'ClouduserList',
- mixins: [WindowsMixin, ListMixin, ColumnsMixin, SingleActionsMixin],
- props: {
- id: String,
- getParams: {
- type: [Object, Function],
- default: () => ({}),
- },
- cloudaccount: Object,
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'cloudusers',
- apiVersion: 'v1',
- getParams: this.getParam,
- steadyStatus: Object.values(expectStatus.clouduser).flat(),
- filterOptions: {
- name: {
- label: this.$t('cloudenv.clouduser_list_t1'),
- },
- owner_name: {
- label: this.$t('cloudenv.clouduser_list_t4'),
- },
- cloudaccount: getDistinctFieldFilter({
- field: 'account',
- type: 'extra_field',
- label: this.$t('common.text00108'),
- }),
- },
- }),
- groupActions: [
- {
- label: this.$t('common.create'),
- permission: 'clouduser_create',
- action: () => {
- this.createDialog('ClouduserCreateDialog', {
- onManager: this.onManager,
- cloudaccount: this.cloudaccount,
- defaultDomainId: this.userInfo.projectDomainId,
- defaultProjectId: this.userInfo.projectId,
- userId: this.userInfo.id,
- })
- },
- meta: () => {
- return {
- validate: (this.$store.getters.isAdminMode || get(this.cloudaccount, 'domain_id') === this.$store.getters.userInfo.projectDomainId) && this.isNormalStatus(),
- buttonType: 'primary',
- }
- },
- },
- {
- label: this.$t('common.batchAction'),
- actions: () => {
- return [
- {
- label: this.$t('common.delete'),
- permission: 'clouduser_delete',
- action: () => {
- this.createDialog('DeleteResDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('common.delete'),
- name: this.$t('dictionary.clouduser'),
- onManager: this.onManager,
- })
- },
- meta: () => this.$getDeleteResult(this.list.selectedItems),
- },
- {
- label: this.$t('iam.enable_console_login'),
- permission: 'clouduser_perform_enable_console_login',
- action: (obj) => {
- this.createDialog('ClouduserSetConsoleLoginDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('iam.enable_console_login'),
- name: this.$t('dictionary.clouduser'),
- onManager: this.onManager,
- action: 'enable-console-login',
- })
- },
- meta: (obj) => {
- return {
- validate: this.list.selectedItems.length && this.list.selectedItems.some(item => !item.is_console_login),
- }
- },
- hidden: () => !this.$appConfig.isPrivate,
- },
- {
- label: this.$t('iam.disable_console_login'),
- permission: 'clouduser_disable_console_login',
- action: (obj) => {
- this.createDialog('ClouduserSetConsoleLoginDialog', {
- vm: this,
- data: this.list.selectedItems,
- columns: this.columns,
- title: this.$t('iam.disable_console_login'),
- name: this.$t('dictionary.clouduser'),
- onManager: this.onManager,
- action: 'disable-console-login',
- })
- },
- meta: (obj) => {
- return {
- validate: this.list.selectedItems.length && this.list.selectedItems.some(item => item.is_console_login),
- }
- },
- hidden: () => !this.$appConfig.isPrivate,
- },
- ]
- },
- meta: () => {
- return {
- validate: this.list.selectedItems && this.list.selectedItems.length > 0 && (this.$store.getters.isAdminMode || get(this.cloudaccount, 'domain_id') === this.$store.getters.userInfo.projectDomainId) && this.isNormalStatus(),
- }
- },
- },
- ],
- }
- },
- computed: {
- ...mapGetters(['userInfo']),
- exportDataOptions () {
- return {
- title: this.$t('dictionary.clouduser'),
- downloadType: 'local',
- items: [
- { field: 'id', title: 'ID' },
- ...this.columns,
- { field: 'manager', title: this.$t('common_624', [this.$t('dictionary.cloudprovider')]) },
- ],
- }
- },
- },
- created () {
- this.initSidePageTab('clouduser-detail')
- this.list.fetchData()
- },
- methods: {
- getParam () {
- const ret = {
- details: true,
- ...(R.is(Function, this.getParams) ? this.getParams() : this.getParams),
- }
- return ret
- },
- },
- }
- </script>
|