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