• 69.资金管理-税率表管理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 revenue = new Revenue();
    16         var tabId = Ext.getCmp('mainTab').getActiveTab().id.split('_')[1];
    17         juage(tabId,"reve",revenue, "revenue");
    18     </script>
    19     
    20   </head>
    21   <body>
    22       <div id="revenue" ></div>
    23   </body>
    24 </html>

    2.税率表js

      1 /**
      2  * 税率信息
      3  * 
      4  * @author sux 2011-02-22
      5  * @memberOf {TypeName}
      6  */
      7 var Revenue = Ext.extend(Ext.grid.EditorGridPanel, {
      8     id : 'revenueId',
      9     constructor : function() {
     10         // 实现统一的提示方式
     11         Ext.form.Field.prototype.msgTarget = 'title';
     12         var number = new Ext.grid.RowNumberer();
     13         var sm = new Ext.grid.CheckboxSelectionModel();
     14         var revenueStore = new Ext.data.JsonStore({
     15             url : 'revenue_edit.action',
     16             root : 'root',
     17             totalProperty : 'totalProperty',
     18             fields : [ 'reId', 'reMin', 'reMax', 'rePercent', 'reMinus' ]
     19         });
     20         var cm = new Ext.grid.ColumnModel([ number, sm, {
     21             header : '编号',
     22             dataIndex : 'reId',
     23             align : 'center'
     24         }, {
     25             header : '最小值',
     26             dataIndex : 'reMin',
     27             align : 'center',
     28             //设置在编辑状态下,指定编辑器
     29             //Ext_数字输入框_Ext.form.NumberField
     30             editor : new Ext.form.NumberField({
     31                 allowBlank : false,
     32                 blankText : '不能为空'
     33             })
     34         }, {
     35             header : '最大值',
     36             dataIndex : 'reMax',
     37             align : 'center',
     38             editor : new Ext.form.NumberField({
     39                 allowBlank : false,
     40                 blankText : '不能为空'
     41             })
     42         }, {
     43             header : '税率',
     44             dataIndex : 'rePercent',
     45             align : 'center',
     46             editor : new Ext.form.NumberField({
     47                 allowBlank : false,
     48                 blankText : '不能为空'
     49             })
     50         }, {
     51             header : '速算减值',
     52             dataIndex : 'reMinus',
     53             align : 'center',
     54             editor : new Ext.form.NumberField({
     55                 allowBlank : false,
     56                 blankText : '不能为空'
     57             })
     58         } ]);
     59         
     60         Revenue.superclass.constructor.call(this, {
     61              Ext.getCmp('mainTab').getActiveTab().getInnerWidth(),
     62             height: Ext.getCmp('mainTab').getActiveTab().getInnerHeight(),
     63             /**表格高度自适应 document.body.clientHeight浏览器页面高度 start**/
     64             monitorResize: true, 
     65             doLayout: function() { 
     66                 this.setWidth(document.body.clientWidth-205);
     67                 this.setHeight(document.body.clientHeight-140);
     68                 Ext.grid.GridPanel.prototype.doLayout.call(this); 
     69             } ,
     70             viewConfig: {
     71                 forceFit: true
     72             },
     73             sm: sm,
     74             cm: cm,
     75             store: revenueStore,
     76             tbar: new Ext.Toolbar({
     77                 items: [{
     78                     text: '删除',
     79                     iconCls: 'delete',
     80                     id: 'reve_delete',
     81                     handler: delRevenueFn
     82                 },{
     83                     text: '新增',
     84                     iconCls: 'add',
     85                     id: 'reve_add',
     86                     handler: newRevenueFn
     87                 },{
     88                     text: '保存或修改',
     89                     iconCls: 'save',
     90                     id: 'reve_saveorupdate',
     91                     handler: modifyRevenueFn
     92                 }]
     93             }),
     94             bbar: new PagingToolbar(revenueStore, 20)
     95         });
     96         revenueStore.load({
     97             params: {
     98                 start: 0,
     99                 limit: 20
    100             }
    101         });
    102     }
    103 });
    104 //删除
    105 delRevenueFn = function(){
    106     gridDel('revenueId', 'reId','revenue_delete.action');
    107 };
    108 //新增
    109 newRevenueFn = function(){
    110     
    111     var DefaultRecord = new Ext.data.Record.create([{name: 'reId', mapping: 0},{name: 'reMin', mapping: 1},
    112                                                     {name: 'reMax', mapping: 2},{name: 'rePercent', mapping: 3},{name: 'reMinus', mapping: 4}]);
    113     //Store.getCount()返回的是store中的所有数据记录,然后使用for循环遍历整个store,从而得到每条记录。
    114     var num = Ext.getCmp('revenueId').getStore().getCount();
    115     var newRecord = new DefaultRecord({
    116         reId: num+1,
    117         reMin: '',
    118         reMax: '',
    119         rePercent: '',
    120         reMinus: ''
    121     });
    122     Ext.getCmp('revenueId').getStore().insert(0,newRecord);    
    123 };
    124 //保存或修改
    125 modifyRevenueFn=function(){
    126     //获取以后都是第一次修改的值
    127     var modifiedRecords = Ext.getCmp('revenueId').getStore().getModifiedRecords();
    128     
    129     var revenues = reRevenueJson(modifiedRecords);
    130     Ext.Ajax.request({
    131         url: 'revenue_modify.action',
    132         waitTitle: '提示',
    133         waitMsg: '正在保存数据...',
    134         method: 'post',
    135         params: {
    136             json: revenues
    137         },
    138         success: reModifySuccessFn,
    139         failure: reModifyfailureFn
    140     })
    141 };
    142 //保存成功后处理
    143 reModifySuccessFn = function(response, options){
    144     var datas = Ext.util.JSON.decode(response.responseText);
    145     Ext.Msg.alert('提示',datas.msg,function(){
    146         Ext.getCmp('revenueId').getStore().load({
    147             params: {
    148                 start: 0,
    149                 limit: 20
    150             }
    151         });
    152     });
    153 };
    154 //删除成功后处理
    155 reModifyfailureFn = function(response, options){
    156     Ext.Msg.alert('提示','连接失败',function(){})
    157 };
    158 //转化json
    159 reRevenueJson = function(modifiedRecords){
    160     var count = modifiedRecords.length;
    161     var revenues='';
    162     //有修改
    163     if(count > 0){
    164         revenues = "[";
    165         for(i=0; i<count; i++){
    166             revenues += "{";
    167             var reId = modifiedRecords[i].get('reId');
    168             var reMin = modifiedRecords[i].get('reMin');
    169             var reMax = modifiedRecords[i].get('reMax');
    170             var rePercent = modifiedRecords[i].get('rePercent');
    171             var reMinus = modifiedRecords[i].get('reMinus');
    172             revenues += '"reId":'+reId+', "reMin":'+reMin+',"reMax":'+reMax+',"rePercent":'+rePercent+',"reMinus":'+reMinus+'}';
    173             if( i != count-1)
    174                 revenues += ","
    175         }
    176         revenues += "]"
    177     }
    178     return revenues;
    179 }
  • 相关阅读:
    Aizu 0525 Osenbei 搜索 A
    PAT 1088 三人行 模拟,坑 C
    POJ1862 Stripies 贪心 B
    ZOJ 4109 Welcome Party 并查集+优先队列+bfs
    POJ 3685 Matrix
    POJ 3579 Median 二分加判断
    Educational Codeforces Round 63 D. Beautiful Array
    Codeforces Round #553 (Div. 2) C
    HDU 5289
    Codeforces 552 E. Two Teams
  • 原文地址:https://www.cnblogs.com/sharpest/p/7657108.html
Copyright © 2020-2023  润新知