Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/whp/plan/WhpSamplingPlanAdd.jsp

461 lines
17 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<!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;
}
.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-content:hover + .input-clear-a {
color: #d4d4d4;
}
.table-hover > tbody > tr:hover {
cursor: pointer;
}
.input-clear-a {
color: white;
}
.input-content:hover + .input-clear-a {
color: #d4d4d4;
}
.labb::after{
width: 10px;
height: 10px;
background: red;
}
.labb {
border: 1px solid gray;
padding: 5px;
border-radius: 5px;
}
</style>
<script type="text/javascript">
$(function () {
initTime()
$('#AutomaticTime').val('');
//计划采样日期
$("#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',
});
conditionDropDowntype()
initTable2()
});
//浏览列表内容刷新
function tableChange() {
$("#tableFun").bootstrapTable('refresh');
}
//采样车间刷新
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 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('').trigger("change");
selelct_1.on("change", function (e) {
deptChange();
tableChange();
});
selelct_1.val(selelct_1Data[0].id).trigger("change")
}
function saveFun() {
$("#addForm").data("bootstrapValidator").updateStatus("deptNames","NOT_VALIDATED", null).validateField("deptNames");
$("#addForm").bootstrapValidator('validate');//提交验证
if ($("#addForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var formData = new FormData($("#addForm")[0]);
$.ajax({
url: ext.contextPath + "/whp/plan/WhpSamplingPlan/save.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) {
}
});
}
}
$("#addForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
sampleTypeId: {
validators: {
notEmpty: {
message: '采样类型不能为空'
}
}
},
deptNames: {
validators: {
notEmpty: {
message: '采样车间不能为空'
}
}
},
date: {
trigger:"change",
validators: {
notEmpty: {
message: '计划采样日期不能为空'
}
}
},
reportDate: {
trigger:"change",
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;
}
function initTime() {
var locale = {
"format": 'YYYY-MM-DD',
"separator": " ~ ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "起始时间",
"toLabel": "结束时间'",
"customRangeLabel": "自定义",
"weekLabel": "W",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
};
var oldreservationtime1 = "${param.oldreservationtime1}";
if (oldreservationtime1 != "" && oldreservationtime1.length > 0) {
strDate = oldreservationtime1.substring(0, 16);
endDate = oldreservationtime1.substring(19, 36);
$('#AutomaticTime').val(oldreservationtime1);
} else {
strDate = moment().subtract(3, 'days').format('YYYY-MM-DD HH:mm');
endDate = moment().subtract(0, 'days').format('YYYY-MM-DD HH:mm');
$('#AutomaticTime').val(strDate + locale.separator + endDate);
}
$('#AutomaticTime').daterangepicker({
"timePicker": true,
"timePicker24Hour": true,
"linkedCalendars": false,
"autoUpdateInput": false,
"timePickerIncrement": 10,
"locale": locale,
//汉化按钮部分
// ranges: {
// // '今日': [moment(), moment().subtract(-1, 'days')],
// '昨日': [moment().subtract(1, 'days'), moment()],
// '最近7日': [moment().subtract(6, 'days'), moment().subtract(-1, 'days')],
// '本月': [moment().startOf('month'), moment().endOf('month').subtract(-1, 'days')],
// '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month').subtract(-1, 'days')]
// },
startDate: strDate,
endDate: endDate
}, function (start, end, label) {
strDate = start.format(this.locale.format);
endDate = end.format(this.locale.format);
if (!this.startDate) {
this.element.val('');
} else {
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
}
});
};
var datedel = function () {
$('#AutomaticTime').val('');
strDate = null;
endDate = null;
};
function initTable2() {
var type = $("#sampleTypeId").val();
if (type == null || type === '') {
return;
}
$("#tableFun").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/whp/baseinfo/WhpSampleCode/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,
typeId: $("#sampleTypeId").val(),
status: 1
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
//detailView: true,//父子表
columns: [
{
field: 'sampleTypeName', // 返回json数据中的name
title: '样品类别', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'prefix', // 返回json数据中的name
title: '前缀', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'address', // 返回json数据中的name
title: '地点', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle'
}, {
field: 'addressCode', // 返回json数据中的name
title: '地点编号', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle'
}, {
field: 'isTest', // 返回json数据中的name
title: '是否检测', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
formatter: function (value, row, index) {
if (value == true) {
return '检测';
} else {
return '不检测';
}
}
}, {
field: 'testItemNames', // 返回json数据中的name
title: '检测项目', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},
{
field: 'deptNames', // 返回json数据中的name
title: '采样车间', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("table");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
});
}
function timedelete() {
}
</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强制为addForm -->
<form class="form-horizontal" id="addForm" 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">
<select class="form-control" name="sampleTypeId" id="sampleTypeId"
style="width: 100%">
</select>
</div>
<%-- <label class="col-sm-2 control-label">* 采样车间:</label>--%>
<%-- <div class="col-sm-4">--%>
<%-- <input type="text" name="deptNames" id="deptNames" class="form-control"--%>
<%-- placeholder="">--%>
<%-- <input type="hidden" name="deptIds" id="deptIds" class="form-control"--%>
<%-- placeholder="">--%>
<%-- </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"
placeholder="请选择.." autocomplete="off"/>
</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"
placeholder="请选择.." autocomplete="off"/>
</div>
</div>
</div>
</form>
<table id="tableFun"></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="saveFun()">保存
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>