| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- /***
- * 角色管理
- * */
- var table = $('#table1');
- var jsid;
- $(function() {
- autosize($('textarea'));
- $('.tool_bars').authorizeButton();
- // laydate.render({
- // elem: '#sc_times',
- // range: '~',
- // theme: '#249fea',
- // });
- //左边表格
- initTable();
- //搜索功能
- $('#sc_btns').click(function() {
- initTable()
- })
- });
- //========================添加功能开始=========================
- function btn_add() {
- $('.addModel').css('display', 'block');
- }
- //关闭按钮
- $('.addBtr').click(function() {
- $('.addModel').css('display', 'none');
- })
- //保存按钮
- $('.addCun').click(function() {
- if($('.add_jsz').val() == '') {
- $('.addJsz_kong').css('display', 'inline-block')
- } else {
- $('.addModel').css('display', 'none');
- ad();
- }
- })
- function ad() {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "configurationapi/api/post/add",
- async: true,
- dataType: 'json',
- data: {
- postname: $('.add_postname').val(), //角色名称
- postcode: $('.add_postcode').val(), //备注
- // sort: $('.add_sort').val(),
- remark: $('.add_remark').val()
- },
- success: function(data) {
- if(data.state.toLowerCase() == 'success') {
- layer.msg("添加成功!");
- table.bootstrapTable('refresh');
- }
- }
- });
- }
- //*************************添加功能结束=========================
- //========================修改功能开始=========================
- function btn_edit() {
- if(jsid) {
- $('.changeModel').css('display', 'block');
- cg(jsid)
- } else {
- layer.confirm('请选择修改行!', {
- btn: ['确定']
- });
- return;
- }
- }
- //关闭按钮
- $('.changeBtr').click(function() {
- $('.changeModel').css('display', 'none');
- })
- //保存按钮
- $('.changeCun').click(function() {
- if($('.change_jsz').val() == '') {
- $('.change_kong').css('display', 'inline-block')
- } else {
- $('.changeModel').css('display', 'none');
- cc(jsid);
- }
- })
- function cg(jsid) {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "configurationapi/api/post/getdetailes",
- async: true,
- dataType: 'json',
- data: {
- id: jsid //角色id
- },
- success: function(data) {
- var con = data.data;
- if(data.state.toLowerCase() == 'success') {
- $('.change_postname').val(con.postname);
- $('.change_postcode').val(con.postcode);
- // $('.change_sort').val(con.sort);
- $('.change_remark').val(con.remark);
- }
- }
- });
- }
- function cc(jsid) {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "configurationapi/api/post/update",
- async: true,
- dataType: 'json',
- data: {
- id: jsid, //角色id
- postname: $('.change_postname').val(),
- postcode: $('.change_postcode').val(),
- // sort: $('.change_sort').val(),
- remark: $('.change_remark').val(), //备注
- },
- success: function(data) {
- if(data.state.toLowerCase() == 'success') {
- layer.msg("修改成功!");
- table.bootstrapTable('refresh');
- }
- }
- });
- }
- //*************************修改功能结束=========================
- //========================删除功能开始=========================
- function btn_delete() {
- if(jsid) {
- // if(jsid == '5aaa5a54b9c1893cb015df26') {
- // layer.confirm('系统维护不能删除!', {
- // btn: ['确定']
- // });
- // return;
- // }
- // $('.delModel').css('display', 'block');
- del(jsid);
- } else {
- layer.confirm('请选择要删除的行!', {
- btn: ['确定']
- });
- return;
- }
- }
- //关闭按钮
- $('.delBtr').click(function() {
- $('.delModel').css('display', 'none');
- })
- //取消按钮
- $('.return').click(function() {
- $('.delModel').css('display', 'none');
- })
- //确定按钮
- $('.sure').click(function() {
- $('.delModel').css('display', 'none');
- })
- function del(jsid) {
- // if(jsid == 39) {
- // layer.confirm('系统管理员不能删除!', {
- // btn: ['确定']
- // });
- // return;
- // }
- layer.confirm('确定删除当前选中岗位?', {
- btn: ['是', '否'] //按钮
- }, function() {
- /*执行删除 发送请求*/
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "configurationapi/api/post/delete",
- async: true,
- dataType: 'json',
- data: {
- ids: jsid //岗位id
- },
- success: function(data) {
- if(data.state.toLowerCase() == 'success') {
- layer.msg("删除成功!");
- table.bootstrapTable('refresh');
- } else {
- alert(data.message);
- }
- }
- });
- });
-
- }
- //*************************删除功能结束=========================
- //右边树形结构
- tree(jsid);
- function tree(jid) {
- $.get(huayi.config.callcenter_url + "configurationapi/api/postsystem/getpostsystem", {
- postid: jid
- }, function(result) {
- result = $.parseJSON(result);
- $(result.data).each(function(i, n) {
- if(n.ischecked == true) {
- n.checked = "true";
- }
- })
- $.fn.zTree.init($("#treeDemo"), setting1, result.data); //实例化树形图
- });
- }
- var setting1 = {
- check: {
- enable: true,
- chkboxType: {
- "Y": "s",
- "N": "s"
- },
- },
- data: {
- simpleData: {
- enable: true,
- idKey: "id",
- pIdKey: "pid",
- rootPId: -1
- }
- },
- callback: {
- onCheck: zTreeOnClick
- }
- };
- function zTreeOnClick(event, treeId, treeNode) {
- var name = treeNode.name;
- };
- //保存岗位
- function pro(app, jsid) {
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "configurationapi/api/postsystem/savepostsystem",
- async: true,
- dataType: 'json',
- data: {
- postid: jsid, //岗位id
- ids: app// 选中权限树的id值
- },
- success: function(data) {
- if(data.state.toLowerCase() == 'success') {
- // layer.confirm('保存权限成功!', {
- // btn: ['确定']
- // });
- // return;
- layer.msg("保存岗位成功!");
- }
- }
- });
- }
- function btn_save() {
- var app = [];
- var ztree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);
- $.each(ztree, function(i, n) {
- app.push(n.id);
- });
- if(jsid){
- pro(app, jsid);
- }else{
- layer.confirm('请选择用户角色!', {
- btn: ['确定']
- });
- return;
- }
- }
- function initTable() {
- //先销毁表格
- table.bootstrapTable('destroy');
- //初始化表格,动态从服务器加载数据
- table.bootstrapTable({
- method: "get", //使用get请求到服务器获取数据
- url: huayi.config.callcenter_url + "configurationapi/api/post/getlistbypage", //获取数据的Servlet地址
- contentType: "application/x-www-form-urlencoded",
- striped: true,
- striped: true, //表格显示条纹
- pagination: true, //启动分页
- pageSize: 10, //每页显示的记录数
- pageNumber: 1, //当前第几页
- pageList: [10, 15, 20, 30, 50, 100], //记录数可选列表
- search: false, //是否启用查询
- showColumns: false, //显示下拉框勾选要显示的列
- showRefresh: false, //显示刷新按钮
- sidePagination: "server", //表示服务端请求
- //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
- //设置为limit可以获取limit, offset, search, sort, order
- queryParamsType: "undefined",
- queryParams: function queryParams(params) { //设置查询参数
- var param = {
- pageindex: params.pageNumber,
- pagesize: params.pageSize,
- keyword: $('#searJsz').val()
- };
- return param;
- },
- onLoadSuccess: function(data) { //加载成功时执行
- //layer.msg("加载成功");
- var newData = {};
- newData.state = data.state;
- newData.message = data.message;
- newData.rows = data.data.rows;
- newData.total = data.data.total;
- $('#table1').bootstrapTable('load', newData);
-
-
-
- },
- onLoadError: function() { //加载失败时执行
- //layer.msg("加载数据失败", { time: 1500, icon: 2 });
- }
- });
- }
- /*选中行添加背景颜色*/
- table.on("click-row.bs.table", function(e, row, ele) {
- $('.success').removeClass('success'); //去除之前选中的行的,选中样式
- $(ele).addClass('success'); //添加当前选中的 success样式用于区别
- jsid = row.id;
- tree(jsid);
- });
- function setCode(val, row, index) {
- var page = table.bootstrapTable("getPageCode");
- return page.pageSize * (page.pageNumber - 1) + index + 1;
- }
|