<%@page contentType="text/html; charset=GBK"%>
<%@page import="zr.zrpower.common.util.SysPreperty"%>
<%@page import="zr.zrpower.entity.sys.SessionUser"%>
<%@page import="zr.zrpower.ejb.sys.UIService"%>
<%@page import="zr.zrpower.common.util.DateWork"%>
<%@page import="zr.zrpower.collectionengine.service.ConfigService"%>
<%@page import="java.lang.Object"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>




<%
  int i=0;
  SessionUser user = (SessionUser) session.getAttribute("userinfo");
  UIService userUI = new UIService();
  String ID = request.getParameter("ID");
  if (ID==null){ID="";}

  ConfigService cs = new ConfigService();
  String strResult=cs.GetCtrlAbleFieldByFID(ID);

  // ctrlAbleFieldInfo="英文表名#中文表名#英文字段名#中文字段名#是#否#否#否#默认值&英文表名1#中文表名1#英文字段名#中文字段名#是#否#否#否#默认值1"
   String[] tempArray=strResult.split("&");
   String[] tempArraySub;
   String currentLine;
   String strshow_data="";
   strshow_data = strshow_data + "[";

   for(i=0;i<tempArray.length;i++)
   {
     if(tempArray[i].length()<1)
      continue;
     tempArraySub=tempArray[i].split("#");
      currentLine=String.valueOf(i+1);
      strshow_data = strshow_data + "[";
      strshow_data = strshow_data + "\""+tempArraySub[1]+"."+tempArraySub[3]+"\",";
      strshow_data = strshow_data + "\""+tempArraySub[4]+"\",";
      strshow_data = strshow_data + "\""+tempArraySub[5]+"\",";
      strshow_data = strshow_data + "\""+tempArraySub[6]+"\",";
      strshow_data = strshow_data + "\""+tempArraySub[7]+"\",";


      try {
          strshow_data = strshow_data + "\""+tempArraySub[8]+"\",";
      }
      catch (Exception exdata) {
          strshow_data = strshow_data + "\"\",";
      }

       if (i <tempArray.length-1 )
       {
            strshow_data = strshow_data + "\""+tempArraySub[0]+"."+tempArraySub[2]+"\"],\r\n";
       }else
       {
            strshow_data = strshow_data + "\""+tempArraySub[0]+"."+tempArraySub[2]+"\"]";
       }

   }
   strshow_data = strshow_data + "]";

%>
<HTML>
<HEAD>
<TITLE><%=SysPreperty.getProperty().SystemName%><%=SysPreperty.getProperty().Versoin%></TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=GBK">

<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<link REL="stylesheet" type="text/css" href="../../../zrsysmanage/css/<%=user.getUserCSS()%>">

<%}else{ %>
<link REL="stylesheet" type="text/css" href="../../../zrsysmanage/css/<%=user.getUserCSS()%>">
<%} %>

<SCRIPT type='text/javascript' src="../../../zrsysmanage/script/Public.js"></SCRIPT>
<SCRIPT type='text/javascript' src="../../../zrsysmanage/script/DealList.js"></SCRIPT>


<!--WEB组件样式和js-->
<%if("6".equals(user.getUserImage())){ %>
<link rel="stylesheet" type="text/css" media="all" href="../../../ZrwebGui/sigma_grid_html/grid/calendar/calendar-blue.css">
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid_html/grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid_html/grid/calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid_html/grid/gt_grid.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid_html/grid/skin/vista/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid_html/grid/skin/pink/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid_html/grid/skin/mac/skinstyle.css">
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid_html/grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid_html/grid/gt_const.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid_html/grid/gt_grid_all.js"></script>
<%}else{ %>
<link rel="stylesheet" type="text/css" media="all" href="../../../ZrwebGui/sigma_grid/grid/calendar/calendar-blue.css">
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid/grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid/grid/calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid/grid/gt_grid.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid/grid/skin/vista/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid/grid/skin/pink/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../../../ZrwebGui/sigma_grid/grid/skin/mac/skinstyle.css">
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid/grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid/grid/gt_const.js"></script>
<script type="text/javascript" src="../../../ZrwebGui/sigma_grid/grid/gt_grid_all.js"></script>

<%} %>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../../ZrCollEngine/DatePicker/WdatePicker.js"></SCRIPT>
<%}%>
<!--WEB组件样式和js结束-->

<script type="text/javascript" >
var css = "<%=user.getUserCSS()%>";
var skincss = "vista";

if (css=="Blue.css")
{skincss = "vista";}
else if (css=="Public.css")
{skincss = "default";}
else if (css=="Window.css" || css=="nBlue.css")
{skincss = "mac";}
else if (css=="Yellow.css")
{skincss = "pink";}
else{
skincss="mac";
}

