| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- /**
- * 添加或修改菜单
- * */
- $(function() {
- autosize($('textarea'));
- var isEdit = helper.request.queryString("isEdit");
- var mid = helper.request.queryString("mid");
- var txt = helper.request.queryString("txt");
- txt = decodeURIComponent(txt);
- var pid = helper.request.queryString("pid");
- var pTxt = helper.request.queryString("pTxt");
- pTxt = decodeURIComponent(pTxt);
- //菜单下拉数据
- getMenuLists();
- if(isEdit) {
- //修改
- if(pid == "000000000000000000000000" || pid == "undefined") {
- $('#menus').val("顶级分类");
- $('#menus').attr('data-id', '000000000000000000000000');
- } else {
- $('#menus').val(pTxt);
- $('#menus').attr('data-id', pid);
- }
- getMenusInfo();
- $('#save_btns').on('click', saveEditAccount);
- } else {
- //添加
- if(mid == "undefined") {
- $('#menus').val("顶级分类");
- $('#menus').attr('data-id', '000000000000000000000000');
- } else {
- $('#menus').val(txt);
- $('#menus').attr('data-id', mid);
- }
- $('#save_btns').on('click', saveAccount);
- }
- $('#menus').on('focus click', function() {
- $('#menusTreeView').removeClass('hidden').addClass('show');
- });
- $('#menus').on('keyup', function() {
- if($(this).val() == '') {
- $('menusTreeView').treeview('uncheckAll', {
- silent: true
- });
- $(this).attr('data-id', '000000000000000000000000');
- }
- });
- $('#menus + .caret').on('click', function() {
- $('#menusTreeView').removeClass('hidden').addClass('show');
- });
- $('#menusTreeView').mouseleave(function() {
- $(this).removeClass('show').addClass('hidden');
- });
- });
- //获取菜单信息
- function getMenusInfo() {
- var mid = helper.request.queryString("mid");
- $.getJSON(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/getModule", {
- mid: mid,
- }, function(data) {
- if(data.state == "success") {
- var res = data.data;
- $('#menusName').val(res.name);
- $('#menusCode').val(res.code);
- $('#menusUrl').val(res.url);
- $('#menusSort').val(res.sort);
- $('#menusIcons').val(res.imgUrl);
- $('#menusIcons').trigger('change');
- $('#menusType').selectpicker('val', res.target).trigger('change');
- $('#menusEabled').find("input[type='radio'][value= " + res.enable + "]").attr("checked", true);
- $('#menusRemark').val(res.remark);
- }
- });
- }
- //添加保存菜单信息
- function saveAccount() {
- if(!$.trim($('#menusName').val())) {
- layer.confirm('菜单名称不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#menusCode').val())) {
- layer.confirm('菜单代码不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#menusUrl').val())) {
- layer.confirm('菜单链接地址不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!regexs.integerReg.test($.trim($('#menusSort').val()))) {
- layer.confirm('请输入有效的排序编号(正整数、负整数、0)', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/addModule", {
- parentid: $('#menus').attr('data-id'), //当前选择节点ID父级ID,无父级ID为'000000000000000000000000'
- code: $('#menusCode').val(),
- name: $('#menusName').val(), //菜单名称
- url: $("#menusUrl").val(),
- target: $('#menusType').val(),
- flag: $('#menusEabled').find('input[type="radio"]:checked').val(), //1为启用,0不启用
- sort: $('#menusSort').val(), //排列序号
- imgUrl: encodeURIComponent($('#menusIcons').val()),
- remark: $('#menusRemark').val(),
- }, function(data) {
- var data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.$("#gridList").resetSelection();
- parent.$("#gridList").trigger("reloadGrid");
- parent.layer.msg("添加成功");
- }
- });
- }
- //修改保存菜单信息
- function saveEditAccount() {
- var mid = helper.request.queryString("mid");
- if(!$.trim($('#menusName').val())) {
- layer.confirm('菜单名称不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#menusCode').val())) {
- layer.confirm('菜单代码不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#menusUrl').val())) {
- layer.confirm('菜单链接地址不允许为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!regexs.integerReg.test($.trim($('#menusSort').val()))) {
- layer.confirm('请输入有效的排序编号(正整数、负整数、0)', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/editmodule", {
- id: mid, //当前选择节点ID
- parentid: $('#menus').attr('data-id'), //父级ID,无父级ID为'000000000000000000000000'
- code: $('#menusCode').val(), //编码
- name: $('#menusName').val(), //菜单名称
- url: $("#menusUrl").val(), //链接地址
- target: $('#menusType').val(), //目标
- flag: $('#menusEabled').find('input[type="radio"]:checked').val(), //1为启用,0不启用
- sort: $('#menusSort').val(), //排列序号
- imgUrl: encodeURIComponent($('#menusIcons').val()), //图片
- remark: $('#menusRemark').val(), //备注信息
- }, function(data) {
- var data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.$("#gridList").resetSelection();
- parent.$("#gridList").trigger("reloadGrid");
- parent.layer.msg("修改成功");
- }
- });
- }
- //菜单下拉
- function getMenuLists() {
- var pid = helper.request.queryString("pid");
- $.getJSON(huayi.config.callcenter_url + 'configurationapi/api/moduleinfo/getall', {
- }, function(result) {
- if(result.state.toLowerCase() == "success") {
- var defaultDatas = result.data;
- var $sTree = $('#menusTreeView').treeview({
- color: "#428bca",
- expandIcon: 'glyphicon glyphicon-chevron-right',
- collapseIcon: 'glyphicon glyphicon-chevron-down',
- nodeIcon: 'fa fa-folder-o',
- //selectedIcon: "glyphicon glyphicon-stop",
- //icon: "glyphicon glyphicon-stop",
- //emptyIcon: 'glyphicon',
- //showCheckbox: true,
- selectable: true,
- state: {
- selected: true
- },
- data: defaultDatas,
- onNodeSelected: function(event, node) {
- $sTree.treeview('clearSearch');
- $('#menus').val(node.text);
- $('#menus').attr('data-id', node.id);
- $('#menusTreeView').removeClass('show').addClass('hidden');
- },
- onNodeUnselected: function(event, node) {
- $('#menus').val('顶级分类');
- $('#menus').attr('data-id', '000000000000000000000000');
- }
- });
- $('#menusTreeView').treeview('collapseAll', {
- silent: true
- });
- var findSNodes = function() {
- return $sTree.treeview('search', [$('#menus').val(), {
- ignoreCase: false,
- exactMatch: false
- }]);
- };
- $('#menus').on('keyup', function(e) {
- var selectableNodes = findSNodes();
- // var m = $('#menusTreeView').treeview('getParent', selectableNodes);
- // $('#menusTreeView').treeview('selectNode', [ m, { silent: true } ]);
- });
- }
- })
- }
- //图标数据
- var iconData = [{
- "text": "默认图标",
- "id": ""
- }, {
- "text": "项目",
- "id": ""
- }, {
- "text": "项目管理",
- "id": ""
- }, {
- "text": "项目合同",
- "id": ""
- }, {
- "text": "项目类型",
- "id": ""
- }, {
- "text": "项目到期",
- "id": ""
- }, {
- "text": "项目申报",
- "id": ""
- }, {
- "text": "设备型号",
- "id": ""
- }, {
- "text": "设备配置",
- "id": ""
- }, {
- "text": "设备管理",
- "id": ""
- }, {
- "text": "设备管理01",
- "id": ""
- }, {
- "text": "设备管理02",
- "id": ""
- }, {
- "text": "设备清单",
- "id": ""
- }, {
- "text": "设备列表",
- "id": ""
- }, {
- "text": "设备",
- "id": ""
- }, {
- "text": "设备审核",
- "id": ""
- }, {
- "text": "设备01",
- "id": ""
- }, {
- "text": "网站程序",
- "id": ""
- }, {
- "text": "网站",
- "id": ""
- }, {
- "text": "网站01",
- "id": ""
- }, {
- "text": "系统安全",
- "id": ""
- }, {
- "text": "系统设置",
- "id": ""
- }, {
- "text": "系统服务",
- "id": ""
- }, {
- "text": "运维管理",
- "id": ""
- }, {
- "text": "运维管理01",
- "id": ""
- }, {
- "text": "系统管理",
- "id": ""
- }, {
- "text": "网站02",
- "id": ""
- }, {
- "text": "网站管理",
- "id": ""
- }, {
- "text": "网站设置",
- "id": ""
- }, {
- "text": "数据",
- "id": ""
- }, {
- "text": "数据01",
- "id": ""
- }, {
- "text": "数据02",
- "id": ""
- }, {
- "text": "报表管理",
- "id": ""
- }, {
- "text": "统计分析",
- "id": ""
- }, {
- "text": "分析",
- "id": ""
- }, {
- "text": "数据分析",
- "id": ""
- }, {
- "text": "报表分析",
- "id": ""
- }, {
- "text": "报表分析01",
- "id": ""
- }, {
- "text": "统计分析01",
- "id": ""
- }, {
- "text": "知识库",
- "id": ""
- }, {
- "text": "知识库01",
- "id": ""
- }, {
- "text": "知识库02",
- "id": ""
- }, {
- "text": "调查问卷",
- "id": ""
- }, {
- "text": "调查问卷01",
- "id": ""
- }, {
- "text": "问卷管理",
- "id": ""
- }, {
- "text": "问卷调查",
- "id": ""
- }, {
- "text": "问卷分析",
- "id": ""
- }, {
- "text": "运维管理",
- "id": ""
- }, {
- "text": "运维报表",
- "id": ""
- }, {
- "text": "运维设置",
- "id": ""
- }, {
- "text": "运维申请",
- "id": ""
- }, {
- "text": "运维支持",
- "id": ""
- }, {
- "text": "系统运维",
- "id": ""
- }, {
- "text": "运维管理01",
- "id": ""
- }, {
- "text": "软件开发",
- "id": ""
- }, {
- "text": "已报修",
- "id": ""
- }, {
- "text": "报修",
- "id": ""
- }, {
- "text": "维修申请",
- "id": ""
- }, {
- "text": "维修",
- "id": ""
- }, {
- "text": "正在维修的工单",
- "id": ""
- }, {
- "text": "路径分析",
- "id": ""
- }, {
- "text": "质检",
- "id": ""
- }, {
- "text": "质检01",
- "id": ""
- }, {
- "text": "app",
- "id": ""
- }, {
- "text": "app01",
- "id": ""
- }, {
- "text": "版本更新",
- "id": ""
- }, {
- "text": "app03",
- "id": ""
- }, {
- "text": "版本更新01",
- "id": ""
- }, {
- "text": "版本更新02",
- "id": ""
- }, {
- "text": "app升级",
- "id": ""
- }, {
- "text": "管理员",
- "id": ""
- }, {
- "text": "用户",
- "id": ""
- }, {
- "text": "维修工管理",
- "id": ""
- }, {
- "text": "维修工",
- "id": ""
- }, {
- "text": "维修工01",
- "id": ""
- }, {
- "text": "用户01",
- "id": ""
- }, {
- "text": "用户02",
- "id": ""
- }, {
- "text": "管理员02",
- "id": ""
- }, {
- "text": "管理员03",
- "id": ""
- }, {
- "text": "项目成员",
- "id": ""
- }, {
- "text": "项目成员01",
- "id": ""
- }, {
- "text": "正在拨号",
- "id": ""
- }, {
- "text": "通话",
- "id": ""
- }, {
- "text": "电话",
- "id": ""
- }, {
- "text": "电话01",
- "id": ""
- }, {
- "text": "通话记录",
- "id": ""
- }, {
- "text": "多方通话",
- "id": ""
- }, {
- "text": "电话未接",
- "id": ""
- }, {
- "text": "电话02",
- "id": ""
- }, {
- "text": "通话时间",
- "id": ""
- }, {
- "text": "通话记录",
- "id": ""
- }, {
- "text": "忙碌",
- "id": ""
- }, {
- "text": "忙碌01",
- "id": ""
- }, {
- "text": "客服",
- "id": ""
- }, {
- "text": "客服01",
- "id": ""
- }, {
- "text": "客服02",
- "id": ""
- }, {
- "text": "客服03",
- "id": ""
- }, {
- "text": "客服04",
- "id": ""
- }, {
- "text": "客服05",
- "id": ""
- }, {
- "text": "客服06",
- "id": ""
- }]
- $("#menusIcons").select2({
- minimumResultsForSearch: -1,
- data: iconData,
- templateResult: formatState
- });
- //格式化图标下拉
- function formatState(state) {
- if(!state.id) {
- return state.text;
- }
- var $state = $(
- '<span><i class="icon-color iconfont">' + state.id + '</i>' + state.text + '</span>'
- );
- return $state;
- };
|