roleModule.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*ext模板
  2. ==============================================*/
  3. var grid="";
  4. var dataModel="";
  5. var ds="";
  6. Ext.onReady(function(){
  7. //ext准备方法开始
  8. Ext.QuickTips.init();
  9. //定义读取数据的模版
  10. dataModel = Ext.data.Record.create([
  11. { name:'id',mapping:'id'},
  12. { name:'name',mapping:'name'},
  13. { name:'funcPermission',mapping:'funcPermission'},
  14. { name:'checkFlag',mapping:'checkFlag'}
  15. ]);
  16. //定义列模板
  17. var sm = new Ext.grid.CheckboxSelectionModel();
  18. var colModel = new Ext.grid.ColumnModel([
  19. new Ext.grid.RowNumberer({width:30}),
  20. sm,
  21. {
  22. id:'id',
  23. header:"模块id",
  24. hidden:true,
  25. dataIndex:'id',
  26. width:50},
  27. {
  28. id:'name',
  29. header:"模块名",
  30. dataIndex:'name',
  31. width:210},
  32. {
  33. id:'funcPermission',
  34. header:"功能权限",
  35. dataIndex:'funcPermission',
  36. hidden:false,
  37. width:78,
  38. fixed:true,
  39. align:'left' ,
  40. editor: new Ext.form.ComboBox({
  41. store:Ideal.ComboBoxR.getStore(parent.dicContainer[184].childrenJson),
  42. displayField:'name',
  43. typeAhead: false,
  44. valueField:'value',
  45. forceSelection:true,
  46. hiddenName :'ILocked',
  47. lazyRender :true,
  48. readOnly : true,
  49. mode: 'local',
  50. triggerAction: 'all',
  51. listClass: 'x-combo-list-small'
  52. }),
  53. renderer:Ideal.ComboBoxR.getRenderer},
  54. {
  55. id:'checkFlag',
  56. header:"选择标志",
  57. dataIndex:'checkFlag',
  58. hidden:true}
  59. ]);
  60. //定义存储器,从后台读取json数据
  61. ds = new Ext.data.Store({
  62. proxy: new Ext.data.HttpProxy({url: prjContextPath+'/moduleAction!queryModuleListByRoleId.action'}),
  63. reader: new Ext.data.JsonReader({root: 'data'},dataModel)
  64. });
  65. //定义列表对象
  66. grid = new Ext.grid.EditorGridPanel({
  67. ds: ds,
  68. clicksToEdit:1,
  69. cm: colModel,
  70. selModel: sm,
  71. frame:false,
  72. border:false,
  73. width:400,
  74. height:260
  75. });
  76. /*默认选中发送对象*/
  77. grid.store.on("load",function(){
  78. var total = grid.getStore().getCount();//数据行数
  79. var arr = new Array();
  80. for(var i=0;i<total;i++){
  81. checkFlag = grid.getView().getCell(i,5).innerText;
  82. if(checkFlag==1){
  83. arr[i] = i;
  84. }
  85. }
  86. grid.getSelectionModel().selectRows(arr,true);
  87. },this);
  88. grid.render('grid-rolemodule');
  89. ds.load({params:{id:roleid}});
  90. //ext准备方法结束
  91. });
  92. /****************************************** 自定义函数 ********************************************************************************/
  93. function saveData() {
  94. var m = grid.getSelections();
  95. var jsonData = "[";
  96. for ( var i = 0, len = m.length; i < len; i++ ){
  97. var ss = Ext.util.JSON.encode(m[i].data);
  98. if ( i==0 )
  99. jsonData = jsonData + ss;
  100. else
  101. jsonData = jsonData + "," + ss;
  102. }
  103. jsonData = jsonData + "]";
  104. return;
  105. //end
  106. Ext.Ajax.request({
  107. url : prjContextPath+'/moduleAction!updateModuleRole.action',
  108. params:{data:jsonData,id:roleid},
  109. method: 'post',
  110. success: function ( result, request) {
  111. closeWindow();
  112. },
  113. failure: function ( result, request) {
  114. }
  115. });
  116. }
  117. function closeWindow(){
  118. parent.maindataFrame.closeWindow();
  119. }