Commit c1cc6289 by zhanglt

Merge branch 'master' of http://gitlab.yqdchina.com/huyi/warehouse into zlt

parents 52009af7 fbd61e11
...@@ -105,6 +105,13 @@ ...@@ -105,6 +105,13 @@
] ]
}) })
} }
/**
* 获取所有明细数据
* @returns {*|jQuery}
*/
function getTableData() {
return $(selector).bootstrapTable('getData');
}
function addDetail(selector){ function addDetail(selector){
var row = { var row = {
id: '', id: '',
...@@ -126,7 +133,7 @@ ...@@ -126,7 +133,7 @@
} }
function removeRow(index, rowId, rowDelFlag){ function removeRow(index, rowId, rowDelFlag){
if(rowId){ if(rowId){
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -99,6 +99,11 @@ ...@@ -99,6 +99,11 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写明细!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
function removeRow(index, rowId, rowDelFlag) { function removeRow(index, rowId, rowDelFlag) {
if (rowId) { if (rowId) {
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
function removeRow(index, rowId, rowDelFlag) { function removeRow(index, rowId, rowDelFlag) {
if (rowId) { if (rowId) {
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -74,6 +74,11 @@ ...@@ -74,6 +74,11 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写明细!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
function initTable() { function initTable() {
var data = ${fns:toJson(materialRequisition.materialRequisitionInfoList)}; var data = ${fns:toJson(materialRequisition.materialRequisitionInfoList)};
if(data.length){
data = data.map(function(item){
item.delFlag = 0;
return item;
})
}
$(selector).bootstrapTable({ $(selector).bootstrapTable({
data: data, data: data,
columns: [{checkbox: true}, columns: [{checkbox: true},
...@@ -116,7 +122,7 @@ ...@@ -116,7 +122,7 @@
field: '', field: '',
title: '操作', title: '操作',
formatter: function (value, row, index) { formatter: function (value, row, index) {
var text = '删除'; var text = row.delFlag == 1 ? '撤销删除' : '删除';
var result = ["<a href='javascript:void(0);' onclick=\"removeRow(" + index + ", '" + row.id + "', '" + row.delFlag + "')\">" + text + "</a>"] var result = ["<a href='javascript:void(0);' onclick=\"removeRow(" + index + ", '" + row.id + "', '" + row.delFlag + "')\">" + text + "</a>"]
return result.join(''); return result.join('');
} }
...@@ -177,10 +183,17 @@ ...@@ -177,10 +183,17 @@
} }
function removeRow(index, rowId, rowDelFlag) { function removeRow(index, rowId, rowDelFlag) {
$(selector).bootstrapTable("remove", { if (rowId && rowId != 'undefined') {
field: '$index', var delFlag = rowDelFlag == 1 ? 0 : 1
values: [index] updateRow(index, {
}) delFlag: delFlag
})
} else {
$(selector).bootstrapTable("remove", {
field: '$index',
values: [index]
})
}
} }
function updateRow(index, row) { function updateRow(index, row) {
......
...@@ -117,6 +117,18 @@ ...@@ -117,6 +117,18 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写领用物资!');
return;
}
var hasReceiver = getTableData().every(function(item){
return item.receiver
})
if(!hasReceiver){
jp.warning('领用人必填!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
function removeRow(index, rowId, rowDelFlag) { function removeRow(index, rowId, rowDelFlag) {
if (rowId) { if (rowId) {
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -82,6 +82,11 @@ ...@@ -82,6 +82,11 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写明细!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
*/ */
function removeRow(index, rowId, rowDelFlag){ function removeRow(index, rowId, rowDelFlag){
if(rowId){ if(rowId){
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -85,6 +85,11 @@ ...@@ -85,6 +85,11 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写明细!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
*/ */
function removeRow(index, rowId, rowDelFlag){ function removeRow(index, rowId, rowDelFlag){
if(rowId){ if(rowId){
var delFlag = rowDelFlag === 1 ? 0 : 1 var delFlag = rowDelFlag == 1 ? 0 : 1
updateRow(index, { updateRow(index, {
delFlag: delFlag delFlag: delFlag
}) })
......
...@@ -133,6 +133,11 @@ ...@@ -133,6 +133,11 @@
if(!isValidate){ if(!isValidate){
return false; return false;
}else{ }else{
var hasDetails = getTableData().length == 0;
if(hasDetails){
jp.warning('请填写明细!');
return;
}
jp.loading(); jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment