• 70.资金管理-福利表管理 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     <script type="text/javascript">
    14         var boon = new Boon();
    15         var tabId = Ext.getCmp('mainTab').getActiveTab().id.split('_')[1];
    16         juage(tabId,"boon",boon,"boon");
    17     </script>
    18     
    19   </head>
    20   <body>
    21       <div id="boon" ></div>
    22   </body>
    23 </html>

    2、

      1 /**
      2  * 福利信息
      3  * @author sux 2011-02-23
      4  * @memberOf {TypeName} 
      5  */
      6 var Boon = Ext.extend(Ext.grid.EditorGridPanel,{
      7     id: 'boonId',
      8     constructor: function(){
      9         Ext.form.Field.prototype.msgTarget = 'title';
     10         var number = new Ext.grid.RowNumberer();
     11         var sm = new Ext.grid.CheckboxSelectionModel();
     12         var boonStore = new Ext.data.JsonStore({
     13             url: 'boon_edit.action',
     14             root: 'root',
     15              totalProperty: 'totalProperty',
     16             fields: ['boonId','boonName','boonMoney','boonPercent','boonRmark']
     17         });
     18         var cm = new Ext.grid.ColumnModel([
     19             number, sm,
     20         {
     21             header: '编号',
     22             dataIndex: 'boonId',
     23             align: 'center'
     24         },{
     25             header: '名称',
     26             dataIndex: 'boonName',
     27             align: 'center',
     28             editor: new Ext.form.TextField({
     29                 allowBlank: false,
     30                 blankText: '不能为空'
     31             })
     32         },{
     33             header: '总额',
     34             dataIndex: 'boonMoney',
     35             align: 'center',
     36             editor: new Ext.form.NumberField({
     37                 allowBlank: false,
     38                 blankText: '不能为空'
     39             })
     40         },{
     41             header: '百分比',
     42             dataIndex: 'boonPercent',
     43             align: 'center',
     44             editor: new Ext.form.NumberField({
     45                 allowBlank: false,
     46                 blankText: '不能为空'
     47             })
     48         },{
     49             header: '备注',
     50             dataIndex: 'boonRemark',
     51             align: 'center',
     52             editor: new Ext.form.TextArea()
     53         }]);
     54         Boon.superclass.constructor.call(this, {
     55              Ext.getCmp('mainTab').getActiveTab().getInnerWidth(),
     56             height: Ext.getCmp('mainTab').getActiveTab().getInnerHeight(),
     57             /**表格高度自适应 document.body.clientHeight浏览器页面高度 start**/
     58             monitorResize: true, 
     59             doLayout: function() { 
     60                 this.setWidth(document.body.clientWidth-205);
     61                 this.setHeight(document.body.clientHeight-140);
     62                 Ext.grid.GridPanel.prototype.doLayout.call(this); 
     63             } ,
     64             viewConfig: {
     65                 forceFit: true
     66             },
     67             sm: sm,
     68             cm: cm,
     69             store: boonStore,
     70             tbar: new Ext.Toolbar({
     71                 items: [{
     72                     text: '删除',
     73                     iconCls: 'delete',
     74                     id: 'boon_delete',
     75                     hidden: 'true',
     76                     handler: delBoonFn
     77                 },{
     78                     text: '新增',
     79                     id: 'boon_add',
     80                     hidden: 'true',
     81                     iconCls: 'add',
     82                     handler: newBoonFn
     83                 },{
     84                     text: '保存或修改',
     85                     iconCls: 'save',
     86                     id: 'boon_saveorupdate',
     87                     hidden: 'true',
     88                     handler: modifyBoonFn
     89                 }]
     90             }),
     91             bbar: new PagingToolbar(boonStore, 20)
     92         });
     93         boonStore.load({
     94             params: {
     95                 start: 0,
     96                 limit: 20
     97             }
     98         });
     99     }
    100 });
    101 //删除
    102 delBoonFn = function(){
    103     gridDel('boonId', 'boonId','boon_delete.action');
    104     
    105 };
    106 //新增
    107 newBoonFn = function(){
    108     var DefaultRecord = new Ext.data.Record.create([{name: 'boonId', mapping: 0},{name: 'boonName', mapping: 1},
    109         {name: 'boonMoney', mapping: 2},{name: 'boonPercent', mapping: 3},{name: 'boonRemark', mapping: 4}]);
    110     var num = Ext.getCmp('boonId').getStore().getCount();
    111     var newRecord = new DefaultRecord({
    112         boonId: num+1,
    113         boonName: '',
    114         boonMoney: '',
    115         boonPercent: '',
    116         boonRemark: ''
    117     });
    118     Ext.getCmp('boonId').getStore().insert(0,newRecord);    
    119 };
    120 //保存或修
    121 modifyBoonFn = function(){
    122     var modifiedRecords = Ext.getCmp('boonId').getStore().getModifiedRecords();
    123     var boons = reJson(modifiedRecords);
    124     Ext.Ajax.request({
    125         url: 'boon_modify.action',
    126         waitTitle: '提示',
    127         waitMsg: '正在保存数据...',
    128         method: 'post',
    129         params: {
    130             json: boons
    131         },
    132         success: boonModifySuccessFn,
    133         failure: boonModifyfailureFn
    134     })
    135 };
    136 boonModifySuccessFn = function(response, options){
    137     var datas = Ext.util.JSON.decode(response.responseText);
    138     Ext.Msg.alert('提示',datas.msg,function(){
    139         Ext.getCmp('boonId').getStore().load({
    140             params: {
    141                 start: 0,
    142                 limit: 20
    143             }
    144         });
    145     });
    146 };
    147 //保存失败
    148 boonModifyfailureFn = function(response, options){
    149     Ext.Msg.alert('提示','连接失败',function(){})
    150 };
    151 //转成json
    152 reJson = function(modifiedRecords){
    153     var count = modifiedRecords.length;
    154     var boons='';
    155     //有修改或保存
    156     if(count > 0){
    157         boons = "[";
    158         for(i=0; i<count; i++){
    159             boons += "{";
    160             var boonId = modifiedRecords[i].get('boonId');
    161             var boonName = modifiedRecords[i].get('boonName');
    162             var boonMoney = modifiedRecords[i].get('boonMoney');
    163             var boonPercent = modifiedRecords[i].get('boonPercent');
    164             var boonRemark = modifiedRecords[i].get('boonRemark');
    165             boons += '"boonId":'+boonId+', "boonName":"'+boonName+'","boonMoney":'+boonMoney+',"boonPercent":'+boonPercent+',"boonRemark":"'+boonRemark+'"}';
    166             if( i != count-1)
    167                 boons += ","
    168         }
    169         boons += "]"
    170     }
    171     return boons;
    172 }
  • 相关阅读:
    获取显卡的cuda算力
    ubuntu安装gitlab
    TensorFlow的Bazel构建文件结构
    如何在制作jar包时引用第三方jar包
    利用Shell脚本将MySQL表中的数据转化为json格式
    恢复MySQL主从数据一致性的总结
    (转)运维角度浅谈MySQL数据库优化
    JDBC常用API小结
    MySQL存储过程及触发器
    坑爹的Maven
  • 原文地址:https://www.cnblogs.com/sharpest/p/7657288.html
Copyright © 2020-2023  润新知