index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div>
  3. <item-filters
  4. ref="FILTERS"
  5. :getParams="getParams"
  6. :disableds="disableds"
  7. :decorators="decorators" />
  8. <sku-list
  9. :filterSkuCallback="filterSkuCallback"
  10. ref="SKU_LIST" />
  11. </div>
  12. </template>
  13. <script>
  14. import { isRequiredData } from '@DB/views/utils'
  15. import { CAPABILIT_PARAMS, SPECS_PARAMS, SKU_PARAMS } from '@DB/views/redis/constants'
  16. import ItemFilters from './components/ItemFilters'
  17. import SkuList from './components/List'
  18. export default {
  19. name: 'RedisCreateSku',
  20. components: {
  21. ItemFilters,
  22. SkuList,
  23. },
  24. inject: ['form', 'scopeParams'],
  25. props: {
  26. decorators: {
  27. type: Object,
  28. },
  29. filterSkuCallback: {
  30. type: Function,
  31. },
  32. disableds: {
  33. type: Object,
  34. },
  35. },
  36. methods: {
  37. getParams (keys) {
  38. const values = this.form.getFieldsValue(keys)
  39. const params = {
  40. usable: true,
  41. provider: this.form.fd.provider,
  42. cloudregion: this.form.fd.cloudregion,
  43. ...values,
  44. ...this.scopeParams,
  45. }
  46. if (!params.project_domian) {
  47. params.project_domian = this.$store.getters.userInfo.projectDomain
  48. }
  49. return params
  50. },
  51. async fetchCapability () {
  52. const { fetchCapability } = this.$refs.FILTERS
  53. const values = this.getParams(CAPABILIT_PARAMS)
  54. if (!values.city && !values.cloudregion) {
  55. return false
  56. }
  57. try {
  58. await fetchCapability(values)
  59. } catch (err) {
  60. throw err
  61. }
  62. },
  63. async fetchSpecs () {
  64. const { fetchSpecs } = this.$refs.FILTERS
  65. const values = this.getParams(SPECS_PARAMS)
  66. if (!isRequiredData(values, SPECS_PARAMS)) {
  67. return false
  68. }
  69. try {
  70. await fetchSpecs(values)
  71. } catch (err) {
  72. throw err
  73. }
  74. },
  75. async fetchSkus () {
  76. const { fetchSkus } = this.$refs.SKU_LIST
  77. const values = this.getParams(SKU_PARAMS)
  78. if (!isRequiredData(values, ['memory_size_mb', ...SPECS_PARAMS])) {
  79. return false
  80. }
  81. try {
  82. await fetchSkus(values)
  83. } catch (err) {
  84. throw err
  85. }
  86. },
  87. },
  88. }
  89. </script>