SetNuma.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.set_numa')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.host')" :count="params.data.length" :action="$t('compute.set_numa')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 2)" />
  7. <a-form-model :form="form" :rules="rules" v-bind="formItemLayout">
  8. <a-form-model-item :label="$t('compute.sched_numa')" :extra="extraInfo">
  9. <a-switch v-model="form.enable_numa_allocate" :checkedChildren="$t('table.title.on')" :unCheckedChildren="$t('table.title.off')" />
  10. </a-form-model-item>
  11. </a-form-model>
  12. </div>
  13. <div slot="footer">
  14. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  15. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  16. </div>
  17. </base-dialog>
  18. </template>
  19. <script>
  20. import DialogMixin from '@/mixins/dialog'
  21. import WindowsMixin from '@/mixins/windows'
  22. export default {
  23. name: 'HostSetNumaDialog',
  24. mixins: [DialogMixin, WindowsMixin],
  25. data () {
  26. return {
  27. loading: false,
  28. scope: this.$store.getters.scope,
  29. form: {
  30. enable_numa_allocate: this.params.data[0].enable_numa_allocate || false,
  31. },
  32. formItemLayout: {
  33. wrapperCol: {
  34. span: 19,
  35. },
  36. labelCol: {
  37. span: 5,
  38. },
  39. },
  40. }
  41. },
  42. computed: {
  43. enableHostAgentNumaAllocate () {
  44. return this.params.data[0].sys_info?.host_agent_cpu_numa_allocate
  45. },
  46. extraInfo () {
  47. return this.form.enable_numa_allocate ? '' : (this.enableHostAgentNumaAllocate ? this.$t('compute.sched_numa_extra_info_1') : this.$t('compute.sched_numa_extra_info_2'))
  48. },
  49. },
  50. methods: {
  51. async handleConfirm () {
  52. this.loading = true
  53. try {
  54. await this.params.onManager('update', {
  55. id: this.params.data[0].id,
  56. managerArgs: {
  57. data: {
  58. enable_numa_allocate: this.form.enable_numa_allocate,
  59. },
  60. },
  61. })
  62. this.loading = false
  63. this.cancelDialog()
  64. this.params.refresh()
  65. } catch (error) {
  66. this.loading = false
  67. }
  68. },
  69. },
  70. }
  71. </script>