Practical js and skills of the micro-oa process form

Practical js and skills in project implementation and development
1 Preface: js placement area
Process:
1) You can insert js code into the code block
2) You can create a jsp file, put the js code into the jsp, and the PC The path on the file server is updated to the custompage field of the workflow_base table, and the mobile terminal is updated to the custompage4Emoble field of the workflow_base table.
Modules:
1) You can insert the js code into the code block.
2) You can create a jsp file, put the js code in the jsp, and update the path on the file server to the custompage field of the table modeinfo.

2 js practical development application scenarios
Commonly used js pop-up prompts use alert().
Under this product, PC end uses Dialog.alert(); mobile end uses $.alert('', promptWrod);

For the process submission and modeling preservation methods, this method needs to be verified and rewritten before the form is saved:

checkCustomize = function(){
    
    return true;};

Value of form page field:

jQuery("#fieldid").val()

Date field comparison:

var date1 = jQuery("#field1id").val();
var date2 = jQuery("#field2id").val();

Compare directly after getting the value:

if(date1>=date2){
    
    }

The list table loops to obtain the value on the
PC side:

jQuery("input[name='check_node_0']").each(function(){
    
    
            var index = jQuery(this).val();
            jQuery(“#fieldid_”+index).val();

});
Mobile terminal:

jQuery("input[name='check_node_0']").each(function(){
    
    
            var index = jQuery(this).attr(‘_rowindex’);
            jQuery(“#fieldid_”+index).val();
});
控制明细表里行隐藏或显示:

jQuery(jQuery(’#fieldid_i’).parents(‘tr’)[0]).hide();
jQuery(jQuery(’#fieldid_i’).parents(‘tr’)[0]).show();

To bind events to the browse button type field, time and date type, use the bindPropertyChange method, for example:

jQuery("#fieldid").bindPropertyChange(function(){});
Bind events to select box type fields, you can use change
to bind events to text box type fields, and you can use blur or click
to bind check box type fields Event, you can use click

问题及技巧:
     在建模页面,bindPropertyChange方法不起作用,可新建一个文本类型的字段通过字段联动将浏览按钮的值赋值到文本字段中,再给文本类型的字段绑定事件
在主框架打开页面:
Window.open(url,’ mainFrame’);
     <a href=’url’ target=’ mainFrame’></a>

The dialog window opened by the system:

function openDialog(){
    
    
			dialog = new window.top.Dialog();
			dialog.currentWindow = window;
			dialog.Width = 600;宽度
			dialog.Height = 380;//高度
			dialog.Title = "title";//标题
			dialog.URL =url;//显示地址
			dialog.OKEvent = function(){
    
    //弹出框确认事件
				dialog.close();
			};
			dialog.show();
		}

A pop-up window opened by the system:

openFullWindow(url);

Add button skills to the process or modeling page:
add a field (any type), add buttons through jQuery's append() or after() method,

jQuery(“#fielid”).append(<input type='button' class='e8_btn_top_first' value='按钮' id='saveBtn' onclick='fun();'/>);

Determine the selection status of the checkbox:jQuery("#inputid").is(':checked'),//为true表示选中

Make the used detail row selected:jQuery("input[name=check_node_0]").attr("checked",true);

The main table field brings out the value of the detailed table field: the
background outputs the data in the format of a json array, and the front desk obtains the loop reading assignment through ajax.

	jQuery.ajax({
    
    
			type:"POST",
			url:url,
			data:{
    
     "param":value},
			success:function(res){
    
    
			    res = res.replace(/[\r]/g,"");	//替换换行
                res = res.replace(/[\n]/g,"");	//替换回车
				var json = eval("("+res+")");
					jQuery.each(json.data,function(i){
    
    
				          addRow0(0);
			var rowIndex=jQuery("input[name=check_node_0]:last").val(); 
 				      	  jQuery("#fieldid_"+rowIndex).val(json.data[i].value);
jQuery("#fieldid_"+rowIndex+"span").text(json.data[i].value);
				    });
				
			},
			error:function(e){
    
    }
		});

A confirmation prompt pops up for custom delete detail rows, how to omit this prompt:
override the detail delete method

isdel=function(){
    
      
			return true;  
		}

Commonly used method:
format the date, like yyyy-mm-dd

function formatDate(date) {
    
          
   		 var myyear = date.getFullYear();     
    		 var mymonth = date.getMonth()+1;     
    		 var myweekday = date.getDate();      
    		 if(mymonth < 10){
    
         
        		mymonth = "0" + mymonth;     
   		 }      
   		 if(myweekday < 10){
    
         
         	myweekday = "0" + myweekday;     
    		 }     
   		 return (myyear+"-"+mymonth + "-" + myweekday);      
}

Calculate the difference in days between two dates:

function getDateDiff(date1,date2){
    
    
			var arr1=date1.split('-');
 		var arr2=date2.split('-');
 		var d1=new Date(arr1[0],parseInt(arr1[1],10)-1,arr1[2]);
 		var d2=new Date(arr2[0],parseInt(arr2[1],10)-1,arr2[2]);
 		var result = (d2.getTime()-d1.getTime())/(1000*3600*24)
 		if(result < 0)
 		result = 0;
 		return result;
}

Scenario
According to the uploaded attachment, select the name of the first attachment as the value or title of a certain field of the process. First, set the field or title to empty:

setInterval("fileNameToRequestName()",200);
function fileNameToRequestName(){
    
    
	var index=1;
	var requestname = jQuery("#requestname").val();
	jQuery(".progressWrapper").each(function(){
    
    
		if(index==1){
    
    
			var $this = jQuery(this).children("div");
			var progressName = $this.children("div.progressName").text();
			progressName = progressName.substring(0,progressName.lastIndexOf("."));
			var progressBarStatus = $this.children("div.progressBarStatus").text();
			if(requestname==''){
    
    
				if("Cancelled"!=progressBarStatus){
    
    
					jQuery("#requestname").val(progressName);
					index++;
				}
			}
		}
	});
}

Dynamically display the page in an area according to the value selected on the page:
Method -:
1. Add an iframe and name the id of the iframe.
2. Bind the click event, method:

Window.open(url,iframe的id);

Method 2:
1. Add an iframe, command the id of the iframe, and attach the default src
2. Binding event method:

jQuery(“iframe”).attr(‘src’,url);
document.getElementById('iframe').src=src;

Need to get the value of the configuration file:

function getPropValue(propname,fieldname){
    
    
 var result = '';
 jQuery.ajax({
    
    
  url: 'url?poopname='+propname+'&fieldname='+fieldname,
     dataType: "text", 
     contentType : "charset=gbk",  
     async:false, 
     success:function(data){
    
    
      result = jQuery.trim(data);
     },
		 error:function(){
    
    },
  }); 
 return result;
}

Close the dialog box to refresh the current page, call the delayed refresh method in the action of the closed dialog box

	Function reflash(){
    
    
setTimeout(“location.reload(true);,1000);
}
var dialog = new window.top.Dialog();
		dialog.currentWindow = window;
		dialog.URL = dialogurl;
		dialog.Width = width ;
		dialog.Height = height;
		dialog.Title=title;
		dialog.Drag = true;
		dialog.CancelEvent = function(){
    
    
			reflash ();
			dialog.close();
		};
		dialog.show();

Please leave a message in the comment area and discuss together~~~

If necessary, please contact WeChat: hdygzh2019 At the same time, please explain your intention and make progress together! ! !

Guess you like

Origin blog.csdn.net/Y_6155/article/details/109019036