easyui列表数据核对检查数据展示

1.easyui窗口内放置table列表

<div id="window_Id" class="easyui-window" title="异常参数列表展示" style="width:602px;height:493px;"
	 data-options="
	 closed:true,
	 maximizable:false,
	 resizable:true,
	 minimizable:false,
	 shadow:false,
	 inline:true,
	 left: 2,
	 top:226
	 ">
			<table id="report_List" class="easyui-datagrid" style="width:587px;height:452px" data-options="
				 striped:true,
				 rownumbers:true,
				 idField:'id',
				 fitColumns:true,
				 <%--作用:根据需要让某行数据颜色样式根据条件分割凸显出来--%>
				 rowStyler: function(index,row){
				  if (Object.keys(row).length > 0 &&row.name.indexOf('**')> -1){
					return 'background-color:#FF0000;color:#000000;';
				}
			}
			">
				<thead>
					<tr>
						<th data-options="field:'id',width:110,resizable:true,fixed:true,align:'center',halign:'center',hidden:true">隐藏序号</th>
						<th data-options="field:'name',width:180,resizable:true,fixed:true,align:'center',halign:'center'">参数名字</th>
						<th data-options="field:'referValue',width:185,resizable:true,fixed:true,align:'center',halign:'center'">参考值</th>
						<th data-options="field:'readValue',width:185,resizable:true,fixed:true,align:'center',halign:'center'">读取值</th>
					</tr>
				</thead>
			</table>
	</div>

2.核对参数一致状况

2.1 定义函数核对

function checkParamsStatus(Sample,samplingValueList,standardValueList,checkParamsString,errParamsList,errResult,count){
	let flag = false;
	switch (Sample) {
		case 1:SampleName="样本A";break;
		case 2:SampleName="样本B";break;
		default:errResult.push("未匹配到样本");break;
	}
	if (checkParamsString != undefined && checkParamsString.length > 0) {
		let checkParamsList = checkParamsString.split(",");
		let checkParamName ="";
		let refer ="" ;
		let checkParamValue ="";
		let errObject ={};
		for (let i = 0; i < checkParamsList.length; i++) {
			checkParamName = checkParamsList[i];
			if(checkParamName==undefined || checkParamName==''){
				errResult.push("第"+i+"采集样本参数名称为空");
			}else{
				//获取样本值和标准值
				samplingParamValue = samplingValueList.get(checkParamName);
				referStandardValue = standardValueList.get(checkParamName);

				if (isValueCheck == 1){//值核对或者字符核对
					samplingParamValue = samplingParamValue*1
					referStandardValue = referStandardValue*1
				}
				if ((samplingParamValue != referStandardValue) || referStandardValue == "" || samplingParamValue == "") {
					if (!flag){  	//判断分割的标志 不同的样本 第一次 永符号 区分不同的样本
						errObject.id = ++count;
						errObject.name = "***"+chkeckFrame+"***";
						errObject.referStandardValue = "***";
						errObject.samplingParamValue = "***";
						errObjectList.push(errObject);
						flag = true;
						errParamsList.push(chkeckFrame+"不一致");
					}
					errObject = {};
					errObject.id = ++count;
					errObject.name = checkParamName;
					errObject.referStandardValue = referStandardValue;
					errObject.samplingParamValue = samplingParamValue;
					errParamsList.push(errObject);
				}
			}
		}
	}else{
		errResult.push(chkeckFrame+"样本列表内容为空");
	}
}

2.2调用核对函数

function checkParamsResult (){
# 准备假设A组采集样本数据
let samplingValueListA = new Map()
samplingValueListA .set("111",111)
samplingValueListA .set("222",222)
samplingValueListA .set("333",333)
samplingValueListA .set("444",444)
# 准备假设B组采集样本数据
let samplingValueListB = new Map()
samplingValueListB.set("111",111)
samplingValueListB.set("222",222)
samplingValueListB.set("333",333)
samplingValueListB.set("444",444)

# 准备假设C组数据为标准值
let standardValueList = new Map()
standardValueList.set("111",111)
standardValueList.set("222",222)
standardValueList.set("333",333)
standardValueList.set("444",444)


# 将核对的参数名称以 逗号分割 选择核对参数名称
let  checkParamsString="111,222,333,444"
let errParamsList = new Array()   //定义在这目的是共用 
let errResult = new Array()
let count = -1
//样本A调用核对函数
checkParamsStatus(samplingValueListA,standardValueList,checkParamsString,errParamsList,errResult,count)
//样本B调用核对函数
checkParamsStatus(samplingValueListB,standardValueList,checkParamsString,errParamsList,errResult,count)
	let resultObject ={}
	resultObject.errResult = errResult;
	resultObject.errObjectList = errObjectList;	
}

	

2.2 取回核对结果页面展示

	let result = checkParamsResult(bz);//新架构参数核对
	if (result != undefined && result.errParamsList.length > 0) {
		$("#window_Id").window('open');
		$("#report_List").datagrid('unselectAll');
		$("#report_List").datagrid('loading');
		$("#report_List").datagrid('loadData',{total:result.errParamsList.length,rows:result.errParamsList});
		$("#report_List").datagrid('loaded');
		return  result.errResult;
	}

3.效果–红色为不同样本的分割

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/beiback/article/details/130980898