Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/work/schedulingAdd.jsp

312 lines
14 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8" %>
<script type="text/javascript">
// var showUser4SelectsFun = function () {
// var userIds = $("#schedulingAddModal #userids").val();
// $.post(ext.contextPath + '/user/userForSelect.do', { formId: "schedulingAddModal #subForm", hiddenId: "userids", textId: "username", userIds: userIds, companyId: unitId }, function (data) {
// $("#user4SelectDiv").html(data);
// openModal('user4SelectModal');
// });
// };
//处理月份添加函数date当前日期num增加的月份【正数增加月份负数减少月份】
function addMonth(date, num) {
num = parseInt(num);
var sDate = dateToDate(date);
var sYear = sDate.getFullYear();
var sMonth = sDate.getMonth() + 1;
var sDay = sDate.getDate();
var eYear = sYear;
var eMonth = sMonth + num;
var eDay = sDay;
while (eMonth > 12) {
eYear++;
eMonth -= 12;
}
var eDate = new Date(eYear, eMonth - 1, eDay);
while (eDate.getMonth() != eMonth - 1) {
eDay--;
eDate = new Date(eYear, eMonth - 1, eDay);
}
return eDate;
};
function dateToDate(date) {
var sDate = new Date();
if (typeof date == 'object'
&& typeof new Date().getMonth == "function"
) {
sDate = date;
} else if (typeof date == "string") {
var arr = date.split('-')
if (arr.length == 3) {
sDate = new Date(arr[0] + '-' + arr[1] + '-' + arr[2]);
}
}
return sDate;
};
function dosave() {
$("#subForm").data('bootstrapValidator').resetForm();//清除当前验证的关键之处
$("#subForm").bootstrapValidator('validate');//提交验证
//console.log($("#subForm").data('bootstrapValidator').isValid());
if ($("#subForm").data('bootstrapValidator').isValid()) {
var parameter = $("#schedulingAddModal #subForm").serialize() + "&bizid=" + unitId
+ "&schedulingtype=" + $("#grouptype").val() + "&date=" + "${date}"
+ "&repeat=" + $('#repeat').bootstrapSwitch('state');
//console.log(parameter);
$.post(ext.contextPath + '/work/scheduling/save.do', parameter, function (data) {
if (data.res > 0) {
closeModal('schedulingAddModal');
showAlert('s', '新增' + data.res + '条排班记录');
$("#table").bootstrapTable('refresh');
doReloadCalendar();
} else if (data.res <= 0) {
showAlert('d', '保存失败');
} else {
showAlert('d', data.res);
}
}, 'json');
}
}
//验证
$("#subForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
feedbackIcons: {/*输入框不同状态,显示图片的样式*/
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
repeatInterval: {
validators: {
regexp: {//正则验证
regexp: "^([1-9]\d*|[0]{1,1})$",
message: '请输入自然数'
}
}
},
groupdetailId: {
validators: {
notEmpty: {
message: '值班班组不能为空'
}
}
}
}
});
$(function () {
//隐藏重复
document.getElementById('repeatIntervalDiv').style.display = "none";
document.getElementById('repeatEddtDiv').style.display = "none";
//重复截至日期
$("#repeatEddt").datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
})
$("#repeatEddt").datepicker('setDate', addMonth(${ date }, 1));
//重复开关
$('#repeat').bootstrapSwitch({
onText: '是',
offText: '否',
size: "small",
onSwitchChange: function (event, state) {
if (state == true) {
//是
document.getElementById('repeatIntervalDiv').style.display = "block";
document.getElementById('repeatEddtDiv').style.display = "block";
} else {
//否
document.getElementById('repeatIntervalDiv').style.display = "none";
document.getElementById('repeatEddtDiv').style.display = "none";
}
}
});
//班次类型select2
$.post(ext.contextPath + "/work/groupTime/getlistForSelect2.do", {
unitId: unitId,
grouptype: '${param.grouptype}'
}, function (data) {
//console.log("sdata", data);
var selectGroupManage = $("#schedulingAddModal #groupmanageid").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;
} // 函数用于呈现当前的选择
});
$("#groupmanageid").on("select2:select", function (e) {
//doReloadCalendar();
});
$(".select2-selection--single").css({'height': '30px', 'paddingTop': '4px'});//选中元素上下居中
if (data.length != 0) {
selectGroupManage.val(data[0].id).trigger("change");//设置选中
} else {
selectGroupManage.val("").trigger("change");//设置选中
}
}, 'json');
//值班班组select2
$.post(ext.contextPath + "/work/groupDetail/getlistForSelect2.do", {
grouptype: '${param.grouptype}',
unitId: unitId
}, function (data) {
// console.log("data", data);
var selectGroupDetail = $("#schedulingAddModal #groupdetailId").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;
} // 函数用于呈现当前的选择
});
$("#groupdetailId").on("select2:select", function (e) {
//doReloadCalendar();
});
$(".select2-selection--single").css({'height': '30px', 'paddingTop': '4px'});//选中元素上下居中
if (data.length != 0) {
selectGroupDetail.val(data[0].id).trigger("change");//设置选中
} else {
selectGroupDetail.val("").trigger("change");//设置选中
}
}, 'json');
//巡检模式
$.post(ext.contextPath + "/timeEfficiency/patrolModel/getPatrolModelList4Select3.do", {
type: '${param.patroltype}',
bizId: unitId
}, function (data) {
var selectpatrolmode_add = $("#schedulingAddModal #patrolmode").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;
} // 函数用于呈现当前的选择
});
// $("#patrolmode").on("select2:select", function (e) {
// //doReloadCalendar();
// });
$(".select2-selection--single").css({'height': '30px', 'paddingTop': '4px'});//选中元素上下居中
if (data.length != 0) {
selectpatrolmode_add.val(data[0].id).trigger("change");//设置选中
} else {
selectpatrolmode_add.val("").trigger("change");//设置选中
}
}, 'json');
})
</script>
<div class="modal fade" id="schedulingAddModal">
<div class="modal-dialog" style="height:500px;">
<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">
<label class="col-sm-2 control-label">班次</label>
<div class="col-sm-4">
<select class="form-control select2 " id="groupmanageid" name="groupmanageid"
style="width: 170px;"></select>
</div>
<label class="col-sm-2 control-label">巡检模式</label>
<div class="col-sm-4">
<select class="form-control select2 " id="patrolmode" name="patrolmode"
style="width: 170px;"></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span style="color:#FE0000">*</span>值班班组</label>
<div class="col-sm-10">
<select class="form-control select2 " id="groupdetailId" name="groupdetailId"
style="width:100%;" multiple="multiple"></select>
<%-- <textarea type="text" class="form-control" id="username" name="username" placeholder="值班人员"--%>
<%-- onclick="showUser4SelectsFun();" row="15" style="border-radius: 4px;"></textarea>--%>
<%-- <input id="userids" name="userids" type="hidden" value="" />--%>
</div>
</div>
<div class="form-group" style="height:34px">
<label class="col-sm-2 control-label">重复排班</label>
<div class="col-sm-10">
<div class="switch" data-on="primary" data-off="info">
<input id="repeat" type="checkbox"/>
</div>
</div>
</div>
<div class="form-group" id="repeatIntervalDiv">
<label class="col-sm-2 control-label">重复周期</label>
<div class="col-sm-3">
<input id="repeatInterval" type="number" min="0" value="1" name="repeatInterval"
class="form-control"
style="border-radius: 4px;"/>
</div>
</div>
<div class="form-group" id="repeatEddtDiv">
<label class="col-sm-2 control-label">截至时间</label>
<div class="col-sm-3">
<input id="repeatEddt" name="repeatEddt" type="text" class="form-control"
style="border-radius: 4px;background-color: white" readonly="readonly"/>
</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()">保存</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>