job.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  10. <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
  11. <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
  12. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/gray/easyui.css" />
  13. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
  14. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
  15. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/icon.css" />
  16. <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/jquery.easyui.min.js"></script>
  17. <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/locale/easyui-lang-zh_CN.js"></script>
  18. <style type="text/css">
  19. .panel-header, .panel-body{border-color:#FCFCFC}
  20. .layout-split-west{border-right:none}
  21. </style>
  22. <script type="text/javascript">
  23. var $easy = $.noConflict(true);
  24. $easy(function(){
  25. $easy('#pageright').panel({
  26. onResize:function(width, height){
  27. $("#jqGrid").setGridWidth(width-4); 
  28. }
  29. });
  30. })
  31. </script>
  32. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
  33. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  34. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  35. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
  36. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
  37. <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
  38. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
  39. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
  40. <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
  41. <script>DD_belatedPNG.fix('*');</script>
  42. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  43. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  44. <script type="text/javascript">
  45. var currentOrgID = '${currentOrgID!}';
  46. var currentOrgParentID = '${currentOrgParentID!}';
  47. var OrgTree = '${OrgTree!}';
  48. var setting = {
  49. view: {
  50. dblClickExpand: false,
  51. showLine: false,
  52. selectedMulti: false
  53. },
  54. data: {
  55. simpleData: {
  56. enable:true,
  57. idKey: "id",
  58. pIdKey: "pId",
  59. rootPId: "-1"
  60. }
  61. },
  62. callback: {
  63. onClick: zTreeClick
  64. }
  65. };
  66. //创建树型菜单
  67. function createTree(OrgTree){
  68. var zNodes = [];
  69. if(OrgTree == ""){
  70. return false;
  71. }
  72. var jsonorgtree = JSON.parse(OrgTree);
  73. jsonorgtree.forEach(function(item,index){
  74. if(currentOrgID==item.orgid){ //所在一级展开
  75. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,open:true});
  76. }else{
  77. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname});
  78. }
  79. })
  80. return zNodes;
  81. }
  82. //ztree的点击回调函数
  83. function zTreeClick(event, treeId, treeNode) {
  84. currentOrgID = treeNode.id; //用于添加操作时使用
  85. currentOrgParentID=treeNode.pId;
  86. setGrid(treeNode.id,treeNode.name);
  87. }
  88. $(document).ready(function(){
  89. var ztreeNode = $.fn.zTree.init($("#treeDemo"), setting,createTree(OrgTree));
  90. var captionName = ztreeNode.getNodes(currentOrgID)[0].name;
  91. //DOM加载完成后,加载jqgrid
  92. $("#jqGrid").jqGrid({
  93. url : '${ctx}/myconsole/job/getByPage',
  94. editurl:"${ctx}/myconsole/job/saveUpdate", //保存或者添加
  95. mtype : "POST",
  96. datatype : "json",
  97. sidx : "sortid",
  98. sord : "asc",
  99. caption:captionName,
  100. postData:{
  101. OrgID:currentOrgID
  102. },
  103. prmNames : {
  104. id: "keyid", 
  105. oper:"oper",    
  106. addoper:"add",
  107. editoper:"edit",
  108. deloper:"del"
  109. },
  110. colModel : [ {
  111. label : '岗位编号',
  112. name : 'keyid',
  113. hidden : true,
  114. key : true,
  115. width : 50,
  116. }, {
  117. label : '岗位名称',
  118. name : 'jobname',
  119. editable: true,
  120. formoptions:{
  121. elmsuffix:" <span style='color:red'>*<span>"
  122. },
  123. editrules:{required:true},
  124. edittype: "select",
  125. formatter:"select",
  126. width : 100,
  127. editoptions: {
  128. dataInit: function(elem){
  129. $(elem).width(225);
  130. },
  131. maxlength: 50,
  132. value : "${dic_jobname}"
  133. },
  134. }, {
  135. label : '岗位类别',
  136. name : 'jobtype',
  137. editable: true,
  138. formoptions:{
  139. elmsuffix:" <span style='color:red'>*<span>"
  140. },
  141. editrules:{required:true},
  142. edittype: "select",
  143. formatter:"select",
  144. width : 100,
  145. editoptions: {
  146. dataInit: function(elem){
  147. $(elem).width(225);
  148. },
  149. maxlength: 50,
  150. value : "${dic_jobtype}"
  151. },
  152. },{
  153. label : '排序号',
  154. name : 'sortid',
  155. hidden : true,
  156. editable: true,
  157. width : 80,
  158. editrules:{
  159. edithidden:true,
  160. custom:true, 
  161. custom_func: function(strFieldValue, strFieldName){
  162. var strFloat = /^([-\+]?(((\d+)(\.\d+))|(\.\d+)|(\d*)))?$/;
  163.  if(!strFloat.test(strFieldValue)){
  164.    return [false, strFieldName+"应该为实数"];
  165.   }
  166. else
  167. {
  168.   return [true,""];
  169. }
  170. }
  171. },
  172. editoptions: {
  173. size:10,
  174. maxlength: 5
  175. }
  176. }, {
  177. label : '岗位描述',
  178. name : 'jobdesc',
  179. editable: true,
  180. edittype: "text",
  181. width : 100,
  182. editoptions: {
  183. dataInit: function(elem){
  184. $(elem).width(218);
  185. },
  186. maxlength: 50
  187. },
  188. },{
  189. label : '创建时间',
  190. name : 'inserttime',
  191. editable: false,
  192. width : 70
  193. } ],
  194. rownumbers : true,//添加左侧行号
  195. viewrecords : true,//是否在浏览导航栏显示记录总数
  196. rowNum : 15,//每页显示记录数
  197. rowList : [10,15,20,30,40,50 ],//用于改变显示行数的下拉列表框的元素数组。
  198. autowidth : true,
  199. height : 'auto',
  200. pager : "#jqGridPager"
  201. });
  202. $('#jqGrid').navGrid('#jqGridPager',
  203. {
  204. add : true,
  205. edit : true,
  206. del : true,
  207. search : true,
  208. refresh : true,
  209. view : true,
  210. position : "left",
  211. cloneToTop : true
  212. },
  213. //点击编辑触发的区域
  214. {
  215. closeAfterEdit : true,
  216. recreateForm : true,
  217. width:600,
  218. beforeShowForm:function(formid){
  219. var useridObj = formid.find('#userid');
  220. useridObj.attr('readOnly',true);
  221. useridObj.css({'background':'#cccccc'});
  222. },
  223. beforeSubmit: function(postdata, formid){
  224. var keyid = postdata.jqGrid_id;
  225. $.each(postdata,function (index, value) {
  226. if(index!="oper"){
  227. modifyJosnKey(postdata,index,"job."+index);
  228. }
  229. })
  230. postdata["job.keyid"]=keyid;
  231. postdata["job.orgid"] = currentOrgID;
  232. postdata["job.parentorgid"] = currentOrgParentID;
  233. return [true,'']; //返回值必须这么写 目前没找到原因,用true 和 返回对象都不好使。待查
  234. },
  235. afterSubmit: function(response,postdata) //
  236. {
  237. var res=eval('(' + response.responseText + ')');
  238. if(res.flag)
  239. {
  240. parent.layer.alert(res.message, {
  241. skin: 'layui-layer-molv' //样式类名
  242. ,closeBtn: 0
  243. });
  244. return [true,res.message,''];
  245. }else{
  246. parent.layer.alert(res.message, {
  247. skin: 'layui-layer-molv' //样式类名
  248. ,closeBtn: 0
  249. });
  250. return [false,res.message,''];
  251. }
  252. },
  253. errorTextFormat : function(data) {
  254. return 'Error: ' + data.responseText
  255. }
  256. },
  257. //添加操作区
  258. {
  259. closeAfterAdd : true, //添加完成后关闭
  260. width:600,
  261. serializeEditData: function(postdata) { //提前数据前,加工数据
  262. $.each(postdata,function(index,value){
  263. if(index!="oper"){
  264. modifyJosnKey(postdata,index,"job."+index);
  265. }
  266. })
  267. postdata["job.orgid"] = currentOrgID;
  268. postdata["job.parentorgid"] = currentOrgParentID;
  269. return postdata;
  270. },
  271. beforeShowForm:function(formid){
  272. $("#orgid").val(currentOrgID);
  273. },
  274. afterShowForm: function (formid){ //点击添加按钮显示表单后,用于绑定事件
  275. var useridObj = formid.find('#userid');
  276. useridObj.blur(function(){
  277. verifyUser(useridObj.val());
  278. });
  279. },
  280. afterSubmit: function(response,postdata) //
  281. {
  282. var res=eval('(' + response.responseText + ')');
  283. if(res.flag)
  284. {
  285. parent.layer.alert(res.message, {
  286. skin: 'layui-layer-molv' //样式类名
  287. ,closeBtn: 0
  288. });
  289. return [true,res.message,''];
  290. }else{
  291. parent.layer.alert(res.message, {
  292. skin: 'layui-layer-molv' //样式类名
  293. ,closeBtn: 0
  294. });
  295. return [false,res.message,''];
  296. }
  297. },
  298. errorTextFormat : function(data) {
  299. return 'Error: ' + data.responseText
  300. }
  301. },
  302. //删除操作区
  303. {
  304. afterSubmit: function(response,postdata)
  305. {
  306. var res=eval('(' + response.responseText + ')');
  307. if(res.flag)
  308. {
  309. parent.layer.alert(res.message, {
  310. skin: 'layui-layer-molv' //样式类名
  311. ,closeBtn: 0
  312. });
  313. return [true,res.message,''];
  314. }else{
  315. parent.layer.alert(res.message, {
  316. skin: 'layui-layer-molv' //样式类名
  317. ,closeBtn: 0
  318. });
  319. return [false,res.message,''];
  320. }
  321. },
  322. errorTextFormat : function(data) {
  323. return 'Error: ' + data.responseText
  324. }
  325. },{
  326. // search options 这里支持多条件查询
  327. multipleSearch: true,
  328. closeAfterSearch: true,
  329. sopt:['eq','ne','cn','nc','lt','le','gt','ge'],
  330. afterSubmit: function(r, data) {
  331. var messageString = r.responseText;
  332. var mesObj = eval('(' + messageString + ')');
  333. return [mesObj.state, mesObj.message];
  334. }
  335. }
  336. )/*
  337. .navButtonAdd("#jqGridPager",{
  338. caption:'分配角色',
  339. onClickButton:function(){
  340. var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
  341. if (!selectedRowId) {
  342. alert("请先选择需要编辑的行!");
  343. return false;
  344. } else {
  345. var UserID=selectedRowId;
  346. function zTreeOnCheck(event, treeId, treeNode) {
  347. //myconsole.log(treeNode);
  348. $.post("${ctx}/myconsole/user/saveUserRole",{"userid":UserID,"roleid":treeNode.id,"checked":treeNode.checked},function(data){
  349. //alert(data);
  350. })
  351. };
  352. var zTreeObj;
  353. var zNodes;
  354. var setting = {
  355. check: {
  356. enable: true,
  357. chkboxType:{ "Y" : "ps", "N" : "ps" },
  358. autoCheckTrigger: true
  359. },
  360. data: {
  361. key: {
  362. name:"rolename",
  363. title:"菜单树"
  364. },
  365. simpleData: {
  366. idKey:"id",
  367. pIdKey:"upperid",
  368. enable:true,
  369. rootPId:"0"
  370. }
  371. },
  372. callback: {
  373. onCheck: zTreeOnCheck
  374. }
  375. };
  376. $.ajax({
  377. url : "${ctx}/myconsole/user/getSimpleTree?userid=" + UserID,
  378. type : "post",
  379. dataType : "json",
  380. success : function(data) {
  381. $.fn.zTree.init($("#RoleTree"), setting, data);//初始化树节点时,添加同步获取的数据
  382. var zTree = $.fn.zTree.getZTreeObj("tree");//获取zTree对象
  383. }
  384. });
  385. $('<div id="dlgSetRole"><ul id="RoleTree" class="ztree"></ul></div>').dialog({
  386. title : '分配角色',
  387. width : 300,
  388. height : 400,
  389. closed : false,
  390. cache : false,
  391. modal : true,
  392. buttons: { // 为对话框添加按钮
  393. "确定": function() {
  394. $("#dlgSetRole").dialog("close");
  395. $("#dlgSetRole").remove()
  396. }
  397. }
  398. });
  399. $(".ui-dialog-titlebar-close").click(function(){
  400. $("#dlgSetRole").remove();
  401. });
  402. }
  403. },
  404. id:'role'
  405. }) */.navButtonAdd("#jqGridPager",{
  406. caption:'分配用户',
  407. id:'job',
  408. onClickButton:function(){
  409. var selectedRowId = $("#jqGrid").jqGrid("getGridParam", "selrow");
  410. if (!selectedRowId) {
  411. //alert("请先选择需要编辑的行!");
  412. parent.layer.alert("请先选择需要编辑的行!", {
  413. skin: 'layui-layer-molv' //样式类名
  414. ,closeBtn: 0
  415. });
  416. return false;
  417. } else {
  418. var JobID=selectedRowId;
  419. var zTreeObj;
  420. var zNodes;
  421. function zTreeOnCheck(event, treeId, treeNode) {
  422. //console.log(treeNode);
  423. $.post("${ctx}/myconsole/job/saveJobUser",{"jobid":JobID,"userid":treeNode.id,"checked":treeNode.checked},function(data){
  424. //alert(data);
  425. parent.layer.msg(data.msg);
  426. })
  427. };
  428. function ajaxDataFilter(treeId, parentNode, data) {
  429. if(data == "") return;
  430. var zNodes = [];
  431. var orgN = data.Org;
  432. orgN.forEach(function(item,index){
  433. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
  434. })
  435. var userN = data.User;
  436. userN.forEach(function(item,index){
  437. zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
  438. })
  439. return zNodes;
  440. }
  441. var setting = { //初始化树
  442. check: {
  443. enable: true,
  444. chkboxType:{ "Y" : "", "N" : "" },
  445. autoCheckTrigger: true
  446. },
  447. data: {
  448. simpleData: {
  449. idKey:"id",
  450. pIdKey:"pId",
  451. enable:true,
  452. rootPId:"currentOrgID"
  453. }
  454. },
  455. callback: {
  456. onCheck: zTreeOnCheck
  457. },
  458. async:{
  459. enable:true,
  460. url:"${ctx}/myconsole/job/getUserTree?jobid=" + JobID,
  461. autoParam:["id", "name"] ,
  462. dataFilter: ajaxDataFilter
  463. }
  464. };
  465. //获取数据
  466. $.ajax({
  467. url : "${ctx}/myconsole/job/getUserTree?jobid=" + JobID+"&name=CSH",
  468. type : "post",
  469. dataType : "json",
  470. success : function(data) {
  471. if(data == "") return;
  472. var zNodes = [];
  473. var orgN = data.Org;
  474. orgN.forEach(function(item,index){
  475. zNodes.push({id:item.orgid,pId:item.parentid,name:item.orgname,istype:false, isParent:true,"nocheck":true});
  476. })
  477. var userN = data.User;
  478. userN.forEach(function(item,index){
  479. zNodes.push({id:item.keyid,pId:item.orgid,name:item.username,istype:true,checked:item.chk});
  480. })
  481. zTreeObj = $.fn.zTree.init($("#UserTree"), setting, zNodes);//初始化树节点时,添加同步获取的数据
  482. }
  483. });
  484. $('<div id="dlgSetUser"><ul id="UserTree" class="ztree"></ul></div>').dialog({
  485. title : '分配用户',
  486. width : 400,
  487. height : 450,
  488. closed : false,
  489. cache : false,
  490. modal : true
  491. });
  492. $(".ui-dialog-titlebar-close").click(function(){
  493. $("#dlgSetUser").remove();
  494. });
  495. }
  496. }
  497. });
  498. ;
  499. })
  500. </script>
  501. <title>我的桌面</title>
  502. </head>
  503. <body>
  504. <div class="easyui-layout" data-options="fit:true">
  505. <div region="west" split="true" style="width:250px;height:100%;background-color:#f5f5f5">
  506. <ul id="treeDemo" class="ztree">
  507. </ul>
  508. </div>
  509. <div region="center" id="pageright">
  510. <div class="page-container">
  511. <table id="jqGrid"></table>
  512. <div id="jqGridPager"></div>
  513. </div>
  514. </div>
  515. </div>
  516. </body>
  517. </html>
  518. <script>
  519. //加载所选机构ID下面的人员
  520. function setGrid(OrgID,OrgName) {
  521. $("#jqGrid").jqGrid('setGridParam', {
  522. datatype : 'json',
  523. postData : {OrgID:OrgID}
  524. }).jqGrid('setCaption', OrgName).trigger("reloadGrid");
  525. }
  526. function verifyUser(userID){
  527. if(userID == "") return ;
  528. var errorShow = $(".FormError");
  529. errorShow.html("").hide();
  530. $.post("${ctx}/myconsole/user/verifyUser", {'userID':userID},
  531. function(data){
  532. if(data.length>0){
  533. $('#userid').val("");
  534. errorShow.html("该登录账号["+userID+"]已存在,请尝试其他用户名").show();
  535. }
  536. }
  537. );
  538. }
  539. </script>