Commit c814b600 by yyq1988

对接入库单表单,优化货品表单

parent 0ed291ec
...@@ -176,6 +176,7 @@ function delRow(obj, prefix){ ...@@ -176,6 +176,7 @@ function delRow(obj, prefix){
// if(width.indexOf("%")>=0 || height.indexOf("%")>=0 ){ // if(width.indexOf("%")>=0 || height.indexOf("%")>=0 ){
// auto =false; // auto =false;
// } // }
// }
// top.layer.open({ // top.layer.open({
// type: 2, // type: 2,
// area: [width, height], // area: [width, height],
...@@ -325,10 +326,10 @@ function delRow(obj, prefix){ ...@@ -325,10 +326,10 @@ function delRow(obj, prefix){
}, },
openStorageSelectDialog:function(isMultiSelect, batchNum, yesFuc){ openStorageSelectDialog:function(isMultiSelect, batchNum, yesFuc){
var url = ctx+"/warehouse/storage/storage/findByPcTypeModel?goodsInfo.goods.batchNum="+batchNum; var url = ctx+"/warehouse/storage/storage/findByPcTypeModel?goodsInfo.goods.batchNum="+batchNum;
var fieldLabels = "名称|类型"; var fieldLabels = "物资编码|名称|类型|型号";
var fieldKeys = "name|type.name"; var fieldKeys = "qrCode.code|name|type.name|model";
var searchLabels = "型号|类型"; var searchLabels = "类型|型号";
var searchKeys = "goodsInfo.model|goodsInfo.type"; var searchKeys = "goodsInfo.type|goodsInfo.model";
top.layer.open({ top.layer.open({
type: 2, type: 2,
area: ['800px', '500px'], area: ['800px', '500px'],
...@@ -344,14 +345,7 @@ function delRow(obj, prefix){ ...@@ -344,14 +345,7 @@ function delRow(obj, prefix){
jp.warning("必须选择一条数据!"); jp.warning("必须选择一条数据!");
return; return;
} }
var ids = []; yesFuc(items);
var names = [];
for(var i=0; i<items.length; i++){
var item = items[i];
ids.push(item.id);
names.push(item.enname)
}
yesFuc(ids.join(","), names.join(","));
top.layer.close(index);//关闭对话框。 top.layer.close(index);//关闭对话框。
}, },
cancel: function(index){ cancel: function(index){
......
...@@ -74,6 +74,16 @@ ...@@ -74,6 +74,16 @@
} }
}, },
{ {
field: 'amount',
title: '单价',
formatter: function (value,row,index){
return Mustache.render($("#amountTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
},
{
field: 'remarks', field: 'remarks',
title: '备注', title: '备注',
formatter: function (value,row,index){ formatter: function (value,row,index){
...@@ -105,7 +115,8 @@ ...@@ -105,7 +115,8 @@
name: '' name: ''
}, },
model: '', model: '',
num: '', num: null,
amount: null,
remarks: '' remarks: ''
} }
...@@ -134,12 +145,50 @@ ...@@ -134,12 +145,50 @@
} }
function onInputChange(rowIndex, elem , field){ function onInputChange(rowIndex, elem , field){
var obj = {}; var obj = {};
obj[field] = $(elem).val() obj[field] = $(elem).val();
var timer = null; updateRow(rowIndex, obj);
clearTimeout(timer); // 校验数量与单价
timer = setTimeout(function (){ if(field === 'num' && obj[field]){
updateRow(rowIndex, obj)
}, 0) // 正则表达式验证可以带小数点的数字
var reg = new RegExp("^[0-9]+(.[0-9]{1,2})?$");
// 不是数字
if(!reg.test(obj[field])){
jp.warning("必须是数字");
$(elem).val('')
return
}
if (Number(obj[field]) <= 0) {
jp.warning("数量不能小于等于0");
$(elem).val('');
return;
}
setSumPrice();
}
if(field === 'amount' && obj[field]) {
// 正则表达式验证可以带小数点的数字
// 不是数字
if(!/^(?:[1-9]\d*|0)(?:\.\d{1,2})?$/.test(obj[field])) {
jp.warning("输入正确的金额");
$(elem).val('')
return
}
setSumPrice();
}
}
function setSumPrice(){
var data = $(selector).bootstrapTable('getData');
var sum = data.reduce(function (sum, current){
if(current.delFlag != 1 && current.amount && current.num){
var total = new Big(current.amount).times(current.num).toNumber();
return new Big(sum).plus(total);
}
return new Big(sum);
},0)
$("#sum").val(sum);
} }
function onSelectType(nodes, rowIndex){ function onSelectType(nodes, rowIndex){
...@@ -178,6 +227,10 @@ ...@@ -178,6 +227,10 @@
<input id="goodsInfoList{{idx}}_num" name="goodsInfoList[{{idx}}].num" type="text" value="{{row.num}}" onchange="onInputChange('{{idx}}', this, 'num')" class="form-control "/> <input id="goodsInfoList{{idx}}_num" name="goodsInfoList[{{idx}}].num" type="text" value="{{row.num}}" onchange="onInputChange('{{idx}}', this, 'num')" class="form-control "/>
</script> </script>
<script id="amountTpl" type="text/html">
<input id="goodsInfoList{{idx}}_amount" name="goodsInfoList[{{idx}}].amount" type="text" value="{{row.amount}}" onchange="onInputChange('{{idx}}', this, 'amount')" class="form-control "/>
</script>
<script id="remarksTpl" type="text/html"> <script id="remarksTpl" type="text/html">
<textarea id="goodsInfoList{{idx}}_remarks" name="goodsInfoList[{{idx}}].remarks" rows="4" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea> <textarea id="goodsInfoList{{idx}}_remarks" name="goodsInfoList[{{idx}}].remarks" rows="4" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
</script> </script>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<link rel="stylesheet" href="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.css"> <link rel="stylesheet" href="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.css">
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table.min.js"></script>
<script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script> <script type="text/javascript" src="${ctxStatic}/plugin/bootstrapTable/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="${ctxStatic}/common/js/big.js"></script>
</head> </head>
<body> <body>
<div class="wrapper wrapper-content"> <div class="wrapper wrapper-content">
...@@ -52,8 +53,14 @@ ...@@ -52,8 +53,14 @@
labelName="operator.name" labelValue="${goods.operator.name}" labelName="operator.name" labelValue="${goods.operator.name}"
cssClass="form-control required" disabled="disabled"/> cssClass="form-control required" disabled="disabled"/>
</td> </td>
<td>备注</td> <td>总价</td>
<td> <td>
<form:input path="sum" htmlEscape="false" readonly="true" class="form-control "/>
</td>
</tr>
<tr>
<td>备注</td>
<td colspan="3">
<form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control "/> <form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control "/>
</td> </td>
</tr> </tr>
......
...@@ -345,6 +345,7 @@ $(document).ready(function() { ...@@ -345,6 +345,7 @@ $(document).ready(function() {
<th>类型编码</th> <th>类型编码</th>
<th>型号</th> <th>型号</th>
<th>数量</th> <th>数量</th>
<th>单价</th>
<th>备注信息</th> <th>备注信息</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
...@@ -373,6 +374,9 @@ $(document).ready(function() { ...@@ -373,6 +374,9 @@ $(document).ready(function() {
{{row.num}} {{row.num}}
</td> </td>
<td> <td>
{{row.amount}}
</td>
<td>
{{row.remarks}} {{row.remarks}}
</td> </td>
<td> <td>
......
...@@ -85,32 +85,10 @@ $(document).ready(function() { ...@@ -85,32 +85,10 @@ $(document).ready(function() {
} }
,{ ,{
field: 'goodsInfo.id',
title: '货品明细外键',
sortable: true,
sortName: 'goodsInfo.id'
,formatter:function(value, row , index){
value = jp.unescapeHTML(value);
<c:choose>
<c:when test="${fns:hasPermission('warehouse:qrcode:qrCode:edit')}">
return "<a href='javascript:edit(\""+row.id+"\")'>"+value+"</a>";
</c:when>
<c:when test="${fns:hasPermission('warehouse:qrcode:qrCode:view')}">
return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
</c:when>
<c:otherwise>
return value;
</c:otherwise>
</c:choose>
}
}
,{
field: 'code', field: 'code',
title: '物资编码', title: '物资编码',
sortable: true, sortable: true,
sortName: 'code' sortName: 'code'
} }
,{ ,{
field: 'url', field: 'url',
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/webpage/include/taglib.jsp" %> <%@ include file="/webpage/include/taglib.jsp" %>
<div id="toolbar" class="text-left"> <div id="toolbar" class="text-left">
<a class="btn btn-primary btn-sm" onclick="addDetail('#detail_table')" title="新增"><i class="fa fa-plus"></i> 新增</a> <a class="btn btn-primary btn-sm" onclick="addDetail('#detail_table')" title="新增"><i class="fa fa-plus"></i> 手动添加</a>
<a class="btn btn-primary btn-sm" disabled="true" onclick="addShelve('#detail_table')" title="新增"><i class="fa fa-plus"></i> 批量编辑货架</a> <a class="btn btn-primary btn-sm" onclick="addScan('#detail_table')" title="新增"><i class="fa fa-plus"></i> 扫码添加</a>
<a id="editAll" class="btn btn-primary btn-sm" onclick="addShelve('#detail_table')" title="新增"><i class="fa fa-plus"></i> 批量编辑货架</a>
</div> </div>
<table id="detail_table" data-toolbar="#toolbar"></table> <table id="detail_table" data-toolbar="#toolbar"></table>
<script> <script>
...@@ -94,7 +95,11 @@ ...@@ -94,7 +95,11 @@
} }
} }
] ]
}) });
$(selector).on('check.bs.table uncheck.bs.table load-success.bs.table ' +
'check-all.bs.table uncheck-all.bs.table', function () {
$('#editAll').prop('disabled', !getSelections().length);
});
} }
function getSelections(){ function getSelections(){
...@@ -108,26 +113,25 @@ ...@@ -108,26 +113,25 @@
return; return;
} }
jp.openStorageSelectDialog(true,$("#batchNum").val(),function (){ jp.openStorageSelectDialog(true,$("#batchNum").val(),function (items){
if(Array.isArray(items)){
var data = items.map(function (item){
if(item.goodsInfo && !item.goodsInfo.amount){
item.goodsInfo.amount = 0;
}
return {
id: '',
delFlag: 0,
remarks: '',
...item
}
})
debugger
$(selector).bootstrapTable('append', data)
}
}) })
// var row = {
// id: '',
// delFlag: 0,
// name: '',
// type: {
// id: '',
// name: ''
// },
// model: '',
// num: '',
// remarks: ''
// }
//
// $(selector).bootstrapTable('append', [
// row
// ])
} }
function removeRow(index, rowId, rowDelFlag){ function removeRow(index, rowId, rowDelFlag){
if(rowId){ if(rowId){
...@@ -172,10 +176,51 @@ ...@@ -172,10 +176,51 @@
} }
function addShelve(){ function addShelve(){
jp.openShelvesSelectDialog(function (){ jp.openShelvesSelectDialog(function (id,name){
getSelections().forEach(function (item,index){
updateRow(index,{
shelves: {
id: id,
name: name
}
})
})
})
}
function addScan(){
layer.open({
type: 1,
title: '扫码',
auto: true,
area: ['500','300'],
content: $("#scanResultTpl").html(),
success: function (){
$("#scanResult").focus();
},
btn:['关闭']
}) })
} }
/**
* 扫码
* 一、获取扫码结果
* 二、请求后台接口获取结果
* 三、增一条明细数据
* 四、清空扫码结果
* @param elem
*/
function onScanChange(elem){
try{
var json = JSON.parse($(elem).val());
var qrCodeId = json.code;
var goodsInfoId = json.infoId;
}catch (e){
console.log(e);
}
}
</script> </script>
<script id="hideTpl" type="text/html"> <script id="hideTpl" type="text/html">
...@@ -183,25 +228,44 @@ ...@@ -183,25 +228,44 @@
<input id="storageInfoList{{idx}}_delFlag" name="storageInfoList[{{idx}}].delFlag" type="hidden" value="{{row.delFlag}}"/> <input id="storageInfoList{{idx}}_delFlag" 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 id="storageInfoList{{idx}}_goodsInfoId" 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 id="storageInfoList{{idx}}_goodsInfoName" 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 id="storageInfoList{{idx}}_shelvesId" name="storageInfoList[{{idx}}].shelves.id" type="hidden" value="{{row.shelves.id}}" readonly class="form-control" /> <input id="storageInfoList{{idx}}_shelvesId" name="storageInfoList[{{idx}}].shelves.id" type="hidden" value="{{row.shelves.id}}" readonly class="form-control" />
<input id="storageInfoList{{idx}}_amount" name="storageInfoList[{{idx}}].amount" type="hidden" value="{{row.amount}}" readonly class="form-control" />
<input id="storageInfoList{{idx}}_qrCodeId" name="storageInfoList[{{idx}}].qrCode.id" type="hidden" value="{{row.qrCode.id}}" readonly 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" value="{{row.name}}" onchange="onInputChange('{{idx}}', this, 'name')" class="form-control "/> <input id="storageInfoList{{idx}}_name" name="storageInfoList[{{idx}}].name" type="text" readonly value="{{row.name}}" onchange="onInputChange('{{idx}}', this, '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:treeselect 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 " 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}}" onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/> <input id="storageInfoList{{idx}}_model" name="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">
<input id="storageInfoList{{idx}}_shelvesName" name="storageInfoList[{{idx}}].shelves.name" type="text" value="{{row.shelves.name}}" readonly class="form-control" /> <input id="storageInfoList{{idx}}_shelvesName" name="storageInfoList[{{idx}}].shelves.name" type="text" value="{{row.shelves.name}}" readonly class="form-control" />
</script> </script>
<script id="remarksTpl" type="text/html"> <script id="remarksTpl" type="text/html">
<textarea id="storageInfoList{{idx}}_remarks" name="storageInfoList[{{idx}}].remarks" rows="4" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea> <textarea id="storageInfoList{{idx}}_remarks" name="storageInfoList[{{idx}}].remarks" rows="4" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
</script>
<script id="scanResultTpl" type="text/html">
<br>
<div class="container-fluid">
<div class="row">
<div class="col-xs-2 text-right">
<label>扫码结果:</label>
</div>
<div class="col-xs-10">
<input type="text" id="scanResult" class="form-control" onchange="onScanChange(this)">
<span class="text-danger">请切换英文输入法</span>
</div>
</div>
</div>
<br>
</script> </script>
\ No newline at end of file
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