Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/sparepart/purchaseRecordAdd.jsp

262 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2026-01-16 14:13:44 +08:00
<%@page import="com.sipai.entity.sparepart.SparePartCommString"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%request.setAttribute("PLAN", SparePartCommString.PURCHASE_PLAN); %>
<%request.setAttribute("START", SparePartCommString.STATUS_START); %>
<%request.setAttribute("ACCEPT", SparePartCommString.STATUS_ACCEPT); %>
<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">
function dosave() {
$("#subForm").bootstrapValidator('validate');//提交验证
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
$.post(ext.contextPath + "/sparepart/purchaseRecord/save.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');
}
}
//输入框验证
$("#subForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
purchaseDate: {
validators: {
notEmpty: {
message: '采购日期不能为空'
}
}
},
purchaseManName: {
validators: {
notEmpty: {
message: '采购负责人不能为空'
}
}
},
}
});
//添加采购记录明细
var addPurchaseRecordDetailFun = function() {
$.post(ext.contextPath + '/sparepart/purchaseRecord/selectPurchaseDetails.do', {companyId : '${company.id}'},
function(data) {
$("#Goods4SelectsDiv").html(data);
openModal('subDetailModal');
});
};
var doFinishSelects = function(data) {
$.post(ext.contextPath + "/sparepart/purchaseRecord/savePurchaseRecord.do", {ids : data , recordId : '${id}' }, function(data) {
if (data.res > 0){
$("#table_PurchaseRecordDetail").bootstrapTable('refresh');
}else if(data.res == 0){
showAlert('d','保存失败');
}else{
showAlert('d',data.res);
}
},'json');
};
$(function(){
$('#table_PurchaseRecordDetail').bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/sparepart/purchaseRecord/getPurchaseRecordDetailList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20,50], // 设置页面可以显示的数据条数
pageSize: 10, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
pid:'${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: 'number', // 返回json数据中的name
title: '到货数量', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
editable: { //编辑列元素
type: 'text',
title: '可用数量',
validate: function (v) {
console.info(v)
if (!v)
return '数量不能为空';
}
}
},{
field: 'price', // 返回json数据中的name
title: '单价/元', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
/* editable: { //编辑列元素
type: 'text',
title: '单价',
validate: function (v) {
if (!v) return '单价不能为空';
}
} */
},{
field: 'totalMoney', // 返回json数据中的name
title: '合计/元', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
},
],
//保存列修改后的数据
onEditableSave: function (field, row, oldValue, $el) {
$.post(ext.contextPath + "/sparepart/purchaseRecord/updatePurchaseRecordDetail.do", {id:row.id,price:row.price,number:row.number}, function(data) {
if (data.res == 1){
$("#table_PurchaseRecordDetail").bootstrapTable('refresh');
}else if(data.res == 0){
showAlert('d','编辑失败');
}else{
showAlert('d',data.res);
}
},'json');
},
onLoadSuccess: function(){ //加载成功时执行
adjustBootstrapTableView("table_PurchaseRecordDetail");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
});
//采购时间
$("#purchaseDate").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format:'yyyy-mm-dd',
})
$("#purchaseDate").datepicker('setDate',new Date());
})
//选择采购负责人
var showUser4SelectsFun = function() {
var userIds= $("#purchaseManId").val();
$.post(ext.contextPath + '/user/userForSelectByStructure.do', {formId:"subForm",hiddenId:"purchaseManId",textId:"purchaseManName",userIds:userIds} , function(data) {
$("#user4SelectDiv").html(data);
openModal("user4SelectModal");
});
};
</script>
<div class="modal fade" id="subModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</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 name="status" type="hidden" value="${ACCEPT}"/>
<div class="form-group">
<label class="col-sm-2 control-label">所属厂区</label>
<div class="col-sm-10">
<input name="bizId" type="hidden" value="${company.id}"/>
<p class="form-control-static" >${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="${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="purchaseDate" name="purchaseDate" style="width: 230px;" 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="purchaseManName" name="purchaseManName" placeholder="点击选择" onclick="showUser4SelectsFun();">
<input id="purchaseManId" name="purchaseManId" type="hidden" />
</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="备注..."></textarea>
</div>
</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="addPurchaseRecordDetailFun()" class="btn btn-box-tool" data-toggle="tooltip" title="按采购计划导入明细"><i class="glyphicon glyphicon-plus"></i></a>
<a onclick="deletesPurchaseRecordDetailFun()" 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_PurchaseRecordDetail"></table>
</div>
</div> -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="dosave()" id="btn_save">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>