解析模块的数据传不到逻辑模块

SampleTime.prototype.getSampleStateBySampleNo是数据解析模块;SampleTime是JS交互逻辑模块;SampleTime.prototype._setSampleNo是关联模块;
关联模块传输数据到解析模块是正常的,但是传输到交互模块就没数据了,本来调用存储过程是正常的,代码量有些大,不便之处多多海涵,同事说this的指向有问题,但不知道怎么修改
所有代码://JScript文件
functionSampleTime(){
vartimes=this._rowsData;
console.log(times);
//计算宽度,总和:
vartotals=0;
for(vartotal=0;totaltotals+=times[total];
}
varfirstTimes=[];
for(varf=0;fif(times[f]!=0){
firstTimes.push(Math.round(100/totals*times[f])+'%');
}else{
firstTimes.push('0%');
}
}
varlist=[
['采样',times[0]],
['送检',times[1]],
['签收',times[2]],
['已登记',times[3]],
['IOM',times[4]],
['离心',times[5]],
['去盖',times[6]],
['测试中',times[7]],
['已上传',times[8]],
['已发送',times[9]]
];
varcontainer=document.querySelector('.container');
vartimeBox=document.querySelector('.timeBox');
//横向:
var_htmlLine='

耗时

';
//纵向
var_htmlParallel='

耗时明细

'
for(varj=0;j//横向:
_htmlLine+=
''+
'

';

if(firstTimes[j]!=='0%'){
_htmlLine+=list[j][1];
}
_htmlLine+='

'+
'

';

if(firstTimes[j]!=='0%'){
_htmlLine+=list[j][0];
}
_htmlLine+='

';
//纵向:
_htmlParallel+=
''+
'

';

if(firstTimes[j]!=='0%'){
_htmlParallel+=list[j][0];
}
_htmlParallel+='

'+
'

';

if(firstTimes[j]!=='0%'){
_htmlParallel+='时间:'+this.Gos[0];
}
_htmlParallel+='

';
if(firstTimes[j]!=='0%'){
_htmlParallel+='描述:'+this.Gos[1];
}
_htmlParallel+='
'
}
container.innerHTML=_htmlLine;
timeBox.innerHTML=_htmlParallel;
//TAT
varrounds=document.querySelector('div.round');
var_watchHtml='';
this._valueDatas.forEach(function(value,index,array){
value=eval('('+value+')');
//console.log(value)
varmaxTat=value.c3text;
varfwcTat=value.c4text;
vardifTat=(maxTat-fwcTat);
varcolors=difTat/maxTat;
var_valueLengths=value.c3text.length;
_watchHtml+=''
varwat=document.createElement('div');
wat.setAttribute('class','watchBox');
wat.innerHTML='';
//rounds.innerHTML=_watchHtml;
rounds.appendChild(wat)
//仪表盘配置参数
varwatch=echarts.init(document.querySelector('.w'+index));
varoption={
toolbox:{
show:false
},
tooltip:{
formatter:"{a}
{b}:{c}%"
},
textStyle:{
fontSize:8,
},
series:[
{
type:'gauge',
radius:'100%',
clockwise:true,
splitNumber:_valueLengths,
center:[110,90],
min:0,
max:Math.round(value.c3text),
detail:{
formatter:'{value}min',
fontSize:10,
offsetCenter:['0%','60%']
},
data:[{value:difTat}],
axisLine:{
show:true,
lineStyle:{
color:[
[colors,'#29b6f6'],
[fwcTat/maxTat,'#ffa726'],
[1,'#f44336'],
]
}
},
splitLine:{
show:false
},
axisLabel:{
distance:5,
fontSize:10,
formatter:function(v){
returnv.toFixed(0);
},
},
pointer:{
show:true,
length:'60%',
width:5,
}
}
]
}
watch.setOption(option);
})
//console.log(this._datas)
//条形图
varline=echarts.init(document.getElementById('line'));
line.showLoading();//加载数据时动画显示
line.setOption({
title:{
text:'测试项所花时间',
top:'10%',
textStyle:{
color:'#9c27b0',
fontSize:18
}
},
tooltip:{
//trigger:'axis',//放大镜
axisPointer:{
type:'shadow'
}
},
grid:{
left:'0%',
right:'0%',
bottom:'0%',
containLabel:true
},
xAxis:{
type:'value',
boundaryGap:[0,0.5],
minInterval:1,
},
yAxis:{
type:'category',
data:this._values,
axisTick:{
alignWithLabel:true,
}
},
series:[
{
name:'选项之间所花时间',
type:'bar',
data:this._datas,
}
]
})
line.hideLoading();//加载完毕后隐藏
}
//調用標本信息SampleTime.prototype._setSampleNo=function(nSampleNo){
//清除表数据
this._tableLogInfo=null;
//alert(nSampleNo);
SampleTime.prototype.getSampleStateBySampleNo(nSampleNo);
SampleTime();
}
//交互模塊,柱状图横向纵向时间轴SampleTime.prototype.getSampleStateBySampleNo=function(p){
//console.log(p);
//横向存储过程
varRequest=Global.NewMessage();
Request.ProcedureName="[proc_datalink_getsample_module]";
Request.ParameterNames=["SampleNo"];
Request.ParameterDataTypes=["int"];
Request.ParameterValues=[p||1]
//PostMessage异步需回调
varReturn=Global.SendMessage("DB_CallProcedure",Request);
varReturns=Return.Table0;
//console.log(Returns)
this.rowsData=[];
this._rowsData=[];
this._rowsData=Returns._rowsData[0];
vardatas=[];
vartimes=[];
for(vardata=0;datatimes.push(this._rowsData[data]);
datas.push(newDate(this._rowsData[data]).getMinutes());
}
//分钟,柱状图横向时间轴
this._rowsData=datas;
console.log(this._rowsData)
//完整时间,纵向时间轴
this.rowsData=times;
this.rowsTime=[]
for(varw=0;wif(this.rowsData[w]!=null){
this.rowsTime.push(this.rowsData[w]);
}
}
//混合数组
this.dataValues=[
["采样",this._rowsData[0]],
["送检",this._rowsData[1]],
["签收",this._rowsData[2]],
["已登记",this._rowsData[3]],
["IOM",this._rowsData[4]],
["离心",this._rowsData[5]],
["去盖",this._rowsData[6]],
["测试中",this._rowsData[7]],
["已上传",this._rowsData[8]],
["已发送",this._rowsData[9]]
]
this.dataValues.sort(function(a,b){
returna[1]-b[1];
});
this._values=[];
this._datas=[];
for(vari=0;ithis._values.push(this.dataValues[i][0]);
this._datas.push(this.dataValues[i][1]);
}
//console.log(this._datas)
//纵向调用:
varRequests=Global.NewMessage();
Requests.ProcedureName="[proc_datalink_getsample_moduleinfo]";
Requests.ParameterNames=["SampleNo","SampleState"];
Requests.ParameterDataTypes=["int","int"];
Requests.ParameterValues=[400,420];
varGo=Global.SendMessage("DB_CallProcedure",Requests);
this.Gos=Go.Table0._rowsData[0];
//TAT仪表盘数据调用
varconfigType="machine";
varmoduleName="TATWarningCFG";
varconfigName="data";
varvalue=top.UniformConfig.readValue(configType,moduleName,configName,"");
if(value==""){
returnfalse;
}
this._valueDatas=JSON.parse(value).SearchCondition;
}SampleTime.prototype.getSampleStateBySampleNo(1);

			
侃侃尔雅
浏览 498回答 2
2回答

