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