BottomBar.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <page-footer>
  3. <template v-slot:right>
  4. <price-fetcher :values="values" :cloudAccountId="cloudAccountId" />
  5. <div class="btns-wrapper d-flex align-items-center">
  6. <a-button
  7. class="ml-3"
  8. type="primary"
  9. native-type="submit"
  10. html-type="submit"
  11. @click="handleConfirm"
  12. :loading="loading">{{ $t('common_258') }}</a-button>
  13. <a-button class="ml-3" @click="() => $router.back()">{{$t('common.cancel')}}</a-button>
  14. </div>
  15. </template>
  16. </page-footer>
  17. </template>
  18. <script>
  19. import { mapGetters } from 'vuex'
  20. import PriceFetcher from '@/components/PriceFetcher'
  21. export default {
  22. name: 'BottomBar',
  23. components: {
  24. PriceFetcher,
  25. },
  26. inject: ['form', 'cloudEnv'],
  27. props: {
  28. values: {
  29. type: Object,
  30. },
  31. cloudAccountId: String,
  32. },
  33. data () {
  34. return {
  35. loading: false,
  36. }
  37. },
  38. computed: {
  39. ...mapGetters(['userInfo']),
  40. },
  41. methods: {
  42. doCreate (data) {
  43. return new this.$Manager('natgateways').create({ data })
  44. },
  45. async handleConfirm () {
  46. this.loading = true
  47. try {
  48. const values = await this.form.fc.validateFields()
  49. const params = {
  50. project_domain: values.project_domain,
  51. name: values.name,
  52. description: values.description,
  53. cloudregion_id: values.cloudregion_id,
  54. network_id: values.network,
  55. vpc_id: values.vpc,
  56. nat_spec: values.sku.name,
  57. billing_type: values.billing_type,
  58. __meta__: values.__meta__,
  59. }
  60. if (params.billing_type === 'postpaid') {
  61. if (values.durationStandard !== 'none') {
  62. params.duration = values.durationStandard
  63. if (values.durationStandard === 'custom') {
  64. params.duration = values.duration
  65. }
  66. }
  67. } else {
  68. params.duration = values.duration
  69. }
  70. if (values.bandwidth && values.bandwidth > 0) {
  71. params.eip_bw = values.bandwidth
  72. }
  73. if (values.charge_type) {
  74. params.eip_charge_type = values.charge_type
  75. }
  76. await this.doCreate(params)
  77. this.loading = false
  78. this.$message.success(this.$t('network.nat.create.success'))
  79. this.$router.push('/nat')
  80. } catch (error) {
  81. this.loading = false
  82. throw error
  83. }
  84. },
  85. },
  86. }
  87. </script>
  88. <style lang="less" scoped>
  89. @import '../../../../../../src/styles/less/theme';
  90. .prices {
  91. .hour {
  92. color: @error-color;
  93. font-size: 24px;
  94. }
  95. .tips {
  96. color: #999;
  97. font-size: 12px;
  98. }
  99. }
  100. </style>