widgetWaterLevelPond.vue
5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!--
水位图
-->
<template>
<!-- <div id="widget-water-pond-level" :style="styleObj">-->
<dv-water-level-pond :config="options" :style="styleObj" v-if="isRouterAlive" />
<!-- </div>-->
</template>
<script>
import waterLevelPond from "@jiaminghi/data-view/lib/components/waterLevelPond";
import Vue from "vue";
import {mapState} from "vuex";
Vue.use(waterLevelPond)
export default {
name: "WidgetWaterLevelPond",
props: {
value: Object,
ispreview: Boolean,
},
data() {
return {
//返回图标数据
options: {
data:[20],//水位位置
shape:'rect',//水位图形状
colors: [],//水位图配色
waveNum: 3,//波浪数量
waveHeight: 40,//波浪高度
waveOpacity: 40,//波浪透明度
formatter: '{value}%'//信息格式化
},
optionsStyle: {}, // 样式
optionsData: {}, // 数据
optionsCollapse: {}, // 图标属性
optionsSetup: {},
flagInter: null,
isRouterAlive:true
};
},
provide(){
return{
reload:this.reload
}
},
beforeDestroy() {
clearInterval(this.flagInter);
},
computed: {
...mapState('dataSource', ['staticData','staticRefreshTime']),
styleObj() {
const style = {
position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + "px",
height: this.optionsStyle.height + "px",
left: this.optionsStyle.left + "px",
top: this.optionsStyle.top + "px",
background: this.optionsSetup.background
};
if(this.optionsSetup.isOutShow){
let borderRadius = 0;
if(this.optionsSetup.shape=='rect'){
borderRadius = 0;
}else if(this.optionsSetup.shape=='roundRect'){
borderRadius = 3;
}else if(this.optionsSetup.shape=='round'){
borderRadius = 50;
}
const border = this.optionsSetup.outBorder +"px solid "+ this.optionsSetup.outBorderColor;
style.borderRadius= borderRadius+"%";
style['border']= border;
// console.log("style",style);
}
return style;
},
},
watch: {
value: {
handler(val) {
this.optionsStyle = val.position;
this.optionsData = val.data;
this.optionsSetup = val.setup;
this.editorOptions();
},
deep: true
}
},
created() {
this.optionsStyle = this.value.position;
this.optionsData = this.value.data;
this.optionsSetup = this.value.setup;
this.editorOptions();
},
methods: {
// 修改图标options属性
editorOptions() {
//颜色值修改
this.setOptionsColor();
//数据修改
this.setOptionsData();
//水位位置
this.showText();
},
// 颜色修改
setOptionsColor() {
const optionsSetup = this.optionsSetup;
const customColor = optionsSetup.customColor;
if (!customColor) return;
const arrColor = [];
for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color);
}
this.options.colors = arrColor;
this.options = Object.assign({}, this.options);
},
//水位位置
showText() {
const {slectedDataType} = this.optionsSetup;
let dataArray = this.getShowText();
if(this.isNotBlank(slectedDataType)){
const refreshTime = this.staticRefreshTime || 300000;
this.dynamicDataFn(refreshTime);
}else{
this.setShowText(dataArray);
}
},
getShowText() {
const {slectedDataType,waterLevelPondDataText} = this.optionsSetup;
let datav = this.staticData[slectedDataType] || waterLevelPondDataText;
return this.isNotBlank(datav)?datav.toString().split(","):[0];
},
setShowText(dataArray) {
this.options.data = dataArray;
this.reload();
},
// 数据修改
setOptionsData() {
const optionsSetup = this.optionsSetup;
this.options.shape=optionsSetup.shape;//水位图形状
this.options.waveHeight=optionsSetup.waveHeight;//波浪高度
let waveOpacity = optionsSetup.waveHeight||0;
this.options.waveOpacity= waveOpacity/100;//波浪透明度
this.options.formatter = optionsSetup.formatter;
this.options.waveNum = optionsSetup.waveNum;//波浪数量
},
//定时动态数据获取
dynamicDataFn(refreshTime) {
if (this.ispreview) {
this.flagInter = setInterval(() => {
this.getEchartData();
}, refreshTime);
} else {
this.getEchartData();
}
},
getEchartData() {
const dataArray = this.getShowText();
this.setShowText(dataArray);
},
// vue hack 之强制刷新组件
reload(){
this.isRouterAlive=false;
this.$nextTick(function(){
this.isRouterAlive=true;
})
},
}
};
</script>
<style scoped lang="scss">
.echarts {
width: 100%;
height: 100%;
overflow: hidden;
}
//.dv-water-pond-level {
// //max-width: 90%;
// border: 10px solid #19c3eb;
// border-radius: 50%;
// //ellipse {
// // stroke: transparent !important;
// //}
// //
// //text {
// // font-size: 40px;
// //}
//}
</style>