Commit a23cda3d by anxiaohe

货品模块表单修改

parent 7f52a8a4
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%> <%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%>
<%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%> <%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%>
<%@ attribute name="callback" type="java.lang.String" required="false" description="回调"%> <%@ attribute name="callback" type="java.lang.String" required="false" description="回调"%>
<%@ attribute name="delCallback" type="java.lang.String" required="false" description="删除回调"%>
<input id="${id}Id" name="${name}" class="${cssClass} form-control" type="hidden" value="${value}"/> <input id="${id}Id" name="${name}" class="${cssClass} form-control" type="hidden" value="${value}"/>
<div class="input-group" style="width:100%"> <div class="input-group" style="width:100%">
<input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}" <input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}"
...@@ -81,7 +82,7 @@ $(document).ready(function(){ ...@@ -81,7 +82,7 @@ $(document).ready(function(){
$("#${id}Name").focus(); $("#${id}Name").focus();
if(typeof '${callback}' !== 'undefined' && window['${callback}']){ if(typeof '${callback}' !== 'undefined' && window['${callback}']){
window['${callback}'](nodes, '${id}'.match(/\d+/g)[0]); window['${callback}'](nodes, '${id}'.match(/\d+/g) ? '${id}'.match(/\d+/g)[0] : '${id}');
} }
top.layer.close(index); top.layer.close(index);
...@@ -98,11 +99,14 @@ $(document).ready(function(){ ...@@ -98,11 +99,14 @@ $(document).ready(function(){
if ($("#${id}Button").hasClass("disabled")){ if ($("#${id}Button").hasClass("disabled")){
return true; return true;
} }
var id = $("#${id}Id").val();
// 清除 // 清除
$("#${id}Id").val(""); $("#${id}Id").val("");
$("#${id}Name").val(""); $("#${id}Name").val("");
$("#${id}Name").focus(); $("#${id}Name").focus();
if(typeof '${delCallback}' !== 'undefined' && window['${delCallback}']){
window['${delCallback}']("${id}", id);
}
}); });
}) })
</script> </script>
\ No newline at end of file
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
</div> </div>
<table id="detail_table" data-toolbar="#toolbar"></table> <table id="detail_table" data-toolbar="#toolbar"></table>
<script> <script>
console.log(${fns:toJson(goods)})
var selector = "#detail_table"; var selector = "#detail_table";
function initTable(){ function initTable(){
var data = ${fns:toJson(goods.goodsInfoList)}; var data = ${fns:toJson(goods.goodsInfoList)};
...@@ -40,21 +42,31 @@ ...@@ -40,21 +42,31 @@
return html + '<span>'+(index+1)+'</span>' return html + '<span>'+(index+1)+'</span>'
} }
}, },
// {
// field: 'type.name',
// title: '品名',
// formatter: function (value,row,index){
// return Mustache.render($("#nameTpl").html(),{
// row: row,
// idx: index
// })
// }
// },
{ {
field: 'name', field: 'type.name',
title: '名称', title: '品名',
formatter: function (value,row,index){ formatter: function (value,row,index){
return Mustache.render($("#nameTpl").html(),{ return Mustache.render($("#typeNameTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row, row: row,
idx: index idx: index
}) })
} }
}, },
{ {
field: 'type.name', field: 'type.code',
title: '品名代码', title: '代码',
formatter: function (value,row,index){ formatter: function (value,row,index){
return Mustache.render($("#typeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{ return Mustache.render($("#typeCodeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row, row: row,
idx: index idx: index
}) })
...@@ -91,6 +103,26 @@ ...@@ -91,6 +103,26 @@
} }
}, },
{ {
field: 'unit',
title: '单位',
formatter: function (value,row,index){
return Mustache.render($("#unitTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
},
{
field: 'infoSum',
title: '总价',
formatter: function (value,row,index){
return Mustache.render($("#infoSumTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
},
{
field: 'remarks', field: 'remarks',
title: '备注', title: '备注',
formatter: function (value,row,index){ formatter: function (value,row,index){
...@@ -104,6 +136,9 @@ ...@@ -104,6 +136,9 @@
field: '', field: '',
title: '操作', title: '操作',
formatter: function (value,row,index){ formatter: function (value,row,index){
if (row.qrCode && row.qrCode.state !== '0') {
return '';
}
var text = row.delFlag == 1 ? '撤销删除' : '删除'; 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('');
...@@ -161,7 +196,7 @@ ...@@ -161,7 +196,7 @@
function onInputChange(rowIndex, elem , field){ function onInputChange(rowIndex, elem , field){
var obj = {}; var obj = {};
obj[field] = $(elem).val(); obj[field] = $(elem).val();
updateRow(rowIndex, obj);
// 校验数量与单价 // 校验数量与单价
if(field === 'num' && obj[field]){ if(field === 'num' && obj[field]){
...@@ -179,7 +214,10 @@ ...@@ -179,7 +214,10 @@
$(elem).val(''); $(elem).val('');
return; return;
} }
setSumPrice();
if ($("#goodsInfoList" + rowIndex + "_amount").val()) {
obj.infoSum = new Big($("#goodsInfoList" + rowIndex + "_amount").val()).times(obj[field]).toNumber();
}
} }
if(field === 'amount' && obj[field]) { if(field === 'amount' && obj[field]) {
...@@ -190,6 +228,15 @@ ...@@ -190,6 +228,15 @@
$(elem).val('') $(elem).val('')
return return
} }
if ($("#goodsInfoList" + rowIndex + "_num").val()) {
obj.infoSum = new Big($("#goodsInfoList" + rowIndex + "_num").val()).times(obj[field]).toNumber();
}
}
updateRow(rowIndex, obj);
if((field === 'num' && obj[field]) || (field === 'amount' && obj[field])) {
setSumPrice(); setSumPrice();
} }
} }
...@@ -212,12 +259,44 @@ ...@@ -212,12 +259,44 @@
var obj = { var obj = {
type: { type: {
id: node.id, id: node.id,
name: node.text name: node.text,
} code: node.original.code
},
amount: node.original.amount,
unit: node.original.unit
}; };
if ($("#goodsInfoList" + rowIndex + "_num").val()) {
obj.infoSum = new Big($("#goodsInfoList" + rowIndex + "_num").val()).times(obj.amount).toNumber();
}
updateRow(rowIndex, obj) updateRow(rowIndex, obj)
} }
} }
function delType (idName, id) {
var name = $("#" + idName + 'Id').attr('name');
var str1 = name.split('.')[0];
var startNum = str1.indexOf('[') + 1;
var str2 = str1.substring(startNum);
var endNum = str2.length - 1;
var num = str2.substring(0, endNum);
var key = "#goodsInfoList" + num;
$(key + "_typeCode").val('');
$(key + "_amount").val('');
$(key + "_unit").val('');
$(key + "_infoSum").val('');
var obj = {
type: {
id: '',
name: '',
code: ''
},
amount: '',
unit: '',
infoSum: ''
};
updateRow(num, obj);
setSumPrice();
}
</script> </script>
<script id="hideTpl" type="text/html"> <script id="hideTpl" type="text/html">
...@@ -229,11 +308,13 @@ ...@@ -229,11 +308,13 @@
<input id="goodsInfoList{{idx}}_name" name="goodsInfoList[{{idx}}].name" type="text" value="{{row.name}}" onchange="onInputChange('{{idx}}', this, 'name')" class="form-control required"/> <input id="goodsInfoList{{idx}}_name" name="goodsInfoList[{{idx}}].name" type="text" value="{{row.name}}" onchange="onInputChange('{{idx}}', this, 'name')" class="form-control required"/>
</script> </script>
<script id="typeTpl" type="text/html">//<!-- <script id="typeNameTpl" type="text/html">//<!--
<sys:treeselect id="goodsInfoList{{idx}}_type" name="goodsInfoList[{{idx}}].type.id" value="{{row.type.id}}" labelName="goodsInfoList{{idx}}.type.code" labelValue="{{row.type.name}}" <sys:treeselect id="goodsInfoList{{idx}}_typeName" name="goodsInfoList[{{idx}}].type.id" value="{{row.type.id}}" labelName="goodsInfoList[{{idx}}].type.name" labelValue="{{row.type.name}}"
title="品名代码" url="/warehouse/materialtype/materialType/treeData" notAllowSelectParent="true" cssClass="form-control required" allowClear="true" allowSearch="true" callback="onSelectType" />//--> title="品名代码" url="/warehouse/materialtype/materialType/treeData" notAllowSelectParent="true" cssClass="form-control required" allowClear="true" allowSearch="true" callback="onSelectType" delCallback="delType" />//-->
</script>
<script id="typeCodeTpl" type="text/html">
<input id="goodsInfoList{{idx}}_typeCode" name="goodsInfoList[{{idx}}].type.code" type="text" value="{{row.type.code}}" readonly class="form-control required"/>
</script> </script>
<script id="modelTpl" type="text/html"> <script id="modelTpl" type="text/html">
<input id="goodsInfoList{{idx}}_model" name="goodsInfoList[{{idx}}].model" type="text" value="{{row.model}}" onchange="onInputChange('{{idx}}', this, 'model')" class="form-control required"/> <input id="goodsInfoList{{idx}}_model" name="goodsInfoList[{{idx}}].model" type="text" value="{{row.model}}" onchange="onInputChange('{{idx}}', this, 'model')" class="form-control required"/>
</script> </script>
...@@ -243,9 +324,14 @@ ...@@ -243,9 +324,14 @@
</script> </script>
<script id="amountTpl" type="text/html"> <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 required"/> <input id="goodsInfoList{{idx}}_amount" name="goodsInfoList[{{idx}}].amount" type="text" value="{{row.amount}}" readonly onchange="onInputChange('{{idx}}', this, 'amount')" class="form-control required"/>
</script>
<script id="unitTpl" type="text/html">
<input id="goodsInfoList{{idx}}_unit" name="goodsInfoList[{{idx}}].unit" type="text" value="{{row.unit}}" readonly onchange="onInputChange('{{idx}}', this, 'unit')" class="form-control required"/>
</script>
<script id="infoSumTpl" type="text/html">
<input id="goodsInfoList{{idx}}_infoSum" name="goodsInfoList[{{idx}}].infoSum" type="text" value="{{row.infoSum}}" readonly onchange="onInputChange('{{idx}}', this, 'infoSum')" class="form-control required"/>
</script> </script>
<script id="remarksTpl" type="text/html"> <script id="remarksTpl" type="text/html">
<textarea id="goodsInfoList{{idx}}_remarks" name="goodsInfoList[{{idx}}].remarks" rows="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea> <textarea id="goodsInfoList{{idx}}_remarks" name="goodsInfoList[{{idx}}].remarks" rows="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
</script> </script>
\ No newline at end of file
...@@ -280,7 +280,10 @@ $(document).ready(function() { ...@@ -280,7 +280,10 @@ $(document).ready(function() {
function addRow(list, idx, tpl, row){ function addRow(list, idx, tpl, row){
$(list).append(Mustache.render(tpl, { $(list).append(Mustache.render(tpl, {
idx: idx, delBtn: true, row: row idx: idx, delBtn: true, row: row,
showAction: function () {
return row.qrCode ? !(row.qrCode.state !== '0') : true;
}
})); }));
} }
...@@ -339,12 +342,13 @@ $(document).ready(function() { ...@@ -339,12 +342,13 @@ $(document).ready(function() {
<table class="ani table"> <table class="ani table">
<thead> <thead>
<tr> <tr>
<th>名称</th> <th>品名</th>
<th>品名代码</th> <th>代码</th>
<th>类型编码</th>
<th>型号</th> <th>型号</th>
<th>数量</th> <th>数量</th>
<th>单价</th> <th>单价</th>
<th>单位</th>
<th>总价</th>
<th>备注信息</th> <th>备注信息</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
...@@ -358,9 +362,6 @@ $(document).ready(function() { ...@@ -358,9 +362,6 @@ $(document).ready(function() {
<script type="text/template" id="goodsChild1Tpl">//<!-- <script type="text/template" id="goodsChild1Tpl">//<!--
<tr> <tr>
<td> <td>
{{row.name}}
</td>
<td>
{{row.type.name}} {{row.type.name}}
</td> </td>
<td> <td>
...@@ -376,15 +377,23 @@ $(document).ready(function() { ...@@ -376,15 +377,23 @@ $(document).ready(function() {
{{row.amount}} {{row.amount}}
</td> </td>
<td> <td>
{{row.unit}}
</td>
<td>
{{row.infoSum}}
</td>
<td>
{{row.remarks}} {{row.remarks}}
</td> </td>
<td> <td>
{{#showAction}}
<button class="btn btn-primary btn-sm" onclick="printQr('{{row.id}}')"> <button class="btn btn-primary btn-sm" onclick="printQr('{{row.id}}')">
打印二维码 打印二维码
</button> </button>
<button class="btn btn-danger btn-sm" onclick="cleanQr('{{row.id}}')"> <button class="btn btn-danger btn-sm" onclick="cleanQr('{{row.id}}')">
清除二维码 清除二维码
</button> </button>
{{/showAction}}
</td> </td>
</tr>//--> </tr>//-->
</script> </script>
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
action="${ctx}/warehouse/materialtype/materialType/save" method="post" action="${ctx}/warehouse/materialtype/materialType/save" method="post"
class="form-horizontal"> class="form-horizontal">
<form:hidden path="id"/> <form:hidden path="id"/>
<form:hidden path="parentIds" />
<h3 class="text-center">物资品名代码表</h3> <h3 class="text-center">物资品名代码表</h3>
<table class="table table-bordered main-table"> <table class="table table-bordered main-table">
<tr> <tr>
...@@ -42,7 +43,17 @@ ...@@ -42,7 +43,17 @@
labelName="parent.name" labelValue="${materialType.parent.name}" labelName="parent.name" labelValue="${materialType.parent.name}"
title="父级编号" url="/warehouse/materialtype/materialType/treeData" title="父级编号" url="/warehouse/materialtype/materialType/treeData"
extId="${materialType.id}" cssClass="form-control required" extId="${materialType.id}" cssClass="form-control required"
allowClear="true"/> allowClear="true" callback="selectParent"/>
</td>
</tr>
<tr class="other-content">
<td><font color="red">*</font>单价</td>
<td>
<form:input path="amount" type="number" htmlEscape="false" class="form-control required isIntGteZero"/>
</td>
<td><font color="red">*</font>单位</td>
<td>
<form:input path="unit" htmlEscape="false" class="form-control required"/>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -59,6 +70,9 @@ ...@@ -59,6 +70,9 @@
</div> </div>
</div> </div>
<script> <script>
var info = ${fns:toJson(materialType)};
console.log(info)
function save() { function save() {
var isValidate = jp.validateForm('#inputForm');//校验表单 var isValidate = jp.validateForm('#inputForm');//校验表单
if(!isValidate){ if(!isValidate){
...@@ -77,8 +91,19 @@ ...@@ -77,8 +91,19 @@
} }
}) })
} }
}
otherContentShow(info.last === 1);
function selectParent (row, id) {
var item = row[0];
otherContentShow(item.parents.length >= 2);
$("#parentIds").val(item.parents.reverse().slice(1).join(',') + ',' + item.id + ',');
}
function otherContentShow (v) {
v ? $(".other-content").show() : $(".other-content").hide();
} }
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -91,6 +91,12 @@ ...@@ -91,6 +91,12 @@
{{d.row.code === undefined ? "": d.row.code}} {{d.row.code === undefined ? "": d.row.code}}
</td> </td>
<td> <td>
{{d.row.amount === undefined ? "": d.row.amount}}
</td>
<td>
{{d.row.unit === undefined ? "": d.row.unit}}
</td>
<td>
{{d.row.remarks === undefined ? "": d.row.remarks}} {{d.row.remarks === undefined ? "": d.row.remarks}}
</td> </td>
<td> <td>
...@@ -115,4 +121,4 @@ ...@@ -115,4 +121,4 @@
</ul> </ul>
</div> </div>
</td> </td>
</script> </script>
\ No newline at end of file
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
<tr> <tr>
<th>名称</th> <th>名称</th>
<th>物资品名代码编码</th> <th>物资品名代码编码</th>
<th>单价</th>
<th>单位</th>
<th>备注信息</th> <th>备注信息</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
...@@ -44,4 +46,4 @@ ...@@ -44,4 +46,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>
\ 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