var initCountVal = 0; var matCodeData = []; function getCol() { var cols = [ {fixed: 'left', field: 'count', title: '数量(必填)', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'}, {field: 'supplier', title: '批号', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'}, {field: 'source', title: '来源', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'}, {field: 'vendor', title: '供应商', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'} // {field: 'allqty', title: '总数量', align: 'center'}, // {field: 'allweight', title: '总重量', align: 'center'} ]; cols.push.apply(cols, matCols); cols.push( {field: 'memo', title:'生产日期', align: 'center'}, {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} ) return cols; } layui.use(['table','laydate', 'form'], function() { var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var form = layui.form; tableIns = table.render({ elem: '#chooseData', data: [], even: true, limit: 500, cellMinWidth: 50, toolbar: '#toolbar', cols: [getCol()], done: function (res, curr, count) { $('td[data-field=count] div').html(initCountVal); setMatCodeData(res.data); limit(); getInBound(); } }); // 页面修改 table.on('edit(chooseData)', function (obj) { // var index = ; // console.log(obj.tr.parents('tr')) // console.log($('obj').othis) // console.log(obj.parents('tr').attr("data-index")); switch (obj.field) { case 'count': updateMatCodeData(obj.data.matNo, obj.data.supplier, Number(obj.value)); break case 'supplier': // updateMatCodeSupplier(obj.data.matNo, obj.value); for (var i=0;i= 0; i--) { if (matCodeData[i].matNo === obj.data.matNo) { matCodeData.splice(i, 1); } } tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound(); // 覆盖render方法的done }}); break; case 'memo': var memoLayer = layer.open({ type: 2, title: '备注', maxmin: true, area: ['400px', '215px'], shadeClose: false, content: 'matMemo.html', btn: ['保存', '取消'], style: 'text-algin: center', yes: function(index, layero){ var memo = layer.getChildFrame('body', index).find("#memo")[0].value; matCodeData.map(function (item) { if (item.matNo === obj.data.matNo && item.supplier === obj.data.supplier) { item.memo = memo; } }); // 重置表格数据 tableIns.reload({data: matCodeData,done:function (res) { limit(); getInBound(); layer.close(memoLayer); }}); }, success: function(layero, index){ var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象 iframeWin.setMatMemo(data.memo); } }); break; } }); function setMatCodeData(data) { matCodeData = data; for (var i=0;i 0) { for (var i=0;i