<%@ 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 uuid = DataBean.getStr(request,"uuid");
    boolean isError = false;
    String infStr = "";
    Iterator it = null;
    FormsModel fm = null;
    try{
            Collection col = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findFormsDetailsByFormUuid(uuid,request);
            fm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findForms(uuid,request);
            it = col.iterator();
    }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="javascript">
<!--
    function btn_add(){
        window.navigate("formsDetailAdd.jsp?uuid=<%=uuid%>");
    }
    function btn_toFormList(){
        window.navigate("formsList.jsp");
    }
    function btn_modify(){
        Navigate("formsDetailModify.jsp");
    }
    function btn_delete(){
        Navigate("formsDetailDelete.jsp");
    }
    function Navigate(url)
    {
        var chk = getOnlyOneItem();
        if(chk == null)
        {
            return;
        }
        window.navigate(url + "?uuid=<%=uuid%>" + "&fdmUuid=" + chk.value);
    }
    function getOnlyOneItem()
    {
        var col = document.getElementsByName('fdmUuid');
        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,needAcl)
    {
        var i = tr.rowIndex - 1;
        var col = document.getElementsByName('fdmUuid');
        col(i).click();
        switchColor(oldIndex, false);
        oldIndex = i + 1;
        if(needAcl.indexOf('不检测')>=0){
        	document.all("qxsz").style.display = "none";
        }else{
        	document.all("qxsz").style.display = "block";
        }
        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 btn_ACL(){
        var chk = getOnlyOneItem();
        if(chk == null)
        {
            return;
        }
        var tableId = "<%= fm.getTblId()%>";
        var name = getFieldName(chk);
        var fieldId =  getFieldID(chk);
        var acl = new CfpDefaultPowerDefModel();
        acl.setCatPath('com.gx.cfp2.' + tableId + '.' + fieldId);
        acl.setPowerType(acl.POWER_TYPE_COL);
        acl.setName(name);
        acl.setAddWithForm(false);
        var ret = CHILDWIN.showPowerDialog(acl);
    }
    function getFieldName(chk)
    {
        var tr = chk.parentElement.parentElement;
        var td = tr.cells(3);
        return td.innerText;
    }
    function getFieldID(chk)
    {
        var tr = chk.parentElement.parentElement;
        var td = tr.cells(2);
        return td.innerText;
    }
//-->
</script>
    <title>业务对象建模</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">业务对象属性列表</h3>
<%if(!isError){%>
    <table class="content" id=listTable>
        <tr><td>&nbsp</td><td>属性编号</td><td>属性ID</td><td>属性名称</td><td>属性数据类型</td><td>属性数据长度</td></tr>
<%
            while(it != null && it.hasNext()){
            FormsDetailModel fdm = (FormsDetailModel)it.next();
              String needAcl = fdm.getColAclCap();
%>
            <tr onclick="itemClick(this,'<%=needAcl%>')" style="cursor:hand">
            <td><input type="radio" name="fdmUuid" value="<%=fdm.getUuid()%>"></td>
            <td><%=DataBean.getStr(fdm.getUuid())%>&nbsp;</td>
            <td><%=DataBean.getStr(fdm.getFieldId())%>&nbsp;</td>
            <td><%=DataBean.getStr(fdm.getFieldName())%>&nbsp;</td>
            <td><%=DataBean.getStr(fdm.getTypeCap())%>&nbsp;</td>
            <td><%=fdm.getFieldLength()%>&nbsp;</td>
<%
          }
%>
</table>
<table class="buttable1">
<tr>
<%if(fm.getStatus() != FormsModel.STATUS_PUBLISHED){%>
<td align=center><input class="butAction" type="button" name="but_add" value="增　　加" onclick="btn_add();">
<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>
<div id="qxsz" style="display : none">
	<input class="butAction" type="button" name="but_power"    value=" 权限设置 " onclick="btn_ACL();">
<div>
</td>
<%}else{%>
<td align=center>
<div id="qxsz" style="display : none">
	<input class="butAction" type="button" name="but_power"    value=" 权限设置 " onclick="btn_ACL();">
<div>
</td>
<%}%>
<td align=center><input class="butAction" type="button" name="but_toFormList" value="业务对象列表" onclick="btn_toFormList();">
</table>
<%}else{%>
<p align=center>生成列表失败．
<p align=center><%=infStr%>
<p align=center><input class="butAction" type="button" name="toFormList" value="业务对象列表" onclick="btn_toFormList();">
<%}%>
</div>
</body>
</html>
