BlogJava 首页 新随笔 联系 聚合 管理
  2 Posts :: 0 Stories :: 0 Comments :: 0 Trackbacks

<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/common/inc_bns.jsp"%>


<%
String orgGuid = (String)request.getParameter("orgGuid");
%>
<html>
 <head>
  <script language="javascript" src="<%=mainWeb%>/script/util/xmlutil.js"></script>
  <script language="javascript" src="<%=mainWeb%>/script/util/stringutil.js"></script>
  <script language="javascript" src="<%=mainWeb%>/script/ajax/ajax.js"></script>
 </head>
 <body topmargin="18">
   <table class="data_tb" align="center" width="90%">
    <tr height="25">
     <td class="data_tb_td" width="30%">任务名称&nbsp;<font color="red">*</font></td>
     <td ><input style="width:65%" id="jobName" name="jobName"></td>
    </tr>
    <tr>
     <td class="data_tb_td">spring bean</td>
     <td><input style="width:65%" id="springBean" name="springBean"></td>
    </tr>
    <tr>
     <td class="data_tb_td">方法名</td>
     <td><input style="width:65%" id="methodName" name="methodName" onkeyup="showMethod()" onblur=selMethod($('javaMethod').value)></td>
    </tr>
    <tr>
     <td class="data_tb_td">方法描述</td>
     <td><select style="width:65%" id="javaMethod" name="javaMethod" onblur=selMethod($('javaMethod').value)></select></td>
    </tr>
    <tr>
     <td class="data_tb_td">任务描述</td>
     <td><textarea rows="4" id="jobRemark" name="jobRemark" style="width:90%" ></textarea></td>
    </tr>
    <tr id="paramTR" style="display:none">
     <td colspan="2">
      <div class="splitDiv">
        <div class="tip">
        <img src="<%=skinImage%>/main/arrow.gif">参数定义</div>
         <table width="100%" border="0" class="data_tb" id="tbParam" cellspacing="0" cellpadding="0">
          <tr height="25">
           <td class="list_table_head" width="40%" >参数名称</td>
           <td class="list_table_head" width="60%">参数描述</td>
          </tr>
          <!--用来复制的空行 开始-->
          <tr height="25" style="display:none">
           <td align="center"><input type='text' style="width:70%" name="paramName" class="txtInput"/></td>
           <td align="center"><input type='text' style="width:80%" name="paramRemark" class="txtInput"/></td>
          </tr>
         </table>
        </div>
        <!-- 快捷键配置 结束 -->
        </tr>
       </table>
      </div>
     </td>
    </tr>
   </table>
   <div class="buttonDiv" style="margin-top:18px;">
    <input type="button" class="button" name="save" value="保  存" onclick="doSave()">
    &nbsp;<input type="button" class="button" value="取  消" onclick="window.close();">
   </div>
 </body>
</html>
<script>
var orgGuid = '<%=orgGuid%>';

function doSave(){
 if (trim($('jobName').value) != '') {
  var reqUrl = webPath + '/JobMngAction.do?method=saveNewJob';
  if(checkKeysRowData() != true) {
   return;
  }else {
   var param = getData();
   sendRequestMore(reqUrl,param,"doJobSave()");
   document.all.save.disabled = true;
   }
 } else {
  alert("请输入任务名称");
  return;
 }
}

//新增回调
function doJobSave(){
 if(xml_request.responseText != ''){
  var retScript = parseXmlbyXMLHttpRequest(xml_request,"resultInfo");
  popAlert(retScript,function(){
   window.close();
  });
 }
}

//以XML格式组织待保存的数据
function getData(){
 return (getJobData() + getParamData());
}

