bklLiudl
2024-07-23 7850733bb718cb91be15449261d0134f59903c4c
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
var Picking = {
    InTable: undefined,
    Server: function () {
        var config = (function () {
         
 
           
            var URL_GetList = "/Business/PickingAjax/GetPickingList";
            var URL_Out = "/Business/PickingAjax/Out";
            return {
                URL_GetList: URL_GetList,
                URL_Out: URL_Out,
            };
        })();
 
        //数据操作服务
        var dataServer = (function ($, config) {
 
            //查询分页列
            var GetList = function (data, callback) {
                $.gitAjax({
                    url: config.URL_GetList,
                    data: { ajaxdata: JSON.stringify(data) },
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        if (callback != undefined && typeof callback == "function") {
                            callback(result);
                        }
                    }
                });
            }
            var Out = function (data, callback) {
                $.gitAjax({
                    url: config.URL_Out,
                    data: data,
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        if (callback != undefined && typeof callback == "function") {
                            callback(result);
                        }
                    }
                });
            }
            return {
              
                GetList: GetList,
                Out: Out,
            }
 
        })($, config);
        return dataServer;
    },
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = Picking.Server();
        var search = Picking.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
 
        Server.GetList(search, function (result) {
            $.jBox.closeTip();
            if (result.Code == 1) {
                Picking.SetTable(result);
            } else {
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
    Refresh: function () {
        var PageSize = $("#mypager").pager("GetPageSize");
        var PageIndex = $("#mypager").pager("GetCurrent");
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = Picking.Server();
        var search = Picking.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
        Server.GetList(search, function (result) {
            $.jBox.closeTip();
            if (result.Code == 1) {
                Picking.SetTable(result);
            } else {
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
    SetTable: function (result) {
        var cols = [
            //{
            //    title: '操作', name: 'ID', width: 100, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
            //        var html = "";
            //        //console.log(item);
            //        //console.log(item.IsDal);
            //        //alert(item.IsDel);
            //        if (item.IsDel == 0) {
            //            html += '<a class="to" href="javascript:void(0)">回库</a>&nbsp;';
            //        }
            //        return html;
            //    }
            //}, 
            {
                title: '单号', name: 'OrdNo', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '托盘号', name: 'Palno', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                } 
            },
         
            {
                title: '库位地址', name: 'Addre', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                     return data;
                }
            }
        ];
 
        if (this.InTable == undefined) {
 
            var ht = masterUI.MMGridHeight();
            this.InTable = $("#tabList").mmGrid({
                cols: cols,
                items: result.Result.List,
                checkCol: true,
                multiSelect: false,
                nowrap: true,
                height: ht
            });
            //绑定编辑 删除事件
            Picking.BindEvent();
        } else {
            this.InTable.load(result.Result.List);
        }
 
        var pageInfo = result.PageInfo;
        if (pageInfo != undefined) {
            $("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: Picking.PageClick });
        }
    },
    BindEvent: function () {
 
        this.InTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
 
            if ($(e.target).is("a.to")) {
                var SN = item.ID;
               
                var submit1 = function (v, h, f) {
                   
                    if (v == "ok") {
                        var list = [];
                        list.push(SN);
                       
                        var param = {};
                        param["list"] = JSON.stringify(list);
                        var Server = Picking.Server();
                        Server.Out(param, function (result) {
                            if (result.Code == 1) {
                                var pageSize = $("#mypager").pager("GetPageSize");
                                Picking.PageClick(1, pageSize);
                            } else {
                                $.jBox.tip(result.Message, "success");
                            }
                        });
                    }
 
                   
                }
                $.jBox.confirm("确定要回库吗?", "提示", submit1);
            }
             
        });
 
        this.InTable.on('loadSuccess', function (e, data) {
 
            LoadBtn.SetBtn();
        });
 
    },
    GetSelect: function () {
        var list = [];
        if (this.InTable != undefined) {
            var rows = this.InTable.selectedRows();
            if (rows != undefined && rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    list.push(rows[i].OrdNo);
                }
            }
        }
        return list;
    },
    GetRows: function () {
        var list = [];
        if (this.InTable != undefined) {
            var rows = this.InTable.selectedRows();
            if (rows != undefined && rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    list.push(rows[i]);
                }
            }
        }
        return list;
    },
    GetSearch: function () {
        var searchBar = $("div[data-condition='search']");
 
        var OrdNo = searchBar.find("input[name='OrdNo']").val();
        var State = searchBar.find("select[name='State']").val();
        var BeginTime = searchBar.find("input[name='BeginTime']").val();
        var EndTime = searchBar.find("input[name='EndTime']").val();
        var search = {};
 
        search["OrdNo"] = OrdNo;
        search["Statu"] = State;
        search["BeginTime"] = BeginTime;
        search["EndTime"] = EndTime;
 
        return search;
    },
    ToolBar: function () {
   
        //搜索 高级搜索按钮
        var searchBar = $("div[data-condition='search']");
        searchBar.find("a[data-command='search']").click(function () {
            //alert("123");
            Picking.PageClick(1, 50);
        });
       
       
 
        //监听回车事件,用于扫描
        //searchBar.find("div[id='container']").keydown(function (event) {
        //    if (event.keyCode == 13) {
        //        var value = $(this).val();
        //        if (!git.IsEmpty(value)) {
        //            alert("A0001");
        //            Picking.PageClick(1, 10);
        //            //setTimeout(function () {
        //            //    searchBar.find("input[name='OrdNo']").val("");
        //            //    searchBar.find("input[name='OrdNo']").focus();
        //            //}, 300);
        //        }
        //    }
        //});
 
        //窗体加载获得焦点
        //searchBar.find("input[name='OrdNo']").focus();
        //加载默认数据
        Picking.PageClick(1, 50);
    },
 
}