<%@ page contentType="text/html;charset=gb2312" %>
<%@ 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");
    FormsModel fm = null;
    boolean isSave = false;
    boolean isError = false;
    String infStr = "";
    try{
        fm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findForms(uuid,request);
        if(request.getMethod().equalsIgnoreCase("POST")){
            isSave = true;
            String tblId = DataBean.getStr(request, "tblId");
            String fieldId = DataBean.getStr(request, "fieldId");
            String fieldName = DataBean.getStr(request, "fieldName");
            String defaultValue = DataBean.getStr(request, "defaultValue");
            int fieldType = DataBean.getInt(request, "fieldType");
            int fieldLength = DataBean.getInt(request, "fieldLength");
            int operIndex = DataBean.getInt(request, "operIndex");
            int listView = DataBean.getInt(request, "listView");
            int notNull = DataBean.getInt(request, "notNull");
            int isOtherDoc = DataBean.getInt(request, "isOtherDoc");
            int otherDocType = DataBean.getInt(request, "otherDocType");
            int isAudit = DataBean.getInt(request, "isAudit");
            //int colAcl = DataBean.getInt(request, "colAcl");
            FormsDetailModel fdm = new FormsDetailModel();
            fdm.setFormUuid(fm.getUuid());
            fdm.setFieldId(fieldId);
            fdm.setFieldName(fieldName);
            fdm.setFieldType(fieldType);
            fdm.setFieldLength(fieldLength);
            fdm.setOperIndex(operIndex);
            fdm.setDefaultValue(defaultValue);
            fdm.setListView(listView);
            fdm.setNotNull(notNull);
            fdm.setIsOtherDoc(isOtherDoc);
            fdm.setOtherDocType(otherDocType);
            fdm.setIsAudit(isAudit);
            //fdm.setColAcl(colAcl);
            fdm = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().createFormsDetail(fdm,request);
        }
    }catch(Exception err){
        isError = true;
        infStr = DataBean.getErrStr(err);
    }
%>
<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_toList(){
        window.navigate("formsDetailList.jsp?uuid=<%=uuid%>");
    }
    function btn_addNext(){
        window.navigate("formsDetailAdd.jsp?uuid=<%=uuid%>");
    }
    function btn_add()
    {
        var b = UTIL.checkVarDefine("fieldId","请输入属性ID．");
        if(b == false)
        {
            return;
        }
        var b = UTIL.checkNull("fieldName", "请输入属性名称．");
        if(b == false)
        {
            return;
        }
        var fieldType = document.all("fieldType");
        var fieldLength = document.all("fieldLength");
        if(fieldType.value == 1)
        {
            var b = UTIL.checkInteger(fieldLength, false, 1, 4000, "属性数据长度");
            if(b == false)
            {
                return;
            }
        }
        else
        {
            fieldLength.value = 0;
        }
        var list1 = document.all("fieldType");
        var obj = document.all("fieldLength");
        list1.disabled = false;
        obj.disabled = false;
        ListForm.submit();
    }
    function fieldType_Changed(list)
    {
        var obj = document.all("fieldLength");
        var index = list.selectedIndex;
        if(index != 0)
        {
            obj.disabled = true;
            obj.value = 0;
        }
        else
        {
            obj.disabled = false;
            obj.value = 20;
        }
    }
//-->
</script>
<title>新增业务对象属性</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">新增业务对象属性</h3>
<%if(!isError){
    if(isSave){
%>
    <p align=center>新增成功.
    <table class="buttable2">
    <tr>
        <td width=50% align=center><input class="butAction" type="button" name="addNext" value="新增下一条" onclick="btn_addNext();">
        <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回属性列表" onclick="btn_toList();">
    </tr>
    </table>
<%}else{%>
<form id="ListForm" name="ListForm" method="POST">
<table class="content">
    <tr>
        <td>业务对象</td><td><%=fm.getTblId()%><input type="hidden" id="tblId" name="tblId" value="<%=fm.getTblId()%>"></td>
        <td>属性ID</td><td><input type="text" id="fieldId" name="fieldId"></td>
    </tr>
    <tr>
        <td>属性名称</td><td><input type="text" id="fieldName" name="fieldName"></td>
        <td>属性数据类型</td>
        <td><select id="fieldType" name="fieldType" onchange="fieldType_Changed(this);">
                <option value="<%=FormsDetailModel.TYPE_STRING%>" SELECTED><%=FormsDetailModel.CAP_TYPE_STRING%></option>
                <option value="<%=FormsDetailModel.TYPE_INT%>"><%=FormsDetailModel.CAP_TYPE_INT%></option>
                <option value="<%=FormsDetailModel.TYPE_FLOAT%>"><%=FormsDetailModel.CAP_TYPE_FLOAT%></option>
                <option value="<%=FormsDetailModel.TYPE_DOUBLE%>"><%=FormsDetailModel.CAP_TYPE_DOUBLE%></option>
                <option value="<%=FormsDetailModel.TYPE_LONG_NUM%>"><%=FormsDetailModel.CAP_TYPE_LONG_NUM%></option>
                <option value="<%=FormsDetailModel.TYPE_LONG_DATE%>"><%=FormsDetailModel.CAP_TYPE_LONG_DATE%></option>
            </select>
        </td>
    </tr>
    <tr>
        <td>属性数据长度</td><td><input type="text" id="fieldLength" name="fieldLength" value=20></td>
        <td>是否可以为空</td>
        <td>
            <input type="radio" id="notNull" name="notNull" value="<%=FormsDetailModel.NOTNULL_FALSE%>" checked>可以
            <input type="radio" id="notNull" name="notNull" value="<%=FormsDetailModel.NOTNULL_TRUE%>" >不可以
        </td>
    </tr>
    <!--<tr>
        <td>检测属性列数据权限</td>
        <td><input type=radio name=colAcl value=1 >检测
            <input type=radio name=colAcl value=0 checked>不检测
        </td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>-->
</table>
<table class="buttable2">
<tr>
    <td width=50% align=center><input class="butAction" type="button" name="add"    value="新　　增" onclick="btn_add();">
    <td width=50% align=center><input class="butAction" type="button" name="toList" value="返回属性列表" onclick="btn_toList();">
</tr>
</table>
</form>
<%}}else{%>
    <p align=center>新增失败.
    <p align=center><%= infStr%>
    <table class="buttable2">
    <tr>
        <td align=center><input class="butAction" type="button" name="toList" value="后　　退" onclick="window.history.back();">
        <td align=center><input class="butAction" type="button" name="toList" value="返回属性列表" onclick="btn_toList();">
    </tr>
    </table>
<%}%>
</div>
</body>
</html>
