Browse Source

更新文档 ,注释

master
谕仙 2 years ago
parent
commit
3469960e57
  1. 8
      lpro/src/main/webapp/page/visual/index.html
  2. 93
      lpro/src/main/webapp/page/visual/js/cfg.js
  3. BIN
      开发文档/开发辅助文档.docx

8
lpro/src/main/webapp/page/visual/index.html

@ -1015,7 +1015,7 @@
<input class="el-input__inner" type="number" v-model="pimax" placeholder="刻度最大值" style="width:75%;" @change="changePiMax"> <input class="el-input__inner" type="number" v-model="pimax" placeholder="刻度最大值" style="width:75%;" @change="changePiMax">
</div> </div>
</div> </div>
<!-- 仪表盘刻度最--> <!-- 仪表盘刻度最-->
<div v-show="editType == 5 && (cid == 5||cid==6) "> <div v-show="editType == 5 && (cid == 5||cid==6) ">
<div class="tool-title " style="padding: 10px;">仪表盘刻度最小值</div> <div class="tool-title " style="padding: 10px;">仪表盘刻度最小值</div>
<div style="padding-left: 10px;"> <div style="padding-left: 10px;">
@ -1038,7 +1038,7 @@
</div> </div>
</div> </div>
<!-- 折线图,柱状图,饼状图切换 --> <!-- 折线图,柱状图切换 -->
<div class="functionDetails" v-show="nid==5 && cid < 4 "> <div class="functionDetails" v-show="nid==5 && cid < 4 ">
<span> <span>
图表设置 图表设置
@ -1059,7 +1059,6 @@
<el-select v-model="cid" placeholder="请选择类型" @change="changeChartData" > <el-select v-model="cid" placeholder="请选择类型" @change="changeChartData" >
<el-option :value="1" label="折线图"></el-option> <el-option :value="1" label="折线图"></el-option>
<el-option :value="2" label="柱形图"></el-option> <el-option :value="2" label="柱形图"></el-option>
<el-option :value="3" label="饼状图"></el-option>
</el-select> </el-select>
</div> </div>
</div> </div>
@ -2004,6 +2003,7 @@
cl.attr("pi-rect",JSON.stringify( this.piRect)); cl.attr("pi-rect",JSON.stringify( this.piRect));
updateChartsOptions(new Map([["startAngle",value[0]],["endAngle",value[1]]])); updateChartsOptions(new Map([["startAngle",value[0]],["endAngle",value[1]]]));
}, },
// 修改预设角度
changeAngleStyle(){ changeAngleStyle(){
var cl = cfg.current_edit_obj ; var cl = cfg.current_edit_obj ;
if(this.angleStyle=="style1"){ if(this.angleStyle=="style1"){
@ -2019,10 +2019,12 @@
cl.attr("angle-style",this.angleStyle); cl.attr("angle-style",this.angleStyle);
}, },
// 修改开始角度
changeStartAngle(e){ changeStartAngle(e){
this.piRect=[Number(e.target.value),this.piRect[1]]; this.piRect=[Number(e.target.value),this.piRect[1]];
this.changePiRect(this.piRect); this.changePiRect(this.piRect);
}, },
// 修改结束角度
changeEndAngle(e){ changeEndAngle(e){
this.piRect=[this.piRect[0],Number(e.target.value)]; this.piRect=[this.piRect[0],Number(e.target.value)];
this.changePiRect(this.piRect); this.changePiRect(this.piRect);

93
lpro/src/main/webapp/page/visual/js/cfg.js

@ -94,6 +94,7 @@ var cfg = {
return deg>=360?0:deg; return deg>=360?0:deg;
}, },
// 拖拽克隆元素到画布的方法
elementDragCopyInfo :function(selector){ elementDragCopyInfo :function(selector){
$(selector).droppable({ $(selector).droppable({
activeClass: "ui-state-default", activeClass: "ui-state-default",
@ -220,7 +221,6 @@ var cfg = {
}) })
}, },
generateNewNode:function(obj,style){ generateNewNode:function(obj,style){
console.log('generateNewNode');
//新节点 添加属性 更新全局变量 //新节点 添加属性 更新全局变量
obj.attr("id","node"+ this.zIndexT); //用于标识唯一 obj.attr("id","node"+ this.zIndexT); //用于标识唯一
style['z-index'] = this.zIndexT; style['z-index'] = this.zIndexT;
@ -1105,25 +1105,36 @@ function updateChartsOptions(modiflyMap){
const option=JSON.parse(optionStr); const option=JSON.parse(optionStr);
const nid=current_edit_obj.attr("nid"); const nid=current_edit_obj.attr("nid");
const cid=current_edit_obj.attr("cid"); const cid=current_edit_obj.attr("cid");
// 在液压表的时候添加formatter属性,360度时候,因为0和100重合故而不显示0,界面上显示为整数
if(nid=="5"&&cid=="6"){ if(nid=="5"&&cid=="6"){
const rectAttr=current_edit_obj.attr("pi-rect"); const rectAttr=current_edit_obj.attr("pi-rect");
// 获取开始角和结束角
const rect=JSON.parse(rectAttr); const rect=JSON.parse(rectAttr);
// 最大角度
const max_m= Math.max(...rect); const max_m= Math.max(...rect);
// 最小角度
const min_m= Math.min(...rect); const min_m= Math.min(...rect);
let isCircle=null; let isCircle=null;
// 因取值范围为[-360,360],故最大值小于0,不是圆
if(max_m<0){ if(max_m<0){
isCircle=false; isCircle=false;
// 因取值范围为[-360,360],故最小值大于0,不是圆
}else if(min_m>0){ }else if(min_m>0){
isCircle=false; isCircle=false;
}else{ }else{
// 判断最大值减最小值的绝对值是否等于360度,已判断是否为圆
isCircle=Math.abs(rect[0])+Math.abs(rect[1])==360; isCircle=Math.abs(rect[0])+Math.abs(rect[1])==360;
} }
// 最小刻度
const pimin=Number(current_edit_obj.attr('pimin')); const pimin=Number(current_edit_obj.attr('pimin'));
// 是否是一个圆(360度)
if(isCircle){ if(isCircle){
option.series[0].axisLabel.formatter=function (value){ option.series[0].axisLabel.formatter=function (value){
// 值等于最小刻度,则不显示
if(value==pimin){ if(value==pimin){
return ; return ;
} }
// 显示整数
return Number(value).toFixed(0); return Number(value).toFixed(0);
}; };
}else { }else {
@ -1134,31 +1145,37 @@ function updateChartsOptions(modiflyMap){
} }
// 获取地图 // 获取地图
var chart = getEchartObj(); var chart = getEchartObj();
// 要修改的属性集合
if(modiflyMap.size>0){ if(modiflyMap.size>0){
modiflyMap.forEach( modiflyMap.forEach(
(value,key,map)=>{ (value,key,map)=>{
// 调用修改属性方法
analysisProp(option,key,value); analysisProp(option,key,value);
} }
) )
} }
// 写入属性 // 写入元素属性
optionNode.setAttribute("option",JSON.stringify(option)); optionNode.setAttribute("option",JSON.stringify(option));
// 更新地图 // 更新地图
chart.setOption(option); chart.setOption(option);
} }
// 解析属性并更改方法
function analysisProp(option,propName,value){ function analysisProp(option,propName,value){
if(propName){ if(propName){
// 解析属性名是否是顶级属性,或者多级属性。例如: 顶级属性 xxx 多级属性 xxx.a.c
const propertys=propName.split('.'); const propertys=propName.split('.');
const pLen=propertys.length; const pLen=propertys.length;
// 固定更改第一个echar对象数据
let data=option.series[0]; let data=option.series[0];
let finally_obj=null; let finally_obj=null;
// 顶级属性修改
if(propertys.length==1){ if(propertys.length==1){
data[propName]=value; data[propName]=value;
return; return;
} }
// 多级属性修改
for (let i=0;i<pLen;i++){ for (let i=0;i<pLen;i++){
const propertyName=propertys[i]; const propertyName=propertys[i];
if(i==pLen-1){ if(i==pLen-1){
@ -1175,76 +1192,6 @@ function analysisProp(option,propName,value){
} }
} }
function objectToString(obj){
let typeStr=Object.prototype.toString.call(obj);
if(typeStr!="[object Object]"&&typeStr!="[object Array]"){
if(typeStr=="[object String]"){
return "\""+obj.toString()+"\"";
}else if(typeStr=="[object Function]"){
return obj.toString().replaceAll(/\n|\t/g,"");
}else{
return obj.toString();
}
}else if(typeStr=="[object Object]"){
let keys=Object.keys(obj);
let keyLen=keys.length;
let finallyStr="{";
for (let i=0;i<keyLen;i++){
let propertyName=keys[i];
let propertyValue=obj[propertyName];
typeStr=Object.prototype.toString.call(propertyValue);
if(typeStr=="[object Object]"){
let objStr=objectToString(propertyValue);
finallyStr+=(propertyName+":"+objStr);
}else if(typeStr=="[object Array]"){
finallyStr+=propertyName+":";
finallyStr+=objectToString(propertyValue);
}else{
finallyStr+=(propertyName+":"+objectToString(propertyValue)+"");
}
if(i!=keyLen-1){
finallyStr+=",";
}
}
return finallyStr+="}";
}else if(typeStr=="[object Array]"){
let finallyStr="[";
let c=0;
let cMax=obj.length-1;
for (const one of obj) {
finallyStr+=objectToString(one);
if(c!=cMax){
finallyStr+=",";
}
c++;
}
return finallyStr+="]";
}
}
function stringToObject(str){
if(str){
}
}
// 修改echart 第一个series属性;示例:
// args: property max
// value 1000
function changeChartOption1(property,value){
var chart = getEchartObj();
var newOp={...option,series:[...option.series]};
newOp.series[0][property]=value;
chart.setOption(newOp);
}
// 修改echart 第一个series单个/多个属性;示例:
// args: {startAngle:-45,endAngle:225}
function changeChartOption(obj){
var chart = getEchartObj();
var newOp={...option,series:[...option.series]};
newOp.series[0]={...newOp.series[0],...obj};
chart.setOption(newOp);
}
//管道图 //管道图
function initSensorPipelineChart(type){ function initSensorPipelineChart(type){
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例

BIN
开发文档/开发辅助文档.docx

Binary file not shown.
Loading…
Cancel
Save