Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/whp/plan/WhpSamplingPlanWorkEdit.jsp
2026-01-16 14:13:44 +08:00

655 lines
25 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.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ 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" %>
<style type="text/css">
.select2-container .select2-selection--single {
height: 34px;
line-height: 34px;
}
.select2-selection__arrow {
margin-top: 3px;
}
.foot {
display: flex;
padding-left: 50px;
}
/*.layout{*/
/* display: flex;*/
/* padding-left: 15px;*/
/*}*/
.form-horizontal {
padding-top: 20px;
}
.right {
margin-left: 50px;
}
.form-checkbox {
height: 23px;
width: 23px;
display: block;
position: absolute;
margin-top: 6px;
margin-left: 13px;
z-index: 9999;
}
.table-hover > tbody > tr:hover {
cursor: pointer;
}
.input-clear-a {
color: white;
}
.input-clear-b {
color: grey;
}
.input-content:hover + .input-clear-a {
color: #d4d4d4;
}
.input-content:hover + .input-clear-b {
color: #d4d4d4;
}
.labb {
border: 1px solid gray;
padding: 5px;
border-radius: 5px;
display: block;
padding-right: 25px;
}
</style>
<script type="text/javascript">
$(function () {
conditionDropDowntype();
$("#date").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$("#reportDate").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
initTable2();
$('#table2').bootstrapTable({
onClickCell: function (field, value, row, $element) {
selectFun()
}
});
});
function showPeriodNo() {
var type = $("#type").val();
$.post(ext.contextPath + "/whp/plan/WhpSamplingPlan/periodNoList.do?typeId=" + type, function (data) {
var dataVal = []
for (var i = 0; i < data.length; i++) {
dataVal.push(data[i].text)
}
$("#dept").val(dataVal)
}, 'json');
}
function conditionDropDowntype() {
var selelct_1Data = jQuery.parseJSON('${type}');
var selelct_1 = $("#sampleTypeId").select2({
data: selelct_1Data,
cache: false,
placeholder: '全部',//默认文字提示
allowClear: true,//允许清空
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_1.val('${bean.sampleTypeId}').trigger("change");
selelct_1.on("change", function (e) {
deptChange();
tableChange();
});
// selelct_1.val(selelct_1Data[0].id).trigger("change")
}
//采样车间刷新
function deptChange() {
var type = $("#sampleTypeId").val();
$.get(ext.contextPath + "/whp/baseinfo/WhpSampleType/getOne?id=" + type, function (data) {
$("#deptIds").val(data.result.deptIds);
$("#deptNames").val(data.result.deptNames);
}, 'json');
}
//浏览列表内容刷新
function tableChange() {
$("#table2").bootstrapTable('refresh');
}
var selectChange1 = function (val, id, index) {
let values = $('.form-control-isTest').eq(index).val()
$.ajax({
url: ext.contextPath + "/whp/plan/WhpSamplingPlanTask/isTest.do?id=" + id + '&isTest=' +$('.form-control-isTest').eq(index).val(),
type: 'POST',
data: values,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
// console.log(data)
// if (data.code == 1) {
// showAlert('S', '修改成功!' + data.msg);
// } else {
// showAlert('d', '修改失败!' + data.msg);
// }
},
error: function (data) {
}
});
};
/*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 + '/whp/plan/WhpSamplingPlanTask/dodeletes.do', {ids : id}, function(data) {
if(data==1){
$("#table").bootstrapTable('refresh');
}else{
showAlert('d','删除失败','mainAlertdiv');
}
});
}
});
};
*/
function initTable2() {
var type = $("#sampleTypeId").val();
if (type == null || type === '') {
return;
}
$("#table2").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/whp/plan/WhpSamplingPlanTask/getList.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,
planCode: '${bean.code}',
planType:1 //,
//status: 0
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
//detailView: true,//父子表
columns: [
{
field: 'sampleCode', // 返回json数据中的name
title: '样品编号', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' ,// 上下居中
formatter:function(value,row,index,field){
var span=document.createElement('span');
span.setAttribute('title',"采样人:"+row.samplingUserName+"(采样时间:"+row.samplingTime.substring(0,10)+";备注:"+row.notes+")");
span.innerHTML=value;
return span.outerHTML;
}
}, {
field: 'sampleAddress', // 返回json数据中的name
title: '地点', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle'
}, {
field: 'isTest', // 返回json数据中的name
title: '是否检测', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
formatter: function (value, row, index) {
return '<select class="form-control-isTest select2" name="isTest" id="isTest\'' + index + '\'" onchange="selectChange1(\'' + value + '\',\'' + row.id + '\',' + index + ')" style="width: 69%; width: 69%;height: 30px;border-radius: 5px;border: 1px solid gray;" value="'+value+'" > ' +
'<option value="1" '+(value===true?'selected':'')+'>检测</option> <option value="0" '+ (value===false?'selected':'')+'>不检测</option>' +
'</select>'
}
}, {
field: 'isSample', // 返回json数据中的name
title: '是否采样', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
formatter:function (value,row,index) {
if (value==1)
{
return '<a class="btn btn-primary btn-sm btn-flat" onclick="editFun1(\'' + row.id + '\')">已采样</a>';
// return '<a claass="btn btn-default btn-sm" title="" onclick="editFun(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 已采样</span></>';
}else{
return '<a class="btn btn-primary btn-sm btn-flat" onclick="editFun1(\'' + row.id + '\')">未采样</a>';
/* return '<a class="btn btn-default btn-sm" title="" onclick="editFun(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 未采样</span></a>';*/
}
}
}, {
field: 'testItemJson', // 返回json数据中的name
title: '检测项目', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
formatter: function (value, row, index) {
return '<select class="form-controlSE-testItemJson select2" name="testItemJson" onchange="selectChange(\'' + value + '\',\'' + row.id + '\',' + index + ')" style="width: 100%" value=""></select>'
}
}
],
onLoadSuccess: function (data) { //加载成功时执行
adjustBootstrapTableView("table");
if(data.rows){
data.rows.forEach((row,index)=>{
var select_Data = []
try{
select_Data =JSON.parse('${whpTestItemDropDown}');
}catch (e) {
}
$('.form-controlSE-testItemJson').eq(index).select2({
data:select_Data,
cache: false,
placeholder: '请选择',//默认文字提示educationTypeCondition
allowClear: true,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
multiple: true,
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
})
console.log("row.testItemIds",row.testItemIds)
$('.form-controlSE-testItemJson').eq(index).val(row.testItemIds.split(',')).trigger("change");
$('.form-controlSE-testItemJson').eq(index).on('change',(data)=>{
let testTtemIds = $('.form-controlSE-testItemJson').eq(index).val();
$.ajax({
url: ext.contextPath + "/whp/plan/WhpSamplingPlanTask/testItems.do?id=" + row.id + '&testItemIds='+(testTtemIds?testTtemIds.join(','):''),
type: 'POST',
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
// console.log(data)
// if (data.code == 1) {
// showAlert('S', '保存成功!' + data.msg);
// } else {
// showAlert('d', '保存失败!' + data.msg);
// }
},
error: function (data) {
}
});
})
})
}
// selectFun()
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
});
}
function updateFun() {
$("#editForm").data("bootstrapValidator").updateStatus("deptNames","NOT_VALIDATED", null).validateField("deptNames");
$("#editForm").bootstrapValidator('validate');//提交验证
if ($("#editForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var formData = new FormData($("#editForm")[0]);
$.ajax({
url: ext.contextPath + "/whp/plan/WhpSamplingPlan/update.do",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
// console.log(data)
if (data.code == 1) {
$("#table").bootstrapTable('refresh');
closeModal('subModal');
} else {
showAlert('d', '保存失败!' + data.msg);
}
},
error: function (data) {
}
});
}
}
function submitFun() {
$("#editForm").data("bootstrapValidator").updateStatus("deptNames","NOT_VALIDATED", null).validateField("deptNames");
$("#editForm").bootstrapValidator('validate');//提交验证
if ($("#editForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var formData = new FormData($("#editForm")[0]);
var allrows = $("#table2").bootstrapTable('getData');
var falg=true;
for(let i=0;i<allrows.length;i++)
{
if(allrows[i].isSample==0&&allrows[i].isTest==true)
{
falg=false;
break;
}
}
if(!falg)
{
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) {
console.log("willDelete",willDelete)
if (willDelete) {
submint(formData);
}
});
}else{
submint(formData);
}
}
}
var submint=function(formData){
stopBubbleDefaultEvent();
console.log("提交")
$.ajax({
url: ext.contextPath + "/whp/plan/WhpSamplingPlan/workSubmit.do",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
if (data.code == 1) {
$("#table").bootstrapTable('refresh');
closeModal('subModal');
} else {
showAlert('d', '保存失败!' + data.msg);
}
},
error: function (data) {
}
});
}
$("#editForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
code: {
validators: {
notEmpty: {
message: '采样单编号不能为空'
}
}
},
sampleTypeId: {
validators: {
notEmpty: {
message: '采样类型不能为空'
}
}
},
date: {
trigger:"change",
validators: {
notEmpty: {
message: '计划采样日期不能为空'
}
}
},
reportDate: {
trigger:"change",
validators: {
notEmpty: {
message: '要求报告日期不能为空'
}
}
},
deptNames: {
validators: {
notEmpty: {
message: '采样车间不能为空'
}
}
}
}
});
//对Date的扩展将 Date 转化为指定格式的String
//月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
//年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
//编辑弹窗
var editFun1 = function (id) {
stopBubbleDefaultEvent();
$.post(ext.contextPath + '/whp/plan/WhpSamplingPlanTask/workEdit.do', {id: id}, function (data) {
$("#taskEidtsub").html(data);
openModal('subSampModal');
});
};
</script>
<div class="modal fade" id="subModal">
<div class="modal-dialog " style="width: 70%">
<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">
<div class="row">
<div class="col-md-12 col-xs-13">
<!-- 新增界面formid强制为editForm -->
<form class="form-horizontal" id="editForm" enctype="multipart/form-data">
<div id="alertDiv"></div>
<%-- <input type="hidden" name="id" value="${user.id }" />--%>
<!-- 界面提醒div强制id为alertdiv -->
<div class="form-group">
<label class="col-sm-2 control-label">* 采样单编号:</label>
<div class="col-sm-4">
<input type="text" name="code" id="code" class="form-control"
readonly value="${bean.code}">
<input type="hidden" name="id" id="id" class="form-control"
placeholder="" value="${bean.id}">
</div>
<label class="col-sm-2 control-label">* 采样类型:</label>
<div class="col-sm-4">
<select class="form-control" name="sampleTypeId" id="sampleTypeId" readonly
disabled="true" style="width: 100%;height: 34px">
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">* 计划采样日期:</label>
<div class="col-sm-4">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="date" name="date"
value="${bean.date.substring(0,10)} "/>
</div>
</div>
<label class="col-sm-2 control-label">* 要求报告日期:</label>
<div class="col-sm-4">
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control" id="reportDate" name="reportDate"
value="${bean.reportDate.substring(0,10)}" placeholder="请选择.."/>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label ">* 采样车间:</label>
<div class="col-sm-4 ">
<input type="text" name="deptNames" id="deptNames" class="form-control"
value="${bean.deptNames} " placeholder="">
<input type="hidden" name="deptIds" id="deptIds" class="form-control"
value="${bean.deptIds} " placeholder="">
</div>
</div>
</form>
<table id="table2"></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 " style="margin-left: 10px"
onclick="updateFun()">保存
</button>
<button type="button" class="btn btn-primary " style="margin-left: 10px"
onclick="submitFun()">提交采样
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>