Commit 53e40cb9 by yyq1988

优化入库添加明细保存问题

parent 377576dc
...@@ -44,13 +44,7 @@ ...@@ -44,13 +44,7 @@
align: 'center', align: 'center',
width: 60, width: 60,
formatter: function (value, row, index){ formatter: function (value, row, index){
var tpl = $("#hideTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""); return '<span>'+(index+1)+'</span>'
var html = Mustache.render(tpl, {
idx: index,
row: row
})
return html + '<span>'+(index+1)+'</span>'
} }
}, },
{ {
...@@ -273,8 +267,10 @@ ...@@ -273,8 +267,10 @@
* 获取所有明细数据 * 获取所有明细数据
* @returns {*|jQuery} * @returns {*|jQuery}
*/ */
function getTableData(){ function getTableData(useCurrentPage){
return $(selector).bootstrapTable('getData'); return $(selector).bootstrapTable('getData',{
useCurrentPage: useCurrentPage
});
} }
/** /**
...@@ -284,28 +280,31 @@ ...@@ -284,28 +280,31 @@
jp.openShelvesSelectDialog(function (items){ jp.openShelvesSelectDialog(function (items){
setTimeout(function(){ setTimeout(function(){
var Shelve = items[0]; // 货架对象 var Shelve = items[0]; // 货架对象
updateTask(getSelections(), 10, function(index){ var realSelections = []; // 保存真实选中的数据
var allSelections = getSelections(); // 保存所有选中的数据(含分页)
var currentPageData = getTableData(true); // 保存当前分页数据
allSelections.forEach(function(item){
var finded = currentPageData.find(function(value){
return value.qrCode.id === item.qrCode.id
});
if(finded){
realSelections.push(item);
}
});
realSelections.forEach(function (item){
var index = getTableData().findIndex(function (current){
return current.qrCode.id === item.qrCode.id;
}); // 需更新的行的下标
updateRow(index,{ updateRow(index,{
shelves: { shelves: {
id: Shelve.id, id: Shelve.id,
name: Shelve.name name: Shelve.name
}, },
warehouse: Shelve.warehouse warehouse: Shelve.warehouse
}); })
}); })
},200) },200)
// getSelections().forEach(function (item){
// var index = getTableData().findIndex(function (current){
// return current.qrCode.id === item.qrCode.id;
// }); // 需更新的行的下标
// // updateRow(index,{
// // shelves: {
// // id: Shelve.id,
// // name: Shelve.name
// // },
// // warehouse: Shelve.warehouse
// // })
// })
}) })
} }
...@@ -384,49 +383,56 @@ ...@@ -384,49 +383,56 @@
</script> </script>
<script id="hideTpl" type="text/html"> <script id="hideTpl" type="text/html">
<input id="storageInfoList{{idx}}_id" name="storageInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/> <input name="storageInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
<input id="storageInfoList{{idx}}_delFlag" name="storageInfoList[{{idx}}].delFlag" type="hidden" value="{{row.delFlag}}"/> <input name="storageInfoList[{{idx}}].delFlag" type="hidden" value="{{row.delFlag}}"/>
<input id="storageInfoList{{idx}}_goodsInfoId" name="storageInfoList[{{idx}}].goodsInfo.id" type="hidden" value="{{row.goodsInfo.id}}"/> <input name="storageInfoList[{{idx}}].goodsInfo.id" type="hidden" value="{{row.goodsInfo.id}}"/>
<input id="storageInfoList{{idx}}_goodsInfoName" name="storageInfoList[{{idx}}].goodsInfo.name" type="hidden" value="{{row.goodsInfo.name}}"/> <input name="storageInfoList[{{idx}}].goodsInfo.name" type="hidden" value="{{row.goodsInfo.name}}"/>
<input id="storageInfoList{{idx}}_goodsInfoAmount" name="storageInfoList[{{idx}}].goodsInfo.amount" type="hidden" value="{{row.goodsInfo.amount}}"/> <input name="storageInfoList[{{idx}}].goodsInfo.amount" type="hidden" value="{{row.goodsInfo.amount}}"/>
<input id="storageInfoList{{idx}}_warehouseId" name="storageInfoList[{{idx}}].warehouse.id" type="hidden" value="{{row.warehouse.id}}" readonly class="form-control" /> <input name="storageInfoList[{{idx}}].warehouse.id" type="hidden" value="{{row.warehouse.id}}" readonly class="form-control" />
<input id="storageInfoList{{idx}}_amount" name="storageInfoList[{{idx}}].amount" type="hidden" value="{{row.amount}}" readonly class="form-control" /> <input name="storageInfoList[{{idx}}].warehouse.name" type="hidden" value="{{row.warehouse.name}}" readonly class="form-control" />
<input id="storageInfoList{{idx}}_qrCodeId" name="storageInfoList[{{idx}}].qrCode.id" type="hidden" value="{{row.qrCode.id}}" readonly class="form-control" /> <input name="storageInfoList[{{idx}}].amount" type="hidden" value="{{row.amount}}" readonly class="form-control" />
<input name="storageInfoList[{{idx}}].qrCode.id" type="hidden" value="{{row.qrCode.id}}" readonly class="form-control" />
<input name="storageInfoList[{{idx}}].name" type="hidden" readonly value="{{row.name}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].type.id" type="hidden" readonly value="{{row.type.id}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].type.name" type="hidden" readonly value="{{row.type.name}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].model" type="hidden" readonly value="{{row.model}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].shelves.id" type="hidden" readonly value="{{row.shelves.id}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].shelves.name" type="hidden" readonly value="{{row.shelves.name}}" class="form-control "/>
<input name="storageInfoList[{{idx}}].remarks" type="hidden" readonly value="{{row.remarks}}" class="form-control "/>
</script> </script>
<script id="nameTpl" type="text/html"> <script id="nameTpl" type="text/html">
<input id="storageInfoList{{idx}}_name" name="storageInfoList[{{idx}}].name" type="text" readonly value="{{row.name}}" onchange="onInputChange('{{idx}}', this, 'name')" class="form-control "/> <input type="text" readonly value="{{row.name}}" class="form-control "/>
</script> </script>
<script id="typeTpl" type="text/html">//<!-- <script id="typeTpl" type="text/html">//<!--
<sys:treeselect id="storageInfoList{{idx}}_type" name="storageInfoList[{{idx}}].type.id" value="{{row.type.id}}" labelName="storageInfoList{{idx}}.type.name" labelValue="{{row.type.name}}" <sys:treeselectNotNameProperty id="storageInfoList{{idx}}_type" name="storageInfoList[{{idx}}].type.id" value="{{row.type.id}}" labelName="storageInfoList{{idx}}.type.name" labelValue="{{row.type.name}}"
title="品名代码" url="/warehouse/materialtype/materialType/treeData" cssClass="form-control " disabled="disabled" allowClear="true" allowSearch="true" callback="onSelectType" />//--> title="品名代码" url="/warehouse/materialtype/materialType/treeData" cssClass="form-control " disabled="disabled" allowClear="true" allowSearch="true" callback="onSelectType" />//-->
</script> </script>
<script id="modelTpl" type="text/html"> <script id="modelTpl" type="text/html">
<input id="storageInfoList{{idx}}_model" name="storageInfoList[{{idx}}].model" type="text" value="{{row.model}}" readonly onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/> <input id="storageInfoList{{idx}}_model" type="text" value="{{row.model}}" readonly onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/>
</script> </script>
<script id="shelvesTpl" type="text/html">//<!-- <script id="shelvesTpl" type="text/html">//<!--
{{#row.readonly}} {{#row.readonly}}
<sys:shelvesselect id="storageInfoList{{idx}}_shelves" name="storageInfoList[{{idx}}].shelves.id" value="{{row.shelves.id}}" labelName="storageInfoList[{{idx}}].shelves.name" labelValue="{{row.shelves.name}}" <sys:shelvesselectNotName id="storageInfoList{{idx}}_shelves" name="storageInfoList[{{idx}}].shelves.id" value="{{row.shelves.id}}" labelName="storageInfoList[{{idx}}].shelves.name" labelValue="{{row.shelves.name}}"
cssClass="form-control required" iframeUrl="/warehouse/storage/storage/form" disabled="disabled"></sys:shelvesselect> cssClass="form-control required" iframeUrl="/warehouse/storage/storage/form" disabled="disabled"></sys:shelvesselectNotName>
{{/row.readonly}} {{/row.readonly}}
{{^row.readonly}} {{^row.readonly}}
<sys:shelvesselect id="storageInfoList{{idx}}_shelves" name="storageInfoList[{{idx}}].shelves.id" value="{{row.shelves.id}}" labelName="storageInfoList[{{idx}}].shelves.name" labelValue="{{row.shelves.name}}" <sys:shelvesselectNotName id="storageInfoList{{idx}}_shelves" name="storageInfoList[{{idx}}].shelves.id" value="{{row.shelves.id}}" labelName="storageInfoList[{{idx}}].shelves.name" labelValue="{{row.shelves.name}}"
cssClass="form-control required" iframeUrl="/warehouse/storage/storage/form" callback="onSelectShelves"></sys:shelvesselect>//--> cssClass="form-control required" iframeUrl="/warehouse/storage/storage/form" callback="onSelectShelves"></sys:shelvesselectNotName>//-->
{{/row.readonly}} {{/row.readonly}}
</script> </script>
<script id="remarksTpl" type="text/html"> <script id="remarksTpl" type="text/html">
{{#row.readonly}} {{#row.readonly}}
<textarea id="storageInfoList{{idx}}_remarks" name="storageInfoList[{{idx}}].remarks" rows="2" readonly class="form-control ">{{row.remarks}}</textarea> <textarea id="storageInfoList{{idx}}_remarks" rows="2" readonly class="form-control ">{{row.remarks}}</textarea>
{{/row.readonly}} {{/row.readonly}}
{{^row.readonly}} {{^row.readonly}}
<textarea id="storageInfoList{{idx}}_remarks" name="storageInfoList[{{idx}}].remarks" rows="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea> <textarea id="storageInfoList{{idx}}_remarks" rows="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
{{/row.readonly}} {{/row.readonly}}
</script> </script>
<script id="warehouseTpl" type="text/html"> <script id="warehouseTpl" type="text/html">
<input id="storageInfoList{{idx}}_warehouseName" name="storageInfoList[{{idx}}].warehouse.name" type="text" value="{{row.warehouse.name}}" readonly class="form-control "/> <input id="storageInfoList{{idx}}_warehouseName" type="text" value="{{row.warehouse.name}}" readonly class="form-control "/>
</script> </script>
<script id="scanResultTpl" type="text/html"> <script id="scanResultTpl" type="text/html">
<br> <br>
......
...@@ -138,7 +138,14 @@ ...@@ -138,7 +138,14 @@
jp.warning('请填写明细!'); jp.warning('请填写明细!');
return; return;
} }
/**处理明细隐藏input元素*/
jp.loading(); jp.loading();
getTableData().forEach(function(item,index){
$("#inputForm").append(Mustache.render($("#hideTpl").html(),{
row: item,
idx: index
}))
})
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){ jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){ if(data.success){
jp.getParent().refresh(); jp.getParent().refresh();
......
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