1.从服务器获取数据:
export const queryChartsData =function(data) {
// return new Promise(function (resolve) {
// setTimeout(function () {
var URL_service =get_URL_service()+"reports/get_workflow_datas";//
eventBus.publish("progress.start");
if(data.listUser && data.listUser.dbValue){
var user_ids=data.listUser.dbValue.join(",")
}else{
user_ids="";
}
let typename=data.listDataType.dbValue;
var requestData=
{
"typename":data.listDataType.dbValue,
"start_date":data.startDate.dbValue,
"end_date":data.finishDate.dbValue,
"user_ids":user_ids
};
if (isEmptyOrNull(data.startDate.dbValue)) {
messagingService.showInfo("请选择开始日期");
return;
}
if (isEmptyOrNull(data.finishDate.dbValue )) {
messagingService.showInfo("请选择结束日期");
return;
}
if (isEmptyOrNull(data.listDataType.dbValue )) {
messagingService.showInfo("请选择数据类型");
return;
}
var xhr = new XMLHttpRequest();
xhr.open('POST', URL_service, false); // 第三个参数为false表示同步请求
xhr.setRequestHeader("Content-Type", "application/json");
try {
eventBus.publish("progress.start");
xhr.send(JSON.stringify(requestData));
eventBus.publish("progress.end");
if (xhr.status === 200) {
console.log(xhr.responseText);
resultData = JSON.parse(xhr.responseText);
if(isEmptyOrNull(resultData) ||resultData.length ==0){
messagingService.showError("未查询到数据!");
return;
}
errorMsg="";
//填充6个数组
if(typename=="DATA"){
chartDataMap.set("total", parseData(resultData.TOTAL,"DATA","TOTAL"));
chartDataMap.set("design", parseData(resultData.L8_DesignRevision,"DATA","图档"));
chartDataMap.set("part", parseData(resultData.L8_PartRevision,"DATA","物料"));
chartDataMap.set("doc", parseData(resultData.L8_DocumentRevision,"DATA","文档"));
chartDataMap.set("ecn", parseData(resultData.L8_ECN,"DATA","ECN"));
chartDataMap.set("pr", parseData(resultData.L8_PR,"DATA","PR"));
}
if(typename=="TASK"){
chartDataMap.set("total", parseData(resultData.TOTAL,"TASK","TOTAL"));
chartDataMap.set("make", parseData(resultData.MAKE,"TASK","制定"));
chartDataMap.set("review", parseData(resultData.REVIEW,"TASK","审核"));
chartDataMap.set("standard", parseData(resultData.STANDARD,"TASK","标准化"));
chartDataMap.set("control", parseData(resultData.CONTROL,"TASK","文控"));
chartDataMap.set("approve", parseData(resultData.APPROVE,"TASK","批准"));
}
if(!isEmptyOrNull(errorMsg)){
messagingService.showError(errorMsg);
}
//resolve(pieChartDataTotal.arrayOfSeriesDataForChart);
return chartDataMap.get("total").arrayOfSeriesDataForChart;
} else {
console.error('请求失败');
}
} catch (e) {
eventBus.publish("progress.end");
messagingService.showError(e.toString());
console.error('请求异常');
}
// }, 1000);
// });
};
2.显示数据