| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- <%@ page contentType="text/html;charset=GBK"%>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <head>
- <title>套餐授权</title>
- <script type=text/javascript src="/shares/js/jquery-1.6.4.min.js"></script>
- <link href="main.css" rel="stylesheet" type="text/css"></link>
- <script type="text/javascript" src="js/lr-page.js"></script>
- <script type="text/javascript" src="/shares/js/constant.js"></script>
- <script type="text/javascript" src="/shares/js/common.js"></script>
- <script type="text/javascript" src="/shares/js/yw/eu/setmeal/setmealAuthor.js"></script>
- <link href="./liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css" rel="stylesheet" type="text/css"></link>
- <script src="./liger/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
- <!-- <script src="./liger/lib/ligerUI/js/plugins/ligerTab.js" type="text/javascript"></script>
- <script src="./liger/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
- <script src="./liger/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
- <script src="./liger/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script> -->
- <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
-
- <script type="text/javascript">
- var dialog;
- var authorTrees = [];
- var managerTree;
- var authorTab;
- var curTab = 1;
- var com_node;
- var com_nodes;
- $(function (){
- $("#layout1").ligerLayout({ leftWidth: 250,height:'99%'});
- var height = $(".l-layout-center").height();
- $("#navtab1").ligerTab({height:height-25});
- tabitem = $("#navtab1").ligerGetTabManager();
- replaceItem();
- checkAll();
- loadAuthorTree();
- $("#leftTree").height(height-90);
- authorTab=$("#authorTab").ligerTab({ onAfterSelectTabItem: function (tabid){
- if(tabid == "tabitem1"){
- curTab = 1;
- }else if(tabid == "comTabId"){
- curTab = 2;
- loadOrderList();
- }
- }});
- });
-
- function replaceItem(){
- tabitem.addTabItem({tabid:'temp_1',text: "",content:"",isMove:false});
- tabitem.selectTabItem("tabitem1");
- tabitem.removeTabItem('temp_1');
- }
-
- function loadTree(){
- $("#unitTree").empty();
- if($(".l-dialog-close").length>0)$(".l-dialog-close").click();
- managerTree = setmealTree("setmealManageAction.do?task=setmealTree","unitTree",clickSetmealEvent,onSetmealSuccess);
- }
-
- function authorTreeProcess(data){
- if(data==null)return;
- var len = $(".authorTree").length;
- $(".authorTree").each(function(i,el){
- var tid = $(el).attr("id");
- var treeData = findDataTree(data,tid);
- $("#" + tid).ligerTree({
- data : treeData,
- checkbox : true,
- folderCheckbox : true,
- slide : false,
- idFieldName : 'key',
- openFolderEven : false,
- nodeWidth : 220,
- attribute : [ 'ix', 'url', 'hide', 'target', 'key',"isHidden","isNew"]
- });
- var authorTree = $("#" + tid).ligerGetTreeManager();
- authorTrees.push(authorTree);
- });
- managerTree = setmealTree("setmealManageAction.do?task=setmealTree","unitTree",clickSetmealEvent,onSetmealSuccess);
- }
- /**
- *套餐树
- */
- function setmealTree(treeAction, treeId, clickEvent, onSuccess,onAppend) {
- var manager = "";
- $("#" + treeId).ligerTree({
- url : getProjectName() + "/" + changePath(treeAction),
- checkbox : true,
- folderCheckbox : false,
- single : true,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- openFolderEven:false,
- nodeWidth : 120,
- attribute : [ 'id', 'url','type'],
- onSelect : function(node) {
- //clickEvent(node);
- },
- onCheck : function(node,checked) {
- clickEvent(node);
- },
- onAppend : function(parentNode, newdata) {
- if(onAppend)onAppend(parentNode, newdata);
- },
- onSuccess : function() {
- if (onSuccess)
- onSuccess();
- }
- });
- manager = $("#" + treeId).ligerGetTreeManager();
- return manager;
- }
- /**
- *编辑标签名称
- */
- function editTabTitle(){
- var setmeal_id = $("#setmeal_id").val();
- $.ajax({
- type:"POST",
- url:"setmealManageAction.do?task=countCompanys&time=" + new Date().getTime(),
- data : {"setmeal_id":setmeal_id},
- cache:false,
- dataType:"json",
- success:function(data){
- var count = data.count;
- var show_title = "已购企业("+count+")";
- $("li[tabid='comTabId']").attr("title",show_title);
- $("li[tabid='comTabId']").children("a").html(show_title);
- },
- error:function(err){
- showAjaxError(err);
- }
- });
- if(curTab==2){
- loadOrderList();
- }
- }
- /**
- *点击套餐事件
- */
- function clickSetmealEvent(node){
- $.ligerDialog.waitting('正在刷新,请稍候...');
- toCancel();
- setTimeout("clickSetmealEventAfter()",1);
- com_node = node;
- }
- function clickSetmealEventAfter(){
- var node = com_node;
- var id = node.data.id;
- var txt = node.data.text;
- var type = node.data.type;
- if(type=='1'){
- $("#delRoleEvent").hide();
- }else{
- $("#delRoleEvent").show();
- }
- isChecked = $(".l-checkbox-checked",node.target);
- if(isChecked!=undefined&&isChecked.length>0){
- $("input[name='role']").val(id);
- $("#roleName").html(txt);
- $("#setmeal_id").val(id);
- $("input[name='author']").each(function(){
- $(this).attr("checked",false);
- });
- editTabTitle();
- var param = {'id':id};
- sendAjaxParam(param,'setmealManageAction.do?task=findSetmealAuthors','json',findprocess);
- }else{
- $("input[name='author']").each(function(){
- $(this).attr("checked",false);
- });
- $("input[name='unit']").val(id);
- $("input[name='role']").val("");
- $("#setmeal_id").val("");
- $("#roleName").html("");
- }
- $.ligerDialog.closeWaitting();
- }
- /**
- *套餐树成功,回调函数
- */
- function onSetmealSuccess(){
- managerTree.expandAll();
-
- var roleId = $("input[name='role']").val();
- if(roleId!=''&&roleId!=undefined){
- $("input[name='author']").each(function(){
- $(this).attr("checked",false);
- });
- var param = {'id':roleId};
- managerTree.selectNode(roleId);
- /* sendAsyncAjax(param,'findRoleAuthor.do','json',process); */
- }
- $("#pageloading").hide();
- }
- function findDataTree(data,key){
- for(var i=0;i<data.length;i++){
- var key1 = data[i]['key'];
- if(key1==key){
- return data[i].children;
- }
- }
- }
- /**
- *点击后事件
- */
- function findprocess(data){
- var tree = $(".authorTree");
- $(".l-checkbox",tree).addClass("l-checkbox-unchecked").removeClass("l-checkbox-checked l-checkbox-incomplete");
- for(var i=0;i<data.length;i++){
- var p = data[i]["actionPath"];
- if(p==null||p=="")continue;
- p = p.replace("?","\\?");
- p = p.replace(new RegExp("=","g"),"\\=");
- p = p.replace(new RegExp("&","g"),"\\&");
- p = p.replace(new RegExp("_","g"),"\\_");
- p = changPath(p);
- $(".l-checkbox","li[url='"+p+"']").click();
- }
- }
- function loadAuthorTree(){
- var param={};
- sendAsyncAjax(param,'roleAuthorTree.do','json',authorTreeProcess);
- }
- function checkAll(){
- var checkIds = $("[name='checkedIds']").val();
- var checkIdCol = checkIds.split(",");
- $("[name='role']").each(function(){
- var roleId = $(this).val();
- if(isExist(roleId,checkIdCol)){
- $(this).parent().click();
- }
- });
- }
- /**
- * 新增 套餐
- */
- function addSetmeal(){
- $.ligerDialog.open({
- height: 200,
- url: 'setmealManageAction.do?task=toAddSetmeal',
- width: 480,
- height:350,
- title: "新增套餐"
- });
- }
- /**
- * 编辑套餐
- */
- function editSetmeal(){
- var setmeal_id = $("input[name='role']").val();
- if(setmeal_id!=''&&setmeal_id!=undefined&&setmeal_id!="1"){
- $.ligerDialog.open({
- height: 200,
- url: 'setmealManageAction.do?task=toEditSetmeal&setmeal_id='+setmeal_id,
- width: 480,
- height:350,
- title: "编辑套餐"
- });
- }else{
- addError("请选择需要编辑的套餐!");
- }
-
- }
- /**
- * 删除套餐
- */
- function delSetmeal(){
- var setmeal_id = $("input[name='role']").val();
- if(setmeal_id!=''&&setmeal_id!=undefined&&setmeal_id!="1"){
- $.ligerDialog.confirm('确定要删除套餐吗?', function (yes)
- {
- if(yes){
- $.ajax({
- type:"POST",
- url:"setmealManageAction.do?task=delSetmeal&time=" + new Date().getTime(),
- data : {"setmeal_id":setmeal_id},
- cache:false,
- dataType:"json",
- success:function(data){
- var result = data;
- if(result==1){
- window.top.$.ligerDialog.success("删除成功!");
- loadTree();
- }else if(result==2){
- $.ligerDialog.error("有公司已购买了该套餐,不能删除!");
- }else{
- $.ligerDialog.error("删除失败!");
- }
- },
- error:function(err){
- showAjaxError(err);
- }
- });
- }
- });
- }else{
- addError("请选择需要删除的套餐!");
- }
-
- }
- /**
- * 选择复制按钮
- */
- function toCopy(){
- $("#toCopyDiv").hide();
- $("#copyDiv").show();
- }
- /**
- * 选择取消复制按钮
- */
- function toCancel(){
- $("#toCopyDiv").show();
- $("#copyDiv").hide();
- $("#selectSetmeal").val("");
- var tree = $(".authorTree");
- $(".l-checkbox",tree).addClass("l-checkbox-unchecked").removeClass("l-checkbox-checked l-checkbox-incomplete");
- }
- /**
- * 下拉框选择套餐事件
- */
- function changeSetmeal(){
- var setmeal_id=$("#selectSetmeal").val();
- var param = {'id':setmeal_id};
- sendAjaxParam(param,'setmealManageAction.do?task=findSetmealAuthors','json',findprocess);//先注释
- }
- /**
- * 保存套餐权限
- */
- function saveSetmeal(){
- var setmeal_id = $("input[name='setmeal_id']").val();
- if(setmeal_id==''||setmeal_id==undefined||setmeal_id=="1"){
- addError("请选择套餐!");
- return;
- }
- $.ligerDialog.confirm('保存后,已绑定该套餐的公司的权限将同步更新,确定要修改吗?', function (yes){
- if(yes){
- $.ligerDialog.waitting('正在保存数据,请稍候...');
- var nodes = [];
- for(var i=0;i<authorTrees.length;i++){
- var atree = authorTrees[i];
- var checkNodes = atree.getChecked();
- for(var j=0;j<checkNodes.length;j++){
- var checkNode = checkNodes[j];
- var url = checkNode.data.url;
- var node = [];
- if(url){
- node.push(checkNode.data.url);
- node.push(encodeURI(checkNode.data.text));
- nodes.push(node);
- }
- }
- }
- if(nodes.length==0){
- $.ligerDialog.error("请选择权限!");
- $.ligerDialog.closeWaitting();
- return;
- }
- setTimeout("saveSetmealAfter()",1);
- com_nodes = nodes;
- }
- });
- }
- function saveSetmealAfter(){
- var nodes = com_nodes;
- var roleId = $("input[name='role']").val();
- var setmeal_id = $("#setmeal_id").val();
- var json = arrayToJson(nodes);
- var param = {"role":roleId,"author":json,"setmeal_id":setmeal_id};
- sendAsyncAjax(param,"setmealManageAction.do?task=saveAuthors","json",loadAuthorProcess);
- }
- function loadAuthorProcess(data){
- $.ligerDialog.closeWaitting();
- displayAjaxMsg(data);
- }
- /**
- * 已购企业列表
- */
- function loadOrderList() {
- var setmeal_id = $("#setmeal_id").val();
- var grid = null;
- grid = $("#orderGrid")
- .ligerGrid(
- {
- columns : [
- {
- display : '公司名称',
- name : 'company_name',
- width : 400
- },
- {
- display : '套餐名称',
- name : 'name',
- width : 220
- } ],
- pageSize : 20,
- url : 'setmealManageAction.do?task=orderList&setmeal_id='+setmeal_id
- + '&time='
- + new Date().getTime(),
- pageParmName : 'p', //页索引参数名,(提交给服务器)
- pagesizeParmName : 'pSize', //页记录数参数名,(提交给服务器)
- width : '99.9%',
- height : '99.5%',
- rownumbers:true
- });
- $("#pageloading").hide();
- }
- /**
- * 企业套餐分配
- */
- function allotSetmeal(){
- window.parent.f_addTab('roleAuthor.do', '企业套餐分配',
- '${pageContext.request.contextPath }/roleAuthor.do');
- }
- function refreshSetmeal(){
- editTabTitle();
- }
- </script>
- <style type="text/css">
- body{ padding:5px; margin:0;}
- #layout1{width:99.5%;margin:0; padding:0; }
- .roleTree{
- height:20px;
- padding-top:3px;
- }
- input[type='button'], input[type='submit'] {
- width: 70px;
- }
- .l-button{margin-left:1px;}
- .prjTree{
- margin:5px 1px 1px 5px;
- }
- /* .l-tab-links{
- background-color: rgb(238, 247, 254);
- } */
- </style>
- </head>
- <body>
- <%@ include file="/include/button.jsp"%>
- <%@ include file="/include/message.jsp"%>
- <div id="pageloading" class='l-all-loading'></div>
- <form name="roleAuthorForm" action="addRoleAuthor.do" method="post">
- <div id="layout1" class="tab1 l-tab">
- <div position="left" title="套餐列表" id="accordion1">
- <c:if test="${isAdmin eq '1'}">
- <div id="deptBtn">
- <input type="button" value="新增" class="l-button" onclick="addSetmeal()" style="width:60px;"/>
- <input type="button" value="修改" class="l-button" onclick="editSetmeal()" style="width:60px;"/>
- <input type="button" value="删除" id="delRoleEvent" class="l-button" onclick="delSetmeal()" style="width:60px;" />
- </div>
- </c:if>
- <input type="hidden" name="checkedIds" value="${checkedIds}" />
- <input type="hidden" name="role" value="${role}"/>
- <input type="hidden" id="setmeal_id" name="setmeal_id" value=""/>
- <input type="hidden" name="unit" value=""/>
- <div id="leftTree" style="overflow:auto;position:relative;">
- <ul id="unitTree" class="tree" style="margin-top: 3px;">
- </div>
- </div>
- <div id="authorTab" position="center">
- <div id="showAuthorDiv" title="套餐权限" >
- <div style="margin-top:3px;margin-left:30px;float:left;">
- <input id="btnSave" type="button" class="l-button" value="保存" onclick="saveSetmeal()"/>
- </div>
- <div id="toCopyDiv" style="margin-top:3px;margin-left:20px;float:left;">
- <input id="btnCopy" style="width:105px;" type="button" class="l-button" value="从其他套餐复制" onclick="toCopy();"/>
- </div>
- <div id="copyDiv" style="margin-top:3px;margin-left:20px;float:left;display: none;" >
- <input id="btnCancel" type="button" class="l-button" value="取消复制" onclick="toCancel();"/>
- <select id="selectSetmeal" name="selectSetmeal" onchange="changeSetmeal();">
- <option value="">=请选择=</option>
- <c:forEach items="${smList }" var="sm" >
- <option value="${sm.universalid }">${sm.name }</option>
- </c:forEach>
- </select>
- </div>
- <div id="navtab1" style="width: 99%;margin:0 auto;overflow:hidden;height:99%; ">
- <c:forEach items="${prjs}" var="prj" varStatus="i">
- <div title="${prj.prjName}" ${i.index==0?"lselected='true'":""}>
- <div class="prjTree" style="width:99%;height:96%;float:left;overflow:auto">
- <ul id="${prj.key}" class="tree authorTree" ix="${i.index+1}" style="margin-top: 3px;">
- </div>
- </div>
- </c:forEach>
- </div>
- </div>
- <div tabid="comTabId" title="已购企业" id="comListTab" style="overflow: hidden;">
- <c:if test="${is_show==true }">
- <input id="btnRefresh" type="button" class="l-button" value="刷新" onclick="refreshSetmeal();" style="margin:5px;margin-right:0px;margin-left:10px;"/>
- <input id="btnAllot" type="button" class="l-button" value="企业套餐分配" onclick="allotSetmeal();" style="width:120px;margin:5px;"/>
- </c:if>
- <div id="orderGrid" style="margin: 0; padding: 0"></div>
- </div>
- </div>
- </div>
- </form>
- </div>
- </body>
- </html>
|