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