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
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
 
var OperationRecordManager = {
    OperationRecordGrid: undefined,
    //接口服务
    Server: function () {
        //配置后端接口api
        var config = (function () {
            var urlGetList = "/OperationRecordAjax/GetOperationRecordList";
 
            return {
                URL_GetList: urlGetList
            };
        })();
 
        //数据操作服务
        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;
    },
 
    //list列表查询第一步
    PageClick: function (PageIndex, PageSize) {
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = OperationRecordManager.Server();
        var search = OperationRecordManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
        Server.GetList(search, function (result) {
            OperationRecordManager.SetTable(result);
            $.jBox.closeTip();
        });
    },
    Refresh: function () {
 
        var PageSize = $("#mypager").pager("GetPageSize");
        var PageIndex = $("#mypager").pager("GetCurrent");
        $.jBox.tip("正在努力加载数据...", "loading");
        var Server = OperationRecordManager.Server();
        var search = OperationRecordManager.GetSearch();
        search["PageIndex"] = PageIndex;
        search["PageSize"] = PageSize;
        Server.GetList(search, function (result) {
            OperationRecordManager.SetTable(result);
            $.jBox.closeTip();
        });
    },
    //渲染表格
    SetTable: function (result) {
        //获取表格需要的高度
        var ht = masterUI.MMGridHeight();
        //渲染表格列信息
        var cols = [
            {
                title: '操作内容', name: 'Msg', width: 300, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '操作类型', name: 'TypeName', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '数据编号', name: 'FkNo', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '菜单名称', name: 'MenuName', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '模块号', name: 'ParentNo', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '操作人', name: 'CreateUserName', width: 140, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return data;
                }
            },
            {
                title: '操作时间', name: 'CreateTime', width: 160, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) {
                    return git.JsonToDateTimeto(data);
                }
            },
        ];
 
        if (this.OperationRecordGrid == undefined) {
            this.OperationRecordGrid = $("#tabList").mmGrid({
                cols: cols,
                items: result.Result.List,
                checkCol: true,
                nowrap: true,
                fullWidthRows: true,
                remoteSort: true,
                multiSelect: true,
                height: ht
            });
            //绑定事件
            OperationRecordManager.BindEvent();
        } else {
            this.OperationRecordGrid.load(result.Result.List);
        }
        //判断渲染分页插件
        var pageInfo = result.PageInfo;
        if (pageInfo != undefined) {
            $("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: OperationRecordManager.PageClick });
        }
    },
    BindEvent: function () {
        //控制按钮权限
        this.OperationRecordGrid.on('loadSuccess', function (e, data) {
            window.LoadBtn.SetBtn();
        });
        //编辑删除事件都绑定
        this.OperationRecordGrid.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
            if ($(e.target).is("a.edit")) {
                var ID = item.ID;
 
                OperationRecordManager.Dialog(ID, "Edit");
            } else if ($(e.target).is("a.delete")) {
                var ID = item.ID;
                var submit = function (v, h, f) {
                    if (v == "ok") {
                        var list = [];
                        list.push(ID);
                        var param = {};
                        param["list"] = JSON.stringify(list);
                        var Server = OperationRecordManager.Server();
                        Server.Delete(param, function (result) {
                            $.jBox.tip(result.Message, "success");
                            var pageSize = $("#mypager").pager("GetPageSize");
                            OperationRecordManager.PageClick(1, pageSize);
                        });
                    }
                }
                $.jBox.confirm("确定要删除该品牌吗?", "提示", submit);
            }
        });
    },
    
    //获取搜索栏中的数据信息
    GetSearch: function () {
        var searchBar = $("div[data-condition='search']");
        
        var userCode = searchBar.find("select[name='UserCode']").val();
        var menuName = searchBar.find("select[name='MenuName']").val();
        var beginTime = searchBar.find("input[name='BeginTime']").val();
        var endTime = searchBar.find("input[name='EndTime']").val();
 
        var search = {};
        search["UserCode"] = userCode;
        search["MenuName"] = menuName;
        search["BeginTime"] = beginTime;
        search["EndTime"] = endTime;
 
        return search;
    },
 
    //初始化方法(渲染按钮事件、表格数据)
    ToolBar: function () {
        //搜索按钮点击事件
        var searchBar = $("div[data-condition='search']");
        searchBar.find("a[data-command='search']").click(function () {
            OperationRecordManager.PageClick(1, 15);
        });
 
        //加载默认数据
        OperationRecordManager.PageClick(1, 15);
    }
};