阿晨1998

functionSampleTime(){vartimes=this._rowsData;...this._valueDatas.forEach(...}//調用標本信息SampleTime.prototype._setSampleNo=function(nSampleNo){//清除表数据this._tableLogInfo=null;//alert(nSampleNo);SampleTime.prototype.getSampleStateBySampleNo(nSampleNo);//ASampleTime();//B}//交互模塊,柱状图横向纵向时间轴//定义初始值的吧SampleTime.prototype.getSampleStateBySampleNo=function(p){...this.rowsData=[];this._rowsData=[];this._rowsData=...}SampleTime.prototype.getSampleStateBySampleNo(1);//C1.为什么要用prototype来定义方法,直接函数不好么?2.既然要用prototype来访定义方法,那就好好使用JS面向对象的方法问题出在:C处代码调用时的this为SampleTime函数对象的prototype属性对象A处代码调用时的this为SampleTime函数对象的prototype属性对象B处代码调用时的this为全局对象那么也即是所你在C、A处设置的参数,对B处的函数体代码来说完全没有用看下下面代码,你就会明白:functionTEST(){this._p="TEST";console.log("this_p1:"+this._p1);console.log("this_p2:"+this._p2);}TEST.prototype.fun1=function(){this._p="fun1";}TEST.prototype._run_=function(){TEST.prototype.fun1();TEST();}TEST.prototype.fun1=function(){this._p1="fun1";}TEST.prototype.fun2=function(){this._p2="fun2";}TEST.prototype.fun2();TEST.prototype._run_();//this_p1:undefined//this_p2:undefinedconsole.log(TEST.prototype._p1);//fun1console.log(TEST.prototype._p2);//fun2console.log(this._p);//TEST
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript