index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="redis-create-index db-create-index pb-5">
  3. <page-header :title="$t('db.text_280')" />
  4. <page-body needMarginBottom>
  5. <a-form
  6. class="mt-3"
  7. v-bind="formItemLayout"
  8. :form="form.fc"
  9. hideRequiredMark>
  10. <a-form-item :label="$t('db.text_281')">
  11. <domain-project :decorators="decorators.projectDomain" :fc="form.fc" :labelInValue="false" />
  12. </a-form-item>
  13. <a-form-item :label="$t('db.text_60')">
  14. <a-input v-decorator="decorators.generate_name" :placeholder="$t('validator.resourceCreateName')" />
  15. <template #extra>
  16. <name-repeated res="dbinstances" :name="form.getFieldValue('generate_name')" />
  17. </template>
  18. </a-form-item>
  19. <a-form-item :label="$t('common.description')">
  20. <a-textarea :auto-size="{ minRows: 1, maxRows: 3 }" v-decorator="decorators.description" :placeholder="$t('common_367')" />
  21. </a-form-item>
  22. <!-- 计费方式 -->
  23. <clearing-radios v-bind="formItemLayout" :auto_renew="false" />
  24. <a-form-item :label="$t('db.text_71')" v-if="form.fd.billing_type !== 'prepaid'">
  25. <duration :decorators="decorators.duration" :form="form" />
  26. </a-form-item>
  27. <a-form-item :label="$t('db.text_265')">
  28. <a-input-number v-decorator="decorators.count" :min="1" :max="10" />
  29. </a-form-item>
  30. <!-- 区域 -->
  31. <item-area
  32. v-if="form.fd.project"
  33. class="mb-0"
  34. :defaultActiveFirstOption="['provider', 'cloudregion']"
  35. :values="form.fc.getFieldsValue()"
  36. filterBrandResource="redis_engine" />
  37. <!-- 套餐 -->
  38. <s-k-u ref="REF_SKU" />
  39. <a-form-item :label="$t('db.text_143')">
  40. <server-password :loginTypes="loginTypes" :decorator="decorators.loginConfig" :form="form" />
  41. </a-form-item>
  42. <!-- 网络 -->
  43. <item-network ref="REF_NETWORK" @vpcListChange="handleVpcListChange" />
  44. <!-- 安全组 -->
  45. <a-form-item v-if="form.getFieldValue('provider') === 'Qcloud'" :label="$t('db.text_144')">
  46. <secgroup-config :max="5" :decorators="decorators.secgroup" :secgroup-params="secgroupParams" />
  47. </a-form-item>
  48. <!-- 标签 -->
  49. <a-form-item :label="$t('table.title.tag')">
  50. <tag v-decorator="decorators.__meta__" :allowNoValue="false" />
  51. </a-form-item>
  52. <bottom-bar :provider="provider" :values="form.fc.getFieldsValue()" :cloudAccountId="cloudAccountId" @cancel="handleCancel" />
  53. </a-form>
  54. </page-body>
  55. </div>
  56. </template>
  57. <script>
  58. import { DECORATORS } from '@DB/views/redis/constants'
  59. import ServerPassword from '@Compute/sections/ServerPassword'
  60. import Duration from '@Compute/sections/Duration'
  61. import ItemArea from '@DB/sections/ItemArea'
  62. import ItemNetwork from '@DB/sections/ItemNetwork'
  63. import SecgroupConfig from '@Compute/sections/SecgroupConfig'
  64. import DomainProject from '@/sections/DomainProject'
  65. import NameRepeated from '@/sections/NameRepeated'
  66. import Tag from '@/sections/Tag'
  67. import changeMinxin from './changeMinxin'
  68. import BottomBar from './components/BottomBar'
  69. import SKU from './components/SKU'
  70. export default {
  71. name: 'IDCCreate',
  72. components: {
  73. Duration,
  74. // 区域
  75. ItemArea,
  76. // SKU
  77. SKU,
  78. // 指定项目
  79. DomainProject,
  80. // 管理员密码
  81. ServerPassword,
  82. // 网络
  83. ItemNetwork,
  84. // 安全组
  85. SecgroupConfig,
  86. // 表单提交
  87. BottomBar,
  88. NameRepeated,
  89. // 标签
  90. Tag,
  91. },
  92. mixins: [changeMinxin],
  93. data () {
  94. return {
  95. loginTypes: ['random', 'password'],
  96. formItemLayout: {
  97. wrapperCol: {
  98. lg: { span: 18 },
  99. xl: { span: 20 },
  100. xxl: { span: 21 },
  101. },
  102. labelCol: {
  103. lg: { span: 6 },
  104. xl: { span: 4 },
  105. xxl: { span: 3 },
  106. },
  107. },
  108. tailFormItemLayout: {
  109. wrapperCol: {
  110. lg: { span: 18, offset: 6 },
  111. xl: { span: 20, offset: 4 },
  112. xxl: { span: 21, offset: 3 },
  113. },
  114. },
  115. decorators: DECORATORS,
  116. project_id: '',
  117. vpcList: [],
  118. vpc: '',
  119. }
  120. },
  121. computed: {
  122. secgroupParams () {
  123. const ret = {
  124. project_id: this.project_id,
  125. ...this.scopeParam,
  126. }
  127. if (this.vpc) {
  128. ret.vpc_id = this.vpc
  129. }
  130. return ret
  131. },
  132. scopeParams () {
  133. if (this.$store.getters.isAdminMode) {
  134. return {
  135. project_domain: this.project_domain,
  136. }
  137. }
  138. return { scope: this.$store.getters.scope }
  139. },
  140. cloudAccountId () {
  141. const values = this.form.getFieldsValue()
  142. const currentVpc = this.vpcList.filter(item => item.id === values.vpc)
  143. if (currentVpc[0]) {
  144. return currentVpc[0].account_id
  145. }
  146. return ''
  147. },
  148. },
  149. methods: {
  150. handleVpcListChange (list) {
  151. this.vpcList = list
  152. },
  153. handleCancel () {
  154. this.$router.push({ name: 'Redis' })
  155. },
  156. },
  157. }
  158. </script>