bklLiudl
2024-07-23 46cca75880353bbffbd8fef39fe2ea659180ebd7
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
var TasksManager = {
    InTables: undefined,
    Server: function (URL, data, callback) {
        $.gitAjax({
            url: URL,
            data: data,
            type: "post",
            dataType: "json",
            success: function (result) {
                callback(result);
            }
        });
    },
 
    ToolBar: function () {
        TasksManager.PageClick(1, 50);
 
        var searchBar = $("div[data-condition='search']");
        searchBar.find('a[data-command="search"]').unbind("click").bind("click", function (event) {
            TasksManager.PageClick(1, 50);
        });
    },
 
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var search = TasksManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
 
        TasksManager.Server("/Data/TaskManageAjax/GetCmdLists", { bbb: JSON.stringify(search) }, function (result) {
            $.jBox.closeTip();
            if (result != null) {
                if (result.Code == 1) {
                    // 查询成功,绑定Table
                    TasksManager.SetTable(result);
                }
 
                $.jBox.tip(result.Message, "warn");
            }
        });
    },
 
    GetSearch: function () {
        var search = {};
        var searchBar = $("div[data-condition='search']");
        search["OrdNo"] = searchBar.find("input[name='OrdNo']").val();
        search["Addre"] = searchBar.find("input[name='Addre']").val();
        search["Palno"] = searchBar.find("input[name='Palno']").val();
        search["IsDel"] = searchBar.find("select[name='IsDel']").val();
        search["BeginTime"] = searchBar.find("input[name='BeginTime']").val();
        search["EndTime"] = searchBar.find("input[name='EndTime']").val();
        return search;
    },
 
    SetTable: function (result) {
        var cols = [
            {
                title: '操作', name: 'CmdId', width: 70, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    var html = "";
                    if (item.IsDel == "未完成") {
                        html += '<a class="del dis" href="javascript:void(0)">删除</a>';
                    }
                    return html;
                }
            },
            {
                title: '单据号', name: 'OrdNo', width: 120, 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: 'Addre', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '高度', name: 'Height', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '操作类型', name: 'CmdTypeStr', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '任务状态', name: 'CmdStatuStr', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '是否完成', name: 'IsDel', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                titleHtml: '时间', name: 'CreateTime', width: 120, align: 'center', editable: true, lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '备注', name: 'Demo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
        ];
 
        // 设置Table
        if (this.InTables == undefined) {
            var ht = masterUI.MMGridHeight();
            this.InTables = $("#tabList").mmGrid({
                cols: cols,
                items: result.Result.List,
                indexCol: true,
                nowrap: true,
                fullWidthRows: true,
                height: ht
            });
 
            //绑定编辑 删除事件
            TasksManager.BindEvent();
 
        }
        else {
            this.InTables.load(result.Result.List);
        }
 
        var pageInfo = result.PageInfo;
        if (pageInfo != undefined) {
            $("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: TasksManager.PageClick });
        }
    },
    BindEvent: function () {
        this.InTables.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
            if ($(e.target).is("a.del"))
            {
                var search = {};
                search["CmdId"] = item.CmdId;
                search["CmdStatu"] = item.CmdStatu;
 
                var submit = function (v, h, f) {
                    if (v == "ok") {
                        TasksManager.Server("/Data/TaskManageAjax/DelCmd", { bbb: JSON.stringify(search) }, function (result) {
                            if (result != null) {
                                $.jBox.tip(result.Message, "warn");
                                TasksManager.PageClick(1, 50);
                            }
                        });
                    }
                }
                $.jBox.confirm("该操作将删除指令,确定要删除吗?", "提示", submit);
            }
        });
 
        this.InTables.on('loadSuccess', function (e, data) {
            LoadBtn.SetBtn();
        });
    }
}