Helius
2020-12-23 c554c7ad5405bafa149dbb6429e8245f78b33ffc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!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"/>
    <!-- 本框架基本脚本和样式 -->
    <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>
</head>
<body class=" container-fluid">
<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  class="f-r text-success "  matrix:btn="goodsType-add"  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="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="typeName" type="text" name="typeName" class="form-control " datatype="*1-50" nullmsg="产品类型名称不能为空">
                                <div class="Validform_checktip"></div>
                            </div>
 
                        </div>
 
 
                        <div class="form-group" >
                            <div class="col-sm-12 text-center">
                                <a matrix:btn="goodsType-edit" class="btn btn-success radius" onclick="updateFunction()" >保存</a>
                                <a matrix:btn="goodsType-del" class="btn btn-danger  radius" onclick="delFunction()" >删除</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 Huiform = null;
    $(function() {
        initFunctionList();
        Huiform = MValidform.validform("#dataform")
    });
 
    /**
     * 初始化产品类型列表
     */
    function initFunctionSelected(id) {
        $.AjaxProxy({
            a : false,
            c : false
        }).invoke(basePath+"/admin/goodstype/all", function(loj) {
            $("#parentId").createSelectTree(loj.attr("result").rows, {
                append : false,
                defaultValue:id,
                value:"typeName",
                defaultHtml:'<option value="0" selected="selected">一级产品类型</option>',
            });
        });
 
    }
 
    function initFunctionList() {
        var zNodes = new Array();
        $.AjaxProxy().invoke(
            basePath+"/admin/goodstype/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, "typeName"));
                }
                initTree(zNodes);
            });
    }
 
    function updateFunction() {
        var myForm=MForm.initForm({
            invokeUrl:basePath+"/admin/goodstype/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/goodstype/findById",
            function(loj) {
                // 初始化产品类型基本信息
                initFunctionSelected(loj.getString( 0, "parentId"));
                $("#id").val(loj.getString( 0, "id"));
                $("#typeName").val(loj.getString( 0, "typeName"));
                $("#typeNo").val(loj.getString( 0, "typeNo"));
            });
    };
 
    function createNode(id, parentId, name) {
        var o = new Object();
        o.id = id;
        o.pId = parentId;
        o.name = name;
        return o;
    }
    function showIcon() {
        layer.open({
            type : 2,
            title : "选择图标",
            area : [ '80%', '80%' ],
            fix : true, // 不固定
            maxmin : true,
            content : '${path}/common/redirect/icons'
        });
    }
 
    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/goodstype/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/goodstype/editForm'
        });
    }
 
 
 
 
</script>
 
 
</body>
</html>