懒羊羊
2024-01-11 541017985eebeac1811cd115b6585fe76525ddaa
提交 | 用户 | 时间
71e81e 1 layui.use(['table', 'admin', 'ax', 'func'], function () {
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 EquipmentAlarm = {
12         tableId: "equipmentAlarmTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     EquipmentAlarm.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: 'ID'},
22             {field: 'equipmentNo', sort: true, title: '设备编号'},
23             {field: 'equipmentName', sort: true, title: '设备名称'},
24             {field: 'workshopCode', sort: true, title: '车间编号'},
25             {field: 'productionLineCode', sort: true, title: '产线编号'},
26             {field: 'locationCode', sort: true, title: '工位编号'},
27             /*{field: 'errorNo', sort: true, title: '故障代码'},*/
28             {field: 'errorDesc', sort: true, title: '故障描述'},
29             {field: 'alarmTime', sort: true, title: '报警时间'},
30     /*        {field: 'whetherRecovery', sort: true, title: '是否恢复(0否1是)'},
31             {field: 'recoveryTime', sort: true, title: '恢复时间'},
32             {field: 'spareField1', sort: true, title: '预留字段1'},
33             {field: 'spareField2', sort: true, title: '预留字段2'},*/
34             {field: 'remarks', sort: true, title: '备注'},
35             /*{align: 'center', toolbar: '#tableBar', title: '操作'}*/
36         ]];
37     };
38
39     /**
40      * 点击查询按钮
41      */
42     EquipmentAlarm.search = function () {
43         var queryData = {};
44         queryData['equipmentNo'] = $("#equipmentNo").val();
45         queryData['equipmentName'] = $("#equipmentName").val();
46
47         table.reload(EquipmentAlarm.tableId, {
48             where: queryData, page: {curr: 1}
49         });
50     };
51
52     /**
53      * 跳转到添加页面
54      */
55     EquipmentAlarm.jumpAddPage = function () {
56         window.location.href = Feng.ctxPath + '/equipmentAlarm/add'
57     };
58
59     /**
60     * 跳转到编辑页面
61     *
62     * @param data 点击按钮时候的行数据
63     */
64     EquipmentAlarm.jumpEditPage = function (data) {
65         window.location.href = Feng.ctxPath + '/equipmentAlarm/edit?id=' + data.id
66     };
67
68     /**
69      * 导出excel按钮
70      */
71     EquipmentAlarm.exportExcel = function () {
72         var checkRows = table.checkStatus(EquipmentAlarm.tableId);
73         if (checkRows.data.length === 0) {
74             Feng.error("请选择要导出的数据");
75         } else {
76             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
77         }
78     };
79
80     /**
81      * 点击删除
82      *
83      * @param data 点击按钮时候的行数据
84      */
85     EquipmentAlarm.onDeleteItem = function (data) {
86         var operation = function () {
87             var ajax = new $ax(Feng.ctxPath + "/equipmentAlarm/delete", function (data) {
88                 Feng.success("删除成功!");
89                 table.reload(EquipmentAlarm.tableId);
90             }, function (data) {
91                 Feng.error("删除失败!" + data.responseJSON.message + "!");
92             });
93             ajax.set("id", data.id);
94             ajax.start();
95         };
96         Feng.confirm("是否删除?", operation);
97     };
98
99     // 渲染表格
100     var tableResult = table.render({
101         elem: '#' + EquipmentAlarm.tableId,
102         url: Feng.ctxPath + '/equipmentAlarm/list',
103         toolbar: '#toolbarDemo',
104         page: true,
105         height: "full-158",
106         cellMinWidth: 100,
107         cols: EquipmentAlarm.initColumn()
108     });
109
110     // 搜索按钮点击事件
111     $('#btnSearch').click(function () {
112         EquipmentAlarm.search();
113     });
114
115     // 添加按钮点击事件
116     $('#btnAdd').click(function () {
117
118     EquipmentAlarm.jumpAddPage();
119
120     });
121
122     // 导出excel
123     $('#btnExp').click(function () {
124         EquipmentAlarm.exportExcel();
125     });
126
127     // 工具条点击事件
128     table.on('tool(' + EquipmentAlarm.tableId + ')', function (obj) {
129         var data = obj.data;
130         var layEvent = obj.event;
131
132         if (layEvent === 'edit') {
133             EquipmentAlarm.jumpEditPage(data);
134         } else if (layEvent === 'delete') {
135             EquipmentAlarm.onDeleteItem(data);
136         }
137     });
138 });