308 lines
14 KiB
Plaintext
308 lines
14 KiB
Plaintext
<%@page import="com.sipai.entity.sparepart.SparePartCommString"%>
|
||
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<%request.setAttribute("PLAN", SparePartCommString.PURCHASE_PLAN); %>
|
||
<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 doupdate() {
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/sparepart/purchasePlan/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');
|
||
}
|
||
}
|
||
function dosubmit(){
|
||
doupdate();
|
||
}
|
||
//导入部门申购明细
|
||
var doaddPurchaseDetailFun = function() {
|
||
$.post(ext.contextPath + '/sparepart/purchasePlan/selectDepartmentPurchaseDetail.do', {pid:'${purchasePlan.id}'} , function(data) {
|
||
$("#subDetailDiv").html(data);
|
||
openModal('subDetailModal');
|
||
});
|
||
};
|
||
var doeditPurchaseDetail = function(id) {
|
||
$.post(ext.contextPath + '/sparepart/purchasePlan/editPurchaseDetail.do', {id:id} , function(data) {
|
||
$("#subDetailDiv").html(data);
|
||
openModal('subDetailModal');
|
||
});
|
||
};
|
||
//删除多条申购明细数据
|
||
var dodeletesPurchaseDetailFun = function() {
|
||
var checkedItems = $("#table_PurchaseDetail").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(willDelete => {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/sparepart/purchasePlan/deletesPurchaseDetail.do', {ids:datas,companyId:'${mPointProp.bizId}'} , function(data) {
|
||
if(data>0){
|
||
$("#table_PurchaseDetail").bootstrapTable('refresh');
|
||
}else{
|
||
showAlert('d','删除失败','alertDiv');
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
}
|
||
};
|
||
$(function(){
|
||
$("#table_PurchaseDetail").bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/sparepart/purchasePlan/getPurchaseDetailList.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:'${purchasePlan.id}',
|
||
type:'${PLAN}'
|
||
}
|
||
},
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
/* onClickRow: function (row) {//单击行事件,执行查看功能
|
||
viewFun(row.id);
|
||
}, */
|
||
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' // 上下居中
|
||
},{
|
||
field: 'price', // 返回json数据中的name
|
||
title: '单价/元', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},{
|
||
field: 'totalMoney', // 返回json数据中的name
|
||
title: '合计/元', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},{
|
||
field: 'departmentId', // 返回json数据中的name
|
||
title: '申购部门', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},{
|
||
title: "操作",
|
||
align: 'center',
|
||
valign: 'middle',
|
||
width: 120, // 定义列的宽度,单位为像素px
|
||
formatter: function (value, row, index) {
|
||
var buts= '';
|
||
buts+= '<button class="btn btn-default btn-sm" title="编辑" onclick="doeditPurchaseDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
|
||
return buts;
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function(){ //加载成功时执行
|
||
adjustBootstrapTableView("table_PurchaseDetail");
|
||
},
|
||
onLoadError: function(){ //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
});
|
||
//选择厂区
|
||
$.post(ext.contextPath + "/user/getSearchBizsByUserId4Select.do", {}, function(data) {
|
||
//选择厂区为一个厂时隐藏选择框
|
||
if(data.length == 1){
|
||
$("#bizId").css("display", "none");
|
||
$("#input_bizId").val(data[0].text);
|
||
$("#hidden_bizId").val(data[0].id);
|
||
}else{
|
||
$("#hidden_bizId").attr("disabled","disabled");
|
||
$("#input_bizId").css("display", "none");
|
||
var selelct =$("#bizId").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('${purchasePlan.bizId}').trigger("change");
|
||
}
|
||
},'json');
|
||
//输入框验证
|
||
$("#subForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
planPurchaseDate: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '申购日期不能为空'
|
||
}
|
||
}
|
||
},
|
||
applicant: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '申购人不能为空'
|
||
}
|
||
}
|
||
},
|
||
}
|
||
});
|
||
$("#planPurchaseDate").datepicker({
|
||
language: 'zh-CN',
|
||
autoclose: true,
|
||
todayHighlight: true,
|
||
format:'yyyy-mm-dd',
|
||
})
|
||
})
|
||
|
||
</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 name="type" type="hidden" value="${PLAN}"/>
|
||
<input id="status" name="status" type="hidden" value="${purchasePlan.status}"/>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*所属厂区</label>
|
||
<div class="col-sm-6">
|
||
<select class="form-control select2" id="bizId" name ="bizId" style="width: 270px;">
|
||
</select>
|
||
<input class="form-control" id="input_bizId" style="border: none;background: transparent;">
|
||
<input type="hidden" id="hidden_bizId" name ="bizId">
|
||
</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="${purchasePlan.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="planPurchaseDate" name="planPurchaseDate" style="width: 230px;" placeholder="请选择" value="${purchasePlan.planPurchaseDate.substring(0,10)}"/>
|
||
</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="applicant" name ="applicant" placeholder="" value="${purchasePlan.applicant}" >
|
||
</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="备注...">${purchasePlan.remark}</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="doaddPurchaseDetailFun()" class="btn btn-box-tool" data-toggle="tooltip" title="新增"><i class="glyphicon glyphicon-plus"></i></a>
|
||
<a onclick="dodeletesPurchaseDetailFun()" 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_PurchaseDetail"></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="doupdate()" id="btn_update">保存</button>
|
||
<button type="button" class="btn btn-primary" onclick="dosubmit()" id="btn_submit">提交</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div>
|