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; /** * 看板配置管理 */ var KanbanConf = { tableId: "kanbanConfTable" }; /** * 初始化表格的列 */ KanbanConf.initColumn = function () { return [[ {type: 'checkbox'}, {field: 'id', hide: true, title: 'ID'}, // {field: 'pageCode', sort: true, title: '页面编号'}, {field: 'ipAddress', sort: true, title: 'ip地址'}, // {field: 'macAddress', sort: true, title: 'MAC地址'}, // {field: 'workshopCode', sort: true, title: '车间编号'}, // {field: 'workshopName', sort: true, title: '车间名称'}, {field: 'lineCode', sort: true, title: '产线编号'}, {field: 'lineName', sort: true, title: '产线名称'}, {field: 'locationCode', sort: true, title: '工位编码'}, {field: 'locationName', sort: true, title: '工位名称'}, // {field: 'warehouseCode', sort: true, title: '仓库编号'}, // {field: 'warehouseName', sort: true, title: '仓库名称'}, {fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'} ]]; }; /** * 点击查询按钮 */ KanbanConf.search = function () { var queryData = {}; queryData['ipAddress'] = $('#ipAddress').val(); queryData['lineCode'] = $('#lineCode').val(); queryData['locationCode'] = $('#locationCode').val(); table.reload(KanbanConf.tableId, { where: queryData, page: {curr: 1} }); }; /** * 跳转到添加页面 */ KanbanConf.jumpAddPage = function () { window.location.href = Feng.ctxPath + '/kanbanConf/add' }; /** * 跳转到编辑页面 * * @param data 点击按钮时候的行数据 */ KanbanConf.jumpEditPage = function (data) { window.location.href = Feng.ctxPath + '/kanbanConf/edit?id=' + data.id }; /** * 导出excel按钮 */ KanbanConf.exportExcel = function () { var checkRows = table.checkStatus(KanbanConf.tableId); if (checkRows.data.length === 0) { Feng.error("请选择要导出的数据"); } else { table.exportFile(tableResult.config.id, checkRows.data, 'xls'); } }; /** * 点击删除 * * @param data 点击按钮时候的行数据 */ KanbanConf.onDeleteItem = function (data) { var operation = function () { var ajax = new $ax(Feng.ctxPath + "/kanbanConf/delete", function (data) { Feng.success("删除成功!"); table.reload(KanbanConf.tableId); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("id", data.id); ajax.start(); }; Feng.confirm("是否删除?", operation); }; // 渲染表格 var tableResult = table.render({ elem: '#' + KanbanConf.tableId, url: Feng.ctxPath + '/kanbanConf/list', page: true, height: "full-158", cellMinWidth: 100, cols: KanbanConf.initColumn() }); // 搜索按钮点击事件 $('#btnSearch').click(function () { KanbanConf.search(); }); // 添加按钮点击事件 $('#btnAdd').click(function () { KanbanConf.jumpAddPage(); }); // 导出excel $('#btnExp').click(function () { KanbanConf.exportExcel(); }); // 工具条点击事件 table.on('tool(' + KanbanConf.tableId + ')', function (obj) { var data = obj.data; var layEvent = obj.event; if (layEvent === 'edit') { KanbanConf.jumpEditPage(data); } else if (layEvent === 'delete') { KanbanConf.onDeleteItem(data); } }); });