var grid_demo_id = "myGrid1" ;
var show_data= <%=strshow_data%>;


var dsOption= {

	fields :[
		{name : 'NAME1'  },
		{name : 'NAME2'  },
                {name : 'NAME3'  },
		{name : 'NAME4'  },
                {name : 'NAME5'  },
		{name : 'NAME6'  },
		{name : 'NAME7' }

	],

	recordType : 'array',
	data : show_data
}



var colsOption = [

           {id: 'NAME1' , header: "<center>字段名称</center>" , width :280,  align : 'center',sortable:false  },
	   {id: 'NAME2' , header: "<center>是否显示</center>" , width :70 ,align : 'center',sortable:false  },
           {id: 'NAME3' , header: "<center>是否编辑</center>" , width :70,  align : 'center',sortable:false  },
	   {id: 'NAME4' , header: "<center>是否必填</center>" , width :70 ,align : 'center',sortable:false  },
           {id: 'NAME5' , header: "<center>强制设置</center>" , width :70,  align : 'center',sortable:false  },
	   {id: 'NAME6' , header: "<center>默认值</center>" , width :150 ,align : 'center',sortable:false  },
	   {id: 'NAME7' , header: "<center>字段名称(En)</center>" , width :160 , align : 'center',hidden:true  }
];


var gridOption={
	id : grid_demo_id,
	width: "860",
	height: "280",
	container : 'gridbox',
	replaceContainer : true,
	dataset : dsOption ,
	columns : colsOption,
	pageSize : 2000,
	toolbarContent : null,
        skin : skincss,

        onCellClick:function(value, record , cell, row,  colNO, rowNO,columnObj,grid){

           gridCtrlAbleFieldClick(rowNO);
        },

       showIndexColumn : true
};


var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad( Sigma.Grid.render(mygrid));

</script>


<SCRIPT LANGUAGE="javascript">

function Check(theForm)
{
  try
  {
    fillCtlFieldInfoStr();//可控字段的处理
    return true;
  }
  catch(e)
  {
    return false;
  }
}

function ShowModal()
{
<%if("6".equals(user.getUserWINDOWTYPE())){%>
  layer.open({
  type: 2,
  title: '默认值设置',
  area: ['770px', '380px'],
  shade: 0.2,
  closeBtn: 0,
  skin: 'yourclass',
  shadeClose: true,
  content: 'CtlAbleFieldDValue.jsp?zdid=txtDefaultValue&strResult='+RegForm.txtDefaultValue.value
});
  <%}else{%>
  var url='CtlAbleFieldDValue.jsp?strResult='+RegForm.txtDefaultValue.value;
  var status='dialogHeight:370px;dialogWidth:780px;status:0;help:no;center:yes';
  var rtnResult=window.showModalDialog(url,window,status);
 if (rtnResult!=null)
   {
     RegForm.txtDefaultValue.value=rtnResult;
   }
  <%}%>
}



function gridCtrlAbleFieldClick(rowNO)
{

   RegForm.row.value=rowNO;
   var allvalue = mygrid.getSelectedRecords()+",0";
   var strValue = allvalue.split(",");


   RegForm.txtCtlFieldName.value=strValue[0];

   if(strValue[1]=="是")
     RegForm.isDisplay.checked=true;
    else
     RegForm.isDisplay.checked=false;

     if(strValue[2]=="是")
     RegForm.isEdit.checked=true;
    else
     RegForm.isEdit.checked=false;

    if(strValue[3]=="是")
     RegForm.isMustFill.checked=true;
    else
     RegForm.isMustFill.checked=false;


    if(strValue[4]=="是")
     RegForm.isForce.checked=true;
    else
     RegForm.isForce.checked=false;

   RegForm.txtDefaultValue.value=strValue[5];
}

function UpdateCtlFieldGrid()
{
   var allvalue = mygrid.getSelectedRecords()+",0";

   var row=RegForm.row.value;
   if(row==null)
   {

     <%if("6".equals(user.getUserWINDOWTYPE())){%>
    parent.parent.layer.alert('文档名称不能为空!', {icon: 7});
    <%}else{%>
     alert("执行的操作无效!");
    <%}%>
     return;
   }


   if(RegForm.isDisplay.checked)
      mygrid.setCellValue("NAME2",row,"是");
   else
      mygrid.setCellValue("NAME2",row,"否");

  if(RegForm.isEdit.checked)
     mygrid.setCellValue("NAME3",row,"是");
   else
     mygrid.setCellValue("NAME3",row,"否");

  if(RegForm.isMustFill.checked)
     mygrid.setCellValue("NAME4",row,"是");
   else
     mygrid.setCellValue("NAME4",row,"否");

 if(RegForm.isForce.checked)
     mygrid.setCellValue("NAME5",row,"是");
   else
     mygrid.setCellValue("NAME5",row,"否");

  mygrid.setCellValue("NAME6",row,RegForm.txtDefaultValue.value);

  mygrid.refresh();
}

 function fillCtlFieldInfoStr()
{

  var strResult="";
  for(row=0;row<mygrid.getRowNumber();row++)
  {

      strResult+=mygrid.getCellValue("NAME7",row)+"#"+
               mygrid.getCellValue("NAME2",row)+"#"+
               mygrid.getCellValue("NAME3",row)+"#"+
               mygrid.getCellValue("NAME4",row)+"#"+
               mygrid.getCellValue("NAME5",row)+"#"+
               mygrid.getCellValue("NAME6",row)+"&";

  }
  RegForm.CtlFieldInfoStr.value=strResult;

}


