| <!DOCTYPE HTML> | 
| <html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml"> | 
| <head> | 
| <meta charset="utf-8"> | 
| <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 
| <meta name="renderer" content="webkit|ie-comp|ie-stand"> | 
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 
| <meta name="viewport" | 
|     content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> | 
| <meta http-equiv="Cache-Control" content="no-siteapp" /> | 
|     <link th:href="@{/plugin/bootstrap-fileinput/css/fileinput.css}" | 
|           media="all" rel="stylesheet" type="text/css"/> | 
| <!-- 本框架基本脚本和样式 --> | 
| <script type="text/javascript" | 
|     th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> | 
| <script type="text/javascript" | 
|     th:src="@{/js/systools/MBase.js}"></script> | 
|   | 
|     <!-- 界面单独引入的其他样式和脚本 --> | 
|     <link rel="stylesheet" | 
|           th:href="@{/plugin/zTree/zTreeStyle/zTreeStyle.css}" | 
|           type="text/css"> | 
|     <script type="text/javascript" | 
|             th:src="@{/plugin/zTree/jquery.ztree.core-3.5.min.js}"></script> | 
|     <script type="text/javascript" | 
|             th:src="@{/plugin/bootstrap-3.3.5/js/bootstrapSwitch.js}"></script> | 
|     <link rel="stylesheet" th:href="@{/plugin/bootstrap-3.3.5/css/bootstrapSwitch.css}"> | 
|     <script type="text/javascript" | 
|             th:src="@{/js/function/public.js}"></script> | 
|     <script th:src="@{/plugin/bootstrap-fileinput/js/fileinput.js}" | 
|             type="text/javascript"></script> | 
|     <script th:src="@{/plugin/bootstrap-fileinput/js/locales/zh.js}" | 
|             type="text/javascript"></script> | 
|     <style type="text/css"> | 
|         table tr td { | 
|             border: none !important; | 
|         } | 
|   | 
|         table tr th { | 
|             border: none !important; | 
|         } | 
|   | 
|         .inline{ | 
|             display: INLINE; | 
|             width: 50%; | 
|         } | 
|   | 
|     </style> | 
| </head> | 
| <body class="gray-bg"> | 
| <div class="wrapper wrapper-content animated fadeInRight"> | 
|   | 
|     <div class="wrapper wrapper-content   "> | 
|         <div class="row"> | 
|             <div class="col-sm-3"> | 
|                 <div class="ibox float-e-margins"> | 
|                     <div class="ibox-title"> | 
|                         <h5>文章类别列表</h5> | 
|                         <div class="pull-right "> | 
|                             <a class="f-r text-success " onclick="openForm()" matrix:btn="ARTICLETYPE-addArticle"><i | 
|                                     class="fa fa-plus c-success"></i> 添加文章类别</a> | 
|                         </div> | 
|                     </div> | 
|                     <div id="treeDemo" class="ibox-content ztree" | 
|                          style="min-height: 400px"></div> | 
|                 </div> | 
|             </div> | 
|             <div class="col-sm-9"> | 
|                 <div class="ibox float-e-margins"> | 
|                     <div class="ibox-title"> | 
|                         <h5>编辑文章类别</h5> | 
|                         <div class="ibox-tools"></div> | 
|                     </div> | 
|                     <div class="ibox-content" style="min-height: 400px"> | 
|                         <form  class="form-horizontal dataform " style="display: none" | 
|                                id="dataform"> | 
|                             <input autocomplete="off"   type="hidden" name="artypeId" id="artypeId"> | 
|                             <div class="form-group"> | 
|                                 <label class="col-offset-1 col-sm-2 control-label">父级文章类别</label> | 
|                                 <div class="col-sm-4"> | 
|                                     <select class="form-control select2 " size="1" name="artypeParentid" | 
|                                             id="artypeParentid" style="width: 100%"> | 
|                                     </select> | 
|                                 </div> | 
|                                 <label class="col-sm-2 control-label">文章类别名称 | 
|                                     <span class="text-danger">*</span> | 
|                                 </label> | 
|                                 <div class="col-sm-4"> | 
|                                     <input autocomplete="off"   id="artypeName" type="text" class="form-control" name="artypeName" | 
|                                            maxLength="50" dataType="s1-50" | 
|                                            nullmsg="文章类别名称不能为空"> | 
|                                 </div> | 
|                             </div> | 
|   | 
|                             <div class="form-group"> | 
|                                 <label class="col-sm-2 control-label">文章类别排序 | 
|                                     <span class="text-danger">*</span> | 
|                                 </label> | 
|                                 <div class="col-sm-4"> | 
|                                     <input autocomplete="off"   id="artypeSort" type="text" class="form-control" name="artypeSort" | 
|                                            dataType="/^\d*\.?\d+$/" | 
|                                            errormsg="仅支持数字" | 
|                                            nullmsg="文章类别排序不能为空"> | 
|                                 </div> | 
|   | 
|   | 
|                                 <label class="col-sm-2 control-label">文章类别描述 | 
|                                 </label> | 
|                                 <div class="col-sm-4"> | 
|                                     <input autocomplete="off"   id="artypeDescribe" type="text" class="form-control" name="artypeDescribe" | 
|                                            maxLength="100" dataType="s1-100" | 
|                                            ignore="ignore" | 
|                                            nullmsg="文章类别描述不能为空"> | 
|                                 </div> | 
|                             </div> | 
|                             <div class="form-group"> | 
|                                 <label class="col-sm-2 control-label">文章类别编号 | 
|                                     <span class="text-danger">*</span> | 
|                                 </label> | 
|                                 <div class="col-sm-4"> | 
|                                     <input autocomplete="off"   id="artypeCode" type="text" class="form-control" name="artypeCode" | 
|                                            maxLength="50" dataType="/^[0-9a-zA-Z_]{1,50}$/" | 
|                                            nullmsg="文章类别编号不能为空" errormsg="仅支持数字、字母及'_'"> | 
|                                 </div> | 
|   | 
|                             </div> | 
|   | 
|                             <div class="form-group"> | 
|                                 <label class="col-sm-2 control-label">文章类别图片路径 | 
|   | 
|                                 </label> | 
|   | 
|                                 <div class="col-sm-10"> | 
|                                     <input autocomplete="off"   value="" name="artypeImgurl" id="artypeImgurl" | 
|                                            class="form-control  upload-input" type="text" /> <a style="width: 10%" | 
|                                             class="btn btn-primary radius upload-a">选择图片 | 
|                                 </a> | 
|                                 </div> | 
|                                 <!--<div class="col-sm-5"> | 
|                                     <input autocomplete="off"   type="text" id="artypeImgurl" readonly="true" class="form-control" name="artypeImgurl" | 
|                                            multiple data-min-file-count="1"   maxLength="250" | 
|                                     > | 
|                                     <form enctype="multipart/form-data"> | 
|                                         <input autocomplete="off"   id="file-zh"  name="file-zh" type="file"> | 
|                                     </form> | 
|                                 </div> | 
|                                 <div class="col-sm-5"> | 
|                                     <img id="imageUrl"  style="width: 80%"/> | 
|                                 </div>--> | 
|                             </div> | 
|                             <div class="form-group" id="showImgUrl"> | 
|                                 <label class="col-sm-2 control-label"> | 
|   | 
|                                 </label> | 
|                                 <div class="col-sm-10"> | 
|                                     <img id="imageUrl"  style="width: 50%;height: 40%"/> | 
|                                 </div> | 
|                             </div> | 
|                             <div id="updateBtn" class="form-group" style="display: none"> | 
|                                 <div class="col-sm-12 text-center"> | 
|                                     <a class="btn btn-success radius" id="saveForm" onclick="updateArticleType()" matrix:btn="ARTICLETYPE-save"><i class="fa fa-check"></i> 保存</a> | 
|                                     <a class="btn btn-danger  radius" onclick="delArticleType()" matrix:btn="ARTICLETYPE-del"><i class="fa fa-close" ></i> 删除</a> | 
|                                 </div> | 
|                             </div> | 
|                         </form> | 
|                     </div> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|     </div> | 
|   | 
| </div> | 
| <script type="text/javascript" | 
|     th:src="@{/js/systools/MJsBase.js}"></script> | 
|     <script type="text/javascript"> | 
|         var dataForm = null; | 
|         var artypeId = 0; | 
|         $(function (){ | 
|             initArticleTypeList(); | 
|         }) | 
|   | 
|         var invokeUrl = basePath + "/admin/multipleUploadFile/doUpload"; | 
|         MUI.initImgUpload(".upload-input"); | 
|         /*$('#file-zh').fileinput({ | 
|             language: 'zh', | 
|             uploadUrl: invokeUrl, | 
|             allowedFileExtensions: ['jpg', 'png', 'gif'], | 
|             maxFileCount: 1, | 
|         }).on("fileuploaded", function (event, data, previewId, index) { | 
|             $('input[name=artypeImgurl]').val(data.response.path) | 
|         });*/ | 
|   | 
|         /** | 
|          * 初始化文章类型列表 | 
|          */ | 
|         function initArticleTypeSelected(id) { | 
|             $.AjaxProxy().invoke(basePath+"/admin/shopArticleType/all", | 
|                     function(loj) { | 
|                         $("#artypeParentid").createSelectTree( | 
|                                 loj.attr("result").rows, | 
|                                 {    id : "artypeId",        // 选项的值 | 
|                                     parent : "artypeParentid",    // 父节点值 | 
|                                     value : "artypeName",    // 要显示的名称 | 
|                                     append : false, | 
|                                     defaultValue : id, | 
|                                     defaultHtml : '<option value="" >一级文章类别</option>' | 
|                                 }); | 
|                     }); | 
|   | 
|         } | 
|         //更新功能 | 
|   | 
|         function updateArticleType() { | 
|             var myForm = MForm.initForm({ | 
|                 invokeUrl : basePath+"/admin/shopArticleType/modifyShopArticleType", | 
|                 afterSubmit : function() { | 
|                     initArticleTypeList(); | 
|                 }, | 
|                 /*beforeSubmit: function () { | 
|                 }*/ | 
|             }); | 
|             myForm.submit(); | 
|             //initDepartmentList(); | 
|         } | 
|   | 
|         // 点击加载节点信息 | 
|         function zTreeOnClick(event, treeId, treeNode) { | 
|             fnPublci.initArticleTypeSelect("#artypeParentid"); | 
|             dataForm = MValidform.validform("#dataform"); | 
|             flag=false; | 
|             $("#dataform").show(); | 
|             $("#updateBtn").show(); | 
|             dataForm.resetForm(); | 
|             $.AjaxProxy({ | 
|                 p : { | 
|                     artypeId : treeNode.id | 
|                 }, | 
|                 a : false, | 
|                 c : true | 
|             }) | 
|                     .invoke( | 
|                             basePath+"/admin/shopArticleType/findById", | 
|                             function(loj) { | 
|                                 // 初始化功能基本信息1 | 
|                                 artypeId = loj.attr("result").rows[0].artypeId; | 
|                                 initArticleTypeSelected(loj.getString(0,"artypeParentid")); | 
|                                 $("#artypeName").val(loj.getString(0, "artypeName")); | 
|                                 $("#artypeCode").val(loj.getString(0, "artypeCode")); | 
|                                 $("#artypeSort").val(loj.getString(0, "artypeSort")); | 
|                                 $("#artypeDescribe").val(loj.getString(0, "artypeDescribe")); | 
|                                 $("#artypeImgurl").val(loj.getString(0, "artypeImgurl")); | 
|                                 $("#artypeId").val(loj.getString(0, "artypeId")); | 
|                                 /*$("#imageUrl").attr("src",loj.getString(0, "artypeImgurl"));*/ | 
|                                 /*$(".file-preview-frame file-preview-success").remove();*/ | 
|                                 if(loj.getString(0, "artypeImgurl") != ''){ | 
|                                     $("#imageUrl").attr("src",loj.getString(0, "artypeImgurl")); | 
|                                     $("#showImgUrl").show(); | 
|                                 }else{ | 
|                                     $("#showImgUrl").hide(); | 
|                                 } | 
|                                 $(".loadingbig").remove(); | 
|   | 
|                                 // 初始话功能按钮 | 
|                                 $.AjaxProxy({ | 
|                                     p : { | 
|                                         id : loj.getString(0, "id") | 
|                                     }, | 
|                                     a : false, | 
|                                     c : false | 
|                                 }) | 
|   | 
|                             }); | 
|   | 
|   | 
|         }; | 
|   | 
|   | 
|         function initArticleTypeList() { | 
|             var zNodes = new Array(); | 
|             $.AjaxProxy().invoke( | 
|                     basePath+"/admin/shopArticleType/all", | 
|                     function(loj) { | 
|                         for (var i = 0; i < loj.getRowCount(); i++) { | 
|                             zNodes[i] = createNode(loj.getString(i, "artypeId"), loj.getString(i, "artypeParentid"), loj.getString( | 
|                                     i, "artypeName") , loj.getString(i, "artypeCode")); | 
|                         } | 
|                         initTree(zNodes); | 
|                     }); | 
|         } | 
|   | 
|         //初始化树型控件 | 
|         function initTree(zNodes) { | 
|             var setting = { | 
|                 view : { | 
|                     dblClickExpand : false, | 
|                     showLine : false, | 
|                     selectedMulti : false | 
|                 }, | 
|                 data : { | 
|                     simpleData : { | 
|                         enable : true, | 
|                         idKey : "id", | 
|                         pIdKey : "pId", | 
|                         rootPId : "" | 
|                     } | 
|                 }, | 
|                 callback : { | 
|                     onClick : zTreeOnClick | 
|                 } | 
|             }; | 
|             $.fn.zTree.init($("#treeDemo"), setting, zNodes); | 
|         } | 
|   | 
|         function createNode(id, parentId, name) { | 
|             var o = new Object(); | 
|             o.id = id; | 
|             o.pId = parentId; | 
|             o.name = name; | 
|             o.open=true; | 
|             return o; | 
|         } | 
|   | 
|         function delArticleType() { | 
|             var id = artypeId; | 
|             if (id != null && id != '') { | 
|                 layer.confirm('删除功能时会删除该功能的所有子功能!', { | 
|                     icon : 3, | 
|                     title : '提示' | 
|                 }, function(index) { | 
|                     layer.close(index); | 
|                     //var id = id; | 
|                     $.AjaxProxy({ | 
|                         p : { | 
|                             keys : id | 
|                         } | 
|                     }).invoke(basePath+"/admin/shopArticleType/del", function(loj) { | 
|                         layer.msg('删除成功!', { | 
|                             icon : 1,time:1000 | 
|                         }, function(index) { | 
|                             $("#dataform").hide(); | 
|                             $("#updateBtn").hide(); | 
|                             layer.close(index); | 
|                             initArticleTypeList(); | 
|                         }); | 
|                         return false; | 
|                     }); | 
|                 }); | 
|             } else { | 
|                 layer.msg("请先选中要删除的功能!"); | 
|             } | 
|         } | 
|   | 
|         function openForm() { | 
|             layer.full( | 
|             layer.open({ | 
|                 type : 2, | 
|                 title : "添加文章类别", | 
|                 anim:1, | 
|                 maxmin : true, | 
|                 area : [ MUI.SIZE_L, '450px' ], | 
|                 content : [ basePath+'/admin/shopArticleType/editForm' ] | 
|             })); | 
|   | 
|         } | 
|   | 
|         $(".select2").select2(); | 
|         var myForm = null; | 
|         $(function() { | 
|             myForm = MForm.initForm({ | 
|                 invokeUrl :basePath+ "/admin/shopArticleType/addShopArticleType", | 
|                 afterSubmit : function() { | 
|                     parent.initArticleTypeList(); | 
|                 } | 
|             }); | 
|             fnPublci.initArticleTypeSelect("#artypeParentid"); | 
|         }); | 
|   | 
|     </script> | 
| </body> | 
| </html> |