暫無描述

addOrEditMenus.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /**
  2. * 添加或修改菜单
  3. * */
  4. $(function() {
  5. autosize($('textarea'));
  6. var isEdit = helper.request.queryString("isEdit");
  7. var mid = helper.request.queryString("mid");
  8. var txt = helper.request.queryString("txt");
  9. txt = decodeURIComponent(txt);
  10. var pid = helper.request.queryString("pid");
  11. var pTxt = helper.request.queryString("pTxt");
  12. pTxt = decodeURIComponent(pTxt);
  13. //菜单下拉数据
  14. getMenuLists();
  15. if(isEdit) {
  16. //修改
  17. if(pid == "000000000000000000000000" || pid == "undefined") {
  18. $('#menus').val("顶级分类");
  19. $('#menus').attr('data-id', '000000000000000000000000');
  20. } else {
  21. $('#menus').val(pTxt);
  22. $('#menus').attr('data-id', pid);
  23. }
  24. getMenusInfo();
  25. $('#save_btns').on('click', saveEditAccount);
  26. } else {
  27. //添加
  28. if(mid == "undefined") {
  29. $('#menus').val("顶级分类");
  30. $('#menus').attr('data-id', '000000000000000000000000');
  31. } else {
  32. $('#menus').val(txt);
  33. $('#menus').attr('data-id', mid);
  34. }
  35. $('#save_btns').on('click', saveAccount);
  36. }
  37. $('#menus').on('focus click', function() {
  38. $('#menusTreeView').removeClass('hidden').addClass('show');
  39. });
  40. $('#menus').on('keyup', function() {
  41. if($(this).val() == '') {
  42. $('menusTreeView').treeview('uncheckAll', {
  43. silent: true
  44. });
  45. $(this).attr('data-id', '000000000000000000000000');
  46. }
  47. });
  48. $('#menus + .caret').on('click', function() {
  49. $('#menusTreeView').removeClass('hidden').addClass('show');
  50. });
  51. $('#menusTreeView').mouseleave(function() {
  52. $(this).removeClass('show').addClass('hidden');
  53. });
  54. });
  55. //获取菜单信息
  56. function getMenusInfo() {
  57. var mid = helper.request.queryString("mid");
  58. $.getJSON(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/getModule", {
  59. mid: mid,
  60. }, function(data) {
  61. if(data.state == "success") {
  62. var res = data.data;
  63. $('#menusName').val(res.name);
  64. $('#menusCode').val(res.code);
  65. $('#menusUrl').val(res.url);
  66. $('#menusSort').val(res.sort);
  67. $('#menusIcons').val(res.imgUrl);
  68. $('#menusIcons').trigger('change');
  69. $('#menusType').selectpicker('val', res.target).trigger('change');
  70. $('#menusEabled').find("input[type='radio'][value= " + res.enable + "]").attr("checked", true);
  71. $('#menusRemark').val(res.remark);
  72. }
  73. });
  74. }
  75. //添加保存菜单信息
  76. function saveAccount() {
  77. if(!$.trim($('#menusName').val())) {
  78. layer.confirm('菜单名称不允许为空!', {
  79. icon: 2,
  80. btn: ['确定'] //按钮
  81. });
  82. return;
  83. }
  84. if(!$.trim($('#menusCode').val())) {
  85. layer.confirm('菜单代码不允许为空!', {
  86. icon: 2,
  87. btn: ['确定'] //按钮
  88. });
  89. return;
  90. }
  91. if(!$.trim($('#menusUrl').val())) {
  92. layer.confirm('菜单链接地址不允许为空!', {
  93. icon: 2,
  94. btn: ['确定'] //按钮
  95. });
  96. return;
  97. }
  98. if(!regexs.integerReg.test($.trim($('#menusSort').val()))) {
  99. layer.confirm('请输入有效的排序编号(正整数、负整数、0)', {
  100. icon: 2,
  101. btn: ['确定'] //按钮
  102. });
  103. return;
  104. }
  105. $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/addModule", {
  106. parentid: $('#menus').attr('data-id'), //当前选择节点ID父级ID,无父级ID为'000000000000000000000000'
  107. code: $('#menusCode').val(),
  108. name: $('#menusName').val(), //菜单名称
  109. url: $("#menusUrl").val(),
  110. target: $('#menusType').val(),
  111. flag: $('#menusEabled').find('input[type="radio"]:checked').val(), //1为启用,0不启用
  112. sort: $('#menusSort').val(), //排列序号
  113. imgUrl: encodeURIComponent($('#menusIcons').val()),
  114. remark: $('#menusRemark').val(),
  115. }, function(data) {
  116. var data = JSON.parse(data);
  117. if(data.state == "success") {
  118. var index = parent.layer.getFrameIndex(window.name);
  119. parent.layer.close(index);
  120. parent.$("#gridList").resetSelection();
  121. parent.$("#gridList").trigger("reloadGrid");
  122. parent.layer.msg("添加成功");
  123. }
  124. });
  125. }
  126. //修改保存菜单信息
  127. function saveEditAccount() {
  128. var mid = helper.request.queryString("mid");
  129. if(!$.trim($('#menusName').val())) {
  130. layer.confirm('菜单名称不允许为空!', {
  131. icon: 2,
  132. btn: ['确定'] //按钮
  133. });
  134. return;
  135. }
  136. if(!$.trim($('#menusCode').val())) {
  137. layer.confirm('菜单代码不允许为空!', {
  138. icon: 2,
  139. btn: ['确定'] //按钮
  140. });
  141. return;
  142. }
  143. if(!$.trim($('#menusUrl').val())) {
  144. layer.confirm('菜单链接地址不允许为空!', {
  145. icon: 2,
  146. btn: ['确定'] //按钮
  147. });
  148. return;
  149. }
  150. if(!regexs.integerReg.test($.trim($('#menusSort').val()))) {
  151. layer.confirm('请输入有效的排序编号(正整数、负整数、0)', {
  152. icon: 2,
  153. btn: ['确定'] //按钮
  154. });
  155. return;
  156. }
  157. $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/editmodule", {
  158. id: mid, //当前选择节点ID
  159. parentid: $('#menus').attr('data-id'), //父级ID,无父级ID为'000000000000000000000000'
  160. code: $('#menusCode').val(), //编码
  161. name: $('#menusName').val(), //菜单名称
  162. url: $("#menusUrl").val(), //链接地址
  163. target: $('#menusType').val(), //目标
  164. flag: $('#menusEabled').find('input[type="radio"]:checked').val(), //1为启用,0不启用
  165. sort: $('#menusSort').val(), //排列序号
  166. imgUrl: encodeURIComponent($('#menusIcons').val()), //图片
  167. remark: $('#menusRemark').val(), //备注信息
  168. }, function(data) {
  169. var data = JSON.parse(data);
  170. if(data.state == "success") {
  171. var index = parent.layer.getFrameIndex(window.name);
  172. parent.layer.close(index);
  173. parent.$("#gridList").resetSelection();
  174. parent.$("#gridList").trigger("reloadGrid");
  175. parent.layer.msg("修改成功");
  176. }
  177. });
  178. }
  179. //菜单下拉
  180. function getMenuLists() {
  181. var pid = helper.request.queryString("pid");
  182. $.getJSON(huayi.config.callcenter_url + 'configurationapi/api/moduleinfo/getall', {
  183. }, function(result) {
  184. if(result.state.toLowerCase() == "success") {
  185. var defaultDatas = result.data;
  186. var $sTree = $('#menusTreeView').treeview({
  187. color: "#428bca",
  188. expandIcon: 'glyphicon glyphicon-chevron-right',
  189. collapseIcon: 'glyphicon glyphicon-chevron-down',
  190. nodeIcon: 'fa fa-folder-o',
  191. //selectedIcon: "glyphicon glyphicon-stop",
  192. //icon: "glyphicon glyphicon-stop",
  193. //emptyIcon: 'glyphicon',
  194. //showCheckbox: true,
  195. selectable: true,
  196. state: {
  197. selected: true
  198. },
  199. data: defaultDatas,
  200. onNodeSelected: function(event, node) {
  201. $sTree.treeview('clearSearch');
  202. $('#menus').val(node.text);
  203. $('#menus').attr('data-id', node.id);
  204. $('#menusTreeView').removeClass('show').addClass('hidden');
  205. },
  206. onNodeUnselected: function(event, node) {
  207. $('#menus').val('顶级分类');
  208. $('#menus').attr('data-id', '000000000000000000000000');
  209. }
  210. });
  211. $('#menusTreeView').treeview('collapseAll', {
  212. silent: true
  213. });
  214. var findSNodes = function() {
  215. return $sTree.treeview('search', [$('#menus').val(), {
  216. ignoreCase: false,
  217. exactMatch: false
  218. }]);
  219. };
  220. $('#menus').on('keyup', function(e) {
  221. var selectableNodes = findSNodes();
  222. // var m = $('#menusTreeView').treeview('getParent', selectableNodes);
  223. // $('#menusTreeView').treeview('selectNode', [ m, { silent: true } ]);
  224. });
  225. }
  226. })
  227. }
  228. //图标数据
  229. var iconData = [{
  230. "text": "默认图标",
  231. "id": "&#xe34f"
  232. }, {
  233. "text": "项目",
  234. "id": "&#xe350"
  235. }, {
  236. "text": "项目管理",
  237. "id": "&#xe351"
  238. }, {
  239. "text": "项目合同",
  240. "id": "&#xe352"
  241. }, {
  242. "text": "项目类型",
  243. "id": "&#xe353"
  244. }, {
  245. "text": "项目到期",
  246. "id": "&#xe354"
  247. }, {
  248. "text": "项目申报",
  249. "id": "&#xe355"
  250. }, {
  251. "text": "设备型号",
  252. "id": "&#xe356"
  253. }, {
  254. "text": "设备配置",
  255. "id": "&#xe357"
  256. }, {
  257. "text": "设备管理",
  258. "id": "&#xe358"
  259. }, {
  260. "text": "设备管理01",
  261. "id": "&#xe359"
  262. }, {
  263. "text": "设备管理02",
  264. "id": "&#xe35a"
  265. }, {
  266. "text": "设备清单",
  267. "id": "&#xe35b"
  268. }, {
  269. "text": "设备列表",
  270. "id": "&#xe35c"
  271. }, {
  272. "text": "设备",
  273. "id": "&#xe35d"
  274. }, {
  275. "text": "设备审核",
  276. "id": "&#xe35e"
  277. }, {
  278. "text": "设备01",
  279. "id": "&#xe35f"
  280. }, {
  281. "text": "网站程序",
  282. "id": "&#xe360"
  283. }, {
  284. "text": "网站",
  285. "id": "&#xe361"
  286. }, {
  287. "text": "网站01",
  288. "id": "&#xe362"
  289. }, {
  290. "text": "系统安全",
  291. "id": "&#xe363"
  292. }, {
  293. "text": "系统设置",
  294. "id": "&#xe364"
  295. }, {
  296. "text": "系统服务",
  297. "id": "&#xe365"
  298. }, {
  299. "text": "运维管理",
  300. "id": "&#xe366"
  301. }, {
  302. "text": "运维管理01",
  303. "id": "&#xe367"
  304. }, {
  305. "text": "系统管理",
  306. "id": "&#xe368"
  307. }, {
  308. "text": "网站02",
  309. "id": "&#xe369"
  310. }, {
  311. "text": "网站管理",
  312. "id": "&#xe36a"
  313. }, {
  314. "text": "网站设置",
  315. "id": "&#xe36b"
  316. }, {
  317. "text": "数据",
  318. "id": "&#xe36c"
  319. }, {
  320. "text": "数据01",
  321. "id": "&#xe36d"
  322. }, {
  323. "text": "数据02",
  324. "id": "&#xe36e"
  325. }, {
  326. "text": "报表管理",
  327. "id": "&#xe36f"
  328. }, {
  329. "text": "统计分析",
  330. "id": "&#xe370"
  331. }, {
  332. "text": "分析",
  333. "id": "&#xe371"
  334. }, {
  335. "text": "数据分析",
  336. "id": "&#xe372"
  337. }, {
  338. "text": "报表分析",
  339. "id": "&#xe373"
  340. }, {
  341. "text": "报表分析01",
  342. "id": "&#xe374"
  343. }, {
  344. "text": "统计分析01",
  345. "id": "&#xe375"
  346. }, {
  347. "text": "知识库",
  348. "id": "&#xe376"
  349. }, {
  350. "text": "知识库01",
  351. "id": "&#xe377"
  352. }, {
  353. "text": "知识库02",
  354. "id": "&#xe378"
  355. }, {
  356. "text": "调查问卷",
  357. "id": "&#xe379"
  358. }, {
  359. "text": "调查问卷01",
  360. "id": "&#xe37a"
  361. }, {
  362. "text": "问卷管理",
  363. "id": "&#xe37b"
  364. }, {
  365. "text": "问卷调查",
  366. "id": "&#xe37c"
  367. }, {
  368. "text": "问卷分析",
  369. "id": "&#xe37d"
  370. }, {
  371. "text": "运维管理",
  372. "id": "&#xe37e"
  373. }, {
  374. "text": "运维报表",
  375. "id": "&#xe37f"
  376. }, {
  377. "text": "运维设置",
  378. "id": "&#xe380"
  379. }, {
  380. "text": "运维申请",
  381. "id": "&#xe381"
  382. }, {
  383. "text": "运维支持",
  384. "id": "&#xe382"
  385. }, {
  386. "text": "系统运维",
  387. "id": "&#xe383"
  388. }, {
  389. "text": "运维管理01",
  390. "id": "&#xe384"
  391. }, {
  392. "text": "软件开发",
  393. "id": "&#xe385"
  394. }, {
  395. "text": "已报修",
  396. "id": "&#xe386"
  397. }, {
  398. "text": "报修",
  399. "id": "&#xe387"
  400. }, {
  401. "text": "维修申请",
  402. "id": "&#xe388"
  403. }, {
  404. "text": "维修",
  405. "id": "&#xe389"
  406. }, {
  407. "text": "正在维修的工单",
  408. "id": "&#xe38a"
  409. }, {
  410. "text": "路径分析",
  411. "id": "&#xe38b"
  412. }, {
  413. "text": "质检",
  414. "id": "&#xe38c"
  415. }, {
  416. "text": "质检01",
  417. "id": "&#xe38d"
  418. }, {
  419. "text": "app",
  420. "id": "&#xe38e"
  421. }, {
  422. "text": "app01",
  423. "id": "&#xe38f"
  424. }, {
  425. "text": "版本更新",
  426. "id": "&#xe390"
  427. }, {
  428. "text": "app03",
  429. "id": "&#xe391"
  430. }, {
  431. "text": "版本更新01",
  432. "id": "&#xe392"
  433. }, {
  434. "text": "版本更新02",
  435. "id": "&#xe393"
  436. }, {
  437. "text": "app升级",
  438. "id": "&#xe394"
  439. }, {
  440. "text": "管理员",
  441. "id": "&#xe395"
  442. }, {
  443. "text": "用户",
  444. "id": "&#xe396"
  445. }, {
  446. "text": "维修工管理",
  447. "id": "&#xe397"
  448. }, {
  449. "text": "维修工",
  450. "id": "&#xe398"
  451. }, {
  452. "text": "维修工01",
  453. "id": "&#xe399"
  454. }, {
  455. "text": "用户01",
  456. "id": "&#xe39a"
  457. }, {
  458. "text": "用户02",
  459. "id": "&#xe39b"
  460. }, {
  461. "text": "管理员02",
  462. "id": "&#xe39c"
  463. }, {
  464. "text": "管理员03",
  465. "id": "&#xe39d"
  466. }, {
  467. "text": "项目成员",
  468. "id": "&#xe39e"
  469. }, {
  470. "text": "项目成员01",
  471. "id": "&#xe39f"
  472. }, {
  473. "text": "正在拨号",
  474. "id": "&#xe3a0"
  475. }, {
  476. "text": "通话",
  477. "id": "&#xe3a1"
  478. }, {
  479. "text": "电话",
  480. "id": "&#xe3a2"
  481. }, {
  482. "text": "电话01",
  483. "id": "&#xe3a3"
  484. }, {
  485. "text": "通话记录",
  486. "id": "&#xe3a4"
  487. }, {
  488. "text": "多方通话",
  489. "id": "&#xe3a5"
  490. }, {
  491. "text": "电话未接",
  492. "id": "&#xe3a6"
  493. }, {
  494. "text": "电话02",
  495. "id": "&#xe3a7"
  496. }, {
  497. "text": "通话时间",
  498. "id": "&#xe3a8"
  499. }, {
  500. "text": "通话记录",
  501. "id": "&#xe3a9"
  502. }, {
  503. "text": "忙碌",
  504. "id": "&#xe3aa"
  505. }, {
  506. "text": "忙碌01",
  507. "id": "&#xe3ab"
  508. }, {
  509. "text": "客服",
  510. "id": "&#xe3ac"
  511. }, {
  512. "text": "客服01",
  513. "id": "&#xe3ad"
  514. }, {
  515. "text": "客服02",
  516. "id": "&#xe3ae"
  517. }, {
  518. "text": "客服03",
  519. "id": "&#xe3af"
  520. }, {
  521. "text": "客服04",
  522. "id": "&#xe3b0"
  523. }, {
  524. "text": "客服05",
  525. "id": "&#xe3b1"
  526. }, {
  527. "text": "客服06",
  528. "id": "&#xe3b2"
  529. }]
  530. $("#menusIcons").select2({
  531. minimumResultsForSearch: -1,
  532. data: iconData,
  533. templateResult: formatState
  534. });
  535. //格式化图标下拉
  536. function formatState(state) {
  537. if(!state.id) {
  538. return state.text;
  539. }
  540. var $state = $(
  541. '<span><i class="icon-color iconfont">' + state.id + '</i>' + state.text + '</span>'
  542. );
  543. return $state;
  544. };