8028fd40d682e3596f958142dc1c0aa1b7f3f528.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <!--框架必需start-->
  6. <script type="text/javascript" src="../../libs/js/jquery.js"></script>
  7. <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
  8. <script type="text/javascript" src="../../libs/js/framework.js"></script>
  9. <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  10. <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
  11. <link rel="stylesheet" type="text/css" id="customSkin"/>
  12. <!--框架必需end-->
  13. <!--数据表格start-->
  14. <script src="../../libs/js/table/quiGrid.js" type="text/javascript"></script>
  15. <!--数据表格end-->
  16. <!-- 日期选择框start -->
  17. <script type="text/javascript" src="../../libs/js/form/datePicker/WdatePicker.js"></script>
  18. <!-- 日期选择框end -->
  19. <!-- 数字步进器start -->
  20. <script type="text/javascript" src="../../libs/js/form/stepper.js"></script>
  21. <!-- 数字步进器end -->
  22. <!-- 树组件start -->
  23. <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
  24. <link type="text/css" rel="stylesheet" href="../../libs/js/tree/ztree/ztree.css"></link>
  25. <!-- 树组件end -->
  26. <!-- 树形下拉框start -->
  27. <script type="text/javascript" src="../../libs/js/form/selectTree.js"></script>
  28. <!-- 树形下拉框end -->
  29. </head>
  30. <body>
  31. <div class="padding_right5">
  32. <div id="maingrid"></div>
  33. </div>
  34. <script type="text/javascript">
  35. var testData={"pager.pageNo":1,"pager.totalRows":14,"rows":[{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":11,"userDuty":"undefined","userEducation":"2","userEmployTime":null,"userId":57,"userLoginName":"guest","userName":"新增","userPassword":"123456","userSex":0},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":56,"userLoginName":"zheng","userName":"郑","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":55,"userLoginName":"li","userName":"李","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":54,"userLoginName":"zhou","userName":"周","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":53,"userLoginName":"sun","userName":"孙","userPassword":"123456","userSex":0},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":52,"userLoginName":"qian","userName":"钱","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":51,"userLoginName":"zhao","userName":"赵","userPassword":"123456","userSex":0},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":50,"userLoginName":"chen","userName":"陈","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":49,"userLoginName":"zhang","userName":"张","userPassword":"123456","userSex":1},{"organization":{"orgDescription":"","orgEstablish":null,"orgId":0,"orgManager":"","orgName":"","orgpId":0,"orgPath":"","orgPhone":""},"userAddress":"","userAge":18,"userAssistance":"undefined","userDepartment":0,"userDuty":"undefined","userEducation":"1","userEmployTime":null,"userId":48,"userLoginName":"wang","userName":"王","userPassword":"123456","userSex":1}]};
  36. var g;
  37. var sexData={"list":[{"value":"1","key":"男"},{"value":"0","key":"女"}]};
  38. var educationData={"list":[{"value":"1","key":"大专"},{"value":"2","key":"本科"},{"value":"3","key":"硕士"},{"value":"4","key":"博士"}]};
  39. var jobNode = {"treeNodes":[
  40. { id:1, pId:0, name:"界面设计"},
  41. { id:2, pId:0, name:"程序开发"},
  42. { id:3, pId:0, name:"市场调研"},
  43. { id:4, pId:0, name:"质量监督"},
  44. { id:5, pId:0, name:"产品测试"}
  45. ]};
  46. var departNode={"treeNodes":[{"id":"1","name":"南京分公司","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"0"},{"id":"2","name":"市场部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"},{"id":"3","name":"市场1组","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"2"},{"id":"7","name":"杭州办事处","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"0"},{"id":"8","name":"接待处","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"7"},{"id":"9","name":"洽谈处","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"7"},{"id":"11","name":"市场2组","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"2"},{"id":"12","name":"市场3组","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"2"},{"id":"13","name":"财务部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"},{"id":"14","name":"行政部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"},{"id":"15","name":"工程部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"},{"id":"16","name":"技术部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"},{"id":"17","name":"生产部","icon":"/online/libs/icons/user_group.gif","open":"true","pId":"1"}]};
  47. var newrowid=200;
  48. function initComplete(){
  49. initGrid();
  50. $("#sel-1").data("data",sexData)
  51. $("#sel-1").render();
  52. $("#sel-2").data("data",educationData)
  53. $("#sel-2").render();
  54. $("#selectTree-3").data("data",jobNode)
  55. $("#selectTree-3").render();
  56. }
  57. function initGrid(){
  58. g = $("#maingrid").quiGrid({
  59. columns: [
  60. { display: '姓名', name: 'userName', align: 'left', width: 120,editor: { type: 'text',maxlength:5,tip:'不超过5个字的中文' }},
  61. { display: '用户名', name: 'userLoginName', align: 'left', width: 120,editor: { type: 'text',tip:'英文或数字' }},
  62. { display: '密码', name: 'userPassword', align: 'left', width: 120,editor: { type: 'text',tip:'6到11位的英文或数字' }},
  63. { display: '性别', name: 'userSex', align: 'left', width: 55,editor: { type: 'select',data:sexData,selWidth:50 },render:function (item){
  64. for (var i = 0; i < sexData["list"].length; i++)
  65. {
  66. if (sexData["list"][i]['value'] == item.userSex)
  67. return sexData["list"][i]['key']
  68. }
  69. return item.userSex;
  70. }},
  71. { display: '年龄', name: 'userAge', align: 'left', width: 80,type:"int",editor: { type: 'stepper',min:18,tip:'不能小于18岁' } },
  72. { display: '入职时间', name: 'userEmployTime', align: 'left', width: 100,editor: { type: 'date',dateFmt:'yyyy-MM-dd'}},
  73. { display: '部门', name: 'userDepartment', align: 'left', width: 150,editor: { type: 'selectTree',data:departNode,selWidth:145 },render:function (item){
  74. for (var i = 0; i < departNode["treeNodes"].length; i++)
  75. {
  76. if (departNode["treeNodes"][i]['id'] == item.userDepartment){
  77. if(departNode["treeNodes"][i]['name']=="请选择"){
  78. return "";
  79. }
  80. return departNode["treeNodes"][i]['name'];
  81. }
  82. }
  83. return item.userDepartment;
  84. } },
  85. { display: '协作部门', name: 'userAssistance', align: 'left', width: 200 ,isSort:false,showTitle:true,editor: { type: 'selectTree',multiMode:true,data:departNode,selWidth:195 },render:function (item){
  86. if(!item.userAssistance){
  87. return "";
  88. }
  89. var itemArray=item.userAssistance.split(",");
  90. var departStr="";
  91. for (var i = 0; i < itemArray.length; i++){
  92. for (var j = 0; j < departNode["treeNodes"].length; j++){
  93. if (departNode["treeNodes"][j]['id'] == itemArray[i]){
  94. departStr=departStr+departNode["treeNodes"][j]['name']+",";
  95. continue;
  96. }
  97. }
  98. }
  99. if (departStr.length > 0 ){
  100. departStr = departStr.substring(0, departStr.length-1);
  101. }
  102. return departStr;
  103. } },
  104. { display: '学历', name: 'userEducation', align: 'left', width: 55,editor: { type: 'select',data:educationData,selWidth:50 },render:function (item){
  105. for (var i = 0; i < educationData["list"].length; i++)
  106. {
  107. if (educationData["list"][i]['value'] == item.userEducation)
  108. return educationData["list"][i]['key']
  109. }
  110. return item.userEducation;
  111. }},
  112. { display: '职务', name: 'userDuty', align: 'left', width: 150 ,isSort:false,showTitle:true,editor: { type: 'selectTree',multiMode:true,noGroup:true,data:jobNode,selWidth:145 },render:function (item){
  113. if(!item.userDuty){
  114. return "";
  115. }
  116. var itemArray=item.userDuty.split(",");
  117. var jobStr="";
  118. for (var i = 0; i < itemArray.length; i++){
  119. for (var j = 0; j < jobNode["treeNodes"].length; j++){
  120. if (jobNode["treeNodes"][j]['id'] == itemArray[i]){
  121. jobStr=jobStr+jobNode["treeNodes"][j]['name']+",";
  122. continue;
  123. }
  124. }
  125. }
  126. if (jobStr.length > 0 ){
  127. jobStr = jobStr.substring(0, jobStr.length-1);
  128. }
  129. return jobStr;
  130. } },
  131. { display: '操作', isAllowHide: false, align: 'left', width:60,
  132. render: function (rowdata, rowindex, value, column){
  133. return '<div class="padding_top4 padding_left5">'
  134. + '<span class="img_list hand" title="查看" onclick="onView(' + rowdata.userId + ')"></span>'
  135. + '<span class="img_delete hand" title="删除" onclick="onDelete(' + rowdata.userId+','+rowindex + ')"></span>'
  136. + '</div>';
  137. }
  138. }
  139. ],
  140. data:testData, sortName: 'userId',rownumbers:true,checkbox:true,pageSize:10,dataAction:"server",usePager: true,
  141. height: "100%", width:"100%",enabledEdit: true,onBeforeEdit: onBeforeEdit, onBeforeSubmitEdit: onBeforeSubmitEdit,onAfterEdit: onAfterEdit
  142. });
  143. }
  144. function addUser(){
  145. var valid = $('#myFormId').validationEngine({returnIsValid: true});
  146. if(valid){
  147. addUserHandler();
  148. }
  149. }
  150. //查看
  151. function onView(rowid){
  152. }
  153. //删除
  154. function onDelete(rowid,rowidx){
  155. }
  156. //编辑前事件
  157. function onBeforeEdit(e)
  158. {
  159. var str="编辑前事件,可阻止某些行或列进行编辑。列名:"+e.column.name+";行号:"+e.rowindex+";编辑前的值:"+e.value+"\n";
  160. //if(e.record.id=="121"){
  161. // top.Dialog.alert("此行不可编辑",null,null,null,2);
  162. // return false;
  163. //}
  164. }
  165. //编辑提交前事件
  166. function onBeforeSubmitEdit(e){
  167. if(e.column.name=="userName"){
  168. if(e.value==""){
  169. top.Dialog.alert("姓名不能为空!",null,null,null,2);
  170. return false;
  171. }
  172. else if (!validateInput(e.value, "^[\u4e00-\u9fa5]+$")){
  173. top.Dialog.alert("姓名需要是中文!",null,null,null,2);
  174. return false;
  175. }
  176. }
  177. if(e.column.name=="userLoginName"){
  178. if(e.value==""){
  179. top.Dialog.alert("用户名不能为空!",null,null,null,2);
  180. return false;
  181. }
  182. else if (!validateInput(e.value, "^[0-9a-zA-Z]+$")){
  183. top.Dialog.alert("用户名需要是字母或数字!",null,null,null,2);
  184. return false;
  185. }
  186. }
  187. if(e.column.name=="userPassword"){
  188. if(e.value==""){
  189. top.Dialog.alert("密码不能为空!",null,null,null,2);
  190. return false;
  191. }
  192. else if (e.value.length<6||e.value.length>11){
  193. top.Dialog.alert("密码需要是6-11位!",null,null,null,2);
  194. return false;
  195. }
  196. else if (!validateInput(e.value, "^[0-9a-zA-Z]+$")){
  197. top.Dialog.alert("密码需要是字母或数字!",null,null,null,2);
  198. return false;
  199. }
  200. }
  201. }
  202. //编辑后事件
  203. function onAfterEdit(e)
  204. {
  205. //var str="编辑后事件,用于ajax提交处理。列名:"+e.column.name+";行号:"+e.rowindex+";编辑后的值:"+e.value+"\n";
  206. /*
  207. $.post("<%=path%>/userdbAction.do?method=modifyAttributes",
  208. {"id":e.record.userId,"key":e.column.name,"value":e.value},
  209. function(result){
  210. },"json");
  211. */
  212. }
  213. </script>
  214. </body>
  215. </html>