Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/timeefficiency/patrolPlanEdit_Safe.jsp

1184 lines
55 KiB
Plaintext
Raw Permalink Normal View History

2026-01-16 14:13:44 +08:00
<%@ 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>
<!-- 拖拽排序-->
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-table/jquery.tablednd.js"
charset="utf-8"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/plugins/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js"
charset="utf-8"></script>
<link rel="stylesheet"
href="<%=request.getContextPath()%>/plugins/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.css"/>
<style type="text/css">
.select2-container .select2-selection--single {
height: 34px;
line-height: 34px;
}
.select2-selection__arrow {
margin-top: 3px;
}
</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_Safe.do', {
patrolPointIds: patrolPointIds,
bizId: '${patrolPlan.unitId}',
processSectionId: $('#processSectionId').val(),
patrolType: $('#patrolType').val()
}, function (data) {
$("#subDiv_PatroPoint").html(data);
openModal('patroPointModal');
});
};
var doFinishSelectPatrolPoint = function (data) {
// $.post(ext.contextPath + '/timeEfficiency/patrolPlan/updatePatrolPoints.do', {
$.post(ext.contextPath + '/timeEfficiency/patrolPoint/saveRoutePointForPlan.do', {
patrolPlanId: '${patrolPlan.id}',
patrolPointIds: data
}, function (data) {
if (data.code) {
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 doupdate() {
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);//赋值班组
}
//保存前先赋值班组
var val2 = $('#patrolAreaName').val();
var rolestr2 = "";
if (val2 != null && val2 != '') {
$.each(val2, function (index, value, array) {
if (rolestr2 != "") {
rolestr2 += ","
}
rolestr2 += value;
})
$('#patrolAreaId').val(rolestr2);//赋值班组
}
$("#subForm").bootstrapValidator('validate');//提交验证
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
var param = $("#subForm").serialize() + '&releaseModal=' + releaseModal;
$.post(ext.contextPath + "/timeEfficiency/patrolPlan/update.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: '任务内容不能为空'
}
}
}
}
});
var releaseModal = '${PatrolPlan_Daily}';//默认每日下发
$(function () {
//初始化班组
refreshSelect('${patrolPlan.groupTypeId}');
//初始化区域
refreshSelect2();
//回显最后一天勾选框
doSelectLastDay();
$('#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', '${patrolPlan.planIssuanceDate.substring(0, 10)}');
$('#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');
});
$('#colorContainer').colorpicker({format: null});
//任务类型下拉数据
$.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) {
var advanceDayStatus = $('#advanceDayStatus').val();
if (advanceDayStatus == '0') {
//第一次回显下拉自带的天数advanceDayStatus赋值成1后才可以进行修改
$('#advanceDayStatus').val('1')
} else {
$('#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;
} // 函数用于呈现当前的选择
});
//月 选择
var selelct_month = $("#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;
} // 函数用于呈现当前的选择
});
var roleitems = new Array();
var roles = JSON.parse(decodeURIComponent('${monthRegister}'));
for (var i = 0; i < roles.length; i++) {
roleitems.push(roles[i].id);
}
selelct_month.val(roleitems).trigger("change");
//年 选择
$.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;
} // 函数用于呈现当前的选择
});
var roleitems = new Array();
var roles = JSON.parse(decodeURIComponent('${yearRegister}'));
for (var i = 0; i < roles.length; i++) {
roleitems.push(roles[i].id);
}
selelct.val(roleitems).trigger("change");
}, '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_Daily}';
}
});
//下发内容初次加载器
if ("${patrolPlan.releaseModal }" == "${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}';
$("#dailyRadio").removeAttr("checked");
$("#weeklyRadio").attr("checked", "checked");
$("#monthlyRadio").removeAttr("checked");
$("#yearlyRadio").removeAttr("checked");
//周多选框
var weekItems = '${patrolPlan.weekRegister}'.split(',');
$("#weekRegister").val(weekItems).trigger("change");
} else if ("${patrolPlan.releaseModal }" == '${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}';
$("#dailyRadio").removeAttr("checked");
$("#weeklyRadio").removeAttr("checked");
$("#monthlyRadio").attr("checked", "checked");
$("#yearlyRadio").removeAttr("checked");
} else if ("${patrolPlan.releaseModal }" == '${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}';
$("#dailyRadio").removeAttr("checked");
$("#weeklyRadio").removeAttr("checked");
$("#monthlyRadio").removeAttr("checked");
$("#yearlyRadio").attr("checked", "checked");
} 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_Daily}';
$("#dailyRadio").attr("checked", "checked");
$("#monthlyRadio").removeAttr("checked");
$("#weeklyRadio").removeAttr("checked");
$("#yearlyRadio").removeAttr("checked");
}
//日期格式需对齐,不然会不准
$("#table_patrolPoint").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/timeEfficiency/patrolPoint/getPatrolPointForPlanSafe.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'client', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
planId: '${patrolPlan.id}'
}
},
responseHandler: function (res) {
return res.result
},
sortName: 'morder', // 要排序的字段
sortOrder: 'asc', // 排序规则
columns: [
{
field: 'patrolPoint.name', // 返回json数据中的name
title: '名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '30%'
},
{
field: '', // 返回json数据中的name
title: '区域', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '30%',
formatter: function (value, row, index) {
var str = '';
if (row.patrolPoint != null && row.patrolPoint.areaManage1 != null) {
str += row.patrolPoint.areaManage1.name
}
if (row.patrolPoint != null && row.patrolPoint.areaManage2 != null) {
str += ' —— ' + row.patrolPoint.areaManage2.name
}
return str;
}
},
{
field: 'equipmentNum', // 返回json数据中的name
title: '关联设备数量', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '30%'
},
{
title: "操作",
align: 'center',
valign: 'middle',
width: '10%', // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = '';
if (row.patrolPoint != null && row.patrolPoint != '') {
buts += '<button class="btn btn-default btn-sm" onclick="configureFun(\'' + row.patrolPlanId + '\',\'' + row.patrolPoint.id + '\')" data-toggle="tooltip" title="编辑"><i class="fa fa-edit "></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
}
buts += '<button class="btn btn-default btn-sm" onclick="deletePatrolPointFun(\'' + row.id + '\')" data-toggle="tooltip" title="删除"><i class="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_patrolPoint");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
},
//当拖拽结束后,整个表格的数据
onReorderRow: function (newData) {
//这里的newData是整个表格数据数组形式
console.log(newData);
$.post(ext.contextPath + '/timeEfficiency/patrolPoint/dosort.do', {jsondata: JSON.stringify(newData)},
function (data) {
if (data == 1) {
//$("#table").bootstrapTable('refresh');
} else {
showAlert('d', '数据错误', 'mainAlertdiv');
}
});
}
});
//是否去除节假日 回显
if ('${patrolPlan.isHoliday}' == 1) {
$("#isHoliday").attr("checked", true);
} else {
$("#isHoliday").attr("checked", false);
}
})
var deletePatrolPointFun = function (id) {
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 + '/timeEfficiency/patrolPoint/dodelete4PatrolPlan.do', {id: id}, function (data) {
var datastr = eval('(' + data + ')');
if (datastr.code == 1) {
$("#table_patrolPoint").bootstrapTable('refresh');
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
});
}
});
};
//弹窗配置任务内容及填报内容
function configureFun(patrolPlanId, patrolPointId) {
$.post(ext.contextPath + '/timeEfficiency/patrolPlan/configureEquipment4Safe.do', {
patrolPlanId: patrolPlanId,
patrolPointId: patrolPointId,
unitId: '${patrolPlan.unitId}'
}, function (data) {
$("#subDiv_Configure").html(data);
openModal('subModalConfigure');
});
}
// $('#subModalConfigure').on('hidden.bs.modal', function () {
// alert('1');
// });
//初始化班组
function refreshSelect(groupTypeId) {
$.post(ext.contextPath + "/work/groupDetail/getlistForSelect2.do", {
unitId: unitId,
grouptype: groupTypeId
}, function (data) {
//先清空下拉选项 避免数据叠加
$("#deptName").empty();
//加载下拉选项
var selelct = $("#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;
} // 函数用于呈现当前的选择
});
var roleitems = new Array();
var roles = JSON.parse(decodeURIComponent('${patrolPlanDept}'));
for (var i = 0; i < roles.length; i++) {
roleitems.push(roles[i].id);
}
selelct.val(roleitems).trigger("change");
}, 'json');
};
//初始化班组
function refreshSelect2() {
$.post(ext.contextPath + "/timeEfficiency/patrolArea/getPatrolArea4Select.do", {bizId: unitId}, function (data) {
console.log(data);
// $.post(ext.contextPath + "/work/groupType/getGroupTypeTree.do", {unitId: unitId}, function (data) {
var selelct = $("#patrolAreaName").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;
} // 函数用于呈现当前的选择
});
var roleitems = new Array();
var roles = JSON.parse('${patrolPlanArea}');
for (var i = 0; i < roles.length; i++) {
roleitems.push(roles[i].id);
}
selelct.val(roleitems).trigger("change");
}, 'json');
};
//勾选每月最后一天
function dolastday() {
//定义一个空数组
var arr = [];
$("input[name='lastday']:checked").each(function (i) {
//把所有被选中的复选框的值存入数组
arr[i] = $(this).val();
})
if (arr != null && arr == '${Last_Day}') {
$("#monthRegister").val('${Last_Day}');
$("#monthRegister").attr("readOnly", true);//将第几天设置为不可修改
} else {
$("#monthRegister").attr("readOnly", false);//将第几天设置为可修改
}
}
//回显最后一天勾选框
function doSelectLastDay() {
var monthRegister = $("#monthRegister").val();
if (monthRegister != null && monthRegister == '${Last_Day}') {
$("input:checkbox[value='${Last_Day}']").attr('checked', 'true');//回显复选框
$("#monthRegister").attr("readOnly", true);//将第几天设置为不可修改
}
}
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);
})
}, 'json');
//编辑风险等级评估项 信息
var doEditPatrolRiskLevel = function () {
var allTableData = $("#table_patrolRiskLevel").bootstrapTable('getData');
var riskLevelIds = "";
$.each(allTableData, function (index, item) {
if (riskLevelIds != "") {
riskLevelIds += ",";
}
riskLevelIds += item.riskLevelId;
})
$.post(ext.contextPath + '/timeEfficiency/patrolRiskLevel/showAllPatrolRiskLevelForSelect.do', {
riskLevelIds: riskLevelIds,
bizId: '${patrolPlan.unitId}'
}, function (data) {
$("#subDiv_PatroPoint").html(data);
openModal('patroRiskLevelModal'); // 跳转另一个jsp界面 选择 风险等级评估项用的 会先展示所有的26个风险等级评估项
});
};
//选择完 点击确定后 要更新已经关联的巡检点或者风险等级评估项
var doFinishSelectPatrolRiskLevel = function (data) {
$.post(ext.contextPath + '/timeEfficiency/patrolPlan/updatePatrolRiskLevels.do', {
patrolPlanId: '${patrolPlan.id}', // add的是patrolPlanId 因为是事先定好的ID
riskLevelIds: data // edit的是从后端传来的request里的patrolPlan对象的id字段
}, function (data) {
if (data.res) {
doRefreshPatrolRiskLevels();
}
}, 'json');
};
var doRefreshPatrolRiskLevels = function () {
$("#table_patrolRiskLevel").bootstrapTable('refresh');
};
// 获取 任务计划关联的风险等级评估项 的表格
$("#table_patrolRiskLevel").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/timeEfficiency/patrolRiskLevel/getRiskLevelsOfPlan.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'client', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
planId: '${patrolPlan.id}'
}
},
responseHandler: function (res) {
return res.result
},
sortName: 'morder', // id 要排序的字段
sortOrder: 'asc', // asc desc 排序规则
columns: [
{
field: 'id', // 返回json数据中的name
title: '安全项内容', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
return row.riskLevel.securitycontent;
}
}
,
{
field: 'safetyinspectionname', // 返回json数据中的name
title: '安全检测类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '25%',
formatter: function (value, row, index) {
console.log(row.riskLevel);
/*if (row.riskLevel.safetyinspection == "1")
return "实时报警";
else if (row.riskLevel.safetyinspection == "2")
return "任务超时报警";
else if (row.riskLevel.safetyinspection == "3")
return "任务不合格报警";*/
return row.riskLevel.safetyinspectionname;
}
},
{
field: 'id', // 返回json数据中的name
title: '风险等级', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '20%',
formatter: function (value, row, index) {
if (row.riskLevel.alarmLevelsConfig != null) {
return row.riskLevel.alarmLevelsConfig.level;
} else {
return '';
}
}
},
{
field: 'id', // 返回json数据中的name
title: '地点', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
width: '20%',
formatter: function (value, row, index) {
return row.riskLevel.place;
}
}
, {
title: "操作",
align: 'center',
valign: 'middle',
width: '10%', // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = '';
buts += '<button class="btn btn-default btn-sm" onclick="deletePatrolRiskLevelFun(\'' + row.planId + '\',\'' + row.riskLevel.id + '\')" data-toggle="tooltip" title="删除"><i class="fa fa-trash-o "></i><span class="hidden-md hidden-lg"> 删除</span></button>';
buts = '<div class = "btn-group">' + buts + '</div>';
return buts;
}
}
],
onLoadSuccess: function () { //加载成功时执行
console.log("table_patrolRiskLevel 加载数据成功!!!");
adjustBootstrapTableView("table_patrolRiskLevel");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
console.log("table_patrolRiskLevel 加载数据失败");
}
})
var deletePatrolRiskLevelFun = function (planid, id) {
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 + '/timeEfficiency/patrolRiskLevel/dodeleteWhenPatrolPlan.do', {
planid: planid,
id: id
}, function (data) {
var datastr = eval('(' + data + ')');
if (datastr.code == 1) {
$("#table_patrolRiskLevel").bootstrapTable('refresh');
showAlert('s', '成功删除一个关联的风险等级评估项!');
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
});
}
});
}; // deletePatrolRiskLevelFun
</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="${patrolPlan.id}"/>
<input name="type" type="hidden" value="${patrolPlan.type}"/>
<input name="unitId" type="hidden" value="${patrolPlan.unitId}"/>
<input name="patrolModelId" type="hidden" value="${patrolPlan.patrolModelId}"/>
<%--用于限制提前下发天数的回显会把字段天数给修改掉----第一次读取数据库的字段后面才可进行修改--%>
<input id="advanceDayStatus" name="advanceDayStatus" type="hidden" value="0"/>
<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" value="${patrolPlan.name}">
</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" <c:if test="${patrolPlan.active == '1'}">selected</c:if>>启用</option>
<option value="0" <c:if test="${patrolPlan.active == '0'}">selected</c:if>>停用</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" value="${patrolPlan.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"
style="border-radius:4px;" value="${patrolPlan.advanceDay}">
</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="dailyRadio"
value="${PatrolPlan_Daily}" checked> 日
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="weeklyRadio"
value="${PatrolPlan_Weekly}"> 周
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="monthlyRadio"
value="${PatrolPlan_Monthly}"> 月
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosinline" id="yearlyRadio"
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" id="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"
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"
style="border-radius:4px;" value="${patrolPlan.monthInterval}">
</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"
style="border-radius:4px;" value="${patrolPlan.yearInterval}">
</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" value="${patrolPlan.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" value="">
</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="名称">${patrolPlan.patrolContent}</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" <c:if test="${patrolPlan.isPictures == '1'}">checked</c:if>> 是
</label>
<label class="radio-inline">
<input type="radio" name="isPictures"
value="0" <c:if test="${patrolPlan.isPictures == '0'}">checked</c:if>> 否
</label>
</div>
</div>
</form>
<!-- ************************************************************************************************************ -->
<div class="box box-primary" id="RiskLevelTable">
<div class="box-header with-border">
<h3 class="box-title">关联风险等级评估项</h3>
<%--<div class="box-tools pull-right">
<a onclick="doEditPatrolRiskLevel()" class="btn btn-box-tool" data-toggle="tooltip"
title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
</div>--%>
<div class="box-tools pull-right">
<a onclick="doEditPatrolRiskLevel()" class="btn btn-box-tool" data-toggle="tooltip"
title="新增"><i class="fa fa-plus"></i></a>
<%--<a onclick="doEditPatrolRiskLevel()" class="btn btn-box-tool" data-toggle="tooltip"
title="删除"><i class="fa fa-minus"></i></a>--%>
</div>
</div>
<!-- /.box-header -->
<div class="box-body ">
<table id="table_patrolRiskLevel"></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="doEditPatrolPoint()" class="btn btn-box-tool" data-toggle="tooltip"
title="新增"><i class="fa fa-plus"></i></a>
</div>
</div>
<div class="box-body ">
<table id="table_patrolPoint"></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="doupdate()" id="btn_save">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>