236 lines
8.4 KiB
Plaintext
236 lines
8.4 KiB
Plaintext
<!DOCTYPE html
|
||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
|
||
<%request.setAttribute("UNIT_TYPE_DEPT",com.sipai.tools.CommString.UNIT_TYPE_DEPT);%>
|
||
<%request.setAttribute("Flag_Active",com.sipai.tools.CommString.Flag_Active);%>
|
||
<%request.setAttribute("Flag_Unactive",com.sipai.tools.CommString.Flag_Unactive);%>
|
||
<script type="text/javascript">
|
||
function doSaveDept() {
|
||
$("#deptAddForm").data('bootstrapValidator').resetForm();
|
||
$("#deptAddForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#deptAddForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/user/saveDept.do", $("#deptAddForm").serialize(), function (data) {
|
||
//console.log("data",data);
|
||
if (data.res == "1") {
|
||
//若是小组则添加小组权限和工艺段
|
||
//保存权限
|
||
var valrole = $('#_roles').val();
|
||
var rolestr = "";
|
||
if (valrole != null) {
|
||
$.each(valrole, function (index, value, array) {
|
||
if (rolestr != "") {
|
||
rolestr += ",";
|
||
}
|
||
rolestr += value;
|
||
});
|
||
}
|
||
$.post(ext.contextPath + "/user/updateRoleDept.do", { deptid: data.id, rolestr_new: rolestr, rolestr_old: "" }, function (data1) {
|
||
if (data1 < 0) {
|
||
showAlert('d', '权限保存失败,请至编辑页面重新保存');
|
||
}
|
||
});
|
||
|
||
//保存区域
|
||
var valarea = $('#_area').val();
|
||
var areastr = "";
|
||
if (valarea != null) {
|
||
$.each(valarea, function (index, value, array) {
|
||
if (areastr != "") {
|
||
areastr += ",";
|
||
}
|
||
areastr += value;
|
||
});
|
||
}
|
||
|
||
$.post(ext.contextPath + "/user/updateDeptArea.do", { deptid: data.id, areastr: areastr }, function (data1) {
|
||
if (data1 < 0) {
|
||
showAlert('d', '区域保存失败,请至编辑页面重新保存');
|
||
}
|
||
})
|
||
initTreeView();
|
||
} else {
|
||
showAlert('d', '保存失败');
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
|
||
$("#deptAddForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
name: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '名称不能为空'
|
||
}
|
||
}
|
||
},
|
||
_pname: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '上级不能为空'
|
||
}
|
||
}
|
||
},
|
||
morder: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '顺序不能为空'
|
||
},
|
||
regexp: {
|
||
regexp: /^[0-9]*$/,
|
||
message: '顺序必须为数字'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
var showCompanySelectFun = function () {
|
||
$.post(ext.contextPath + '/user/showCompany4Select.do', { formId: "deptAddForm", hiddenId: "pid", textId: "_pname" }, function (data) {
|
||
$("#company4SelectDiv").html(data);
|
||
openModal('company4SelectModal');//待加
|
||
});
|
||
};
|
||
|
||
var showRoleSelectFun = function () {
|
||
$.post(ext.contextPath + "/user/getJsonRoleByBizid.do", { bizid: $('#pid').val() }, function (data) {
|
||
var select = $("#_roles").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 items = new Array();
|
||
/* $.each(JSON.parse(roles),function(index,value,array){
|
||
items.put(value.id);
|
||
}); */
|
||
select.val(items).trigger("change");
|
||
}, 'json');
|
||
};
|
||
|
||
var showAreaSelectFun = function () {
|
||
$.post(ext.contextPath + "/timeEfficiency/patrolArea/getPatrolArea4Select.do", { bizId: $('#pid').val() }, function (data) {
|
||
var select = $("#_area").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 items = new Array();
|
||
/* $.each(JSON.parse(roles),function(index,value,array){
|
||
items.put(value.id);
|
||
}); */
|
||
select.val(items).trigger("change");
|
||
}, 'json');
|
||
};
|
||
|
||
|
||
$(function () {
|
||
$("#active").select2({ minimumResultsForSearch: 10 }).val("${Flag_Active}").trigger("change");
|
||
fixSelect2ToForm("active");
|
||
showRoleSelectFun();
|
||
showAreaSelectFun();
|
||
})
|
||
</script>
|
||
</head>
|
||
<div class="box box-primary">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">新增部门</h3>
|
||
|
||
<div class="box-tools pull-right">
|
||
<a onclick="doSaveDept()" class="btn btn-box-tool" data-toggle="tooltip" title="保存"><i
|
||
class="glyphicon glyphicon-floppy-disk"></i></a>
|
||
</div>
|
||
</div>
|
||
<div class="box-body ">
|
||
<form class="form-horizontal " id="deptAddForm">
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<div id="company4SelectDiv"></div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*名称</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="name" name="name" placeholder="名称" value=""
|
||
style="border-radius:4px">
|
||
</div>
|
||
<label class="col-sm-2 control-label">*上级</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="_pname" name="_pname" placeholder="上级"
|
||
onclick="showCompanySelectFun();" style="border-radius:4px;background-color: white"
|
||
value="${pname}">
|
||
<input id="pid" name="pid" type="hidden" value="${param.pid}" />
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*编号</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="code" name ="code" placeholder="编号" value="" />
|
||
</div>
|
||
</div>
|
||
<!-- <div class="form-group">
|
||
<label class="col-sm-2 control-label">简称</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="sname" name ="sname" placeholder="简称" value="" />
|
||
<input id="type" name="type" type="hidden" value="${UNIT_TYPE_DEPT}"/>
|
||
</div>
|
||
<div id="biz_id" style="display:none;">
|
||
<label class="col-sm-2 control-label">水厂编号</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="id" name ="id" placeholder="编号" value="" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">办公室</label>
|
||
<div class="col-sm-10">
|
||
<input type="text" class="form-control" id="office" name ="office" placeholder="办公室" value="">
|
||
</div>
|
||
</div>-->
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">*顺序</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="morder" name="morder" placeholder="顺序" value=""
|
||
style="border-radius:4px">
|
||
</div>
|
||
<label class="col-sm-2 control-label">启用</label>
|
||
<div class="col-sm-4">
|
||
<select id="active" name="active" class="form-control select2">
|
||
<option value="${Flag_Active}">启用</option>
|
||
<option value="${Flag_Unactive}">禁用</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="dept_unique" class="form-group">
|
||
<label class="col-sm-2 control-label">权限</label>
|
||
<div class="col-sm-4">
|
||
<select class="form-control select2" id="_roles" name="_roles">
|
||
</select>
|
||
</div>
|
||
<!-- <label class="col-sm-2 control-label">编码</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="code" name="code" placeholder="编码" value="" style="border-radius:4px">
|
||
</div> -->
|
||
<label class="col-sm-2 control-label">区域</label>
|
||
<div class="col-sm-4">
|
||
<select class="form-control select2" id="_area" name="_area">
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div> |