507 lines
23 KiB
Plaintext
507 lines
23 KiB
Plaintext
<%@page import="com.sipai.entity.sparepart.SparePartCommString"%>
|
||
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<%request.setAttribute("AUDIT", SparePartCommString.STATUS_STOCK_AUDIT); %>
|
||
<%request.setAttribute("START", SparePartCommString.STATUS_STOCK_START); %>
|
||
<%request.setAttribute("FINSH", SparePartCommString.STATUS_STOCK_FINISH); %>
|
||
<style type="text/css">
|
||
.select2-container .select2-selection--single{
|
||
height:34px;
|
||
line-height: 34px;
|
||
}
|
||
.select2-selection__arrow{
|
||
margin-top:3px;
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
//流程审核文件上传所需参数
|
||
var masterId_process = '${outStockRecord.id}';//业务Id
|
||
var tbName_process = 'TB_Process_UploadFile'; //数据表
|
||
var nameSpace_process ='ProcessUploadFile';//保存文件夹
|
||
var status = 'delete';//有删除权限
|
||
|
||
function doupdate() {
|
||
$.post(ext.contextPath + "/sparepart/stockCheck/getCheck.do", {warehouseId: $("#warehouseId").val()}, function(res) {
|
||
if (res.data == 0) {
|
||
$('#subForm').data('bootstrapValidator')
|
||
.updateStatus('userName', 'NOT_VALIDATED',null)
|
||
.validateField('userName');
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/sparepart/outStockRecord/update.do", $("#subForm").serialize(), function(data) {
|
||
if (data.res == 1){
|
||
closeModal('subModal');
|
||
$("#table").bootstrapTable('refresh');
|
||
}else if(data.res == 0){
|
||
showAlert('d','保存失败');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
} else {
|
||
showAlert('d',"请完成盘点后在进行领料操作!");
|
||
}
|
||
},'json');
|
||
}
|
||
function dosubmit(){
|
||
$.post(ext.contextPath + "/sparepart/stockCheck/getCheck.do", {warehouseId: $("#warehouseId").val()}, function(res) {
|
||
if (res.data == 0) {
|
||
$("#status").val('${AUDIT}');
|
||
$('#subForm').data('bootstrapValidator')
|
||
.updateStatus('auditManName', 'NOT_VALIDATED',null)
|
||
.validateField('auditManName');
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
var url = "";
|
||
if('${taskName}'!= null && '${taskName}'!=""){
|
||
url = "/sparepart/outStockRecord/submitOutStockHandle.do";
|
||
}else{
|
||
url = "/sparepart/outStockRecord/startProcess.do";
|
||
}
|
||
$.post(ext.contextPath + url, $("#subForm").serialize(), function(data) {
|
||
if (data.res == 1) {
|
||
$("#table").bootstrapTable('refresh');
|
||
closeModal('subModal');
|
||
}else if(data.res == 0){
|
||
showAlert('d','保存失败');
|
||
}else if(data.res == 2){
|
||
showAlert('d','未检测到出库审核流程,请先部署出库审核流程!');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
} else {
|
||
showAlert('d',"请完成盘点后在进行领料操作!");
|
||
}
|
||
},'json');
|
||
}
|
||
//提交时先验证审核人不能为空,保存时审核人可以为空
|
||
function submitFun(){
|
||
//没有领用明细不能发起审核
|
||
var allTableData = $("#table_outStockDetail").bootstrapTable('getData');
|
||
if(allTableData.length == 0){
|
||
showAlert('d','请先添加领用的明细信息!','alertDiv');
|
||
}else{
|
||
//新增的输入框添加验证
|
||
$("#subForm").data('bootstrapValidator').addField('auditManName',{
|
||
validators: {
|
||
notEmpty: {
|
||
message: '审核人不能为空'
|
||
},
|
||
}
|
||
});
|
||
dosubmit();
|
||
}
|
||
}
|
||
//关闭模态框时刷新表格数据
|
||
function closeModel(){
|
||
closeModal('subModal');
|
||
$("#table").bootstrapTable('refresh');
|
||
}
|
||
//新增入库明细
|
||
var addDetailFun = function() {
|
||
//新增物资领用明细时,验证所属仓库不能为空
|
||
$("#subForm").data('bootstrapValidator').validateField('warehouseId');
|
||
if($("#subForm").data('bootstrapValidator').isValidField('warehouseId')){
|
||
var allTableData = $("#table_outStockDetail").bootstrapTable('getData');
|
||
var stockIds="";
|
||
$.each(allTableData,function(index,item){
|
||
if(stockIds!=""){
|
||
stockIds+=",";
|
||
}
|
||
stockIds+=item.stockId;
|
||
})
|
||
$.post(ext.contextPath + '/sparepart/outStockRecord/selectStockForOutStockDetails.do', {stockIds:stockIds,companyId:'${outStockRecord.bizId}',
|
||
warehouseId:$("#warehouseId").val()},
|
||
function(data) {
|
||
$("#stock4SelectsDiv").html(data);
|
||
openModal('subDetailModal');
|
||
});
|
||
}
|
||
};
|
||
var doFinishSelects = function(data) {
|
||
$.post(ext.contextPath + '/sparepart/outStockRecord/saveOutStockRecordDetails.do', {outstockRecordId:'${outStockRecord.id}',
|
||
stockIds:data} , function(data) {
|
||
if(data.res){
|
||
$("#table_outStockDetail").bootstrapTable('refresh');
|
||
}
|
||
},'json');
|
||
};
|
||
//删除多条申购明细数据
|
||
var deletesDetailFun = function() {
|
||
var checkedItems = $("#table_outStockDetail").bootstrapTable('getSelections');
|
||
var datas="";
|
||
$.each(checkedItems, function(index, item){
|
||
datas+=item.id+",";
|
||
});
|
||
if(datas==""){
|
||
showAlert('d','请先选择记录','alertDiv');
|
||
}else{
|
||
swal({
|
||
text: "您确定要删除此记录?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function(willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/sparepart/outStockRecord/deletesOutStockRecordDetail.do', {ids:datas} , function(data) {
|
||
if(data>0){
|
||
$("#table_outStockDetail").bootstrapTable('refresh');
|
||
}else{
|
||
showAlert('d','删除失败','alertDiv');
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
}
|
||
};
|
||
//输入框验证
|
||
$("#subForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
outDate: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '领用日期不能为空'
|
||
}
|
||
}
|
||
},
|
||
warehouseId: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '所属仓库不能为空'
|
||
}
|
||
}
|
||
},
|
||
deptId: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '领用部门不能为空'
|
||
}
|
||
}
|
||
},
|
||
userName: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '领用人不能为空'
|
||
}
|
||
}
|
||
},
|
||
}
|
||
});
|
||
$(function(){
|
||
//初始化文件显示
|
||
getFileList_process();
|
||
|
||
$('#table_outStockDetail').bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/sparepart/outStockRecord/getOutStockDetailList.do', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20,50], // 设置页面可以显示的数据条数
|
||
pageSize: 10, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
showFooter:true,//添加页脚
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||
return {
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset/params.limit+1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order,
|
||
pid:'${outStockRecord.id}',
|
||
}
|
||
},
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
checkbox: true, // 显示一个勾选框
|
||
},{
|
||
field: 'goods.name', // 返回json数据中的name
|
||
title: '物品名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
},{
|
||
field: 'goods.model', // 返回json数据中的name
|
||
title: '规格型号', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
},{
|
||
field: 'goods.brand', // 返回json数据中的name
|
||
title: '品牌', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},{
|
||
field: 'goods.unit', // 返回json数据中的name
|
||
title: '单位', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},/* {
|
||
field: 'dept.name', // 返回json数据中的name
|
||
title: '领用部门', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, */{
|
||
field: 'outNumber', // 返回json数据中的name
|
||
title: '领用数量', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
editable: { //编辑列元素
|
||
type: 'text',
|
||
title: '领用数量',
|
||
validate: function (v) {
|
||
if (!v) return '数量不能为空';
|
||
|
||
}
|
||
}
|
||
},{
|
||
field: 'includedTaxCostPrice', // 返回json数据中的name
|
||
title: '含税单价/元', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
footerFormatter:"合计",
|
||
},{
|
||
field: 'includedTaxTotalMoney', // 返回json数据中的name
|
||
title: '含税合计/元', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
footerFormatter:function(value){
|
||
if(value==""){
|
||
return"";
|
||
}else{
|
||
var count = 0;
|
||
for(var i in value){
|
||
count += value[i].includedTaxTotalMoney;
|
||
}
|
||
return count.toFixed(4);
|
||
}
|
||
},
|
||
},
|
||
// {
|
||
// field: 'price', // 返回json数据中的name
|
||
// title: '不含税单价/元', // 表格表头显示文字
|
||
// align: 'center', // 左右居中
|
||
// valign: 'middle', // 上下居中
|
||
//
|
||
// },{
|
||
// field: 'totalMoney', // 返回json数据中的name
|
||
// title: '不含税合计/元', // 表格表头显示文字
|
||
// align: 'center', // 左右居中
|
||
// valign: 'middle' ,// 上下居中
|
||
// footerFormatter:function(value){
|
||
// if(value==""){
|
||
// return"";
|
||
// }else{
|
||
// var count = 0;
|
||
// for(var i in value){
|
||
// count += value[i].totalMoney;
|
||
// }
|
||
// return count.toFixed(2);
|
||
// }
|
||
// },
|
||
// },
|
||
],
|
||
//保存列修改后的数据
|
||
onEditableSave: function (field, row, oldValue, $el) {
|
||
$.post(ext.contextPath + "/sparepart/outStockRecord/updateOutStockDetail.do", {id:row.id,price:row.price,number:row.outNumber}, function(data) {
|
||
if (data.res == 1){
|
||
$("#table_outStockDetail").bootstrapTable('refresh');
|
||
}else if(data.res == 0){
|
||
showAlert('d','编辑失败');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
$("#table_outStockDetail").bootstrapTable('refresh');
|
||
}
|
||
},'json');
|
||
},
|
||
onLoadSuccess: function(){ //加载成功时执行
|
||
adjustBootstrapTableView("table_outStockDetail");
|
||
},
|
||
onLoadError: function(){ //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
});
|
||
//选择部门
|
||
$.post(ext.contextPath + "/user/getDeptByBizId4Select.do", {companyId:"${outStockRecord.bizId}"}, function(data) {
|
||
var selelct = $("#deptId").select2({
|
||
data: data,
|
||
placeholder:'请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||
formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||
});
|
||
selelct.val('${outStockRecord.deptId}').trigger("change");
|
||
},'json');
|
||
//选择仓库
|
||
$.post(ext.contextPath + "/sparepart/warehouse/getWarehouseForSelectByCompanyId.do", {companyId:"${outStockRecord.bizId}"}, function(data) {
|
||
var selelct =$("#warehouseId").select2({
|
||
data: data,
|
||
placeholder:'请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||
formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||
});
|
||
selelct.val('${outStockRecord.warehouseId}').trigger("change");
|
||
},'json');
|
||
//领用时间
|
||
$("#outDate").datepicker({
|
||
language: 'zh-CN',
|
||
autoclose: true,
|
||
todayHighlight: true,
|
||
format:'yyyy-mm-dd',
|
||
});
|
||
});
|
||
//选择入库负责人
|
||
var showUser4SelectsFun = function() {
|
||
var userIds= $("#userId").val();
|
||
$.post(ext.contextPath + '/user/userForSelectByStructure.do', {formId:"subForm",hiddenId:"userId",textId:"userName",userIds:userIds} , function(data) {
|
||
$("#user4SelectDiv").html(data);
|
||
openModal("user4SelectModal");
|
||
});
|
||
};
|
||
//选择入库审核人
|
||
var showUser4AuditSelectsFun = function() {
|
||
var userIds= $("#auditManId").val();
|
||
$.post(ext.contextPath + '/user/userForSelectByStructure.do', {formId:"subForm",hiddenId:"auditManId",textId:"auditManName",userIds:userIds} , function(data) {
|
||
$("#user4SelectDiv").html(data);
|
||
openModal("user4SelectModal");
|
||
});
|
||
};
|
||
</script>
|
||
<div class="modal fade" id="subModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">编辑物资领用记录</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="subForm">
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<input id="status" name="status" type="hidden" value="${outStockRecord.status}"/>
|
||
<input id="bizId" name="bizId" type="hidden" value="${outStockRecord.bizId}"/>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">所属厂区</label>
|
||
<div class="col-sm-6" >
|
||
<p class="form-control-static" >${outStockRecord.company.name}</p>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*领用单号</label>
|
||
<div class="col-sm-6">
|
||
<input type="text" class="form-control" id="id" name ="id" placeholder="名称" value="${outStockRecord.id}" readonly>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*领用日期</label>
|
||
<div class="col-sm-6">
|
||
<div class="input-group date">
|
||
<div class="input-group-addon">
|
||
<i class="fa fa-calendar"></i>
|
||
</div>
|
||
<input type="text" class="form-control" id="outDate" name="outDate" style="width: 230px;" value="${outStockRecord.outDate.substring(0,10)}" placeholder="请选择"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">票据单号</label>
|
||
<div class="col-sm-6">
|
||
<input type="text" class="form-control" id="billNumber" name ="billNumber" placeholder="票据单号" value="${outStockRecord.billNumber}">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*所属仓库</label>
|
||
<div class="col-sm-6">
|
||
<select class="form-control select2" id="warehouseId" name="warehouseId" style="width: 270px;" ></select>
|
||
</div>
|
||
</div>
|
||
<!-- <div class="form-group">
|
||
<label class="col-sm-2 control-label">*领用部门</label>
|
||
<div class="col-sm-6">
|
||
<select class="form-control select2" id="deptId" name ="deptId" style="width: 270px;">
|
||
</select>
|
||
</div>
|
||
</div> -->
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*领用人</label>
|
||
<div class="col-sm-6">
|
||
<input type="text" class="form-control" id="userName" name="userName" placeholder="点击选择" onclick="showUser4SelectsFun();" value="${outStockRecord.userName}">
|
||
<input id="userId" name="userId" type="hidden" value="${outStockRecord.userId}" />
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">审核人</label>
|
||
<div class="col-sm-6">
|
||
<input type="text" class="form-control" id="auditManName" name="auditManName" placeholder="点击选择" onclick="showUser4AuditSelectsFun();" value="${outStockRecord.auditManName}">
|
||
<input id="auditManId" name="auditManId" type="hidden" value="${outStockRecord.auditManId}" />
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">备注</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" rows="2" id ="remark" name ="remark" placeholder="备注...">${outStockRecord.remark}</textarea>
|
||
</div>
|
||
</div>
|
||
<!-- 文件上传,显示 -->
|
||
<div class="form-group" style="margin:8px">
|
||
<label class="col-sm-2 control-label"></label>
|
||
<button type="button" class="btn btn-default btn-file" onclick="fileinput_process()" id="btn_save"><i class="fa fa-paperclip"></i>上传文件</button>
|
||
</div>
|
||
<div id="fileArea">
|
||
</div>
|
||
</form>
|
||
<div class="box box-primary" >
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">领用明细</h3>
|
||
<div class="box-tools pull-right">
|
||
<a onclick="addDetailFun()" class="btn btn-box-tool" data-toggle="tooltip" title="新增"><i class="glyphicon glyphicon-plus"></i></a>
|
||
<a onclick="deletesDetailFun()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i class="glyphicon glyphicon-minus"></i></a>
|
||
</div>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body ">
|
||
<table id="table_outStockDetail"></table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" onclick="closeModel()">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="doupdate()" id="btn_save">保存</button>
|
||
<button type="button" class="btn btn-primary" onclick="submitFun()" id="btn_save">提交</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div>
|