//获取系统样式基本配置信息
function getJobData(){
 var xml = '<Jobs>';
  xml += '<job><jobName>' + document.all.jobName.value + '</jobName>';
  xml += '<springBean>' + document.all.springBean.value + '</springBean>';
  xml += '<methodName>' + document.all.methodName.value + '</methodName>';
  xml += '<javaMethod>' + document.all.javaMethod.value + '</javaMethod>';
  xml += '<jobRemark>' + trim(document.all.jobRemark.value) + '</jobRemark>';
  xml += '<orgGuid>' + orgGuid + '</orgGuid>';
  xml += '</job>';
 xml += '</Jobs>';
 return xml;
}

//获取录入参数信息
function getParamData(){
 var rows = document.getElementById('tbParam').rows;
 var xml = '<Params>';
 for(var k = 2,len = rows.length; k < len; k++){
  xml += '<param><name>' + trim(rows[k].cells[0].firstChild.value) + '</name>';
  xml += '<remark>' + trim(rows[k].cells[1].firstChild.value) + '</remark>';
  xml += '</param>';
 }
 xml += '</Params>';
 return xml;
}

//获取方法描述
function showMethod(){
 if (checkLength($('springBean').value)>0 && checkLength($('methodName').value)>0){
  var url = "<%=mainWeb%>/JobMngAction.do?method=getMethod&springBean="+$('springBean').value+"&methodName="+$('methodName').value;
  sendRequest(url,"showJobDetail()");
 }else  {
  return;
 }
}
//展示方法描述,同时展示对应所需要的方法参数的个数
function showJobDetail(){
 if(http_request.responseText!=""){
  $('javaMethod').outerHTML = http_request.responseText;
  var hadoption = $('javaMethod').outerHTML.split("OPTION");
  if (hadoption.length > 1) {
   var textValue = $('javaMethod').options[$('javaMethod').selectedIndex].innerText;
   var leftpoint = textValue.indexOf("(");
   var rightpoint = textValue.lastIndexOf(")");
   var newtextValue = textValue.substr( parseInt(leftpoint),parseInt(rightpoint) );
   document.all.save.disabled = false;
   if (newtextValue != null && newtextValue != 'null' && newtextValue.length>0) {
    var params = newtextValue.split("String");
    if (params.length-1 > 0) {
     /*取得当前表*/
     var tab = document.getElementById('tbParam');
     var lc = tab.rows.length;
     if (lc > 2){
      for (var i=lc;i>2;i--) {
       /*执行删除*/
       tab.rows[i-1].removeNode(true);
      }
      $('paramTR').style.display="";
     }
     
     for (var num=0;num<params.length-1;num++) {
      /*取得表内容第一行*/
      var rows = document.getElementById('tbParam').rows;
      var firstTR = tab.rows[1];
        /*克隆第一行内容*/
        var newTR = firstTR.cloneNode(true);
        /*将克隆的一行追加到当前DOM对象的最后*/
        tab.firstChild.appendChild(newTR);
        /*将克隆的一行显示出来*/
        newTR.style.display = "";
     }
     $('paramTR').style.display="";
    }else {
     $('paramTR').style.display="none";
    }
   }
  }else  {
   document.all.save.disabled = true;
   return;
  }
 }else  {
  return;
 }
}


//响应方法描述下拉矿选择,变换方法名称
function selMethod(value){
 var index = value.indexOf("(");
 $('methodName').value=value.substring(0,index);
 $('javaMethod').value=value;
 selectShowJobDetail();
}

