懒羊羊
2023-10-17 5d91e0a52879bf16511817b3cd20496f07717ab1
提交 | 用户 | 时间
487b2f 1 layui.use(['table', 'admin', 'ax', 'func'], function () {
YY 2     var $ = layui.$;
3     var table = layui.table;
4     var $ax = layui.ax;
5     var admin = layui.admin;
6     var func = layui.func;
7
8     /**
9      * 管理
10      */
11     var OpcuaConf = {
12         tableId: "opcuaConfTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     OpcuaConf.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: 'ID'},
22             {field: 'module', sort: true, title: '所属模块'},
23             {field: 'node', sort: true, title: '节点'},
24             {field: 'length', sort: true, title: '长度'},
5d91e0 25             {field: 'sysTypes', sort: true, title: '类型'},
487b2f 26             {field: 'functionality', sort: true, title: '功能说明'},
YY 27             {field: 'subscribe', sort: true, title: '是否订阅'},
28             {field: 'rModule', sort: true, title: '订阅响应模块'},
29             {field: 'rFunction', sort: true, title: '订阅响应函数'},
30             {field: 'remarks', sort: true, title: '备注'},
31             {fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'}
32         ]];
33     };
34
35     /**
36      * 点击查询按钮
37      */
38     OpcuaConf.search = function () {
39         var queryData = {};
40
41
42         table.reload(OpcuaConf.tableId, {
43             where: queryData, page: {curr: 1}
44         });
45     };
46
47     /**
48      * 跳转到添加页面
49      */
50     OpcuaConf.jumpAddPage = function () {
51         window.location.href = Feng.ctxPath + '/opcuaConf/add'
52     };
53
54     /**
55     * 跳转到编辑页面
56     *
57     * @param data 点击按钮时候的行数据
58     */
59     OpcuaConf.jumpEditPage = function (data) {
60         window.location.href = Feng.ctxPath + '/opcuaConf/edit?id=' + data.id
61     };
62
63     /**
64      * 导出excel按钮
65      */
66     OpcuaConf.exportExcel = function () {
67         var checkRows = table.checkStatus(OpcuaConf.tableId);
68         if (checkRows.data.length === 0) {
69             Feng.error("请选择要导出的数据");
70         } else {
71             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
72         }
73     };
74
75     /**
76      * 点击删除
77      *
78      * @param data 点击按钮时候的行数据
79      */
80     OpcuaConf.onDeleteItem = function (data) {
81         var operation = function () {
82             var ajax = new $ax(Feng.ctxPath + "/opcuaConf/delete", function (data) {
83                 Feng.success("删除成功!");
84                 table.reload(OpcuaConf.tableId);
85             }, function (data) {
86                 Feng.error("删除失败!" + data.responseJSON.message + "!");
87             });
88             ajax.set("id", data.id);
89             ajax.start();
90         };
91         Feng.confirm("是否删除?", operation);
92     };
93
94     // 渲染表格
95     var tableResult = table.render({
96         elem: '#' + OpcuaConf.tableId,
97         url: Feng.ctxPath + '/opcuaConf/list',
98         page: true,
99         height: "full-158",
100         cellMinWidth: 100,
101         cols: OpcuaConf.initColumn()
102     });
103
104     // 搜索按钮点击事件
105     $('#btnSearch').click(function () {
106         OpcuaConf.search();
107     });
108
109     // 添加按钮点击事件
110     $('#btnAdd').click(function () {
111
112     OpcuaConf.jumpAddPage();
113
114     });
115
116     // 导出excel
117     $('#btnExp').click(function () {
118         OpcuaConf.exportExcel();
119     });
120
121     // 工具条点击事件
122     table.on('tool(' + OpcuaConf.tableId + ')', function (obj) {
123         var data = obj.data;
124         var layEvent = obj.event;
125
126         if (layEvent === 'edit') {
127             OpcuaConf.jumpEditPage(data);
128         } else if (layEvent === 'delete') {
129             OpcuaConf.onDeleteItem(data);
130         }
131     });
132 });