BillingOpts.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div>
  3. <a-form-item :label="$t('db.text_54')" v-bind="formItemLayout">
  4. <a-radio-group v-decorator="decorators['billing_type']">
  5. <a-radio-button
  6. :key="key"
  7. :value="key"
  8. v-for="key in Object.keys(BILL_TYPES_MAP)">{{BILL_TYPES_MAP[key].label}}</a-radio-button>
  9. </a-radio-group>
  10. <div v-if="getFieldValue('billing_type') === 'prepaid'">
  11. <a-radio-group v-decorator="decorators['duration']">
  12. <a-radio-button
  13. :key="item.value"
  14. :value="item.value"
  15. v-for="item in BUY_DURATIONS_OPTIONS">
  16. {{item.label}}</a-radio-button>
  17. </a-radio-group>
  18. </div>
  19. </a-form-item>
  20. </div>
  21. </template>
  22. <script>
  23. import { BILL_TYPES_MAP, BUY_DURATIONS_OPTIONS } from '../constants/index.js'
  24. import { CreateServerForm } from '@Compute/constants'
  25. const decorators = {
  26. billing_type: [
  27. 'billing_type',
  28. {
  29. initialValue: 'postpaid',
  30. },
  31. ],
  32. duration: [
  33. 'duration',
  34. {
  35. initialValue: '1M',
  36. },
  37. ],
  38. }
  39. export default {
  40. inject: ['form'],
  41. props: {
  42. decorators: {
  43. type: Object,
  44. default: () => {
  45. return decorators
  46. },
  47. },
  48. },
  49. data () {
  50. return {
  51. BILL_TYPES_MAP,
  52. BUY_DURATIONS_OPTIONS,
  53. formItemLayout: {
  54. wrapperCol: { span: CreateServerForm.wrapperCol },
  55. labelCol: { span: CreateServerForm.labelCol },
  56. },
  57. }
  58. },
  59. computed: {
  60. FC () {
  61. if (this.form && this.form.fc) {
  62. return this.form.fc
  63. }
  64. return {}
  65. },
  66. getFieldValue () {
  67. if (this.FC && this.FC.getFieldValue) {
  68. return this.FC.getFieldValue
  69. }
  70. return () => null
  71. },
  72. },
  73. }
  74. </script>