Commit 4e1e4465 by yyq1988

对接物资领用

parent 6b384f95
......@@ -13,6 +13,9 @@
<%@ attribute name="url" type="java.lang.String" required="true" description="数据地址"%>
<%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="isMultiSelected" type="java.lang.Boolean" required="false" description="是否允许多选"%>
<%@ attribute name="validate" type="java.lang.Boolean" required="false" description="是否选择前校验"%>
<%@ attribute name="validateSelector" type="java.lang.String" required="false" description="校验的选择器"%>
<%@ attribute name="validateMsg" type="java.lang.String" required="false" description="校验的未通过提示信息"%>
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择,如果限制,设置为disabled"%>
<%@ attribute name="callback" type="java.lang.String" required="false" description="选择回调"%>
<input id="${id}Id" name="${name}" type="hidden" value="${value}"/>
......@@ -34,6 +37,12 @@ $(document).ready(function(){
return true;
}
if('${validate}' && '${validateSelector}'){
if(!$("${validateSelector}").val()){
jp.warning('${validateMsg}');
return;
}
}
top.layer.open({
type: 2,
area: ['800px', '500px'],
......
......@@ -350,6 +350,29 @@ function delRow(obj, prefix){
}
});
},
openGridSelectDialog:function(params, yesFuc){
top.layer.open({
type: 2,
area: ['800px', '500px'],
title: params.title,
auto:true,
name:'friend',
content: ctx+"/tag/gridselect?url="+encodeURIComponent(params.url)+"&fieldLabels="+encodeURIComponent(params.fieldLabels)+"&fieldKeys="+encodeURIComponent(params.fieldKeys)+"&searchLabels="+encodeURIComponent(params.searchLabels)+"&searchKeys="+encodeURIComponent(params.searchKeys)+"&isMultiSelected="+params.isMultiSelect,
btn: ['确定', '关闭'],
yes: function(index, layero){
var iframeWin = layero.find('iframe')[0].contentWindow; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
var items = iframeWin.getSelections();
if(items == ""){
jp.warning("必须选择一条数据!");
return;
}
yesFuc(items);
top.layer.close(index);//关闭对话框。
},
cancel: function(index){
}
});
},
dateFormat:function (timestamp, format) {
var _this = new Date(timestamp);
var o = {
......
......@@ -232,5 +232,5 @@
</script>
<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="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
</script>
\ No newline at end of file
......@@ -10,134 +10,126 @@
<table id="detail_table"></table>
<script>
var selector = "#detail_table";
function initTable(){
var data = ${fns:toJson(ledger.ledgerInfoList)};
function initTable() {
var data = [];
$(selector).bootstrapTable({
data: data,
columns:[
columns: [
{
field: 'no',
title: '序号',
align: 'center',
width: 60,
formatter: function (value, row, index){
var tpl = $("#hideTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, "");
var html = Mustache.render(tpl, {
idx: index,
row: row
})
return html + '<span>'+(index+1)+'</span>'
}
},
{
field: 'name',
title: '名称',
formatter: function (value,row,index){
return Mustache.render($("#nameTpl").html(),{
row: row,
idx: index
})
formatter: function (value, row, index) {
return '<span>' + (index + 1) + '</span>'
}
},
{
field: 'type.name',
title: '类型',
formatter: function (value,row,index){
return Mustache.render($("#typeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
align: 'center'
},
{
field: 'model',
title: '型号',
formatter: function (value,row,index){
return Mustache.render($("#modelTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
align: 'center'
},
{
field: 'batchNum',
title: '批次号',
formatter: function (value,row,index){
return Mustache.render($("#batchNumTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
align: 'center'
},
{
field: 'shelves.name',
field: 'shelvesNames',
title: '货架',
formatter: function (value,row,index){
return Mustache.render($("#shelvesTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
align: 'center'
},
{
field: 'code',
title: '物资编码',
formatter: function (value,row,index){
return Mustache.render($("#codeTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, ""),{
row: row,
idx: index
})
}
field: 'warehouseNames',
title: '仓库',
align: 'center'
},
{
field: '',
title: '操作',
formatter: function (value,row,index){
var text = row.delFlag == 1 ? '撤销删除' : '删除';
var result = ["<a href='javascript:void(0);' onclick=\"removeRow(" + index + ", '" + row.id + "', '" + row.delFlag + "')\">"+text+"</a>" ]
return result.join('');
align: 'center',
formatter: function (){
return '<a class="view-detail">查看明细</a>'
},
events: {
'click .view-detail': function (e,value,row){
layer.open({
title: '查看明细',
type: 1,
auto: true,
area: ['800', '600'],
content: $("#detailTpl").html(),
success: function (){
$("#table").bootstrapTable({
method: 'get',
url: '${ctx}/warehouse/ledger/ledger/infoDate?batchNum='+ row.batchNum+'&ledger.id=${ledger.id}',
page: true,
columns: [
{field: 'name', title: '物资名称'},
{field: 'type.name', title: '类型'},
{field: 'model', title: '型号'},
{field: 'batchNum', title: '批次号'},
{field: 'shelves.name', title: '货架'},
{field: 'code', title: '物资编码'},
{field: 'amount', title: '单价'},
]
})
},
})
}
}
}
]
});
jp.get("${ctx}/warehouse/ledger/ledger/countLedger?id=${ledger.id}", function (ledger) {
var data = ledger.countLedgerInfoList || [];
$(selector).bootstrapTable('append', data);
})
}
function getSelections(){
function getSelections() {
return $(selector).bootstrapTable('getSelections');
}
function removeRow(index, rowId, rowDelFlag){
if(rowId){
function removeRow(index, rowId, rowDelFlag) {
if (rowId) {
var delFlag = rowDelFlag === 1 ? 0 : 1
updateRow(index, {
delFlag: delFlag
})
}else{
} else {
$(selector).bootstrapTable("remove", {
field: '$index',
values: [index]
})
}
}
function updateRow(index, row){
function updateRow(index, row) {
$(selector).bootstrapTable('updateRow', {
index: index,
row: row
})
}
function onInputChange(rowIndex, elem , field){
function onInputChange(rowIndex, elem, field) {
var obj = {};
obj[field] = $(elem).val()
var timer = null;
clearTimeout(timer);
timer = setTimeout(function (){
timer = setTimeout(function () {
updateRow(rowIndex, obj)
}, 0)
}
function onSelectType(nodes, rowIndex){
if(Array.isArray(nodes) && nodes.length === 1){
function onSelectType(nodes, rowIndex) {
if (Array.isArray(nodes) && nodes.length === 1) {
var node = nodes[0];
var obj = {
type: {
......@@ -153,40 +145,14 @@
* 获取所有明细数据
* @returns {*|jQuery}
*/
function getTableData(){
function getTableData() {
return $(selector).bootstrapTable('getData');
}
</script>
<script id="hideTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_id" name="ledgerInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
<input id="ledgerInfoList{{idx}}_delFlag" name="ledgerInfoList[{{idx}}].delFlag" type="hidden" value="{{row.delFlag}}"/>
<input id="ledgerInfoList{{idx}}_goodsInfoId" name="ledgerInfoList[{{idx}}].goodsInfo.id" type="hidden" value="{{row.goodsInfo.id}}"/>
<input id="ledgerInfoList{{idx}}_shelvesId" name="ledgerInfoList[{{idx}}].shelves.id" type="hidden" value="{{row.shelves.id}}" readonly class="form-control" />
<input id="ledgerInfoList{{idx}}_qrCodeId" name="ledgerInfoList[{{idx}}].qr.id" type="hidden" value="{{row.qr.id}}" readonly class="form-control" />
</script>
<script id="nameTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_name" name="ledgerInfoList[{{idx}}].name" type="text" readonly value="{{row.name}}" onchange="onInputChange('{{idx}}', this, 'name')" class="form-control "/>
</script>
<script id="typeTpl" type="text/html">//<!--
<sys:treeselect id="ledgerInfoList{{idx}}_type" name="ledgerInfoList[{{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" />//-->
</script>
<script id="modelTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_model" name="ledgerInfoList[{{idx}}].model" type="text" value="{{row.model}}" readonly onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/>
</script>
<script id="batchNumTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_batchNum" name="ledgerInfoList[{{idx}}].batchNum" type="text" value="{{row.batchNum}}" readonly onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/>
</script>
<script id="shelvesTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_shelvesName" name="ledgerInfoList[{{idx}}].shelves.name" type="text" value="{{row.shelves.name}}" readonly onchange="onInputChange('{{idx}}', this, 'model')" class="form-control "/>
</script>
<script id="codeTpl" type="text/html">
<input id="ledgerInfoList{{idx}}_code" name="ledgerInfoList[{{idx}}].code" type="text" value="{{row.code}}" readonly class="form-control" />
<script id="detailTpl" type="text/html">
<br>
<div class="container-fluid">
<table id="table"></table>
</div>
</script>
\ No newline at end of file
......@@ -32,26 +32,25 @@
title="类型" url="/warehouse/materialtype/materialType/treeData"
extId="${ledger.id}" cssClass="form-control " allowClear="true"/>
</td>
</tr>
<tr>
<td>型号</td>
<td>
<form:input path="model" htmlEscape="false" class="form-control "/>
</td>
</tr>
<tr>
<td>数量</td>
<td>
<form:input path="num" htmlEscape="false" class="form-control "/>
</td>
</tr>
<tr>
<td>总价</td>
<td>
<form:input path="sum" htmlEscape="false" class="form-control "/>
</td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="4">
<td colspan="6">
<%@include file="ledgerDetail.jsp" %>
</td>
</tr>
......@@ -66,26 +65,6 @@
$(document).ready(function () {
initTable();
});
function save() {
var isValidate = jp.validateForm('#inputForm');//校验表单
if(!isValidate){
return false;
}else{
jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){
jp.getParent().refresh();
var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
parent.layer.close(dialogIndex);
jp.success(data.msg)
}else{
jp.error(data.msg);
}
})
}
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -307,7 +307,6 @@ $(document).ready(function() {
<table class="ani table">
<thead>
<tr>
<th>物资名称</th>
<th>类型</th>
<th>型号</th>
<th>批次号</th>
......@@ -324,9 +323,6 @@ $(document).ready(function() {
<script type="text/template" id="ledgerChild1Tpl">//<!--
<tr>
<td>
{{row.name}}
</td>
<td>
{{row.type.name}}
</td>
<td>
......
......@@ -55,91 +55,16 @@
</tr>
<tr>
<td>备注</td>
<td>
<td colspan="3">
<form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control "/>
</td>
</tr>
</table>
<div class="tabs-container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#tab-1"
aria-expanded="true">领用明细表:</a>
</li>
</ul>
<div class="tab-content">
<div id="tab-1" class="tab-pane fade in active">
<a class="btn btn-white btn-sm"
onclick="addRow('#materialRequisitionInfoList', materialRequisitionInfoRowIdx, materialRequisitionInfoTpl);materialRequisitionInfoRowIdx = materialRequisitionInfoRowIdx + 1;"
title="新增"><i class="fa fa-plus"></i> 新增</a>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th class="hide"></th>
<th>物资领用主表ID</th>
<th>物资台账明细ID</th>
<th>领用人</th>
<th>备注信息</th>
<th width="10">&nbsp;</th>
<td colspan="4">
<%@include file="materialRequisitionDetail.jsp" %>
</td>
</tr>
</thead>
<tbody id="materialRequisitionInfoList">
</tbody>
</table>
<script type="text/template" id="materialRequisitionInfoTpl">//<!--
<tr id="materialRequisitionInfoList{{idx}}">
<td class="hide">
<input id="materialRequisitionInfoList{{idx}}_id" name="materialRequisitionInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
<input id="materialRequisitionInfoList{{idx}}_delFlag" name="materialRequisitionInfoList[{{idx}}].delFlag" type="hidden" value="0"/>
</td>
<td>
<input id="materialRequisitionInfoList{{idx}}_materialRequisition" name="materialRequisitionInfoList[{{idx}}].materialRequisition.id" type="text" value="{{row.materialRequisition.id}}" class="form-control "/>
</td>
<td>
<input id="materialRequisitionInfoList{{idx}}_ledgerInfo" name="materialRequisitionInfoList[{{idx}}].ledgerInfo.id" type="text" value="{{row.ledgerInfo.id}}" class="form-control "/>
</td>
<td>
<input id="materialRequisitionInfoList{{idx}}_receiver" name="materialRequisitionInfoList[{{idx}}].receiver" type="text" value="{{row.receiver.id}}" class="form-control "/>
</td>
<td>
<textarea id="materialRequisitionInfoList{{idx}}_remarks" name="materialRequisitionInfoList[{{idx}}].remarks" rows="4" class="form-control ">{{row.remarks}}</textarea>
</td>
<td class="text-center" width="10">
{{#delBtn}}<span class="close" onclick="delRow(this, '#materialRequisitionInfoList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
</td>
</tr>//-->
</script>
<script type="text/javascript">
var materialRequisitionInfoRowIdx = 0,
materialRequisitionInfoTpl = $("#materialRequisitionInfoTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, "");
$(document).ready(function () {
var data = ${fns:toJson(materialRequisition.materialRequisitionInfoList)};
for (var i = 0; i < data.length; i++) {
addRow('#materialRequisitionInfoList', materialRequisitionInfoRowIdx, materialRequisitionInfoTpl, data[i]);
materialRequisitionInfoRowIdx = materialRequisitionInfoRowIdx + 1;
}
});
</script>
</div>
</div>
</div>
<c:if test="${mode == 'add' || mode=='edit'}">
<div class="col-lg-3"></div>
<div class="col-lg-6">
<div class="form-group text-center">
<div>
<button class="btn btn-primary btn-block btn-lg btn-parsley"
data-loading-text="正在提交...">提 交
</button>
</div>
</div>
</div>
</c:if>
</form:form>
</div>
</div>
......@@ -149,6 +74,7 @@
<script type="text/javascript">
$(document).ready(function() {
initTable();
jp.ajaxForm("#inputForm",function(data){
if(data.success){
jp.success(data.msg);
......@@ -163,6 +89,27 @@
format: "YYYY-MM-DD HH:mm:ss"
});
});
function save() {
var isValidate = jp.validateForm('#inputForm');//校验表单
if(!isValidate){
return false;
}else{
jp.loading();
jp.post($("#inputForm").attr('action'),$('#inputForm').serialize(),function(data){
if(data.success){
jp.getParent().refresh();
var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
parent.layer.close(dialogIndex);
jp.success(data.msg)
}else{
jp.error(data.msg);
}
})
}
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -114,7 +114,7 @@ $(document).ready(function() {
}
,{
field: 'warehouse.name',
title: '仓库id',
title: '仓库',
sortable: true,
sortName: 'warehouse.name'
}
......
......@@ -118,10 +118,10 @@
jp.warning('请选择批次号!');
return;
}
jp.openStorageSelectDialog({batchNum:$("#batchNum").val(),state: 0, isMultiSelect: true },function (items){
if(Array.isArray(items)){
var data = items.map(function (item){
item[0] = false;
if(item.goodsInfo && !item.goodsInfo.amount){
item.goodsInfo.amount = 0;
}
......@@ -135,9 +135,14 @@
$(selector).bootstrapTable('append', data)
}
})
}
/**
* 删除明细
* @param index
* @param rowId
* @param rowDelFlag
*/
function removeRow(index, rowId, rowDelFlag){
if(rowId){
var delFlag = rowDelFlag === 1 ? 0 : 1
......@@ -151,12 +156,25 @@
})
}
}
/**
* 更新行
* @param index 下标
* @param row 更新对象
*/
function updateRow(index, row){
$(selector).bootstrapTable('updateRow', {
index: index,
row: row
})
}
/**
* 监听input值,并更新行
* @param rowIndex 更新行的下标
* @param elem 元素
* @param field 属性
*/
function onInputChange(rowIndex, elem , field){
var obj = {};
obj[field] = $(elem).val()
......@@ -167,6 +185,11 @@
}, 0)
}
/**
* 监听类型选择回调并更新行
* @param nodes 选中数据
* @param rowIndex 行下标
*/
function onSelectType(nodes, rowIndex){
if(Array.isArray(nodes) && nodes.length === 1){
var node = nodes[0];
......@@ -188,14 +211,16 @@
return $(selector).bootstrapTable('getData');
}
/**
* 批量添加货架
*/
function addShelve(){
jp.openShelvesSelectDialog(function (items){
var Shelve = items[0];
// TODO: 获取选中的明细下标
var Shelve = items[0]; // 货架对象
getSelections().forEach(function (item){
var index = getTableData().findIndex(function (current){
return current.qrCode.id === item.qrCode.id;
})
}); // 需更新的行的下标
updateRow(index,{
shelves: {
id: Shelve.id,
......@@ -265,7 +290,6 @@
<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}}_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}}_warehouseId" 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 id="storageInfoList{{idx}}_qrCodeId" name="storageInfoList[{{idx}}].qrCode.id" type="hidden" value="{{row.qrCode.id}}" readonly class="form-control" />
......@@ -284,8 +308,9 @@
<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 "/>
</script>
<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" />
<script id="shelvesTpl" type="text/html">//<!--
<sys:gridselect url="${ctx}/warehouse/shelves/shelves/data" id="storageInfoList{{idx}}_shelves" name="storageInfoList[{{idx}}].shelves.id" value="{{row.shelves.id}}" labelName="storageInfoList[{{idx}}].shelves.name" labelValue="{{row.shelves.name}}"
title="选择货架" cssClass="form-control required" fieldLabels="货架名称|货架编号" fieldKeys="name|code" searchLabels="仓库名称|仓库编号" searchKeys="name|code" ></sys:gridselect>//-->
</script>
<script id="remarksTpl" type="text/html">
<textarea id="storageInfoList{{idx}}_remarks" name="storageInfoList[{{idx}}].remarks" rows="2" onchange="onInputChange('{{idx}}', this, 'remarks')" class="form-control ">{{row.remarks}}</textarea>
......
......@@ -331,7 +331,8 @@ $(document).ready(function() {
var qrId$ = $("<input type='hidden' name='ledgerInfoList["+index+"].qr.id' value='"+item.qrCode.id+"' />");
var shelvesId$ = $("<input type='hidden' name='ledgerInfoList["+index+"].shelves.id' value='"+item.shelves.id+"' />");
var code$ = $("<input type='hidden' name='ledgerInfoList["+index+"].code' value='"+item.qrCode.code+"' />");
$("#ledgerForm").append(id$).append(delFlag$).append(name$).append(typeId$).append(batchNum$).append(model$).append(goodsInfoId$).append(qrId$).append(shelvesId$).append(code$);
var amount$ = $("<input type='hidden' name='ledgerInfoList["+index+"].amount' value='"+item.amount+"' />");
$("#ledgerForm").append(id$).append(delFlag$).append(name$).append(typeId$).append(batchNum$).append(model$).append(goodsInfoId$).append(qrId$).append(shelvesId$).append(code$).append(amount$);
})
jp.loading('入库中...');
jp.post("${ctx}/warehouse/ledger/ledger/save", $("#ledgerForm").serialize(), function (res){
......
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