roleEdit.php
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php $this->load->view('common/header'); ?>
<body>
<div class="panel panel-default">
<form action="system/role/update" id="edit">
<input type="hidden" value="<?=$id?>" name="id">
<div class="panel-body">
<div class="row cl">
<!--<div class="form-group col-sm-3 col-md-2">
<label>所属网点</label>
<span class="form-control select-box">
<select class="select" size="1">
<option selected value>请选择</option>
</select>
</span>
</div>-->
<div class="form-group col-sm-3 col-md-2">
<label>角色</label>
<input type="text" name="nameZh" class="form-control input-text" value="<?=$item->nameZh?>">
</div>
</div>
<div class="row cl">
<div class="form-group col-sm-3 col-md-2">
<label>菜单权限地图</label>
<ul id="tree" class="ztree"></ul>
</div>
</div>
</div>
</form>
</div>
<div class="row cl pt-20 pb-20 col-sm-12">
<div class="col-sm-offset-4 col-sm-2">
<button class="btn btn-primary btn-block" onclick="save()">保存</button>
</div>
<div class="col-sm-2">
<button class="btn btn-warning btn-block" onclick="layer_close()">取消</button>
</div>
</div>
<?php $this->load->view('common/footer'); ?>
<script>
var setting = {
async: {
enable: true,
// url: '<?//=site_url('/perm/organization')?>//',
url: '<?=site_url('/perm/menu')?>',
autoParam:["id"]
},
check: {
enable: true
},
data: {
simpleData: {
enable: true
}
}
};
var code;
function setCheck() {
var zTree = $.fn.zTree.getZTreeObj("tree"),
type = { "Y" : "ps", "N" :"ps"};
zTree.setting.check.chkboxType = type;
}
$(document).ready(function(){
$.fn.zTree.init($("#tree"), setting);
setCheck();
});
function save() {
//获得款中的节点
var treeObj = $.fn.zTree.getZTreeObj("tree");
// console.log(treeObj);
var nodes = treeObj.getCheckedNodes(true);
var menuIds = [];
console.log(nodes);
$.each(nodes, function (i,v) {
menuIds.push(v.id);
});
console.log(menuIds);
var targetUrl = $("#edit").attr("action");
var data = $("#edit").serializeJson();
var newData = {
nameZh:data['nameZh'],
id:data['id'],
menuIds:menuIds
};
$.ajax({
type: 'put',
url: apiBaseUrl + targetUrl,
cache: false,
data: JSON.stringify(newData),
dataType: 'json',
contentType: "application/json; charset=UTF-8",
success: function (data) {
// console.log(data);
if (data.msg) {
layer.alert(data.msg);
} else if (data.code != 0) {
layer.alert('操作失败');
} else {
layer.msg('操作成功');
window.parent.reload();
layer_close();
}
if (data.code) {
setTimeout(function () {
window.parent.reload();
layer_close();
}, 500);
}
},
error: function () {
layer.alert("操作失败")
}
});
// layer_close();
}
</script>
</body>
<html>