- 浏览: 5555 次
- 性别:
- 来自: 深圳
文章分类
最新评论
用div构造的异步树
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.cnunisoft.uma.tableobject.TblOrganizationDto"%>
<%@page import="com.cnunisoft.uma.tableobject.TblAlarmconnectorDto"%>
<%@page import="com.cnunisoft.util.UtilTool"%>
<jsp:useBean id="localBean" scope="request" class="com.cnunisoft.uma.beans.LocalizationPackManager"/>
<jsp:useBean id="ptools" scope="request" class="com.cnunisoft.uma.action.ParameterTools"/>
<%
String mibDescUrl = (String)request.getAttribute("mibDescUrl");
%>
<html>
<head>
<title>
</title>
<LINK href="<%=request.getContextPath()%>/Resource/style/style1.css" type="text/css" rel="stylesheet">
<style type="text/css">
body, td{
font-size: 12px;
}
A:LINK, A:VISITED, A:ACTIVE, A:HOVER{
font-size: 13px;
padding-left: 3px;
TEXT-DECORATION: NONE;
}
</style>
<script src="<%=request.getContextPath()%>/Resource/Js/ajax.js" language="javascript" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/Resource/Js/common.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
function checkTreeChar()
{
var digits="\\;'<>\";'.(,?@#$%//&^=+-|*)~`/";
var inString="";
inString=String.fromCharCode(window.event.keyCode);
if((inString.trim()).length>0){
if (digits.indexOf(inString)!=-1)
{
// alert("你输入的字符包含非法字符\\;'<>\";'.(,?_@#$%//&^=+-|*)~`/,请重新输入!");
alert("你输入的字符包含非法字符\;'<>\";'.(,?_@#$%//&^=+-|*)~`/,请重新输入!");
return false;
}
else
return true;
}
}
//响应回车事件
function SubmitKeyClick(button) {
if (event.keyCode == 13){
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
function btnSearchNext_OnClick(val) {
trimAllFiled(document.FormPar);
if(val!=''){
makeRequest("<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?act=ajax&txt="+encodeURIComponent(val));
}else{
alert('<%=localBean.getResourceValue("query.content.is.null",request)%>');
return;
}
}
function elementFocus(leafName,hrefName){
var isElementFocus = document.all.txtElementFocus.value;//全局变量,用于保存之前哪一个叶节点被选中
var isHrefFocus = document.all.txtHrefFocus.value;
if(isElementFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
// var bfeDoc = eval("document.all." + isElementFocus);
// bfeDoc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/person.gif";
}
if(isHrefFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
var hrefDoc1 = eval("document.all." + isHrefFocus);
hrefDoc1.style.color="#006699";
}
//对新点中的节点进行操作
var doc = eval("document.all." + leafName);
// doc.src = "<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeafS.gif";
var hrefDoc = eval("document.all." + hrefName);
hrefDoc.style.color="#FF6600";
document.all.txtElementFocus.value = leafName;
document.all.txtHrefFocus.value = hrefName;
}
function elementFocus2(leafName,hrefName){
var isElementFocus = document.all.txtElementFocus.value;//全局变量,用于保存之前哪一个叶节点被选中
var isHrefFocus = document.all.txtHrefFocus.value;
if(isElementFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
// var bfeDoc = eval("document.all." + isElementFocus);
// bfeDoc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/person.gif";
}
if(isHrefFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
var hrefDoc1 = eval("document.all." + isHrefFocus);
hrefDoc1.style.color="#006699";
}
//对新点中的节点进行操作
var doc = eval("document.all." + leafName);
// doc.src = "<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeafS.gif";
var hrefDoc = eval("document.all." + hrefName);
hrefDoc.style.color="#FF6600";
document.all.txtElementFocus.value = leafName;
document.all.txtHrefFocus.value = hrefName;
}
function changeNodeIconSubTree(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert("changeNodeIconSubTree" + vsrc);
if(vsrc.indexOf("Tplus.png") != -1){
// alert("1f");
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tminus.png";
}else if(vsrc.indexOf("Tminus.png") != -1){
// alert("else if");
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tplus.png";
}
}
function changeNodeIcon(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert(name);
// alert("vsrc = "+vsrc);
if(vsrc.indexOf("Lplus.png") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tminus.png";
}else if(vsrc.indexOf("Tminus.png") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Lplus.png";
}
}
//changeElementIcon
function changeElementIcon(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert("changeElementIcon"+ vsrc);
if(vsrc.indexOf("folder.gif") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/folderopen.gif";
}else if(vsrc.indexOf("folderopen.gif") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/folder.gif";
}
}
function ExpandNode(ParentNode,ParentId){
var NodeX = eval(ParentNode.id + '_0');
// var divId = ParentNode +"_0";
// var NodeX= eval(divId);
// var NodeX = eval("document.all."+ParentNode + '_0');
if (NodeX.style.display == 'none')
{
NodeX.style.display="block";
document.frames['hiddenframe'].location.replace("<%=request.getContextPath()%>/SubTreeForOrgnization.jsp?Pid=" + ParentId + "&PNode=" + ParentNode.id + "&mibDescUrl=<%=mibDescUrl%>");
NodeX.loaded = 'yes';
}
else
{
NodeX.style.display='none';
}
}
function ExpandNode2(ParentNode,ParentId){
// var NodeX = eval(ParentNode.id + '_0');
var NodeX = eval("document.all."+ParentNode + '_0');
if (NodeX.style.display == 'none')
{
NodeX.style.display="block";
document.frames['hiddenframe'].location.replace("<%=request.getContextPath()%>/SubTreeForOrgnization.jsp?Pid=" + ParentId + "&id=ids&PNode=" + ParentNode + "&mibDescUrl=<%=mibDescUrl%>");
NodeX.loaded = 'yes';
}
else
{
NodeX.style.display='none';
}
}
//查询树节点
function plus_Click(Pid,PNode) {
// PID=" + ParentId + "&PNode=" + ParentNode.id + "&mibDescUrl=<%=mibDescUrl%>"
// alert("plus_Click");
if(Pid!=''){
// alert("Pid");
makeRequest("<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?act=ajax&Pid="+ Pid+"&PNode="+PNode.id+"&mibDescUrl=mibDescUrl");
}
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var res = http_request.responseXML;
var Classes = res.getElementsByTagName("value");
var path='';
for(var i=0;i<Classes.length;i++)
{
path = Classes(i).getElementsByTagName("path")[0].firstChild.nodeValue;
if(path == 'blank'){
alert("<%=localBean.getResourceValue("not.find.node")%>");
}else{
// alert("您查找的节点可能在如下树路径上 请按如下顺序展开树\n"+path);
//alert("path = "+path);
path = replaceAll(path,'@','<br>');
//<p>确定选用的节点 并按后面的提示路径即可找到所需的节点</p>
alert_div('type',"<Strong><%=localBean.getResourceValue("alert.div.message")%></Strong><br>"+path);
}
// var paths = path.split("||");
// for(j =0;j<paths.length;j++){
//ExpandNode(Node_10,1);
// var parentNode = paths[j].split(",")[0].toString();
// var id = paths[j].split(",")[1].toString();
// setTimeout("ExpandNode2('"+parentNode+"','"+id+"')",10*j);
}
}
}
}
function replaceAll(str,oldStr,reStr){
return str.split(oldStr).join(reStr);
}
//层的可以拖动调用的js方法
function f_mdown(obj)
{
currentMoveObj = obj; //当对象被按下时,记录该对象
currentMoveObj.style.position = "absolute";
relLeft = event.x - currentMoveObj.style.pixelLeft;
relTop = event.y - currentMoveObj.style.pixelTop;
}
window.document.onmouseup = function()
{
currentMoveObj = null; //当鼠标释放时同时释放拖动对象
}
function f_move(obj)
{
if(currentMoveObj != null)
{
currentMoveObj.style.pixelLeft=event.x-relLeft;
currentMoveObj.style.pixelTop=event.y-relTop;
}
}
//--弹出div
var parameter;
var type;
function alert_div(type,parameter)
{
//获得鼠标当前X,Y坐标
var x,y;
if(!document.all)
{
x=pageX;
y=pageY;
}else{
x=0; //鼠标X轴的值
y=0; //鼠标Y轴的值
}
var sH = document.body.scrollHeight; //窗口的高度
var sW = document.body.scrollWidth+20; //窗口的宽度
var width=300 , height=200; //设置div的大小
if((x + width) >= sW) //当鼠标点击时的x坐标的值加上div的宽度大于窗口的宽度
{
x = x - width;
}
var left=x+400 , top=y+5 ; //设置div的位置
var str="";
// 整个div的大小和位子
str+="<div id='div1' onmousedown='f_mdown(this)' onmousemove='f_move(this)' style='z-index:1;background-color:#E6EEFB;position:absolute;border:2px solid slategray;left:"+left+";top:"+top+";width:"+width+";height:"+height+";'>";
//--begin灰色top
str+="<div style='padding-bottom:2px;background-color: #6CA6E3;width:105%;height:16px;color:white;'>";
// 灰色div的设置
str+=" <div style='float:left;height:20px;overflow:hidden;margin:0px;padding:4px 0px 0px 5px;width:235;'><%=localBean.getResourceValue("search.tips")%></div>";
// 灰色div右侧的按钮
//str+=" <span style='width:14px;font-family:webdings;cursor:hand;'>0</span>";
str+=" <span style='width:14px;font-family:webdings;cursor:hand;float:right;' onclick='hide()'>r</span>";
str+="</div>";
//--end
//--begin白色div
str+="<div style=' margin:10px 5px 10px 10px;word-break:break-all;'>";
// 白色div中的信息
str+="<table cellpadding='0' cellspacing='1' border='0' class='border' align=left>";
str+="<tr><td> "+parameter+"</td></tr>";
str += "</table>";
str+="</div>";
//--end
str+="</div>";
//document.write(str);
document.body.insertAdjacentHTML("afterBegin",str);
document.getElementById('btnSearchNext').disabled = 'disabled';
}
//--关闭div
function hide()
{
document.getElementById( "div1").style.display = "none";
document.getElementById('btnSearchNext').disabled = '';
}
function test(){
alert("hello");
}
</script>
</head>
<body class="body">
<form name="FormPar" id="FormPar" action="">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
<tr>
<%@include file="../../includeLeft.jsp"%>
<td class="td-content" valign="top">
<table border="0" cellpadding="2" cellspacing="1" class="form-table" width="100%" style="height:100%;">
<tr>
<td class="list-tr1" vAlign="top" width="30%">
<div id="search" style="width:100%; height:25px; border:0px;">
<%--在树中找:--%><%--查 询--%>
<%=localBean.getResourceValue("Organization.table.findintree",request)%><input type="text" name="txtSearch" size="10" onKeyPress="return checkTreeChar();" onKeyDown="SubmitKeyClick('btnSearchNext');"/><input type="button" class="button" value=" Go " name="btnSearch" id="btnSearch" style="display:none" onClick="" /><input type="button" class="button" value="<%=localBean.getResourceValue("assetlistview.table.search")%>" name="btnSearchNext" id="btnSearchNext" onClick="btnSearchNext_OnClick(document.FormPar.txtSearch.value);" />
<input type="hidden" name="oldSearch" />
<input type="hidden" name="oldid" />
</div>
<div id="hide" style="display:none"></div>
<div id=treeviewarea style="width:100%; height:97%; border:0px; overflow:auto; background-color: ">
<iframe style="display:none" width="100%" height="100" id="hiddenframe"></iframe>
<TABLE width="200%" border="0" style="scrolling:auto">
<TR>
<TD>
<%
// com.cnunisoft.uma.cmp.TblMibSessionFacade bean = mibTree.getBean();
// TblMibDto[] dtos = bean.tblMibFindByParentOid("1");//ptools
TblOrganizationDto[] dtos = (TblOrganizationDto[])request.getAttribute("dtos");
int i=10;
int children;
String ID = "";
String mainTree = "";
String leaf ="no";
for (int j = 0; j < dtos.length; j++)
{
children = dtos.length;
ID = dtos[j].getUidroleid();
%>
<input type="hidden" name="txtElementFocus"/>
<input type="hidden" name="txtHrefFocus"/>
<div style="height:92%;" id='Node_<%= i %>'><a
<% if(children >0)
{%>
href="javascript:ExpandNode(Node_<%=i%>,<%=ID%>);javascript:changeNodeIcon('node<%=i%>');javascript:changeElementIcon('element<%=i%>')"><img name="node<%=i%>" src="<%=request.getContextPath()%>/Resource/Images/tree/Lplus.png" border="0"></a>
<%;}
else{%>
><img src="<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeaf.gif" border="0"></a><%;}%>
<a class="hand"
<% if (children >0)
{%>
name='notmibheaf<%=i%>' onclick="elementFocus('notmibLeaf<%=i%>',this.name)" href="<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?mainTree=<%=mainTree%>&DeptID=<%=dtos[j].getUidroleid()%>&leaf=<%=leaf%>%>" target="Edit"
<%} %>
><img name="element<%=i%>" src='<%=request.getContextPath()%>/Resource/Images/mztree/root.gif' border='0' alt="">
<%=dtos[j].getStrrolename()%></a>
</div>
<div id='Node_<%= i %>_0' style='display: none' >
<%--正在加载 ...--%>
<%=localBean.getResourceValue("MibTree.loding",request)%>
</div>
<%
i++;
}
%>
</TD>
</TR>
</TABLE>
</div>
</td>
<td class="list-tr1" vAlign="top"><iframe id="Edit" name="Edit" src="<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?mainTree=&from=&DeptID=<%=dtos[0].getUidroleid()%>" frameBorder="0" width="100%" style="height:100%;"></iframe>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" colspan="3" class="copy"><%@include file="../../copyRight.jsp"%>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
ExpandNode(Node_<%=i-1%>,'<%=ID%>');
changeNodeIcon('node<%=i-1%>');
changeElementIcon('element<%=i-1%>');
</script>
</body>
</HTML>
//////////////////////////
下面是SubTreeForOrgnization.jsp
////////////////////////////////
<!-- SubTreeForOrgnization.jsp -->
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="com.cnunisoft.uma.action.systemMonitor.config.*"%>
<%@page import="com.cnunisoft.uma.tableobject.*"%>
<%@page import="com.leagsoft.db.DatabaseService"%>
<%@page import="com.cnunisoft.util.UtilTool"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.*"%>
<jsp:useBean id="ptools" scope="request" class="com.cnunisoft.uma.action.ParameterTools"/>
<jsp:useBean id="localBean" scope="request" class="com.cnunisoft.uma.beans.LocalizationPackManager"/>
<HTML>
<HEAD>
<html:base/>
<TITLE></TITLE>
</HEAD>
<%
String mainTree ="";
String leaf = "no";
String thisDomain = ptools.getCurrentDomainID();
String PID = request.getParameter("Pid");
String sql = "select * from Tbl_Organization where (iRoletype='1' or iRoletype='3' or iRoletype='4') and uidParentRoleID = '"+PID+"'" +" order by strrolename";
ArrayList list = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql,TblOrganizationDto.class);
//begin
TblOrganizationDto[] dtos_allOrg=(TblOrganizationDto[])ptools.invokeSessionBeanMethod("TblOrganization", "tblOrganizationFindAllSubRole",
new Class[]{String.class}, new Object[]{new String("1")});
String uidUserGroupID = ptools.getUserGroupID(request);
if(!ptools.isAdministrators(uidUserGroupID)){
TblOperatorgroupDto[] deptDtos = (TblOperatorgroupDto[])ptools.invokeSessionBeanMethod(
"TblOperatorgroup",
"tblOperatorgroupFindByTypeAndID",
new Class[]{int.class, String.class},
new Object[]{new Integer(1), uidUserGroupID});
List filter = new ArrayList();
for(int i = 0; i < deptDtos.length; i++){
filter.add(deptDtos[i].getStrdevDeptNet());
}
ArrayList list2 = new ArrayList();
//过滤没有权限的
for(int i = 0; i < dtos_allOrg.length; i++){
if("1".equals(dtos_allOrg[i].getUidroleid()) || filter.contains(dtos_allOrg[i].getUidroleid())){
if (!list2.contains(dtos_allOrg[i])) {
list2.add(dtos_allOrg[i]);
}
if (!"1".equals(dtos_allOrg[i].getUidparentroleid())) {
for (int j = 0; j < dtos_allOrg.length; j++) {
if (UtilTool.objectEquals(dtos_allOrg[i].getUidparentroleid(), dtos_allOrg[j].getUidroleid())) {
if (!list2.contains(dtos_allOrg[j])) {
list2.add(dtos_allOrg[j]);
}
continue;
}
}
}
}
}
dtos_allOrg = new TblOrganizationDto[list2.size()];
dtos_allOrg = (TblOrganizationDto[])list2.toArray(dtos_allOrg);
}
//end过滤没有权限的
//筛选 对所有有权限的uidRoleId与 所取到的当前结点下的uidRoleId集,进行对比, 最终筛选取出当前结点下所有的uidRoleId且具备权限访问的集合,用一个样的新的集合list8保存起来
ArrayList list8 = new ArrayList();
for(int i=0;i<list.size();i++){
for(int j = 0;j<dtos_allOrg.length;j++){
if(((TblOrganizationDto)list.get(i)).getUidroleid().equals(dtos_allOrg[j].getUidroleid())){
list8.add((TblOrganizationDto)list.get(i));
}
}
}
//离职员工放到最下面
int num_leaver = 0;
int num_unknow = 0;
TblOrganizationDto last_1 = null;
TblOrganizationDto last_2 = null;
TblOrganizationDto last_3 = null;
String strCurDomainID = ptools.getCurrentDomainID();
// if("1".equals(PID)){ //对于根结点下的 离职员工 未知部门 下级管理域
for(int j = 0;j<list8.size();j++){
if(((TblOrganizationDto)list8.get(j)).getUidroleid().equals("2") || ((TblOrganizationDto)list8.get(j)).getUidroleid().equals( ((TblOrganizationDto)list8.get(j)).getUiddomainid()+"2") ){//表Tbl_Organization中uidroleid为2,代表离职员工
last_1= (TblOrganizationDto)list8.get(j);
// list8.remove(last_1);
}
if(((TblOrganizationDto)list8.get(j)).getUidroleid().equals("0") ||((TblOrganizationDto)list8.get(j)).getUidroleid().equals(((TblOrganizationDto)list8.get(j)).getUiddomainid()+"0")){//表Tbl_Organization中uidroleid为0,代表未知部门
last_2= (TblOrganizationDto)list8.get(j);
// list8.remove(last_2);
}
if(((TblOrganizationDto)list8.get(j)).getIroletype().intValue()== 3){//表Tbl_Organization中iRoleType为3,代表下级管理域
last_3= (TblOrganizationDto)list8.get(j);
// list8.remove(last_3);
}
}//end for
//}//end if
if(last_3 != null){list8.remove(last_3);}
if(last_2 != null){list8.remove(last_2);}
if(last_1 != null){list8.remove(last_1);}
list = list8;
if(last_3 != null){list.add(last_3);}
if(last_2 != null){list.add(last_2);}
if(last_1 != null){list.add(last_1);}
//
Object[] dtos_Org = null;
Object[] dtos_Alarm = null;
dtos_Org = new TblOrganizationDto[list.size()];
dtos_Org = (TblOrganizationDto[])list.toArray(dtos_Org);
String sql_Alarm = "";
ArrayList list_user = null;
//
String sq = "select * from Tbl_MgmDomaininfo where uidParentDomainID is not null";
ArrayList li = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sq,TblMgmdomaininfoDto.class);
if(li.size() >0 ){
for(int a = 0;a<li.size();a++){
String domain = ((TblMgmdomaininfoDto)li.get(a)).getUiddomainid();
if(PID.equals(domain+"2")){//下级的离职员工
sql_Alarm = "select * from Tbl_Alarmconnector where uidRoleID in(select uidRoleID+'2' from Tbl_Organization where uidDomainID='"+domain+"') and uidUserID!='0' and sStatus != '-1'";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
break;
}
else if(!PID.equals("2")){
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}else{// 离职员工
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus = '-1' "+ " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}
}
}
else{
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}
// String sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
String ParentNode = request.getParameter("PNode");
String strUnimon = request.getContextPath();
int i = 0,j = 0;
String nSpace="";
j= ParentNode.length()- ParentNode.replaceAll("_","").length();
for (i=0;i<j;i++)
nSpace = nSpace + "<img src='"+ strUnimon +"/Resource/Images/tree/blank.png' border='0'>";
String sHTML ="";
String[] ids = new String[dtos_Org.length];
String eachPid = "";
Map subNodeMap = new HashMap();
for (int count = 0; count < dtos_Org.length; count++) { //对当前结点下取出的 Tbl_Organization表中 的记录集进行判断,其是否还有下级部门域,采用HashMap的方式保存存起来,格式为 put(uidRoleID,下级部门域个数)
if( list.size()>0 ){
ids[count] = ((TblOrganizationDto)dtos_Org[count]).getUidroleid();
eachPid = ((TblOrganizationDto)dtos_Org[count]).getUidroleid();
sql = "select * from Tbl_Organization where iRoleType='1' and uidParentRoleID = '"+eachPid+"'";
ArrayList list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblOrganizationDto.class);
if(list3.size()<1){
if(eachPid.equals("2")){//离职员工 在Tbl_Alarmconnector表 离职员工的标识为 sStatus = '-1'
sql = "select * from Tbl_Alarmconnector where sStatus = '-1'";
list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(eachPid,(Object)(new Integer(list3.size())));
}
else {
sql = "select * from Tbl_Alarmconnector where uidRoleID = '"+eachPid+"'" +"and sStatus != '-1'";
list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(eachPid,(Object)(new Integer(list3.size())));
}
}
else{
subNodeMap.put(eachPid,(new Integer(list3.size())));
}
}
else{
eachPid = ((TblAlarmconnectorDto)dtos_Org[count]).getUidroleid();
subNodeMap.put(eachPid,(Object)(new Integer(0)));
}
}
for(int a = 0;a<li.size();a++){
String domain = ((TblMgmdomaininfoDto)li.get(a)).getUiddomainid();
for (int f = 0; f < dtos_Org.length; f++){
String tempPID = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
if(tempPID.equals(domain+"2")){
sql = "select * from Tbl_Alarmconnector where uidRoleID in(select uidRoleID from Tbl_Organization where uidDomainID='"+domain+"') and uidUserID!='0' and sStatus != '-1'";
ArrayList list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(tempPID,(Object)(new Integer(list3.size())));
break;
}
}
}
String ID = "";
String IDTemp;
String name ="";
Number subCount = null;
i = 0;
for (int f = 0; f < dtos_Org.length; f++)
{
String alarmUrl2 = null;
if(list.size()>0){
ID=((TblOrganizationDto)dtos_Org[f]).getUidroleid();
}
String nameID = ID.replace("-","");//这样处理就没js错误 (如果uidRoleId中包含-或.会有js错,原因还未知)
nameID = nameID.replace(".","");//这样处理就没js错误
nameID += f;
subCount = (Number)subNodeMap.get(((TblOrganizationDto)dtos_Org[f]).getUidroleid());
int children=subCount != null ? subCount.intValue() : 1;
sHTML = sHTML + "<div style='height:100%;' id='" + ParentNode + "_" + (i + 1) + "'>" + nSpace ;
if (children >0){//确定是否有子节点
sHTML = sHTML + "<a href=\"+\"javascript:ExpandNode("+ ParentNode + "_" + (i + 1)+",'" + ID + "');javascript:changeNodeIconSubTree('node"+nameID+"');javascript:changeElementIcon('element"+nameID+"')\"+\"><img name='node"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/tree/Tplus.png' border='0'></a>\\n";
}
else{
String getUidroleid_1="";
String getUiduserid="";
if(list.size()>0){
getUidroleid_1 = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
getUiduserid = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
String alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&act=user&DeptID="+getUidroleid_1+"&UserID="+getUiduserid+"&userroleid="+getUidroleid_1+"&from=1";
if(dtos_Org[f] instanceof TblOrganizationDto){
//对于Tbl_Organization 表中的页结点
alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&DeptID="+((TblOrganizationDto)dtos_Org[f]).getUidroleid()+"&leaf=yes";
}
alarmUrl2 = alarmUrl;
if(list.size()>0 && dtos_Org[f] instanceof TblOrganizationDto){
sHTML = sHTML + "<a href='"+alarmUrl+"' target='Edit'><img src='"+ strUnimon +"/Resource/Images/tree/Tminus.png' border='0'></a>\\n";
}
}
sHTML = sHTML;
String iconName = null;//mibTree.getNodeIconName(dtos[f]); 保留,以后再做
if (children >0){
iconName = "folder.gif";
if(!thisDomain.equals(((TblOrganizationDto)dtos_Org[f]).getUiddomainid())){//不是本级管理域
iconName = "folder.png";
}
String getUidroleid ="";
String getStrrolename="";
if(list.size()>0){
getUidroleid = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
getStrrolename = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
String url = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&DeptID="+getUidroleid+"&leaf=yes";
sHTML = sHTML + "<a name='notleafhref"+nameID+"'"+" onclick=\"+\"elementFocus('notmibLeaf"+nameID+"',this.name)\"+\" href='"+url+"' target='Edit'";
sHTML = sHTML + "><img name='element"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/" + iconName + "' border='0'>" + getStrrolename+ "</a></div>";
}else{
iconName = "folder.gif";
if(!thisDomain.equals(((TblOrganizationDto)dtos_Org[f]).getUiddomainid())){//不是本级管理域
iconName = "folder.png";
}
String else_getUidroleid ="";
if(list.size()>0){
else_getUidroleid = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
}
sHTML = sHTML + "<a name='notleafhref"+nameID+"'"+" onclick=\"+\"elementFocus('notmibLeaf"+nameID+"',this.name)\"+\" href='"+alarmUrl2+"' target='Edit'";
if(list.size()>0){
name = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
sHTML = sHTML + "><img name='mibLeaf"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/" + iconName + "' border='0'> " + name + "</a></div>";
}
if (children >0)
// " 正在加载 ...</div>"
{
sHTML = sHTML + "<div id='" + ParentNode + "_" + (i + 1) + "_0' style='display: none' loaded='no'>" + nSpace +
localBean.getResourceValue("SubTree.loding", request);
}
i++;
}
%>
<%-- 对表tbl_alarmConnector查出的记录添加进树 此表的所有记录都为叶节点,无需太多的复杂处理--%>
<%
for (int f = 0; f < dtos_Alarm.length; f++)
{
String alarmUrl2 = null;
ID=((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
subCount = (Number)subNodeMap.get(((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid());
String nameID = ID.replace("-","");
nameID += f;
// int children=subCount != null ? subCount.intValue() : 1;
sHTML = sHTML + "<div style='height:100%;' id='" + ParentNode + "_" + (i + 1) + "'>" + nSpace ;
String getUidroleid_1="";
String getUiduserid="";
getUidroleid_1 = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
getUiduserid = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUiduserid();
String alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&act=user&DeptID="+getUidroleid_1+"&UserID="+getUiduserid+"&userroleid="+getUidroleid_1+"&from=1";
alarmUrl2 = alarmUrl;
sHTML = sHTML + "<a href='"+alarmUrl+"' target='Edit'><img src='"+ strUnimon +"/Resource/Images/tree/Tminus.png' border='0'></a>\\n";
sHTML = sHTML;
String iconName = null;//mibTree.getNodeIconName(dtos[f]); 保留,以后再做
iconName = "person.gif";
String else_getUidroleid ="";
else_getUidroleid = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
sHTML = sHTML + "<a name='leafhref"+nameID+"'"+" onclick=\"+\"elementFocus('mibLeaf"+nameID+"',this.name)\"+\" href='"+alarmUrl2+"' target='Edit'";
name = ((TblAlarmconnectorDto)dtos_Alarm[f]).getStruserdes();
sHTML = sHTML + "><img name='mibLeaf"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/person.gif' border='0'> " + name + "</a></div>";
i++;
}
%>
<BODY>
<script type="text/javascript">
var x = eval('parent.' + '<%= ParentNode + "_0"%>') ;
x.innerHTML="<%=sHTML%>";
</script>
</BODY>
</HTML>
<%
String pid = request.getParameter("id");
if(true){ %>
<script type="text/javascript">
// ExpandNode2(Node_10_4,6fc609da-0000-b000-8000-000c29336d12);
// parent.test();
</script>
<%
}
%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.cnunisoft.uma.tableobject.TblOrganizationDto"%>
<%@page import="com.cnunisoft.uma.tableobject.TblAlarmconnectorDto"%>
<%@page import="com.cnunisoft.util.UtilTool"%>
<jsp:useBean id="localBean" scope="request" class="com.cnunisoft.uma.beans.LocalizationPackManager"/>
<jsp:useBean id="ptools" scope="request" class="com.cnunisoft.uma.action.ParameterTools"/>
<%
String mibDescUrl = (String)request.getAttribute("mibDescUrl");
%>
<html>
<head>
<title>
</title>
<LINK href="<%=request.getContextPath()%>/Resource/style/style1.css" type="text/css" rel="stylesheet">
<style type="text/css">
body, td{
font-size: 12px;
}
A:LINK, A:VISITED, A:ACTIVE, A:HOVER{
font-size: 13px;
padding-left: 3px;
TEXT-DECORATION: NONE;
}
</style>
<script src="<%=request.getContextPath()%>/Resource/Js/ajax.js" language="javascript" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/Resource/Js/common.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
function checkTreeChar()
{
var digits="\\;'<>\";'.(,?@#$%//&^=+-|*)~`/";
var inString="";
inString=String.fromCharCode(window.event.keyCode);
if((inString.trim()).length>0){
if (digits.indexOf(inString)!=-1)
{
// alert("你输入的字符包含非法字符\\;'<>\";'.(,?_@#$%//&^=+-|*)~`/,请重新输入!");
alert("你输入的字符包含非法字符\;'<>\";'.(,?_@#$%//&^=+-|*)~`/,请重新输入!");
return false;
}
else
return true;
}
}
//响应回车事件
function SubmitKeyClick(button) {
if (event.keyCode == 13){
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
function btnSearchNext_OnClick(val) {
trimAllFiled(document.FormPar);
if(val!=''){
makeRequest("<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?act=ajax&txt="+encodeURIComponent(val));
}else{
alert('<%=localBean.getResourceValue("query.content.is.null",request)%>');
return;
}
}
function elementFocus(leafName,hrefName){
var isElementFocus = document.all.txtElementFocus.value;//全局变量,用于保存之前哪一个叶节点被选中
var isHrefFocus = document.all.txtHrefFocus.value;
if(isElementFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
// var bfeDoc = eval("document.all." + isElementFocus);
// bfeDoc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/person.gif";
}
if(isHrefFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
var hrefDoc1 = eval("document.all." + isHrefFocus);
hrefDoc1.style.color="#006699";
}
//对新点中的节点进行操作
var doc = eval("document.all." + leafName);
// doc.src = "<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeafS.gif";
var hrefDoc = eval("document.all." + hrefName);
hrefDoc.style.color="#FF6600";
document.all.txtElementFocus.value = leafName;
document.all.txtHrefFocus.value = hrefName;
}
function elementFocus2(leafName,hrefName){
var isElementFocus = document.all.txtElementFocus.value;//全局变量,用于保存之前哪一个叶节点被选中
var isHrefFocus = document.all.txtHrefFocus.value;
if(isElementFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
// var bfeDoc = eval("document.all." + isElementFocus);
// bfeDoc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/person.gif";
}
if(isHrefFocus.length!=0){
//用户选择过叶节点时,则要把该节点复原,再对当前选中的节点进行处理
var hrefDoc1 = eval("document.all." + isHrefFocus);
hrefDoc1.style.color="#006699";
}
//对新点中的节点进行操作
var doc = eval("document.all." + leafName);
// doc.src = "<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeafS.gif";
var hrefDoc = eval("document.all." + hrefName);
hrefDoc.style.color="#FF6600";
document.all.txtElementFocus.value = leafName;
document.all.txtHrefFocus.value = hrefName;
}
function changeNodeIconSubTree(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert("changeNodeIconSubTree" + vsrc);
if(vsrc.indexOf("Tplus.png") != -1){
// alert("1f");
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tminus.png";
}else if(vsrc.indexOf("Tminus.png") != -1){
// alert("else if");
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tplus.png";
}
}
function changeNodeIcon(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert(name);
// alert("vsrc = "+vsrc);
if(vsrc.indexOf("Lplus.png") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Tminus.png";
}else if(vsrc.indexOf("Tminus.png") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/tree/Lplus.png";
}
}
//changeElementIcon
function changeElementIcon(name){
var doc = eval("document.all." + name);
var vsrc = doc.src;
// alert("changeElementIcon"+ vsrc);
if(vsrc.indexOf("folder.gif") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/folderopen.gif";
}else if(vsrc.indexOf("folderopen.gif") != -1){
doc.src = "<%=request.getContextPath()%>/Resource/Images/mztree/folder.gif";
}
}
function ExpandNode(ParentNode,ParentId){
var NodeX = eval(ParentNode.id + '_0');
// var divId = ParentNode +"_0";
// var NodeX= eval(divId);
// var NodeX = eval("document.all."+ParentNode + '_0');
if (NodeX.style.display == 'none')
{
NodeX.style.display="block";
document.frames['hiddenframe'].location.replace("<%=request.getContextPath()%>/SubTreeForOrgnization.jsp?Pid=" + ParentId + "&PNode=" + ParentNode.id + "&mibDescUrl=<%=mibDescUrl%>");
NodeX.loaded = 'yes';
}
else
{
NodeX.style.display='none';
}
}
function ExpandNode2(ParentNode,ParentId){
// var NodeX = eval(ParentNode.id + '_0');
var NodeX = eval("document.all."+ParentNode + '_0');
if (NodeX.style.display == 'none')
{
NodeX.style.display="block";
document.frames['hiddenframe'].location.replace("<%=request.getContextPath()%>/SubTreeForOrgnization.jsp?Pid=" + ParentId + "&id=ids&PNode=" + ParentNode + "&mibDescUrl=<%=mibDescUrl%>");
NodeX.loaded = 'yes';
}
else
{
NodeX.style.display='none';
}
}
//查询树节点
function plus_Click(Pid,PNode) {
// PID=" + ParentId + "&PNode=" + ParentNode.id + "&mibDescUrl=<%=mibDescUrl%>"
// alert("plus_Click");
if(Pid!=''){
// alert("Pid");
makeRequest("<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?act=ajax&Pid="+ Pid+"&PNode="+PNode.id+"&mibDescUrl=mibDescUrl");
}
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var res = http_request.responseXML;
var Classes = res.getElementsByTagName("value");
var path='';
for(var i=0;i<Classes.length;i++)
{
path = Classes(i).getElementsByTagName("path")[0].firstChild.nodeValue;
if(path == 'blank'){
alert("<%=localBean.getResourceValue("not.find.node")%>");
}else{
// alert("您查找的节点可能在如下树路径上 请按如下顺序展开树\n"+path);
//alert("path = "+path);
path = replaceAll(path,'@','<br>');
//<p>确定选用的节点 并按后面的提示路径即可找到所需的节点</p>
alert_div('type',"<Strong><%=localBean.getResourceValue("alert.div.message")%></Strong><br>"+path);
}
// var paths = path.split("||");
// for(j =0;j<paths.length;j++){
//ExpandNode(Node_10,1);
// var parentNode = paths[j].split(",")[0].toString();
// var id = paths[j].split(",")[1].toString();
// setTimeout("ExpandNode2('"+parentNode+"','"+id+"')",10*j);
}
}
}
}
function replaceAll(str,oldStr,reStr){
return str.split(oldStr).join(reStr);
}
//层的可以拖动调用的js方法
function f_mdown(obj)
{
currentMoveObj = obj; //当对象被按下时,记录该对象
currentMoveObj.style.position = "absolute";
relLeft = event.x - currentMoveObj.style.pixelLeft;
relTop = event.y - currentMoveObj.style.pixelTop;
}
window.document.onmouseup = function()
{
currentMoveObj = null; //当鼠标释放时同时释放拖动对象
}
function f_move(obj)
{
if(currentMoveObj != null)
{
currentMoveObj.style.pixelLeft=event.x-relLeft;
currentMoveObj.style.pixelTop=event.y-relTop;
}
}
//--弹出div
var parameter;
var type;
function alert_div(type,parameter)
{
//获得鼠标当前X,Y坐标
var x,y;
if(!document.all)
{
x=pageX;
y=pageY;
}else{
x=0; //鼠标X轴的值
y=0; //鼠标Y轴的值
}
var sH = document.body.scrollHeight; //窗口的高度
var sW = document.body.scrollWidth+20; //窗口的宽度
var width=300 , height=200; //设置div的大小
if((x + width) >= sW) //当鼠标点击时的x坐标的值加上div的宽度大于窗口的宽度
{
x = x - width;
}
var left=x+400 , top=y+5 ; //设置div的位置
var str="";
// 整个div的大小和位子
str+="<div id='div1' onmousedown='f_mdown(this)' onmousemove='f_move(this)' style='z-index:1;background-color:#E6EEFB;position:absolute;border:2px solid slategray;left:"+left+";top:"+top+";width:"+width+";height:"+height+";'>";
//--begin灰色top
str+="<div style='padding-bottom:2px;background-color: #6CA6E3;width:105%;height:16px;color:white;'>";
// 灰色div的设置
str+=" <div style='float:left;height:20px;overflow:hidden;margin:0px;padding:4px 0px 0px 5px;width:235;'><%=localBean.getResourceValue("search.tips")%></div>";
// 灰色div右侧的按钮
//str+=" <span style='width:14px;font-family:webdings;cursor:hand;'>0</span>";
str+=" <span style='width:14px;font-family:webdings;cursor:hand;float:right;' onclick='hide()'>r</span>";
str+="</div>";
//--end
//--begin白色div
str+="<div style=' margin:10px 5px 10px 10px;word-break:break-all;'>";
// 白色div中的信息
str+="<table cellpadding='0' cellspacing='1' border='0' class='border' align=left>";
str+="<tr><td> "+parameter+"</td></tr>";
str += "</table>";
str+="</div>";
//--end
str+="</div>";
//document.write(str);
document.body.insertAdjacentHTML("afterBegin",str);
document.getElementById('btnSearchNext').disabled = 'disabled';
}
//--关闭div
function hide()
{
document.getElementById( "div1").style.display = "none";
document.getElementById('btnSearchNext').disabled = '';
}
function test(){
alert("hello");
}
</script>
</head>
<body class="body">
<form name="FormPar" id="FormPar" action="">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
<tr>
<%@include file="../../includeLeft.jsp"%>
<td class="td-content" valign="top">
<table border="0" cellpadding="2" cellspacing="1" class="form-table" width="100%" style="height:100%;">
<tr>
<td class="list-tr1" vAlign="top" width="30%">
<div id="search" style="width:100%; height:25px; border:0px;">
<%--在树中找:--%><%--查 询--%>
<%=localBean.getResourceValue("Organization.table.findintree",request)%><input type="text" name="txtSearch" size="10" onKeyPress="return checkTreeChar();" onKeyDown="SubmitKeyClick('btnSearchNext');"/><input type="button" class="button" value=" Go " name="btnSearch" id="btnSearch" style="display:none" onClick="" /><input type="button" class="button" value="<%=localBean.getResourceValue("assetlistview.table.search")%>" name="btnSearchNext" id="btnSearchNext" onClick="btnSearchNext_OnClick(document.FormPar.txtSearch.value);" />
<input type="hidden" name="oldSearch" />
<input type="hidden" name="oldid" />
</div>
<div id="hide" style="display:none"></div>
<div id=treeviewarea style="width:100%; height:97%; border:0px; overflow:auto; background-color: ">
<iframe style="display:none" width="100%" height="100" id="hiddenframe"></iframe>
<TABLE width="200%" border="0" style="scrolling:auto">
<TR>
<TD>
<%
// com.cnunisoft.uma.cmp.TblMibSessionFacade bean = mibTree.getBean();
// TblMibDto[] dtos = bean.tblMibFindByParentOid("1");//ptools
TblOrganizationDto[] dtos = (TblOrganizationDto[])request.getAttribute("dtos");
int i=10;
int children;
String ID = "";
String mainTree = "";
String leaf ="no";
for (int j = 0; j < dtos.length; j++)
{
children = dtos.length;
ID = dtos[j].getUidroleid();
%>
<input type="hidden" name="txtElementFocus"/>
<input type="hidden" name="txtHrefFocus"/>
<div style="height:92%;" id='Node_<%= i %>'><a
<% if(children >0)
{%>
href="javascript:ExpandNode(Node_<%=i%>,<%=ID%>);javascript:changeNodeIcon('node<%=i%>');javascript:changeElementIcon('element<%=i%>')"><img name="node<%=i%>" src="<%=request.getContextPath()%>/Resource/Images/tree/Lplus.png" border="0"></a>
<%;}
else{%>
><img src="<%=request.getContextPath()%>/Resource/Images/MIBIcon/MIBLeaf.gif" border="0"></a><%;}%>
<a class="hand"
<% if (children >0)
{%>
name='notmibheaf<%=i%>' onclick="elementFocus('notmibLeaf<%=i%>',this.name)" href="<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?mainTree=<%=mainTree%>&DeptID=<%=dtos[j].getUidroleid()%>&leaf=<%=leaf%>%>" target="Edit"
<%} %>
><img name="element<%=i%>" src='<%=request.getContextPath()%>/Resource/Images/mztree/root.gif' border='0' alt="">
<%=dtos[j].getStrrolename()%></a>
</div>
<div id='Node_<%= i %>_0' style='display: none' >
<%--正在加载 ...--%>
<%=localBean.getResourceValue("MibTree.loding",request)%>
</div>
<%
i++;
}
%>
</TD>
</TR>
</TABLE>
</div>
</td>
<td class="list-tr1" vAlign="top"><iframe id="Edit" name="Edit" src="<%=request.getContextPath()%>/GlobalConfig/organizationAction.do?mainTree=&from=&DeptID=<%=dtos[0].getUidroleid()%>" frameBorder="0" width="100%" style="height:100%;"></iframe>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" colspan="3" class="copy"><%@include file="../../copyRight.jsp"%>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
ExpandNode(Node_<%=i-1%>,'<%=ID%>');
changeNodeIcon('node<%=i-1%>');
changeElementIcon('element<%=i-1%>');
</script>
</body>
</HTML>
//////////////////////////
下面是SubTreeForOrgnization.jsp
////////////////////////////////
<!-- SubTreeForOrgnization.jsp -->
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="com.cnunisoft.uma.action.systemMonitor.config.*"%>
<%@page import="com.cnunisoft.uma.tableobject.*"%>
<%@page import="com.leagsoft.db.DatabaseService"%>
<%@page import="com.cnunisoft.util.UtilTool"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.*"%>
<jsp:useBean id="ptools" scope="request" class="com.cnunisoft.uma.action.ParameterTools"/>
<jsp:useBean id="localBean" scope="request" class="com.cnunisoft.uma.beans.LocalizationPackManager"/>
<HTML>
<HEAD>
<html:base/>
<TITLE></TITLE>
</HEAD>
<%
String mainTree ="";
String leaf = "no";
String thisDomain = ptools.getCurrentDomainID();
String PID = request.getParameter("Pid");
String sql = "select * from Tbl_Organization where (iRoletype='1' or iRoletype='3' or iRoletype='4') and uidParentRoleID = '"+PID+"'" +" order by strrolename";
ArrayList list = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql,TblOrganizationDto.class);
//begin
TblOrganizationDto[] dtos_allOrg=(TblOrganizationDto[])ptools.invokeSessionBeanMethod("TblOrganization", "tblOrganizationFindAllSubRole",
new Class[]{String.class}, new Object[]{new String("1")});
String uidUserGroupID = ptools.getUserGroupID(request);
if(!ptools.isAdministrators(uidUserGroupID)){
TblOperatorgroupDto[] deptDtos = (TblOperatorgroupDto[])ptools.invokeSessionBeanMethod(
"TblOperatorgroup",
"tblOperatorgroupFindByTypeAndID",
new Class[]{int.class, String.class},
new Object[]{new Integer(1), uidUserGroupID});
List filter = new ArrayList();
for(int i = 0; i < deptDtos.length; i++){
filter.add(deptDtos[i].getStrdevDeptNet());
}
ArrayList list2 = new ArrayList();
//过滤没有权限的
for(int i = 0; i < dtos_allOrg.length; i++){
if("1".equals(dtos_allOrg[i].getUidroleid()) || filter.contains(dtos_allOrg[i].getUidroleid())){
if (!list2.contains(dtos_allOrg[i])) {
list2.add(dtos_allOrg[i]);
}
if (!"1".equals(dtos_allOrg[i].getUidparentroleid())) {
for (int j = 0; j < dtos_allOrg.length; j++) {
if (UtilTool.objectEquals(dtos_allOrg[i].getUidparentroleid(), dtos_allOrg[j].getUidroleid())) {
if (!list2.contains(dtos_allOrg[j])) {
list2.add(dtos_allOrg[j]);
}
continue;
}
}
}
}
}
dtos_allOrg = new TblOrganizationDto[list2.size()];
dtos_allOrg = (TblOrganizationDto[])list2.toArray(dtos_allOrg);
}
//end过滤没有权限的
//筛选 对所有有权限的uidRoleId与 所取到的当前结点下的uidRoleId集,进行对比, 最终筛选取出当前结点下所有的uidRoleId且具备权限访问的集合,用一个样的新的集合list8保存起来
ArrayList list8 = new ArrayList();
for(int i=0;i<list.size();i++){
for(int j = 0;j<dtos_allOrg.length;j++){
if(((TblOrganizationDto)list.get(i)).getUidroleid().equals(dtos_allOrg[j].getUidroleid())){
list8.add((TblOrganizationDto)list.get(i));
}
}
}
//离职员工放到最下面
int num_leaver = 0;
int num_unknow = 0;
TblOrganizationDto last_1 = null;
TblOrganizationDto last_2 = null;
TblOrganizationDto last_3 = null;
String strCurDomainID = ptools.getCurrentDomainID();
// if("1".equals(PID)){ //对于根结点下的 离职员工 未知部门 下级管理域
for(int j = 0;j<list8.size();j++){
if(((TblOrganizationDto)list8.get(j)).getUidroleid().equals("2") || ((TblOrganizationDto)list8.get(j)).getUidroleid().equals( ((TblOrganizationDto)list8.get(j)).getUiddomainid()+"2") ){//表Tbl_Organization中uidroleid为2,代表离职员工
last_1= (TblOrganizationDto)list8.get(j);
// list8.remove(last_1);
}
if(((TblOrganizationDto)list8.get(j)).getUidroleid().equals("0") ||((TblOrganizationDto)list8.get(j)).getUidroleid().equals(((TblOrganizationDto)list8.get(j)).getUiddomainid()+"0")){//表Tbl_Organization中uidroleid为0,代表未知部门
last_2= (TblOrganizationDto)list8.get(j);
// list8.remove(last_2);
}
if(((TblOrganizationDto)list8.get(j)).getIroletype().intValue()== 3){//表Tbl_Organization中iRoleType为3,代表下级管理域
last_3= (TblOrganizationDto)list8.get(j);
// list8.remove(last_3);
}
}//end for
//}//end if
if(last_3 != null){list8.remove(last_3);}
if(last_2 != null){list8.remove(last_2);}
if(last_1 != null){list8.remove(last_1);}
list = list8;
if(last_3 != null){list.add(last_3);}
if(last_2 != null){list.add(last_2);}
if(last_1 != null){list.add(last_1);}
//
Object[] dtos_Org = null;
Object[] dtos_Alarm = null;
dtos_Org = new TblOrganizationDto[list.size()];
dtos_Org = (TblOrganizationDto[])list.toArray(dtos_Org);
String sql_Alarm = "";
ArrayList list_user = null;
//
String sq = "select * from Tbl_MgmDomaininfo where uidParentDomainID is not null";
ArrayList li = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sq,TblMgmdomaininfoDto.class);
if(li.size() >0 ){
for(int a = 0;a<li.size();a++){
String domain = ((TblMgmdomaininfoDto)li.get(a)).getUiddomainid();
if(PID.equals(domain+"2")){//下级的离职员工
sql_Alarm = "select * from Tbl_Alarmconnector where uidRoleID in(select uidRoleID+'2' from Tbl_Organization where uidDomainID='"+domain+"') and uidUserID!='0' and sStatus != '-1'";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
break;
}
else if(!PID.equals("2")){
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}else{// 离职员工
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus = '-1' "+ " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}
}
}
else{
sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
list_user = (ArrayList)DatabaseService.getInstance().queryDataByKeys(sql_Alarm,TblAlarmconnectorDto.class);
dtos_Alarm = new TblAlarmconnectorDto[list_user.size()];
dtos_Alarm = (TblAlarmconnectorDto[])list_user.toArray(dtos_Alarm);
}
// String sql_Alarm = "select * from Tbl_Alarmconnector where uidUserID!='0' and sStatus != '-1' and uidRoleID ='"+PID+"'" + " order by strUserName";
String ParentNode = request.getParameter("PNode");
String strUnimon = request.getContextPath();
int i = 0,j = 0;
String nSpace="";
j= ParentNode.length()- ParentNode.replaceAll("_","").length();
for (i=0;i<j;i++)
nSpace = nSpace + "<img src='"+ strUnimon +"/Resource/Images/tree/blank.png' border='0'>";
String sHTML ="";
String[] ids = new String[dtos_Org.length];
String eachPid = "";
Map subNodeMap = new HashMap();
for (int count = 0; count < dtos_Org.length; count++) { //对当前结点下取出的 Tbl_Organization表中 的记录集进行判断,其是否还有下级部门域,采用HashMap的方式保存存起来,格式为 put(uidRoleID,下级部门域个数)
if( list.size()>0 ){
ids[count] = ((TblOrganizationDto)dtos_Org[count]).getUidroleid();
eachPid = ((TblOrganizationDto)dtos_Org[count]).getUidroleid();
sql = "select * from Tbl_Organization where iRoleType='1' and uidParentRoleID = '"+eachPid+"'";
ArrayList list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblOrganizationDto.class);
if(list3.size()<1){
if(eachPid.equals("2")){//离职员工 在Tbl_Alarmconnector表 离职员工的标识为 sStatus = '-1'
sql = "select * from Tbl_Alarmconnector where sStatus = '-1'";
list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(eachPid,(Object)(new Integer(list3.size())));
}
else {
sql = "select * from Tbl_Alarmconnector where uidRoleID = '"+eachPid+"'" +"and sStatus != '-1'";
list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(eachPid,(Object)(new Integer(list3.size())));
}
}
else{
subNodeMap.put(eachPid,(new Integer(list3.size())));
}
}
else{
eachPid = ((TblAlarmconnectorDto)dtos_Org[count]).getUidroleid();
subNodeMap.put(eachPid,(Object)(new Integer(0)));
}
}
for(int a = 0;a<li.size();a++){
String domain = ((TblMgmdomaininfoDto)li.get(a)).getUiddomainid();
for (int f = 0; f < dtos_Org.length; f++){
String tempPID = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
if(tempPID.equals(domain+"2")){
sql = "select * from Tbl_Alarmconnector where uidRoleID in(select uidRoleID from Tbl_Organization where uidDomainID='"+domain+"') and uidUserID!='0' and sStatus != '-1'";
ArrayList list3 = DatabaseService.getInstance().queryDataByKeys(sql,TblAlarmconnectorDto.class);
subNodeMap.put(tempPID,(Object)(new Integer(list3.size())));
break;
}
}
}
String ID = "";
String IDTemp;
String name ="";
Number subCount = null;
i = 0;
for (int f = 0; f < dtos_Org.length; f++)
{
String alarmUrl2 = null;
if(list.size()>0){
ID=((TblOrganizationDto)dtos_Org[f]).getUidroleid();
}
String nameID = ID.replace("-","");//这样处理就没js错误 (如果uidRoleId中包含-或.会有js错,原因还未知)
nameID = nameID.replace(".","");//这样处理就没js错误
nameID += f;
subCount = (Number)subNodeMap.get(((TblOrganizationDto)dtos_Org[f]).getUidroleid());
int children=subCount != null ? subCount.intValue() : 1;
sHTML = sHTML + "<div style='height:100%;' id='" + ParentNode + "_" + (i + 1) + "'>" + nSpace ;
if (children >0){//确定是否有子节点
sHTML = sHTML + "<a href=\"+\"javascript:ExpandNode("+ ParentNode + "_" + (i + 1)+",'" + ID + "');javascript:changeNodeIconSubTree('node"+nameID+"');javascript:changeElementIcon('element"+nameID+"')\"+\"><img name='node"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/tree/Tplus.png' border='0'></a>\\n";
}
else{
String getUidroleid_1="";
String getUiduserid="";
if(list.size()>0){
getUidroleid_1 = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
getUiduserid = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
String alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&act=user&DeptID="+getUidroleid_1+"&UserID="+getUiduserid+"&userroleid="+getUidroleid_1+"&from=1";
if(dtos_Org[f] instanceof TblOrganizationDto){
//对于Tbl_Organization 表中的页结点
alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&DeptID="+((TblOrganizationDto)dtos_Org[f]).getUidroleid()+"&leaf=yes";
}
alarmUrl2 = alarmUrl;
if(list.size()>0 && dtos_Org[f] instanceof TblOrganizationDto){
sHTML = sHTML + "<a href='"+alarmUrl+"' target='Edit'><img src='"+ strUnimon +"/Resource/Images/tree/Tminus.png' border='0'></a>\\n";
}
}
sHTML = sHTML;
String iconName = null;//mibTree.getNodeIconName(dtos[f]); 保留,以后再做
if (children >0){
iconName = "folder.gif";
if(!thisDomain.equals(((TblOrganizationDto)dtos_Org[f]).getUiddomainid())){//不是本级管理域
iconName = "folder.png";
}
String getUidroleid ="";
String getStrrolename="";
if(list.size()>0){
getUidroleid = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
getStrrolename = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
String url = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&DeptID="+getUidroleid+"&leaf=yes";
sHTML = sHTML + "<a name='notleafhref"+nameID+"'"+" onclick=\"+\"elementFocus('notmibLeaf"+nameID+"',this.name)\"+\" href='"+url+"' target='Edit'";
sHTML = sHTML + "><img name='element"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/" + iconName + "' border='0'>" + getStrrolename+ "</a></div>";
}else{
iconName = "folder.gif";
if(!thisDomain.equals(((TblOrganizationDto)dtos_Org[f]).getUiddomainid())){//不是本级管理域
iconName = "folder.png";
}
String else_getUidroleid ="";
if(list.size()>0){
else_getUidroleid = ((TblOrganizationDto)dtos_Org[f]).getUidroleid();
}
sHTML = sHTML + "<a name='notleafhref"+nameID+"'"+" onclick=\"+\"elementFocus('notmibLeaf"+nameID+"',this.name)\"+\" href='"+alarmUrl2+"' target='Edit'";
if(list.size()>0){
name = ((TblOrganizationDto)dtos_Org[f]).getStrrolename();
}
sHTML = sHTML + "><img name='mibLeaf"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/" + iconName + "' border='0'> " + name + "</a></div>";
}
if (children >0)
// " 正在加载 ...</div>"
{
sHTML = sHTML + "<div id='" + ParentNode + "_" + (i + 1) + "_0' style='display: none' loaded='no'>" + nSpace +
localBean.getResourceValue("SubTree.loding", request);
}
i++;
}
%>
<%-- 对表tbl_alarmConnector查出的记录添加进树 此表的所有记录都为叶节点,无需太多的复杂处理--%>
<%
for (int f = 0; f < dtos_Alarm.length; f++)
{
String alarmUrl2 = null;
ID=((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
subCount = (Number)subNodeMap.get(((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid());
String nameID = ID.replace("-","");
nameID += f;
// int children=subCount != null ? subCount.intValue() : 1;
sHTML = sHTML + "<div style='height:100%;' id='" + ParentNode + "_" + (i + 1) + "'>" + nSpace ;
String getUidroleid_1="";
String getUiduserid="";
getUidroleid_1 = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
getUiduserid = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUiduserid();
String alarmUrl = request.getContextPath()+"/GlobalConfig/organizationAction.do?mainTree="+mainTree+"&act=user&DeptID="+getUidroleid_1+"&UserID="+getUiduserid+"&userroleid="+getUidroleid_1+"&from=1";
alarmUrl2 = alarmUrl;
sHTML = sHTML + "<a href='"+alarmUrl+"' target='Edit'><img src='"+ strUnimon +"/Resource/Images/tree/Tminus.png' border='0'></a>\\n";
sHTML = sHTML;
String iconName = null;//mibTree.getNodeIconName(dtos[f]); 保留,以后再做
iconName = "person.gif";
String else_getUidroleid ="";
else_getUidroleid = ((TblAlarmconnectorDto)dtos_Alarm[f]).getUidroleid();
sHTML = sHTML + "<a name='leafhref"+nameID+"'"+" onclick=\"+\"elementFocus('mibLeaf"+nameID+"',this.name)\"+\" href='"+alarmUrl2+"' target='Edit'";
name = ((TblAlarmconnectorDto)dtos_Alarm[f]).getStruserdes();
sHTML = sHTML + "><img name='mibLeaf"+nameID+"'"+" src='"+ strUnimon +"/Resource/Images/mztree/person.gif' border='0'> " + name + "</a></div>";
i++;
}
%>
<BODY>
<script type="text/javascript">
var x = eval('parent.' + '<%= ParentNode + "_0"%>') ;
x.innerHTML="<%=sHTML%>";
</script>
</BODY>
</HTML>
<%
String pid = request.getParameter("id");
if(true){ %>
<script type="text/javascript">
// ExpandNode2(Node_10_4,6fc609da-0000-b000-8000-000c29336d12);
// parent.test();
</script>
<%
}
%>
相关推荐
4. 发送Ajax请求:使用`$.ajax`或`$.post`等方法构造并发送异步请求,将表单数据作为参数传递。 5. 处理响应:在Ajax的success回调函数中,根据服务器返回的数据更新DOM,例如显示提交结果或提示信息。 6. 关闭弹出...
4. **实例化树**:使用`ecotree.js`初始化树,将数据和容器元素传递给构造函数: ```javascript var tree = new EcoTree("tree", treeData); ``` 5. **渲染树**:调用`render`方法来绘制树: ```javascript ...
// 构造函数、getter和setter省略 } ``` 接着,我们需要创建一个菜单服务,用于加载和处理菜单数据。这个服务可能从数据库、配置文件或硬编码的数据中获取菜单项。例如: ```java public class MenuService { ...
在使用`dtree`之前,我们需要在HTML中创建一个容器元素,例如`<div id="tree"></div>`,然后通过JavaScript来初始化树形结构。这通常涉及到调用`dtree`的构造函数,传入树的初始数据和配置项。 ```javascript var ...
<div id="uploadStatus"></div> <!-- JavaScript部分 --> <script src="ajaxfileupload.js"></script> $(function() { var uploadUrl = "your/upload/script.php"; $("#uploadFile").ajaxFileUpload({ url: ...
4. **Vue.js组件**: 在本文的代码中,`<div id="app"></div>`是一个Vue组件,其内部使用Vue.js的指令和绑定来构建界面。 5. **异步请求**: 使用`this.$http.post`发出异步POST请求。这是Vue-resource插件提供的方法...
使用`div`元素配合CSS的布局技术(如盒模型、Flexbox或Grid)可以实现复杂的页面结构。例如,`div`常用于创建可自定义样式的容器,而Flexbox和Grid则可以实现灵活的多列布局。CSS选择器如类选择器、ID选择器、伪类等...
XTree有两种主要的使用模式:一是直接在JavaScript中构造树形结构,二是通过XML数据源动态构建。对于前者,你可以直接在JavaScript代码中创建WebFXTreeItem对象并进行关联,以形成树形结构。对于后者,你需要先生成...
通过创建或使用XMLHttpRequest对象,我们可以向服务器发送异步请求,并在接收到响应后更新DOM元素。 在这个示例中,有两个select框,一个用于选择学院(college),另一个用于选择专业(major)。当用户在学院...
开发者可以通过查看和分析这个文件来学习`thTree`的用法,包括如何加载CSS样式,引入jQuery和`thTree`脚本,以及如何构造树形数据结构。 2. `README`:通常,这个文件包含了关于`thTree`的安装指南、使用方法、API...
"的DIV,用静态CSS定义或者用脚本设置style属性,使得该DIV高度宽度都为500px,文字颜色为黄色,背景色为红色,同时该DIV的文字垂直和水平方向都居中。 - **解析**: 首先需要使用`document.createElement('div')`...
在JavaScript中,使用函数来定义对象和方法是一种常见的代码组织形式,特别是使用构造函数和原型链来实现类和继承机制,从而达到代码的模块化。 需要注意的是,文档内容由于OCR技术的限制存在一些错误和遗漏。在...
第一部分 构建ASP.NET页面 第1章 ASP.NET Framework概览 2 1.1 ASP.NET和.NET Framework 5 1.1.1 框架类库 5 1.1.2 公共语言运行库 9 1.2 ASP.NET控件 10 1.2.1 ASP.NET控件概览 11 ...17.3 执行异步数据库命令 ...
- Promise构造函数同步执行,then方法异步执行,遵循微任务(microtask)队列,会在当前脚本或任务队列之后执行。 12. 实现new操作符: - new操作符用于创建对象实例,本质上是对函数进行调用并返回新对象。 13. ...
3. 当表单以`<div>`或其他非表单元素存在时,可以使用JavaScript手动创建`FormData`实例,并添加具体的文件数据。点击上传按钮时,同样可以发起一个Ajax请求。 ```javascript $("#upload").click(function(){ var ...
next-pipe-props让您通过管道传递不同的功能(异步也可以)以构造最终的prop对象。 数据是从第一个函数传递过来的,并作为参数传递给下一个函数。 最好的开发人员经验来自传递完整对象并返回最终的prop对象。 这 ...
6. **无表单提交**:Ajax请求无需使用form标签,而是通过JavaScript直接构造请求数据。 7. **ID属性**:Ajax中使用ID属性来定位DOM元素,以便进行操作。 8. **div与span**:div常用于组织大块内容,内容会独占一行...
- 右侧Tab则可以是`<div>`容器,通过`<ul>`和`<li>`构建Tab标题,每个`<li>`包含一个`<a>`标签,点击后切换对应的Tab内容区域。 2. **CSS 样式**: - 使用CSS来定义样式,使菜单和Tab具有清晰的视觉层次和交互...
例如,我们可以使用`setInterval`或`requestAnimationFrame`来定时更新`div`的位置,从而创建出平滑的移动效果。 JS中的事件处理是另一个关键知识点,比如鼠标点击、页面加载、键盘输入等。例如,我们可以通过`...
它首先使用`requests.get()`发送HTTP GET请求获取页面文本,然后用`etree.HTML()`解析这个文本,创建一个`ElementTree`对象。接着,使用`tree_1.xpath()`方法和XPath表达式来获取页面中所有图片链接。这些链接随后被...