109 lines
3.1 KiB
HTML
109 lines
3.1 KiB
HTML
{extend name="base"/}
|
|
{block name="resources"}
|
|
<style type="text/css">
|
|
.tree-line{padding:10px 0;background:#ededed;margin-bottom:2px;line-height: 1.8;border:1px solid #000;}
|
|
.tree-line .layui-form{padding-left: 10px !important;}
|
|
.tree-line .layui-form-checkbox{margin:0 10px !important;vertical-align:middle;}
|
|
.form-wrap {margin-top: 0;}
|
|
.group-tree-block .layui-table tbody tr:hover {background-color: white;}
|
|
</style>
|
|
{/block}
|
|
{block name="main"}
|
|
<div class="layui-form form-wrap" lay-filter="save">
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label"><span class="required">*</span>角色名称:</label>
|
|
<div class="layui-input-block">
|
|
<input name="group_name" type="text" required lay-verify="required" placeholder="请输入角色名称" class="layui-input len-long" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">描述:</label>
|
|
<div class="layui-input-block">
|
|
<textarea name="desc" class="layui-textarea len-long" placeholder="请输入角色的相关描述" maxlength="150"></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label"><span class="required">*</span>设置权限:</label>
|
|
<div class="layui-input-block">
|
|
<div class="layui-input-inline group-tree-block" id="tree_box"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 表单操作 -->
|
|
<div class="form-row">
|
|
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
|
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
|
</div>
|
|
</div>
|
|
{/block}
|
|
{block name="script"}
|
|
|
|
<script>
|
|
var tree_data = JSON.parse('{:json_encode($tree_data, JSON_UNESCAPED_UNICODE)}'),
|
|
form,
|
|
repeat_flag = false; //防重复标识
|
|
|
|
layui.use('form', function() {
|
|
form = layui.form;
|
|
form.render();
|
|
|
|
form.on('submit(save)', function (data) {
|
|
|
|
var obj = $("#tree_box input:checked"),
|
|
group_array = [];
|
|
|
|
for (var i = 0; i < obj.length; i++) {
|
|
group_array.push(obj.eq(i).val());
|
|
}
|
|
|
|
data.field.menu_array = group_array.toString();
|
|
|
|
if (repeat_flag) return;
|
|
repeat_flag = true;
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
dataType: "JSON",
|
|
url: ns.url("shop/user/addgroup"),
|
|
data: data.field,
|
|
success: function (res) {
|
|
repeat_flag = false;
|
|
|
|
if (res.code == 0) {
|
|
layer.confirm('添加成功', {
|
|
title:'操作提示',
|
|
btn: ['返回列表', '继续添加'],
|
|
closeBtn: 0,
|
|
yes: function(){
|
|
location.href = ns.url("shop/user/group")
|
|
},
|
|
btn2: function() {
|
|
location.href = ns.url("shop/user/addgroup")
|
|
}
|
|
})
|
|
}else{
|
|
layer.msg(res.message);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
form.verify({
|
|
title: function (value) {
|
|
if (value.length == 0) {
|
|
return '请输入角色名称';
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
function back() {
|
|
location.href = ns.url("shop/user/group");
|
|
}
|
|
</script>
|
|
<script src="SHOP_JS/tree.js"></script>
|
|
{/block}
|