允许echart在组件内更换图标类型
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
:key="`chart-${index}`"
|
:key="`chart-${index}`"
|
||||||
:theme="theme"
|
:theme="theme"
|
||||||
:data="values"
|
:data="values"
|
||||||
|
:tpl="data.config"
|
||||||
:ops="data.echartOps"/>
|
:ops="data.echartOps"/>
|
||||||
<AiDvTable
|
<AiDvTable
|
||||||
v-else-if="currentType === 'AiDvTable'"
|
v-else-if="currentType === 'AiDvTable'"
|
||||||
|
|||||||
@@ -39,9 +39,14 @@
|
|||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</config-item>
|
</config-item>
|
||||||
<config-item label="echart选项" v-if="/Chart/.test(config.type)" top-label>
|
<template v-if="/Chart/.test(config.type)">
|
||||||
<json-editor v-model="config.echartOps"/>
|
<config-item label="图表模板">
|
||||||
</config-item>
|
<chart-picker v-model="config.config" @input="v=>config.echartOps=$copy($echartTpls[v])"/>
|
||||||
|
</config-item>
|
||||||
|
<config-item label="图表配置项" top-label>
|
||||||
|
<json-editor v-model="config.echartOps"/>
|
||||||
|
</config-item>
|
||||||
|
</template>
|
||||||
<config-item label="视频地址" v-if="config.type === 'video'">
|
<config-item label="视频地址" v-if="config.type === 'video'">
|
||||||
<el-input v-model="config.src" size="mini"/>
|
<el-input v-model="config.src" size="mini"/>
|
||||||
</config-item>
|
</config-item>
|
||||||
@@ -208,10 +213,12 @@ import AiDialogBtn from "dui/packages/layout/AiDialogBtn.vue";
|
|||||||
import {monitorTypes} from "../config";
|
import {monitorTypes} from "../config";
|
||||||
import AiDvSummary from "../../../../components/layout/AiDvSummary/AiDvSummary.vue";
|
import AiDvSummary from "../../../../components/layout/AiDvSummary/AiDvSummary.vue";
|
||||||
import JsonEditor from "./jsonEditor.vue";
|
import JsonEditor from "./jsonEditor.vue";
|
||||||
|
import Template from "../../../../project/sass/apps/AppAskForm/components/Template.vue";
|
||||||
|
import ChartPicker from "./chartPicker.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'componentConfig',
|
name: 'componentConfig',
|
||||||
components: {JsonEditor, AiDvSummary, AiDialogBtn, ConfigItem},
|
components: {ChartPicker, Template, JsonEditor, AiDvSummary, AiDialogBtn, ConfigItem},
|
||||||
props: {
|
props: {
|
||||||
config: {default: () => ({})},
|
config: {default: () => ({})},
|
||||||
instance: Function,
|
instance: Function,
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ export default {
|
|||||||
fullscreen: false
|
fullscreen: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
value(v) {
|
||||||
|
const content = this.editor.get()
|
||||||
|
if (v && content && JSON.stringify(v) != JSON.stringify(content)) {
|
||||||
|
this.editor?.set(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
const {JSONEditor} = window
|
const {JSONEditor} = window
|
||||||
@@ -27,7 +35,7 @@ export default {
|
|||||||
},
|
},
|
||||||
}, this.value)
|
}, this.value)
|
||||||
} else setTimeout(() => this.init(), 500)
|
} else setTimeout(() => this.init(), 500)
|
||||||
const fullscreenBtn = document.querySelector(".fullscreenBtn")
|
const fullscreenBtn = this.$el.querySelector(".fullscreenBtn")
|
||||||
if (!fullscreenBtn) {
|
if (!fullscreenBtn) {
|
||||||
const btn = document.createElement("div")
|
const btn = document.createElement("div")
|
||||||
btn.className = "fullscreenBtn el-icon-full-screen"
|
btn.className = "fullscreenBtn el-icon-full-screen"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default {
|
|||||||
data: {default: () => []},
|
data: {default: () => []},
|
||||||
ops: {default: () => ({})},
|
ops: {default: () => ({})},
|
||||||
type: {default: "line"},
|
type: {default: "line"},
|
||||||
|
tpl: String,
|
||||||
series: Object,
|
series: Object,
|
||||||
theme: {
|
theme: {
|
||||||
default: '0'
|
default: '0'
|
||||||
@@ -51,14 +52,13 @@ export default {
|
|||||||
|
|
||||||
return ['#FFBA44', '#EC6666', '#FF3E18', '#C9FF82', '#29D7FA', '#ea7ccc']
|
return ['#FFBA44', '#EC6666', '#FF3E18', '#C9FF82', '#29D7FA', '#ea7ccc']
|
||||||
},
|
},
|
||||||
|
|
||||||
chartOptions() {
|
chartOptions() {
|
||||||
let {type, data, ops: options = {}} = this,
|
let {type, data, ops: options = {}} = this,
|
||||||
style = this.series ? this.series : this.ops.daemon ? this.ops.daemon : {},
|
style = this.series ? this.series : this.ops.daemon ? this.ops.daemon : {},
|
||||||
colors = this.theme === '1' ? this.colors : (options.color || this.colors),
|
colors = this.theme === '1' ? this.colors : (options.color || this.colors),
|
||||||
legend = {textStyle: {color: '#fff', padding: [0, 0, 0, 8], fontSize: 14}, show: false},
|
legend = {textStyle: {color: '#fff', padding: [0, 0, 0, 8], fontSize: 14}, show: false},
|
||||||
series = data?.[0] ? Array(Object.keys(data?.[0]).length - 1).fill(1)
|
series = data?.[0] ? Array(Object.keys(data?.[0]).length - 1).fill(1)
|
||||||
.map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : []
|
.map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : []
|
||||||
return {
|
return {
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
@@ -118,9 +118,11 @@ export default {
|
|||||||
this.getChartData(oldDims != current)
|
this.getChartData(oldDims != current)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
theme() {
|
theme() {
|
||||||
this.refresh()
|
this.refresh()
|
||||||
|
},
|
||||||
|
tpl(v) {
|
||||||
|
v && this.refresh()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -149,7 +151,7 @@ export default {
|
|||||||
|
|
||||||
if (copy && typeof copy == 'object') {
|
if (copy && typeof copy == 'object') {
|
||||||
// 递归调用
|
// 递归调用
|
||||||
target[name] = this.deepAssign( src, copy)
|
target[name] = this.deepAssign(src, copy)
|
||||||
} else if (copy !== undefined) {
|
} else if (copy !== undefined) {
|
||||||
target[name] = copy
|
target[name] = copy
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user