winUpLoad.js 2.6 KB

Ext.define('App.view.winUpLoad', {
    extend: 'Ext.window.Window',
    alias: 'widget.winupload',
    width: 450,
    height: 185,
    title: 'Загрузка  на сервер',

    modal : true,
    closeAction: 'hide',
    listeners:{
        'beforehide':function(win){
         //   Ext.getCmp(win.animateTarget).hide();
        }
    },






    items: [
    Ext.create('Ext.form.Panel', {
        width: 440,
        bodyPadding: 20,
        frame: true,
        renderTo: Ext.getBody(),    
        items: [
                 {
                    xtype: 'fieldcontainer',
                    layout: 'hbox',
                    fieldDefaults: {
                        labelAlign: 'top'
                    },

                items: [
                        {
                            flex: 4,
                            name: 'wintitle',
                            itemId: 'wintitle',
                            id: 'wintitle',
                            margins: '0 0 0 0',
                            html: ""
                        },
                        {
                            flex: 1,
                            xtype: 'hidden',
                            name: 'winid',
                            itemId: 'winid',
                            id:'winid',
                            html: "",
                            "visible": false,
                        },
                ]
            },

           {
            xtype: 'filefield',
            name: 'file',
            fieldLabel: 'XML',
            labelWidth: 30,
            msgTarget: 'side',
            allowBlank: false,
            anchor: '100%',
            buttonText: 'Выберите файл...'
        }],

        buttons: [{
            text: 'Загрузить',
            bodyPadding: 10,
            handler: function () {

              

                var form = this.up('form').getForm();
                if(form.isValid()){
                    form.submit({
                        url: 'http://94.127.138.40/importer/upload.php',
                        method: 'POST',
                        params: { region: Ext.getCmp("winid").html },
                        enctype: 'multipart/form-data',
                        waitMsg: 'Загрузка файла...',
                        success: function (formPanel, action) {
                         //   alert("Ok!");
                        },
                        failure: function (formPanel, action) {
                        //    alert("Error!");
                        }
                    });
                }
            }
        }]
    })
    ]
});