<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><SCRIPT LANGUAGE="JavaScript">
if(top == self){ if(opener && opener && opener.top && opener.top.core) window.core = opener.top.core;else document.write('<script src="Jsvm.suk"></'+'script>');}else{core = top.core}</script><script>try{var s = core.getId();}catch(e){alert("主窗口已经关闭,请重新登陆");window.close();}eval("System = "+core.System);sys = new System();</script><style>
td{font-size:14.8px}
</style>
<script> DataMap = function(){
this.set = new DataMap.Set();
// this.column = new Array(); this.data = null;
this.groupData = null; //排序后的数据表
this.group = null; //分组信息
this.column_group = new Array(); //每列的组信息
this.row_group = null; //每行的组信息
this.point = 0;
}
DataMap.SUM = function(data,column,start,end){
var value = 0;
for(var i=start;i<end;i++){
var t = data[i][column];
if(isNaN(t) && isNaN(parseFloat(t)))
return "--";
value += parseFloat(t);
}
return value;
}DataMap.prototype.load = function(xmlDoc){
this.set.load( xmlDoc);
var nodeMap = xmlDoc.selectSingleNode("//group");
if(nodeMap){
nodeMap = nodeMap.childNodes;
var groupLength = nodeMap.length;
var node;
this.s_group = new Array();
for(var i=0;i<groupLength;i++){
node=nodeMap.nextNode();
var group = new DataMap.Group(node.getAttribute("column"));
group.func = node.getAttribute("func");
group.desc = node.getAttribute("desc");
this.s_group[i] = group;
}
}
}DataMap.prototype.pushGroup = function(map){
for(var i=0;i<this.row_group.length;i++){
map.append("<tr bgcolor=ffffff height=21>");
var tmpRow = this.groupData[i]; for(var j=0;j<tmpRow.length;j++){
if(this.column_group[j]){
if(!this.column_group[j].started){
var thisgroup = this.column_group[j];
var rowspan= thisgroup.getRowCount(0);
thisgroup.started = true;
thisgroup.head = i;
thisgroup.title = this.groupData[i][j];
map.append('<td rowspan="'+rowspan+'">');
map.append(thisgroup.title);
map.append("</td>");
}
}else{
map.append('<td>');
map.append(this.groupData[i][j]);
map.append("</td>");
}
}
map.append("</tr>");
if(this.row_group[i] != null){
var nowGroup = this.group[this.group.length -1];
while(nowGroup != null){
if(nowGroup.func != null){
map.append("<tr bgcolor=ffffff height=21>");
for(var j=0;j<tmpRow.length;j++){
if(j < nowGroup.column){
if(!this.column_group[j])
map.append('<td>--</td>');
}else if(nowGroup.column ==j){
map.append('<td>'+nowGroup.title+'</td>');
}else{
map.append('<td>'+DataMap[nowGroup.func](this.groupData,j,nowGroup.head,(nowGroup.row_group[nowGroup.point] + nowGroup.head))+'</td>');
}
}
map.append("</tr>");
}
if(nowGroup == this.group[this.row_group[i]])
break;
nowGroup = nowGroup.parents;
}
nowGroup.reset();
}
}
}
DataMap.prototype.push = function(map){
if(this.group && this.group.length > 0){
this.pushGroup(map);
return;
}else{
for(var i=0;i<this.data.length;i++){
map.append("<tr bgcolor=ffffff height=21>");
for(var j=0;j<this.data[i].length;j++){
map.append('<td>'+this.data[i][j]+'</td>');
}
map.append("</tr>");
}
}
}DataMap.prototype.setColumn = function(str){
this.data = this.set.getData(str);
this.groupData = new Array(); //排序后的数据表
this.row_group = new Array(); //每行的组信息
this.point = 0;
this.process();
}
DataMap.prototype.process = function(layer,arr){
if(!this.group || this.group.length==0)
return;
if(!layer){
layer=0;
arr = new Array();
for(var i=0;i<this.data.length;i++){
arr[i] = i;
}
} var key = new Object();
var group = this.group[layer];
var groupLength = this.group.length;
var temp;
for(var i=0,n=arr.length;i<n;i++){
temp = this.data[arr[i]][group.column];
if(!key[temp])
key[temp] = new Array();
key[temp][key[temp].length] = arr[i];
}
var isNumber = true;
var indexBox = new Array();
for(var m in key){
indexBox[indexBox.length] = m;
} indexBox = indexBox.sort(); if(group.desc)
indexBox = indexBox.reverse(); if(group.parents)
group.parents.childs[group.parents.childs.length] = indexBox.length; for(var i=0;i<indexBox.length;i++){
var newArr = key[indexBox[i]];
group.row_group[group.row_group.length] = newArr.length;
if(layer == groupLength-1){
this.point += newArr.length;
for(var x=0;x<newArr.length;x++){
this.groupData[this.groupData.length]=this.data[newArr[x]];
}
}else{
this.process(layer+1,newArr);
}
this.row_group[this.point-1] = layer;
}
}DataMap.prototype.addGroup = function(group){
group.recycle();
this.group[this.group.length] = group;
this.column_group[group.column] = group;
if(this.group.length > 1){
this.group[this.group.length-2].child = group;
group.parents = this.group[this.group.length-2];
}
}DataMap.Group = function(i){
this.column = i; this.func = null;
this.desc = false;
this.showlist = true;
}DataMap.Group.prototype.recycle = function(){
this.child = null;
this.parents = null;
this.childs = new Array(); //子分组指针
this.row_group = new Array(); //每个分组的数据行数 this.point = 0;
this.htmlRowCount = 0;
this.started = false; //是否写入头
}
<HEAD>
<TITLE> New Document </TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><SCRIPT LANGUAGE="JavaScript">
if(top == self){ if(opener && opener && opener.top && opener.top.core) window.core = opener.top.core;else document.write('<script src="Jsvm.suk"></'+'script>');}else{core = top.core}</script><script>try{var s = core.getId();}catch(e){alert("主窗口已经关闭,请重新登陆");window.close();}eval("System = "+core.System);sys = new System();</script><style>
td{font-size:14.8px}
</style>
<script> DataMap = function(){
this.set = new DataMap.Set();
// this.column = new Array(); this.data = null;
this.groupData = null; //排序后的数据表
this.group = null; //分组信息
this.column_group = new Array(); //每列的组信息
this.row_group = null; //每行的组信息
this.point = 0;
}
DataMap.SUM = function(data,column,start,end){
var value = 0;
for(var i=start;i<end;i++){
var t = data[i][column];
if(isNaN(t) && isNaN(parseFloat(t)))
return "--";
value += parseFloat(t);
}
return value;
}DataMap.prototype.load = function(xmlDoc){
this.set.load( xmlDoc);
var nodeMap = xmlDoc.selectSingleNode("//group");
if(nodeMap){
nodeMap = nodeMap.childNodes;
var groupLength = nodeMap.length;
var node;
this.s_group = new Array();
for(var i=0;i<groupLength;i++){
node=nodeMap.nextNode();
var group = new DataMap.Group(node.getAttribute("column"));
group.func = node.getAttribute("func");
group.desc = node.getAttribute("desc");
this.s_group[i] = group;
}
}
}DataMap.prototype.pushGroup = function(map){
for(var i=0;i<this.row_group.length;i++){
map.append("<tr bgcolor=ffffff height=21>");
var tmpRow = this.groupData[i]; for(var j=0;j<tmpRow.length;j++){
if(this.column_group[j]){
if(!this.column_group[j].started){
var thisgroup = this.column_group[j];
var rowspan= thisgroup.getRowCount(0);
thisgroup.started = true;
thisgroup.head = i;
thisgroup.title = this.groupData[i][j];
map.append('<td rowspan="'+rowspan+'">');
map.append(thisgroup.title);
map.append("</td>");
}
}else{
map.append('<td>');
map.append(this.groupData[i][j]);
map.append("</td>");
}
}
map.append("</tr>");
if(this.row_group[i] != null){
var nowGroup = this.group[this.group.length -1];
while(nowGroup != null){
if(nowGroup.func != null){
map.append("<tr bgcolor=ffffff height=21>");
for(var j=0;j<tmpRow.length;j++){
if(j < nowGroup.column){
if(!this.column_group[j])
map.append('<td>--</td>');
}else if(nowGroup.column ==j){
map.append('<td>'+nowGroup.title+'</td>');
}else{
map.append('<td>'+DataMap[nowGroup.func](this.groupData,j,nowGroup.head,(nowGroup.row_group[nowGroup.point] + nowGroup.head))+'</td>');
}
}
map.append("</tr>");
}
if(nowGroup == this.group[this.row_group[i]])
break;
nowGroup = nowGroup.parents;
}
nowGroup.reset();
}
}
}
DataMap.prototype.push = function(map){
if(this.group && this.group.length > 0){
this.pushGroup(map);
return;
}else{
for(var i=0;i<this.data.length;i++){
map.append("<tr bgcolor=ffffff height=21>");
for(var j=0;j<this.data[i].length;j++){
map.append('<td>'+this.data[i][j]+'</td>');
}
map.append("</tr>");
}
}
}DataMap.prototype.setColumn = function(str){
this.data = this.set.getData(str);
this.groupData = new Array(); //排序后的数据表
this.row_group = new Array(); //每行的组信息
this.point = 0;
this.process();
}
DataMap.prototype.process = function(layer,arr){
if(!this.group || this.group.length==0)
return;
if(!layer){
layer=0;
arr = new Array();
for(var i=0;i<this.data.length;i++){
arr[i] = i;
}
} var key = new Object();
var group = this.group[layer];
var groupLength = this.group.length;
var temp;
for(var i=0,n=arr.length;i<n;i++){
temp = this.data[arr[i]][group.column];
if(!key[temp])
key[temp] = new Array();
key[temp][key[temp].length] = arr[i];
}
var isNumber = true;
var indexBox = new Array();
for(var m in key){
indexBox[indexBox.length] = m;
} indexBox = indexBox.sort(); if(group.desc)
indexBox = indexBox.reverse(); if(group.parents)
group.parents.childs[group.parents.childs.length] = indexBox.length; for(var i=0;i<indexBox.length;i++){
var newArr = key[indexBox[i]];
group.row_group[group.row_group.length] = newArr.length;
if(layer == groupLength-1){
this.point += newArr.length;
for(var x=0;x<newArr.length;x++){
this.groupData[this.groupData.length]=this.data[newArr[x]];
}
}else{
this.process(layer+1,newArr);
}
this.row_group[this.point-1] = layer;
}
}DataMap.prototype.addGroup = function(group){
group.recycle();
this.group[this.group.length] = group;
this.column_group[group.column] = group;
if(this.group.length > 1){
this.group[this.group.length-2].child = group;
group.parents = this.group[this.group.length-2];
}
}DataMap.Group = function(i){
this.column = i; this.func = null;
this.desc = false;
this.showlist = true;
}DataMap.Group.prototype.recycle = function(){
this.child = null;
this.parents = null;
this.childs = new Array(); //子分组指针
this.row_group = new Array(); //每个分组的数据行数 this.point = 0;
this.htmlRowCount = 0;
this.started = false; //是否写入头
}
if(this.htmlRowCount > 0)
return this.htmlRowCount;
if(this.child == null){
return this.row_group[this.point+c];
} var count = 0;
for(var i=0;i<this.childs[this.point];i++){
if(this.child.func != null)
count+=1;
count+= this.child.getRowCount(i);
}
this.htmlRowCount = count;
return count;
}DataMap.Group.prototype.reset = function(){
this.point++;
this.htmlRowCount = 0;
this.started = false;
if(this.child != null)
this.child.reset();
}
DataMap.Set = function(){
this.width = 0;
this.length = 0;
this._data = new Array();
this.match = new Array();
this.column = new Object();
this.user_name = new Object();
}
DataMap.Set.prototype.load = function(xmldoc){
var nodeMap = xmlDoc.selectSingleNode("//head").childNodes;
this.width = nodeMap.length;
var node;
var type = new Array();
for(var i=0;i<this.width;i++){
node=nodeMap.nextNode();
this.column[node.getAttribute("name")] = i;
if( node.getAttribute("is_num") == 1)
type[i] = true;
this._data[i] = new Array();
}
var tmpdata = null;
nodeMap = xmlDoc.selectSingleNode("//data").childNodes;
this.length = nodeMap.length;
for(var i=0;i<this.length;i++){
var nodes = nodeMap.nextNode().childNodes;
for(var j=0,n=nodes.length;j<n;j++){
tmpdata = nodes.nextNode().text;
if(type[j]){
if(tmpdata=="")
this._data[j][i] = 0;
else this._data[j][i] = parseFloat(tmpdata);
}else {
if(!tmpdata) this._data[j][i] = "--";
else this._data[j][i] = tmpdata;
}
}
}
for(var i in this.column){
this.column[i] = this._data[this.column[i]];
}
}DataMap.Set.prototype.getData = function(arr){ var data = new Array(this.length);
for(var i=0;i<arr.length;i++){
if(!arr[i])
continue;
if(arr[i] == "_identity"){
arr = new Array();
for(var j=0;j<this.length;j++)
arr[i][j]=j;
continue;
}
if(arr[i] == "_"){
for(var j=0;j<this.length;j++)
arr[i][j]="";
continue;
} if(arr[i].indexOf("[") == -1){
if(this.column[arr[i]])
arr[i] = this.column[arr[i]];
else arr[i] = null;
}else{
if(this.match[arr[i]]){
arr[i] = this.match[arr[i]];
}
else{
var evals = "",ev=arr[i];
var m=0;var m1=0;
while((m=ev.indexOf('[',m)) != -1){
evals+=ev.substring(m1,m);
evals+="this.column['";m++;m1=m;
}
evals += ev.substring(m1,ev.length);
ev = evals;
evals = "";
m=0;m1=0;
while((m=ev.indexOf(']',m)) != -1){
evals+=ev.substring(m1,m);
evals+="'][0]";m++;m1=m;
}
evals += ev.substring(m1,ev.length);
try{
eval(evals);
}catch(e){
alert(evals+"\n"+arr[i]+"算法输入错误!");
arr[i] = null;
}
if(arr[i] != null){
evals = evals.replace(/\]\[0\]/g,"][j]");
this.match[arr[i]] = new Array();
for(var j=0;j<this.length;j++){
this.match[arr[i]][j] = eval(evals);
}
arr[i] = this.match[arr[i]];
}
}
}
} for(var i=0;i<this.length;i++){
data[i] = new Array();
for(j=0;j<arr.length;j++){
if(arr[j])
data[i][j] = arr[j][i];
else
data[i][j] = "-";
}
}
return data;
}////////////////////////////////////////////////////////////////////////////////////////////
Report = function(dom){ this.map = null;
this.dataMap = new DataMap(); this.title = new Report.Title(this);
this.header = new Report.Head(this); var column = this.dataMap.set.column;
var map = new Map();
map.append('<table width=100%><tr bgcolor=ffffff><td','coladd',' width=30%></td><td','groupEdit',' width=70%></td></tr><tr bgcolor=ffffff><td','dom',' colspan=2></td></tr></table>');
map.finish(dom);
this.dom = map.getMap('dom');
this.editmap = map.getMap('editmap');
this.groupEditMap = map.getMap('groupEdit');}
Report.prototype.getXML = function(){
alert(this.header.getXML()+this.title.getXML())
}
Report.prototype.load = function(xmlDoc){
this.dataMap.load( xmlDoc.selectSingleNode("//datamap"));
this.header.load(xmlDoc.selectSingleNode("//header"));
var doc = xmlDoc.selectSingleNode("//title").firstChild;
if(doc)
this.title.root = Node.loadTreeXML(doc);
else{
for(i in this.dataMap.set.column){
var tmp = Node.newNode(this.title.root);
tmp.prop.title = i;
tmp.prop.col_name = i;
}
}
}Report.prototype.show = function(){
this.map = new Map();
this.map.append("<table bgcolor=#808080 cellspacing=2 cellpadding>"); if(this.title.change){
this.title.process();
var col = new Array();
var ll = this.title.lastLine;
if(this.dataMap.s_group){
for(var i=0;i<this.dataMap.s_group.length;i++){
if(this.dataMap.s_group[i]){
ll[this.dataMap.s_group[i].column].groups = this.dataMap.s_group[i];
}
}
delete this.dataMap.s_group
} this.dataMap.group = new Array();
this.dataMap.column_group = new Array();
for(var i=0;i<ll.length;i++){
col[i]=ll[i].prop.col_name;
if(ll[i].groups){
ll[i].groups.column = i;
this.dataMap.addGroup(ll[i].groups);
}
} this.dataMap.setColumn(col);
this.title.change = false;
}
this.header.push();
this.title.push();
this.dataMap.push(this.map); if(this.title.root.prop.sum == '1'){
var data = this.dataMap.data;
this.map.append("<tr bgcolor=ffffff>");
for(var i=0;i<data[0].length;i++){
if(i==0)
this.map.append("<td align=center>合计:</td>");
else
this.map.append("<td>"+DataMap.SUM(data,i,0,data.length)+"</td>");
}
this.map.append("</tr>");
}
this.map.finish(this.dom);
this.title.edit();
this.header.edit();
}Report.Head = function(report){
this.report = report;
this.title = "<b><font style='font-size:16px'>标题</font></b>";
this.left = "左侧文字";
this.right = "右侧文字";
}
Report.Head.prototype.getXML = function(){
return '<head title="'+this.title+'" left="'+this.left+'" right="'+this.right+'"/>';
}Report.Head.prototype.load = function(xmlDoc){
var title =xmlDoc.getAttribute("title");
var left = xmlDoc.getAttribute("left");
var right = xmlDoc.getAttribute("right");
if(title) this.title = title;
if(left) this.left = left;
if(right) this.right = right;
}Report.Head.prototype.push = function(){
var width = this.report.title.lastLine.length;
this.report.map.append("<tr bgcolor=ffffff height=20><td align=center ids=title colspan="+width,'head_0',"><div>"+this.title+"</div></td></tr><tr bgcolor=ffffff height=20>");
var left = parseInt(width/2);
this.report.map.append("<td align=left ids=left colspan="+left,'head_1',"><div>"+this.left+"</div></td>");
this.report.map.append("<td align=right ids=right colspan="+(width - left),'head_2',"><div>"+this.right+"</div></td></tr>");
}Report.Head.prototype.edit = function(){
var head = this;
for(var i=0;i<3;i++){
this.report.map.getMap("head_"+i).ondblclick=function(){
var tmp = this.childNodes[0];
tmp.innerHTML = '<input style="text-align: '+this.align+';border: 0;width:100%">';
var tmp1 = tmp.childNodes[0];
tmp1.ids = this.ids;
tmp1.value = head[this.ids];
tmp1.select();
tmp1.focus();
tmp1.onblur = function(){
head[this.ids] = tmp1.value;
tmp.innerHTML = tmp1.value;
head[this.ids] = tmp1.value;
alert(this.ids+""+head[this.ids])
}
tmp.onmousedown = function(){
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}
}
}////////////////////////////Report.Title = function(report){
this.report = report;
this.change = true; this.root = new Node();
this.lastLine = null;
this.layer = null; this.raster = new Report.Raster();
this.editor = new Report.Editor(report);
}
Report.Title.prototype.getXML = function(){
var sb = new StringBuffer();
sb.append("<title>\n");
sb.append(this.root.getTreeXML());
sb.append("\n</title>\n<group>\n");
var ll = this.lastLine;
for(var i=0;i<ll.length;i++){
if(ll[i].groups){
sb.append('<by column="'+i+'" func="'+(ll[i].groups.func ? ll[i].groups.func : "")+'" desc="'+(ll[i].groups.desc==1 ? 1:"")+'"/>\n');
}
}
sb.append("</group>");
return sb.toString();
}
[email protected]
可以给我一份么?
交个朋友
谢谢楼主。
[email protected]