layui.use(['table', 'admin', 'ax', 'func', 'form', 'layer'], function () { var $ = layui.$; var table = layui.table; var $ax = layui.ax; var admin = layui.admin; var func = layui.func; var form = layui.form; var layer = layui.layer; /** * 物料档案管理 */ var MaterialArchives = { tableId: "materialArchivesTable" }; /** * 初始化表格的列 */ MaterialArchives.initColumn = function () { return [[ {type: 'checkbox'}, {field: 'id', hide: true, title: 'id'}, {field: 'maintainContentCode', title: '编号'}, {field: 'maintainContentName', title: '名称'}, {field: 'maintainContentType', title: '类型'}, {field: 'maintainContent', title: '保养内容描述'}, ]]; }; /** * 点击查询按钮 */ MaterialArchives.search = function () { var queryData = {}; queryData['maintainContentCode'] = $('#maintainContentCode').val(); queryData['maintainContentName'] = $('#maintainContentName').val(); table.reload(MaterialArchives.tableId, { where: queryData, page: {curr: 1} }); }; // 渲染表格 var tableResult = table.render({ elem: '#' + MaterialArchives.tableId, url: Feng.ctxPath + '/equipmentMaintainContentConf/list', page: true, height: "full-158", cellMinWidth: 100, cols: MaterialArchives.initColumn() }); // 搜索按钮点击事件 $('#btnSearch').click(function () { MaterialArchives.search(); }); // 确定按钮点击事件 $('#btnAdd').click(function () { MaterialArchives.infoToFath(); }); /** * 传递选择的数据 */ MaterialArchives.infoToFath = function () { var checkRows = table.checkStatus(MaterialArchives.tableId); if (checkRows.data.length === 0) { Feng.error("请选择物料!"); } else { //给父页面传值 var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 parent.layui.$('#materialList').val(JSON.stringify(checkRows.data)); parent.layer.close(index); } }; });