<%@page contentType="text/html; charset=GBK" %>

<%@page import="zr.zrpower.common.util.SysPreperty"%>
<%@page import="zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "zr.zrpower.flowengine.mode.base.Variable"%>
<%@ page import = "zr.zrpower.flowengine.service.FlowSetup"%>

<%@page import="zr.zrpower.entity.sys.SessionUser"%>

<html>
<%SessionUser user = (SessionUser) session.getAttribute("userinfo");

FlowSetup flowSetup = new FlowSetup();
Variable[] Variables = null;
Variables = flowSetup.GetVariableList();
  request.setCharacterEncoding("GBK");
String strResult=request.getParameter("strResult");

  //html5用到
  String userClass="windowimg";
  String zdid=request.getParameter("zdid");
  if(!"6".equals(user.getUserImage())){
     userClass=user.getUserImage();
  }
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
<title><%=SysPreperty.getProperty().SystemName%><%=SysPreperty.getProperty().Versoin%></title>

<link REL="stylesheet" type="text/css" href="../../../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/script/Public.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../../zrsysmanage/script/DealList.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../../js/Workflow.js"></SCRIPT>
<script type='text/javascript' src='../../../dwr/engine.js'></script>
<script type='text/javascript' src='../../../dwr/util.js'></script>
<script type='text/javascript' src='../../../dwr/interface/FlowMaActBean.js'></script>
<SCRIPT type='text/javascript' src="../../js/Workflow.js"></SCRIPT>
<script Language="javascript">
function btnSpecialValue(strValue)
{
  if(CheckInputWhereExpression(RegForm.txtResult.value,strValue))
     RegForm.txtResult.value=RegForm.txtResult.value+strValue;
}

function ShowHelpModal()
{

  var url='formulaHelp.jsp';
  var status='dialogHeight:600px;dialogWidth:500px;status:0;help:no;center:yes';
  window.showModalDialog(url,window,status);
}


    function fillFieldName(obj)
   {
     var table=RegForm.TableList;
     fieldName="["+table.options[table.selectedIndex].value+"."+obj.options[obj.selectedIndex].value+"]";
     RegForm.txtResult.value= RegForm.txtResult.value+fieldName;
   }

  function   fillVariable(obj)
  {
   RegForm.txtResult.value=RegForm.txtResult.value+obj.options[obj.selectedIndex].value;
  }

  function  OKClick()
  {

   <%if("6".equals(user.getUserImage())){%>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
      var str='<%=zdid%>';
      str=document.all("txtResult").value;

      parent.$('#<%=zdid%>').val(document.all("txtResult").value);
      parent.layer.close(index);
    <%}else{%>
      window.returnValue=RegForm.txtResult.value;
   window.close();

    <%}%>
  }
</script>

</head>
<%
  UIService userUI = new UIService();
