IcomUserNaturePage.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. var gridr="";
  2. var dataModelr="";
  3. var dsr="";
  4. var record_start=0;
  5. var start=0;
  6. var limit=getLimitNum();
  7. Ext.onReady(function(){
  8. //ext准备方法开始
  9. Ext.QuickTips.init();
  10. //定义读取数据的模版
  11. dataModelr = Ext.data.Record.create([
  12. { name:'id',mapping:'id'},
  13. { name:'name',mapping:'name'},
  14. { name:'userid',mapping:'userid'},
  15. { name:'loginname',mapping:'loginname'},
  16. { name:'loginpwd',mapping:'loginpwd'},
  17. { name:'mac',mapping:'mac'},
  18. { name:'status',mapping:'status'}
  19. ]);
  20. //定义列模板
  21. var colModelr = new Ext.grid.ColumnModel([
  22. new Ext.grid.RowNumberer({
  23. header: "序号",
  24. width: 36,
  25. height:60,
  26. renderer: function(value,metadata,record,rowIndex){
  27. return record_start + 1 + rowIndex;
  28. }
  29. }),
  30. {
  31. id:'id',
  32. header:"id",
  33. dataIndex:'id',
  34. hidden:true,
  35. width:80,
  36. sortable: true,
  37. align:'left' },
  38. {
  39. id:'name',
  40. header:"姓名",
  41. dataIndex:'name',
  42. hidden:false,
  43. width:80,
  44. sortable: true,
  45. align:'left' },
  46. {
  47. id:'userid',
  48. header:"员工编号",
  49. dataIndex:'userid',
  50. hidden:true,
  51. width:180,
  52. sortable: true,
  53. align:'left' },
  54. {
  55. id:'loginname',
  56. header:"账号",
  57. dataIndex:'loginname',
  58. hidden:false,
  59. width:80,
  60. sortable: true,
  61. align:'left' ,
  62. editor: new Ext.form.TextField({allowBlank: false,allowNegative: true})},
  63. {
  64. id:'loginpwd',
  65. header:"密码",
  66. dataIndex:'loginpwd',
  67. inputType:'password',
  68. hidden:false,
  69. width:100,
  70. fixed:false,
  71. sortable: true,
  72. align:'left' ,
  73. editor: new Ext.form.TextField({allowBlank: false,allowNegative: true}) },
  74. {
  75. id:'mac',
  76. header:"MAC地址",
  77. dataIndex:'mac',
  78. hidden:false,
  79. width:100,
  80. fixed:false,
  81. sortable: true,
  82. align:'left' ,
  83. editor: new Ext.form.TextField({allowBlank: false,allowNegative: true}) },
  84. {
  85. id:'status',
  86. header:"状态",
  87. dataIndex:'status',
  88. hidden:false,
  89. width:80,
  90. fixed:true,
  91. sortable: true,
  92. align:'left' ,
  93. editor: new Ext.form.ComboBox({
  94. store:Ideal.ComboBoxR.getStore(parent.dicContainer[104].childrenJson),
  95. displayField:'name',
  96. typeAhead: false,
  97. valueField:'value',
  98. forceSelection:true,
  99. hiddenName :'ILocked',
  100. lazyRender :true,
  101. readOnly : true,
  102. mode: 'local',
  103. triggerAction: 'all',
  104. listClass: 'x-combo-list-small'
  105. }),
  106. renderer:Ideal.ComboBoxR.getRenderer}
  107. ]);
  108. //定义存储器,从后台读取json数据
  109. dsr = new Ext.data.Store({
  110. proxy: new Ext.data.HttpProxy({url: projectPath+'/permissionsAction!query.action'}),
  111. reader: new Ext.data.JsonReader({totalProperty:'total',root: 'data'},dataModelr)
  112. });
  113. var pagingBar = new Ext.PagingToolbar({
  114. pageSize: limit,
  115. store: dsr,
  116. autoWidth: true,
  117. displayInfo: true,
  118. beforePageText: "第",
  119.   afterPageText: "页,共{0}页",
  120.   firstText: "首页",
  121.   prevText: "上一页",
  122.   nextText: "下一页",
  123.   lastText: "尾页",
  124. refreshText: "刷新",
  125. displayMsg: "当前显示记录从{0}-{1} 总{2}条记录",
  126. emptyMsg: "没有相关记录!",
  127. doLoad:function(start){
  128. record_start=start;
  129.     var o = {}, pn = this.paramNames;
  130. o[pn.start] = start;
  131. o[pn.limit] = this.pageSize;
  132. if(this.fireEvent('beforechange', this, o) !== false){
  133. dsr.load({params:o});
  134. }
  135.        }
  136. });
  137. //定义列表对象
  138. gridr = new Ext.grid.EditorGridPanel({
  139. ds: dsr,
  140. clicksToEdit:1,
  141. selModel: new Ext.grid.RowSelectionModel(),
  142. cm: colModelr,
  143. frame:false,
  144. border:false,
  145. bbar: pagingBar
  146. });
  147. gridr.render('grid_userarea');
  148. dsr.on('beforeload', function(){
  149. this.baseParams={position:positionInnerCode,deptid:deptcode};
  150. });
  151. dsr.load({params:{start:start,limit:limit}});
  152. //ext准备方法结束
  153. //ext准备方法结束
  154. });
  155. /****************************************** 自定义函数 ********************************************************************************/
  156. var winHandle;
  157. var value;
  158. var te;
  159. /**
  160. * 新增或者修改后的保存
  161. */
  162. function doValidateEdit(e){
  163. value = e.value;
  164. var columnName = e.field;
  165. var id=e.record.data['id'];
  166. var loginname=e.record.data['loginname'];
  167. $.post(prjContextPath+"/permissionsAction!queryJiaoyan.action",
  168. {
  169. loginname:loginname
  170. }, callBackFunc);
  171. }
  172. function callBackFunc(json) {
  173. if (json != null && json.success != null) {
  174. if (json.success == "0") {
  175. te.value='';
  176. //alert(te.value='');
  177. alert('用户已存在');
  178. return 0;
  179. }
  180. } else {
  181. alert('用户可用');
  182. }
  183. }
  184. function resetpwd(){
  185. var m = gridr.getSelections();
  186. if(m.length==0){
  187. setMessage('请选择要维护的数据!');
  188. return;
  189. }
  190. if(m.length == 1)
  191. {
  192. var tempUserCode=m[0].data['id'];
  193. var loginpwd=m[0].data['loginpwd'];
  194. $.post(projectPath+"/permissionsAction!resetpwd.action", {id:tempUserCode,loginpwd:111111}, callFuncresetpwd);
  195. }
  196. }
  197. function callFuncresetpwd(json){
  198. if(json!=null){
  199. if(json.success=="1"){
  200. //alert('提示:发文成功!');
  201. dsr.reload();
  202. }
  203. }else{
  204. alert('提示:初始化失败!');
  205. }
  206. }
  207. function saveIcomPersonNature() {
  208. var m = dsr.modified.slice(0);
  209. if(m.length == 0){
  210. setMessage('没有需要保存的条目!');
  211. return;
  212. }
  213. for(var j=0;j<m.length;j++){
  214. var loginname = m[j].data['loginname'];
  215. if(trim(loginname) == ''){
  216. setMessage('请填写账户!');
  217. return;
  218. }
  219. var loginpwd = m[j].data['loginpwd'];
  220. if(fucCheckLength(loginpwd)!= 6){
  221. setMessage('请填写6位字符密码!');
  222. return;
  223. }
  224. if(!(checkIsStrNum(loginpwd))){
  225. setMessage('密码由数字和字母组成!');
  226. return;
  227. }
  228. var mac= m[j].data['mac'];
  229. if(trim(mac) == ''){
  230. setMessage('请填写MAC地址!');
  231. return;
  232. }
  233. }
  234. var jsonData = "[";
  235. for ( var i = 0, len = m.length; i < len; i++ ){
  236. var ss = Ext.util.JSON.encode(m[i].data);
  237. if ( i==0 )
  238. jsonData = jsonData + ss;
  239. else
  240. jsonData = jsonData + "," + ss;
  241. }
  242. jsonData = jsonData + "]";
  243. if(jsonData == '[]'){
  244. setMessage('请填写完整信息!');
  245. return;
  246. }
  247. //end
  248. Ext.Ajax.request({
  249. url : prjContextPath+'/permissionsAction!updateBatch.action',
  250. params:{data:jsonData},
  251. method: 'post',
  252. success: function ( result, request) {
  253. //如果失败 捕获后台自定义的异常
  254. if (isScript(result.responseText))return;
  255. dsr.modified = []; //将修改过的记录置为空,如果不清空,则修改过的数据会一直保留
  256. extMessage('保存成功!');
  257. dsr.reload({params:{position:positionInnerCode,deptid:deptcode}});
  258. },
  259. failure: function ( result, request) {
  260. }
  261. });
  262. }
  263. /**
  264. * 删除提示操作
  265. */
  266. function deleteIcomPersonNature()
  267. {
  268. var m = gridr.getSelections();
  269. if(m.length == 0){
  270. setMessage('请选择要删除的数据!');
  271. return;
  272. }
  273. if(m.length > 0)
  274. {
  275. parent._confirm_msg_show( '确定要删除选中的数据吗?' , this.window.name+'.deleteIcomPersonNature_deleteCall(1)');
  276. }
  277. }
  278. /**
  279. * 删除操作,用户做选择后回调函数
  280. */
  281. function deleteIcomPersonNature_deleteCall(btn)
  282. {
  283. //如果点击确定
  284. if(btn == '1')
  285. {
  286. var m = gridr.getSelections();
  287. var ballPlatCode = new Array();
  288. for(i=0;i<m.length;i++){
  289. ballPlatCode[ballPlatCode.length]=m[i].data['id'];
  290. }
  291. if(ballPlatCode.length == 0)
  292. return;
  293. Ext.Ajax.request({
  294. url : projectPath+'/permissionsAction!delete.action',
  295. method: 'POST',
  296. params:{idArray:ballPlatCode},
  297. success: function ( result, request ) {
  298. //如果失败 捕获后台自定义的异常
  299. if (isScript(result.responseText))return;
  300. gridr.modified = [];
  301. dsr.reload({params:{position:positionInnerCode}});
  302. extMessage('删除成功!');
  303. },
  304. failure: function ( result, request) {
  305. }
  306. });
  307. }else{
  308. return;
  309. }
  310. }
  311. //编辑单条数据
  312. function updateNewRow(){
  313. var m = gridr.getSelections();
  314. if(m.length == 0){
  315. setMessage('请选择要维护的数据!');
  316. return;
  317. }
  318. if(m.length == 1){
  319. var id=m[0].data['id'];
  320. if(id!=''){
  321. var userid=m[0].data['userid'];
  322. var url='/system/permissions/userRoleRange.jsp?id='+id+'&userid='+userid;
  323. winHandle=parent.parent.openWindow(projectPath+url,420,360,'设置用户角色',this.window);
  324. }else{
  325. setMessage('提示:您选择的用户尚未创建系统帐号信息!');
  326. }
  327. }
  328. }
  329. function closeWindow(){
  330. if(winHandle!=null){
  331. winHandle.reset();
  332. }
  333. }
  334. function updatepwd(){
  335. var url='/system/permissions/user_view.jsp';
  336. winHandle=parent.openWindow(projectPath+url,300,210,'设置用户密码',this.window);
  337. }