74.资金管理-员工工资配置 extjs 页面

1.

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10     <base href="<%=basePath%>">
11     
12     <title>基本工资信息</title>
13     
14     <script type="text/javascript">
15         var salaryBasic = new SalaryBasic();
16         var tabId = Ext.getCmp('mainTab').getActiveTab().id.split('_')[1];
17         juage(tabId,"salb",salaryBasic,"salaryBasic");
18     </script>
19     
20   </head>
21   <body>
22       <div id="salaryBasic" ></div>
23   </body>
24 </html>

2、

  1 /**
  2  * 员工工资基本信息管理
  3  * @author sux 2011-02-23
  4  * @memberOf {TypeName} 
  5  * @return {TypeName} 
  6  */
  7 var SalaryBasic = Ext.extend(Ext.grid.EditorGridPanel,{
  8     id: 'salaryBasicId',
  9     constructor: function(){
 10         Ext.form.Field.prototype.msgTarget = 'title';
 11         var number = new Ext.grid.RowNumberer();
 12         var sm = new Ext.grid.CheckboxSelectionModel();
 13         var salBasicStore = new Ext.data.JsonStore({
 14             url: 'salBasic_list.action',
 15             root: 'root',
 16              totalProperty: 'totalProperty',
 17             fields: ['sbId','employee','sbBasic','sbEndowment','sbHospitalization','sbUnemployment','sbInjury',
 18                 'sbMaternity','sbHousing','sbTraffic','sbEatery','sbTelephone']
 19         })
 20         var cm = new Ext.grid.ColumnModel([
 21             number, sm,
 22         {
 23             header: '编号',
 24             dataIndex: 'sbId',
 25             align: 'center'
 26         },{
 27             header: '员工工号',
 28             dataIndex: 'employee',
 29             align: 'center',
 30             renderer: function(value){
 31                 //判断其类型是否为object类型
 32                 if(typeof(value) == "object"){
 33                     return value.empId;
 34                 }else{
 35                     return value;
 36                 }
 37             },
 38             editor: new Ext.form.TextField({
 39                 allowBlank: false,
 40                 blankText: '不能为空',     
 41                 id: 'salaryBasicEmp',
 42                 listeners: {'blur':this.uniqueEmp}
 43             })
 44         },{
 45             header: '员工姓名',
 46             dataIndex: 'employee',
 47             align: 'center',
 48             renderer: function(value){
 49                 if(value)
 50                 return value.empName;
 51             }
 52         },{
 53             header: '基本工资',
 54             dataIndex: 'sbBasic',
 55             align: 'center',
 56             editor: new Ext.form.TextField()
 57         },{
 58             header: '养老保险',
 59             dataIndex: 'sbEndowment',
 60             align: 'center',
 61             editor: new Ext.form.ComboBox({
 62                 mode: 'local',
 63                 triggerAction: 'all',
 64                 editable: false,
 65                 store: new Ext.data.SimpleStore({
 66                     fields: ['name','value'],
 67                     data: [['是','1'],['否','0']]
 68                 }),
 69                 displayField: 'name',
 70                 valueField: 'value'
 71             }),
 72             renderer: function(value){
 73                 if(value == '1') return '是';
 74                 return '否';
 75             }
 76         },{
 77             header: '医疗保险',
 78             dataIndex: 'sbHospitalization',
 79             align: 'center',
 80             editor: new Ext.form.ComboBox({
 81                 mode: 'local',
 82                 triggerAction: 'all',
 83                 editable: false,
 84                 store: new Ext.data.SimpleStore({
 85                     fields: ['name','value'],
 86                     data: [['是','1'],['否','0']]
 87                 }),
 88                 displayField: 'name',
 89                 valueField: 'value'
 90             }),
 91             renderer: function(value){
 92                 if(value == '1') return '是';
 93                 return '否';
 94             }
 95         },{
 96             header: '失业保险',
 97             dataIndex: 'sbUnemployment',
 98             align: 'center',
 99             editor: new Ext.form.ComboBox({
100                 mode: 'local',
101                 editable: false,
102                 triggerAction: 'all',
103                 store: new Ext.data.SimpleStore({
104                     fields: ['name','value'],
105                     data: [['是','1'],['否','0']]
106                 }),
107                 displayField: 'name',
108                 valueField: 'value'
109             }),
110             renderer: function(value){
111                 if(value == '1') return '是';
112                 return '否';
113             }
114         },{
115             header: '工伤保险',
116             dataIndex: 'sbInjury',
117             align: 'center',
118             editor: new Ext.form.ComboBox({
119                 mode: 'local',
120                 triggerAction: 'all',
121                 editable: false,
122                 store: new Ext.data.SimpleStore({
123                     fields: ['name','value'],
124                     data: [['是','1'],['否','0']]
125                 }),
126                 displayField: 'name',
127                 valueField: 'value'
128             }),
129             renderer: function(value){
130                 if(value == '1') return '是';
131                 return '否';
132             }
133         },{
134             header: '生育保险',
135             dataIndex: 'sbMaternity',
136             align: 'center',
137             editor: new Ext.form.ComboBox({
138                 mode: 'local',
139                 triggerAction: 'all',
140                 editable: false,
141                 store: new Ext.data.SimpleStore({
142                     fields: ['name','value'],
143                     data: [['是','1'],['否','0']]
144                 }),
145                 displayField: 'name',
146                 valueField: 'value'
147             }),
148             renderer: function(value){
149                 if(value == '1') return '是';
150                 return '否';
151             }
152         },{
153             header: '住房公积金',
154             dataIndex: 'sbHousing',
155             align: 'center',
156             editor: new Ext.form.ComboBox({
157                 mode: 'local',
158                 editable: false,
159                 triggerAction: 'all',
160                 store: new Ext.data.SimpleStore({
161                     fields: ['name','value'],
162                     data: [['是','1'],['否','0']]
163                 }),
164                 displayField: 'name',
165                 valueField: 'value'
166             }),
167             renderer: function(value){
168                 if(value) return '是';
169                 return '否';
170             }
171         },{
172             header: '交通补贴',
173             dataIndex: 'sbTraffic',
174             align: 'center',
175             editor: new Ext.form.NumberField()
176         },{
177             header: '餐费补贴',
178             dataIndex: 'sbEatery',
179             align: 'center',
180             editor: new Ext.form.NumberField()
181         },{
182             header: '通迅补贴',
183             dataIndex: 'sbTelephone',
184             align: 'center',
185             editor: new Ext.form.NumberField()
186         }])
187         SalaryBasic.superclass.constructor.call(this, {
188              Ext.getCmp('mainTab').getActiveTab().getInnerWidth(),
189             height: Ext.getCmp('mainTab').getActiveTab().getInnerHeight(),
190             /**表格高度自适应 document.body.clientHeight浏览器页面高度 start**/
191             monitorResize: true, 
192             doLayout: function() { 
193                 this.setWidth(document.body.clientWidth-205);
194                 this.setHeight(document.body.clientHeight-140);
195                 Ext.grid.GridPanel.prototype.doLayout.call(this); 
196             } ,
197             viewConfig: {
198                 forceFit: true
199             },
200             sm: sm, 
201             cm: cm,
202             store: salBasicStore,
203             tbar: new Ext.Toolbar({
204                 items: ['条目:',{
205                     xtype: 'combo',
206                      80,
207                     triggerAction: 'all',
208                     editable: false,
209                     mode: 'local',
210                     store: new Ext.data.SimpleStore({
211                         fields: ['name','value'],
212                         data: [[" "," "],["empId","员工工号"],["empName","员工姓名"]]
213                     }),
214                     id: 'sb_condition',
215                     displayField: 'value',
216                     valueField: 'name'
217                 },'内容',{
218                     xtype: 'textfield',
219                     id: 'sb_conditionValue',
220                      80
221                 },{
222                     text: '查看',
223                     handler: salViewFn,
224                     iconCls: 'search'
225                 },{
226                     text: '删除',
227                     handler: salDelFn,
228                     id: 'salb_delete',
229                     iconCls: 'delete'
230                 },{
231                     text: '新增',
232                     id: 'salb_add',
233                     handler: salNewFn,
234                     iconCls: 'add'
235                 },{
236                     text: '修改或保存',
237                     iconCls: 'save',
238                     id: 'salb_saveorupdate',
239                     handler: salUpdateOrSaveFn
240                 }]                
241             }),
242             bbar: new PagingToolbar(salBasicStore, 20)
243         })
244         salBasicStore.load({
245             params: {
246                 start: 0,
247                 limit: 20
248             }
249         });
250     },
251 //员工工号
252     uniqueEmp: function(obj){
253         var empId = obj.getValue();
254         Ext.Ajax.request({
255             url: 'salBasic_uniqueEmp.action',
256             success: function(response, options){
257                 var obj = Ext.util.JSON.decode(response.responseText);
258                 if(obj.msg == false){
259                     Ext.Msg.alert("提示","此员工的工资已配置");
260                 }
261             },
262             failure: hrmsys.util.common.failure,
263             params: {
264                 empId: empId
265             }
266         })
267     }
268 });
269 //查看
270 salViewFn = function(){
271     var condition = Ext.getCmp("sb_condition").getValue();
272     var conditionValue = Ext.getCmp("sb_conditionValue").getValue();
273     Ext.getCmp('salaryBasicId').getStore().load({
274         params: {
275             type: 'query',
276             condition: condition,
277             conditionValue: conditionValue,
278             start: 0,
279             limit: 20
280         }
281     });
282 };
283 //删除
284 salDelFn = function(){
285     gridDel('salaryBasicId','sbId', 'salBasic_delete.action');
286 };
287 //新增
288 salNewFn = function(){
289     var DefaultRecord = new Ext.data.Record.create([{name: 'sbId', mapping: 0},{name: 'employee', mapping: 1},
290         {name: 'empName', mapping:2},{name: 'sbBasic', mapping: 3},{name: 'sbEndowment', mapping: 4},
291         {name: 'sbHospitalization', mapping: 5},{name: 'sbUnemployment', mapping: 6},{name: 'sbInjury', mapping: 7},
292         {name: 'sbMaternity', mapping: 8},{name: 'sbHousing', mapping:9},{name: 'sbTraffic', mapping: 10},
293         {name: 'sbEatery', mapping: 11},{name: 'sbTelephone', mapping: 12}]);
294     var num = Ext.getCmp('salaryBasicId').getStore().getCount();
295     var newRecord = new DefaultRecord({
296         sbId: num+1
297     });
298     Ext.getCmp('salaryBasicId').getStore().insert(0,newRecord);    
299 };
300 
301 //保存或者修改
302 salUpdateOrSaveFn = function(){
303     var modifiedRecords = Ext.getCmp('salaryBasicId').getStore().getModifiedRecords();
304     var salBasics = reSalBasicJson(modifiedRecords);
305     //alert(salBasics);
306     Ext.Ajax.request({
307         url: 'salBasic_save.action',
308         method: 'post',
309         waitTitle: '提示',
310         waitMsg: '正在保存数据...',
311         params: {
312             json: salBasics
313         },
314         success: salBasicSuccessFn,
315         failure: boonModifyfailureFn
316     })
317 };
318 //保存成功保存
319 salBasicSuccessFn = function(response, options){
320     var datas = Ext.util.JSON.decode(response.responseText);
321     Ext.Msg.alert('提示',datas.msg,function(){
322         Ext.getCmp('salaryBasicId').getStore().load({
323             params: {
324                 start: 0,
325                 limit: 20
326             }
327         });
328     });
329 };
330 //json
331 reSalBasicJson = function(modifiedRecords){
332     var count = modifiedRecords.length;
333     var salBasics='';
334     //有修改或保存
335     if(count > 0){
336         salBasics = "[";
337         for(i=0; i<count; i++){
338             salBasics += "{";
339             var sbId = modifiedRecords[i].get('sbId');
340             var employee = modifiedRecords[i].get('employee');
341             if(typeof(employee) == "object"){
342                 var empId = employee.empId;
343             }else{
344                 var empId = employee;
345             }
346             //var empName = modifiedRecords[i].get('empName');
347             var sbBasic = modifiedRecords[i].get('sbBasic');
348             var sbEndowment = modifiedRecords[i].get('sbEndowment');
349             var sbHospitalization = modifiedRecords[i].get('sbHospitalization');
350             var sbUnemployment = modifiedRecords[i].get('sbUnemployment');
351             var sbInjury = modifiedRecords[i].get('sbInjury');
352             var sbEatery = modifiedRecords[i].get('sbEatery');
353             var sbMaternity = modifiedRecords[i].get('sbMaternity');
354             var sbHousing = modifiedRecords[i].get('sbHousing');
355             var sbTraffic = modifiedRecords[i].get('sbTraffic');
356             var sbTelephone = modifiedRecords[i].get('sbTelephone');
357             salBasics += '"sbId":'+sbId+', "empId":"'+empId+'","sbBasic":'+sbBasic+
358             ',"sbEndowment":'+sbEndowment+', "sbHospitalization":'+sbHospitalization+', "sbUnemployment":'+sbUnemployment+
359             ', "sbInjury":'+sbInjury+', "sbEatery":'+sbEatery+', "sbMaternity":'+sbMaternity+', "sbHousing":'+sbHousing+
360             ', "sbTraffic":'+sbTraffic+', "sbTelephone":'+sbTelephone+'}';
361             if( i != count-1)
362                 salBasics += ","
363         }
364         salBasics += "]"
365     }
366     return salBasics;
367 }
原文地址:https://www.cnblogs.com/sharpest/p/7658513.html