fix: 完善新增权限操作
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FLASK_DEBUG=True # 开启调试模式
|
FLASK_DEBUG=True # 开启调试模式
|
||||||
FLASK_RUN_PORT=5050 # 设置运行的端口
|
FLASK_RUN_PORT=5000 # 设置运行的端口
|
||||||
FLASK_RUN_HOST=0.0.0.0 # 设置监听的 ip
|
FLASK_RUN_HOST=0.0.0.0 # 设置监听的 ip
|
||||||
FLASK_APP="pear_admin:create_app()" # 运行程序
|
FLASK_APP="pear_admin:create_app()" # 运行程序
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.blog-title {
|
.blog-title {
|
||||||
padding-left: 13.5px;
|
padding-left: 13.5px;
|
||||||
}
|
}
|
||||||
@@ -48,8 +47,6 @@
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.message-board {
|
.message-board {
|
||||||
padding: 0 10px 10px;
|
padding: 0 10px 10px;
|
||||||
}
|
}
|
||||||
@@ -57,7 +54,7 @@
|
|||||||
.message-board li {
|
.message-board li {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
border-bottom: 1px solid #EEE;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-board li p {
|
.message-board li p {
|
||||||
@@ -65,7 +62,7 @@
|
|||||||
padding-top: 3px;
|
padding-top: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-board li>span {
|
.message-board li > span {
|
||||||
color: #999;
|
color: #999;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
|
|||||||
@@ -91,6 +91,33 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">权限类型</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="type"
|
||||||
|
value="menu"
|
||||||
|
title="菜单"
|
||||||
|
lay-filter="form-rights-filter"
|
||||||
|
checked
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="type"
|
||||||
|
value="path"
|
||||||
|
title="路由"
|
||||||
|
lay-filter="form-rights-filter"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="type"
|
||||||
|
value="auth"
|
||||||
|
title="权限"
|
||||||
|
lay-filter="form-rights-filter"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">图标</label>
|
<label class="layui-form-label">图标</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
@@ -102,22 +129,14 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item" style="display: none">
|
||||||
<label class="layui-form-label">权限类型</label>
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<input type="radio" name="type" value="menu" title="菜单" checked />
|
|
||||||
<input type="radio" name="type" value="path" title="路由" />
|
|
||||||
<input type="radio" name="type" value="auth" title="权限" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="layui-form-item">
|
|
||||||
<label class="layui-form-label">访问地址</label>
|
<label class="layui-form-label">访问地址</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="url"
|
name="url"
|
||||||
lay-verify=""
|
lay-verify=""
|
||||||
placeholder="权限类路由时输入访问地址,其他情况下不需要输入"
|
placeholder="请输入访问地址"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
class="layui-input"
|
class="layui-input"
|
||||||
/>
|
/>
|
||||||
@@ -152,13 +171,10 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">打开方式</label>
|
<label class="layui-form-label">打开方式</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input
|
<select name="open_type" id="">
|
||||||
type="text"
|
<option value="_component" selected>默认方式</option>
|
||||||
name="open_type"
|
<option value="_blank">新窗口</option>
|
||||||
placeholder=""
|
</select>
|
||||||
autocomplete="off"
|
|
||||||
class="layui-input"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
@@ -193,6 +209,7 @@
|
|||||||
var $ = layui.$;
|
var $ = layui.$;
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
|
|
||||||
treeTable.render({
|
treeTable.render({
|
||||||
elem: "#rights-table",
|
elem: "#rights-table",
|
||||||
id: "rights-table",
|
id: "rights-table",
|
||||||
@@ -281,6 +298,19 @@
|
|||||||
field.id = null;
|
field.id = null;
|
||||||
method = "POST";
|
method = "POST";
|
||||||
url = "/api/v1/rights";
|
url = "/api/v1/rights";
|
||||||
|
|
||||||
|
if (field.type === "path") {
|
||||||
|
if (!/\//.test(field.url)) {
|
||||||
|
layer.msg("url 不符合格式");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (field.type === "auth") {
|
||||||
|
console.log(field.pid);
|
||||||
|
if (!field.pid || field.pid === "0") {
|
||||||
|
layer.msg("权限必须填入父级 id");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
method = "PUT";
|
method = "PUT";
|
||||||
url = `/api/v1/rights/${field.id}`;
|
url = `/api/v1/rights/${field.id}`;
|
||||||
@@ -330,6 +360,30 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
form.on("radio(form-rights-filter)", function (data) {
|
||||||
|
var elem = data.elem; // 获得 radio 原始 DOM 对象
|
||||||
|
var checked = elem.checked; // 获得 radio 选中状态
|
||||||
|
var value = elem.value; // 获得 radio 值
|
||||||
|
var othis = data.othis; // 获得 radio 元素被替换后的 jQuery 对象
|
||||||
|
|
||||||
|
switch (value) {
|
||||||
|
case "menu":
|
||||||
|
$('[name="icon_sign"]').parent().parent().show();
|
||||||
|
$('[name="url"]').parent().parent().hide();
|
||||||
|
break;
|
||||||
|
case "path":
|
||||||
|
$('[name="icon_sign"]').parent().parent().hide();
|
||||||
|
$('[name="url"]').parent().parent().show();
|
||||||
|
break;
|
||||||
|
case "auth":
|
||||||
|
$('[name="url"]').parent().parent().hide();
|
||||||
|
$('[name="icon_sign"]').parent().parent().hide();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.msg(["value: " + value, "checked: " + checked].join("<br>"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user