2025-11-27 16:55:35 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
<html lang="en-us" id="extr-page">
|
|
|
|
|
|
<head>
|
2025-12-15 15:23:57 +08:00
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
|
|
|
|
|
|
<link rel="stylesheet" href="../../css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
|
|
|
|
|
|
<link rel="stylesheet" href="../../css/ztree/demo.css" type="text/css">
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../layui/css/layui.css">
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap-select.min.css">
|
2025-11-27 16:55:35 +08:00
|
|
|
|
</head>
|
|
|
|
|
|
<style>
|
2025-12-15 15:23:57 +08:00
|
|
|
|
.switch {
|
|
|
|
|
|
width: 60px;
|
|
|
|
|
|
height: 34px;
|
|
|
|
|
|
margin-left: 1%;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#checkInput {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.round {
|
|
|
|
|
|
border-radius: 24px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slider {
|
|
|
|
|
|
background-color: red;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
transition: all .4s;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#sPan {
|
|
|
|
|
|
margin-top: 0.4%;
|
|
|
|
|
|
margin-left: 5%;
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slider:after {
|
|
|
|
|
|
content: '';
|
|
|
|
|
|
width: 26px;
|
|
|
|
|
|
height: 26px;
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 4px;
|
|
|
|
|
|
left: 4px;
|
|
|
|
|
|
transition: all .4s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#checkInput:checked + .slider {
|
|
|
|
|
|
background: #70B603;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#checkInput:checked + .slider:after {
|
|
|
|
|
|
transform: translateX(26px);
|
|
|
|
|
|
}
|
2025-11-27 16:55:35 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<body>
|
2025-12-15 15:23:57 +08:00
|
|
|
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="padding: 0 24px 0 24px;">
|
|
|
|
|
|
<form class="form-horizontal" onsubmit="return false" id="form">
|
|
|
|
|
|
<fieldset>
|
|
|
|
|
|
<input type="hidden" id="id" name="id">
|
|
|
|
|
|
<!--<div class="form-group">-->
|
|
|
|
|
|
<!--<label class="col-md-2 control-label">公司名称</label>-->
|
|
|
|
|
|
<!--<div class="col-md-10">-->
|
|
|
|
|
|
<!--<input class="form-control" placeholder="公司名称" type="text" name="companyName" id="companyName"-->
|
|
|
|
|
|
<!--data-bv-notempty="true"-->
|
|
|
|
|
|
<!--data-bv-notempty-message="公司名称 不能为空">-->
|
|
|
|
|
|
<!--</div>-->
|
|
|
|
|
|
<!--</div>-->
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label"><i class="tip-required" style="color: red; font-size: 20px">*</i>公司名称</label>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
|
<select id="orgId" name="companyId" class="form-control selectpicker show-tick"
|
|
|
|
|
|
data-live-search="true"
|
|
|
|
|
|
data-bv-notempty="true" data-bv-notempty-message="公司名称不能为空"></select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label"><i class="tip-required" style="color: red; font-size: 20px">*</i>角色名称</label>
|
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
|
<input class="form-control" placeholder="角色" type="text" name="name" id="name"
|
|
|
|
|
|
data-bv-notempty="true"
|
|
|
|
|
|
data-bv-notempty-message="角色名称 不能为空">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<label id="roleLevelName" class="col-md-2 control-label"
|
|
|
|
|
|
style="color: red; margin-left: 11%;width: auto;"></label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label"><i class="tip-required" style="color: red; font-size: 20px">*</i>角色级别</label>
|
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
|
<select name="roleLevel" id="roleLevel" class="form-control layui-select">
|
|
|
|
|
|
<option value="1">公司级</option>
|
|
|
|
|
|
<option value="2">分公司级</option>
|
|
|
|
|
|
<option value="3">项目部级</option>
|
|
|
|
|
|
<option value="4">分包商级</option>
|
|
|
|
|
|
<option value="5">施工人员级</option>
|
|
|
|
|
|
<option value="6">总部</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label"><i class="tip-required" style="color: red; font-size: 20px">*</i>注册启用</label>
|
|
|
|
|
|
<label class="switch">
|
|
|
|
|
|
<input id="checkInput" type="checkbox"/>
|
|
|
|
|
|
<div id="btnCheck" class="slider round"></div>
|
|
|
|
|
|
<span id="sPan" style="color: red">*开启:用户注册可以选择该角色,关闭:不可选择</span>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label"><i class="tip-required" style="color: red; font-size: 20px">*</i>权限类型</label>
|
|
|
|
|
|
<div class="col-md-10" style="margin-top: 0.5%;" id="types">
|
|
|
|
|
|
<input required lay-verify="required" type="checkbox" value="1"
|
|
|
|
|
|
name="permissionType"><label>大屏</label>
|
|
|
|
|
|
<input required lay-verify="required" type="checkbox" value="2"
|
|
|
|
|
|
name="permissionType"><label>后台</label>
|
|
|
|
|
|
<input required lay-verify="required" type="checkbox" id="work" value="3"
|
|
|
|
|
|
name="permissionType"><label>施工</label>
|
|
|
|
|
|
<input required lay-verify="required" type="checkbox" id="sup" value="4"
|
|
|
|
|
|
name="permissionType"><label>监督</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label">描述</label>
|
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
|
<textarea class="form-control" placeholder="描述" name="description" id="description"></textarea>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
|
<label class="col-md-2 control-label">权限</label>
|
|
|
|
|
|
<div class="col-md-10">
|
|
|
|
|
|
<ul id="treeDemo" class="ztree"></ul>
|
|
|
|
|
|
<ul id="treeAppDemo" class="ztree"></ul>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-actions">
|
|
|
|
|
|
<div class="row" align="center">
|
|
|
|
|
|
<div class="col-md-12">
|
|
|
|
|
|
<button class="btn btn-primary" onclick="cancel()">返回</button>
|
|
|
|
|
|
<button class="btn btn-primary" permission="sys:role:add" type="submit" onclick="add()">
|
|
|
|
|
|
保存
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
</form>
|
2025-11-27 16:55:35 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-15 15:23:57 +08:00
|
|
|
|
<script type="text/javascript" src="../../js/libs/jquery-3.7.1.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/jq.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/common.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../layui/layui.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/libs/jquery.ztree.all-3.5.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/my/ztree-menu.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../../public/public.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/publicJs.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/bootstrap/bootstrap.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript" src="../../js/bootstrap/bootstrap-select.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
$('#orgId').selectpicker({
|
|
|
|
|
|
'selectedText': 'cat'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(".selectpicker").selectpicker({
|
|
|
|
|
|
noneSelectedText: '请选择'//默认显示内容
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
layui.use(['layer', 'laydate', 'form'], function () {
|
|
|
|
|
|
var layer = layui.layer;
|
|
|
|
|
|
var form = layui.form;
|
|
|
|
|
|
$("#roleLevel").change(function () {
|
|
|
|
|
|
var opt = $("#roleLevel").val();
|
|
|
|
|
|
if (opt == 5 || opt == "5") {
|
|
|
|
|
|
document.getElementById("roleLevelName").innerText = "“角色名称”请填写“班组长”或“施工人员”";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
document.getElementById("roleLevelName").innerText = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#work").change(function () {
|
|
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
|
|
$('#sup').attr("disabled", 'disabled');
|
|
|
|
|
|
$("#pro-tip").css("display", "inline-block");
|
|
|
|
|
|
isRequired = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$("#pro-tip").css("display", "none");
|
|
|
|
|
|
$('#sup').removeAttr("disabled").prop();
|
|
|
|
|
|
isRequired = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
});
|
|
|
|
|
|
$("#sup").change(function () {
|
|
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
|
|
$('#work').attr("disabled", 'disabled');
|
|
|
|
|
|
$("#pro-tip").css("display", "inline-block");
|
|
|
|
|
|
isRequired = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$("#pro-tip").css("display", "none");
|
|
|
|
|
|
$('#work').removeAttr("disabled").prop();
|
|
|
|
|
|
isRequired = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
});
|
|
|
|
|
|
getOrg(form);
|
|
|
|
|
|
initData(form);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.zTree.init($("#treeDemo"), getSettting(), getMenuBackTree());
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.zTree.init($("#treeAppDemo"), getSettting(), getMenuAppTree());
|
|
|
|
|
|
|
|
|
|
|
|
function initData(form) {
|
|
|
|
|
|
var id = localStorage.getItem("roleId");
|
|
|
|
|
|
if (id != "") {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
url: smz_ht_url + '/roles/' + id,
|
|
|
|
|
|
async: false,
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
//$("#companyName").val(data.companyName);
|
|
|
|
|
|
$("#id").val(data.id);
|
|
|
|
|
|
$("#name").val(data.name);
|
|
|
|
|
|
$("#description").val(data.description);
|
|
|
|
|
|
$("#roleLevel").find('option[value=\'' + data.roleLevel + '\']').prop("selected", "selected");
|
|
|
|
|
|
checkFindData(data.status);
|
|
|
|
|
|
selectedTypes(data.type);
|
|
|
|
|
|
console.log(data.companyId);
|
|
|
|
|
|
var company = data.companyId;
|
|
|
|
|
|
//getOrg(form);
|
|
|
|
|
|
|
|
|
|
|
|
//$("#orgId").val(company);
|
|
|
|
|
|
//form.render('select');
|
|
|
|
|
|
$("#orgId").selectpicker('val', company);
|
|
|
|
|
|
$("#orgId").selectpicker('refresh');
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
initMenuBackDatas(id);
|
|
|
|
|
|
initMenuAppDatas(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//是否启用赋值
|
|
|
|
|
|
function checkFindData(data) {
|
|
|
|
|
|
var check = document.getElementById("checkInput");
|
|
|
|
|
|
var btnCheck = document.getElementById("btnCheck");
|
|
|
|
|
|
if (data == "0") {
|
|
|
|
|
|
check.chechked = false;
|
|
|
|
|
|
} else if (data == "1") {
|
|
|
|
|
|
check.click();
|
|
|
|
|
|
check.chechked = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
check.chechked = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function selectedTypes(type) {
|
|
|
|
|
|
if (type != null) {
|
|
|
|
|
|
$(type.split(",")).each(function (i, dom) {
|
|
|
|
|
|
$("input[name='permissionType'][value=" + dom + "]").prop("checked", true);
|
|
|
|
|
|
if (dom == 3) {
|
|
|
|
|
|
$('#sup').attr("disabled", 'disabled');
|
|
|
|
|
|
} else if (dom == 4) {
|
|
|
|
|
|
$('#work').attr("disabled", 'disabled');
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#form').bootstrapValidator();
|
|
|
|
|
|
|
|
|
|
|
|
function add() {
|
|
|
|
|
|
var opt = $("#roleLevel").val();
|
|
|
|
|
|
if (opt == 5 || opt == "5") {
|
|
|
|
|
|
var name = $("#name").val();
|
|
|
|
|
|
if (name == '班组长' || name == '施工人员') {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.msg('请填写"班组长"或"施工人员"!');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bootstrapValidator = $("#form").data('bootstrapValidator');
|
|
|
|
|
|
bootstrapValidator.validate();
|
|
|
|
|
|
if (!bootstrapValidator.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var formdata = $("#form").serializeObject();
|
|
|
|
|
|
formdata.permissionIds = getCheckedMenuIds();
|
|
|
|
|
|
formdata.status = findCheck();//是否启用
|
|
|
|
|
|
var radio = document.getElementsByName("permissionType");
|
|
|
|
|
|
var type = "";
|
|
|
|
|
|
for (var j = 0; j < radio.length; j++) {
|
|
|
|
|
|
if (radio[j].checked) {
|
|
|
|
|
|
if (type != "") {
|
|
|
|
|
|
type += "," + radio[j].value;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
type += radio[j].value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
formdata.type = type;//权限类型
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'post',
|
|
|
|
|
|
url: smz_ht_url + '/roles',
|
|
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
|
|
data: JSON.stringify(formdata),
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
layer.msg("成功", {shift: -1, time: 1000}, function () {
|
|
|
|
|
|
setTimeout("reloading()", 2100);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getOrg() {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'post',
|
|
|
|
|
|
url: smz_ht_url + '/project/getCompanys',
|
|
|
|
|
|
async: false,
|
|
|
|
|
|
dataType: "json",
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
$("#orgId").empty();
|
|
|
|
|
|
var select = $("#orgId");
|
|
|
|
|
|
if (data.length > 1) {
|
|
|
|
|
|
select.append("<option value=''>请选择公司</option>");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
|
|
select.append("<option value='" + data[i].id + "'>" + data[i].name + "</option>");
|
|
|
|
|
|
}
|
|
|
|
|
|
select.selectpicker('refresh');
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取注册按钮
|
|
|
|
|
|
function findCheck() {
|
|
|
|
|
|
var check = document.getElementById("checkInput");
|
|
|
|
|
|
if (check.checked) {
|
|
|
|
|
|
return "1";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "0";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置弹窗关闭
|
|
|
|
|
|
function reloading() {
|
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|
|
|
|
|
parent.layer.close(index); //再执行关闭
|
|
|
|
|
|
window.parent.example.ajax.reload(null, false); // 刷新页面
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
|
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|
|
|
|
|
parent.layer.close(index); //再执行关闭
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2025-11-27 16:55:35 +08:00
|
|
|
|
</body>
|
2025-12-15 15:23:57 +08:00
|
|
|
|
</html>
|