mixin.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { chartColors } from '@/constants'
  2. export default {
  3. props: {
  4. options: {
  5. type: Object,
  6. required: true,
  7. },
  8. params: Object,
  9. formItemLayout: {
  10. type: Object,
  11. required: true,
  12. },
  13. visible: {
  14. type: Boolean,
  15. default: false,
  16. },
  17. type: String,
  18. },
  19. data () {
  20. return {
  21. ringColors: [
  22. {
  23. key: 'blue',
  24. percent60: chartColors[0],
  25. percent80: chartColors[0],
  26. percent100: chartColors[0],
  27. label: this.$t('dashboard.color.scheme.blue'),
  28. },
  29. {
  30. key: 'default',
  31. percent60: chartColors[3],
  32. percent80: chartColors[1],
  33. percent100: chartColors[2],
  34. label: this.$t('dashboard.color.scheme.default'),
  35. },
  36. {
  37. key: 'reverse',
  38. percent60: chartColors[2],
  39. percent80: chartColors[1],
  40. percent100: chartColors[3],
  41. label: this.$t('dashboard.color.scheme.reverse'),
  42. },
  43. ],
  44. }
  45. },
  46. methods: {
  47. setDefaultName (usage) {
  48. const usageKey = this.type === 'k8s' ? 'k8s_usage' : 'usage'
  49. if (!this.form.fc.isFieldTouched(this.decorators.name[0])) {
  50. this.form.fc.setFieldsValue({
  51. [this.decorators.name[0]]: this.$t(usageKey)[usage],
  52. })
  53. }
  54. },
  55. },
  56. }