layui.use(['table', 'admin', 'ax', 'func'], function () {
|
var $ = layui.$;
|
var table = layui.table;
|
var $ax = layui.ax;
|
var admin = layui.admin;
|
var func = layui.func;
|
|
/**
|
* plc交互数据管理
|
*/
|
var PlcInteractiveData = {
|
tableId: "plcInteractiveDataTable"
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
PlcInteractiveData.initColumn = function () {
|
return [[
|
{type: 'checkbox'},
|
{field: 'id', hide: true, title: 'id'},
|
{field: 'snCode', sort: true, title: 'SN号'},
|
{field: 'grade', sort: true, title: '员工权限'},
|
{field: 'stationCode', sort: true, title: '工位编号'},
|
{field: 'workID', sort: true, title: '员工ID'},
|
{field: 'palletID', sort: true, title: '托盘号'},
|
{field: 'stationStatus', sort: true, title: '站状态1:OK;2:NG'},
|
{field: 'spare', sort: true, title: '备注'},
|
{field: 'createTime', sort: true, title: '创建时间'},
|
{field: 'updateTime', sort: true, title: '修改时间'},
|
{field: 'createUser', sort: true, title: '创建人'},
|
{field: 'updateUser', sort: true, title: '修改人'},
|
{align: 'center', toolbar: '#tableBar', title: '操作'}
|
]];
|
};
|
|
/**
|
* 点击查询按钮
|
*/
|
PlcInteractiveData.search = function () {
|
var queryData = {};
|
|
|
table.reload(PlcInteractiveData.tableId, {
|
where: queryData, page: {curr: 1}
|
});
|
};
|
|
/**
|
* 跳转到添加页面
|
*/
|
PlcInteractiveData.jumpAddPage = function () {
|
window.location.href = Feng.ctxPath + '/plcInteractiveData/add'
|
};
|
|
/**
|
* 跳转到编辑页面
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
PlcInteractiveData.jumpEditPage = function (data) {
|
window.location.href = Feng.ctxPath + '/plcInteractiveData/edit?id=' + data.id
|
};
|
|
/**
|
* 导出excel按钮
|
*/
|
PlcInteractiveData.exportExcel = function () {
|
var checkRows = table.checkStatus(PlcInteractiveData.tableId);
|
if (checkRows.data.length === 0) {
|
Feng.error("请选择要导出的数据");
|
} else {
|
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
|
}
|
};
|
|
/**
|
* 点击删除
|
*
|
* @param data 点击按钮时候的行数据
|
*/
|
PlcInteractiveData.onDeleteItem = function (data) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/plcInteractiveData/delete", function (data) {
|
Feng.success("删除成功!");
|
table.reload(PlcInteractiveData.tableId);
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", data.id);
|
ajax.start();
|
};
|
Feng.confirm("是否删除?", operation);
|
};
|
|
// 渲染表格
|
var tableResult = table.render({
|
elem: '#' + PlcInteractiveData.tableId,
|
url: Feng.ctxPath + '/plcInteractiveData/list',
|
page: true,
|
height: "full-158",
|
cellMinWidth: 100,
|
cols: PlcInteractiveData.initColumn()
|
});
|
|
// 搜索按钮点击事件
|
$('#btnSearch').click(function () {
|
PlcInteractiveData.search();
|
});
|
|
// 添加按钮点击事件
|
$('#btnAdd').click(function () {
|
|
PlcInteractiveData.jumpAddPage();
|
|
});
|
|
// 导出excel
|
$('#btnExp').click(function () {
|
PlcInteractiveData.exportExcel();
|
});
|
|
// 工具条点击事件
|
table.on('tool(' + PlcInteractiveData.tableId + ')', function (obj) {
|
var data = obj.data;
|
var layEvent = obj.event;
|
|
if (layEvent === 'edit') {
|
PlcInteractiveData.jumpEditPage(data);
|
} else if (layEvent === 'delete') {
|
PlcInteractiveData.onDeleteItem(data);
|
}
|
});
|
});
|