提交 | 用户 | 时间
|
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 admin = layui.admin; |
|
6 |
var func = layui.func; |
|
7 |
var laydate = layui.laydate; |
|
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 MaterialTraceability = { |
|
24 |
tableId: "materialTraceabilityTable" |
|
25 |
}; |
|
26 |
|
|
27 |
/** |
|
28 |
* 初始化表格的列 |
|
29 |
*/ |
|
30 |
MaterialTraceability.initColumn = function () { |
|
31 |
return [[ |
|
32 |
{type: 'checkbox'}, |
|
33 |
{field: 'id', hide: true, title: 'ID'}, |
|
34 |
{field: 'productNo', sort: true, title: '产品序列号',minWidth:160}, |
|
35 |
/* {field: 'housingBarCode', sort: true, title: '壳体条码'},*/ |
|
36 |
{field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:160}, |
|
37 |
{field: 'productCode', sort: true, title: '产品编码',minWidth:125}, |
|
38 |
/* {field: 'productName', sort: true, title: '产品名称'},*/ |
|
39 |
{field: 'lineCode', sort: true, title: '产线编号',minWidth:125}, |
|
40 |
/*{field: 'lineName', sort: true, title: '产线名称'},*/ |
|
41 |
{field: 'locationCode', sort: true, title: '工位编号',minWidth:125}, |
|
42 |
/*{field: 'locationName', sort: true, title: '工位名称'},*/ |
|
43 |
{field: 'materialCode', sort: true, title: '物料编号',minWidth:125}, |
|
44 |
/* {field: 'materialName', sort: true, title: '物料描述'},*/ |
|
45 |
{field: 'materialBatchNo', sort: true, title: '物料批次号',minWidth:125}, |
|
46 |
{field: 'materialSerialNo', sort: true, title: '物料序列号',minWidth:125}, |
|
47 |
{field: 'assemblyQty', sort: true, title: '数量'}, |
|
48 |
{field: 'assemblyUser', sort: true, title: '装配用户',minWidth:125}, |
|
49 |
{field: 'assemblyTime', sort: true, title: '装配时间',minWidth:160}, |
|
50 |
/* {field: 'spareField1', sort: true, title: '预留字段1'}, |
|
51 |
{field: 'spareField2', sort: true, title: '预留字段2'}, |
|
52 |
{field: 'spareField3', sort: true, title: '预留字段3'}, |
|
53 |
{field: 'spareField4', sort: true, title: '预留字段4'}, |
|
54 |
{field: 'remarks', sort: true, title: '备注'}, |
|
55 |
{align: 'center', toolbar: '#tableBar', title: '操作'}*/ |
|
56 |
]]; |
|
57 |
}; |
|
58 |
|
|
59 |
/** |
|
60 |
* 点击查询按钮 |
|
61 |
*/ |
|
62 |
MaterialTraceability.search = function () { |
|
63 |
var queryData = {}; |
|
64 |
queryData['productNo'] = $("#productNo").val(); |
|
65 |
queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
66 |
queryData['materialBatchNo'] = $("#materialBatchNo").val(); |
|
67 |
queryData['materialSerialNo'] = $("#materialSerialNo").val(); |
|
68 |
queryData['startTime'] = $("#startTime").val(); |
|
69 |
queryData['endTime'] = $("#endTime").val(); |
|
70 |
|
|
71 |
table.reload(MaterialTraceability.tableId, { |
|
72 |
where: queryData, page: {curr: 1} |
|
73 |
}); |
|
74 |
}; |
|
75 |
|
|
76 |
/** |
|
77 |
* 跳转到添加页面 |
|
78 |
*/ |
|
79 |
MaterialTraceability.jumpAddPage = function () { |
|
80 |
window.location.href = Feng.ctxPath + '/materialTraceability/add' |
|
81 |
}; |
|
82 |
|
|
83 |
$("#btnExpAll").click(function () { |
|
84 |
var queryData = {}; |
|
85 |
queryData['productNo'] = $('#productNo').val(); |
|
86 |
queryData['workOrderNo'] = $('#workOrderNo').val(); |
|
87 |
queryData['materialBatchNo'] = $('#materialBatchNo').val(); |
|
88 |
queryData['materialSerialNo'] = $('#materialSerialNo').val(); |
|
89 |
queryData['startTime'] = $("#startTime").val(); |
|
90 |
queryData['endTime'] = $("#endTime").val(); |
|
91 |
$.ajax({ |
|
92 |
type: "POST", |
|
93 |
url: Feng.ctxPath + '/materialTraceability/exportTable', |
|
94 |
data: queryData, |
|
95 |
success : function (result) { |
|
96 |
table.exportFile(tableResult.config.id, result.data, 'xls'); |
|
97 |
} |
|
98 |
}); |
|
99 |
}); |
|
100 |
|
|
101 |
|
|
102 |
/** |
|
103 |
* 跳转到编辑页面 |
|
104 |
* |
|
105 |
* @param data 点击按钮时候的行数据 |
|
106 |
*/ |
|
107 |
MaterialTraceability.jumpEditPage = function (data) { |
|
108 |
window.location.href = Feng.ctxPath + '/materialTraceability/edit?id=' + data.id |
|
109 |
}; |
|
110 |
|
|
111 |
/** |
|
112 |
* 导出excel按钮 |
|
113 |
*/ |
|
114 |
MaterialTraceability.exportExcel = function () { |
|
115 |
var checkRows = table.checkStatus(MaterialTraceability.tableId); |
|
116 |
if (checkRows.data.length === 0) { |
|
117 |
Feng.error("请选择要导出的数据"); |
|
118 |
} else { |
|
119 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
120 |
} |
|
121 |
}; |
|
122 |
|
|
123 |
/** |
|
124 |
* 点击删除 |
|
125 |
* |
|
126 |
* @param data 点击按钮时候的行数据 |
|
127 |
*/ |
|
128 |
MaterialTraceability.onDeleteItem = function (data) { |
|
129 |
var operation = function () { |
|
130 |
var ajax = new $ax(Feng.ctxPath + "/materialTraceability/delete", function (data) { |
|
131 |
Feng.success("删除成功!"); |
|
132 |
table.reload(MaterialTraceability.tableId); |
|
133 |
}, function (data) { |
|
134 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
135 |
}); |
|
136 |
ajax.set("id", data.id); |
|
137 |
ajax.start(); |
|
138 |
}; |
|
139 |
Feng.confirm("是否删除?", operation); |
|
140 |
}; |
|
141 |
|
|
142 |
// 渲染表格 |
|
143 |
var tableResult = table.render({ |
|
144 |
elem: '#' + MaterialTraceability.tableId, |
|
145 |
url: Feng.ctxPath + '/materialTraceability/list', |
|
146 |
toolbar: '#toolbarDemo', |
|
147 |
page: true, |
|
148 |
height: "full-158", |
|
149 |
cellMinWidth: 100, |
|
150 |
cols: MaterialTraceability.initColumn() |
|
151 |
}); |
|
152 |
|
|
153 |
// 搜索按钮点击事件 |
|
154 |
$('#btnSearch').click(function () { |
|
155 |
MaterialTraceability.search(); |
|
156 |
}); |
|
157 |
|
|
158 |
// 添加按钮点击事件 |
|
159 |
$('#btnAdd').click(function () { |
|
160 |
|
|
161 |
MaterialTraceability.jumpAddPage(); |
|
162 |
|
|
163 |
}); |
|
164 |
|
|
165 |
// 导出excel |
|
166 |
$('#btnExp').click(function () { |
|
167 |
MaterialTraceability.exportExcel(); |
|
168 |
}); |
|
169 |
|
|
170 |
// 工具条点击事件 |
|
171 |
table.on('tool(' + MaterialTraceability.tableId + ')', function (obj) { |
|
172 |
var data = obj.data; |
|
173 |
var layEvent = obj.event; |
|
174 |
|
|
175 |
if (layEvent === 'edit') { |
|
176 |
MaterialTraceability.jumpEditPage(data); |
|
177 |
} else if (layEvent === 'delete') { |
|
178 |
MaterialTraceability.onDeleteItem(data); |
|
179 |
} |
|
180 |
}); |
|
181 |
}); |