yantian yue
2023-10-18 465d5c4666546e7e54f0e3c34c7bcce5830aaa6a
提交 | 用户 | 时间
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     /**
465d5c 9      * OPCUA配置管理
487b2f 10      */
YY 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
465d5c 41         queryData['node'] = $('#node').val();
487b2f 42
YY 43         table.reload(OpcuaConf.tableId, {
44             where: queryData, page: {curr: 1}
45         });
46     };
47
48     /**
49      * 跳转到添加页面
50      */
51     OpcuaConf.jumpAddPage = function () {
52         window.location.href = Feng.ctxPath + '/opcuaConf/add'
53     };
54
55     /**
56     * 跳转到编辑页面
57     *
58     * @param data 点击按钮时候的行数据
59     */
60     OpcuaConf.jumpEditPage = function (data) {
61         window.location.href = Feng.ctxPath + '/opcuaConf/edit?id=' + data.id
62     };
63
64     /**
65      * 导出excel按钮
66      */
67     OpcuaConf.exportExcel = function () {
68         var checkRows = table.checkStatus(OpcuaConf.tableId);
69         if (checkRows.data.length === 0) {
70             Feng.error("请选择要导出的数据");
71         } else {
72             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
73         }
74     };
75
76     /**
77      * 点击删除
78      *
79      * @param data 点击按钮时候的行数据
80      */
81     OpcuaConf.onDeleteItem = function (data) {
82         var operation = function () {
83             var ajax = new $ax(Feng.ctxPath + "/opcuaConf/delete", function (data) {
84                 Feng.success("删除成功!");
85                 table.reload(OpcuaConf.tableId);
86             }, function (data) {
87                 Feng.error("删除失败!" + data.responseJSON.message + "!");
88             });
89             ajax.set("id", data.id);
90             ajax.start();
91         };
92         Feng.confirm("是否删除?", operation);
93     };
94
95     // 渲染表格
96     var tableResult = table.render({
97         elem: '#' + OpcuaConf.tableId,
98         url: Feng.ctxPath + '/opcuaConf/list',
99         page: true,
100         height: "full-158",
101         cellMinWidth: 100,
102         cols: OpcuaConf.initColumn()
103     });
104
105     // 搜索按钮点击事件
106     $('#btnSearch').click(function () {
107         OpcuaConf.search();
108     });
109
110     // 添加按钮点击事件
111     $('#btnAdd').click(function () {
112
113     OpcuaConf.jumpAddPage();
114
115     });
116
117     // 导出excel
118     $('#btnExp').click(function () {
119         OpcuaConf.exportExcel();
120     });
121
122     // 工具条点击事件
123     table.on('tool(' + OpcuaConf.tableId + ')', function (obj) {
124         var data = obj.data;
125         var layEvent = obj.event;
126
127         if (layEvent === 'edit') {
128             OpcuaConf.jumpEditPage(data);
129         } else if (layEvent === 'delete') {
130             OpcuaConf.onDeleteItem(data);
131         }
132     });
133 });