chartSettingMixins.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // import _ from 'lodash'
  2. import cloneDeep from 'lodash/cloneDeep'
  3. import ColorSelect from 'data-room-ui/ColorMultipleSelect/index.vue'
  4. const chartSettingMixins = {
  5. components: {
  6. ColorSelect
  7. },
  8. data () {
  9. return {
  10. customRules: {},
  11. colorScheme: [],
  12. colors: []
  13. }
  14. },
  15. computed: {
  16. },
  17. watch: {
  18. },
  19. mounted () {
  20. this.initColor()
  21. },
  22. methods: {
  23. initColor () {
  24. const colorSetting = this.config?.setting?.find(item => item.type === 'colorSelect')
  25. if (colorSetting && colorSetting.value && colorSetting.value.length) {
  26. this.colorScheme = cloneDeep(colorSetting.value)
  27. this.colors = cloneDeep(colorSetting.value)
  28. }
  29. },
  30. // 清空颜色
  31. delColor () {
  32. this.colors = []
  33. this.config.setting.forEach((set) => {
  34. if (set && set.type === 'colorSelect' && set.value && set.value.length) {
  35. set.value = []
  36. }
  37. })
  38. },
  39. addColor () {
  40. this.colors.push('')
  41. },
  42. updateColorScheme (colors) {
  43. this.colors = [...colors]
  44. this.config.setting.forEach((set) => {
  45. if (set && set.type === 'colorSelect') {
  46. set.value = [...colors]
  47. }
  48. })
  49. }
  50. }
  51. }
  52. export { chartSettingMixins }