Record once to add a js code block in Panwei OA, and limit the start date and time to not be greater than or equal to the end date and time

Target:

  • When submitting after selecting a process, the selected start date and time cannot be greater than the end date and time
  • The selected start date and time cannot be equal to the end date and time
  • Submission is only possible if the above conditions are met

Renderings:

 The steps to add js code in the OA background are as follows:

 Figure 1 (refer to Figure 1 for steps 1-5)

Figure 2  (refer to Figure 2 in step 6)

 Figure 3 (refer to Figure 3 in step 7)

 Figure 4 (refer to Figure 4 for steps 8-9)

  1. After entering the background, select the "Process Engine" menu
  2. Select the "Path Settings" menu on the left menu
  3. Find and click the process that needs to be modified
  4. Find "Transfer Settings" ---> "Node Information" in the process information on the right 
  5. Select the node to be modified in the "Form Content" column, and click
  6. In the pop-up window after clicking, refer to Figure 2 and click the applicant to display the template
  7. Select the start date, time and end date, time fields respectively, and then write down the ID corresponding to each field from the lower right corner to obtain the corresponding value
  8. Click "Insert" ---> "Code Block" and an editable code box will pop up
  9. Add your own logic code in the box, click " OK"
  10. Finally, save the modification of the process, and then go to create the process to find that it has taken effect

Finally on the code:

<script type="text/javascript"> 
    // 来访日期id:field28480 来访时间id:field28481
    // 离开日期id:field28482 离开时间id:field28483
    var beginTime = {date: "field28480", time: "field28481"};
    var endTime   = {date: "field28482", time: "field28483"};
    $(document).ready(function(){
        checkCustomize = function (){
            var a= new Date($("#" + beginTime.date).val() + " " +$("#" + beginTime.time).val());
            var b= new Date($("#" + endTime.date).val() + " " +$("#" + endTime.time).val());    
            if(a > b){
                window.top.Dialog.alert("来访日期时间不得大于离开日期时间,请检查后重新选择!");                          
                return false;
            }else if(a-b==0){
                window.top.Dialog.alert("来访日期时间与离开日期时间相同,请检查后重新输入!");
                return  false;
            }else{
                return true;
            };	                                          
        };       	  
    });
</script>

That's it! ! !

The test works! ! ! Thanks for the support! ! !

Guess you like

Origin blog.csdn.net/qq_38543537/article/details/131576575