%>
<body class="BodyMain">
<form action="" method="post" name="RegForm">


  <fieldset style="width:98%">
    <legend>默认值</legend>
      <table border='0' width="99%" cellspacing="0" cellpadding="0" align=center>
                <tr>
                  <td colspan="2">
                    <table border='0' width="755" cellspacing="0" cellpadding="0" align=center>
                      <tr>
                        <td style="width:110px" align="center" height=23>
                          待选表
                        </td>
                        <td style="width:110px" align="center">
                          待选字段
                        </td>
                        <td style="width:130px" align="center">
                          待选变量值
                        </td>
                        <td style="width:410px" align="center"></td>
                      </tr>
                      <tr>
                        <td align="center">
                          <select id="TableList" name="TableList" style="width:100px;height:150px" size=15 onchange='loadFieldList(this.value)' >
                          </select>
                        </td>
                        <td align=center>
                          <select id="FieldList" name="FieldList" style="width:100px;height:150px" size=15 onclick="fillFieldName(this)">
                          </select>
                        </td>
                        <td  align="center" >
                          <select name="VaribleList" style="width:120px;height:150px" size=15 onchange="fillVariable(this)" >
                          <%
                          if(Variables!=null)
                          {
                            for(int i=0;i< Variables.length;i++)
                            {
                              out.print("<option value=\""+Variables[i].getCODE()+"\">"+Variables[i].getNAME()+"</option>");
                            }
                          }
                          %>
                           <Option value="^UserIdea^">用户意见(流程内置变量)</Option>
                          </select>
                        </td>
                        <td align="center" valign="top">

                          <input  type="button" value="+" class="Button1" onclick="btnSpecialValue('+')"/>
                          <input  type="button" value="-" class="Button1" onclick="btnSpecialValue('-')"/>
                          <input  type="button" value="*" class="Button1" onclick="btnSpecialValue('*')"/>
                          <input  type="button" value="/" class="Button1" onclick="btnSpecialValue('/')"/>
                           <input  type="button" value=">" class="Button1" onclick="btnSpecialValue('>')"/>
                          <input  type="button" value=">=" class="Button1" onclick="btnSpecialValue('>=')"/><br /><br />
                          <input  type="button" value="<"  class="Button1" onclick="btnSpecialValue('<')"/>
                          <input  type="button" value="<=" class="Button1" onclick="btnSpecialValue('<=')"/>
                          <input  type="button" value="!=" class="Button1" onclick="btnSpecialValue('!=')"/>
                          <input  type="button" value="=" class="Button1" onclick="btnSpecialValue('=')"/>
                          <input  type="button" value="(" class="Button1" onclick="btnSpecialValue('(')"/>
                          <input  type="button" value=")" class="Button1" onclick="btnSpecialValue(')')"/><br /><br />
                          <input  type="button" value="AND" class="Button1" onclick="btnSpecialValue(' AND ')"/>
                          <input  type="button" value="OR" class="Button1" onclick="btnSpecialValue(' OR ')"/>
                          <input  type="button" value="0" class="Button1" onclick="btnSpecialValue('0')"/>
                          <input  type="button" value="1" class="Button1" onclick="btnSpecialValue('1')"/>
                          <input  type="button" value="2" class="Button1" onclick="btnSpecialValue('2')"/>
                          <input  type="button" value="3" class="Button1" onclick="btnSpecialValue('3')"/><br /><br />
                          <input  type="button" value="4" class="Button1" onclick="btnSpecialValue('4')"/>
                          <input  type="button" value="5" class="Button1" onclick="btnSpecialValue('5')"/>
                          <input  type="button" value="6" class="Button1" onclick="btnSpecialValue('6')"/>
                          <input  type="button" value="7" class="Button1" onclick="btnSpecialValue('7')"/>
                          <input  type="button" value="8" class="Button1" onclick="btnSpecialValue('8')"/>
                          <input  type="button" value="9" class="Button1" onclick="btnSpecialValue('9')"/>
                        </td>
                      </tr>
                   <tr>
                   <td colspan=4 style="border-bottom:1px inset #999999;">　</td>
                   </tr>
                   <tr>
                   <td colspan=4 height=5>&nbsp;</td>
                   </tr>
                   <tr>
                    <td align=center colspan=4>设置结果：<input class="text" type="text" name="txtResult" id="txtResult" size="93" value="<%=strResult%>"   maxlength="1000" ></td>

                   </tr>
                    </table>
                  </td>
                </tr>
              </table>
              <br>
  </fieldset>
  <center>
    <br>
     <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <%=userUI.ClickButton1("确 定","OKClick();","buttonSure.gif",user.getUserImage())%>


                 <%if("6".equals(user.getUserWINDOWTYPE())){%>
             <%=userUI.ClickButton1("关 闭","parent.layer.closeAll();","buttonClose.gif",user.getUserImage())%>
  <%}else{ %>
   <%=userUI.ClickButton1("设置帮助","JavaScript:ShowHelpModal();","buttonSelect.gif",user.getUserImage())%>
     <%=userUI.ClickButton1("取 消","window.close();","buttonClose.gif",user.getUserImage())%>
 <%} %>
          </tr></table>
    <br/>
  </center>


<%
//清空相关对象
user = null;
userUI = null;
flowSetup = null;
%>
</form>
</body>
</html>
<SCRIPT LANGUAGE="javascript">

   // 加载数据表下拉列表。
    function loadTableList(){
        FlowMaActBean.GetTableList(
        function(items){
              dwr.util.addOptions("TableList",items,0,1);

              if(RegForm.TableList.length>0)
              {
                RegForm.TableList.selectedIndex=0;
                loadFieldList(RegForm.TableList.value);
              }


        }
        );

    }

    loadTableList();


     // 加载字段下拉列表。
    function loadFieldList(TableName){
        if(TableName==null||TableName==''){
       ClearList("FieldList");
        return;
        }

        FlowMaActBean.GetFieldList(TableName,
        function(items){
              ClearList("FieldList");
              dwr.util.addOptions("FieldList",items,0,1);
              if(RegForm.FieldList.length>0)
              {
                RegForm.FieldList.selectedIndex=0;
              }

        }
        );


    }


    function ClearList(ObjId){
        dwr.util.removeAllOptions(ObjId);
    }



</SCRIPT>
