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

668 lines
31 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("PatrolPlan_Weekly", com.sipai.entity.timeefficiency.TimeEfficiencyCommStr.PatrolPlan_Weekly); %>
<% request.setAttribute("PatrolPlan_Daily", com.sipai.entity.timeefficiency.TimeEfficiencyCommStr.PatrolPlan_Daily); %>
<% request.setAttribute("PatrolPlan_Monthly", com.sipai.entity.timeefficiency.TimeEfficiencyCommStr.PatrolPlan_Monthly); %>
<% request.setAttribute("PatrolPlan_Yearly", com.sipai.entity.timeefficiency.TimeEfficiencyCommStr.PatrolPlan_Yearly); %>
<% request.setAttribute("Last_Day", com.sipai.entity.timeefficiency.PatrolPlan.Last_Day); %>
<!-- 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--default .select2-selection--multiple {
height: 34px;
}
</style>
<script type="text/javascript">
//编辑用户信息
var doEditPatrolPoint = function () {
var allTableData = $("#table_patrolPoint").bootstrapTable('getData');
var patrolPointIds = "";
$.each(allTableData, function (index, item) {
if (patrolPointIds != "") {
patrolPointIds += ",";
}
patrolPointIds += item.patrolPointId;
})
$.post(ext.contextPath + '/timeEfficiency/patrolPoint/patrolPointForSelect.do', {
patrolPointIds: patrolPointIds,
bizId: '${param.bizId}', processSectionId: $('#processSectionId').val()
}, function (data) {
$("#subDiv_PatroPoint").html(data);
openModal('patroPointModal');
});
};
var doFinishSelectPatrolPoint = function (data) {
$.post(ext.contextPath + '/timeEfficiency/patrolPlan/updatePatrolPoints.do', {
patrolPlanId: '${patrolPlanId}',
patrolPointIds: data
}, function (data) {
if (data.res) {
doRefreshPatrolPoints();
}
}, 'json');
};
var doRefreshPatrolPoints = function () {
$("#table_patrolPoint").bootstrapTable('refresh');
};
function contains(arr, val) {
console.log(arr);
console.log(val);
for (var i = 0; i < arr.length; i++) {
console.log(arr[i] + '======' + val);
if (arr[i] === val) {
return true;
}
}
return false;
}
function dosave() {
var radios = document.getElementsByName('optionsRadiosinline');
var type = '';
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
type = radios[i].value;
break;
}
}
if (type == '${PatrolPlan_Weekly}') {
//不用验证
} else if (type == '${PatrolPlan_Monthly}') {
// console.log($('#planIssuanceDate').val());//2023-01-01
// console.log($('#monthRegister').val());//['2', '27']
//截取 日
var day = $('#planIssuanceDate').val().slice(8, 10);
//去除0
day = parseInt(day);
if (contains($('#monthRegister').val(), day + '')) {
//日期匹配
} else {
//日期不匹配
alert("'下次下发日期' 必须在 '每月' 所选范围内");
return;
}
} else if (type == '${PatrolPlan_Yearly}') {
// console.log($('#planIssuanceDate').val());//2023-01-01
// console.log($('#yearRegister').val());//['1.2', '11.17']
//截取 月
var month = $('#planIssuanceDate').val().slice(5, 7);
//截取 日
var day = $('#planIssuanceDate').val().slice(8, 10);
//去除0
month = parseInt(month);
//去除0
day = parseInt(day);
if (contains($('#yearRegister').val(), month + '.' + day)) {
//日期匹配
} else {
//日期不匹配
alert("'下次下发日期' 必须在 '每月' 所选范围内");
return;
}
} else {
//不用验证
}
//保存前先赋值班组
var val = $('#deptName').val();
var rolestr = "";
if (val != null && val != '') {
$.each(val, function (index, value, array) {
if (rolestr != "") {
rolestr += ","
}
rolestr += value;
})
$('#deptIds').val(rolestr);//赋值班组
}
$("#subForm").bootstrapValidator('validate');//提交验证
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var param = $("#subForm").serialize() + '&releaseModal=' + releaseModal;
$.post(ext.contextPath + "/timeEfficiency/patrolPlan/save.do", param, function (data) {
if (data.res == 1) {
closeModal('subModal')
$("#table").bootstrapTable('refresh');
} else if (data.res == 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
}
$("#subForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
name: {
validators: {
notEmpty: {
message: '任务名称不能为空'
}
}
},
taskTypeName: {
validators: {
notEmpty: {
message: '任务类型不能为空'
}
}
},
groupTypeName: {
validators: {
notEmpty: {
message: '班组类型不能为空'
}
}
},
deptName: {
validators: {
notEmpty: {
message: '任务班组不能为空'
}
}
},
patrolContent: {
validators: {
notEmpty: {
message: '任务内容不能为空'
}
}
},
planIssuanceDate: {
validators: {
notEmpty: {
message: '下次下发日期不能为空'
}
}
}
}
});
var releaseModal = '${PatrolPlan_Daily}';//默认每日下发
$(function () {
//初始化班组
refreshSelect();
$('#planIssuanceDate').datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
}).on('hide', function (e) {
$('#subForm').data('bootstrapValidator')
.updateStatus('planIssuanceDate', 'NOT_VALIDATED', null)
.validateField('planIssuanceDate');
});
<%--$('#planIssuanceDate').datepicker('setDate', '${nowDate.substring(0, 10)}');--%>
$('#planIssuanceDate').datepicker('setDate', '');
$('#colorContainer').colorpicker({format: null});
$('#sdt').timepicker({
showMeridian: false
}).on('hide', function (e) {
//当日期选择框关闭时,执行刷新校验
$('#subForm').data('bootstrapValidator')
.updateStatus('sdt', 'NOT_VALIDATED', null)
.validateField('sdt');
});
//日期格式需对齐,不然会不准
$('#edt').timepicker({
showMeridian: false
}).on('hide', function (e) {
//当日期选择框关闭时,执行刷新校验
$('#subForm').data('bootstrapValidator')
.updateStatus('edt', 'NOT_VALIDATED', null)
.validateField('edt');
});
//巡检楼层下拉数据
$.post(ext.contextPath + "/timeEfficiency/patrolArea/getPatrolArea4Select.do", {bizId: '${param.bizId}'}, function (data) {
var selelct = $("#patrolAreaId").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;
} // 函数用于呈现当前的选择
});
fixSelect2ToForm('patrolAreaId')
}, 'json');
//任务类型下拉数据
$.post(ext.contextPath + "/timeEfficiency/PatrolType/getType4Select.do", {bizId: '${param.bizId}'}, function (data) {
var selelct = $("#taskTypeName").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.on('change', function (e) {
$('#taskType').val(e.target.value);
//后台转化为天
$.post(ext.contextPath + "/timeEfficiency/PatrolType/countDay.do", {id: e.target.value}, function (data) {
$('#advanceDay').val(data);
})
});
selelct.val('${patrolPlan.taskType}').trigger("change");
fixSelect2ToForm('taskTypeName')
}, 'json');
//周 选择
$("#weekRegister").select2({
placeholder: '请选择',//默认文字提示
allowClear: true,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
minimumResultsForSearch: 10,//数据超过十个启用搜索框
multiple: true,
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
//月 选择
$("#monthRegister").select2({
placeholder: '请选择',//默认文字提示
allowClear: true,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
minimumResultsForSearch: 10,//数据超过十个启用搜索框
multiple: true,
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
//年 选择
$.post(ext.contextPath + "/timeEfficiency/patrolPlan/getYearRegisterSelect.do", {}, function (data) {
var selelct = $("#yearRegister").select2({
data: data,
placeholder: '请选择',//默认文字提示
allowClear: false,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
// level: 1,
minimumResultsForSearch: 10,//数据超过十个启用搜索框
multiple: true,
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
}, 'json');
document.getElementById('weekDiv').style.display = 'none';
document.getElementById('monthDiv').style.display = 'none';
document.getElementById('monthDiv2').style.display = 'none';
document.getElementById('yearDiv').style.display = 'none';
document.getElementById('yearDiv2').style.display = 'none';
document.getElementById('viewType2').style.display = 'none';
$('input[type=radio][name=optionsRadiosinline]').change(function () {
if (this.value == '${PatrolPlan_Weekly}') {
document.getElementById('weekDiv').style.display = 'block';
document.getElementById('monthDiv').style.display = 'none';
document.getElementById('monthDiv2').style.display = 'none';
document.getElementById('yearDiv').style.display = 'none';
document.getElementById('yearDiv2').style.display = 'none';
document.getElementById('viewType1').style.display = 'block';
document.getElementById('viewType2').style.display = 'none';
releaseModal = '${PatrolPlan_Weekly}';
} else if (this.value == '${PatrolPlan_Monthly}') {
document.getElementById('weekDiv').style.display = 'none';
document.getElementById('monthDiv').style.display = 'block';
document.getElementById('monthDiv2').style.display = 'block';
document.getElementById('yearDiv').style.display = 'none';
document.getElementById('yearDiv2').style.display = 'none';
document.getElementById('viewType1').style.display = 'none';
document.getElementById('viewType2').style.display = 'block';
releaseModal = '${PatrolPlan_Monthly}';
} else if (this.value == '${PatrolPlan_Yearly}') {
document.getElementById('weekDiv').style.display = 'none';
document.getElementById('monthDiv').style.display = 'none';
document.getElementById('monthDiv2').style.display = 'none';
document.getElementById('yearDiv').style.display = 'block';
document.getElementById('yearDiv2').style.display = 'block';
document.getElementById('viewType1').style.display = 'none';
document.getElementById('viewType2').style.display = 'block';
releaseModal = '${PatrolPlan_Yearly}';
} else {
document.getElementById('weekDiv').style.display = 'none';
document.getElementById('monthDiv').style.display = 'none';
document.getElementById('monthDiv2').style.display = 'none';
document.getElementById('yearDiv').style.display = 'none';
document.getElementById('yearDiv2').style.display = 'none';
document.getElementById('viewType1').style.display = 'block';
document.getElementById('viewType2').style.display = 'none';
releaseModal = '${PatrolPlan_Monthly}';
}
});
})
//初始化 - 班组类型
var selectType = $("#sheetName").select2({minimumResultsForSearch: 10});
$.post(ext.contextPath + "/work/groupType/getGroupTypeTree.do", {unitId: unitId}, function (data) {
$("#groupTypeName").empty();
var selelct_ = $("#groupTypeName").select2({
data: data,
placeholder: '请选择',//默认文字提示
allowClear: false,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
minimumResultsForSearch: 5,//数据超过5个启用搜索框
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
selelct_.val('${patrolPlan.groupTypeId}').trigger("change");
selelct_.on('change', function (e) {
$('#groupTypeId').val(e.target.value);
$('#deptIds').val('');
// $('#deptName').val('');
refreshSelect(e.target.value);
})
fixSelect2ToForm('groupTypeName')
}, 'json');
//初始化 - 任务班组 (带id查询)
function refreshSelect(groupTypeId) {
//先清空下拉选项 避免数据叠加
$("#deptName").empty();
$.post(ext.contextPath + "/work/groupDetail/getlistForSelect2.do", {
unitId: unitId,
grouptype: groupTypeId
}, function (data) {
//先清空下拉选项 避免数据叠加
// $("#deptName").empty();
//加载下拉选项
var selelct2 = $("#deptName").select2({
data: data,
placeholder: '请选择',//默认文字提示
allowClear: false,//允许清空
escapeMarkup: function (markup) {
return markup;
}, // 自定义格式化防止xss注入
language: "zh-CN",
minimumInputLength: 0,
minimumResultsForSearch: 10,//数据超过十个启用搜索框
multiple: true,
formatResult: function formatRepo(repo) {
return repo.text;
}, // 函数用来渲染结果
formatSelection: function formatRepoSelection(repo) {
return repo.text;
} // 函数用于呈现当前的选择
});
// fixSelect2ToForm('deptName');
}, 'json');
};
</script>
<div class="modal fade" id="subModal">
<div class="modal-dialog modal-lg">
<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>
<div class="form-group">
<input name="id" type="hidden" value="${patrolPlanId}"/>
<input name="type" type="hidden" value="${param.type}"/>
<input name="unitId" type="hidden" value="${param.bizId}"/>
<input name="patrolModelId" type="hidden" value="${param.patrolModelId}"/>
<label class="col-sm-2 control-label">*任务名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="name" name="name" placeholder="名称"
autocomplete="off">
</div>
<label class="col-sm-2 control-label">启用状态</label>
<div class="col-sm-4">
<select class="form-control select2" id="active" name="active">
<option value="1">启用</option>
<option value="0">停用</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*任务类型</label>
<div class="col-sm-4">
<select class="form-control select2" id="taskTypeName" name="taskTypeName"
style="width: 100%;">
</select>
<input type="hidden" name="taskType" id="taskType">
</div>
<label class="col-sm-2 control-label">提前下发天数</label>
<div class="col-sm-4">
<input type="number" class="form-control" id="advanceDay" name="advanceDay"
placeholder="提前下发天数" min="0"
value="0" style="border-radius:4px;">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">任务周期</label>
<div class="col-sm-4">
<div id="radioDiv">
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="optionsRadios1"
value="${PatrolPlan_Daily}" checked> 日
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="optionsRadios2"
value="${PatrolPlan_Weekly}"> 周
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="optionsRadios3"
value="${PatrolPlan_Monthly}"> 月
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="optionsRadios4"
value="${PatrolPlan_Yearly}"> 年
</label>
</div>
</div>
<div id="viewType1">
<label class="col-sm-2 control-label">节假日</label>
<div class="col-sm-4">
<label class="radio-inline">
<input type="checkbox" name="isHoliday" value="1"> 去除
</label>
</div>
</div>
<div id="viewType2">
<label class="col-sm-2 control-label">*下次下发日期</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="planIssuanceDate" name="planIssuanceDate" autocomplete="off"
style="width: 232px;">
</div>
</div>
</div>
<!--每周下发方式-->
<div class="form-group" id="weekDiv"
style="border-radius:4px;border:2px solid cadetblue;padding-top:4px;padding-bottom:4px;margin-left:4px;margin-right:4px">
<label class="col-sm-2 control-label">在</label>
<div class="col-sm-8">
<select class="form-control select2" id="weekRegister" name="weekRegister"
style="width:260px;">
<option value="2">周一</option>
<option value="3">周二</option>
<option value="4">周三</option>
<option value="5">周四</option>
<option value="6">周五</option>
<option value="7">周六</option>
<option value="1">周日</option>
</select>
<label class="control-label">按住ctrl多选</label>
</div>
</div>
<!--每月下发方式-->
<div class="form-group" id="monthDiv"
style="border-radius:4px;border:2px solid rgb(204, 155, 20);padding-top:4px;padding-bottom:4px;margin-left:4px;margin-right:4px">
<label class="col-sm-2 control-label">周期</label>
<div class="col-sm-2">
<input type="number" class="form-control" id="monthInterval" name="monthInterval"
placeholder="间隔" min="1" oninput="if(value<1)value=1"
value="1" style="border-radius:4px;">
</div>
<div class="col-sm-4">
<p class="form-control-static">月</p>
</div>
</div>
<div class="form-group" id="monthDiv2"
style="border-radius:4px;border:2px solid rgb(204, 155, 20);padding-top:4px;padding-bottom:4px;margin-left:4px;margin-right:4px">
<label class="col-sm-2 control-label">每月</label>
<div class="col-sm-10">
<select class="form-control select2" id="monthRegister" name="monthRegister"
style="width:100%;">
<c:forEach var="i" begin="1" end="31">
<option value="${i}">${i}日</option>
</c:forEach>
</select>
<label class="control-label">按住ctrl多选</label>
</div>
</div>
<!--每年下发方式-->
<div class="form-group" id="yearDiv"
style="border-radius:4px;border:2px solid rgb(204, 155, 20);padding-top:4px;padding-bottom:4px;margin-left:4px;margin-right:4px">
<label class="col-sm-2 control-label">周期</label>
<div class="col-sm-2">
<input type="number" class="form-control" id="yearInterval" name="yearInterval"
placeholder="间隔" min="1" oninput="if(value<1)value=1"
value="1" style="border-radius:4px;">
</div>
<div class="col-sm-4">
<p class="form-control-static">年</p>
</div>
</div>
<div class="form-group" id="yearDiv2"
style="border-radius:4px;border:2px solid rgb(204, 155, 20);padding-top:4px;padding-bottom:4px;margin-left:4px;margin-right:4px">
<label class="col-sm-2 control-label">每年</label>
<div class="col-sm-10">
<select class="form-control select2" id="yearRegister" name="yearRegister"
style="width:100%;">
</select>
<label class="control-label">按住ctrl多选</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*班组类型</label>
<div class="col-sm-4">
<select class="form-control select2" id="groupTypeName" name="groupTypeName"
style="width: 100%;">
</select>
<input type="hidden" name="groupTypeId" id="groupTypeId">
</div>
<label class="col-sm-2 control-label">*任务班组</label>
<div class="col-sm-4">
<select class="form-control select2" id="deptName" name="deptName"
style="width: 100%;">
</select>
<input type="hidden" name="deptIds" id="deptIds">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">*任务内容</label>
<div class="col-sm-10">
<textarea class="form-control" id="patrolContent" name="patrolContent" rows="3"
placeholder="名称"></textarea>
</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="isPictures"
value="1" checked> 是
</label>
<label class="radio-inline">
<input type="radio" name="isPictures"
value="0"> 否
</label>
</div>
</div>
</form>
</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>