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
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
var PalletMatOutManager = {
    LogStoreList: undefined,
    Server: function () {
        var config = (function () {
            var URL_GetList = "/Business/IPalletMatOutAjax/GetList";
            var URL_PalletOut = "/Business/IPalletMatOutAjax/PalletOut";
            return {
                URL_GetList: URL_GetList,
                URL_PalletOut: URL_PalletOut,
            };
        })();
 
        //数据操作服务
        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 PalletOut = function (data, callback) {
                $.gitAjax({
                    url: config.URL_PalletOut,
                    data: { ajaxdata: JSON.stringify(data) },
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        if (callback != undefined && typeof callback == "function") {
                            callback(result);
                        }
                    }
                });
            }
            return {
                GetList: GetList,
                PalletOut: PalletOut
            }
        })($, config);
        return dataServer;
    },
    PalletOut: function () {
        debugger
        var rows = this.LogStoreList.selectedRows();
        if (rows.length == 0) {
            $.jBox.tip("请选择要出库的托盘", "提示");
            return false;
        }
        var Palno = rows[0].Palno;
        var LocationCode = rows[0].LocationCode;
        var MatNo = rows[0].MatNo;
 
        debugger
        //var AccessCode = $("div[data-condition='search']").find("select[name='AccessCode']").val();
        //if (AccessCode == null || AccessCode.length <= 0) {
        //    $.jBox.tip("请选择要出库口", "提示");
        //    return false;
        //}
        var submit = function (v, h, f) {
            if (v) {
                var param = {};
                param["Palno"] = Palno;
                param["LocationCode"] = LocationCode;
                param["MatNo"] = MatNo;
                var AccessCode = h.find('select[name="AccessCode"]').val();
                if (AccessCode == null || AccessCode.length <= 0) {
                    $.jBox.tip("请选择要出库口", "提示");
                    return false;
                }
                param["AccessCode"] = AccessCode;
                var Server = PalletMatOutManager.Server();
                Server.PalletOut(param,
                    function(result) {
                        if (result.Code == 1) {
                            $.jBox.tip(result.Message, "info");
                            PalletMatOutManager.PageClick(1, 50);
                        } else {
                            $.jBox.tip(result.Message, "warn");
                        }
                    });
            } else {
                
            }
        }
 
        $.jBox.open("get:/Business/IPalletMatOut/SelectOutMode", "提示", 300, 150, { buttons: { "确定": true, "关闭": false }, top: '6%', submit: submit, loaded: "" });
        /*$.jBox.confirm("确定要出库吗?", "提示", submit);*/
    },
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = PalletMatOutManager.Server();
        var search = PalletMatOutManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
 
        Server.GetList(search, function (result) {
            $.jBox.closeTip();
            if (result.Code == 1) {
                PalletMatOutManager.SetTable(result);
            } else {
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
    SetTable: function (result) {
        var cols = [
            {
                title: '操作', name: 'Guid', width: 80, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
                    var html = "";
                    html += '<a class="out dis" href="javascript:void(0)">出库</a>&nbsp;';
                    return html;
                }
            },
            {
                title: '生产令号', name: 'LingNo', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '库位地址', name: 'LocationCode', width: 120, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '托盘码', name: 'Palno', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '批次号', name: 'BatchNo', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '批次描述', name: 'BatchName', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '物料编码', name: 'MatNo', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '物料名称', name: 'MatName', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '数量', name: 'Quant', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '单位', name: 'UnitName', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '合格证', name: 'Certificate', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '图号', name: 'TuNo', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
        ];
        var ht = masterUI.MMGridHeight();
        if (this.LogStoreList == undefined) {
            this.LogStoreList = $("#tabList").mmGrid({
                cols: cols,
                items: result.Result.List,
                fullWidthRows: true,
                checkCol: true,
                nowrap: true,
                height: ht
            });
            //绑定编辑 删除事件
            PalletMatOutManager.BindEvent();
        }
        else {
            this.LogStoreList.load(result.Result.List);
        }
 
        var pageInfo = result.PageInfo;
        if (pageInfo != undefined) {
            $("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: PalletMatOutManager.PageClick });
        }
    },
    BindEvent: function () {
        this.LogStoreList.on('loadSuccess', function (e, data) {
            LoadBtn.SetBtn();
        });
 
        this.LogStoreList.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
            if ($(e.target).is("a.out")) {
                var Palno = item.Palno;
                var LocationCode = item.LocationCode;
                var MatNo = item.MatNo;
 
                //var AccessCode = $("div[data-condition='search']").find("select[name='AccessCode']").val();
                
                var submit = function (v, h, f) {
                    if (v) {
                        var param = {};
                        param["Palno"] = Palno;
                        param["LocationCode"] = LocationCode;
                        param["MatNo"] = MatNo;
 
                        var AccessCode = h.find('select[name="AccessCode"]').val();
                        if (AccessCode == null || AccessCode.length <= 0) {
                            $.jBox.tip("请选择要出库口", "提示");
                            return false;
                        }
                        param["AccessCode"] = AccessCode;
 
                        var Server = PalletMatOutManager.Server();
                        Server.PalletOut(param, function (result) {
                            if (result.Code == 1) {
                                $.jBox.tip(result.Message, "info");
                                PalletMatOutManager.PageClick(1, 50);
                            } else {
                                $.jBox.tip(result.Message, "warn");
                            }
                        });
                    }
                }
 
                $.jBox.open("get:/Business/IPalletMatOut/SelectOutMode", "提示", 300, 150, { buttons: { "确定": true, "关闭": false }, top: '6%', submit: submit, loaded: "" });
            }
        });
    },
    GetSelect: function () {
        var list = [];
        if (this.LogStoreList != undefined) {
            var rows = this.LogStoreList.selectedRows();
            if (rows != undefined && rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    list.push(rows[i].Addre);
                }
            }
        }
        return list;
    },
    GetRows: function () {
        var list = [];
        if (this.LogStoreList != undefined) {
            var rows = this.LogStoreList.selectedRows();
            if (rows != undefined && rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    list.push(rows[i]);
                }
            }
        }
        return list;
    },
    GetSearch: function () {
        var search = {};
        var searchBar = $("div[data-condition='search']");
        search["Palno"] = searchBar.find("input[name='Palno']").val();
        search["LocationCode"] = searchBar.find("input[name='Addre']").val();
        search["MatNo"] = searchBar.find("input[name='MatNo']").val();
        search["MatName"] = searchBar.find("input[name='MatName']").val();
        search["LingNo"] = searchBar.find("input[name='LingNo']").val();
        search["BatchNo"] = searchBar.find("input[name='BatchNo']").val();
        return search;
    },
    ToolBar: function () {
        //debugger
        //工具栏按钮点击事件
        $("div.toolbar").find("a.btn").click(function () {
            var command = $(this).attr("data-command");
 
            if (command == "Out") {
 
                PalletMatOutManager.PalletOut();
            }
 
        });
        //搜索 高级搜索按钮
        var searchBar = $("div[data-condition='search']");
        searchBar.find("a[data-command='search']").click(function () {
            PalletMatOutManager.PageClick(1, 50);
        });
        //加载默认数据
        PalletMatOutManager.PageClick(1, 50);
    }
}