WorkBenchSet.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /**
  2. * 设置工作台的window
  3. */
  4. Ext.define('erp.view.core.window.WorkBenchSet', {
  5. extend: 'Ext.window.Window',
  6. alias: 'widget.workbenchset',
  7. id : 'win',
  8. title: '<font color=#CD6839>工作台设置</font>',
  9. iconCls: 'x-button-icon-set',
  10. height: screen.height*0.8,
  11. width: screen.width*0.9,
  12. maximizable : true,
  13. buttonAlign : 'center',
  14. layout : 'border',
  15. initComponent: function() {
  16. //工作台所在页面
  17. this.contentWindow = Ext.getCmp("content-panel").items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow;
  18. //工作台
  19. this.bench = this.contentWindow.Ext.getCmp("bench");
  20. this.setDataStore();
  21. this.setDataView();
  22. this.items[1].store = this.store;//grid和DataView用的同一个store,在grid的数据改变时,DataView也会相应的改变
  23. this.items[2].store = this.store;
  24. this.callParent(arguments);
  25. this.show();
  26. },
  27. items: [{
  28. region: 'north',
  29. labelAlign: 'right',
  30. xtype: 'form',
  31. frame:true,
  32. buttonAlign: 'center',
  33. buttons: [{
  34. text: '确 定',
  35. handler: function(btn) {
  36. var me = Ext.getCmp('win');
  37. me.setBench();
  38. me.contentWindow.location.reload();
  39. me.close();
  40. }
  41. },{
  42. text: '取 消',
  43. handler: function(btn) {
  44. Ext.getCmp('win').close();
  45. }
  46. },{
  47. text: '应 用',
  48. handler: function(btn) {
  49. var me = Ext.getCmp('win');
  50. me.setBench();
  51. me.contentWindow.location.reload();
  52. me.close();
  53. }
  54. }]
  55. },{
  56. region: 'west',
  57. xtype: 'gridpanel',
  58. id: 'benchdetail',
  59. width: 400,
  60. bodyStyle: 'background:#f1f1f1;',
  61. autoScroll: true,
  62. enableLocking: true,
  63. columns: [
  64. { header: '应用', dataIndex: 'wb_isuse', flex: 0.38 , xtype: 'checkcolumn',editor: {xtype: 'checkbox',cls: 'x-grid-checkheader-editor'}},
  65. { header: '名称', dataIndex: 'wb_detail', flex: 1 },
  66. { header: '模块代号', dataIndex: 'wb_name', flex: 0, hidden: true },
  67. { header: '序号', dataIndex: 'wb_detno', flex: 0.5, xtype: 'numbercolumn', format: '0',editor: {xtype: 'combobox', editable: false, displayField: 'display',valueField: 'value', queryMode: 'local', store: Ext.create('Ext.data.Store', { fields: ['display', 'value'], data : [{"display": 1, "value": 1},{"display": 2, "value": 2}, {"display": 3, "value": 3}, {"display": 4, "value": 4}, {"display": 5, "value": 5}, {"display": 6, "value": 6}, {"display": 7, "value": 7}, {"display": 8, "value": 8}, {"display": 9, "value": 9}, {"display": 10, "value": 10}, {"display": 11, "value": 11},{"display": 12, "value": 12}]}),listeners:{blur:function(f, sel){
  68. var v = f.value;
  69. var selected = Ext.getCmp('benchdetail').selModel.lastSelected;
  70. var lastValue = selected.data.wb_lastdetno;//f.lastValue没用
  71. Ext.each(Ext.getCmp('benchdetail').store.data.items, function(item, i){
  72. if(item.data.wb_name != selected.data.wb_name && item.data.wb_detno == v){
  73. item.set('wb_detno', lastValue);
  74. }
  75. });
  76. selected.set('wb_lastdetno', v);
  77. selected.set('wb_detno', v);
  78. Ext.getCmp('benchdetail').columns[3].doSort('ASC');
  79. }}}},
  80. { header: '宽度(%)', dataIndex: 'wb_width', flex: 0.5, xtype: 'numbercolumn', editor: {xtype: 'combobox', editable: false, displayField: 'display',valueField: 'value', queryMode: 'local', store: Ext.create('Ext.data.Store', { fields: ['display', 'value'], data : [{"display": 33.33, "value": 33.33},{"display": 66.67, "value": 66.67}]})}},
  81. { header: '高度(%)', dataIndex: 'wb_height', flex: 0.5, xtype: 'numbercolumn', editor: {xtype: 'combobox', editable: false, displayField: 'display',valueField: 'value', queryMode: 'local', store: Ext.create('Ext.data.Store', { fields: ['display', 'value'], data : [{"display": 33.33, "value": 33.33},{"display": 66.67, "value": 66.67}]})}},
  82. ],
  83. plugins: Ext.create('Ext.grid.plugin.CellEditing', {
  84. clicksToEdit: 1
  85. }),
  86. listeners: {
  87. afterrender: function(){
  88. Ext.each(this.store.data.items, function(item, i){
  89. item.index == i;
  90. });
  91. }
  92. }
  93. }],
  94. setDataView: function(){
  95. this.items[2] = Ext.create('Ext.view.View', {
  96. region: 'center',
  97. bodyStyle: 'background:#f1f1f1;',
  98. deferInitialRefresh: false,
  99. enableDragDrop: true,
  100. tpl: Ext.create('Ext.XTemplate',
  101. '<tpl for=".">',
  102. '<tpl if="wb_isuse">',
  103. '<div class="phone" style="display:inline;width:{[values.wb_width > 60 ? 60 : 30]}%;height:{[values.wb_height > 60 ? 60 : 30]}%; border-bottom-style: solid;border-bottom-color: red;border-bottom: medium;">',
  104. '<Strong>{wb_detno}:{wb_detail}</Strong><span>({wb_width}%, {wb_height}%)</span>',
  105. (!Ext.isIE6? '<img src="' + basePath + 'resource/images/icon/{wb_name}.png" title="{wb_detno}:{wb_detail}({wb_width}%, {wb_height}%)" style="display:inline;" width=80;height=80;/>' :
  106. '<div style="width:74px;height:74px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + basePath + 'resource/images/icon/{wb_name}.png\',sizingMethod=\'scale\')"></div>'),
  107. '</div>',
  108. '</tpl>',
  109. '<tpl if="wb_isuse == false">',
  110. '<div class="phone" style="display:none;width:{[values.wb_width > 60 ? 60 : 30]}%;height:{[values.wb_height > 60 ? 60 : 30]}%; border-bottom-style: solid;border-bottom-color: red;border-bottom: medium;">',
  111. '<Strong>{wb_detno}:{wb_detail}</Strong><span>({wb_width}%, {wb_height}%)</span>',
  112. (!Ext.isIE6? '<img src="' + basePath + 'resource/images/icon/{wb_name}.png" title="{wb_detno}:{wb_detail}({wb_width}%, {wb_height}%)" style="display:inline;" width=80;height=80;/>' :
  113. '<div style="width:74px;height:74px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + basePath + 'resource/images/icon/{wb_name}.png\',sizingMethod=\'scale\')"></div>'),
  114. '</div>',
  115. '</tpl>',
  116. '</tpl>'
  117. ),
  118. id: 'phones',
  119. style: 'background:#f1f1f1;',
  120. itemSelector: 'div.phone',
  121. overItemCls : 'phone-hover',
  122. multiSelect : true,
  123. autoScroll : true
  124. });
  125. },
  126. setDataStore: function(){
  127. var me = this;
  128. var data = me.module;
  129. var checked = Ext.Array.pluck(me.bench.items.items, 'id');
  130. var detno = 1;
  131. Ext.each(data, function(item){
  132. item.wb_detno = detno++;
  133. item.wb_lastdetno = item.wb_detno;
  134. if(Ext.Array.contains(checked, item.wb_name)){
  135. var panel = me.bench.down('#' + item.wb_name);
  136. if(panel){
  137. item.wb_width = Ext.util.Format.number(panel.columnWidth*100, '0.00');
  138. item.wb_height = Ext.util.Format.number((panel.height)/me.contentWindow.height*100, '0.00');
  139. item.wb_isuse = true;
  140. }
  141. } else {
  142. item.wb_width = 33.33;
  143. item.wb_height = 33.33;
  144. item.wb_isuse = false;
  145. }
  146. });
  147. Ext.define('WorkBench', {
  148. extend: 'Ext.data.Model',
  149. fields: [
  150. {name: 'wb_detail', type: 'string'},
  151. {name: 'wb_detno', type: 'int'},
  152. {name: 'wb_lastdetno', type: 'int'},
  153. {name: 'wb_isuse', type: 'bool'},
  154. {name: 'wb_name', type: 'string'},
  155. {name: 'wb_width', type: 'string'},
  156. {name: 'wb_height', type: 'string'}
  157. ]
  158. });
  159. me.store = Ext.create('Ext.data.Store', {
  160. model: 'WorkBench',
  161. sortInfo: {
  162. field: 'wb_detno',
  163. direction: 'ASC'
  164. },
  165. data: data
  166. });
  167. },
  168. module: [{ wb_detail: '待办事宜', wb_name: 'bench_task'},
  169. { wb_detail: '常用模块', wb_name: 'bench_link'},
  170. { wb_detail: '通知公告', wb_name: 'bench_notify'},
  171. { wb_detail: '新闻动态', wb_name: 'bench_news'},
  172. { wb_detail: '日程安排', wb_name: 'bench_subscription'},
  173. { wb_detail: '我的考勤', wb_name: 'bench_schedule'},
  174. { wb_detail: '我的知会', wb_name: 'bench_note'},
  175. { wb_detail: '我的任务', wb_name: 'bench_mytask'},
  176. { wb_detail: '工作计划', wb_name: 'bench_plan'},
  177. { wb_detail: '我的邮箱', wb_name: 'bench_email'},
  178. { wb_detail: '知识地图', wb_name: 'bench_knowledge'},
  179. { wb_detail: '待开会议', wb_name: 'bench_meeting'},
  180. { wb_detail: '我的任务流程', wb_name: 'bench_flow'},
  181. { wb_detail: '我的超时流程', wb_name: 'bench_overflow'}
  182. ],
  183. setBench: function(){
  184. var data = new Array();
  185. Ext.each(this.store.data.items, function(item){
  186. if(item.dirty){
  187. data.push(item.data);
  188. }
  189. });
  190. Ext.Ajax.request({
  191. url : basePath + 'common/setWorkBench.action',
  192. method : 'post',
  193. params: {
  194. data: Ext.encode(data)
  195. },
  196. async: false,
  197. callback : function(options,success,response){
  198. var res = new Ext.decode(response.responseText);
  199. if(res.exceptionInfo) {
  200. showError(res.exceptionInfo);
  201. }
  202. }
  203. });
  204. }
  205. });