| | |
| | | if (layEvent === 'edit') { |
| | | showEditModel(data); |
| | | } else if (layEvent === 'del') { |
| | | doDel(data.experimentTypeId); |
| | | doDel(data.billNo); |
| | | } else if (layEvent === 'look') { |
| | | var $a = $(obj.tr).find('a[lay-event="look"]'); |
| | | var offset = $a.offset(); |
| | |
| | | form.val('editForm', expTpe); |
| | | // 表单提交事件 |
| | | form.on('submit(waitMatinEditSubmit)', function (data) { |
| | | if (isExpAdd) { |
| | | if (xxDataList.length <= 0) { |
| | | layer.tips('请添加单据明细', '#matAddBtnComment', {tips: [1, '#ff4c4c']}); |
| | | return false; |
| | | } |
| | | var nList = admin.util.deepClone(xxDataList); |
| | | for (var xi = 0; xi < nList.length; xi++) { |
| | | nList[xi].experimentId = undefined; |
| | | } |
| | | data.field.expListJson = JSON.stringify(nList); |
| | | // 组装数据 |
| | | if (xxDataList.length <= 0) { |
| | | layer.tips('请添加单据明细', '#matAddBtnComment', {tips: [1, '#ff4c4c']}); |
| | | return false; |
| | | } |
| | | layer.load(2); |
| | | $.get(url, data.field, function (res) { |
| | | layer.closeAll('loading'); |
| | | if (res.code === 200) { |
| | | layer.close(dIndex); |
| | | insTb.reload({page: {curr: 1}}); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | var param = []; |
| | | var nList = admin.util.deepClone(xxDataList); |
| | | for (var xi = 0; xi < nList.length; xi++) { |
| | | if (nList[xi].qty > 0) { |
| | | param.push({ |
| | | billNo: data.field.billNo, |
| | | billType: data.field.billType, |
| | | matNo: nList[xi].matNo, |
| | | matName: nList[xi].matName, |
| | | qty: nList[xi].qty, |
| | | }) |
| | | } |
| | | }, 'json'); |
| | | } |
| | | if (param.length === 0) { |
| | | layer.msg('单据明细数量不合法', {icon: 2}); |
| | | return false; |
| | | } |
| | | if (isExpAdd) { |
| | | layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/waitMatin/add/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll('loading'); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | insTb.reload({page: {curr: 1}}); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | return false; |
| | | }); |
| | | // 明细表格 |
| | |
| | | }); |
| | | } |
| | | |
| | | // 删除 |
| | | function doDel(experimentTypeId) { |
| | | // 删除单据 |
| | | function doDel(billNo) { |
| | | layer.confirm('确定要删除吗?', { |
| | | shade: .1, |
| | | skin: 'layui-layer-admin' |
| | | }, function (i) { |
| | | layer.close(i); |
| | | layer.load(2); |
| | | $.post('../../json/ok.json', { |
| | | experimentTypeId: experimentTypeId |
| | | }, function (res) { |
| | | layer.closeAll('loading'); |
| | | if (res.code === 200) { |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.reload({page: {curr: 1}}); |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | |
| | | $.ajax({ |
| | | url: baseUrl+"/waitMatin/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | billNo: billNo |
| | | }, |
| | | // contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll('loading'); |
| | | if (res.code === 200){ |
| | | insTb.reload({page: {curr: 1}}); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }, 'json'); |
| | | }) |
| | | }); |
| | | } |
| | | |