// JScript 文件
function SampleTime() {
var times = this._rowsData;
console.log(times);
//計算寬度,總和:
var totals = 0;
for (var total= 0;total < times.length;total++){
totals += times[total];
}
var firstTimes = [];
for (var f=0;f < times.length;f++){
if (times[f] != 0) {
firstTimes.push(Math.round(100/totals*times[f]) + '%');
}else{
firstTimes.push('0%');
}
}
var list = [
['采樣', times[0]],
['送檢', times[1]],
['簽收', times[2]],
['已登記', times[3]],
['IOM', times[4]],
['離心', times[5]],
['去蓋', times[6]],
['測試中', times[7]],
['已上傳', times[8]],
['已發(fā)送', times[9]]
];
var container = document.querySelector('.container');
var timeBox = document.querySelector('.timeBox');
//橫向:
var _htmlLine = '<p>耗時</p>';
//縱向
var _htmlParallel = '<p>耗時明細</p>'
for (var j = 0;j < list.length; j++) {
//橫向:
_htmlLine +=
'<div class="lineBox" style="width:'+ firstTimes[j] +'" > ' +
'<div class="top"><b>●</b><p>' ;
if(firstTimes[j]!=='0%') {
_htmlLine += list[j][1];
}
_htmlLine+= '</p></div>' +
'<div class="bottom"><p>';
if(firstTimes[j]!=='0%') {
_htmlLine += list[j][0];
}
_htmlLine+= '</p></div></div>';
//縱向:
_htmlParallel +=
'<div class="time" style="height:'+ firstTimes[j] +'">' +
'<div class="left"><b>●</b><P>';
if(firstTimes[j]!=='0%'){
_htmlParallel += list[j][0];
}
_htmlParallel += '</P></div>' +
'<div class="right"><p>';
if(firstTimes[j]!=='0%') {
_htmlParallel += '時間: ' + this.Gos[0];
}
_htmlParallel += '</p><span>';
if(firstTimes[j]!=='0%') {
_htmlParallel += '描述: ' + this.Gos[1];
}
_htmlParallel += '</span></div></div>'
}
container.innerHTML = _htmlLine;
timeBox.innerHTML = _htmlParallel;
//TAT
var rounds = document.querySelector('div.round');
var _watchHtml = '';
this._valueDatas.forEach(function (value,index,array) {
value = eval('('+ value +')');
//console.log(value)
var maxTat = value.c3text;
var fwcTat = value.c4text;
var difTat = (maxTat - fwcTat);
var colors = difTat/maxTat;
var _valueLengths = value.c3text.length;
_watchHtml += '<div class="watchBox"><div class="watch w'+index+'"></div></div>'
var wat=document.createElement('div');
wat.setAttribute('class','watchBox');
wat.innerHTML='<div class="watch w'+index+'"></div>';
// rounds.innerHTML = _watchHtml;
rounds.appendChild(wat)
//儀表盤配置參數(shù)
var watch = echarts.init(document.querySelector('.w'+index));
var option = {
toolbox: {
show: false
},
tooltip: {
formatter: "{a} <br/> : {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){
return v.toFixed(0);
},
},
pointer: {
show: true,
length: '60%',
width: 5,
}
}
]
}
watch.setOption(option);
})
//console.log(this._datas)
//條形圖
var line = echarts.init(document.getElementById('line'));
line.showLoading(); //加載數(shù)據(jù)時動畫顯示
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(); //加載完畢后隱藏
}
//調(diào)用標(biāo)本信息
SampleTime.prototype._setSampleNo = function( nSampleNo ) {
//清除表數(shù)據(jù)
this._tableLogInfo = null;
//alert(nSampleNo);
SampleTime.prototype.getSampleStateBySampleNo(nSampleNo);
SampleTime();
}
// 交互模塊,柱狀圖 橫向 縱向時間軸
SampleTime.prototype.getSampleStateBySampleNo = function (p) {
//console.log(p);
//橫向存儲過程
var Request = Global.NewMessage();
Request.ProcedureName = "[proc_datalink_getsample_module]";
Request.ParameterNames = ["SampleNo"];
Request.ParameterDataTypes = ["int"];
Request.ParameterValues = [p||1]
//PostMessage 異步需回調(diào)
var Return = Global.SendMessage("DB_CallProcedure", Request);
var Returns = Return.Table0;
//console.log(Returns)
this.rowsData = [];
this._rowsData = [];
this._rowsData = Returns._rowsData[0];
var datas = [];
var times = [];
for (var data = 0; data < this._rowsData.length; data++) {
times.push(this._rowsData[data]);
datas.push(new Date(this._rowsData[data]).getMinutes());
}
//分鐘,柱狀圖 橫向時間軸
this._rowsData = datas;
console.log(this._rowsData)
//完整時間,縱向時間軸
this.rowsData = times;
this.rowsTime = []
for (var w = 0;w < this.rowsData.length;w++){
if (this.rowsData[w] != null){
this.rowsTime.push(this.rowsData[w]);
}
}
//混合數(shù)組
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]],
["已發(fā)送", this._rowsData[9]]
]
this.dataValues.sort(function (a, b) {
return a[1] - b[1];
});
this._values = [];
this._datas = [];
for (var i = 0; i < this.dataValues.length; i++) {
this._values.push(this.dataValues[i][0]);
this._datas.push(this.dataValues[i][1]);
}
//console.log(this._datas)
//縱向調(diào)用:
var Requests = Global.NewMessage();
Requests.ProcedureName = "[proc_datalink_getsample_moduleinfo]";
Requests.ParameterNames = ["SampleNo","SampleState"];
Requests.ParameterDataTypes = ["int","int"];
Requests.ParameterValues = [400,420];
var Go = Global.SendMessage("DB_CallProcedure", Requests);
this.Gos = Go.Table0._rowsData[0];
//TAT儀表盤數(shù)據(jù)調(diào)用
var configType = "machine";
var moduleName = "TATWarningCFG";
var configName = "data";
var value = top.UniformConfig.readValue(configType, moduleName, configName, "");
if (value == "") {
return false;
}
this._valueDatas = JSON.parse(value).SearchCondition;
}
SampleTime.prototype.getSampleStateBySampleNo(1);
function SampleTime() {
var times = this._rowsData;
...
this._valueDatas.forEach(
...
}
//調(diào)用標(biāo)本信息
SampleTime.prototype._setSampleNo = function( nSampleNo ) {
//清除表數(shù)據(jù)
this._tableLogInfo = null;
//alert(nSampleNo);
SampleTime.prototype.getSampleStateBySampleNo(nSampleNo);//A
SampleTime();//B
}
// 交互模塊,柱狀圖 橫向 縱向時間軸
//定義初始值的吧
SampleTime.prototype.getSampleStateBySampleNo = function (p) {
...
this.rowsData = [];
this._rowsData = [];
this._rowsData =
...
}
SampleTime.prototype.getSampleStateBySampleNo(1);//C
1.為什么要用prototype來定義方法,直接函數(shù)不好么?
2.既然要用prototype來訪定義方法,那就好好使用JS面向?qū)ο蟮姆椒?/p>
問題出在:C處
代碼調(diào)用時的this為SampleTime函數(shù)對象的prototype屬性對象A處
代碼調(diào)用時的this為SampleTime函數(shù)對象的prototype屬性對象B處
代碼調(diào)用時的this為全局對象
那么也即是所你在C、A處設(shè)置的參數(shù),對B處的函數(shù)體代碼來說完全沒有用
看下下面代碼,你就會明白:
function TEST(){
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:undefined
console.log(TEST.prototype._p1);//fun1
console.log(TEST.prototype._p2);//fun2
console.log(this._p);//TEST
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團,成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負責(zé)iOS教學(xué)及管理工作。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。