bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
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
 
var StoreBasicManager = {
    InTable: undefined,
    Server: function () {
        var config = (function () {
            var URL_GetList = "/Data/StoreAjax/GetBasicList";
            return {
                URL_GetList: URL_GetList,
            };
        })();
 
        //数据操作服务
        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);
                        }
                    }
                });
            }
            //删除 
 
            return {
                GetList: GetList,
 
            }
 
        })($, config);
        return dataServer;
    },
 
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = StoreBasicManager.Server();
        var search = StoreBasicManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
        Server.GetList(search, function (result) {
            $.jBox.closeTip();
            if (result.Code == 1) {
                StoreBasicManager.SetTable(result);
            } else {
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
 
    SetTable: function (result) {
        var cols = [
            {
                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, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '规格型号', name: 'PackFormat', width: 260, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '库存数量', name: 'Quant', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '单位', name: 'UnitName', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '类型', name: 'MatType', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '品牌', name: 'BrandName', width: 100, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '重量', name: 'NWeight', width: 60, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '长', name: 'Long', width: 60, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '宽', name: 'Width', width: 60, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '高', name: 'Height', width: 60, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '操作', name: 'Guid', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    var html = "";
                    html += '<a class="edit" href="javascript:void(0)">详情</a>&nbsp;&nbsp;';
                    return html;
                }
            }
        ];
 
        if (this.InTable == undefined) {
            var ht = masterUI.MMGridHeight();
            this.InTable = $("#tabList").mmGrid({
                cols: cols,
                items: result.Result.List,
                //checkCol: true,
                indexCol: true,
                fullWidthRows: true,
                nowrap: true,
                height: ht
            });
            //绑定编辑 删除事件
            StoreBasicManager.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: StoreBasicManager.PageClick });
        }
    },
 
    BindEvent: function () {
        this.InTable.on('loadSuccess', function (e, data) {
            LoadBtn.SetBtn();
        });
 
        this.InTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
            if ($(e.target).is("a.edit")) {
                //var list = StoreBasicManager.GetSelect();
                //if (list.length == 0) {
                //    $.jBox.tip("请选择要查看明细的项!", "warn");
                //    return false;
                //}
                var MatNo = item["MatNo"];
                StoreBasicManager.Dialog(MatNo, "Detail");
            }
        });
    },
 
    GetSearch: function () {
        var searchBar = $("div[data-condition='search']");
        var BrandId = searchBar.find("select[name='Brand']").val();
        var MatTypeId = searchBar.find("select[name='MatType']").val();
        var MatNo = searchBar.find("input[name='MatNo']").val();
        var MatName = searchBar.find("input[name='MatName']").val();
        var PackFormat = searchBar.find("input[name='PackFormat']").val();
 
        var search = {};
        search["MatNo"] = MatNo;
        search["MatName"] = MatName;
        search["BrandId"] = BrandId;
        search["MatTypeId"] = MatTypeId;
        search["PackFormat"] = PackFormat;
 
        return search;
    },
 
    // 获取Table选中行
    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].MatNo);
                }
            }
        }
        return list;
    },
 
    Dialog: function (MatNo, Command) {
        //窗体加载完成回调事件 并 绑定 三级弹框视图
        var loaded = function (h) {
            var $table = $('#table')
            var MatNoH = $('#matnoh').html();
 
            $.gitAjax({
                url: "/StoreAjax/GetStoreDetail",
                data: { ajaxdata: MatNoH },
                type: "post",
                dataType: "json",
                success: function (result) {            // result = 后台返回值
                    if (result != null) {
                        var data = result.Result.List;
                        $table.bootstrapTable({ data: data })
                    }
                }
            })
        }
 
        switch (Command) {
            case "Detail":
                $.jBox.open("get:/Data/Store/StoreDetail?MatNo=" + MatNo, "详细信息", 680, 500, { buttons: { "确定": true, "关闭": false }, loaded: loaded });
                // $.jBox.open("get:/Business/CheckTask/Edit?Guid=" + Guid, "编辑", width, height, { buttons: { /*"确定": true,*/ "关闭": false }, top: '10%' })
                break;
            default: break;
        }
    },
 
    ToolBar: function () {
        //搜索 高级搜索按钮
        var searchBar = $("div[data-condition='search']");
        searchBar.find("a[data-command='search']").click(function () {
            StoreBasicManager.PageClick(1, 50);
        });
 
        var btnClick = $("div.toolbar");
        btnClick.find("a.btn").click(function () {
            var command = $(this).attr("data-command");
 
            if (command == "Detail") {
                var list = StoreBasicManager.GetSelect();
                if (list.length == 0) {
                    $.jBox.tip("请选择要查看明细的项!", "warn");
                    return false;
                }
                var MatNo = list[0];
                StoreBasicManager.Dialog(MatNo, command);
            }
            else if (command == "Excel") {
 
            }
            else if (command == "Port") {
                // 获取查询条件
                var search = StoreBasicManager.GetSearch();
 
                $.gitAjax({
                    url: "/Data/StoreAjax/SetSeesion",
                    data: { ajaxdata: JSON.stringify(search) },
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        // alert(1);
                        //window.open("ReportShow");
                        window.location.href = "/Data/Store/ReportShow";
                    }
                });
                //var urlStr = "MatNo=" + search.MatNo + "&MatName=" + search.MatName + " &AreaNo=" + search.AreaNo + "&AddreNo=" + search.AddreNo + "&PackFormat=" + search.PackFormat;
                //// 打开新窗体 将查询条件传值到新页面
                //window.location.href = "/Data/Store/ReportShow?" + urlStr;
            }
 
        });
 
        // 下拉框选择事件
        $("#areaid").change(function () {
            var areaid = ($(this).val());       // 获取库区编码
            $.gitAjax({
                url: "/StorageAjax/BindOption",
                data: { ajaxdata: areaid },
                type: "post",
                dataType: "json",
                success: function (result) {            // result = 后台返回值
                    if (result != null) {
                        // 清空下拉框选项 重新赋值 
                        $("#Addreid").empty();
                        $("#Addreid").html(result.Addreid);
                    }
                }
            })
        });
 
        //监听回车事件,用于扫描
        searchBar.find("input[name='MatNo']").keydown(function (event) {
            if (event.keyCode == 13) {
 
                var value = $(this).val();
                if (!git.IsEmpty(value)) {
                    StoreBasicManager.PageClick(1, 50);
                    setTimeout(function () {
                        searchBar.find("input[name='MatNo']").val("");
                        searchBar.find("input[name='MatNo']").focus();
                    }, 300);
                }
            }
        });
 
        //窗体加载获得焦点
        searchBar.find("input[name='MatNo']").focus();
        //加载默认数据
        StoreBasicManager.PageClick(1, 50);
    },
}