layui.use(['laydate','table', 'admin', 'ax', 'func'], function () {
|
var $ = layui.$;
|
var table = layui.table;
|
var $ax = layui.ax;
|
var admin = layui.admin;
|
var func = layui.func;
|
var laydate = layui.laydate;
|
|
//日期时间选择器
|
laydate.render({
|
elem: '#startTime'
|
,type: 'datetime'
|
});
|
|
laydate.render({
|
elem: '#endTime'
|
,type: 'datetime'
|
});
|
|
/**
|
* 物料追溯管理
|
*/
|
var MaterialTraceability = {
|
tableId: "materialTraceabilityTable"
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
MaterialTraceability.initColumn = function () {
|
return [[
|
{type: 'checkbox'},
|
{field: 'id', hide: true, title: 'ID'},
|
{field: 'productNo', sort: true, title: '产品序列号',minWidth:160},
|
/* {field: 'housingBarCode', sort: true, title: '壳体条码'},*/
|
{field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:160},
|
{field: 'productCode', sort: true, title: '产品编码',minWidth:125},
|
/* {field: 'productName', sort: true, title: '产品名称'},*/
|
{field: 'lineCode', sort: true, title: '产线编号',minWidth:125},
|
/*{field: 'lineName', sort: true, title: '产线名称'},*/
|
{field: 'locationCode', sort: true, title: '工位编号',minWidth:125},
|
/*{field: 'locationName', sort: true, title: '工位名称'},*/
|
{field: 'materialCode', sort: true, title: '物料编号',minWidth:125},
|
/* {field: 'materialName', sort: true, title: '物料描述'},*/
|
{field: 'materialBatchNo', sort: true, title: '物料批次号',minWidth:125},
|
{field: 'materialSerialNo', sort: true, title: '物料序列号',minWidth:125},
|
{field: 'assemblyQty', sort: true, title: '数量'},
|
{field: 'assemblyUser', sort: true, title: '装配用户',minWidth:125},
|
{field: 'assemblyTime', sort: true, title: '装配时间',minWidth:160},
|
/* {field: 'spareField1', sort: true, title: '预留字段1'},
|
{field: 'spareField2', sort: true, title: '预留字段2'},
|
{field: 'spareField3', sort: true, title: '预留字段3'},
|
{field: 'spareField4', sort: true, title: '预留字段4'},
|
{field: 'remarks', sort: true, title: '备注'},
|
{align: 'center', toolbar: '#tableBar', title: '操作'}*/
|
]];
|
};
|
|
/**
|
* 点击查询按钮
|
*/
|
MaterialTraceability.search = function () {
|
var queryData = {};
|
queryData['productNo'] = $("#productNo").val();
|
queryData['workOrderNo'] = $("#workOrderNo").val();
|
queryData['materialBatchNo'] = $("#materialBatchNo").val();
|
queryData['materialSerialNo'] = $("#materialSerialNo").val();
|
queryData['startTime'] = $("#startTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
|
table.reload(MaterialTraceability.tableId, {
|
where: queryData, page: {curr: 1}
|
});
|
};
|
|
/**
|
* 跳转到添加页面
|
*/
|
MaterialTraceability.jumpAddPage = function () {
|
window.location.href = Feng.ctxPath + '/materialTraceability/add'
|
};
|
|
$("#btnExpAll").click(function () {
|
var queryData = {};
|
queryData['productNo'] = $('#productNo').val();
|
queryData['workOrderNo'] = $('#workOrderNo').val();
|
queryData['materialBatchNo'] = $('#materialBatchNo').val();
|
queryData['materialSerialNo'] = $('#materialSerialNo').val();
|
queryData['startTime'] = $("#startTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
$.ajax({
|
type: "POST",
|
url: Feng.ctxPath + '/materialTraceability/exportTable',
|
data: queryData,
|
success : function (result) {
|
table.exportFile(tableResult.config.id, result.data, 'xls');
|
}
|
});
|
});
|
|
|
/**
|
* 跳转到编辑页面
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
MaterialTraceability.jumpEditPage = function (data) {
|
window.location.href = Feng.ctxPath + '/materialTraceability/edit?id=' + data.id
|
};
|
|
/**
|
* 导出excel按钮
|
*/
|
MaterialTraceability.exportExcel = function () {
|
var checkRows = table.checkStatus(MaterialTraceability.tableId);
|
if (checkRows.data.length === 0) {
|
Feng.error("请选择要导出的数据");
|
} else {
|
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
|
}
|
};
|
|
/**
|
* 点击删除
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
MaterialTraceability.onDeleteItem = function (data) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/materialTraceability/delete", function (data) {
|
Feng.success("删除成功!");
|
table.reload(MaterialTraceability.tableId);
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", data.id);
|
ajax.start();
|
};
|
Feng.confirm("是否删除?", operation);
|
};
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + MaterialTraceability.tableId,
|
url: Feng.ctxPath + '/materialTraceability/list',
|
toolbar: '#toolbarDemo',
|
page: true,
|
height: "full-158",
|
cellMinWidth: 100,
|
cols: MaterialTraceability.initColumn()
|
});
|
|
// 搜索按钮点击事件
|
$('#btnSearch').click(function () {
|
MaterialTraceability.search();
|
});
|
|
// 添加按钮点击事件
|
$('#btnAdd').click(function () {
|
|
MaterialTraceability.jumpAddPage();
|
|
});
|
|
// 导出excel
|
$('#btnExp').click(function () {
|
MaterialTraceability.exportExcel();
|
});
|
|
// 工具条点击事件
|
table.on('tool(' + MaterialTraceability.tableId + ')', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
|
if (layEvent === 'edit') {
|
MaterialTraceability.jumpEditPage(data);
|
} else if (layEvent === 'delete') {
|
MaterialTraceability.onDeleteItem(data);
|
}
|
});
|
});
|