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
var TaskItemsManager = {
    InTables: undefined,
    Server: function (URL, data, callback) {
        $.gitAjax({
            url: URL,
            data: data,
            type: "post",
            dataType: "json",
            success: function (result) {
                callback(result);
            }
        });
    },
 
    ToolBar: function () {
        var searchBar = $("div[data-condition='search']");
        //窗体加载获得焦点
        TaskItemsManager.PageClick(1, 15);
        searchBar.find("input[name='MatNo']").focus();
 
        searchBar.find('button[data-command="Search"]').unbind("click").bind("click", function (event) {
            TaskItemsManager.PageClick(1, 15);
        });
 
        var btnClick = $("div.toolbar");
        btnClick.find("a.btn").click(function () {
            var command = $(this).attr("data-command");
            switch (command) {
                case "Edit":                    // 保存按钮
                    var param = CheckPalno.GetModel();
                    if (!param) {
                        return false;
                    }
                    var Server = CheckManager.Server();
                    Server.Add(param, function (result) {
                        if (result.Code == 1) {
                            window.location.href = "/Business/CheckData/Index";
                        } else {
                            $.jBox.tip(result.Message);
                        }
                    });
                    break;
                case "Delete":                  // 取消按钮
                    window.location.href = "/Business/CheckTask/Index";
                    break;
                default: break;
            }
 
        })
    },
 
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var search = TaskItemsManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
        TaskItemsManager.Server("/Business/CheckTaskAjax/GetItems", { bbb: JSON.stringify(search) }, function (result) {
            $.jBox.closeTip();
            if (result != null) {
                if (result.Code == 1) {
                    // 查询成功,绑定Table
                    TaskItemsManager.SetTable(result);
                }
 
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
 
    GetSearch: function () {
        var search = {};
        var searchBar = $("div[data-condition='search']");
        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["Palno"] = searchBar.find("input[name='Palno1']").val();
        return search;
    },
 
    SetTable: function (result) {
        var cols = [
            {
                title: '库位地址', name: 'LocationCode', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '托盘号', name: 'Palno', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '生产令号', name: 'LingNo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '物料编码', name: 'MatNo', width: 120, align: 'center', lockWidth: false, 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: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                titleHtml: '实际数量', name: 'AQuant', width: 80, align: 'center', editable: true, lockWidth: false, renderer: function (data, item, rowIndex) {
                    //return data;
                    var html = "";
                    html += '<input id="cb' + rowIndex + '" value="' + data + '"  onblur="fun(' + rowIndex + ')" style="border:0px; border-bottom: 2px solid #9fc4bf; width: 100%" />';
                    return html;
                }
            },
            {
                title: '包装规格', name: 'PackFormat', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '计量单位', name: 'UnitFrist', width: 55, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '主键ID', name: 'Guid', width: 100, hidden: true, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '任务主键ID', name: 'TaskID', width: 100, hidden: true, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
        ];
 
        // 设置Table
        if (this.InTables == undefined) {
            var ht = masterUI.MMGridHeight()-70;
            this.InTables = $("#tabLists").mmGrid({
                cols: cols,
                sortName: 'Palno',
                sortStatus: 'desc',
                items: result.Result.List,
                indexCol:true,
                nowrap: true,
                fullWidthRows: true,
                //indexCol:true,
                height: ht
            });
        }
        else {
            this.InTables.load(result.Result.List);
        }
    },
    SetItems: function (rowIndex)
    {
        if (TaskItemsManager.InTables != undefined) {
            var rows = TaskItemsManager.InTables.row(rowIndex);
            if (rows != undefined) {
                var search = {};
                search["Guid"] = rows.Guid;
                search["AQuant"] = $("#cb" + rowIndex).val();
                TaskItemsManager.Server("/Business/CheckTaskAjax/SetItems", { bbb: JSON.stringify(search) }, function (result) {
                    if (result != null) {
                        if (result.Code == -1) {
                            $.jBox.tip(result.Message, "warn");
                        }
                    }
                });
            }
        }
    },
}