action:
// 操作部门
public ActionForward departMent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String departId = "";// 部门id
List dePartMentList = null;// 部门list
String flag = request.getParameter("departflag");
// 修改部门时查询某条线路的部门
if (flag.equals("updatedepart")) {
departId = request.getParameter("deparMentId");
dePartMentList = logic.getDepartMentById(departId);
if (!dePartMentList.isEmpty()) {
request.setAttribute("departMentPO", dePartMentList);
}
}
// 查询该机构的部门信息
String creatororgid = TLAppUtil.getCurrOrgId(request);
// 代理商ID
String angId = "";
// 查询所有的url
List resultList = new ArrayList();
List angentIDlist = new ArrayList();
int a = 0;
// 查询登陆用户的所在部门信息
if (!creatororgid.equals("") || creatororgid != null) {
List departMent = logic.getDepartmentName(creatororgid);
List getOrgName = (List) logic.getOrgNameByid(creatororgid);
Object[] arg = new Object[3];
arg[0] = creatororgid;
List list1 = new ArrayList();
if (!departMent.isEmpty()) {
a = 1;
for (int k = 0; k < departMent.size(); k++) {
Object[] arg2 = new Object[2];
arg2[0] = departMent.get(k);
list1.add(arg2);
}
}
arg[1] = list1;
arg[2] = getOrgName.get(0);
resultList.add(arg);
angentIDlist.add(creatororgid);
}
// 查询代理商的
List list = logic.getAngentID(creatororgid);
if (!list.isEmpty()) {
Map map = new HashMap();
for (int i = 0; i < list.size(); i++) {
map = (Map) list.get(i);
String angentID = map.get("agentId").toString();
List departMent = logic.getDepartmentName(angentID);
List getOrgName = (List) logic.getOrgNameByid(angentID);
Object[] arg = new Object[3];
arg[0] = list.get(i);
List list1 = new ArrayList();
angentIDlist.add(angentID);
if (!departMent.isEmpty()) {
a = 1;
for (int k = 0; k < departMent.size(); k++) {
Object[] arg2 = new Object[2];
arg2[0] = departMent.get(k);
list1.add(arg2);
}
}
arg[1] = list1;
arg[2] = getOrgName.get(0);
resultList.add(arg);
}
}
//判断是否是国旅和集散,如果不是,则按条件显示国旅和集散
if (angentIDlist != null && angentIDlist.size() > 0) {
String gl = "402880fe21d3b0b00121d3e6bf00000a";
String js = "4028800020d5c8470120d6646b9100a9";
List tempList = new ArrayList();
Map map = new HashMap();
for (int i = 0; i < angentIDlist.size(); i++) {
angId += (String) angentIDlist.get(i);
angId += ",";
}
if (angId.indexOf(gl) == -1) {
map.put("orgName", "深圳中国国际旅行社有限公司");
map.put("orgId", "402880fe21d3b0b00121d3e6bf00000a");
map.put("id", "4028800021e189180121e1b11472001f");
map.put("name", "在线营销部");
tempList.add(map);
request.setAttribute("tempList", tempList);
}
if (angId.indexOf(js) == -1) {
map = new HashMap();
map.put("orgName", "深圳旅游集散中心有限公司");
map.put("orgId", "4028800020d5c8470120d6646b9100a9");
map.put("id", "4028800420eaac540120f05a593b0012");
map.put("name", "网站客服中心");
tempList.add(map);
request.setAttribute("tempList", tempList);
}
}
//既不为集散也不为国旅
if (a != 1) {
resultList = null;
List tempList = new ArrayList();
Map map = new HashMap();
map.put("orgName", "深圳中国国际旅行社有限公司");
map.put("orgId", "402880fe21d3b0b00121d3e6bf00000a");
map.put("id", "4028800021e189180121e1b11472001f");
map.put("name", "在线营销部");
tempList.add(map);
map = new HashMap();
map.put("orgName", "深圳旅游集散中心有限公司");
map.put("orgId", "4028800020d5c8470120d6646b9100a9");
map.put("id", "4028800420eaac540120f05a593b0012");
map.put("name", "网站客服中心");
tempList.add(map);
request.setAttribute("tempList", tempList);
}
request.setAttribute("dePartMendList", resultList);
return mapping.findForward("to_department");
}
--界面:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib prefix="cpnams" uri="/WEB-INF/tld/cpnams.tld"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/tld/fn.tld" prefix="fn"%>
<%@ taglib prefix="jodd" uri="http://www.springside.org.cn/jodd_form"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base target="_self">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>指定部门</title>
<link href="<%=request.getContextPath()%>/css/Supply.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
function showValue(){
var str = '';
var strid = '';
var form_obj=document.forms["frm"];
for (i=0;i<form_obj.length ;i++ ){
e=form_obj[i];
if(e!=null&&e.name!=''){
if( e.name == 'box' && e.type=="radio" && e.checked == true ){
strid = strid + e.id + ""
str = str+e.value + "";
}
}
}
document.getElementById("show").innerText = str;
document.getElementById("deptName").value = strid;
}
function ok(){
var _id = document.getElementById("deptName").value;
var _name = document.getElementById("show").innerText;
window.dialogArguments[0].value = _id;
window.dialogArguments[1].value = _name;
window.close();
}
</script>
</head>
<body onLoad="showValue()">
<form name="frm" method="post"
action="<%=request.getContextPath()%>/line.do">
<input type="hidden" name="deptName" id="deptName" />
<table width="800" border="0" cellspacing="0" cellpadding="0"
class="xzlxtitle">
<tr>
<td width="18">
<img src="../../images/Supply/xzjt.gif" width="18" height="27" />
</td>
<td width="733">
请选择部门
</td>
<td width="89">
<a href="#" onClick="ok()">[确定]</a>
<a href="#" onClick="window.close()">[关闭]</a>
</td>
</tr>
</table>
<table width="800" border="0" cellpadding="0" cellspacing="0"
class="xzlx">
<c:forEach items="${dePartMendList}" var="vo" varStatus="status">
<tr>
<td width="19">
<img src="../../images/Supply/xzjt2.gif" width="16" height="24" />
</td>
<td width="831">
<c:out value="${vo[2].name}" />:
</td>
</tr>
<tr>
<td height="1" colspan="2"
background="../../images/Supply/xuxian.gif"></td>
</tr>
<tr>
<td colspan="2">
<div>
<ul>
<c:forEach items="${vo[1]}" var="departvo" varStatus="status">
<c:if test="${departMentPO==null}">
<li style="width:148px;float:left;">
<input type="radio" name="box" id="<c:out value='${departvo[0].id}'/>"
value="<c:out value='${departvo[0].name}'/>" onClick="showValue()" />
<c:out value='${departvo[0].name}' />
</li>
</c:if>
<c:if test="${departMentPO!=null}">
<li style="width:148px;float:left;">
<input type="radio" name="box" <c:forEach items="${departMentPO}" var="vo2" varStatus="status"><c:if test="${departvo[0].name==vo2.NAME}">checked</c:if></c:forEach> id="<c:out value='${departvo[0].id}'/>"
value="<c:out value='${departvo[0].name}'/>" onClick="showValue()"/>
<c:out value='${departvo[0].name}' />
</li>
</c:if>
</c:forEach>
</ul>
</div>
</td>
</tr> <tr>
<td height="1" colspan="2" background="../../images/Supply/xuxian.gif"></td>
</tr>
</c:forEach>
<c:forEach items="${tempList}" var="votemp" varStatus="status">
<tr>
<td width="19">
<img src="../../images/Supply/xzjt2.gif" width="16" height="24" />
</td>
<td width="831">
<c:out value="${votemp.orgName}" />:
</td>
</tr>
<tr>
<td height="1" colspan="2"
background="../../images/Supply/xuxian.gif"></td>
</tr>
<tr>
<td colspan="2">
<div>
<ul>
<c:if test="${departMentPO==null}">
<li style="width:148px;float:left;">
<input type="radio" name="box" id="<c:out value='${votemp.id}'/>"
value="<c:out value='${votemp.name}'/>" onClick="showValue()" />
<c:out value='${votemp.name}' />
</li>
</c:if>
<c:if test="${departMentPO!=null}">
<li style="width:148px;float:left;">
<input type="radio" name="box" <c:forEach items="${departMentPO}" var="vo2" varStatus="status"><c:if test="${votemp.name==vo2.name}">checked</c:if></c:forEach> id="<c:out value='${votemp.id}'/>"
value="<c:out value='${votemp.name}'/>" onClick="showValue()" />
<c:out value='${votemp.name}' />
</li>
</c:if>
</ul>
</div>
</td>
</tr> <tr>
<td height="1" colspan="2" background="../../images/Supply/xuxian.gif"></td>
</tr>
</c:forEach>
<tr>
<td colspan="2">
你选择的部门是:
<label id="show"></label>
</td>
</tr>
<tr>
<td height="4" colspan="2" bgcolor="#319eef" backgcolor=""></td>
</tr>
</table>
</form>
</body>
</html>