bd9257a1984b6374fb0e99ce05842b2548bd7873.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <%@page language="java" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>基本表格模板</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!--数据表格start-->
  19. <script src="<%=path%>/libs/js/table/quiGrid.js" type="text/javascript"></script>
  20. <!--数据表格end-->
  21. <!-- 日期选择框start -->
  22. <script type="text/javascript" src="<%=path%>/libs/js/form/datePicker/WdatePicker.js"></script>
  23. <!-- 日期选择框end -->
  24. <!-- 数字步进器start -->
  25. <script type="text/javascript" src="<%=path%>/libs/js/form/stepper.js"></script>
  26. <!-- 数字步进器end -->
  27. <!-- 树组件start -->
  28. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  29. <link type="text/css" rel="stylesheet" href="<%=path%>/libs/js/tree/ztree/ztree.css"></link>
  30. <!-- 树组件end -->
  31. <!-- 树形下拉框start -->
  32. <script type="text/javascript" src="<%=path%>/libs/js/form/selectTree.js"></script>
  33. <!-- 树形下拉框end -->
  34. </head>
  35. <body>
  36. <div>
  37. 即时编辑下拉框联动:两种类型:1、不取后台值,而是进行一些计算,改变级联的下拉框;2、需要改变的值是从后台重新取。这里是第1种。<br/>
  38. 目前只支持两级联动,但可以使用多个两级联动。为了简化代码,这里表格编辑结果未提交到后台。
  39. </div>
  40. <div class="padding_right5">
  41. <div id="maingrid"></div>
  42. </div>
  43. <script type="text/javascript">
  44. var g;
  45. var testData={"form.paginate.pageNo":1,"form.paginate.totalRows":13,"rows":[
  46. {"userDepartment":"2","userGroup":"22","userSex":"1","id":125,"userEducation":"2","userAge":20,"userName":"张三","userType":"1","medical":11},
  47. {"userDepartment":"3","userGroup":"32","userSex":"1","id":126,"userEducation":"2","userAge":20,"userName":"李四","userType":"2","medical":22}
  48. ]}
  49. var sexData={"list":[{"value":"1","key":"男"},{"value":"0","key":"女"}]};
  50. var educationData={"list":[{"value":"1","key":"大专"},{"value":"2","key":"本科"},{"value":"3","key":"硕士"},{"value":"4","key":"博士"}]};
  51. var depart={"list":[{"value":"1","key":"市场部"},{"value":"2","key":"财务部"},{"value":"3","key":"咨询部"}]};
  52. var group1={"list":[{"value":"11","key":"市场一组"},{"value":"12","key":"市场二组"},{"value":"13","key":"市场三组"}]};
  53. var group2={"list":[{"value":"21","key":"财务一组"},{"value":"22","key":"财务二组"},{"value":"23","key":"财务三组"}]};
  54. var group3={"list":[{"value":"31","key":"咨询一组"},{"value":"32","key":"咨询二组"},{"value":"33","key":"咨询三组"}]};
  55. var userTypeData={"list":[{"value":"1","key":"正式员工"},{"value":"2","key":"临时员工"}]};
  56. var medi1={"list":[{"value":"11","key":"公费医疗"},{"value":"12","key":"自费医疗"},{"value":"13","key":"无医疗保险"}]};
  57. var medi2={"list":[{"value":"21","key":"自费医疗"},{"value":"22","key":"无医疗保险"}]};
  58. var newrowid=200;
  59. function initComplete(){
  60. initGrid();
  61. }
  62. function initGrid(){
  63. g = $("#maingrid").quiGrid({
  64. columns: [
  65. { display: '姓名', name: 'userName', align: 'left', width: 120,editor: { type: 'text',maxlength:5,tip:'不超过5个字的中文' }},
  66. { display: '性别', name: 'userSex', align: 'left', width: 65,editor: { type: 'select',data:sexData,selWidth:50 },render:function (item){
  67. for (var i = 0; i < sexData["list"].length; i++)
  68. {
  69. if (sexData["list"][i]['value'] == item.userSex)
  70. return sexData["list"][i]['key']
  71. }
  72. return item.userSex;
  73. }},
  74. { display: '部门', name: 'userDepartment', align: 'left', width: 165,editor: { type: 'select',data:depart,selWidth:150,link:true,relation:"parent" ,linkHandler:linkHandler1 },render:function (item){
  75. for (var i = 0; i < depart["list"].length; i++)
  76. {
  77. if (depart["list"][i]['value'] == item.userDepartment)
  78. return depart["list"][i]['key']
  79. }
  80. return "";
  81. }},
  82. { display: '小组', name: 'userGroup', align: 'left', width: 165,editor: { type: 'select',data:group1,selWidth:150,link:true,relation:"child",linkHandler:linkHandler1 },render:function (item){
  83. var childData=linkHandler1(item.userDepartment);
  84. if(childData){
  85. for (var i = 0; i < childData["list"].length; i++)
  86. {
  87. if (childData["list"][i]['value'] == item.userGroup)
  88. return childData["list"][i]['key']
  89. }
  90. }
  91. return "";
  92. }},
  93. { display: '入职类型', name: 'userType', align: 'left', width: 165,editor: { type: 'select',data:userTypeData,selWidth:150,link:true,relation:"parent" ,linkHandler:linkHandler2 },render:function (item){
  94. for (var i = 0; i < userTypeData["list"].length; i++)
  95. {
  96. if (userTypeData["list"][i]['value'] == item.userType)
  97. return userTypeData["list"][i]['key']
  98. }
  99. return "";
  100. }},
  101. { display: '医保情况', name: 'medical', align: 'left', width: 165,editor: { type: 'select',data:medi1,selWidth:150,link:true,relation:"child",linkHandler:linkHandler2 },render:function (item){
  102. var childData=linkHandler2(item.userType);
  103. if(childData){
  104. for (var i = 0; i < childData["list"].length; i++)
  105. {
  106. if (childData["list"][i]['value'] == item.medical)
  107. return childData["list"][i]['key']
  108. }
  109. }
  110. return "";
  111. }},
  112. { display: '操作', isSort: false, width: 200, render: function (rowdata, rowindex, value)
  113. {
  114. var h = "";
  115. if (!rowdata._editing)
  116. {
  117. h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>删除</span></a> ";
  118. h += "<a onclick='onView(" + rowindex + ")'><span class='icon_view'>查看</span></a>";
  119. h += "<a onclick='beginEdit(" + rowindex + ")'><span class='icon_edit'>修改</span></a> ";
  120. }
  121. else
  122. {
  123. h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>删除</span></a> ";
  124. h += "<a onclick='onView(" + rowindex + ")'><span class='icon_view'>查看</span></a>";
  125. h += "<a onclick='endEdit(" + rowindex + ")'><span class='icon_ok'>提交</span></a> ";
  126. h += "<a onclick='cancelEdit(" + rowindex + ")'><span class='icon_no'>取消</span></a> ";
  127. }
  128. return h;
  129. }
  130. }
  131. ],
  132. data:testData,sortName: 'userId',rownumbers:true,pageSize:10,dataAction:"server",usePager: true,
  133. height: "100%", width:"100%",enabledEdit: true,clickToEdit: false,onDblClickRow:function(rowdata, rowindex){
  134. g.beginEdit(rowindex);
  135. },onBeforeEdit: onBeforeEdit, onBeforeSubmitEdit: onBeforeSubmitEdit,onAfterSubmitEdit: onAfterSubmitEdit,
  136. toolbar:
  137. {
  138. items: [
  139. { text: '新增', click: addUser, iconClass: 'icon_add' },
  140. { line: true },
  141. { text: '全部确认修改', click: endAllEdit, iconClass: 'icon_ok' },
  142. { line: true },
  143. { text: '全部取消修改', click: cancelAllEdit, iconClass: 'icon_no' }
  144. ]
  145. }
  146. });
  147. }
  148. function linkHandler1(value){
  149. var cData;
  150. if(value=="1"){
  151. cData=group1;
  152. }
  153. else if(value=="2"){
  154. cData=group2;
  155. }
  156. else if(value=="3"){
  157. cData=group3;
  158. }
  159. return cData;
  160. }
  161. function linkHandler2(value){
  162. var cData;
  163. if(value=="1"){
  164. cData=medi1;
  165. }
  166. else if(value=="2"){
  167. cData=medi2;
  168. }
  169. return cData;
  170. }
  171. //查看
  172. function onView(rowidx){
  173. }
  174. //删除
  175. function onDelete(rowidx){
  176. }
  177. //编辑
  178. function beginEdit(rowid) {
  179. g.beginEdit(rowid);
  180. }
  181. //取消编辑
  182. function cancelEdit(rowid) {
  183. g.cancelEdit(rowid);
  184. }
  185. //结束编辑
  186. function endEdit(rowid)
  187. {
  188. g.endEdit(rowid);
  189. }
  190. //新增
  191. function addUser(){
  192. var row = g.getRow(0);
  193. var rowData={
  194. userName:"新增",
  195. userSex:1,
  196. userAge:18,
  197. userId:'',
  198. userEducation:"2",
  199. userDepartment:"",
  200. userGroup:""
  201. }
  202. g.addEditRow(rowData, row, true);
  203. }
  204. //将row JSON对象转化为bo对象
  205. function rowToBO(row) {
  206. var params = '&userinfor.userId='+row.userId+'&userinfor.userName='+row.userName+'&userinfor.userSex='+row.userSex+'&userinfor.userAge='+Math.ceil(row.userAge)+'&userinfor.userDepartment='+row.userDepartment+'&userinfor.userEmployTime='+row.userEmployTime+'&userinfor.userPassword='+row.userPassword+'&userinfor.userEducation='+row.userEducation+'&userinfor.userLoginName='+row.userLoginName;
  207. return params;
  208. }
  209. //删除后的提示
  210. function handleResult(result){
  211. if(result == 1){
  212. top.Dialog.alert("删除成功!",null,null,null,1);
  213. g.loadData();
  214. }else{
  215. top.Dialog.alert("删除失败!");
  216. }
  217. }
  218. //全部确认修改
  219. function endAllEdit(){
  220. g.endEdit();
  221. }
  222. //全部取消修改
  223. function cancelAllEdit()
  224. {
  225. g.cancelEdit();
  226. }
  227. //编辑前事件
  228. function onBeforeEdit(e)
  229. {
  230. var str="编辑前事件,可阻止某些行或列进行编辑。列名:"+e.column.name+";行号:"+e.rowindex+";编辑前的值:"+e.value+"\n";
  231. //if(e.record.id=="121"){
  232. //top.Dialog.alert("此行不可编辑",null,null,null,2);
  233. // return false;
  234. //}
  235. }
  236. //编辑提交前事件
  237. function onBeforeSubmitEdit(e){
  238. if(e.newdata.userName==""){
  239. top.Dialog.alert("姓名不能为空!",null,null,null,2);
  240. return false;
  241. }
  242. else if (!validateInput(e.newdata.userName, "^[\u4e00-\u9fa5]+$")){
  243. top.Dialog.alert("姓名需要是中文!",null,null,null,2);
  244. return false;
  245. }
  246. }
  247. //编辑后事件
  248. function onAfterSubmitEdit(e)
  249. {
  250. }
  251. </script>
  252. </body>
  253. </html>