| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <template>
- <page-list
- :list="list"
- :columns="columns"
- :single-actions="singleActions"
- :group-actions="groupActions" />
- </template>
- <script>
- import ListMixin from '@/mixins/list'
- import WindowsMixin from '@/mixins/windows'
- import expectStatus from '@/constants/expectStatus'
- import {
- getNameFilter,
- getStatusFilter,
- } from '@/utils/common/tableFilter'
- import SingleActionsMixin from '../mixins/singleActions'
- import ColumnsMixin from '../mixins/columns'
- export default {
- name: 'ContainerList',
- mixins: [ListMixin, WindowsMixin, SingleActionsMixin, ColumnsMixin],
- props: {
- id: String,
- resId: String,
- data: {
- type: Object,
- required: true,
- },
- },
- data () {
- return {
- list: this.$list.createList(this, {
- id: this.id,
- resource: 'containers',
- getParams: {
- guest_id: this.resId,
- },
- steadyStatus: Object.values(expectStatus.container).flat(),
- filterOptions: {
- name: getNameFilter(),
- status: getStatusFilter('container'),
- },
- }),
- groupActions: [
- // 启动
- {
- label: this.$t('compute.repo.start'),
- action: () => {
- const ids = this.list.selectedItems.map(item => item.id)
- this.list.onManager('batchPerformAction', {
- steadyStatus: 'running',
- id: ids,
- managerArgs: {
- action: 'start',
- },
- })
- },
- meta: () => {
- const ret = { validate: true, tooltip: null }
- if (this.list.selectedItems.length === 0) {
- ret.validate = false
- return ret
- }
- const isStatusOk = this.list.selectedItems.every(item => ['exited'].includes(item.status))
- if (!isStatusOk) {
- ret.validate = false
- return ret
- }
- return ret
- },
- },
- // 停止
- {
- label: this.$t('compute.repo.stop'),
- action: () => {
- this.createDialog('ContainerShutDownDialog', {
- data: this.list.selectedItems,
- columns: this.columns,
- onManager: this.onManager,
- })
- },
- meta: () => {
- const ret = { validate: true, tooltip: null }
- if (this.list.selectedItems.length === 0) {
- ret.validate = false
- return ret
- }
- const isStatusOk = this.list.selectedItems.every(item => ['running'].includes(item.status))
- if (!isStatusOk) {
- ret.validate = false
- return ret
- }
- return ret
- },
- },
- ],
- }
- },
- created () {
- this.list.fetchData()
- },
- methods: {
- handleOpenSidepage (row, tab) {
- this.sidePageTriggerHandle(this, 'VmPodContainerSidePage', {
- id: row.id,
- resource: 'containers',
- getParams: this.getParam,
- }, {
- list: this.list,
- tab,
- })
- },
- },
- }
- </script>
|