index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div>
  3. <a-form-item class="mb-0">
  4. <a-radio-group @change="brandWidthChangeHandle" v-decorator="decorators.brandWidth">
  5. <a-radio-button v-for="item in brandWidthOptions" :key="item.key" :value="item.key">{{ item.label }}</a-radio-button>
  6. </a-radio-group>
  7. </a-form-item>
  8. <a-form-item v-if="showDuration" class="mb-0">
  9. <a-input-group compact>
  10. <a-input class="w-25" type="number" suffix="M" v-decorator="decorators.customBrandWidth" @change="customBrandWidthChangeHandle" />
  11. </a-input-group>
  12. </a-form-item>
  13. </div>
  14. </template>
  15. <script>
  16. import * as R from 'ramda'
  17. export default {
  18. name: 'MigrationBandwidth',
  19. props: {
  20. decorators: {
  21. type: Object,
  22. required: true,
  23. validator: val => !R.isNil(val.brandWidth) && !R.isNil(val.customBrandWidth),
  24. },
  25. form: {
  26. type: Object,
  27. },
  28. },
  29. data () {
  30. return {
  31. brandWidthOptions: [
  32. { key: '-1', label: this.$t('compute.text_138') },
  33. { key: '100', label: '100M' },
  34. { key: '200', label: '200M' },
  35. { key: '300', label: '300M' },
  36. { key: '500', label: '500M' },
  37. { key: '1000', label: '1000M' },
  38. { key: 'custom', label: this.$t('compute.text_144') },
  39. ],
  40. showDuration: false,
  41. }
  42. },
  43. methods: {
  44. brandWidthChangeHandle (e) {
  45. this.form.fc.setFieldsValue({ brandWidth: e.target.value })
  46. if (e.target.value === 'custom') {
  47. this.showDuration = true
  48. } else {
  49. this.showDuration = false
  50. }
  51. },
  52. customBrandWidthChangeHandle (e) {
  53. const brandWidth = isNaN(parseInt(e.target.value)) ? 1 : parseInt(e.target.value)
  54. this.form.fc.setFieldsValue({ customBrandWidth: brandWidth })
  55. },
  56. },
  57. }
  58. </script>
  59. <style>
  60. </style>