cl
2024-01-23 6dadf36ef118fbb3b2cd5aca94cde88e29fb55dc
提交 | 用户 | 时间
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 EquipmentMaintainContentConf = {
12         tableId: "equipmentMaintainContentConfTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     EquipmentMaintainContentConf.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: '主键id'},
22             {field: 'maintainContentCode', sort: true, title: '编号', width: 125},
23             {field: 'maintainContentName', sort: true, title: '名称', width: 125},
24             {field: 'maintainContentType', sort: true, title: '类型'},
25             {field: 'maintainContent', sort: true, title: '保养内容描述',minWidth:130},
26             {field: 'state', sort: true, title: '状态'},
27             {field: 'createUser', sort: true, title: '创建用户', width: 125},
28             {field: 'updateUser', sort: true, title: '更改用户', width: 125},
29             {field: 'createTime', sort: true, title: '创建时间',minWidth:160},
30             {field: 'updateTime', sort: true, title: '更改时间',minWidth:160},
31             {field: 'remarks', sort: true, title: '备注'},
32             {align: 'center', toolbar: '#tableBar', title: '操作', width: 125}
33         ]];
34     };
35
36     /**
37      * 点击查询按钮
38      */
39     EquipmentMaintainContentConf.search = function () {
40         var queryData = {};
41         queryData['maintainContentCode'] = $('#maintainContentCode').val();
42         queryData['maintainContentName'] = $('#maintainContentName').val();
43
44
45         table.reload(EquipmentMaintainContentConf.tableId, {
46             where: queryData, page: {curr: 1}
47         });
48     };
49
50     /**
51      * 弹出添加对话框
52      */
53     EquipmentMaintainContentConf.openAddDlg = function () {
54         window.location.href = Feng.ctxPath + '/equipmentMaintainContentConf/add'
55     };
56
57      /**
58       * 点击编辑
59       *
60       * @param data 点击按钮时候的行数据
61       */
62       EquipmentMaintainContentConf.openEditDlg = function (data) {
63           window.location.href = Feng.ctxPath + '/equipmentMaintainContentConf/edit?id=' + data.id
64       };
65
66
67     /**
68      * 导出excel按钮
69      */
70     EquipmentMaintainContentConf.exportExcel = function () {
71         var checkRows = table.checkStatus(EquipmentMaintainContentConf.tableId);
72         if (checkRows.data.length === 0) {
73             Feng.error("请选择要导出的数据");
74         } else {
75             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
76         }
77     };
78
79     /**
80      * 点击删除
81      *
82      * @param data 点击按钮时候的行数据
83      */
84     EquipmentMaintainContentConf.onDeleteItem = function (data) {
85         var operation = function () {
86             var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentConf/delete", function (data) {
87                 Feng.success("删除成功!");
88                 table.reload(EquipmentMaintainContentConf.tableId);
89             }, function (data) {
90                 Feng.error("删除失败!" + data.responseJSON.message + "!");
91             });
92             ajax.set("id", data.id);
93             ajax.start();
94         };
95         Feng.confirm("是否删除?", operation);
96     };
97
98     // 渲染表格
99     var tableResult = table.render({
100         elem: '#' + EquipmentMaintainContentConf.tableId,
101         url: Feng.ctxPath + '/equipmentMaintainContentConf/list',
102         page: true,
103         height: "full-158",
104         cellMinWidth: 100,
105         cols: EquipmentMaintainContentConf.initColumn()
106     });
107
108     // 搜索按钮点击事件
109     $('#btnSearch').click(function () {
110         EquipmentMaintainContentConf.search();
111     });
112
113     // 添加按钮点击事件
114     $('#btnAdd').click(function () {
115
116     EquipmentMaintainContentConf.openAddDlg();
117
118     });
119
120     // 导出excel
121     $('#btnExp').click(function () {
122         EquipmentMaintainContentConf.exportExcel();
123     });
124
125     // 工具条点击事件
126     table.on('tool(' + EquipmentMaintainContentConf.tableId + ')', function (obj) {
127         var data = obj.data;
128         var layEvent = obj.event;
129
130         if (layEvent === 'edit') {
131             EquipmentMaintainContentConf.openEditDlg(data);
132         } else if (layEvent === 'delete') {
133             EquipmentMaintainContentConf.onDeleteItem(data);
134         }
135     });
136 });