<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page import="com.gx.webpage.framework.util.inoutformat.DataBean" %>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.factory.PageDesignDbEngineFactory"%>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.valueobject.*"%>
<%
    String table = "";
    boolean isError = false;
    String infStr = "";
    String formUuid = DataBean.getStr(request,"uuid");
    try{
        Collection col = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findFormsUiByType(formUuid, FormsUiModel.TYPE_SEARCH,request);
        if(request.getMethod().equalsIgnoreCase("POST"))
        {
            FormsUiModel fm = new FormsUiModel();
            fm.setFormUuid(formUuid);
            fm.setUiName("基本列表");
            fm.setType(FormsUiModel.TYPE_SEARCH);
            fm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().createFormsUi(fm,request);
            col.add(fm);
        }
        Iterator it = col.iterator();
        while(it.hasNext()){
            FormsUiModel fm = (FormsUiModel)it.next();
            table += "<tr onclick='itemClick(this)' style='cursor : hand'>\r\n";
            table += "<td><input type=radio name=uuid value='" + fm.getUuid() + "'></td>\r\n";
            table += "<td>" + DataBean.getStr(fm.getUuid()) + "&nbsp;</td>\r\n";
            table += "<td>" + DataBean.getStr(fm.getUiName()) + "&nbsp;</td>\r\n";
            table += "</tr>";
        }
    }catch(Exception err){
        isError = true;
        infStr = DataBean.getErrStr(err);
    }
%>
<html>
<head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="./../../../../webpage/common/css/common.css" rel="StyleSheet"  type="text/css" />
<script language="javascript" src="./../../../../webpage/common/engine/constant.js"></script>
<script language="JScript.Encode" src="./../../../../webpage/common/engine/common.js"></script>
<script language="JScript.Encode" src="./../../../../webpage/common/engine/DTFControl.js"></script>
<script language="JScript.Encode" src="./../../../../webpage/common/js/DataReferControl.js"></script>
<script language="JScript.Encode" src="./../../../../webpage/design/js/SqlBuilder.js"></script>
<script language="JScript.Encode" src="./../../../../webpage/common/engine/TimerControl.js"></script>
<script language="javascript">
<!--
    function btn_copy(){
        Navigate("listAdd.jsp");
    }
    function btn_modify(){
        Navigate("listModify.jsp");
    }
    function btn_delete(){
        Navigate("listDelete.jsp");
    }
    function btn_design(){
        var chk = getOnlyOneItem();
        if(chk != null)
        {
            CHILDWIN.open("./../../../design/listDesign/ListDesignMain.jsp?uuid=" + chk.value+"&designType=4", "listdesign");
        }
    }
    function btn_use(){
        var chk = getOnlyOneItem();
        if(chk != null)
        {
            var url = "./../../../common/module/searchList.jsp?uiUuid=" + chk.value;
            CHILDWIN.open(url);
        }
    }
    function btn_toFormsList(){
        window.navigate("./../searchList.jsp");
    }
    function Navigate(url)
    {
        var chk = getOnlyOneItem();
        if(chk == null)
        {
            return;
        }
        window.navigate(url + "?uuid=" + chk.value);
    }
    function getOnlyOneItem()
    {
        var col = document.getElementsByName('uuid');
        for(var i=0; i < col.length; i++)
        {
            var chk = col(i);
            if(chk.checked == true)
            {
                return chk;
            }
        }
        MSG.show('请选择一个查询列表视图');
        return null;
    }
    var oldIndex = -1;
    function itemClick(tr)
    {
        var i = tr.rowIndex - 1;
        var col = document.getElementsByName('uuid');
        col(i).click();
        switchColor(oldIndex, false);
        oldIndex = i + 1;
        switchColor(oldIndex, true);
    }
    function switchColor(index, set)
    {
        if(index < 0) return;
        var tr = listTable.rows(index);
        if(set == true)
        {
            tr.style.backgroundColor = '#cccccc';
        }
        else
        {
            tr.style.backgroundColor = '';
        }
    }
    function but_CreatNormalUi()
    {
        myForm.submit();
    }
//-->
</script>
    <title>自定义查询列表视图</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">自定义查询视图列表</h3>
<%if(!isError){%>
<table class="content" id="listTable">
    <tr><td width="50px">&nbsp</td>
        <td width="200px">查询视图列表标识</td>
        <td>查询视图列表名称</td>
<%= table%>
</table>
<table class="buttable1">
<tr>
<td align=center><input class="butAction" type="button" name="but_copy"       value="拷 贝" onclick="btn_copy();">
<td align=center><input class="butAction" type="button" name="but_modify"     value="修 改" onclick="btn_modify();">
<td align=center><input class="butAction" type="button" name="but_delete"     value="删 除" onclick="btn_delete();">
<td align=center><input class="butAction" type="button" name="but_use"        value="测 试" onclick="btn_use();">
<td align=center><input class="butAction" type="button" name="but_CreatNormalUi" value="建立基本列表视图" onclick="but_CreatNormalUi();">
<td align=center><input class="butAction" type="button" name="but_designForm" value="设计列表视图" onclick="btn_design();">
<td align=center><input class="butAction" type="button" name="but_toList"     value="返回视图列表" onclick="btn_toFormsList();">
</table>
<form name=myForm id=myForm method=post>
</form>
<%}else{%>
<p align=center>生成列表失败．
<p align=center><%= infStr%>
<p align=center><input type=button class=butAction value="后退" onclick="window.history.back();">
<%}%>
</div>
</body>
</html>
