index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. import validateForm, { isRequired } from '@/utils/validate'
  2. import i18n from '@/locales'
  3. // 公有云计费方式配置选项
  4. export const BILL_TYPES_MAP = {
  5. postpaid: {
  6. label: i18n.t('db.text_55'),
  7. key: 'postpaid',
  8. },
  9. prepaid: {
  10. label: i18n.t('db.text_56'),
  11. key: 'prepaid',
  12. },
  13. }
  14. export const BUY_DURATIONS_OPTIONS = [
  15. {
  16. label: i18n.t('db.text_240'),
  17. value: '1M',
  18. unit: 'M',
  19. },
  20. {
  21. label: i18n.t('db.text_241'),
  22. value: '2M',
  23. unit: 'M',
  24. },
  25. {
  26. label: i18n.t('db.text_242'),
  27. value: '3M',
  28. unit: 'M',
  29. },
  30. {
  31. label: i18n.t('db.text_243'),
  32. value: '6M',
  33. unit: 'M',
  34. },
  35. {
  36. label: i18n.t('db.text_244'),
  37. value: '1Y',
  38. unit: 'Y',
  39. },
  40. {
  41. label: i18n.t('db.text_245'),
  42. value: '2Y',
  43. unit: 'Y',
  44. },
  45. {
  46. label: i18n.t('db.text_246'),
  47. value: '3Y',
  48. unit: 'Y',
  49. },
  50. ]
  51. // 账号权限
  52. export const ACCOUNT_PRIVILEGES = {
  53. read: i18n.t('db.text_6'),
  54. write: i18n.t('db.text_5'),
  55. repl: i18n.t('db.text_247'),
  56. }
  57. export const ENGINE_KEYS = ['single', 'master', 'cluster', 'rwsplit']
  58. // Elasticache机型翻译
  59. export const ENGINE_ARCH = {
  60. single: i18n.t('db.text_76'),
  61. master: i18n.t('db.text_77'),
  62. cluster: i18n.t('db.text_248'),
  63. rwsplit: i18n.t('db.text_249'),
  64. }
  65. export const NODE_KEYS = ['single', 'double', 'readone', 'readthree', 'readfive']
  66. // 节点类型翻译
  67. export const NODE_TYPE = {
  68. readthree: i18n.t('db.text_250'),
  69. readone: i18n.t('db.text_251'),
  70. readfive: i18n.t('db.text_252'),
  71. single: i18n.t('db.text_253'),
  72. double: i18n.t('db.text_254'),
  73. }
  74. export const PERFORMANCE_TYPE_KEYS = ['standard', 'enhanced']
  75. // 性能类型
  76. export const PERFORMANCE_TYPE = {
  77. standard: i18n.t('db.text_255'),
  78. enhanced: i18n.t('db.text_256'),
  79. }
  80. // capbilit接口所需要的参数
  81. export const CAPABILIT_PARAMS = ['billing_type', 'city', 'provider', 'cloudregion', 'zone']
  82. // elasticcacheskus/instance-specs接口所需要的参数
  83. export const SPECS_PARAMS = ['billing_type', 'engine', 'engine_version', 'local_category', 'node_type', 'performance_type', 'provider', 'cloudregion']
  84. // elasticcacheskus接口所需要的参数
  85. export const SKU_PARAMS = ['project_domian', 'memory_size_mb', ...CAPABILIT_PARAMS, ...SPECS_PARAMS]
  86. export const DECORATORS = {
  87. duration: {
  88. durationStandard: [
  89. 'durationStandard',
  90. {
  91. initialValue: 'none',
  92. },
  93. ],
  94. duration: [
  95. 'duration',
  96. {
  97. initialValue: '1h',
  98. },
  99. ],
  100. },
  101. projectDomain: {
  102. project: [
  103. 'project',
  104. {
  105. initialValue: undefined,
  106. rules: [
  107. { required: true, message: i18n.t('db.text_134'), trigger: 'change' },
  108. ],
  109. },
  110. ],
  111. domain: [
  112. 'domain',
  113. {
  114. initialValue: undefined,
  115. rules: [
  116. { required: true, message: i18n.t('db.text_135'), trigger: 'change' },
  117. ],
  118. },
  119. ],
  120. },
  121. generate_name: [
  122. 'generate_name',
  123. {
  124. initialValue: '',
  125. validateTrigger: ['change', 'blur'],
  126. validateFirst: true,
  127. rules: [
  128. { required: true, message: i18n.t('db.text_136') },
  129. { validator: validateForm('resourceCreateName') },
  130. ],
  131. },
  132. ],
  133. description: ['description'],
  134. count: [
  135. 'count',
  136. {
  137. initialValue: 1,
  138. rules: [
  139. { required: true, message: i18n.t('db.text_257') },
  140. ],
  141. },
  142. ],
  143. billing_type: [
  144. 'billing_type',
  145. {
  146. initialValue: 'postpaid',
  147. },
  148. ],
  149. sku: [
  150. 'sku',
  151. {
  152. rules: [
  153. { required: true, message: i18n.t('db.text_258') },
  154. ],
  155. },
  156. ],
  157. regionZone: {
  158. cloudregion: [
  159. 'region',
  160. {
  161. initialValue: { key: '', label: '' },
  162. rules: [
  163. { validator: isRequired(), message: i18n.t('db.text_259') },
  164. ],
  165. },
  166. ],
  167. zone: [
  168. 'zone',
  169. {
  170. initialValue: { key: '', label: '' },
  171. rules: [
  172. { validator: isRequired(), message: i18n.t('db.text_260') },
  173. ],
  174. },
  175. ],
  176. },
  177. slaveZones: [
  178. 'slave_zones',
  179. {
  180. initialValue: '',
  181. },
  182. ],
  183. cityProviderRegion: {
  184. city: ['city', {
  185. initialValue: undefined,
  186. }],
  187. provider: ['provider', {
  188. initialValue: undefined,
  189. }],
  190. region: ['region', {
  191. initialValue: undefined,
  192. }],
  193. zone: ['zone', {
  194. initialValue: undefined,
  195. }],
  196. },
  197. loginConfig: {
  198. loginType: [
  199. 'loginType',
  200. {
  201. initialValue: 'random',
  202. },
  203. ],
  204. keypair: [
  205. 'loginKeypair',
  206. {
  207. initialValue: undefined, // { key: '', label: '' }
  208. rules: [
  209. { validator: true, message: i18n.t('db.text_137') },
  210. ],
  211. },
  212. ],
  213. },
  214. vpcNetwork: {
  215. vpc: [
  216. 'vpc',
  217. {
  218. initialValue: undefined,
  219. rules: [
  220. { required: true, message: i18n.t('db.text_261') },
  221. ],
  222. },
  223. ],
  224. network: [
  225. 'network',
  226. {
  227. initialValue: undefined,
  228. rules: [
  229. { required: true, message: i18n.t('db.text_262') },
  230. ],
  231. },
  232. ],
  233. },
  234. secgroup: {
  235. type: [
  236. 'secgroup_type',
  237. {
  238. initialValue: 'default',
  239. },
  240. ],
  241. secgroup: [
  242. 'secgroup',
  243. {
  244. rules: [
  245. { required: true, message: i18n.t('db.text_138') },
  246. ],
  247. },
  248. ],
  249. },
  250. __meta__: [
  251. '__meta__',
  252. {
  253. rules: [
  254. { validator: validateForm('tagName') },
  255. ],
  256. },
  257. ],
  258. }