334 lines
12 KiB
Plaintext
334 lines
12 KiB
Plaintext
<%@ page contentType="text/html; charset=GBK"%>
|
||
<%@ page import="com.tenwa.comm.dataRightmanager.DataRightManager" %>
|
||
<%@ page import="com.tenwa.officetempalte.util.FileOperatorUtil" %>
|
||
<%@ page import="com.amarsoft.app.util.XMLDataUtil" %>
|
||
<%@ include file="/IncludeBegin.jsp"%>
|
||
<%
|
||
/*
|
||
Author:zywei 20050826
|
||
Tester:
|
||
Content: 选择对话框页面
|
||
Input Param:
|
||
Output param:
|
||
History Log:
|
||
zywei 2007/10/11 解决大数据量查询引起的响应延迟
|
||
xhgao 2009/04/09 增加KeyFilter加快查询速度;增加双击确认
|
||
fwang 2009/08/26 增加公共页面搜索可配置化
|
||
*/
|
||
String PG_TITLE = "选择信息"; // 浏览器窗口标题 <title> PG_TITLE </title>
|
||
|
||
//获取参数:查询名称和参数
|
||
String pageSize = CurPage.getParameter("PageSize");
|
||
String sSelName = CurPage.getParameter("SelName");
|
||
String sParaString = CurPage.getParameter("ParaString");
|
||
String RightType=CurPage.getParameter("RightType");
|
||
if(RightType==null&&RightType.length()==0){RightType="default";}
|
||
sParaString = (sParaString == null)?"":java.net.URLDecoder.decode(sParaString, "UTF-8");
|
||
//将空值转化为空字符串
|
||
if(sSelName == null) sSelName = "";
|
||
if(sParaString == null) sParaString = "";
|
||
|
||
//定义变量:查询类型、展现方式、参数、隐藏域
|
||
String sSelType = "",sSelBrowseMode = "",sSelArgs = "",sSelHideField = "";
|
||
//定义变量:代码、字段显示中文名称、表名、主键
|
||
String sSelCode = "",sSelFieldName = "",sSelTableName = "",sSelPrimaryKey = "";
|
||
//定义变量:字段显示风格、返回值、过滤字段、选择方式
|
||
String sSelFieldDisp = "",sSelReturnValue = "",sSelFilterField = "",sMutilOrSingle = "";
|
||
//定义变量:显示字段对齐方式、显示字段类型、显示字段检查模式、是否根据检索条件查询、属性5
|
||
String sAttribute1 = "",sAttribute2 = "",sAttribute3 = "",sAttribute4 = "",sAttribute5 = "";
|
||
//定义变量:数组长度
|
||
int l = 0;
|
||
//定义变量:返回字段的个数
|
||
int iReturnFiledNum = 0;
|
||
|
||
String sSql = " select SelType,SelTableName,SelPrimaryKey,SelBrowseMode,SelArgs,SelHideField,SelCode, "+
|
||
" SelFieldName,SelFieldDisp,SelReturnValue,SelFilterField,MutilOrSingle, "+
|
||
" Attribute1,Attribute2,Attribute3,Attribute4,Attribute5 "+
|
||
" from O where SelName =:SelName and IsInUse = '1' ";
|
||
BizObject bo = JBOFactory.createBizObjectQuery("jbo.sys.SELECT_CATALOG", sSql).setParameter("SelName", sSelName).getSingleResult(false);
|
||
if(bo != null){
|
||
sSelType = bo.getAttribute("SelType").getString(); // × 预留
|
||
sSelTableName = bo.getAttribute("SelTableName").getString(); // doTemp.UpdateTable
|
||
sSelPrimaryKey = bo.getAttribute("SelPrimaryKey").getString(); // doTemp.setKey(
|
||
sSelBrowseMode = bo.getAttribute("SelBrowseMode").getString(); // 固定Grid
|
||
sSelArgs = bo.getAttribute("SelArgs").getString(); // × 预留 sParaString
|
||
sSelHideField = bo.getAttribute("SelHideField").getString(); // doTemp.setVisible(sSelHideField,false)
|
||
sSelCode = bo.getAttribute("SelCode").getString(); // Sql
|
||
if(sSelCode.indexOf(".xml")>0)
|
||
{
|
||
String xmlPath=application.getRealPath(sSelCode);
|
||
Map<String,String> xmlFile=XMLDataUtil.readTableInfoFromXmlFile(xmlPath);
|
||
sSelCode=xmlFile.get("table_sql");
|
||
sSelCode=sSelCode.replaceAll("\r|\n", " ");
|
||
sSelCode=sSelCode.replaceAll("\t", " ");
|
||
}
|
||
sSelFieldName = bo.getAttribute("SelFieldName").getString(); // doTemp.setHeader(
|
||
sSelFieldDisp = bo.getAttribute("SelFieldDisp").getString(); // doTemp.setHTMLStyle(
|
||
sSelReturnValue = bo.getAttribute("SelReturnValue").getString(); // sReturnValue
|
||
sSelFilterField = bo.getAttribute("SelFilterField").getString(); // doTemp.setFilter(
|
||
sMutilOrSingle = bo.getAttribute("MutilOrSingle").getString(); // doTemp.multiSelectionEnabled
|
||
sAttribute1 = bo.getAttribute("Attribute1").getString(); // doTemp.setAlign(
|
||
sAttribute2 = bo.getAttribute("Attribute2").getString(); // doTemp.setType(
|
||
sAttribute3 = bo.getAttribute("Attribute3").getString(); // doTemp.setCheckFormat(
|
||
sAttribute4 = bo.getAttribute("Attribute4").getString(); // 若1则 doTemp.WhereClauseNoFilter += " and 1=2 ";
|
||
sAttribute5 = bo.getAttribute("Attribute5").getString(); // 设置下拉框来源
|
||
}
|
||
|
||
//将空值转化为空字符串
|
||
if(sSelType == null) sSelType = "";
|
||
if(sSelTableName == null) sSelTableName = "";
|
||
if(sSelPrimaryKey == null) sSelPrimaryKey = "";
|
||
if(sSelBrowseMode == null) sSelBrowseMode = "";
|
||
if(sSelArgs == null) sSelArgs = "";
|
||
else sSelArgs = sSelArgs.trim();
|
||
if(sSelHideField == null) sSelHideField = "";
|
||
else sSelHideField = sSelHideField.trim();
|
||
if(sSelCode == null) sSelCode = "";
|
||
else sSelCode = sSelCode.trim();
|
||
if(sSelFieldName == null) sSelFieldName = "";
|
||
else sSelFieldName = sSelFieldName.trim();
|
||
if(sSelFieldDisp == null) sSelFieldDisp = "";
|
||
else sSelFieldDisp = sSelFieldDisp.trim();
|
||
if(sSelReturnValue == null) sSelReturnValue = "";
|
||
else sSelReturnValue = sSelReturnValue.trim();
|
||
if(sSelFilterField == null) sSelFilterField = "";
|
||
else sSelFilterField = sSelFilterField.trim();
|
||
if(sMutilOrSingle == null) sMutilOrSingle = "";
|
||
if(sAttribute1 == null) sAttribute1 = "";
|
||
if(sAttribute2 == null) sAttribute2 = "";
|
||
if(sAttribute3 == null) sAttribute3 = "";
|
||
if(sAttribute4 == null) sAttribute4 = "";
|
||
if(sAttribute5 == null) sAttribute5 = "";
|
||
|
||
//获取返回值
|
||
StringTokenizer st = new StringTokenizer(sSelReturnValue,"@");
|
||
String [] sReturnValue = new String[st.countTokens()];
|
||
while (st.hasMoreTokens()) {
|
||
sReturnValue[l] = st.nextToken();
|
||
l ++;
|
||
}
|
||
iReturnFiledNum = sReturnValue.length;
|
||
//设置显示标题
|
||
String sHeaders = sSelFieldName;
|
||
|
||
//将Sql中的变量用相对应的值替换
|
||
StringTokenizer stArgs = new StringTokenizer(sParaString,",");
|
||
while (stArgs.hasMoreTokens()) {
|
||
try{
|
||
String sArgName = stArgs.nextToken().trim();
|
||
String sArgValue = stArgs.nextToken().trim();
|
||
sSelCode = StringFunction.replace(sSelCode,"#"+sArgName,sArgValue );
|
||
}catch(NoSuchElementException ex){
|
||
throw new Exception("输入参数格式错误!");
|
||
}
|
||
}
|
||
//加权限的的条件
|
||
String param=FileOperatorUtil.getParam(sSelCode);
|
||
if(param.length()>0){
|
||
String[] params=param.split(",");
|
||
if(params.length==2){
|
||
String sCondtion=DataRightManager.getRightConditionSelect(CurUser,params[0],params[1],"1");
|
||
//sSelCode = StringFunction.replace(sSelCode,"{"+param+"}",sCondtion );
|
||
//汽车业务经销商发起没有跟单人员不需要加权限条件
|
||
sSelCode = StringFunction.replace(sSelCode,"{"+param+"}"," and 1=1 " );
|
||
}
|
||
}
|
||
//实例化DataObject
|
||
ASDataObject doTemp = new ASDataObject(sSelCode);
|
||
doTemp.UpdateTable = sSelTableName;
|
||
doTemp.setKey(sSelPrimaryKey,true);
|
||
doTemp.setHeader(sHeaders);
|
||
|
||
//设置隐藏字段
|
||
if(!sSelHideField.equals("")) doTemp.setVisible(sSelHideField,false);
|
||
|
||
//设置对齐格式
|
||
StringTokenizer stAlign = new StringTokenizer(sAttribute1,"@");
|
||
while (stAlign.hasMoreTokens()) {
|
||
String sAlignName = stAlign.nextToken().trim();
|
||
String sAlignValue = stAlign.nextToken().trim();
|
||
doTemp.setAlign(sAlignName,sAlignValue);
|
||
}
|
||
|
||
//设置类型
|
||
StringTokenizer stType = new StringTokenizer(sAttribute2,"@");
|
||
while (stType.hasMoreTokens()) {
|
||
String sTypeName = stType.nextToken().trim();
|
||
String sTypeValue = stType.nextToken().trim();
|
||
doTemp.setType(sTypeName,sTypeValue);
|
||
}
|
||
|
||
//设置检查模式
|
||
StringTokenizer stCheck = new StringTokenizer(sAttribute3,"@");
|
||
while (stCheck.hasMoreTokens()) {
|
||
String sCheckName = stCheck.nextToken().trim();
|
||
String sCheckValue = stCheck.nextToken().trim();
|
||
doTemp.setCheckFormat(sCheckName,sCheckValue);
|
||
}
|
||
|
||
//KeyFilter加快查询速度
|
||
StringTokenizer stFilter = new StringTokenizer(sAttribute4,"@");
|
||
String sFilter="";
|
||
while (stFilter.hasMoreTokens()) {
|
||
String sFilterValue = stFilter.nextToken().trim();
|
||
sFilter=sFilter+"||"+sFilterValue;
|
||
}
|
||
if(sFilter.length()>2){
|
||
doTemp.setKeyFilter(sSelPrimaryKey);
|
||
}
|
||
|
||
//设置下拉框来源
|
||
StringTokenizer sDrawDownList = new StringTokenizer(sAttribute5,"@");
|
||
ArrayList ddwColumn = new ArrayList();
|
||
while (sDrawDownList.hasMoreTokens()) {
|
||
String sFilterOptions = null;
|
||
String sColumnList = sDrawDownList.nextToken().trim();
|
||
String sSourceType = sDrawDownList.nextToken().trim();
|
||
String sSource = sDrawDownList.nextToken().trim();
|
||
if(sDrawDownList.hasMoreTokens())
|
||
sFilterOptions = sDrawDownList.nextToken().trim();
|
||
if("Code".equalsIgnoreCase(sSourceType)){
|
||
doTemp.setDDDWCode(sColumnList,sSource);
|
||
}else if("Sql".equalsIgnoreCase(sSourceType)){
|
||
doTemp.setDDDWSql(sColumnList,sSource);
|
||
}else if("CodeTable".equalsIgnoreCase(sSourceType)){
|
||
doTemp.setDDDWCodeTable(sColumnList,sSource);
|
||
}
|
||
if(sFilterOptions == null) sFilterOptions = " ";
|
||
ddwColumn.add(sColumnList+"@"+sFilterOptions);
|
||
}
|
||
|
||
//设置显示格式
|
||
StringTokenizer stDisp = new StringTokenizer(sSelFieldDisp,"@");
|
||
while (stDisp.hasMoreTokens()) {
|
||
String sDispName = stDisp.nextToken().trim();
|
||
String sDispValue = stDisp.nextToken().trim();
|
||
doTemp.setHTMLStyle(sDispName,sDispValue);
|
||
}
|
||
|
||
//设置检索区
|
||
if(!sSelFilterField.equals("")){
|
||
String[] sColName= sSelFilterField.split(",");
|
||
for(int i=0;i<sColName.length;i++){
|
||
boolean executed = false;
|
||
for(int j=0;j<ddwColumn.size();j++){
|
||
String stColumn = ddwColumn.get(j).toString().split("@")[0].trim();
|
||
String stOptions = "Operators="+ddwColumn.get(j).toString().split("@")[1].trim();
|
||
|
||
if(stColumn.equals(sColName[i].toString())){
|
||
doTemp.setFilter(Sqlca,"DF"+i,sColName[i],stOptions);
|
||
executed = true;
|
||
}
|
||
}
|
||
if(!executed){
|
||
doTemp.setColumnAttribute(sColName[i], "IsFilter", "1");
|
||
//doTemp.setFilter(Sqlca,"DF"+i,sColName[i],"");
|
||
}
|
||
}
|
||
}
|
||
|
||
doTemp.appendHTMLStyle(""," style=\"cursor:pointer;\" ondblclick=javascript:parent.parent.returnSelection() ");
|
||
|
||
//如果需要根据检索条件查询结果,则默认查询为空
|
||
if(sAttribute4.equals("1"))
|
||
doTemp.WhereClauseNoFilter += " and 1=2 ";
|
||
else if(sAttribute4.indexOf("and")>0)
|
||
{
|
||
doTemp.WhereClauseNoFilter+=" "+sAttribute4;
|
||
}
|
||
|
||
if(!sMutilOrSingle.equals("Single"))
|
||
doTemp.multiSelectionEnabled=true;
|
||
//实例化DataWindow
|
||
ASDataWindow dwTemp = new ASDataWindow(CurPage,doTemp,Sqlca);
|
||
dwTemp.Style="1"; //设置DW风格 1:Grid 2:Freeform
|
||
dwTemp.ReadOnly = "1"; //设置是否只读 1:只读 0:可写
|
||
// dwTemp.setPageSize(10); //服务器分页
|
||
|
||
dwTemp.setPageSize(pageSize==null?20:Integer.parseInt(pageSize));
|
||
|
||
//生成HTMLDataWindow
|
||
Vector vTemp = dwTemp.genHTMLDataWindow("%");
|
||
for(int i=0;i<vTemp.size();i++) {
|
||
out.print((String)vTemp.get(i));
|
||
}
|
||
|
||
String sButtons[][] = {};
|
||
%><%@include file="/Resources/CodeParts/List05.jsp"%>
|
||
<script type="text/javascript">
|
||
|
||
<%/*~[Describe=提交;]~*/%>
|
||
function doSearch(){
|
||
document.forms["form1"].submit();
|
||
}
|
||
|
||
<%/*~[Describe=将选择行的信息拼成字符串并返回;]~*/%>
|
||
function mySelectRow(){
|
||
if (getRow()<0) return;
|
||
var sReturnValue = "";
|
||
try{
|
||
<%for(int j = 0 ; j < sReturnValue.length ; j ++){%>
|
||
sReturnValue += getItemValue(0,getRow(),"<%=sReturnValue[j]%>") + "@";
|
||
<%}%>
|
||
}catch(e){
|
||
return;
|
||
}
|
||
parent.sObjectInfo = sReturnValue;
|
||
}
|
||
|
||
<%/*~[Describe=将选择行的信息拼成字符串并返回;]~*/%>
|
||
function returnValue(){
|
||
var sReturnValue = "";
|
||
var sMutilOrSingle = "<%=sMutilOrSingle%>";
|
||
if(sMutilOrSingle != "Single") //多选
|
||
sReturnValue = myMultiSelectRow();
|
||
else
|
||
sReturnValue = mySingleSelectRow();
|
||
|
||
sReturnSplit = sReturnValue.split("@"); //在返回时,只要判断第一个是undefined,就可以说明它没有选择到任何数据
|
||
if(sReturnSplit[0]=="undefined"){ //其他项不会有undefied的。
|
||
parent.sObjectInfo="";
|
||
}else{
|
||
parent.sObjectInfo = sReturnValue;
|
||
}
|
||
}
|
||
|
||
<%/*~[Describe=将选择行的信息拼成字符串并返回;]~*/%>
|
||
function mySingleSelectRow(){
|
||
try{
|
||
var sReturnValue = "";
|
||
<%for(int j = 0 ; j < iReturnFiledNum ; j ++){%>
|
||
sReturnValue += getItemValue(0,getRow(),"<%=sReturnValue[j]%>") + "@";
|
||
<%}%>
|
||
}catch(e){
|
||
return;
|
||
}
|
||
return (sReturnValue);
|
||
}
|
||
|
||
<%/*~[Describe=将选择行的信息拼成字符串并返回;]~*/%>
|
||
function myMultiSelectRow(){
|
||
try{
|
||
var b = getRowCount(0);
|
||
var sReturnValue = "";
|
||
for(var iMSR = 0 ; iMSR < b ; iMSR++){
|
||
var a = getItemValue(0,iMSR,"MultiSelectionFlag");
|
||
if(a == "√"){
|
||
<%for(int j = 0 ; j < iReturnFiledNum ; j ++){%>
|
||
sReturnValue += getItemValue(0,iMSR,"<%=sReturnValue[j]%>") + "@";
|
||
<%}%>
|
||
sReturnValue += "~";
|
||
}
|
||
}
|
||
}catch(e){
|
||
return;
|
||
}
|
||
return (sReturnValue);
|
||
}
|
||
window.onload=function(){
|
||
AsOne.AsInit();
|
||
init();
|
||
my_load(2,0,'myiframe0');
|
||
}
|
||
</script>
|
||
<%@ include file="/IncludeEnd.jsp"%> |