| <!DOCTYPE html> | 
| <html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml"> | 
| <head> | 
|     <meta charset="utf-8"> | 
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 
|     <meta name="renderer" content="webkit"> | 
|     <meta http-equiv="Cache-Control" content="no-siteapp"/> | 
|     <title>主页</title> | 
|     <link rel="shortcut icon" href="favicon.ico"> | 
|     <!--[if lt IE 8]> | 
|     <meta http-equiv="refresh" content="0;ie.html"/> | 
|     <![endif]--> | 
|   | 
|     <!-- 本框架基本脚本和样式 --> | 
|     <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"> | 
|   | 
| </head> | 
|   | 
| <body class="gray-bg"> | 
| <div class="wrapper wrapper-content  animated fadeInRight"> | 
|     <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 matrix:btn="shoppinggoodscategory1-add" class="f-r text-success " onclick="openForm()"><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 style="display: none;" class="form-horizontal dataform " id="dataform"> | 
|                         <input autocomplete="off"   type="hidden" name="id" id="id"> | 
|                         <div class="form-group"> | 
|                             <label class="col-sm-2 control-label">父级类型</label> | 
|                             <div class="col-sm-3"> | 
|                                 <select class="select2 form-control " size="1" name="parentId" id="parentId"> | 
|                                     <option value="0" selected="selected">一级商品类型</option> | 
|                                 </select> | 
|                             </div> | 
|                         </div> | 
|                         <div class="form-group"> | 
|                             <label class="col-sm-2 control-label">商品类型名称</label> | 
|                             <div class="col-sm-3"> | 
|                                 <input autocomplete="off"   id="name" type="text" name="name" class="form-control " datatype="*1-50" | 
|                                        nullmsg="商品类型名称不能为空"> | 
|                                 <div class="Validform_checktip"></div> | 
|                             </div> | 
|   | 
|                         </div> | 
|                         <div class="form-group"> | 
|                             <label class="col-sm-2 control-label">排序</label> | 
|                             <div class="col-sm-3"> | 
|                                 <input autocomplete="off"   class="form-control " size="1" name="sequence" value="${obj.sequence}" | 
|                                        id="sequence" | 
|                                        nullmsg="排序不能为空" datatype="n1-10" errormsg="长度不能超过10的正整数"> | 
|                                 <div class="Validform_checktip"></div> | 
|                             </div> | 
|                         </div> | 
|   | 
|                         <div class="form-group"> | 
|                             <div class="col-sm-12 text-center"> | 
|                                 <a matrix:btn="shoppinggoodscategory1-edit" class="btn btn-success radius" | 
|                                    onclick="updateFunction()">保存</a> | 
|                                 <a matrix:btn="shoppinggoodscategory1-del" class="btn btn-danger  radius" | 
|                                    onclick="delFunction()">删除</a> | 
|                             </div> | 
|                         </div> | 
|                     </form> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|     </div> | 
| </div> | 
|   | 
| <script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> | 
| <script type="text/javascript" th:src="@{/js/content.min.js}"></script> | 
| <script type="text/javascript" | 
|         th:src="@{/plugin/zTree/jquery.ztree.core-3.5.min.js}"></script> | 
| <script type="text/javascript"> | 
|   | 
|     $(".select2").select2({'width': '100%'}); | 
|   | 
|     var Huiform = null; | 
|     $(function () { | 
|         initFunctionList(); | 
|         Huiform = MValidform.validform("#dataform") | 
|     }); | 
|   | 
|     /** | 
|      * 初始化商品类型列表 | 
|      */ | 
|     function initFunctionSelected(id) { | 
|         $.AjaxProxy({ | 
|             a: false, | 
|             c: false, | 
|             p: {salePlatform: '线下'} | 
|         }).invoke(basePath + "/admin/shoppinggoodscategory/all", function (loj) { | 
|             $("#parentId").createSelectTree(loj.attr("result").rows, { | 
|                 append: false, | 
|                 defaultValue: id, | 
|                 value: "name", | 
|                 defaultHtml: '<option value="0" selected="selected">一级商品类型</option>', | 
|             }); | 
|         }); | 
|   | 
|     } | 
|   | 
|     function initFunctionList() { | 
|         var zNodes = new Array(); | 
|         $.AjaxProxy({p: {salePlatform: '线下'}}).invoke( | 
|             basePath + "/admin/shoppinggoodscategory/all", | 
|             function (loj) { | 
|                 for (var i = 0; i < loj.getRowCount(); i++) { | 
|                     zNodes[i] = createNode(loj.getString(i, "id"), loj | 
|                         .getString(i, "parentId"), loj.getString(i, "name")); | 
|                 } | 
|                 initTree(zNodes); | 
|             }); | 
|     } | 
|   | 
|     function updateFunction() { | 
|         var myForm = MForm.initForm({ | 
|             invokeUrl: basePath + "/admin/shoppinggoodscategory/addOrModify", | 
|             afterSubmit: function () { | 
|                 initFunctionList(); | 
|             }, | 
|         }); | 
|         myForm.submit(); | 
|     } | 
|   | 
|     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 zTreeOnClick(event, treeId, treeNode) { | 
|         $("#dataform").show(); | 
|         Huiform.resetForm(); | 
|         $.AjaxProxy({ | 
|             p: {id: treeNode.id}, | 
|             a: false, | 
|             c: true | 
|         }).invoke( | 
|             basePath + "/admin/shoppinggoodscategory/findById", | 
|             function (loj) { | 
|                 // 初始化商品类型基本信息 | 
|                 initFunctionSelected(loj.getString(0, "parentId")); | 
|                 $("#id").val(loj.getString(0, "id")); | 
|                 $("#name").val(loj.getString(0, "name")); | 
|                 $("#sequence").val(loj.getString(0, "sequence")); | 
|   | 
|             }); | 
|     }; | 
|   | 
|     function createNode(id, parentId, name) { | 
|         var o = new Object(); | 
|         o.id = id; | 
|         o.pId = parentId; | 
|         o.name = name; | 
|         return o; | 
|     } | 
|   | 
|   | 
|     function delFunction() { | 
|         var id = $("#id").val(); | 
|         if (id != null && id != '') { | 
|             layer.confirm('删除商品类型时会删除该商品的所有子商品类型!', { | 
|                 icon: 3, | 
|                 title: '提示' | 
|             }, function (index) { | 
|                 layer.close(index); | 
|                 var id = $("#id").val(); | 
|                 $.AjaxProxy({ | 
|                     p: {keys: id} | 
|                 }).invoke(basePath + "/admin/shoppinggoodscategory/del", function (loj) { | 
|                     layer.alert('删除成功!', { | 
|                         icon: 1 | 
|                     }, function (index) { | 
|                         $("#dataform").hide(); | 
|                         layer.close(index); | 
|                         initFunctionList(); | 
|                     }); | 
|                     return false; | 
|                 }); | 
|             }); | 
|         } else { | 
|             layer.alert("请先选中要删除的商品类型!"); | 
|         } | 
|     } | 
|   | 
|     function openForm() { | 
|         layer.open({ | 
|             type: 2, | 
|             title: "新增商品类型", | 
|             area: [MUI.SIZE_L, '400px'], | 
|             content: basePath + '/admin/shoppinggoodscategory/editFormUderline' | 
|         }); | 
|     } | 
|   | 
|   | 
| </script> | 
|   | 
| </body> | 
| </html> |