Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/sparepart/purchasePlanList.jsp
2026-01-16 14:13:44 +08:00

482 lines
21 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="com.sipai.entity.base.ServerObject"%>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security"%>
<%@page import="com.sipai.entity.sparepart.SparePartCommString"%>
<%request.setAttribute("PLAN", SparePartCommString.PURCHASE_PLAN); %>
<%-- <%request.setAttribute("SUBMINT", SparePartCommString.STATUS_SUBMIT); %>
<%request.setAttribute("PASS", SparePartCommString.STATUS_PASS); %>
<%request.setAttribute("REJECT", SparePartCommString.STATUS_REJECT); %> --%>
<%request.setAttribute("FINISH", SparePartCommString.STATUS_FINISH); %>
<!DOCTYPE html>
<!-- <html lang="zh-CN"> -->
<!-- BEGIN HEAD -->
<head>
<title><%= ServerObject.atttable.get("TOPTITLE")%></title>
<!-- 引用页头及CSS页-->
<jsp:include page="/jsp/inc.jsp"></jsp:include>
<!-- bootstrap switch -->
<link rel="stylesheet" href="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/js/bootstrap-switch.min.js" charset="utf-8"></script>
<style type="text/css">
.select2-container .select2-selection--single{
height:30px;
line-height: 30px;
}
.select2-selection__arrow{
margin-top:3px;
}
.table-hover>tbody>tr:hover {
cursor: pointer;
}
</style>
<script type="text/javascript">
var addFun = function() {
$("#searchForm").bootstrapValidator('validate');//提交验证
if ($("#searchForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
$.post(ext.contextPath + '/sparepart/purchasePlan/addPurchasePlan.do', {companyId :companyId } , function(data) {
$("#subDiv").html(data);
openModal('subModal');
});
};
};
var editFun = function(id) {
stopBubbleDefaultEvent();
$.post(ext.contextPath + '/sparepart/purchasePlan/editPurchasePlan.do', {id:id} , function(data) {
$("#subDiv").html(data);
openModal('subModal');
});
};
var viewFun = function(id){
$.post(ext.contextPath + '/sparepart/subscribe/view.do', {id:id} , function(data) {
$("#subDiv").html(data);
openModal('subModal');
});
};
var deleteFun = function(id) {
stopBubbleDefaultEvent();
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/purchasePlan/delete.do', {id : id}, function(data) {
if(data==1){
$("#table").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
};
var deletesFun = function() {
var checkedItems = $("#table").bootstrapTable('getSelections');
var datas="";
$.each(checkedItems, function(index, item){
datas+=item.id+",";
});
if(datas==""){
showAlert('d','请先选择记录','mainAlertdiv');
}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/purchasePlan/deletes.do', {ids:datas} , function(data) {
if(data>0){
$("#table").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
}
};
var dosearch = function() {
$("#table").bootstrapTable('refresh');
selectDept();
};
var companyId = unitId;
$(function() {
initFun();
//简易公司combotree
// $.post(ext.contextPath + "/user/showCompanySelectTree.do", {}, function (data) {
// $('#companySelectTree').html(data);
// });
//输入框验证
$("#searchForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
search_code: {
validators: {
notEmpty: {
message: '请先选择厂区'
}
}
},
}
});
});
//导出设备表,要用get请求的方式
function downloadFuns(id) {
window.open(ext.contextPath + "/sparepart/purchasePlan/downloadSubscribeDetailExcel4Plan.do?subscribeId="+id);
}
function selectDept(){
//选择部门
$.post(ext.contextPath + "/user/getDeptByBizId4Select.do", {companyId:unitId}, function(data) {
$("#dept_id").empty();
var selelct = $("#dept_id").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;} // 函数用于呈现当前的选择
});
$(".select2-selection--single").css({'height':'30px','paddingTop':'4px'})
selelct.val('').trigger("change");
selelct.on("change",function(e){
$("#table").bootstrapTable('refresh');
});
},'json');
}
var initFun = function(){
selectDept();
$("#table").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/sparepart/subscribe/getList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20,50], // 设置页面可以显示的数据条数
pageSize: 10, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
showFooter:true,//添加页脚
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
search_name: $('#search_name').val(),
search_code: unitId,
status:'${FINISH}',
deptId : $('#dept_id').val(),
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
/* onClickRow: function (row) {//单击行事件,执行查看功能
viewFun(row.id);
}, */
detailView: true,//父子表
onPostBody:function () {
//合并页脚
merge_footer();
},
columns: [
/* {
checkbox: true, // 显示一个勾选框
}, */{
field: 'id', // 返回json数据中的name
title: '申购单号', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
},{
field: 'dept.name', // 返回json数据中的name
title: '申购部门', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
},{
field: 'subscribeManName', // 返回json数据中的name
title: '申购人', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
},{
field: 'subscribeDate', // 返回json数据中的name
title: '申购日期', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
formatter:function (value, row, index){
return value.substring(0,10);
},
footerFormatter:"总计/元",
},{
field: 'totalMoney', // 返回json数据中的name
title: '合计金额/元', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
footerFormatter:function(value){
//console.info(value)
if(value==""){
return"";
}else{
var count = 0;
for(var i in value){
count += value[i].totalMoney;
}
return count.toFixed(2);
}
},
},/* {
field: 'remark', // 返回json数据中的name
title: '备注', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
}, */
{
title: "操作",
align: 'center',
valign: 'middle',
width: 120, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts= '';
buts+= '<security:authorize buttonUrl="sparepart/subscribe/view.do">';
buts+= '<button class="btn btn-default btn-sm" title="查看" onclick="viewFun(\'' + row.id
+ '\')"><i class="fa fa-eye"></i><span class="hidden-md hidden-lg"> 查看</span></button>';
buts+= '</security:authorize>';
buts+= '<security:authorize buttonUrl="sparepart/subscribe/downloadSubscribeDetailExcel4Plan.do">';
buts+= '<button class="btn btn-default btn-sm" title="导出" onclick="downloadFuns(\'' + row.id
+ '\')"><i class="fa fa-cloud-download"></i><span class="hidden-md hidden-lg"> 导出</span></button>';
buts+= '</security:authorize>';
buts='<div class="btn-group" >'+buts+'</div>';
return buts;
}
}
],
//注册加载子表的事件。index父表当前行的行索引,row父表当前行的Json数据对象,$detail当前行下面创建的新行里面的td对象。
onExpandRow: function (index, row, $detail) {
initDetailTable(index, row, $detail);
},
onLoadSuccess: function(){ //加载成功时执行
adjustBootstrapTableView("table");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
});
}
//合并页脚
function merge_footer() {
//获取table表中footer 并获取到这一行的所有列
var footer_tbody = $('.fixed-table-footer table tbody');
var footer_tr = footer_tbody.find('>tr');
var footer_td = footer_tr.find('>td');
var footer_td_1 = footer_td.eq(0);
//除了第一列和倒数两列其余全部隐藏,然后再设置第一列跨列
//遍历隐藏中间的列 下标从1开始
for(var i=1;i<footer_td.length-2;i++) {
footer_td.eq(i).hide();
}
//设置跨列
footer_td_1.attr('colspan', footer_td.length-1).show();
//这里可以根据自己的表格来设置列的宽度 使对齐
footer_td_1.attr('width', "910px").show();
}
//初始化子表格,采购单明细表
var initDetailTable = function (index, row, $detail) {
var subscribeId = row.id;
var detailTable = $detail.html('<table></table>').find('table');
$(detailTable).bootstrapTable({
url: ext.contextPath + '/sparepart/subscribe/getSubscribeDetailList.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,
pids:subscribeId,
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
columns: [
{
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: 'usableNumber', // 返回json数据中的name
title: '可采购数量', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
cellStyle:function (value, row, index, field) {
return { css: {"background": "yellow"} };
}
},{
field: 'price', // 返回json数据中的name
title: '单价/元', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
},{
field: 'totalMoney', // 返回json数据中的name
title: '合计/元', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
},
],
onLoadSuccess: function(){ //加载成功时执行
adjustBootstrapTableView("detailTable");
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
});
};
</script>
</head>
<body onload="initMenu()" class="hold-transition ${cu.themeclass} sidebar-mini">
<div class="wrapper">
<!-- 引用top -->
<%-- <jsp:include page="/jsp/top.jsp"></jsp:include> --%>
<!-- 菜单栏 -->
<%-- <jsp:include page="/jsp/left.jsp"></jsp:include> --%>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<%-- <section class="content-header">--%>
<%-- <h1 id ="head_title"></h1>--%>
<%-- <ol class="breadcrumb">--%>
<%-- <li><a id ='head_firstlevel' href="#"><i class="fa fa-dashboard"></i> </a></li>--%>
<%-- <!-- <li class="active">Here</li> -->--%>
<%-- </ol>--%>
<%-- </section>--%>
<!-- Main content -->
<section class="content container-fluid">
<div id="mainAlertdiv"></div>
<div id="subDiv"></div>
<div id="subDetailDiv"></div>
<div id="Goods4SelectDiv"></div>
<div id="fileInputDiv"></div>
<form id="searchForm">
<div >
<!-- <div class="form-group form-inline">
<div class="form-group">
<label class="form-label" id="companylabel">水厂:</label>
<label class="form-label" id="company" style="width:180px;border: none;background: transparent;" ></label>
</div>
<div class="form-group">
<select class="form-control select2 " id="search_code" name ="search_code" style="width: 220px;"></select>
</div>
</div> -->
<div id="companySelectTree"></div>
<div class="form-group" style="padding:0;">
<%-- <div class="btn-group" style="width: 220px;padding-bottom:10px;">
<security:authorize buttonUrl="sparepart/warehouse/add.do">
<button type="button" class="btn btn-default btn-sm" onclick="addFun();"><i class="fa fa-plus"></i> 新增</button>
<button type="button" class="btn btn-default btn-sm" onclick="deletesFun();"><i class="fa fa-trash-o"></i> 删除</button>
</security:authorize>
</div> --%>
<div class="form-group pull-right form-inline" >
<div class="input-group" >
<label class="form-label" id="companylabel">申购部门:</label>
<select class="form-control select2" id="dept_id" name ="dept_id" style="width: 160px;">
</select>
</div>
<div class="input-group input-group-sm" style="width: 250px;">
<input type="text" id="search_name" name="search_name" class="form-control pull-right" placeholder="名称">
<div class="input-group-btn">
<button class="btn btn-default" onclick="dosearch();"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
</div>
</div>
</form>
<table id="table"></table>
</section>
<!-- /.content -->
</div>
<%-- <jsp:include page="/jsp/bottom.jsp"></jsp:include> --%>
<%-- <jsp:include page="/jsp/side.jsp"></jsp:include> --%>
</div>
</body>
<!-- 文件上传-->
<link rel="stylesheet" href="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/css/fileinput.min.css"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/js/fileinput.min.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/bootstrap-fileinput/js/locales/zh.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/JS/commonFileUpload.js" charset="utf-8"></script>
</html>