天天看點

jQuery easyUI combotree和combobox使用執行個體

jQuery easyUI combotree和combobox使用執行個體

背景代碼:

@ActionAnnotation(name = "查詢資料字典清單",group = "查詢", check = LOGIN)
     public ModelAndView queryCombotree(HttpServletRequest request, HttpServletResponse response) throws Exception {
     String sd_code = request.getParameter("sd_code");
     
     Dict dict = new Dict();
     dict.setMode("sd_code");
     dict.setSd_code(sd_code);
     dict.setSd_parent_id(Dict.ROOT_CODE);
     Dict query = dictService.query(dict);
     
     Dict dict2 = new Dict();
     dict2.setMode("sd_path2");
     dict2.setSd_path(query.getSd_id());
     
         String tree = dictService.treeSingle(dict2);
         return responseText(response, tree);
     }      
$("#wf_type").combotree({
                         url:"${path}/sys/dict_
queryCombotree.do?sd_code=flowtype",

                         editable : false ,

                         valueField : 'id',

                         textField : 'text',

                         onSelect: function(data) {

                             //傳回樹對象

                         var tree = $('#wf_type').combotree('tree').tree;

                         //選中的節點是否為葉子節點,如果不是葉子節點,清除選中

                         var isLeaf = tree('isLeaf', data.target);

                         if (!isLeaf) {

                             $.messager.alert("系統提示", "請選擇具體流程!", "info");

                             $('#wf_type').combotree('clear');

                             return;

                         }

                         $("#wf_id").combobox({

                                         url:"${path}/work/task_flowList.do?wf_type=" + data.id,

                                         editable : false ,

                                         width:"308",

                                         valueField : 'wf_id',

                                         textField : 'wf_name',

                                         onSelect:function(data) {

                                             $("#tbody").empty();

                                             var date = new Date();

                                             var a = date.getFullYear() + "" + (date.getMonth() + 1) + date.getDate() + date.getHours() + date.getMinutes() + date.getSeconds();

                                             $("#wt_name").val(data.wf_name + a + "${loginUser.su_name}");

                                             $.ajaxPost("${path}/work/flowStep_showStep.do", {"wf_id":data.wf_id}, function(result) {

                                                 var datas = eval(result);

                                                 $.each(datas, function(i, o) {

                                                     if (i == 0) {

                                                         $("#wt_auditer_target").val(o.wfs_auditer);

                                                         $("#wfs_type").val(o.wfs_type);

                                                         $("#wfs_id").val(o.wfs_id);

                                                     }

                                                     var html = "<tr><td class='th'>" + o.wfs_name + "</td>";

                                                     html += "<td class='td'>" + o.wfs_auditer_name + "</td></tr>";

                                                     $("#tbody").append(html);

                                                 });

                                             });

                                         }

                                     });

                         }

                    });      
<tr>
                 <td class="th">流程類型</td>
                 <td class="td"><input type="text" id="wf_type" name="wf_type" class="input"
                                       validType="maxLength[32]" style="width:308px;"/></td>
             </tr>
             <tr>
                 <td class="th">流程</td>
                 <td class="td"><input type="text" id="wf_id" name="wf_id" class="input"
                                       validType="maxLength[32]" style="width:300px;"/></td>
             </tr>