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

184 lines
7.7 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.

<!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;
}
</style>
<script type="text/javascript">
var old = '';
var key = '';
$(function () {
var key = setInterval(()=>{
//JSON序列化方式导致中文乱码
if ($('#objUserId').val()!=old){
jobList()
old = $('#objUserId').val()
}
if ($('#subModalAdd').is(':hidden')){
clearInterval(key)
}
},500)
});
function jobList() {
clearInterval(key);
$.post(ext.contextPath + "/user/getJsonJobByUser.do?userId=" + $('#objUserId').val(), function (data) {
$("#jobId").select2({
data:data,
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;
} // 函数用于呈现当前的选择
});
}, 'json');
}
function saveFun() {
//console.log($("#addForm").serialize());
$("#addForm").bootstrapValidator('validate');//提交验证
if ($("#addForm").data('bootstrapValidator').isValid()) {
//获取验证结果,如果成功,执行下面代码
// alert("调用接口前");
$.post(ext.contextPath + "/kpi/KpiPlanStaff/save.do", $("#addForm").serialize()+ "&check=1", function (data) {
// alert("接口返回码:"+data.code);
if (data.code == -1) {
showAlert('d', data.msg, 'addAlertdiv');
} else if (data.code == 0) {
showAlert('d', data.msg, 'addAlertdiv');
} else if (data.code == 2) {
swal({
text: data.creater + "已为该考核对象创建了考核方案,是否继续添加该考核对象",
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(willCreate => {
if (willCreate) {
$.post(ext.contextPath + "/kpi/KpiPlanStaff/save.do", $("#addForm").serialize() + "&check=0", function (data) {
if (data.code == 0) {
showAlert('d', '保存失败', 'addAlertdiv');
} else {
$("#table").bootstrapTable('refresh');
closeModal('subModalAdd');
}
})
}
})
} else {
// alert("走其他");
$("#table").bootstrapTable('refresh');
closeModal('subModalAdd');
}
}, 'json');
}
}
$("#addForm").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
objUserName: {
validators: {
notEmpty: {
message: '请选择用户'
}
}
},
jobId: {
validators: {
notEmpty: {
message: '状态不能为空'
}
}
}
}
});
function showUser4OneSelectFun() {
$.post(ext.contextPath + '/user/userForOneSelect.do',
{formId: "addForm", hiddenId: "objUserId", textId: "objUserName"},
function (data) {
$("#user4SelectDiv").html(data);
openModal('user4SelectModal');
});
}
</script>
<div class="modal fade" id="subModalAdd">
<div class="modal-dialog">
<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强制为addForm -->
<form class="form-horizontal" id="addForm">
<div id="alertDiv"></div>
<div id="addAlertdiv"></div>
<%-- 考核计划主键--%>
<input type="hidden" id="periodInstanceId" name="periodInstanceId" value="${periodInstanceId}" />
<input type="hidden" id="applyBizId" name="applyBizId" value="${applyBizId}" />
<input type="hidden" name="unitId" value="${unitId}" />
<!-- 界面提醒div强制id为alertdiv -->
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-3 control-label">考核对象:</label>
<div class="col-sm-9">
<input type="text" id="objUserName" name="objUserName" class="form-control"
placeholder="请输入文本" onclick="showUser4OneSelectFun();" onchange="jobList()"/>
<input type="hidden" id="objUserId" name="objUserId" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">职位:</label>
<div class="col-sm-9">
<select class="form-control" id="jobId" name="jobId"></select>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
<security:authorize buttonUrl="kpi/KpiPlanStaff/save.do">
<button type="button" class="btn btn-primary" onclick="saveFun()">保存</button>
</security:authorize>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>