CommonUsePortal.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Ext.define('erp.view.common.DeskTop.CommonUsePortal', {
  2. extend: 'erp.view.common.DeskTop.Portlet',
  3. alias: 'widget.commonuseportal',
  4. title: '<div class="div-left">常用模块</div>',
  5. iconCls: 'main-news',
  6. id: 'bench_link',
  7. enableTools:true,
  8. pageCount:15,
  9. activeRefresh:true,
  10. initComponent : function() {
  11. var me = this;
  12. Ext.apply(me,{
  13. items: [{
  14. xtype: 'gridpanel',
  15. id: 'link_grid',
  16. cls: 'custom-grid',
  17. columnLines : true,
  18. store: Ext.create('Ext.data.Store', {
  19. fields:['cu_id', 'cu_description', 'cu_url', 'cu_count','cu_lock'],
  20. proxy: {
  21. type: 'ajax',
  22. url : basePath + 'common/getCommonUse.action',
  23. method : 'get',
  24. extraParams:{
  25. count:me.pageCount
  26. },
  27. reader: {
  28. type: 'json',
  29. root: 'commonuse'
  30. }
  31. },
  32. autoLoad:true
  33. }),
  34. bodyStyle: 'background: #f1f1f1;',
  35. columns: [{
  36. text: 'ID',
  37. dataIndex: 'cu_id',
  38. hidden: true
  39. },{
  40. text: '模块名',
  41. dataIndex: 'cu_description',
  42. flex: 1,
  43. renderer: function(val, meta, record){
  44. var ht = "<a href=\"javascript:openTable("
  45. + record.data['cu_id'] + ",null,\'" + val + "\',\'" + record.data['cu_url'].replace(/\'/g, '\\\'') + "\',null,null,null,null,true)\">" + val + "</a>";
  46. return ht;
  47. }
  48. },{
  49. text: '链接',
  50. dataIndex: 'cu_url',
  51. hidden: true
  52. },{
  53. text: '次数',
  54. dataIndex: 'cu_count',
  55. hidden: true
  56. },{
  57. xtype: 'actioncolumn',
  58. text: '操作',
  59. flex: 0.15,
  60. items: [{
  61. icon:basePath + 'resource/images/16/lock_bg.png',
  62. tooltip: '锁定',
  63. iconCls:'',
  64. getClass: function(v, meta, rec) {
  65. if(rec.get('cu_lock')==1){
  66. this.items[0].tooltip = '取消关注';
  67. return 'lock';
  68. }else{
  69. this.items[0].tooltip = '关注';
  70. return 'lockopen';
  71. }
  72. },
  73. handler: function(view, rowIndex, colIndex) {
  74. var rec = view.getStore().getAt(rowIndex);
  75. var type=0;
  76. if(rec.data.cu_lock==null||rec.data.cu_lock==0){
  77. type=1;
  78. }else{
  79. type=0;
  80. }
  81. view.ownerCt.lockCommonUse(rec.get('cu_id'), type);
  82. }
  83. }/*,{
  84. icon: basePath + 'resource/images/16/up.png',
  85. tooltip: '上',
  86. handler: function(view, rowIndex, colIndex) {
  87. var rec = view.getStore().getAt(rowIndex);
  88. view.ownerCt.updateCommonUse(rec.get('cu_id'), 1);
  89. }
  90. },{
  91. icon: basePath + 'resource/images/16/down.png',
  92. tooltip: '下',
  93. handler: function(view, rowIndex, colIndex) {
  94. var rec = view.getStore().getAt(rowIndex);
  95. view.ownerCt.updateCommonUse(rec.get('cu_id'), -1);
  96. }
  97. }*/,{
  98. icon: basePath + 'resource/images/16/delete.png',
  99. tooltip: '删除',
  100. handler: function(view, rowIndex, colIndex) {
  101. var rec = view.getStore().getAt(rowIndex);
  102. view.ownerCt.deleteCommonUse(rec.get('cu_id'));
  103. }
  104. }]
  105. }],
  106. lockCommonUse : function(id, t) {
  107. var g = this;
  108. g.setLoading(true);
  109. Ext.Ajax.request({
  110. url : basePath + 'common/lockCommonUse.action',
  111. params : {
  112. _noc : 1,
  113. id : id,
  114. type : t,
  115. count:15
  116. },
  117. callback : function(o, s, r) {
  118. g.setLoading(false);
  119. var rs = Ext.decode(r.responseText);
  120. if (rs.commonuse) {
  121. g.store.loadData(rs.commonuse);
  122. }
  123. }
  124. });
  125. },
  126. updateCommonUse : function(id, t) {
  127. var g = this;
  128. g.setLoading(true);
  129. Ext.Ajax.request({
  130. url : basePath + 'common/updateCommonUse.action',
  131. params : {
  132. _noc : 1,
  133. id : id,
  134. type : t,
  135. count:15
  136. },
  137. callback : function(o, s, r) {
  138. g.setLoading(false);
  139. var rs = Ext.decode(r.responseText);
  140. if (rs.commonuse) {
  141. g.store.loadData(rs.commonuse);
  142. }
  143. }
  144. });
  145. },
  146. deleteCommonUse :function(id){
  147. var g = this;
  148. Ext.Ajax.request({
  149. url : basePath + 'common/deleteCommonUse.action',
  150. params: {
  151. id: id
  152. },
  153. method : 'post',
  154. callback : function(options,success,response){
  155. var res = new Ext.decode(response.responseText);
  156. if(res.exception || res.exceptionInfo){
  157. showError(res.exceptionInfo);
  158. return;
  159. }
  160. Ext.each(g.store.data.items, function(item){
  161. if(item.data['cu_id'] == id){
  162. g.store.remove(item);
  163. }
  164. });
  165. }
  166. });
  167. }
  168. }]
  169. });
  170. this.callParent();
  171. },
  172. _dorefresh:function(panel){
  173. var gridpanel=panel.down('gridpanel');
  174. gridpanel.getStore().load();
  175. },
  176. getMore:function(){
  177. openTable(null,null,'更多常用模块',"jsps/common/datalist.jsp?whoami=CommonUse&urlcondition=cu_emid=session:em_id",null,null);
  178. }
  179. });