ItemNetwork.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <network-selects
  3. ref="NETWORK"
  4. :label="$t('db.text_32')"
  5. :isDefaultFetch="false"
  6. :vpcFormat="vpcFormat"
  7. :vpcParams="getVpcParams"
  8. :networkParams="getNetworkParams"
  9. v-bind="formItemLayout">
  10. <template v-slot:helplink>
  11. {{$t('compute.text_196')}}<help-link href="/network2">{{$t('compute.perform_create')}}</help-link>
  12. </template>
  13. </network-selects>
  14. </template>
  15. <script>
  16. import NetworkSelects from '@/sections/NetworkSelects'
  17. export default {
  18. name: 'DBItemNetwork',
  19. components: {
  20. NetworkSelects,
  21. },
  22. inject: ['form', 'formItemLayout', 'scopeParams'],
  23. methods: {
  24. vpcFormat (vpc) {
  25. const { name, manager } = vpc
  26. return (
  27. <div class='d-flex'>
  28. <a-badge status={ vpc.network_count ? 'success' : 'default' } />
  29. <span class='text-truncate flex-fill mr-2' title={ name }>{ name }</span>
  30. <span style="color: #8492a6; font-size: 13px">{ this.$t('db.text_340', [manager]) }</span>
  31. </div>
  32. )
  33. },
  34. getVpcParams () {
  35. const { fd } = this.form
  36. const params = {
  37. cloudregion_id: fd.cloudregion_id || fd.cloudregion,
  38. ...this.scopeParams,
  39. }
  40. const zone = fd.zones || fd.zone
  41. if (fd.provider === 'Aws') {
  42. params.provider = 'Aws'
  43. } else {
  44. if (zone) {
  45. params.zone_id = zone.split('+')[0]
  46. }
  47. }
  48. return params
  49. },
  50. getNetworkParams () {
  51. const { fd } = this.form
  52. const params = {
  53. cloudregion_id: fd.cloudregion_id || fd.cloudregion,
  54. ...this.scopeParams,
  55. }
  56. // zones是rds新建
  57. const zonesStr = this.form.getFieldValue('zones')
  58. if (fd.provider === 'Aws') {
  59. params.provider = 'Aws'
  60. } else {
  61. if (zonesStr) {
  62. const zoneArr = zonesStr.split('+')
  63. if (zoneArr && zoneArr.length > 0) {
  64. params['zones.0'] = zoneArr[0]
  65. }
  66. }
  67. }
  68. // zone是redis新建
  69. const zone = this.form.getFieldValue('zone')
  70. if (zone) {
  71. params.zone = zone
  72. } else {
  73. const zone_id = this.form.getFieldValue('zone_id')
  74. if (zone_id) {
  75. params.zone = zone_id
  76. }
  77. }
  78. return params
  79. },
  80. fetchVpc () {
  81. this.$refs.NETWORK.fetchVpc(this.vpcListChange)
  82. },
  83. vpcListChange ({ vpcList }) {
  84. this.$emit('vpcListChange', vpcList)
  85. },
  86. },
  87. }
  88. </script>
  89. <style>
  90. </style>