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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PaperPriceList.aspx.cs" Inherits="CY.WebForm.Pages.sysInquiry.PaperPriceList" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>纸价管理</title>
    <uc:CMSHead ID="CMSHead1" runat="server" />
    <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
    <link href="../../libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css" />
    <!-- 树start-->
    <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
    <link href="../../libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //正数正则表达式
        var reg1 = /^\d+(?=\.{0,1}\d+$|$)/;
 
        var setting = {
            callback: {
                onClick: onClick
            }
        };
 
 
        var zNodes = <%=PaperListStr %>;
 
        function initComplete() {
            $.fn.zTree.init($("#PaperTree"), setting, zNodes);
            //每次刷新时保持上次打开的
            //showAll();
              
        }
        function showContent() {
            var treeNodeId = jQuery.jCookie('PaperSet');
            if (treeNodeId == false || treeNodeId == "false") { }
            else {
                var zTree = $.fn.zTree.getZTreeObj("PaperTree");
                var node = zTree.getNodeByParam("id", treeNodeId);
                zTree.selectNode(node);
            }
           parent.iframeHeight('frmrightChild');
        }
 
        function onClick(e, treeId, treeNode) {
            //单击展开
            var zTree = $.fn.zTree.getZTreeObj("PaperTree");
            zTree.expandNode(treeNode);
 
 
            if(!treeNode.isParent)
            {
               //存储点击节点id
               jQuery.jCookie('leftTreeNodeId', treeNode.id.toString());
               $("#spnSelPaperName").text(treeNode.name);
               $("#hidPaperId").val(treeNode.id);
 
               GetPaperPriceListList(treeNode.id,"");
            }
        }
 
        function showAll() {
            var treeObj = $.fn.zTree.getZTreeObj("PaperTree");
            treeObj.expandAll(true);
            parent.iframeHeight('frmrightChild');
        }
        function hideAll() {
            var treeObj = $.fn.zTree.getZTreeObj("PaperTree")
            treeObj.expandAll(false);
        }
 
        $(
            function()
            {
 
                var zTree = $.fn.zTree.getZTreeObj("PaperTree");
                var root = zTree.getNodes()[0];
                 try {
                     node = root.children[0].children[0];
                 }
                 catch (ex) {
                     node = root;
                     node.id = -2;
                 }
                 onClick(zTree, node.id, node);
                 var selTreeId = jQuery.jCookie('leftTreeNodeId');
                 if (selTreeId != "") {
                     node = zTree.getNodeByParam("id", selTreeId);
                     zTree.selectNode(node);
                 }
                 setInterval("parent.iframeHeight('frmrightChild')", 1000);
                //品牌类别选择事件
                $("#ddlBrandList").change(
                      function()
                      {
                          var paperId=$("#hidPaperId").val();
                          var brandId=$("#ddlBrandList").val();
                          GetPaperPriceListList(paperId,brandId);
                      }
                );
 
                //确定事件
                $("#btnSure").live("click",
                    function()
                    {
                        if($(":checkbox[checked='checked']").length==0)
                        {
                            top.Dialog.alert("请选择要设置价格的克重", function () {
                            });
                            return;
                        }
                        var allPrice=$("#txtAllPrice").val();
                        if(allPrice=="")
                        {
                             top.Dialog.alert("请输入要设置的价格", function () {
                            });
                            return;
                        }
                        if(!reg1.test(allPrice))
                        {
                              top.Dialog.alert("设置的价格必须为正数字", function () {
                            });
                            return;
                        }
 
                        $(":checkbox[checked='checked']").each(
                            function()
                            {
                                $(this).parent().parent().children().eq(2).children().val(allPrice);
                            }
                        );
 
                        $("#txtAllPrice").val("");
                    }
                );
 
                //保存事件
                $("#btnSave").live("click",
                    function()
                    {
                        var paperId=$("#hidPaperId").val();
                        var brandId=$("#ddlBrandList").val();
                        var priceList="";
                        $("#tbPeperPriceList tbody tr").each(
                            function()
                            {
                               var kzValue=$(this).children().eq(1).text();
                               var priceValue=$(this).children().eq(2).children().val();
                               if(priceValue=="")
                               {
                                     top.Dialog.alert("设置的价格不能为空", function () {
                                    });
                                    return;
                               }
                               else
                               {
                                    if(!reg1.test(priceValue))
                                    {
                                        top.Dialog.alert("设置的价格必须为正数字", function () {
                                        });
                                       return;
                                    }
                               }
                               priceList+=kzValue+":"+priceValue+",";
                            }
                        );
 
                        if(priceList!=null)
                        priceList=priceList.substring(0,priceList.length-1);
                        $.ajax(
                            {
                                 url: '/Pages/sysInquiry/PaperPriceList.aspx?tmp' + (new Date()).valueOf(),
                                 type: "POST",
                                 data:"save=true&paperId="+paperId+"&brandId="+brandId+"&priceList="+priceList,
                                 success: function (resultStr) {
                                     top.Dialog.alert(resultStr, function () {
                                    });
                                 }
                            }
                        );
                    }
                );
 
                $(".textprice").live("blur",
                    function()
                    {
                        var price=$(this).val();
                        if(!reg1.test(price))
                        {
                            top.Dialog.alert("设置的价格必须为正数字", function () {
                            });
                            $(this).val("0");
                        }
                    }
                );
            }
        );
 
        
        function GetPaperPriceListList(paperId,brandId)
        {
            $.ajax(
                           {
                                 url: '/Pages/sysInquiry/PaperPriceList.aspx?tmp' + (new Date()).valueOf(),
                                 type: "POST",
                                 data:"Init=true&paperId="+paperId+"&brandId="+brandId,
                                 success: function (dataJsonStr) {
                                     var  dataJson=eval('('+dataJsonStr+')');
 
                                     var selBrandId=dataJson.brandId;
                                     var brandList=dataJson.brandList;
                                     var option="";
                                     for(var j=0;j<brandList.length;j++)
                                     {
                                        option += "<option value=\"" + brandList[j].brandKey + "\">" + brandList[j].brandName + "</option>";
                                     }
                                     $("#ddlBrandList").html("");
                                     $("#ddlBrandList").html(option);
 
                                     $("#ddlBrandList").find("option[value='"+selBrandId+"']").attr("selected",true);
 
                                     var paperPriceList=dataJson.paperPriceList;
 
                                     var htmlStr=""; 
                                     var hidIsFirm=$("#hidIsFirm").val();
                                     for(var i=0;i<paperPriceList.length;i++)
                                     {
                                        if(hidIsFirm=='true')
                                        {
                                            if(paperPriceList[i].PaperPrice=="0")
                                            {
                                                continue;
                                            }
                                        }
                                        htmlStr+="<tr><td><input type=\"checkbox\" /></td><td>"+paperPriceList[i].GramWeight+"</td><td><input type=\"text\" value='"+paperPriceList[i].PaperPrice+"' class='textprice' /></td></tr>";
                                     }
                                     $("#tbPeperPriceList tbody tr").remove();
                                     $("#tbPeperPriceList tbody").append(htmlStr);
                                     $("#tbPeperPriceList").render();
                                     $(".textprice").render();
                                     $("#btnSave").show();
                                     parent.iframeHeight('frmrightChild');     
                                 }
                           }
                           );
        }
    </script>
    <!-- 树end -->
    <style type="text/css">
        .ztree * { font-family: sans-serif !important; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <input type="hidden" id="hidIsFirm" runat="server" value="true" />
    <div id="scrollContent">
        <div style="float: left; margin-right: 10px">
            <ul id="PaperTree" class="ztree">
            </ul>
        </div>
        <div style="float: left; width: 70%">
            <table class="tableStyle" style="width: 100%">
                <tr>
                    <th colspan="2">
                        纸张价格
                    </th>
                </tr>
                <tr>
                    <td>
                        所选纸张:
                    </td>
                    <td>
                        <span id="spnSelPaperName"></span>
                        <input type="hidden" id="hidPaperId" runat="server" value="" />
                    </td>
                </tr>
                <tr>
                    <td>
                        操作:
                    </td>
                    <td>
                        请选择品牌:
                        <select id="ddlBrandList" keepdefaultstyle="true">
                        </select>
                        统一价格:<input type="text" id="txtAllPrice" /><input type="button" id="btnSure" value="确定" />
                    </td>
                </tr>
                <tr>
                    <td>
                        列表:
                    </td>
                    <td>
                        <table class="tableStyle" useclick="false" usecheckbox="true" sortmode="true" id="tbPeperPriceList">
                            <thead>
                                <tr>
                                    <th width="25">
                                    </th>
                                    <th>
                                        克重
                                    </th>
                                    <th>
                                        吨价
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <input type="button" value="保存" id="btnSave" style="display: none" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="CB">
        </div>
    </div>
    </form>
</body>
</html>