winListGSM.js 9.75 KB













Ext.define('App.view.winListGSM', {
    extend: 'Ext.window.Window',
    alias: 'widget.winlistgsm',
    requires: [
             'Ext.grid.*',
             'Ext.data.*',
             'Ext.panel.*',
             'Ext.layout.container.Border',
              'Ext.form.*'
        ],
    width: 710,
    height: 500,
    title: 'Списки на оповещение',
    modal: true,
    closeAction: 'hide',
    listeners: {
        'beforehide': function (win) {
            //   Ext.getCmp(win.animateTarget).hide();
        }
    },
    items: [
                          Ext.create('Ext.Panel', {
                              frame: true,
                              width: 700,
                      
                            //  layout: 'hbox' ,
                              items: [
                                  
                                  Ext.create('Ext.grid.Panel', {
                                  store: Ext.create('App.store.PersonGSMStore'),
                                  id: 'grdPersonGSM',
                                  name: 'grdPersonGSM',

                                  listeners: {
                                      itemclick: {
                                          fn: function (grid, record) {
                                             
                                              Ext.getCmp('grdStationGSM').getStore().removeAll();
                                              Ext.getCmp('grdContactGSM').getStore().removeAll();
                                              
                                              for (var i = 0; i < objAjax.data.length; i++) {

                                                  if (objAjax.data[i].id == record.get('id')) {

                                                        
                                                   
                                                   
                                                     

                                                      for (var j = 0; j < objAjax.data[i].devices.length; j++) {

                                                          Ext.getCmp('grdStationGSM').getStore().insert(
                                                               0,
                                                               new App.model.StationGSM({
                                                                   title: objAjax.data[i].devices[j].title,
                                                               })
                                                               );

                                                      }

                                                      for (var j = 0; j < objAjax.data[i].contacts.length; j++) {


                                                          var type_id = objAjax.data[i].contacts[j].type;

                                                          var strtype = "";

                                                        //  1 - городской телефон
                                                        //  2 - мобильник
                                                        //  3 - емыл



                                                          if (type_id == 1) {
                                                              strtype = "Городской телефон";
                                                          }
                                                          else if (type_id == 2) {
                                                              strtype = "Мобильник";
                                                          }
                                                          else {
                                                              strtype = "e-mail";
                                                          }

                                                          Ext.getCmp('grdContactGSM').getStore().insert(
                                                               0,
                                                               new App.model.ContactGSM({
                                                                   contact: objAjax.data[i].contacts[j].contact,
                                                                   type: strtype
                                                               })
                                                               );

                                                      }

                                                      grdContactGSM




                                                  }
                                               
                                              }


                                          }
                                      }
                                  },

                                      columns: [
                                          { text: "Должность", flex:3, dataIndex: 'job', sortable: true },
                                          { text: "Ф.И.О", flex: 2, dataIndex: 'name', sortable: true },
                                           { text: "Организация", flex: 2, dataIndex: 'organization', sortable: true },
                                      ],


                                      forceFit: true,
                                      height: 260,
                                      split: true,
                                      region: 'north'

                                  }),

                                   {
                                       id: 'detailPanel',
                                       region: 'center',
                                      // collapsible: true,
                                       //split: true,
                                       flex: 1,
                                      // layout: 'border',
                                       
                                       items: [                     Ext.create('Ext.grid.Panel', {
                                                                         store: Ext.create('App.store.StationGSMStore'),
                                                                         id: 'grdStationGSM',
                                                                         name: 'grdStationGSM',
                                                                         height:100,
                                                                         columns: [
                                                                             { text: "Станции", flex: 1, dataIndex: 'title', sortable: true }
                                                                         ],
                                                                         forceFit: true,
                                                                         split: true,
                                                                     }),
                              
                                                                     Ext.create('Ext.grid.Panel', {
                                                                         store: Ext.create('App.store.ContactGSMStore'),
                                                                         id: 'grdContactGSM',
                                                                         name: 'grdContactGSM',
                                                                         height: 100,
                                                                          columns: [
                                                                             { text: "Контакты", flex: 1, dataIndex: 'type', sortable: true },
                                                                             { text: "", flex: 1, dataIndex: 'contact', sortable: true }
                                                                          ],
                                                                          forceFit: true,
                                                                          split: true
                                                                   
                                                                         
                                                                     })
                                                    ]
                                              
                                            
                                         
                                   }]
                          })
                     ]
});




/*


Ext.onReady(function () {
    Ext.define('Book', {
        extend: 'Ext.data.Model',
        proxy: {
            type: 'ajax',
            reader: 'xml'
        },
        fields: [
   
            { name: 'Author', mapping: '@author.name' },
            'Title',
            'Manufacturer',
            'ProductGroup',
            'DetailPageURL'
        ]
    });

    var store = Ext.create('Ext.data.Store', {
        model: 'Book',
        proxy: {
      
            type: 'ajax',
            url: 'sheldon.xml',

            reader: {
                type: 'xml',
                record: 'Item',
                totalProperty: 'total'
            }
        }
    });



   
    var bookTplMarkup = [
        'Title: <a href="{DetailPageURL}" target="_blank">{Title}</a><br/>',
        'Author: {Author}<br/>',
        'Manufacturer: {Manufacturer}<br/>',
        'Product Group: {ProductGroup}<br/>'
    ];
    var bookTpl = Ext.create('Ext.Template', bookTplMarkup);

   
    grid.getSelectionModel().on('selectionchange', function (sm, selectedRecord) {
        if (selectedRecord.length) {
            var detailPanel = Ext.getCmp('detailPanel');
            detailPanel.update(bookTpl.apply(selectedRecord[0].data));
        }
    });

    store.load();


    */