123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <{include file="./admin/header.html"}>
- <{include file="./admin/left.html"}>
- <{include file="./admin/nav.html"}>
- <link rel="stylesheet" href="<{$web_cfg.cdn}>/public/static/css/zTreeStyle/zTreeStyle.css">
- <script src="<{$web_cfg.cdn}>/public/static/js/jquery-1.4.4.min.js"></script>
- <script src="<{$web_cfg.cdn}>/public/static/js/jquery.ztree.all-3.5.js"></script>
- <div class="panel">
- <div class="panel-body">
- <div style="margin-left:10px;">
- <p></p>
- <!-- 容器 -->
- <div id='tree' class="ztree"></div>
- <input id='groupid' type='hidden' value='<{$groupid}>' />
- </div>
- <div style="text-align:center;"><input id="submit" class="btn" type='submit' value='权限修改提交' /></div>
- </div>
- </div>
- <script>
- var setting = {
- view: {
- nameIsHTML: true
- },
- check: {
- enable: true,
- chkboxType: { "Y" : "", "N" : "" }
- },
- data: {
- simpleData: {
- enable: true
- }
- },
- callback: {}
- };
- var zNodes = <{$resource}>;
- $(document).ready(function(){
- var objTree = $.fn.zTree.init($("#tree"), setting, zNodes);
-
- //勾选用户组已有权限
- checkedUsergroupCpt();
-
- //禁用登陆用户没有的权限
- disableCpt();
-
- //提交权限
- $("#submit").click(function () {
- var checkNodes = objTree.getCheckedNodes(true);
-
- var resourceids = [];
- for (var i=0; i < checkNodes.length; i++) {
- resourceids.push(checkNodes[i].id);
- }
-
- var groupid = $('#groupid').val();
- if (groupid == '') {
- alert('无效用户组id');
- return false;
- }
- console.log(resourceids);
-
- $.post("<{$web_cfg.domain}>?c=permission&a=editUsergroupCpt"
- , {resourceids: resourceids, groupid: groupid}
- , function (data) {
- if (data.ok) {
- alert('编辑权限成功');
- location.reload();
- } else {
- alert(data.msg);
- return false;
- }
- },
- 'json'
- );
- return false;
- });
-
- //勾选用户组已有权限
- function checkedUsergroupCpt() {
- var usergroupCpt = <{$usergroupCpt}>;
- for (var i=0; i<usergroupCpt.length; i++) {
- var node = objTree.getNodeByParam("id", usergroupCpt[i].resourceid, null);
- try {
- objTree.checkNode(node, true, true, 1);
- } catch(e) {}
- }
- }
-
- //禁用登陆用户没有没有的权限
- function disableCpt() {
- var disableTreeIds = <{$disableTreeIds}>;
- var zTree = $.fn.zTree.getZTreeObj("tree");
- for (var i=0; i<disableTreeIds.length; i++) {
- var treeId = disableTreeIds[i];
- var node = zTree.getNodeByParam("id", treeId, null);
- zTree.setChkDisabled(node, true, true, false);
- }
- }
- });
- </script>
- <{include file="./admin/bottom.html"}>
|