GroupDocumentPower.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /**
  2. * ERP项目groupgrid样式:hrjob分组
  3. */
  4. Ext.define('erp.view.core.grid.GroupDocumentPower',{
  5. extend: 'Ext.grid.Panel',
  6. alias: 'widget.groupdocumentpower',
  7. layout : 'fit',
  8. id: 'grid',
  9. emptyText : $I18N.common.grid.emptyText,
  10. columnLines : true,
  11. autoScroll : true,
  12. iconCls: 'icon-grid',
  13. frame: true,
  14. bodyStyle:'background-color:#f1f1f1;',
  15. features: [Ext.create('Ext.grid.feature.Grouping',{
  16. startCollapsed: true,
  17. groupHeaderTpl: '<input type="checkbox" id="group{name}" onclick="selectOrg(\'{name}\',\'group{name}\')"/>{name} ({rows.length} 人)'
  18. })],
  19. store: Ext.create('Ext.data.Store', {
  20. fields: [{
  21. name: 'jo_orgid',
  22. type: 'number'
  23. }, {
  24. name:'jo_orgname',
  25. type:'string'
  26. },{
  27. name:'jo_description',
  28. type:'string'
  29. },{
  30. name:'jo_name',
  31. type:'string'
  32. },{
  33. name:'jo_emid',
  34. type:'number'
  35. },{
  36. name:'jo_id',
  37. type:'number'
  38. },{
  39. name:'dpp_add',
  40. type:'bool'
  41. },{
  42. name:'dpp_delete',
  43. type:'bool'
  44. },{
  45. name:'dpp_upload',
  46. type:'bool'
  47. },{
  48. name:'dpp_download',
  49. type:'bool'
  50. },{
  51. name:'dpp_update',
  52. type:'bool'
  53. }],
  54. sorters: [{
  55. property : 'jo_emid',
  56. direction: 'ASC'
  57. }],
  58. groupField: 'jo_orgname'
  59. }),
  60. columns: [{
  61. text: '岗位资料',
  62. columns: [{
  63. text: 'ID',
  64. width: 0,
  65. dataIndex: 'jo_id'
  66. },{
  67. text: '组织ID',
  68. flex: 1,
  69. dataIndex: 'jo_orgid'
  70. },{
  71. text: '组织名称',
  72. flex: 1,
  73. dataIndex: 'jo_orgname'
  74. },{
  75. text: '岗位描述',
  76. flex: 1.5,
  77. dataIndex: 'jo_description'
  78. },{
  79. text: '岗位名称',
  80. flex: 1,
  81. dataIndex: 'jo_name'
  82. },{
  83. text: '员工ID',
  84. flex: 1,
  85. dataIndex: 'jo_emid'
  86. }]
  87. },{
  88. text: '操作名称',
  89. columns: [{
  90. text: '添加文件夹',
  91. flex: 0.2,
  92. xtype: 'checkcolumn',
  93. editor: {
  94. xtype: 'checkbox',
  95. cls: 'x-grid-checkheader-editor'
  96. },
  97. dataIndex: 'dpp_add'
  98. },{
  99. text: '删除文件/文件夹',
  100. flex: 0.2,
  101. xtype: 'checkcolumn',
  102. editor: {
  103. xtype: 'checkbox',
  104. cls: 'x-grid-checkheader-editor'
  105. },
  106. dataIndex: 'dpp_delete'
  107. },{
  108. text: '上传',
  109. flex: 0.2,
  110. xtype: 'checkcolumn',
  111. editor: {
  112. xtype: 'checkbox',
  113. cls: 'x-grid-checkheader-editor'
  114. },
  115. dataIndex: 'dpp_upload'
  116. },{
  117. text: '下载',
  118. flex: 0.2,
  119. xtype: 'checkcolumn',
  120. editor: {
  121. xtype: 'checkbox',
  122. cls: 'x-grid-checkheader-editor'
  123. },
  124. dataIndex: 'dpp_download'
  125. },{
  126. text: '修改',
  127. flex: 0.2,
  128. xtype: 'checkcolumn',
  129. editor: {
  130. xtype: 'checkbox',
  131. cls: 'x-grid-checkheader-editor'
  132. },
  133. dataIndex: 'dpp_update'
  134. }]
  135. }],
  136. tbar: [{
  137. iconCls: 'tree-save',
  138. text: $I18N.common.button.erpSaveButton,
  139. handler: function(){
  140. var grid = Ext.getCmp('grid');
  141. var documentpositionpowers = [];
  142. var documentpositionpower = null;
  143. Ext.each(grid.store.data.items, function(){
  144. if(this.dirty){
  145. documentpositionpower = new Object();
  146. documentpositionpower.dpp_dcpid = grid.dcp_id;
  147. documentpositionpower.dpp_id = this.data['dpp_id'];
  148. documentpositionpower.dpp_joid = this.data['jo_id'];
  149. documentpositionpower.dpp_add = this.data['dpp_add'] ? 1 : 0;
  150. documentpositionpower.dpp_delete = this.data['dpp_delete'] ? 1 : 0;
  151. documentpositionpower.dpp_upload = this.data['dpp_upload'] ? 1 : 0;
  152. documentpositionpower.dpp_download = this.data['dpp_download'] ? 1 : 0;
  153. documentpositionpower.dpp_update = this.data['dpp_update'] ? 1 : 0;
  154. documentpositionpowers.push(documentpositionpower);
  155. }
  156. });
  157. if(documentpositionpowers.length > 0){
  158. Ext.Ajax.request({//拿到grid的columns
  159. url : basePath + 'hr/employee/updateJobDocumentPower.action',
  160. params: {
  161. update: Ext.encode(documentpositionpowers)
  162. },
  163. method : 'post',
  164. callback : function(options,success,response){
  165. var res = new Ext.decode(response.responseText);
  166. if(res.exception || res.exceptionInfo){
  167. showError(res.exceptionInfo);
  168. return;
  169. }
  170. if(res.success){
  171. updateSuccess(function(){
  172. parent.Ext.getCmp("win").close();
  173. });
  174. }
  175. }
  176. });
  177. }
  178. }
  179. },'-',{
  180. iconCls: 'group-close',
  181. text: $I18N.common.button.erpCloseButton,
  182. handler: function(){
  183. parent.Ext.getCmp("win").close();
  184. }
  185. }],
  186. initComponent : function(){
  187. this.callParent(arguments);
  188. this.dcp_id = getUrlParam('dcp_id');
  189. this.getGroupData();
  190. },
  191. listeners: {//滚动条有时候没反应,添加此监听器
  192. scrollershow: function(scroller) {
  193. if (scroller && scroller.scrollEl) {
  194. scroller.clearManagedListeners();
  195. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  196. }
  197. }
  198. },
  199. getGroupData: function(){
  200. var me = this;
  201. //先取HrJob,HrJob的配置是放在datalist表里面的
  202. Ext.Ajax.request({//拿到grid的columns
  203. url : basePath + 'hr/employee/getHrJob_dcp.action',
  204. params: {
  205. id: me.dcp_id
  206. },
  207. method : 'post',
  208. callback : function(options,success,response){
  209. var res = new Ext.decode(response.responseText);
  210. if(res.exception || res.exceptionInfo){
  211. showError(res.exceptionInfo);
  212. return;
  213. }
  214. if(!res.hrjob){
  215. return;
  216. } else {
  217. var data = new Array();
  218. Ext.each(res.hrjob, function(){
  219. var j = this;
  220. Ext.each(res.documentpositionpower, function(){
  221. if(j.jo_id == this.dpp_joid){
  222. j = Ext.Object.merge(j, this);
  223. j.dpp_id = this.dpp_id;
  224. j.dpp_add = this.dpp_add == 1;
  225. j.dpp_delete = this.dpp_delete == 1;
  226. j.dpp_upload = this.dpp_upload == 1;
  227. j.dpp_download = this.dpp_download == 1;
  228. j.dpp_update = this.dpp_update == 1;
  229. }
  230. });
  231. data.push(j);
  232. });
  233. me.store.loadData(data);
  234. }
  235. }
  236. });
  237. },
  238. selModel: Ext.create('Ext.selection.CheckboxModel',{
  239. listeners:{
  240. 'select': function(view, record){
  241. this.selectAllPower(record);
  242. },
  243. 'deselect': function(view, record){
  244. this.deselectAllPower(record);
  245. }
  246. },
  247. selectAllPower: function(record){
  248. record.set('dpp_add', true);
  249. record.set('dpp_delete', true);
  250. record.set('dpp_upload', true);
  251. record.set('dpp_download', true);
  252. record.set('dpp_update', true);
  253. },
  254. deselectAllPower: function(record){
  255. record.set('dpp_add', false);
  256. record.set('dpp_delete', false);
  257. record.set('dpp_upload', false);
  258. record.set('dpp_download', false);
  259. record.set('dpp_update', false);
  260. }
  261. })
  262. });
  263. function selectOrg(orgname, id){
  264. var dom = document.getElementById(id);
  265. var grid = Ext.getCmp('grid');
  266. var selected = new Array();
  267. Ext.each(grid.store.data.items, function(){
  268. if(this.data['jo_orgname'] == orgname){
  269. selected.push(this);
  270. }
  271. });
  272. if(dom.checked){
  273. grid.selModel.select(selected);
  274. } else {
  275. grid.selModel.deselect(selected);
  276. }
  277. }