function openDoc()
{
<%if("6".equals(user.getUserWINDOWTYPE())){%>
  parent.layer.open({
  type: 2,
  title: '查看模板',
  maxmin: false,//是否可以最大化
  area: ['850px', '420px'],
  content: '../../../collengine.do?COLL_AID=<%=ID%>&coll_PKID=&coll_FKID=&coll_MODE=2'
});
  <%}else{%>
   OpenMenuWindow("opendoc.jsp?ID=<%=ID%>");

   <%}%>
}

</SCRIPT>
</HEAD>
<BODY class="BodyMain">
<FORM name="RegForm" method="post" action="../../../actionsubconfigmsg.do">
<input type="hidden" name="CtlFieldInfoStr">
<input type="hidden" name="FID" value="<%=ID%>">
<input type="hidden" name="Act" value="setfield">
<input type="hidden" name="row" value="0">


<table border='0' width="100%" cellspacing="0" cellpadding="0" align=center>
              <tr>
                <td>

           <br>
       <table border='0' width="100%" cellspacing="0" cellpadding="0" align=center>
              <tr>
                <td colspan=2 height=150>
                  <table border='0' width="100%" cellspacing="0" cellpadding="0" align=center>
                  <tr>
                    <td align=right width="10%" height="30">字段名称：</td>
                    <td width="40%"><input class="text" type="text" name="txtCtlFieldName" size="35"   maxlength="100" value=""  readonly="readonly"></td>
                    <td align=left width="50%" colspan="2">

                       <table cellspacing="0" cellpadding="0" border='0'><tr>
                       <td><input type="checkbox" name="isDisplay" value="0" />显示
                        &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="isEdit" value="0" />编辑
                       &nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="isMustFill" value="0" />必填&nbsp;&nbsp;</td>
                       <%=userUI.ClickButton("查看模板","JavaScript:openDoc()","IcoBrowse.gif",user.getUserImage())%>
                       </tr></table>

                   </td>
                   </tr>
                    <tr>
                    <td align=right height="30"><input type="checkbox" name="isForce" value="0" />强制设置</td>
                    <td  align="left" colspan="3">
                     <table cellspacing="0" cellpadding="0" border='0'>
                       <tr>
                          <td>
                              &nbsp; &nbsp;默认值：
                               <input class="text" type="text" name="txtDefaultValue" id="txtDefaultValue" size="65" maxlength="1000" value="">

                                </td>
                                <%=userUI.ClickButton("设置","JavaScript:ShowModal();","buttonSelect.gif",user.getUserImage())%>
                                <%=userUI.ClickButton("更新","JavaScript:UpdateCtlFieldGrid();","buttonCancel.gif",user.getUserImage())%>

                       </tr>


                   </table>
                   &nbsp;&nbsp;&nbsp;<font class="WriteSign">说明：设置默认值时选强制设置时字段中有无值时都设置。</font>
                 </td>
                </tr>

             </table>
             <br>
             <div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:600px;width:800px;" ></div>

              </td>
              </tr>
            </table>


    </td>
  </tr>
  <tr><td style="height:8px"></td></tr>
  <tr valign="bottom" >
    <td valign="bottom">
      <center>

        <table cellspacing="0" cellpadding="0" border='0'>
          <tr>
            <%=userUI.ClickButton("保存","JavaScript:if(Check(document.RegForm)){document.RegForm.submit();}","buttonSave.gif",user.getUserImage())%>

            <%if("6".equals(user.getUserWINDOWTYPE())){%>
               <%=userUI.ClickButton("关闭","JavaScript:parent.layer.closeAll();","buttonClose.gif",user.getUserImage())%>

           <%}else{ %>
            <%=userUI.ClickButton("关闭","JavaScript:window.close();","buttonClose.gif",user.getUserImage())%>
         <%} %>
          </tr>
        </table>
        <br>
      </center>
    </td>
  </tr>
</table>


</FORM>
</BODY>
</HTML>
<%
user =null;
userUI=null;

%>
