提交 | 用户 | 时间
|
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 |
var form = layui.form; |
|
8 |
|
|
9 |
/** |
|
10 |
* 保养计划管理 |
|
11 |
*/ |
|
12 |
var EquipmentMaintainPlan = { |
|
13 |
tableId: "equipmentMaintainPlanTable" |
|
14 |
}; |
|
15 |
|
|
16 |
/** |
|
17 |
* 初始化表格的列 |
|
18 |
*/ |
|
19 |
EquipmentMaintainPlan.initColumn = function () { |
|
20 |
return [[ |
|
21 |
{type: 'checkbox'}, |
|
22 |
{field: 'id', hide: true, title: '主键id'}, |
|
23 |
{field: 'equipmentNo', sort: true, title: '设备编号', width: 125}, |
|
24 |
{field: 'equipmentName', sort: true, title: '设备名称', width: 125}, |
|
25 |
{field: 'planNo', sort: true, title: '计划编号', width: 155}, |
|
26 |
{field: 'planName', sort: true, title: '计划名称', width: 125}, |
|
27 |
{field: 'planType', sort: true, title: '计划类型', width: 125}, |
|
28 |
{field: 'maintainType', sort: true, title: '保养类别', width: 125}, |
|
29 |
{field: 'intervalTime', sort: true, title: '间隔时间', width: 125}, |
|
30 |
{field: 'intervalUnit', sort: true, title: '间隔单位', width: 125}, |
|
31 |
// {field: 'state', sort: true, title: '状态'}, |
|
32 |
{field: 'state', sort: true, templet: '#stateTpl', title: '状态'}, |
|
33 |
{field: 'remarks', sort: true, title: '备注'}, |
|
34 |
{field: 'createUser', sort: true, title: '创建用户', width: 125}, |
|
35 |
{field: 'updateUser', sort: true, title: '更改用户', width: 125}, |
|
36 |
{field: 'createTime', sort: true, title: '创建时间',minWidth:160}, |
|
37 |
{field: 'updateTime', sort: true, title: '更改时间',minWidth:160}, |
|
38 |
{field: 'startTime', sort: true, title: '开始保养时间',minWidth:160}, |
|
39 |
{field: 'endTime', sort: true, title: '结束保养时间',minWidth:160}, |
|
40 |
{align: 'center', toolbar: '#tableBar', title: '操作', width: 125} |
|
41 |
]]; |
|
42 |
}; |
|
43 |
|
|
44 |
/** |
|
45 |
* 点击查询按钮 |
|
46 |
*/ |
|
47 |
EquipmentMaintainPlan.search = function () { |
|
48 |
var queryData = {}; |
|
49 |
queryData['planNo'] = $('#planNo').val(); |
|
50 |
queryData['equipmentName'] = $('#equipmentName').val(); |
|
51 |
queryData['equipmentNo'] = $('#equipmentNo').val(); |
|
52 |
|
|
53 |
table.reload(EquipmentMaintainPlan.tableId, { |
|
54 |
where: queryData, page: {curr: 1} |
|
55 |
}); |
|
56 |
}; |
|
57 |
|
|
58 |
form.on('switch(status)', function (obj) { |
|
59 |
var id = obj.elem.value; |
|
60 |
var checked = obj.elem.checked ? 1 : 0; |
|
61 |
EquipmentMaintainPlan.changeStatus(id, checked); |
|
62 |
}); |
|
63 |
|
|
64 |
// 修改状态方法 |
|
65 |
EquipmentMaintainPlan.changeStatus = function (id, checked) { |
|
66 |
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/editItem", function (data) { |
|
67 |
Feng.success("修改成功!"); |
|
68 |
}, function (data) { |
|
69 |
Feng.error("修改失败!" + data.message); |
|
70 |
table.reload(BsWorkshopInfo.tableId); |
|
71 |
}); |
|
72 |
ajax.set("id", id); |
|
73 |
ajax.set("state", checked); |
|
74 |
ajax.start(); |
|
75 |
}; |
|
76 |
|
|
77 |
/** |
|
78 |
* 弹出添加对话框 |
|
79 |
*/ |
|
80 |
EquipmentMaintainPlan.openAddDlg = function () { |
|
81 |
window.location.href = Feng.ctxPath + '/equipmentMaintainPlan/add' |
|
82 |
}; |
|
83 |
|
|
84 |
/** |
|
85 |
* 点击编辑 |
|
86 |
* |
|
87 |
* @param data 点击按钮时候的行数据 |
|
88 |
*/ |
|
89 |
EquipmentMaintainPlan.openEditDlg = function (data) { |
|
90 |
window.location.href = Feng.ctxPath + '/equipmentMaintainPlan/edit?id=' + data.id |
|
91 |
}; |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* 导出excel按钮 |
|
96 |
*/ |
|
97 |
EquipmentMaintainPlan.exportExcel = function () { |
|
98 |
var checkRows = table.checkStatus(EquipmentMaintainPlan.tableId); |
|
99 |
if (checkRows.data.length === 0) { |
|
100 |
Feng.error("请选择要导出的数据"); |
|
101 |
} else { |
|
102 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
103 |
} |
|
104 |
}; |
|
105 |
|
|
106 |
/** |
|
107 |
* 点击删除 |
|
108 |
* |
|
109 |
* @param data 点击按钮时候的行数据 |
|
110 |
*/ |
|
111 |
EquipmentMaintainPlan.onDeleteItem = function (data) { |
|
112 |
var operation = function () { |
|
113 |
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainPlan/delete", function (data) { |
|
114 |
Feng.success("删除成功!"); |
|
115 |
table.reload(EquipmentMaintainPlan.tableId); |
|
116 |
}, function (data) { |
|
117 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
118 |
}); |
|
119 |
ajax.set("id", data.id); |
|
120 |
ajax.start(); |
|
121 |
}; |
|
122 |
Feng.confirm("是否删除?", operation); |
|
123 |
}; |
|
124 |
|
|
125 |
// 渲染表格 |
|
126 |
var tableResult = table.render({ |
|
127 |
elem: '#' + EquipmentMaintainPlan.tableId, |
|
128 |
url: Feng.ctxPath + '/equipmentMaintainPlan/list', |
|
129 |
page: true, |
|
130 |
height: "full-158", |
|
131 |
cellMinWidth: 100, |
|
132 |
cols: EquipmentMaintainPlan.initColumn() |
|
133 |
}); |
|
134 |
|
|
135 |
// 搜索按钮点击事件 |
|
136 |
$('#btnSearch').click(function () { |
|
137 |
EquipmentMaintainPlan.search(); |
|
138 |
}); |
|
139 |
|
|
140 |
// 添加按钮点击事件 |
|
141 |
$('#btnAdd').click(function () { |
|
142 |
|
|
143 |
EquipmentMaintainPlan.openAddDlg(); |
|
144 |
|
|
145 |
}); |
|
146 |
|
|
147 |
// 导出excel |
|
148 |
$('#btnExp').click(function () { |
|
149 |
EquipmentMaintainPlan.exportExcel(); |
|
150 |
}); |
|
151 |
|
|
152 |
// 工具条点击事件 |
|
153 |
table.on('tool(' + EquipmentMaintainPlan.tableId + ')', function (obj) { |
|
154 |
var data = obj.data; |
|
155 |
var layEvent = obj.event; |
|
156 |
|
|
157 |
if (layEvent === 'edit') { |
|
158 |
EquipmentMaintainPlan.openEditDlg(data); |
|
159 |
} else if (layEvent === 'delete') { |
|
160 |
EquipmentMaintainPlan.onDeleteItem(data); |
|
161 |
} |
|
162 |
}); |
|
163 |
}); |