IcomPersonNaturePage.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /**===========================================
  2. * @projectDescription IcomPersonNature.js
  3. * @use by IcomPersonNature.jsp
  4. * @author hongyan_guan
  5. * @create at 2008-08-27 星期三 下午 02:11:40
  6. * @update by
  7. ==============================================*/
  8. var gridr="";
  9. var dataModelr="";
  10. var dsr="";
  11. Ext.onReady(function(){
  12. //ext准备方法开始
  13. Ext.QuickTips.init();
  14. //定义读取数据的模版
  15. dataModelr = Ext.data.Record.create([
  16. { name:'id',mapping:'id'},
  17. { name:'name',mapping:'name'},
  18. { name:'telephone',mapping:'telephone'},
  19. { name:'position',mapping:'position'},
  20. { name:'status',mapping:'status'},
  21. { name:'orderNum',mapping:'orderNum'}
  22. ]);
  23. //定义列模板
  24. var colModelr = new Ext.grid.ColumnModel([
  25. new Ext.grid.RowNumberer(),
  26. {
  27. id:'id',
  28. header:"id",
  29. dataIndex:'id',
  30. hidden:true,
  31. width:80,
  32. sortable: true,
  33. align:'left' },
  34. {
  35. id:'position',
  36. header:"position",
  37. dataIndex:'position',
  38. hidden:true,
  39. width:80,
  40. sortable: true,
  41. align:'left' },
  42. {
  43. id:'name',
  44. header:"姓名",
  45. dataIndex:'name',
  46. hidden:false,
  47. width:100,
  48. fixed:false,
  49. sortable: true,
  50. align:'left' ,
  51. editor: new Ext.form.TextField({allowBlank: false,allowNegative: true}) },
  52. {
  53. id:'telephone',
  54. header:"电话",
  55. dataIndex:'telephone',
  56. hidden:false,
  57. width:100,
  58. fixed:false,
  59. sortable: true,
  60. align:'left' ,
  61. editor: new Ext.form.TextField({allowBlank: false,allowNegative: true}) },
  62. {
  63. id:'orderNum',
  64. header:"排序号",
  65. dataIndex:'orderNum',
  66. hidden:false,
  67. width:100,
  68. fixed:false,
  69. sortable: true,
  70. align:'left' ,
  71. editor: new Ext.form.NumberField({allowBlank: false,allowNegative: true}) },
  72. {
  73. id:'status',
  74. header:"状态",
  75. dataIndex:'status',
  76. hidden:false,
  77. width:80,
  78. fixed:true,
  79. sortable: true,
  80. align:'left' ,
  81. editor: new Ext.form.ComboBox({
  82. store:Ideal.ComboBoxR.getStore(parent.dicContainer[104].childrenJson),//store:carTypeStore
  83. displayField:'name',
  84. typeAhead: false,
  85. valueField:'value',
  86. forceSelection:true,
  87. hiddenName :'ILocked',
  88. lazyRender :true,
  89. readOnly : true,
  90. mode: 'local',
  91. triggerAction: 'all',
  92. listClass: 'x-combo-list-small'
  93. }),
  94. renderer:Ideal.ComboBoxR.getRenderer}
  95. ]);
  96. //定义存储器,从后台读取json数据
  97. dsr = new Ext.data.Store({
  98. proxy: new Ext.data.HttpProxy({url: projectPath+'/employeeAction!query.action'}),
  99. reader: new Ext.data.JsonReader({root: 'data'},dataModelr)
  100. });
  101. //定义列表对象
  102. gridr = new Ext.grid.EditorGridPanel({
  103. ds: dsr,
  104. clicksToEdit:1,
  105. selModel: new Ext.grid.RowSelectionModel(),
  106. cm: colModelr,
  107. frame:false,
  108. border:false
  109. });
  110. gridr.render('grid_personarea');
  111. dsr.load({params:{position:positionInnerCode}});
  112. //ext准备方法结束
  113. });
  114. /****************************************** 自定义函数 ********************************************************************************/
  115. var winHandle;
  116. /**
  117. * 新增或者修改后的保存
  118. */
  119. function saveIcomPersonNature() {
  120. var m = dsr.modified.slice(0);
  121. if(m.length == 0){
  122. setMessage('没有需要保存的条目!');
  123. return;
  124. }
  125. for(var j=0;j<m.length;j++){
  126. var fullName = m[j].data['name'];
  127. if(trim(fullName) == ''){
  128. setMessage('请填写名称!');
  129. return;
  130. }
  131. }
  132. var jsonData = "[";
  133. for ( var i = 0, len = m.length; i < len; i++ ){
  134. var ss = Ext.util.JSON.encode(m[i].data);
  135. if ( i==0 )
  136. jsonData = jsonData + ss;
  137. else
  138. jsonData = jsonData + "," + ss;
  139. }
  140. jsonData = jsonData + "]";
  141. if(jsonData == '[]'){
  142. setMessage('请填写完整信息!');
  143. return;
  144. }
  145. //end
  146. Ext.Ajax.request({
  147. url : prjContextPath+'/employeeAction!update.action',
  148. params:{data:jsonData},
  149. method: 'post',
  150. success: function ( result, request) {
  151. //如果失败 捕获后台自定义的异常
  152. if (isScript(result.responseText))return;
  153. dsr.modified = []; //将修改过的记录置为空,如果不清空,则修改过的数据会一直保留
  154. extMessage('保存成功!');
  155. dsr.reload({params:{position:positionInnerCode}});
  156. },
  157. failure: function ( result, request) {
  158. }
  159. });
  160. }
  161. /**
  162. * 删除提示操作
  163. */
  164. function deleteIcomPersonNature()
  165. {
  166. var m = gridr.getSelections();
  167. if(m.length == 0){
  168. setMessage('请选择要删除的数据!');
  169. return;
  170. }
  171. if(m.length > 0)
  172. {
  173. parent._confirm_msg_show( '确定要删除选中的数据吗?' , this.window.name+'.deleteIcomPersonNature_deleteCall(1)');
  174. }
  175. }
  176. /**
  177. * 删除操作,用户做选择后回调函数
  178. */
  179. function deleteIcomPersonNature_deleteCall(btn)
  180. {
  181. //如果点击确定
  182. if(btn == '1')
  183. {
  184. var m = gridr.getSelections();
  185. var ballPlatCode = new Array();
  186. for(i=0;i<m.length;i++){
  187. ballPlatCode[ballPlatCode.length]=m[i].data['id'];
  188. }
  189. if(ballPlatCode.length == 0)
  190. return;
  191. Ext.Ajax.request({
  192. url : projectPath+'/employeeAction!delete.action',
  193. method: 'POST',
  194. params:{idArray:ballPlatCode},
  195. success: function ( result, request ) {
  196. //如果失败 捕获后台自定义的异常
  197. if (isScript(result.responseText))return;
  198. gridr.modified = [];
  199. dsr.reload({params:{position:positionInnerCode}});
  200. extMessage('删除成功!');
  201. },
  202. failure: function ( result, request) {
  203. }
  204. });
  205. }else{
  206. return;
  207. }
  208. }
  209. /**
  210. * 新建一行记录
  211. */function addNewRow(){
  212. if(positionInnerCode==""||positionInnerCode==null){
  213. setMessage("请选择岗位!");
  214. return;
  215. }
  216. var p = new dataModelr({
  217. id:'',
  218. position:positionInnerCode,
  219. name:'',
  220. orderNum:'',
  221. telephone:'',
  222. status:0
  223. });
  224. gridr.stopEditing();
  225. dsr.insert(0, p);
  226. gridr.startEditing(0, 0);
  227. }
  228. function userPeixun(){
  229. var m = gridr.getSelections();
  230. if(m.length == 0){
  231. setMessage('请选择要维护培训的人员数据!');
  232. return;
  233. }
  234. if(m.length == 1)
  235. {
  236. var tempUserCode=m[0].data['userCode'];
  237. winHandle=parent.openWindow(projectPath+'/personManage.do?method=doPeixunAction&forward=/permission/IcomPersonNaturePage/personPeixunGrid.jsp&userCode='+tempUserCode,600,405,'表单窗口',this.window);
  238. }
  239. }