提交 | 用户 | 时间
|
71e81e
|
1 |
layui.use(['laydate','table', 'admin', 'ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var form = layui.form; |
|
6 |
var laydate = layui.laydate; |
|
7 |
|
|
8 |
|
|
9 |
//日期时间选择器 |
|
10 |
laydate.render({ |
|
11 |
elem: '#startTime' |
|
12 |
,type: 'datetime' |
|
13 |
}); |
|
14 |
|
|
15 |
laydate.render({ |
|
16 |
elem: '#endTime' |
|
17 |
,type: 'datetime' |
|
18 |
}); |
|
19 |
|
|
20 |
/** |
|
21 |
* 产品过站采集管理 |
|
22 |
*/ |
|
23 |
var PassingStationCollection = { |
|
24 |
tableId: "passingStationCollectionTable" |
|
25 |
}; |
|
26 |
|
|
27 |
/** |
|
28 |
* 初始化表格的列 |
|
29 |
*/ |
|
30 |
PassingStationCollection.initColumn = function () { |
|
31 |
return [[ |
|
32 |
{type: 'checkbox'}, |
|
33 |
{field: 'id', hide: true, title: '主键id'}, |
|
34 |
{field: 'workOrderNo', sort: true, title: '工单编号',minWidth:160}, |
|
35 |
{field: 'sfcCode', sort: true, title: '总成序列号',minWidth:160}, |
|
36 |
{field: 'productCode', sort: true, title: '产品编号', width: 125}, |
|
37 |
{field: 'productionLine', sort: true, title: '产线编号', width: 125}, |
|
38 |
{field: 'locationCode', sort: true, title: '工位编号', width: 125}, |
|
39 |
/*{field: 'equipmentNo', sort: true, title: '设备编号', width: 125},*/ |
|
40 |
{field: 'inboundTime', sort: true, title: '入站时间',minWidth:160}, |
|
41 |
{field: 'outboundTime', sort: true, title: '出站时间',minWidth:160}, |
|
42 |
{field: 'beatTime', sort: true, title: '节拍时间',minWidth:125}, |
|
43 |
// {field: 'inRsSign', sort: true, title: '入站是否合格', width: 135}, |
|
44 |
/* {field: 'inRsSign', sort: true, templet: '#stateTpl', title: '入站是否合格', width: 135},*/ |
|
45 |
|
|
46 |
/* {field: 'inMsgSign', sort: true, title: '入站NG原因', width: 125},*/ |
|
47 |
// {field: 'outRsSign', sort: true, title: '出站是否合格', width: 135}, |
|
48 |
{field: 'outRsSign', sort: true, templet: '#stateTpls', title: '出站是否合格', width: 135}, |
|
49 |
// {field: 'outRsSignState', sort: true, title: '出站是否合格', width: 135}, |
|
50 |
|
|
51 |
/* {field: 'outMsgSign', sort: true, title: '出站NG原因', width: 125},*/ |
|
52 |
// {field: 'collectionTime', sort: true, title: '采集时间',minWidth:160}, |
|
53 |
/* {field: 'createUser', sort: true, title: '创建用户', width: 125},*/ |
|
54 |
{field: 'createTime', sort: true, title: '采集时间',minWidth:160}, |
|
55 |
/* {field: 'updateUser', sort: true, title: '更改用户', width: 125}, |
|
56 |
{field: 'updateTime', sort: true, title: '更改时间',minWidth:160},*/ |
|
57 |
{align: 'center', toolbar: '#tableBar', title: '操作', width: 125} |
|
58 |
]]; |
|
59 |
}; |
|
60 |
|
|
61 |
form.on('switch(status)', function (obj) { |
|
62 |
var id = obj.elem.value; |
|
63 |
var checked = obj.elem.checked ? 1 : 0; |
|
64 |
PassingStationCollection.changeStatus(id, checked); |
|
65 |
}); |
|
66 |
|
|
67 |
form.on('switch(statuss)', function (obj) { |
|
68 |
var id = obj.elem.value; |
|
69 |
var checked = obj.elem.checked ? 1 : 0; |
|
70 |
PassingStationCollection.changeStatuss(id, checked); |
|
71 |
}); |
|
72 |
|
|
73 |
// 修改状态方法 |
|
74 |
PassingStationCollection.changeStatus = function (id, checked) { |
|
75 |
var ajax = new $ax(Feng.ctxPath + "/passingStationCollection/editItem", function (data) { |
|
76 |
Feng.success("修改成功!"); |
|
77 |
}, function (data) { |
|
78 |
Feng.error("修改失败!" + data.message); |
|
79 |
}); |
|
80 |
ajax.set("id", id); |
|
81 |
ajax.set("inRsSign", checked); |
|
82 |
ajax.start(); |
|
83 |
}; |
|
84 |
|
|
85 |
PassingStationCollection.changeStatuss = function (id, checked) { |
|
86 |
var ajax = new $ax(Feng.ctxPath + "/passingStationCollection/editItem", function (data) { |
|
87 |
Feng.success("修改成功!"); |
|
88 |
}, function (data) { |
|
89 |
Feng.error("修改失败!" + data.message); |
|
90 |
}); |
|
91 |
ajax.set("id", id); |
|
92 |
ajax.set("outRsSign", checked); |
|
93 |
ajax.start(); |
|
94 |
}; |
|
95 |
/** |
|
96 |
* 点击查询按钮 |
|
97 |
*/ |
|
98 |
PassingStationCollection.search = function () { |
|
99 |
var queryData = {}; |
|
100 |
queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
101 |
queryData['productionLine'] = $("#productionLine").val(); |
|
102 |
queryData['sfcCode'] = $("#sfcCode").val(); |
|
103 |
queryData['locationCode'] = $("#locationCode").val(); |
|
104 |
queryData['startTime'] = $("#startTime").val(); |
|
105 |
queryData['endTime'] = $("#endTime").val(); |
|
106 |
|
|
107 |
table.reload(PassingStationCollection.tableId, { |
|
108 |
where: queryData, page: {curr: 1} |
|
109 |
}); |
|
110 |
}; |
|
111 |
|
|
112 |
$("#btnExpAll").click(function () { |
|
113 |
var queryData = {}; |
|
114 |
queryData['workOrderNo'] = $('#workOrderNo').val(); |
|
115 |
queryData['productionLine'] = $('#productionLine').val(); |
|
116 |
queryData['sfcCode'] = $('#sfcCode').val(); |
|
117 |
queryData['locationCode'] = $('#locationCode').val(); |
|
118 |
queryData['startTime'] = $("#startTime").val(); |
|
119 |
queryData['endTime'] = $("#endTime").val(); |
|
120 |
$.ajax({ |
|
121 |
type: "POST", |
|
122 |
url: Feng.ctxPath + '/passingStationCollection/exportTable', |
|
123 |
data: queryData, |
|
124 |
success : function (result) { |
|
125 |
console.log(result.data) |
|
126 |
table.exportFile(tableResult.config.id, result.data, 'xls'); |
|
127 |
} |
|
128 |
}); |
|
129 |
}); |
|
130 |
|
|
131 |
/** |
|
132 |
* 跳转到添加页面 |
|
133 |
*/ |
|
134 |
PassingStationCollection.jumpAddPage = function () { |
|
135 |
window.location.href = Feng.ctxPath + '/passingStationCollection/add' |
|
136 |
}; |
|
137 |
|
|
138 |
/** |
|
139 |
* 跳转到编辑页面 |
|
140 |
* |
|
141 |
* @param data 点击按钮时候的行数据 |
|
142 |
*/ |
|
143 |
PassingStationCollection.jumpEditPage = function (data) { |
|
144 |
window.location.href = Feng.ctxPath + '/passingStationCollection/edit?id=' + data.id |
|
145 |
}; |
|
146 |
|
|
147 |
/** |
|
148 |
* 导出excel按钮 |
|
149 |
*/ |
|
150 |
PassingStationCollection.exportExcel = function () { |
|
151 |
var checkRows = table.checkStatus(PassingStationCollection.tableId); |
|
152 |
if (checkRows.data.length === 0) { |
|
153 |
Feng.error("请选择要导出的数据"); |
|
154 |
} else { |
|
155 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
156 |
} |
|
157 |
}; |
|
158 |
|
|
159 |
/** |
|
160 |
* 点击删除 |
|
161 |
* |
|
162 |
* @param data 点击按钮时候的行数据 |
|
163 |
*/ |
|
164 |
PassingStationCollection.onDeleteItem = function (data) { |
|
165 |
var operation = function () { |
|
166 |
var ajax = new $ax(Feng.ctxPath + "/passingStationCollection/delete", function (data) { |
|
167 |
Feng.success("删除成功!"); |
|
168 |
table.reload(PassingStationCollection.tableId); |
|
169 |
}, function (data) { |
|
170 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
171 |
}); |
|
172 |
ajax.set("id", data.id); |
|
173 |
ajax.start(); |
|
174 |
}; |
|
175 |
Feng.confirm("是否删除?", operation); |
|
176 |
}; |
|
177 |
|
|
178 |
// 渲染表格 |
|
179 |
var tableResult = table.render({ |
|
180 |
elem: '#' + PassingStationCollection.tableId, |
|
181 |
url: Feng.ctxPath + '/passingStationCollection/list', |
|
182 |
toolbar: '#toolbarDemo', |
|
183 |
page: true, |
|
184 |
height: "full-158", |
|
185 |
cellMinWidth: 100, |
|
186 |
cols: PassingStationCollection.initColumn() |
|
187 |
}); |
|
188 |
|
|
189 |
// 搜索按钮点击事件 |
|
190 |
$('#btnSearch').click(function () { |
|
191 |
PassingStationCollection.search(); |
|
192 |
}); |
|
193 |
|
|
194 |
// 添加按钮点击事件 |
|
195 |
$('#btnAdd').click(function () { |
|
196 |
|
|
197 |
PassingStationCollection.jumpAddPage(); |
|
198 |
|
|
199 |
}); |
|
200 |
|
|
201 |
// 导出excel |
|
202 |
$('#btnExp').click(function () { |
|
203 |
PassingStationCollection.exportExcel(); |
|
204 |
}); |
|
205 |
|
|
206 |
// 工具条点击事件 |
|
207 |
table.on('tool(' + PassingStationCollection.tableId + ')', function (obj) { |
|
208 |
var data = obj.data; |
|
209 |
var layEvent = obj.event; |
|
210 |
|
|
211 |
if (layEvent === 'edit') { |
|
212 |
PassingStationCollection.jumpEditPage(data); |
|
213 |
} else if (layEvent === 'delete') { |
|
214 |
PassingStationCollection.onDeleteItem(data); |
|
215 |
} |
|
216 |
}); |
|
217 |
}); |