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 SalesOrderChild = { tableId: "salesOrderChildTable" }; /** * 初始化表格的列 */ SalesOrderChild.initColumn = function () { return [[ {type: 'checkbox'}, {field: 'id', hide: true, title: '主键id'}, {field: 'salesOrderCode', sort: true, title: '订单编号'}, {field: 'customerNo', sort: true, title: '客户编号'}, {field: 'cargoNo', sort: true, title: '货号'}, {field: 'productCode', sort: true, title: '产品编号'}, {field: 'productName', sort: true, title: '产品名称'}, {field: 'planNumber', sort: true, title: '计划数量'}, {field: 'planStartTime', sort: true, title: '计划开始时间'}, {field: 'planEndTime', sort: true, title: '计划结束时间'}, {field: 'workshopCode', sort: true, title: '车间编码'}, {field: 'lineCode', sort: true, title: '产线编码'}, {field: 'deliveryTime', sort: true, title: '交货时间'}, {field: 'createUser', sort: true, title: '创建用户'}, {field: 'createTime', sort: true, title: '创建时间'}, {fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'} ]]; }; /** * 点击查询按钮 */ SalesOrderChild.search = function () { var queryData = {}; queryData['salesOrderCode'] = $('#salesOrderCode').val(); queryData['customerNo'] = $('#customerNo').val(); queryData['cargoNo'] = $('#cargoNo').val(); queryData['productCode'] = $('#productCode').val(); queryData['productName'] = $('#productName').val(); queryData['workshopCode'] = $('#workshopCode').val(); queryData['lineCode'] = $('#lineCode').val(); table.reload(SalesOrderChild.tableId, { where: queryData, page: {curr: 1} }); }; /** * 跳转到添加页面 */ SalesOrderChild.jumpAddPage = function () { window.location.href = Feng.ctxPath + '/salesOrderChild/add' }; /** * 跳转到编辑页面 * * @param data 点击按钮时候的行数据 */ SalesOrderChild.jumpEditPage = function (data) { window.location.href = Feng.ctxPath + '/salesOrderChild/edit?id=' + data.id }; /** * 导出excel按钮 */ SalesOrderChild.exportExcel = function () { var checkRows = table.checkStatus(SalesOrderChild.tableId); if (checkRows.data.length === 0) { Feng.error("请选择要导出的数据"); } else { table.exportFile(tableResult.config.id, checkRows.data, 'xls'); } }; /** * 点击删除 * * @param data 点击按钮时候的行数据 */ SalesOrderChild.onDeleteItem = function (data) { var operation = function () { var ajax = new $ax(Feng.ctxPath + "/salesOrderChild/delete", function (data) { Feng.success("删除成功!"); table.reload(SalesOrderChild.tableId); }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("id", data.id); ajax.start(); }; Feng.confirm("是否删除?", operation); }; // 渲染表格 var tableResult = table.render({ elem: '#' + SalesOrderChild.tableId, url: Feng.ctxPath + '/salesOrderChild/list', page: true, height: "full-158", cellMinWidth: 100, cols: SalesOrderChild.initColumn() }); // 搜索按钮点击事件 $('#btnSearch').click(function () { SalesOrderChild.search(); }); // 添加按钮点击事件 $('#btnAdd').click(function () { SalesOrderChild.jumpAddPage(); }); // 导出excel $('#btnExp').click(function () { SalesOrderChild.exportExcel(); }); // 工具条点击事件 table.on('tool(' + SalesOrderChild.tableId + ')', function (obj) { var data = obj.data; var layEvent = obj.event; if (layEvent === 'edit') { SalesOrderChild.jumpEditPage(data); } else if (layEvent === 'delete') { SalesOrderChild.onDeleteItem(data); } }); });