PageRenderTime 58ms CodeModel.GetById 13ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/source/gl/mb/right/right_assign.html

http://prosporous.googlecode.com/
HTML | 246 lines | 241 code | 5 blank | 0 comment | 0 complexity | c19507751acf5bcab4338ae8a2988f3e MD5 | raw file
  1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2<html>
  3    <head>
  4        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5        <title>????</title>
  6        <{$showjs}>
  7        <link rel="stylesheet" type="text/css" href="../css/main.css" />
  8        <style>
  9            .userlist{background-image:url(../img/shield.png)!important;}
 10            .useradd{background-image:url(../img/shield_add.png)!important;}
 11            .userkey{background-image:url(../img/group_key.png)!important;}
 12            .usercfg{background-image:url(../img/group_gear.png)!important;}
 13            .zdpz{background-image:url(../img/list_settings.gif)!important;}
 14            body { background-color: #D1DDEF; }
 15        </style>
 16        <script language="javascript">
 17            var isGroupChange = false,
 18                isComeFromUser = false;
 19            //????
 20            var ds = new Ext.data.Store({
 21                autoLoad:true,
 22                //url:'../right/get_users.php',
 23                proxy:new Ext.data.HttpProxy({
 24                    url:'../right/get_users.php'
 25                }),
 26                reader: new Ext.data.JsonReader({
 27                        totalProperty: "total",
 28                        root:'result'
 29                    },[
 30                        {name:'id',type:'int'},
 31                        {name:'user'}
 32                    ]
 33                )
 34            });
 35            var colModel = new Ext.grid.ColumnModel([
 36                {id:'id',header:'UID',dataIndex:'id',sortable:true,width:'15px'},
 37                {header:'???',dataIndex:'user',sortable:true}
 38            ]);
 39            //?????
 40            var ds_group = new Ext.data.Store({
 41                autoLoad:true,
 42                //url:'../right/get_users.php',
 43                proxy:new Ext.data.HttpProxy({
 44                    url:'../right/get_users.php?t=group'
 45                }),
 46                reader: new Ext.data.JsonReader({
 47                        totalProperty: "total",
 48                        root:'result'
 49                    },[
 50                        {name:'id',type:'int'},
 51                        {name:'title'},
 52                        {name:'intro'}
 53                    ]
 54                ),
 55                listeners:{
 56                    load:function(){
 57                        Ext.getCmp('all-user-grid').getSelectionModel().selectFirstRow();
 58                    }
 59                }
 60                   
 61            });
 62            var colModel_group = new Ext.grid.ColumnModel([
 63                new Ext.grid.CheckboxSelectionModel({singleSelect:true}),
 64                {id:'id',header:'GID',dataIndex:'id',sortable:true},
 65                {header:'??',dataIndex:'title',sortable:true},
 66                {header:'??',dataIndex:'intro'}
 67            ]);
 68            //???????
 69            var resetGroup = function(){
 70                //?????????
 71                var usm = Ext.getCmp('all-user-grid').getSelectionModel();
 72                var select_total = usm.getCount();
 73                if (select_total<1){
 74                    usm.clearSelections();
 75                    return;
 76                }
 77                var uid = usm.getSelected().get('id');
 78                Ext.Ajax.request({
 79                    url:'../right/get_users.php?t=user',
 80                    method:'POST',
 81                    success:function(r){
 82                        var cfg = r.responseText.split(',');
 83                        isComeFromUser = true;  //??????
 84                        var cfg_range = Ext.getCmp('all-group-grid').getStore().queryBy(function(r){
 85                            //?????????
 86                            return cfg.indexOf(r.get('id')+'') !== -1;
 87                        },this).getRange();
 88                        //????????
 89                        Ext.getCmp('all-group-grid').getSelectionModel().selectRecords(cfg_range);
 90                        isComeFromUser = false;  //??????
 91                        isGroupChange = false;
 92                    },
 93                    failure:function(){
 94                        Ext.Msg.alert('??','?????????????"??"??');
 95                    },
 96                    params:{uid:uid}
 97                });
 98            };
 99            //???????
100            var saveGroup = function(){
101                var usm = Ext.getCmp('all-user-grid').getSelectionModel();
102                var gsm = Ext.getCmp('all-group-grid').getSelectionModel();
103                var uid = usm.getSelected().get('id');
104                var gid = gsm.getSelections();
105                var gids = new Array();
106                Ext.each(gid,function(a){
107                    gids.push(a.get('id'));
108                });
109                //???????
110                var rcft = gids.join(',');
111                Ext.Ajax.request({
112                    url:'../right/get_users.php?t=save',
113                    method:'POST',
114                    success:function(r){
115                        if(r.responseText == 'ok'){
116                            Ext.Msg.alert('??','?????????');
117                            isGroupChange = false;
118                        }
119                    },
120                    failure:function(){
121                        Ext.Msg.alert('??','??????????"??"??');
122                    },
123                    params:{
124                        uid:uid,
125                        gids:rcft
126                    }
127                });
128            };
129            
130            
131            //??
132            Ext.onReady(function(){
133                var bd = Ext.getBody();
134                
135                var group = new Ext.Panel({
136                    id:'group',
137                    fram:true,
138                    labelAlign:'left',
139                    layout:'column',
140                    autoWidth:true,
141                    height:350,
142                    items:[{
143                        title:'????',
144                        columnWidth:0.20,
145                        layout:'fit',
146                        items:[{
147                            id:'all-user-grid',
148                            xtype:'grid',
149                            autoScroll:true,
150                            //autoHeight:true,
151                            height:340,
152                            ds:ds,
153                            cm:colModel,
154                            sm: new Ext.grid.RowSelectionModel({
155                                singleSelect:true,
156                                listeners:{
157                                    rowselect: function(sm, row, rec) {
158                                        resetGroup();
159                                    },
160                                    beforerowselect: function(){
161                                        
162                                        if (isGroupChange){
163                                             if(confirm('?????????????????')){
164                                                 isGroupChange = false;
165                                                    return true;
166                                             }
167                                            return false;
168                                        }
169                                    }
170                                }
171                            })
172                        }]
173                    },{
174                        title:'?????',
175                        columnWidth:0.8,
176                        style:'margin-left:0px',
177                        tools:[{
178                            id:'save',
179                            on:{
180                                click:saveGroup
181                            }
182                        }],
183                        items:[{
184                            id:'all-group-grid',
185                            xtype:'grid',
186                            //autoHeight:true,
187                            autoScroll:true,
188                            height:400,
189                            autoExpandMax :true,
190                            ds:ds_group,
191                            cm:colModel_group,
192                            sm:new Ext.grid.CheckboxSelectionModel({
193                                singleSelect:true,
194                                handleMouseDown: Ext.emptyFn,
195                                listeners:{
196                                    selectionchange:function(){
197                                        if (!isComeFromUser){
198                                            isGroupChange = true;
199                                            isComeFromUser = false;
200                                        }
201                                    },
202                                    beforerowselect:function(){
203                                        var n = Ext.getCmp('all-user-grid').getSelectionModel().getCount();
204                                        if(n<1){
205                                            Ext.Msg.alert('??','????????????????!');
206                                            return false;
207                                        }
208                                    }
209                                }
210                            }),
211                            listeners:{
212                                rowdblclick:function(obj,rowIndex){
213                                    var csm = obj.getSelectionModel();
214                                    csm.selectRow(rowIndex,true);
215                                }
216                            },
217                            tbar:[
218                                //new Ext.Toolbar.TextItem('??????'),
219                                {
220                                    pressed:false,
221                                    text:'??',
222                                    listeners:{
223                                        click:function(){
224                                            resetGroup();
225                                        }
226                                    }
227                                },
228                                {
229                                    pressed:false,
230                                    text:'??',
231                                    listeners:{
232                                        click:saveGroup
233                                    }
234                                }
235                            ]
236                            //sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
237                        }]
238                    }],
239                    renderTo:Ext.getBody()
240                });
241            });
242        </script>
243    </head>
244    <body>
245    </body>
246</html>