允许echart在组件内更换图标类型

This commit is contained in:
aixianling
2024-03-25 17:49:57 +08:00
parent 4c220621b5
commit 5273f300ea
4 changed files with 27 additions and 9 deletions

View File

@@ -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'"

View File

@@ -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)">
<config-item label="图表模板">
<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"/> <json-editor v-model="config.echartOps"/>
</config-item> </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,

View File

@@ -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"

View File

@@ -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,7 +52,6 @@ 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 : {},
@@ -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
} }