index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div>
  3. <a-tooltip v-if="isGpuEmpty" :title="$t('compute.text_146')">
  4. <span><a-switch :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" :value="gpuEnable" :disabled="true" /></span>
  5. </a-tooltip>
  6. <a-form-item class="mb-0" v-else>
  7. <a-switch :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" v-decorator="decorators.gpuEnable" @change="change" />
  8. </a-form-item>
  9. <template v-if="gpuEnable">
  10. <a-row>
  11. <a-col :span="3" class="mr-2">
  12. <a-form-item>
  13. <base-select v-decorator="decorators.devType" :options="gpuDevTypeOptions" @change="onChangeDevType" />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="12">
  17. <a-form-item>
  18. <base-select v-decorator="decorators.gpu" :options="realGpuOptions" :item.sync="curGpuItem"
  19. :selectProps="{ placeholder: $t('compute.text_147') }" />
  20. </a-form-item>
  21. </a-col>
  22. </a-row>
  23. <a-form-item class="mb-0">
  24. <a-radio-group v-decorator="decorators.gpuCount">
  25. <a-radio-button
  26. v-for="item in gpuCountOptions"
  27. :value="item.key"
  28. :key="item.key">{{ item.label }}</a-radio-button>
  29. </a-radio-group>
  30. </a-form-item>
  31. </template>
  32. </div>
  33. </template>
  34. <script>
  35. import { GPU_COUNT_OPTIONS, GPU_DEV_TYPE_OPTIONS, GPU_DEV_TYPE_OPTION_MAP } from '@Compute/constants'
  36. export default {
  37. name: 'GPU',
  38. props: {
  39. decorators: {
  40. type: Object,
  41. validator: val => val.gpuEnable && val.gpu && val.gpuCount && val.devType,
  42. },
  43. gpuOptions: {
  44. type: Array,
  45. default: () => [],
  46. },
  47. },
  48. data () {
  49. return {
  50. gpuEnable: false,
  51. gpuCountOptions: GPU_COUNT_OPTIONS,
  52. curGpuItem: {},
  53. gpuDevTypeOptions: GPU_DEV_TYPE_OPTIONS,
  54. curGpuDevType: GPU_DEV_TYPE_OPTION_MAP['GPU-VGA'].value,
  55. }
  56. },
  57. computed: {
  58. isGpuEmpty () {
  59. return this.gpuOptions && this.gpuOptions.length === 0
  60. },
  61. realGpuOptions () {
  62. return this.gpuOptions.filter(item => item.dev_type === this.curGpuDevType)
  63. },
  64. },
  65. methods: {
  66. change (val) {
  67. this.gpuEnable = val
  68. this.$emit('change', val)
  69. },
  70. onChangeDevType (val) {
  71. this.curGpuDevType = val
  72. },
  73. },
  74. }
  75. </script>