| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- /**
- * 菜单设置
- * */
- $(function() {
- $('.tool_bars').authorizeButton();
- gridList();
- });
- function gridList() {
- var $gridList = $("#gridList");
- $gridList.jqGrid({
- url: huayi.config.callcenter_url + 'configurationapi/api/moduleinfo/gettreegridjson',
- datatype: "json",
- autowidth: true,
- rownumbers: true, //如果为ture则会在表格左边新增一列,显示行顺序号,从1开始递增。此列名为'rn'.
- rownumWidth: 60,
- shrinkToFit: false, //此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽度
- gridview: true, //构造一行数据后添加到grid中,如果设为true则是将整个表格的数据都构造完成后再添加到grid中,但treeGrid, subGrid, or afterInsertRow 不能用
- treeGrid: true, //启用或者禁用treegrid模式
- treeGridModel: "adjacency", //treeGrid所使用的方法
- ExpandColumn: "opt_url", //指定那列来展开tree grid,默认为第一列,只有在treeGrid为true时起作用
- height: '100%',
- postData: {
- },
- colModel: [{
- label: "主键",
- name: "id",
- hidden: true,
- key: true
- },
- {
- label: '名称',
- name: 'module_name',
- width: 200,
- align: 'left'
- },
- {
- label: '链接',
- name: 'opt_url',
- width: 520,
- align: 'left'
- },
- {
- label: '菜单类型',
- name: 'target',
- width: 80,
- align: 'center',
- formatter: function(cellvalue) {
- if(cellvalue == "expand") {
- return "无页面";
- } else if(cellvalue == "iframe") {
- return "框架页";
- } else if(cellvalue == "open") {
- return "弹出页";
- } else if(cellvalue == "blank") {
- return "新窗口";
- }
- }
- },
- // {
- // label: "是否是菜单",
- // name: "F_IsMenu",
- // width: 100,
- // align: "center",
- // formatter: function(cellvalue) {
- // return cellvalue == true ? "<i class=\"glyphicon glyphicon-ok-circle\"></i>" : "<i class=\"glyphicon glyphicon-ban-circle\"></i>";
- // }
- // },
- {
- label: "是否启用",
- name: "state_flag",
- width: 100,
- align: "center",
- formatter: function(cellvalue) {
- return cellvalue == 1 ? "<i class=\"glyphicon glyphicon-ok-circle\"></i>" : "<i class=\"glyphicon glyphicon-ban-circle\"></i>";
- }
- },
- {
- label: '介绍',
- name: 'remark',
- width: 300,
- align: 'left'
- }
- ]
- });
- $("#sc_btns").click(function() {
- $gridList.jqGrid('setGridParam', {
- postData: {
- keyword: $("#sc_keyWords").val(),
- },
- }).trigger('reloadGrid');
- });
- }
- function btn_add() {
- var mid = $("#gridList").jqGridRowValue().id;
- var txt = $("#gridList").jqGridRowValue().module_name;
- layer.open({
- type: 2,
- content: "template/addOrEditMenus.html?mid=" + mid + "&txt=" + $(txt).text(), //iframe的url,no代表不显示滚动条
- title: '新增菜单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- function btn_edit() {
- var mid = $("#gridList").jqGridRowValue().id;
- var pid = $("#gridList").jqGridRowValue().parent;
- var pTxt = $("#gridList").getRowData(pid).module_name;
- if(!mid) {
- layer.confirm('您还没有选择菜单', {
- icon: 7,
- btn: ['确定', '取消'],
- });
- return;
- }
- layer.open({
- type: 2,
- content: "template/addOrEditMenus.html?isEdit=true&mid=" + mid + "&pid=" + pid + "&pTxt=" + $(pTxt).text(), //iframe的url,no代表不显示滚动条
- title: '修改菜单',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
- function btn_delete() {
- var mid = $("#gridList").jqGridRowValue().id;
- if(!mid) {
- layer.confirm('您还没有选择菜单', {
- icon: 7,
- btn: ['确定', '取消'],
- });
- return;
- }
- layer.confirm('您确定要删除当前选项吗?', {
- icon: 7,
- btn: ['确定', '取消'],
- yes: function(index, layero) {
-
- $.post(huayi.config.callcenter_url + "configurationapi/api/moduleinfo/delmodule", {
- ids: mid,
- }, function(result) {
- result = JSON.parse(result);
- if(result.state.toLowerCase() == "success") {
- layer.msg("删除成功");
- $("#gridList").resetSelection();
- $("#gridList").trigger("reloadGrid");
- }
- })
- },
- });
- }
- function btn_modulebutton() {
- var mid = $("#gridList").jqGridRowValue().id;
- if(!mid) {
- layer.confirm('您还没有选择菜单', {
- icon: 7,
- btn: ['确定', '取消'],
- });
- return;
- }
- layer.open({
- type: 2,
- content: "template/modulebuttons.html?mid=" + mid, //iframe的url,no代表不显示滚动条
- title: '按钮管理',
- resize: false,
- area: ['80%', '90%'], //宽高
- });
- }
|