Commonly used js for oa process of pan-micro oa process form

1. Control the selection range of the date field. For example, the cost generation date can only be selected from ten days before the current date to today, otherwise the process is not allowed to be submitted

封装方法: cus_judgeDateRange(fieldid, floorday, upperday)
* @param {
    
    fieldid} 日期字段ID
* @param {
    
    floorday} 下限天数(与当前日期比较),空值代表不限制
* @param {
    
    upperday} 上限天数(与当前日期比较),空值代表不限制
* @return 返回true表示在范围内,false表示超出限定范围或日期置为空

2. Calculate the difference in hours between the two date and time field combinations in real time and assign it to another field
Package method: cus_CalTimeDiff(begfields, endfields, unit, digit)

 * @param {
    
    begfields} 开始时间
 * @param {
    
    endfields} 结束时间
 * @param {
    
    unit} 计量结果单位1()、2(小时)、3(分钟)、4(),默认为天
 * @param {
    
    digit} 计算结果保留小数位数,默认2位小数
 * @return 以endfields字段值减去beginfields字段值得到时间差值

3. When the process is submitted, the verification end time must be greater than the start time, otherwise the process is not allowed to be submitted
Package method: cus_CompareTime(timefield1, timefield2)

 * @param {
    
    timefield1} 字段1(开始时间)
 * @param {
    
    timefield2} 字段2(结束时间)
 * @return 返回true表示timefield2较大,false表示timefield1较大或相等
 * 注:timefield1/timefield2结构,可为单独日期字段、单独时间字段、日期+时间组合字段(以英文逗号隔开);日期字段空值默认取今天,时间字段空值默认为00:00

4. There is no radio button (Radio style) in the E8 form field, how to realize the radio button? Convert the select box field into a single-select box display/edit

封装方法:cus_ConvertSelectToRadio(fieldids)
 * @param {
    
    fields}字段id集合,以逗号隔开
 *:转换后可能不支持联动功能,只是转换样式显示/编辑

5. Control the display and hiding of the detailed area according to the different selection box values

步骤一:设计器明细所在单元格/行设置自定义属性name:_detailarea
步骤二:代码块插入
cus_HideAreaByName("_detailarea");    //封装的根据name属性隐藏区域方法
cus_ShowAreaByName("_detailarea");    //封装的根据name属性显示区域方法

6. Control the hiding/display of the detail column according to the different value of the selection box

步骤一:需要隐藏的列设置列自定义属性class:_detailcolumn
步骤二:代码块插入
封装接口:cus_ControlDetailColumnByClass(cusclassname, status)
 * @param {
    
    cusclassname}  列自定义class属性
 * @param {
    
    status}  1为显示,2为隐藏

Seven, verify the specified fields are required

cus_verifyExistNullField("field13031,field13032", "字段未填写");    //封装的校验是否存在空值字段方法

8. According to the field ID, directly obtain the corresponding value of the field

cus_getFieldValue(fieldid)

Nine, assign a value to the text type field

cus_setInputFieldValue(fieldid, fieldvalue)

10. Points to note in detail lines

明细行数据行数:indexnum0
明细行序号行数:nodesnum0

11. Process browsing button stitching

function BrowseBoxData(viewtype, ahtml, id) {
    
    
	var ismust = 1;
	if (viewtype == '1') {
    
    
		ismust = 2;
	}

	var str = "<span class=\"e8_showNameClass\">";
	str += ahtml;

	// str += "<span class=\"e8_delClass\" id=\"" + id + "\" οnclick=\"del(event,this," + ismust + ",false,{});\" style=\"opacity: 1; visibility: visible;\">&nbsp;x&nbsp;</span></span>";
	str += "<span class=\"e8_delClass\" id=\"" + id + "\" οnclick=\"del(event,this," + ismust + ",false,{});\" style=\"opacity: 0; visibility: hidden;\">&nbsp;x&nbsp;</span></span>";
	return str;
};

Insert picture description here

12. Remove all detail lines

$("#detailDiv_0").find("tr").each(function(){
    
    
			if("datarow" == $(this).attr("_target")){
    
    
				$(this).remove();
			}
		});

Thirteen, simulate browsing button
1, rewrite browsing click event
Insert picture description here

2. Use ajax to call the background jsp page
Insert picture description here
Insert picture description here

14. Precautions
for process binding events Since the process itself has many binding events, you cannot use attr to splice the corresponding events in many cases. It is recommended to use bindProperty to bind
Insert picture description here

15. The js that went before submission

checkCustomize = function (){
    
    //提交的时候判断
	if(true){
    
    
		流程提交
	}else{
    
    
		流程不提交
	}
}

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/109018957