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

560 lines
21 KiB
Plaintext
Raw Permalink 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"%>
<% request.setAttribute("Maintain_Week", com.sipai.entity.maintenance.MaintainCommStr.Maintain_Week); %>
<% request.setAttribute("Maintain_TenDays", com.sipai.entity.maintenance.MaintainCommStr.Maintain_TenDays); %>
<% request.setAttribute("Maintain_Month", com.sipai.entity.maintenance.MaintainCommStr.Maintain_Month); %>
<% request.setAttribute("Maintain_Quarter", com.sipai.entity.maintenance.MaintainCommStr.Maintain_Quarter); %>
<% request.setAttribute("Maintain_HalfYear", com.sipai.entity.maintenance.MaintainCommStr.Maintain_HalfYear); %>
<% request.setAttribute("Maintain_Year", com.sipai.entity.maintenance.MaintainCommStr.Maintain_Year); %>
<% request.setAttribute("Maintain_IN", com.sipai.entity.maintenance.MaintainCommStr.Maintain_IN); %>
<% request.setAttribute("Maintain_OUT", com.sipai.entity.maintenance.MaintainCommStr.Maintain_OUT); %>
<!-- 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>
<script type="text/javascript">
function dosave() {
$("#subForm").bootstrapValidator('validate');//提交验证
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
$.post(ext.contextPath + "/maintenance/anticorrosiveLibrary/doupdate.do", $("#subForm").serialize(), function(data) {
if (data.code == 1) {
closeModal('subModal');
$("#table").bootstrapTable('refresh');
}else if(data.code == 0){
showAlert('d',data.msg);
}else{
showAlert('d',data.msg);
}
},'json');
}
}
$("#subForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
projectName: {
validators: {
notEmpty: {
message: '项目名称不能为空'
}
}
},
cycle: {
validators: {
notEmpty: {
message: '防腐周期不能为空'
}
}
},
times: {
validators: {
notEmpty: {
message: '工时定额不能为空'
}
}
},
cost: {
validators: {
notEmpty: {
message: '人工费不能为空'
}
}
},
reason: {
validators: {
notEmpty: {
message: '委外原因不能为空'
}
}
},
contents: {
validators: {
notEmpty: {
message: '防腐内容不能为空'
}
}
},
qualityRequirement: {
validators: {
notEmpty: {
message: '质量要求不能为空'
}
}
},
}
});
$(function () {
$('#timesDiv').show();
$('#costDiv').hide();
$('#reasonDiv').hide();
// $("#times").prop("disabled", false);
// $("#cost").attr("disabled","disabled");
$('input[type=radio][name=mode]').change(function () {
if (this.value == '${Maintain_IN}') {
$('#timesDiv').show();
$('#costDiv').hide();
$('#reasonDiv').hide();
$("#times").prop("disabled", false);
$("#cost").attr("disabled","disabled");
} else {
$('#timesDiv').hide();
$('#costDiv').show();
$('#reasonDiv').show();
$("#cost").prop("disabled", false);
$("#times").attr("disabled","disabled");
}
});
//防腐周期
//$("#cycle").select2({minimumResultsForSearch: 10}).val("${anticorrosiveLibrary.cycle}").trigger("change");
$("#cycle").val("${anticorrosiveLibrary.cycle}");
$('#times').val(parseFloat($('#times').val()).toFixed(2));
$('#cost').val(parseFloat($('#cost').val()).toFixed(2));
if ("${anticorrosiveLibrary.mode }" == "${Maintain_IN}") {//自修
document.getElementById('timesDiv').style.display = '';
document.getElementById('costDiv').style.display = 'none';
document.getElementById('reasonDiv').style.display = 'none';
$("#mode1").attr("checked","checked");
$("#mode2").removeAttr("checked");
}else{//委外
document.getElementById('timesDiv').style.display = 'none';
document.getElementById('costDiv').style.display = '';
document.getElementById('reasonDiv').style.display = '';
$("#mode2").attr("checked","checked");
$("#mode1").removeAttr("checked");
}
$("#table_Material").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/maintenance/anticorrosiveLibraryMaterial/getlist.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
anticorrosiveLibraryId: '${anticorrosiveLibrary.id}',
unitId: '${anticorrosiveLibrary.unitId}'
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
responseHandler: function(res){
return res.result
},
// onClickCell:function(field, value, row, $element){
// alert(JSON.stringify(value));
// },
columns: [
{
field: 'name', // 返回json数据中的name
title: '材料名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
return row.anticorrosiveMaterial.name;
}
}, {
field: 'cost', // 返回json数据中的name
title: '材料单价(元)', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
if (row.anticorrosiveMaterial.cost == null || row.anticorrosiveMaterial.cost == 0) {
return 0;
} else {
return (row.anticorrosiveMaterial.cost * 1).toFixed(2);//toFixed指定保留小数点后几位数
}
}
}, {
field: 'num', // 返回json数据中的name
title: '数量', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
return row.num;
}
}, {
field: 'costall', // 返回json数据中的name
title: '价格(元)', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
if (row.anticorrosiveMaterial.cost == null || row.anticorrosiveMaterial.cost == 0 || row.num == 0) {
return 0;
} else {
return (row.anticorrosiveMaterial.cost * row.num).toFixed(2);//toFixed指定保留小数点后几位数
}
}
},{
title: "操作",
align: 'center',
valign: 'middle',
width: 40, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = '';
buts += '<button class="btn btn-default btn-sm" onclick="dodel_material(\'' + row.id + '\')" data-toggle="tooltip" title="删除"><i class="fa fa fa-trash-o "></i><span class="hidden-md hidden-lg"> 删除</span></button>';
buts = '<div class = "btn-group">' + buts + '</div>';
return buts;
}
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("table_Material");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
})
$("#table_Equipment").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/maintenance/anticorrosiveLibraryEquipment/getlist.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
anticorrosiveLibraryId: '${anticorrosiveLibrary.id}',
unitId: '${anticorrosiveLibrary.unitId}'
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
responseHandler: function(res){
return res.result
},
columns: [
{
field: 'equipmentcardid', // 返回json数据中的name
title: '设备编号', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '50%',
formatter: function (value, row, index) {
return row.equipmentCard.equipmentcardid;
}
}, {
field: 'equipmentname', // 返回json数据中的name
title: '设备名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '50%',
formatter: function (value, row, index) {
return row.equipmentCard.equipmentname;
}
},
{
title: "操作",
align: 'center',
valign: 'middle',
width: 40, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = '';
buts += '<button class="btn btn-default btn-sm" onclick="dodel_equipment(\'' + row.id + '\')" data-toggle="tooltip" title="删除"><i class="fa fa fa-trash-o "></i><span class="hidden-md hidden-lg"> 删除</span></button>';
buts = '<div class = "btn-group">' + buts + '</div>';
return buts;
}
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("table_Equipment");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
})
})
//获取设备ids
function getEquipments(){
var allTableData = $("#table_Equipment").bootstrapTable('getData');
var equipmentCardIds = "";
$.each(allTableData, function (index, item) {
if (equipmentCardIds != "") {
equipmentCardIds += ",";
}
equipmentCardIds += item.equipmentCard.id;
})
$.post(ext.contextPath + '/equipment/getEquipmentCardIdsForSelect.do', {
equipmentCardIds: equipmentCardIds,
bizId: '${anticorrosiveLibrary.unitId}', processSectionId: $('#processSectionId').val()
}, function (data) {
$("#subModal_Equipment").html(data);
openModal('equipmentCardModal');
});
}
//修改设备ids
var doFinishSelectEquipmentCard = function (data) {
$.post(ext.contextPath + '/maintenance/anticorrosiveLibraryEquipment/updateEquipmentCards.do', {
anticorrosiveLibraryId: '${anticorrosiveLibrary.id}',
equipmentCardIds: data
}, function (data) {
if (data.res) {
$("#table_Equipment").bootstrapTable('refresh');
}
}, 'json');
};
//删除关联设备
function dodel_equipment(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 + '/maintenance/anticorrosiveLibraryEquipment/dodelete.do', {id : id}, function(data) {
if(data==1){
$("#table_Equipment").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
}
//获取材料ids
function getMaterials(){
var allTableData = $("#table_Material").bootstrapTable('getData');
var materialIds = "";
$.each(allTableData, function (index, item) {
if (materialIds != "") {
materialIds += ",";
}
materialIds += item.anticorrosiveMaterial.id;
})
$.post(ext.contextPath + '/maintenance/anticorrosiveMaterial/getAnticorrosiveMaterialIdsForSelect.do', {
materialIds: materialIds
}, function (data) {
$("#subModal_Equipment").html(data);
openModal('materialModal');
});
}
//修改材料ids
var doFinishSelectMaterial = function (data) {
$.post(ext.contextPath + '/maintenance/anticorrosiveLibraryMaterial/updateMaterials.do', {
anticorrosiveLibraryId: '${anticorrosiveLibrary.id}',
materialIds: data
}, function (data) {
if (data.res) {
$("#table_Material").bootstrapTable('refresh');
}
}, 'json');
};
//删除关联材料
function dodel_material(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 + '/maintenance/anticorrosiveLibraryMaterial/dodelete.do', {id : id}, function(data) {
if(data==1){
$("#table_Material").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
}
</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">&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="id" type="hidden" value="${anticorrosiveLibrary.id}" />
<input name="unitId" type="hidden" value="${anticorrosiveLibrary.unitId}" />
<div class="form-group">
<label class="col-sm-2 control-label">*项目名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="projectName" name="projectName" autocomplete="off" placeholder="项目名称" value="${anticorrosiveLibrary.projectName}">
</div>
<label class="col-sm-2 control-label">*防腐周期</label>
<div class="col-sm-4">
<select class="form-control select2" id="cycle" name="cycle">
<option value="">请选择</option>
<option value="${Maintain_Week}">一周</option>
<option value="${Maintain_TenDays}">旬</option>
<option value="${Maintain_Month}">月度</option>
<option value="${Maintain_Quarter}">季度</option>
<option value="${Maintain_HalfYear}">半年度</option>
<option value="${Maintain_Year}">年度</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*防腐方式</label>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" name="mode" id="mode1" value="${Maintain_IN}" checked> 自行防腐
</label>
<label class="radio-inline">
<input type="radio" name="mode" id="mode2" value="${Maintain_OUT}"> 委外防腐
</label>
</div>
<div id="timesDiv">
<label class="col-sm-2 control-label">*工时定额(小时)</label>
<div class="col-sm-4">
<input type="number" class="form-control" id="times" name="times" autocomplete="off" min="0" step="0.01"
placeholder="工时定额" value="${anticorrosiveLibrary.times}">
</div>
</div>
<div id="costDiv">
<label class="col-sm-2 control-label">*人工费(元)</label>
<div class="col-sm-4">
<input type="number" class="form-control" id="cost" name="cost" autocomplete="off" min="0" step="0.01"
placeholder="人工费" value="${anticorrosiveLibrary.cost}">
</div>
</div>
</div>
<div id="reasonDiv">
<div class="form-group">
<label class="col-sm-2 control-label">*委外理由说明</label>
<div class="col-sm-10">
<textarea class="form-control" id="reason" name="reason" rows="3"
placeholder="委外理由说明">${anticorrosiveLibrary.reason}</textarea>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*防腐内容</label>
<div class="col-sm-10">
<textarea class="form-control" id="contents" name="contents" rows="3"
placeholder="防腐内容">${anticorrosiveLibrary.contents}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*质量要求</label>
<div class="col-sm-10">
<textarea class="form-control" id="qualityRequirement" name="qualityRequirement" rows="3"
placeholder="质量要求">${anticorrosiveLibrary.qualityRequirement}</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="getEquipments()" class="btn btn-box-tool" data-toggle="tooltip" title="编辑"><i
class="glyphicon glyphicon-edit"></i></a>
</div>
</div>
<div class="box-body ">
<table id="table_Equipment"></table>
</div>
</div>
<!-- 材料列表 -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">使用材料</h3>
<div class="box-tools pull-right">
<a onclick="getMaterials()" class="btn btn-box-tool" data-toggle="tooltip" title="编辑"><i
class="glyphicon glyphicon-edit"></i></a>
</div>
</div>
<div class="box-body ">
<table id="table_Material"></table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" 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>