初始化
This commit is contained in:
53
frontend/packages/js/mixins/chartSettingMixins.js
Normal file
53
frontend/packages/js/mixins/chartSettingMixins.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// import _ from 'lodash'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import ColorSelect from 'data-room-ui/ColorMultipleSelect/index.vue'
|
||||
const chartSettingMixins = {
|
||||
components: {
|
||||
ColorSelect
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
customRules: {},
|
||||
colorScheme: [],
|
||||
colors: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
mounted () {
|
||||
this.initColor()
|
||||
},
|
||||
methods: {
|
||||
initColor () {
|
||||
const colorSetting = this.config?.setting?.find(item => item.type === 'colorSelect')
|
||||
if (colorSetting && colorSetting.value && colorSetting.value.length) {
|
||||
this.colorScheme = cloneDeep(colorSetting.value)
|
||||
this.colors = cloneDeep(colorSetting.value)
|
||||
}
|
||||
},
|
||||
// 清空颜色
|
||||
delColor () {
|
||||
this.colors = []
|
||||
this.config.setting.forEach((set) => {
|
||||
if (set && set.type === 'colorSelect' && set.value && set.value.length) {
|
||||
set.value = []
|
||||
}
|
||||
})
|
||||
},
|
||||
addColor () {
|
||||
this.colors.push('')
|
||||
},
|
||||
updateColorScheme (colors) {
|
||||
this.colors = [...colors]
|
||||
this.config.setting.forEach((set) => {
|
||||
if (set && set.type === 'colorSelect') {
|
||||
set.value = [...colors]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { chartSettingMixins }
|
||||
Reference in New Issue
Block a user