//選擇分類指標後賦值
function AfterSelDetailCode(sender,selectObjs,data)
{
var result = new Array();
var lstResult = <%=WgEvalClass.StrClientOprEntityList %>;
var lstOldResult = objArrClone(<%=WgEvalClass.StrClientOprEntityList %>);
for(var i in selectObjs)
{
var no = new Object();
no.indicatorCategoryCode = selectObjs[i].indicatorCategoryCode;
no.indicatorCategoryName = selectObjs[i].indicatorCategoryName;
no.indicatorCategoryId=selectObjs[i].id;
no.score=0;
if(!wisdom.isEmpty(selectObjs[i].parentIndicatorCategory_id)){
no.parentTemplateIndicatorCategoryId= selectObjs[i].parentIndicatorCategory_id;
}
else{
if(lstResult != null && lstResult.length > 0 && !wisdom.isEmpty(selectObjs[i].parentIndicatorCategory_indicatorCategoryCode)){
for(var numj in lstResult)
{
if(lstResult[numj].indicatorCategoryCode == selectObjs[i].parentIndicatorCategory_indicatorCategoryCode)
{
no.parentTemplateIndicatorCategoryId= lstResult[numj].id;
break;
}
}
}
else{
no.parentTemplateIndicatorCategoryId=null;
}
}
no.treePath = selectObjs[i].treePath;
no.treePathName = selectObjs[i].treePathName;
no.id = selectObjs[i].id;
no.tempId = selectObjs[i].id;
result.push(no);
lstOldResult.push(no);
if(!wisdom.isEmpty(no.treePath)){
var treepathlist = no.treePath.split('|');
for(var j in treepathlist)
{
var flag = false;
for(var seli in selectObjs)
{
if(treepathlist[j] == selectObjs[seli].indicatorCategoryCode)
{
flag = true;
break;
}
}
if(flag) continue;
for(var numi in data)
{
if(data[numi].indicatorCategoryCode == treepathlist[j]){
var oldFlag = false;
for(var oldi in lstOldResult)
{
if(lstOldResult[oldi].indicatorCategoryCode == data[numi].indicatorCategoryCode)
{
oldFlag = true;
break;
}
}
if(oldFlag) continue;
var obj = new Object();
obj.indicatorCategoryCode = data[numi].indicatorCategoryCode;
obj.indicatorCategoryName = data[numi].indicatorCategoryName;
obj.indicatorCategoryId=data[numi].id;
obj.treePath = data[numi].treePath;
obj.treePathName = data[numi].treePathName;
obj.id = data[numi].id;
obj.tempId = data[numi].id;
if(data[numi].parentIndicatorCategory_id == undefined || data[numi].parentIndicatorCategory_id == "undefined" || wisdom.isEmpty(data[numi].parentIndicatorCategory_id)){
obj.parentTemplateIndicatorCategoryId = null;
}else{
obj.parentTemplateIndicatorCategoryId = data[numi].parentIndicatorCategory_id;
}
result.push(obj);
lstOldResult.push(obj);
break;
}
}
}
}
}
ClearTreeDataSource("<%=WgEvalClass.ClientID %>");
WgEvalClass_StrClientClearSelfFun();
WgEvalClass_SupplierEvaluationTemplateIndicatorCategoryDto_OprEntityRowIndex = -1;
//MergeTree("<%=WgEvalClass.ClientID %>", result, false);
BindWsdTree("<%=WgEvalClass.ClientID %>", lstOldResult);
<%=WgEvalClass.StrClientOprEntityList %> = lstOldResult;
var treeDest= $find("<%=WgEvalClass.ClientID %>");
treeDest.datalist = lstOldResult;
if (treeDest.get_nodes() != null && treeDest.get_nodes().get_count() > 0) {
//默認選中第一個節點
var treeargs = new Object();
var node = treeDest.get_nodes().getNode(0);
treeargs.initNodeKey = node.get_value();
if (typeof (treeDest.treeRowSelectFun) != 'undefined') {
treeDest.treeRowSelectFun(treeDest, treeargs);
}
node.set_selected(true);
}
SetSerial();
}
//設置生成序列號
function SetSerial()
{
var indicatorcodes=<%=WgEvalClass.StrClientOprEntityList%>;
var serialNum = 1;
for(var n in indicatorcodes)
{
if(wisdom.isEmpty(indicatorcodes[n].parentTemplateIndicatorCategoryId))
{
indicatorcodes[n].serial = serialNum;
serialNum++;
setSerialNum(indicatorcodes[n],indicatorcodes);
}
}
var tree=$find("<%=WgEvalClass.ClientID%>");
if(tree != null && tree.get_selectedNode() != null)
{
var nodeValue = tree.get_selectedNode().get_value()
for(var n in indicatorcodes)
{
if(indicatorcodes[n].id == nodeValue)
{
<%= ChildClassPanel.StrSetCurrentEntityToControl%>(indicatorcodes[n]);
break;
}
}
}
}
function setSerialNum(obj,arrObj)
{
var serialNum = 1;
for(var n in arrObj)
{
if(obj.id == arrObj[n].parentTemplateIndicatorCategoryId)
{
arrObj[n].serial = obj.serial + "." + serialNum;
serialNum++;
setSerialNum(arrObj[n],arrObj)
}
}
}
作者“zhangjingjing”