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; console.log("info页面--------"+$('#bomInfoCode').val()); /** * 基础BOM管理 */ var ProductBomChildInfo = { tableId: "productBomChildInfoTable" }; /** * 初始化表格的列 */ ProductBomChildInfo.initColumn = function () { return [[ {type: 'checkbox'}, {field: 'id', hide: true, title: '主键id'}, {field: 'opCode', sort: true, title: '工序编码',width:130}, {field: 'opName', sort: true, title: '工序名称'}, {field: 'materialCode', sort: true, title: '物料编码',width:130}, {field: 'materialName', sort: true, title: '物料名称'}, {field: 'costQty', sort: true, title: '单耗'}, {field: 'unit', sort: true, title: '单位'}, {field: 'remark', sort: true, title: '备注'}, {field: 'bomCode', sort: true, title: 'BOM编码',width:130}, {fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'} ]]; }; /** * 点击查询按钮 */ ProductBomChildInfo.search = function () { var queryData = {}; queryData['opCode'] = $('#opCode').val(); queryData['opName'] = $('#opName').val(); queryData['materialCode'] = $('#materialCode').val(); queryData['materialName'] = $('#materialName').val(); queryData['bomCode'] = $('#bomCode').val(); table.reload(ProductBomChildInfo.tableId, { where: queryData, page: {curr: 1} }); }; /** * 跳转到添加页面 */ ProductBomChildInfo.jumpAddPage = function () { func.open({ height: 650, title: '添加BOM信息', content: Feng.ctxPath + '/productBomChildInfo/add?bomInfoCode=' + $("#bomInfoCode").val(), tableId: ProductBomChildInfo.tableId, // endCallback: function () { // ProductBomChildInfo.initTable(ProductBomChildInfo.tableId); // } }); // window.location.href = Feng.ctxPath + '/productBomChildInfo/add?bomInfoCode='+ $("#bomInfoCode").val() }; /** * 跳转到编辑页面 * * @param data 点击按钮时候的行数据 */ ProductBomChildInfo.jumpEditPage = function (data) { // window.location.href = Feng.ctxPath + '/productBomChildInfo/edit?id=' + data.id func.open({ height: 650, title: 'BOM信息', content: Feng.ctxPath + '/productBomChildInfo/edit?id=' + data.id, tableId: ProductBomChildInfo.tableId, // endCallback: function () { // ProductBomChildInfo.initTable(ProductBomChildInfo.tableId); // } }); }; // 关闭页面 $('#btnBack').click(function () { window.location.href = Feng.ctxPath + "/productBomInfo"; }); /** * 导出excel按钮 */ ProductBomChildInfo.exportExcel = function () { var checkRows = table.checkStatus(ProductBomChildInfo.tableId); if (checkRows.data.length === 0) { Feng.error("请选择要导出的数据"); } else { table.exportFile(tableResult.config.id, checkRows.data, 'xls'); } }; /** * 点击删除 * * @param data 点击按钮时候的行数据 */ ProductBomChildInfo.onDeleteItem = function (data) { var operation = function () { var ajax = new $ax(Feng.ctxPath + "/productBomChildInfo/delete", function (data) { Feng.success("删除成功!"); table.reload(ProductBomChildInfo.tableId); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("id", data.id); ajax.start(); }; Feng.confirm("是否删除?", operation); }; var queryData = {}; queryData['bomCode'] = $('#bomInfoCode').val(); // 渲染表格 var tableResult = table.render({ elem: '#' + ProductBomChildInfo.tableId, url: Feng.ctxPath + '/productBomChildInfo/list', page: true, height: "full-158", cellMinWidth: 100, where: queryData, cols: ProductBomChildInfo.initColumn() }); // 搜索按钮点击事件 $('#btnSearch').click(function () { ProductBomChildInfo.search(); }); // 添加按钮点击事件 $('#btnAdd').click(function () { ProductBomChildInfo.jumpAddPage(); }); // 导出excel $('#btnExp').click(function () { ProductBomChildInfo.exportExcel(); }); // 工具条点击事件 table.on('tool(' + ProductBomChildInfo.tableId + ')', function (obj) { var data = obj.data; var layEvent = obj.event; if (layEvent === 'edit') { ProductBomChildInfo.jumpEditPage(data); } else if (layEvent === 'delete') { ProductBomChildInfo.onDeleteItem(data); } }); });