//选择方法描述后选择到的方法
function selectShowJobDetail() {
 if(http_request.responseText!=""){
  var textValue = document.all.javaMethod.value;
  var hadoption = $('javaMethod').outerHTML.split("OPTION");
  if (hadoption.length > 1) {
   var leftpoint = textValue.indexOf("(");
   var rightpoint = textValue.lastIndexOf(")");
   var newtextValue = textValue.substr( parseInt(leftpoint),parseInt(rightpoint) );
   document.all.save.disabled = false;
   if (newtextValue != null && newtextValue != 'null' && newtextValue.length > 0) {
    var params = newtextValue.split("String");
    if (params.length-1 > 0) {
     /*取得当前表*/
     var tab = document.getElementById('tbParam');
     var lc = tab.rows.length;
     if (lc > 2){
      for (var i=lc;i>2;i--) {
       /*执行删除*/
       tab.rows[i-1].removeNode(true);
      }
      $('paramTR').style.display="";
     }
     
     for (var num=0;num<params.length-1;num++) {
      /*取得表内容第一行*/
      var rows = document.getElementById('tbParam').rows;
      var firstTR = tab.rows[1];
        /*克隆第一行内容*/
        var newTR = firstTR.cloneNode(true);
        /*将克隆的一行追加到当前DOM对象的最后*/
        tab.firstChild.appendChild(newTR);
        /*将克隆的一行显示出来*/
        newTR.style.display = "";
     }
     $('paramTR').style.display="";
    }else {
     $('paramTR').style.display="none";
    }
   }
  }else  {
   document.all.save.disabled = true;
   return;
  }
 }else  {
  return;
 }
}

 

function doAddNewTD(obj){
   /*取得当前表*/
   var tab = obj.parentElement.parentElement.parentElement;
   /*取得表内容第一行*/
   var firstTR = tab.rows[1];
   var rows = document.getElementById('tbParam').rows;
   /*克隆第一行内容*/
   var newTR = firstTR.cloneNode(true);
   /*将克隆的一行显示出来*/
   newTR.style.display = "";
   /*将克隆的一行追加到当前DOM对象的最后*/
   tab.appendChild(newTR);
}

/*从表格中移出一行*/
function doRemoveTD(obj){
   /*取得当前行*/
   var curRow = obj.parentElement.parentElement;
   /*取得当前操作表*/
   var tab = curRow.parentElement;
   /*只有大于两行的时候才准予删除*/
   if (tab.rows.length > 3){
 /*执行删除*/
 tab.deleteRow(curRow.rowIndex);
   }
}

//检验任务录入的数据是否合法
function checkJobData() {
 var jobName = document.all.jobName.value;
 var springBean = document.all.springBean.value;
 var methodName = document.all.methodName.value;
 var javaMethod = document.all.javaMethod.value;
 var jobRemark = document.all.jobRemark.value;
 if (checkLength(jobName)>50) {
  alert("任务名称过长!");
  return false;
 }
 if (trim(jobName) == '' ) {
  alert("任务名称不能为空!");
  return false;
 }
 if (checkLength(springBean)>30) {
  alert("spring Bean名称过长!");
  return false;
 }
 if (trim(springBean) == '' ) {
  alert("spring Bean名称不能为空!");
  return false;
 }
 if (checkLength(methodName)>30) {
  alert("方法名过长!");
  return false;
 }
 if (trim(methodName) == '' ) {
  alert("方法名不能为空!");
  return false;
 }
 if (checkLength(javaMethod)>250) {
  alert("方法描述过长!");
  return false;
 }
 if (trim(javaMethod) == '' ) {
  alert("方法描述不能为空!");
  return false;
 }
 if (checkLength(jobRemark)>250) {
  alert("任务描述过长!");
  return false;
 }
 return true;
}


//检验行内录入的参数否合法
function checkKeysRowData(){
 var rows = document.getElementById('tbParam').rows;
 checkJobData();
 for(var i=2,len = rows.length;i<len;i++) {
  var strvalueName = rows[i].cells[0].firstChild.value;
  var strvalueRemark = rows[i].cells[1].firstChild.value;
  if (trim(strvalueName) == "" || trim(strvalueRemark) == "") {
   alert("参数不能为空");
   return false;
  }
  if (checkLength(strvalueName)>50) {
   alert("第"+i+"行参数名称太长!");
   return false;
  }
  if (checkLength(strvalueRemark)>100) {
   alert("第"+i+"行参数描述太长!");
   return false;
  }
 }
 return true;
}
</script>

posted on 2008-03-04 18:36 海浪 阅读(153) 评论(0)  编辑  收藏 所属分类: 前台技术(javascript)

只有注册用户登录后才能发表评论。


网站导航: