123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="renderer" content="webkit|ie-comp|ie-stand">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
- <meta http-equiv="Cache-Control" content="no-siteapp" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/gray/easyui.css" />
- <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/icon.css" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/jquery.easyui.min.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/locale/easyui-lang-zh_CN.js"></script>
- <style type="text/css">
- .panel-header, .panel-body{border-color:#FCFCFC}
- .layout-split-west{border-right:none}
- </style>
- <script type="text/javascript">
- var $easy = $.noConflict(true);
- $easy(function(){
- $easy('#pageright').panel({
- onResize:function(width, height){
- $("#jqGrid").setGridWidth(width-4);
- }
- });
- })
- </script>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
- <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
- <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
- <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
- <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
- <script type="text/javascript">
- var currentOrgID = '${currentOrgID!}';
- var OrgTree = '${OrgTree!}';
- var setting = {
- view: {
- dblClickExpand: false,
- showLine: false,
- selectedMulti: false
- },
- data: {
- simpleData: {
- enable:true,
- idKey: "id",
- pIdKey: "pId",
- rootPId: "-1"
- }
- },
- callback: {
- onClick: zTreeClick
- }
- };
-
- //创建树型菜单
- function createTree(OrgTree){
- var zNodes = [];
- if(OrgTree == ""){
- return false;
- }
- var jsonorgtree = JSON.parse(OrgTree);
- jsonorgtree.forEach(function(item,index){
- if(currentOrgID==item.orgid){ //所在一级展开
- zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,open:true});
- }else{
- zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname});
- }
- })
- return zNodes;
- }
-
- //ztree的点击回调函数
- function zTreeClick(event, treeId, treeNode) {
- currentOrgID = treeNode.id; //用于添加操作时使用
- setGrid(treeNode.id,treeNode.name);
- }
-
- $(document).ready(function(){
- var ztreeNode = $.fn.zTree.init($("#treeDemo"), setting,createTree(OrgTree));
- var captionName = ztreeNode.getNodes(currentOrgID)[0].name;
- //DOM加载完成后,加载jqgrid
- $("#jqGrid").jqGrid({
- url : '${ctx}/myconsole/user/getByPage',
- editurl:"${ctx}/myconsole/user/saveOrUpdate", //保存或者添加
- mtype : "POST",
- datatype : "json",
- sidx : "sortid",
- sord : "asc",
- caption:captionName,
- prmNames : {
- id: "keyid",
- oper:"oper",
- addoper:"add",
- editoper:"edit",
- deloper:"del"
- },
- colModel : [ {
- label : '用户编号',
- name : 'keyid',
- hidden : true,
- key : true,
- width : 50,
- }, {
- label : '登录账号',
- name : 'userid',
- editable: true,
- formoptions:{
- elmsuffix:" <span style='color:red'>*(初始密码${defaultPassword})<span>"
- },
- editrules:{
- required:true
- },
- width : 80,
- editoptions: {
- size:50,
- maxlength: 32
- }
- }, {
- label : '用户姓名',
- name : 'username',
- editable: true,
- formoptions:{
- elmsuffix:" <span style='color:red'>*<span>"
- },
- editrules:{required:true},
- width : 80,
- editoptions: {
- size:50,
- maxlength: 120
- }
- }, {
- label : '机构名称',
- name : 'orgid',
- editable: true,
- width : 50,
- edittype :"select",
- formatter:"select",
- editoptions:{value:"${orgOptions}"}
- }, {
- label : '手机号码',
- name : 'mobile',
- editable: true,
- width : 80,
- editrules:{
- edithidden:true,
- custom:true,
- custom_func: function(strFieldValue, strFieldName){
- var strTelephone = /^([\x00-\xff]+$)?$/; //非汉字
- if(!strTelephone.test(strFieldValue)){
- return [false, strFieldName+"应该为电话号"];
- }
- if(strTelephone.length>100){
- return [false, strFieldName+"字符数过多,大于100"];
- }
- return [true,""];
- }
- },
- editoptions: {
- size:50,
- maxlength: 50
- }
- } ,{
- label : '邮箱',
- name : 'email',
- editable: true,
- width : 80,
- editrules:{
- edithidden:true,
- custom:true,
- custom_func: function(strFieldValue, strFieldName){
- var strMail = /^(.+\@.+\..+)?$/; //邮箱
- if(!strMail.test(strFieldValue)){
- return [false, strFieldName+"格式不正确"];
- }
- if(strMail.length>100){
- return [false, strFieldName+"字符数过多,大于100"];
- }
- return [true,""];
- }
- },
- editoptions: {
- size:50,
- maxlength: 50
- }
- }, {
- label : '排序号',
- name : 'sortid',
- hidden : true,
- editable: true,
- width : 80,
- editrules:{
- edithidden:true,
- custom:true,
- custom_func: function(strFieldValue, strFieldName){
- var strFloat = /^([-\+]?(((\d+)(\.\d+))|(\.\d+)|(\d*)))?$/;
- if(!strFloat.test(strFieldValue)){
- return [false, strFieldName+"应该为实数"];
- }
- else
- {
- return [true,""];
- }
- }
- },
- editoptions: {
- size:50,
- maxlength: 5
- }
- },{
- label : '用户类型',
- name : 'usertype',
- editable: true,
- edittype: "select",
- editoptions:{
- dataInit: function(elem){
- $(elem).width(300);
- },
- value : "后台用户:后台用户;前台用户:前台用户;综合用户:综合用户"
- },
- editrules:{edithidden:true},
- width : 45
- }, {
- label : '创建人',
- name : 'insertusername',
- editable: false,
- width : 45
- }, {
- label : '创建时间',
- name : 'inserttime',
- editable: false,
- width : 70
- } ],
- rownumbers : true,//添加左侧行号
- viewrecords : true,//是否在浏览导航栏显示记录总数
- rowNum : 15,//每页显示记录数
- rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
- autowidth : true,
- height : 'auto',
- pager : "#jqGridPager"
- });
-
- $('#jqGrid').navGrid('#jqGridPager',
- {
- add : true,
- edit : true,
- del : true,
- search : true,
- refresh : false,
- view : true,
- position : "left",
- cloneToTop : true
- },
- //点击编辑触发的区域
- {
- closeAfterEdit : true,
- recreateForm : true,
- width:600,
- beforeShowForm:function(formid){
- var useridObj = formid.find('#userid');
- useridObj.attr('readOnly',true);
- useridObj.css({'background':'#cccccc'});
- },
- beforeSubmit: function(postdata, formid){
- var keyid = postdata.jqGrid_id;
- $.each(postdata,function (index, value) {
- if(index!="oper"){
- modifyJosnKey(postdata,index,"user."+index);
- }
- })
- postdata["user.keyid"]=keyid;
- return [true,'']; //返回值必须这么写 目前没找到原因,用true 和 返回对象都不好使。待查
- },
- afterSubmit: function(response,postdata) //
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
- }else{
-
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
- }
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- //添加操作区
- {
- closeAfterAdd : true, //添加完成后关闭
- width:600,
- serializeEditData: function(postdata) { //提前数据前,加工数据
- $.each(postdata,function(index,value){
- if(index!="oper"){
- modifyJosnKey(postdata,index,"user."+index);
- }
- })
- postdata["user.keyid"] = "";
- return postdata;
- },
- beforeShowForm:function(formid){
- $("#orgid").val(currentOrgID);
- },
- afterShowForm: function (formid){ //点击添加按钮显示表单后,用于绑定事件
- var useridObj = formid.find('#userid');
- useridObj.blur(function(){
- verifyUser(useridObj.val());
- });
- },
- afterSubmit: function(response,postdata) //
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
- }else{
-
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
- }
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },
- //删除操作区
- {
- afterSubmit: function(response,postdata)
- {
- var res=eval('(' + response.responseText + ')');
- if(res.flag)
- {
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [true,res.message,''];
- }else{
- parent.layer.alert(res.message, {
- skin: 'layui-layer-molv' //样式类名
- ,closeBtn: 0
- });
- return [false,res.message,''];
- }
- },
- errorTextFormat : function(data) {
- return 'Error: ' + data.responseText
- }
- },{
- // search options 这里支持多条件查询
- multipleSearch: true,
- closeAfterSearch: true,
- sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
- afterSubmit: function(r, data) {
- var messageString = r.responseText;
- var mesObj = eval('(' + messageString + ')');
- return [mesObj.state, mesObj.message];
- }
- }
- )
- .navButtonAdd("#jqGridPager",{
- caption:'分配角色',
- onClickButton:function(){
- var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
- if (!selectedRowId) {
- alert("请先选择需要编辑的行!");
- return false;
- } else {
- var UserID=selectedRowId;
- function zTreeOnCheck(event, treeId, treeNode) {
- //myconsole.log(treeNode);
-
- $.post("${ctx}/myconsole/user/saveUserRole",{"userid":UserID,"roleid":treeNode.id,"checked":treeNode.checked},function(data){
- parent.layer.msg(data);
- })
- };
- var zTreeObj;
- var zNodes;
- var setting = {
- check: {
- enable: true,
- chkboxType:{ "Y" : "ps", "N" : "ps" },
- autoCheckTrigger: true
- },
- data: {
- simpleData: {
- idKey:"id",
- pIdKey:"upperid",
- enable:true,
- rootPId:"0"
- }
- },
- callback: {
- onCheck: zTreeOnCheck
- }
- };
- $.ajax({
- url : "${ctx}/myconsole/user/getRoleTree?userid=" + UserID,
- type : "post",
- dataType : "json",
- success : function(data) {
- var zNodes = [];
- var roleInfo = data;
- roleInfo.forEach(function(item,index){
- zNodes.push({id:item.keyid,pId:0,name:item.rolename,istype:true,checked:item.chk});
- })
-
-
- $.fn.zTree.init($("#RoleTree"), setting, zNodes);//初始化树节点时,添加同步获取的数据
- var zTree = $.fn.zTree.getZTreeObj("tree");//获取zTree对象
- }
- });
- $('<div id="dlgSetRole"><ul id="RoleTree" class="ztree"></ul></div>').dialog({
- title : '分配角色',
- width : 300,
- height : 400,
- closed : false,
- cache : false,
- modal : true,
-
- });
- $(".ui-dialog-titlebar-close").click(function(){
- $("#dlgSetRole").remove();
- });
- }
-
-
- },
- id:'role'
- }).navButtonAdd("#jqGridPager",{
- caption:'坐席分机构',
- onClickButton:function(){
- var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
- if (!selectedRowId) {
- alert("请先选择需要编辑的行!");
- return false;
- } else {
- var UserID=selectedRowId;
- function zTreeOnCheck(event, treeId, treeNode) {
- //myconsole.log(treeNode);
-
- $.post("${ctx}/myconsole/user/saveUserOrg",{"userkeyid":UserID,"orgid":treeNode.id,"orgname":treeNode.name,"checked":treeNode.checked},function(data){
- parent.layer.msg(data);
- })
- };
- var zTreeObj;
- var zNodes;
- var setting = {
- check: {
- enable: true,
- chkboxType:{ "Y" : "ps", "N" : "ps" },
- autoCheckTrigger: true
- },
- data: {
- simpleData: {
- idKey:"id",
- pIdKey:"upperid",
- enable:true,
- rootPId:"0"
- }
- },
- callback: {
- onCheck: zTreeOnCheck
- }
- };
- $.ajax({
- url : "${ctx}/myconsole/user/getOrgTree?userkeyid=" + UserID,
- type : "post",
- dataType : "json",
- success : function(data) {
- var zNodes = [];
- var roleInfo = data;
- roleInfo.forEach(function(item,index){
- zNodes.push({id:item.orgid,pId:0,name:item.orgname,istype:true,checked:item.chk});
- })
-
-
- $.fn.zTree.init($("#OrgTree"), setting, zNodes);//初始化树节点时,添加同步获取的数据
- var zTree = $.fn.zTree.getZTreeObj("tree");//获取zTree对象
- }
- });
- $('<div id="dlgSetRole"><ul id="OrgTree" class="ztree"></ul></div>').dialog({
- title : '坐席分机构',
- width : 500,
- height : 550,
- closed : false,
- cache : false,
- modal : true,
-
- });
- $(".ui-dialog-titlebar-close").click(function(){
- $("#dlgSetRole").remove();
- });
- }
-
-
- },
- id:'agentorg'
- }) .navButtonAdd("#jqGridPager",{
- caption:'重置密码',
- onClickButton:function(){
- var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
- if (!selectedRowId) {
- alert("请先选择需要编辑的行!");
- return false;
- } else {
- var UserID=selectedRowId;
- $.post("${ctx}/myconsole/user/initPass",{"keyid":UserID},function(data){
- if(data){
- alert("密码修改成功,默认密码为${defaultPassword}");
- }else{
- alert("修改失败");
- }
- })
- }
- }
- }
- );
- })
-
- </script>
- <title>我的桌面</title>
- </head>
- <body>
- <div class="easyui-layout" data-options="fit:true">
- <div region="west" split="true" style="width:250px;height:100%;background-color:#f5f5f5">
- <ul id="treeDemo" class="ztree">
- </ul>
- </div>
- <div region="center" id="pageright">
- <div class="page-container">
- <table id="jqGrid"></table>
- <div id="jqGridPager"></div>
- </div>
- </div>
- </div>
- </body>
- </html>
- <script>
- //加载所选机构ID下面的人员
- function setGrid(OrgID,OrgName) {
- $("#jqGrid").jqGrid('setGridParam', {
- datatype : 'json',
- postData : {OrgID:currentOrgID}
- }).jqGrid('setCaption', OrgName).trigger("reloadGrid");
- }
-
-
- function verifyUser(userID){
- if(userID == "") return ;
- var errorShow = $(".FormError");
- errorShow.html("").hide();
- $.post("${ctx}/myconsole/user/verifyUser", {'userID':userID},
- function(data){
- if(data.length>0){
- $('#userid').val("");
- errorShow.html("该登录账号["+userID+"]已存在,请尝试其他用户名").show();
- }
- }
- );
- }
-
- </script>
|