changeMinxin.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. export default {
  2. data () {
  3. return {
  4. provider: '',
  5. }
  6. },
  7. async created () {
  8. const capability = ['engine', 'engine_version', 'category', 'storage_type']
  9. const specs = ['vcpu_count', 'vmem_size_mb', 'zones']
  10. this.keysChange = {
  11. capability,
  12. specs,
  13. }
  14. await this.$nextTick()
  15. this.skuRef = this.$refs.SKU
  16. this.networkRef = this.$refs.NETWORK
  17. },
  18. methods: {
  19. domain_change () {
  20. if (this.$store.getters.isAdminMode) {
  21. const { domain } = this.form.fd
  22. this.scopeParams.project_domain = domain || this.form.getFieldValue('domain')
  23. delete this.scopeParams.scope
  24. } else {
  25. delete this.scopeParams.project_domain
  26. }
  27. },
  28. cloudregion_change () {
  29. this.skuRef.fetchCapability()
  30. },
  31. // 获取CPU核数、内存、可用区
  32. capability_change () {
  33. this.skuRef.fetchSpecs()
  34. },
  35. // 获取skulist
  36. specs_change () {
  37. this.skuRef.fetchSkus()
  38. },
  39. zones_change () {
  40. this.skuRef.fetchSkus()
  41. this.networkRef.fetchVpc()
  42. },
  43. provider_change () {
  44. const { provider } = this.form.fd
  45. if (provider && provider === 'Aws') {
  46. this.networkRef.fetchVpc()
  47. }
  48. },
  49. async handleValuesChange (fc, changedFields) {
  50. const fields = Object.keys(changedFields)
  51. if (changedFields && fields.length > 0) {
  52. fields.forEach(field => {
  53. this.$set(this.form.fd, field, changedFields[field])
  54. if (field === 'vpc') {
  55. this.vpc = changedFields[field]
  56. }
  57. })
  58. }
  59. if (changedFields.hasOwnProperty('provider')) {
  60. this.provider = changedFields.provider
  61. }
  62. await this.$nextTick()
  63. Object.keys(changedFields).forEach(field => {
  64. if (changedFields[field] === undefined) return false
  65. let _field = field
  66. if (this[`${_field}_change`] === undefined) {
  67. for (const k in this.keysChange) {
  68. if (this.keysChange[k].indexOf(_field) > -1) {
  69. _field = k
  70. }
  71. }
  72. }
  73. const handleChange = this[`${_field}_change`]
  74. if (this[`${_field}_change`]) {
  75. return handleChange()
  76. }
  77. })
  78. },
  79. },
  80. }