Commit a23cda3d by anxiaohe

货品模块表单修改

parent 7f52a8a4
......@@ -21,6 +21,7 @@
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%>
<%@ attribute name="dataMsgRequired" 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}"/>
<div class="input-group" style="width:100%">
<input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}"
......@@ -81,7 +82,7 @@ $(document).ready(function(){
$("#${id}Name").focus();
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);
......@@ -98,11 +99,14 @@ $(document).ready(function(){
if ($("#${id}Button").hasClass("disabled")){
return true;
}
var id = $("#${id}Id").val();
// 清除
$("#${id}Id").val("");
$("#${id}Name").val("");
$("#${id}Name").focus();
if(typeof '${delCallback}' !== 'undefined' && window['${delCallback}']){
window['${delCallback}']("${id}", id);
}
});
})
</script>
......@@ -12,6 +12,8 @@
</div>
<table id="detail_table" data-toolbar="#toolbar"></table>
<script>
console.log(${fns:toJson(goods)})
var selector = "#detail_table";
function initTable(){
var data = ${fns:toJson(goods.goodsInfoList)};
......@@ -40,21 +42,31 @@
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',
title: '名称',
field: 'type.name',
title: '品名',
formatter: function (value,row,index){
return Mustache.render($("#nameTpl").html(),{
return Mustache.render($("#typeNameTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
},
{
field: 'type.name',
title: '品名代码',
field: 'type.code',
title: '代码',
formatter: function (value,row,index){
return Mustache.render($("#typeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
return Mustache.render($("#typeCodeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
......@@ -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',
title: '备注',
formatter: function (value,row,index){
......@@ -104,6 +136,9 @@
field: '',
title: '操作',
formatter: function (value,row,index){
if (row.qrCode && row.qrCode.state !== '0') {
return '';
}
var text = row.delFlag == 1 ? '撤销删除' : '删除';
var result = ["<a href='javascript:void(0);' onclick=\"removeRow(" + index + ", '" + row.id + "', '" + row.delFlag + "')\">"+text+"</a>" ]
return result.join('');
......@@ -161,7 +196,7 @@
function onInputChange(rowIndex, elem , field){
var obj = {};
obj[field] = $(elem).val();
updateRow(rowIndex, obj);
// 校验数量与单价
if(field === 'num' && obj[field]){
......@@ -179,7 +214,10 @@
$(elem).val('');
return;
}
setSumPrice();
if ($("#goodsInfoList" + rowIndex + "_amount").val()) {
obj.infoSum = new Big($("#goodsInfoList" + rowIndex + "_amount").val()).times(obj[field]).toNumber();
}
}
if(field === 'amount' && obj[field]) {
......@@ -190,6 +228,15 @@
$(elem).val('')
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();
}
}
......@@ -212,12 +259,44 @@
var obj = {
type: {
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)
}
}
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 id="hideTpl" type="text/html">
......@@ -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"/>
</script>
<script id="typeTpl" 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}}"
title="品名代码" url="/warehouse/materialtype/materialType/treeData" notAllowSelectParent="true" cssClass="form-control required" allowClear="true" allowSearch="true" callback="onSelectType" />//-->
<script id="typeNameTpl" type="text/html">//<!--
<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" 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 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"/>
</script>
......@@ -243,9 +324,14 @@
</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 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 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>
</script>
......@@ -280,7 +280,10 @@ $(document).ready(function() {
function addRow(list, idx, tpl, row){
$(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() {
<table class="ani table">
<thead>
<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>
</tr>
......@@ -358,9 +362,6 @@ $(document).ready(function() {
<script type="text/template" id="goodsChild1Tpl">//<!--
<tr>
<td>
{{row.name}}
</td>
<td>
{{row.type.name}}
</td>
<td>
......@@ -376,15 +377,23 @@ $(document).ready(function() {
{{row.amount}}
</td>
<td>
{{row.unit}}
</td>
<td>
{{row.infoSum}}
</td>
<td>
{{row.remarks}}
</td>
<td>
{{#showAction}}
<button class="btn btn-primary btn-sm" onclick="printQr('{{row.id}}')">
打印二维码
</button>
<button class="btn btn-danger btn-sm" onclick="cleanQr('{{row.id}}')">
清除二维码
</button>
{{/showAction}}
</td>
</tr>//-->
</script>
......@@ -16,6 +16,7 @@
action="${ctx}/warehouse/materialtype/materialType/save" method="post"
class="form-horizontal">
<form:hidden path="id"/>
<form:hidden path="parentIds" />
<h3 class="text-center">物资品名代码表</h3>
<table class="table table-bordered main-table">
<tr>
......@@ -42,7 +43,17 @@
labelName="parent.name" labelValue="${materialType.parent.name}"
title="父级编号" url="/warehouse/materialtype/materialType/treeData"
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>
</tr>
<tr>
......@@ -59,6 +70,9 @@
</div>
</div>
<script>
var info = ${fns:toJson(materialType)};
console.log(info)
function save() {
var isValidate = jp.validateForm('#inputForm');//校验表单
if(!isValidate){
......@@ -77,7 +91,18 @@
}
})
}
}
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>
</body>
......
......@@ -91,6 +91,12 @@
{{d.row.code === undefined ? "": d.row.code}}
</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}}
</td>
<td>
......
......@@ -33,6 +33,8 @@
<tr>
<th>名称</th>
<th>物资品名代码编码</th>
<th>单价</th>
<th>单位</th>
<th>备注信息</th>
<th>操作</th>
</tr>
......
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