setmealManageTree.jsp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <%@ page contentType="text/html;charset=GBK"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <head>
  5. <title>套餐授权</title>
  6. <script type=text/javascript src="/shares/js/jquery-1.6.4.min.js"></script>
  7. <link href="main.css" rel="stylesheet" type="text/css"></link>
  8. <script type="text/javascript" src="js/lr-page.js"></script>
  9. <script type="text/javascript" src="/shares/js/constant.js"></script>
  10. <script type="text/javascript" src="/shares/js/common.js"></script>
  11. <script type="text/javascript" src="/shares/js/yw/eu/setmeal/setmealAuthor.js"></script>
  12. <link href="./liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css" rel="stylesheet" type="text/css"></link>
  13. <script src="./liger/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
  14. <!-- <script src="./liger/lib/ligerUI/js/plugins/ligerTab.js" type="text/javascript"></script>
  15. <script src="./liger/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
  16. <script src="./liger/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
  17. <script src="./liger/lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script> -->
  18. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
  19. <script type="text/javascript">
  20. var dialog;
  21. var authorTrees = [];
  22. var managerTree;
  23. var authorTab;
  24. var curTab = 1;
  25. var com_node;
  26. var com_nodes;
  27. $(function (){
  28. $("#layout1").ligerLayout({ leftWidth: 250,height:'99%'});
  29. var height = $(".l-layout-center").height();
  30. $("#navtab1").ligerTab({height:height-25});
  31. tabitem = $("#navtab1").ligerGetTabManager();
  32. replaceItem();
  33. checkAll();
  34. loadAuthorTree();
  35. $("#leftTree").height(height-90);
  36. authorTab=$("#authorTab").ligerTab({ onAfterSelectTabItem: function (tabid){
  37. if(tabid == "tabitem1"){
  38. curTab = 1;
  39. }else if(tabid == "comTabId"){
  40. curTab = 2;
  41. loadOrderList();
  42. }
  43. }});
  44. });
  45. function replaceItem(){
  46. tabitem.addTabItem({tabid:'temp_1',text: "",content:"",isMove:false});
  47. tabitem.selectTabItem("tabitem1");
  48. tabitem.removeTabItem('temp_1');
  49. }
  50. function loadTree(){
  51. $("#unitTree").empty();
  52. if($(".l-dialog-close").length>0)$(".l-dialog-close").click();
  53. managerTree = setmealTree("setmealManageAction.do?task=setmealTree","unitTree",clickSetmealEvent,onSetmealSuccess);
  54. }
  55. function authorTreeProcess(data){
  56. if(data==null)return;
  57. var len = $(".authorTree").length;
  58. $(".authorTree").each(function(i,el){
  59. var tid = $(el).attr("id");
  60. var treeData = findDataTree(data,tid);
  61. $("#" + tid).ligerTree({
  62. data : treeData,
  63. checkbox : true,
  64. folderCheckbox : true,
  65. slide : false,
  66. idFieldName : 'key',
  67. openFolderEven : false,
  68. nodeWidth : 220,
  69. attribute : [ 'ix', 'url', 'hide', 'target', 'key',"isHidden","isNew"]
  70. });
  71. var authorTree = $("#" + tid).ligerGetTreeManager();
  72. authorTrees.push(authorTree);
  73. });
  74. managerTree = setmealTree("setmealManageAction.do?task=setmealTree","unitTree",clickSetmealEvent,onSetmealSuccess);
  75. }
  76. /**
  77. *套餐树
  78. */
  79. function setmealTree(treeAction, treeId, clickEvent, onSuccess,onAppend) {
  80. var manager = "";
  81. $("#" + treeId).ligerTree({
  82. url : getProjectName() + "/" + changePath(treeAction),
  83. checkbox : true,
  84. folderCheckbox : false,
  85. single : true,
  86. childIcon : 'folder',
  87. idFieldName : 'id',
  88. parentIDFieldName : 'pid',
  89. openFolderEven:false,
  90. nodeWidth : 120,
  91. attribute : [ 'id', 'url','type'],
  92. onSelect : function(node) {
  93. //clickEvent(node);
  94. },
  95. onCheck : function(node,checked) {
  96. clickEvent(node);
  97. },
  98. onAppend : function(parentNode, newdata) {
  99. if(onAppend)onAppend(parentNode, newdata);
  100. },
  101. onSuccess : function() {
  102. if (onSuccess)
  103. onSuccess();
  104. }
  105. });
  106. manager = $("#" + treeId).ligerGetTreeManager();
  107. return manager;
  108. }
  109. /**
  110. *编辑标签名称
  111. */
  112. function editTabTitle(){
  113. var setmeal_id = $("#setmeal_id").val();
  114. $.ajax({
  115. type:"POST",
  116. url:"setmealManageAction.do?task=countCompanys&time=" + new Date().getTime(),
  117. data : {"setmeal_id":setmeal_id},
  118. cache:false,
  119. dataType:"json",
  120. success:function(data){
  121. var count = data.count;
  122. var show_title = "已购企业("+count+")";
  123. $("li[tabid='comTabId']").attr("title",show_title);
  124. $("li[tabid='comTabId']").children("a").html(show_title);
  125. },
  126. error:function(err){
  127. showAjaxError(err);
  128. }
  129. });
  130. if(curTab==2){
  131. loadOrderList();
  132. }
  133. }
  134. /**
  135. *点击套餐事件
  136. */
  137. function clickSetmealEvent(node){
  138. $.ligerDialog.waitting('正在刷新,请稍候...');
  139. toCancel();
  140. setTimeout("clickSetmealEventAfter()",1);
  141. com_node = node;
  142. }
  143. function clickSetmealEventAfter(){
  144. var node = com_node;
  145. var id = node.data.id;
  146. var txt = node.data.text;
  147. var type = node.data.type;
  148. if(type=='1'){
  149. $("#delRoleEvent").hide();
  150. }else{
  151. $("#delRoleEvent").show();
  152. }
  153. isChecked = $(".l-checkbox-checked",node.target);
  154. if(isChecked!=undefined&&isChecked.length>0){
  155. $("input[name='role']").val(id);
  156. $("#roleName").html(txt);
  157. $("#setmeal_id").val(id);
  158. $("input[name='author']").each(function(){
  159. $(this).attr("checked",false);
  160. });
  161. editTabTitle();
  162. var param = {'id':id};
  163. sendAjaxParam(param,'setmealManageAction.do?task=findSetmealAuthors','json',findprocess);
  164. }else{
  165. $("input[name='author']").each(function(){
  166. $(this).attr("checked",false);
  167. });
  168. $("input[name='unit']").val(id);
  169. $("input[name='role']").val("");
  170. $("#setmeal_id").val("");
  171. $("#roleName").html("");
  172. }
  173. $.ligerDialog.closeWaitting();
  174. }
  175. /**
  176. *套餐树成功,回调函数
  177. */
  178. function onSetmealSuccess(){
  179. managerTree.expandAll();
  180. var roleId = $("input[name='role']").val();
  181. if(roleId!=''&&roleId!=undefined){
  182. $("input[name='author']").each(function(){
  183. $(this).attr("checked",false);
  184. });
  185. var param = {'id':roleId};
  186. managerTree.selectNode(roleId);
  187. /* sendAsyncAjax(param,'findRoleAuthor.do','json',process); */
  188. }
  189. $("#pageloading").hide();
  190. }
  191. function findDataTree(data,key){
  192. for(var i=0;i<data.length;i++){
  193. var key1 = data[i]['key'];
  194. if(key1==key){
  195. return data[i].children;
  196. }
  197. }
  198. }
  199. /**
  200. *点击后事件
  201. */
  202. function findprocess(data){
  203. var tree = $(".authorTree");
  204. $(".l-checkbox",tree).addClass("l-checkbox-unchecked").removeClass("l-checkbox-checked l-checkbox-incomplete");
  205. for(var i=0;i<data.length;i++){
  206. var p = data[i]["actionPath"];
  207. if(p==null||p=="")continue;
  208. p = p.replace("?","\\?");
  209. p = p.replace(new RegExp("=","g"),"\\=");
  210. p = p.replace(new RegExp("&","g"),"\\&");
  211. p = p.replace(new RegExp("_","g"),"\\_");
  212. p = changPath(p);
  213. $(".l-checkbox","li[url='"+p+"']").click();
  214. }
  215. }
  216. function loadAuthorTree(){
  217. var param={};
  218. sendAsyncAjax(param,'roleAuthorTree.do','json',authorTreeProcess);
  219. }
  220. function checkAll(){
  221. var checkIds = $("[name='checkedIds']").val();
  222. var checkIdCol = checkIds.split(",");
  223. $("[name='role']").each(function(){
  224. var roleId = $(this).val();
  225. if(isExist(roleId,checkIdCol)){
  226. $(this).parent().click();
  227. }
  228. });
  229. }
  230. /**
  231. * 新增 套餐
  232. */
  233. function addSetmeal(){
  234. $.ligerDialog.open({
  235. height: 200,
  236. url: 'setmealManageAction.do?task=toAddSetmeal',
  237. width: 480,
  238. height:350,
  239. title: "新增套餐"
  240. });
  241. }
  242. /**
  243. * 编辑套餐
  244. */
  245. function editSetmeal(){
  246. var setmeal_id = $("input[name='role']").val();
  247. if(setmeal_id!=''&&setmeal_id!=undefined&&setmeal_id!="1"){
  248. $.ligerDialog.open({
  249. height: 200,
  250. url: 'setmealManageAction.do?task=toEditSetmeal&setmeal_id='+setmeal_id,
  251. width: 480,
  252. height:350,
  253. title: "编辑套餐"
  254. });
  255. }else{
  256. addError("请选择需要编辑的套餐!");
  257. }
  258. }
  259. /**
  260. * 删除套餐
  261. */
  262. function delSetmeal(){
  263. var setmeal_id = $("input[name='role']").val();
  264. if(setmeal_id!=''&&setmeal_id!=undefined&&setmeal_id!="1"){
  265. $.ligerDialog.confirm('确定要删除套餐吗?', function (yes)
  266. {
  267. if(yes){
  268. $.ajax({
  269. type:"POST",
  270. url:"setmealManageAction.do?task=delSetmeal&time=" + new Date().getTime(),
  271. data : {"setmeal_id":setmeal_id},
  272. cache:false,
  273. dataType:"json",
  274. success:function(data){
  275. var result = data;
  276. if(result==1){
  277. window.top.$.ligerDialog.success("删除成功!");
  278. loadTree();
  279. }else if(result==2){
  280. $.ligerDialog.error("有公司已购买了该套餐,不能删除!");
  281. }else{
  282. $.ligerDialog.error("删除失败!");
  283. }
  284. },
  285. error:function(err){
  286. showAjaxError(err);
  287. }
  288. });
  289. }
  290. });
  291. }else{
  292. addError("请选择需要删除的套餐!");
  293. }
  294. }
  295. /**
  296. * 选择复制按钮
  297. */
  298. function toCopy(){
  299. $("#toCopyDiv").hide();
  300. $("#copyDiv").show();
  301. }
  302. /**
  303. * 选择取消复制按钮
  304. */
  305. function toCancel(){
  306. $("#toCopyDiv").show();
  307. $("#copyDiv").hide();
  308. $("#selectSetmeal").val("");
  309. var tree = $(".authorTree");
  310. $(".l-checkbox",tree).addClass("l-checkbox-unchecked").removeClass("l-checkbox-checked l-checkbox-incomplete");
  311. }
  312. /**
  313. * 下拉框选择套餐事件
  314. */
  315. function changeSetmeal(){
  316. var setmeal_id=$("#selectSetmeal").val();
  317. var param = {'id':setmeal_id};
  318. sendAjaxParam(param,'setmealManageAction.do?task=findSetmealAuthors','json',findprocess);//先注释
  319. }
  320. /**
  321. * 保存套餐权限
  322. */
  323. function saveSetmeal(){
  324. var setmeal_id = $("input[name='setmeal_id']").val();
  325. if(setmeal_id==''||setmeal_id==undefined||setmeal_id=="1"){
  326. addError("请选择套餐!");
  327. return;
  328. }
  329. $.ligerDialog.confirm('保存后,已绑定该套餐的公司的权限将同步更新,确定要修改吗?', function (yes){
  330. if(yes){
  331. $.ligerDialog.waitting('正在保存数据,请稍候...');
  332. var nodes = [];
  333. for(var i=0;i<authorTrees.length;i++){
  334. var atree = authorTrees[i];
  335. var checkNodes = atree.getChecked();
  336. for(var j=0;j<checkNodes.length;j++){
  337. var checkNode = checkNodes[j];
  338. var url = checkNode.data.url;
  339. var node = [];
  340. if(url){
  341. node.push(checkNode.data.url);
  342. node.push(encodeURI(checkNode.data.text));
  343. nodes.push(node);
  344. }
  345. }
  346. }
  347. if(nodes.length==0){
  348. $.ligerDialog.error("请选择权限!");
  349. $.ligerDialog.closeWaitting();
  350. return;
  351. }
  352. setTimeout("saveSetmealAfter()",1);
  353. com_nodes = nodes;
  354. }
  355. });
  356. }
  357. function saveSetmealAfter(){
  358. var nodes = com_nodes;
  359. var roleId = $("input[name='role']").val();
  360. var setmeal_id = $("#setmeal_id").val();
  361. var json = arrayToJson(nodes);
  362. var param = {"role":roleId,"author":json,"setmeal_id":setmeal_id};
  363. sendAsyncAjax(param,"setmealManageAction.do?task=saveAuthors","json",loadAuthorProcess);
  364. }
  365. function loadAuthorProcess(data){
  366. $.ligerDialog.closeWaitting();
  367. displayAjaxMsg(data);
  368. }
  369. /**
  370. * 已购企业列表
  371. */
  372. function loadOrderList() {
  373. var setmeal_id = $("#setmeal_id").val();
  374. var grid = null;
  375. grid = $("#orderGrid")
  376. .ligerGrid(
  377. {
  378. columns : [
  379. {
  380. display : '公司名称',
  381. name : 'company_name',
  382. width : 400
  383. },
  384. {
  385. display : '套餐名称',
  386. name : 'name',
  387. width : 220
  388. } ],
  389. pageSize : 20,
  390. url : 'setmealManageAction.do?task=orderList&setmeal_id='+setmeal_id
  391. + '&time='
  392. + new Date().getTime(),
  393. pageParmName : 'p', //页索引参数名,(提交给服务器)
  394. pagesizeParmName : 'pSize', //页记录数参数名,(提交给服务器)
  395. width : '99.9%',
  396. height : '99.5%',
  397. rownumbers:true
  398. });
  399. $("#pageloading").hide();
  400. }
  401. /**
  402. * 企业套餐分配
  403. */
  404. function allotSetmeal(){
  405. window.parent.f_addTab('roleAuthor.do', '企业套餐分配',
  406. '${pageContext.request.contextPath }/roleAuthor.do');
  407. }
  408. function refreshSetmeal(){
  409. editTabTitle();
  410. }
  411. </script>
  412. <style type="text/css">
  413. body{ padding:5px; margin:0;}
  414. #layout1{width:99.5%;margin:0; padding:0; }
  415. .roleTree{
  416. height:20px;
  417. padding-top:3px;
  418. }
  419. input[type='button'], input[type='submit'] {
  420. width: 70px;
  421. }
  422. .l-button{margin-left:1px;}
  423. .prjTree{
  424. margin:5px 1px 1px 5px;
  425. }
  426. /* .l-tab-links{
  427. background-color: rgb(238, 247, 254);
  428. } */
  429. </style>
  430. </head>
  431. <body>
  432. <%@ include file="/include/button.jsp"%>
  433. <%@ include file="/include/message.jsp"%>
  434. <div id="pageloading" class='l-all-loading'></div>
  435. <form name="roleAuthorForm" action="addRoleAuthor.do" method="post">
  436. <div id="layout1" class="tab1 l-tab">
  437. <div position="left" title="套餐列表" id="accordion1">
  438. <c:if test="${isAdmin eq '1'}">
  439. <div id="deptBtn">
  440. <input type="button" value="新增" class="l-button" onclick="addSetmeal()" style="width:60px;"/>
  441. <input type="button" value="修改" class="l-button" onclick="editSetmeal()" style="width:60px;"/>
  442. <input type="button" value="删除" id="delRoleEvent" class="l-button" onclick="delSetmeal()" style="width:60px;" />
  443. </div>
  444. </c:if>
  445. <input type="hidden" name="checkedIds" value="${checkedIds}" />
  446. <input type="hidden" name="role" value="${role}"/>
  447. <input type="hidden" id="setmeal_id" name="setmeal_id" value=""/>
  448. <input type="hidden" name="unit" value=""/>
  449. <div id="leftTree" style="overflow:auto;position:relative;">
  450. <ul id="unitTree" class="tree" style="margin-top: 3px;">
  451. </div>
  452. </div>
  453. <div id="authorTab" position="center">
  454. <div id="showAuthorDiv" title="套餐权限" >
  455. <div style="margin-top:3px;margin-left:30px;float:left;">
  456. <input id="btnSave" type="button" class="l-button" value="保存" onclick="saveSetmeal()"/>
  457. </div>
  458. <div id="toCopyDiv" style="margin-top:3px;margin-left:20px;float:left;">
  459. <input id="btnCopy" style="width:105px;" type="button" class="l-button" value="从其他套餐复制" onclick="toCopy();"/>
  460. </div>
  461. <div id="copyDiv" style="margin-top:3px;margin-left:20px;float:left;display: none;" >
  462. <input id="btnCancel" type="button" class="l-button" value="取消复制" onclick="toCancel();"/>
  463. <select id="selectSetmeal" name="selectSetmeal" onchange="changeSetmeal();">
  464. <option value="">=请选择=</option>
  465. <c:forEach items="${smList }" var="sm" >
  466. <option value="${sm.universalid }">${sm.name }</option>
  467. </c:forEach>
  468. </select>
  469. </div>
  470. <div id="navtab1" style="width: 99%;margin:0 auto;overflow:hidden;height:99%; ">
  471. <c:forEach items="${prjs}" var="prj" varStatus="i">
  472. <div title="${prj.prjName}" ${i.index==0?"lselected='true'":""}>
  473. <div class="prjTree" style="width:99%;height:96%;float:left;overflow:auto">
  474. <ul id="${prj.key}" class="tree authorTree" ix="${i.index+1}" style="margin-top: 3px;">
  475. </div>
  476. </div>
  477. </c:forEach>
  478. </div>
  479. </div>
  480. <div tabid="comTabId" title="已购企业" id="comListTab" style="overflow: hidden;">
  481. <c:if test="${is_show==true }">
  482. <input id="btnRefresh" type="button" class="l-button" value="刷新" onclick="refreshSetmeal();" style="margin:5px;margin-right:0px;margin-left:10px;"/>
  483. <input id="btnAllot" type="button" class="l-button" value="企业套餐分配" onclick="allotSetmeal();" style="width:120px;margin:5px;"/>
  484. </c:if>
  485. <div id="orderGrid" style="margin: 0; padding: 0"></div>
  486. </div>
  487. </div>
  488. </div>
  489. </form>
  490. </div>
  491. </body>
  492. </html>