解决方案 »

  1.   

    Ext.create("Ext.grid.Panel", {
    xtype: "grid",
    title: "根目录",
    columnWidth: 1,
    store: store,
    height: "500",
    region: "center",
    id: "selectgrid",
    emptyText: '该目录为空!请点击<img src="../images/desktopUI/folder-back.png">上一级!',
    selModel: selModel,
    disableSelection: false,
    columns: [
    {text: "",      width: 30,dataIndex: "leaf"},
         {text: "文件名", width: 150,flex: 1,dataIndex: "name",sortable: true},
         {text: "类型",   width: 80,dataIndex: "extname",sortable: false},
         {text: "大小",   width: 100,dataIndex: "filesize",align: "right",sortable: true},
         {text: "创建时间",width: 150,dataIndex: "createtime",renderer: function(A) {return A.replace("T", " ")},sortable: true}
    ],
    listeners: {
            itemdblclick: function(D, A, C, E, B) {
                if (A.raw.filesize == "") {
                    store.load({
                        params: {subId: A.raw.filedir},
    callback: function(records,options,success){
    if(success==true){//加载成功
    var I = store.getCount();
    if(I>0){
    fdir= store.getAt(0).get('filedir')
    }else{
    fdir = A.raw.filedir + "@thisnewfolder";
    }
    }
    },
    scope: store,
    add: false
                    })
                }
            },
            itemcontextmenu: function(G, B, E, F, C, D) {
                C.preventDefault();
                C.stopEvent();
                var A = new Ext.menu.Menu({
                    items: [{
                        text: "新建目录",
                        iconCls: "folder_new",
                        handler: function() {
                            this.up("menu").hide();
                            fpnewdir()
                        }
                    },
                    {
                        text: "打开",
                        iconCls: "folder_open",
                        handler: function() {
                            this.up("menu").hide();
                            if (B.raw.filesize == "") {
                                store.load({
                                    params: {subId: B.raw.filedir}
                                })
                            } else {
                                var H = Ext.create("widget.uxNotification", {
                                    title: "信息窗口",
                                    corner: "br",
                                    stickOnClick: false,
                                    manager: "desktop",
                                    iconCls: "ux-notification-icon-information",
                                    html: ""
                                });
                                H.show()
                            }
                        }
                    },
                    {
                        text: "下载",
                        iconCls: "folder_download",
                        handler: function() {
                            this.up("menu").hide();
                            fpdownload()
                        }
                    },
                    {
                        text: "重命名",
                        iconCls: "folder_rename",
                        handler: function() {
                            this.up("menu").hide();
                            Ext.MessageBox.prompt("重命名", "请输入",
                            function(H, I) {
                                if (H == "ok") {
                                    if (I.length < 1) {
    Ext.example.msg('重命名:', '文件(夹)名称不能为空!');
                                        return
                                    }
                                    if (I != stripscript(I)) {
    Ext.example.msg('重命名:', '文件(夹)名称含非法字符!');
                                        return
                                    }
                                    Ext.Ajax.request({
                                        url: "../data/FactoryPhotoDo-JSON.php?cmd=ren&dirname=" + B.raw.name + "&newname=" + encodeURIComponent(I),
                                        success: function(J) {
                                            var K = Ext.JSON.decode(J.responseText);
                                            if (K.success == true) {
                                                store.load({
                                                    params: {cmd: "cmdrefresh"}
                                                });                                           
    Ext.example.msg('重命名:', '重命名已成功提交,请点<img src="../images/desktopUI/shuaxin.png">刷新查看结果!')
                                            } else {
    Ext.example.msg('重命名:', '重命名提交失败,请检查是否权限不够!')
                                            }
                                        },
                                        failure: function(J) {
    Ext.example.msg('重命名错误:', '请与管理员联系!')
                                        }
                                    })
                                }
                            },
                            this, false, B.raw.name)
                        }
                    },
                    {
                        text: "剪切",
                        iconCls: "folder_cut",
                        handler: function() {
                            this.up("menu").hide();
                            fpcopy(1)
                        }
                    },
                    {
                        text: "复制",
                        iconCls: "folder_copy",
                        handler: function() {
                            this.up("menu").hide();
                            fpcopy(0)
                        }
                    },
                    {
                        text: "删除",
                        iconCls: "folder_del",
                        handler: function() {
                            this.up("menu").hide();
                            fpdel()
                        }
                    }]
                }).showAt(C.getXY())
            }
        },
    dockedItems: [{
            dock: "top",
            xtype: "toolbar",
            items: [{
                itemId: "cmdup",
                text: "上一级",
                iconCls: "folder-back",
                handler: function() {
                    store.load({
                        params: {cmd: "cmdup",path: fdir},
    callback: function(records,options,success){
    if(success==true){//加载成功
    var I = store.getCount();
    if(I>0){
    fdir= store.getAt(0).get('filedir')
    }else{
    fdir = A.raw.id + "@thisnewfolder";
    }
    }
    },
    scope: store,
    add: false
                    })
                }
            },
            {
                itemId: "cmdroot",
                text: "根目录",
                iconCls: "xtxx",
                handler: function() {
    fdir="root";
                    store.load({
                        params: {cmd: "cmdroot",path: 'root'}
                    })
                }
            },
            {
                itemId: "cmdrefresh",
                text: "刷新",
                iconCls: "refresh",
                handler: function() {
                    store.load({
                        params: {cmd: "cmdrefresh",path: fdir}
                    })
                }
            },
            {
                itemId: "cmddelete",
                text: "删除",
                iconCls: "folder_del",
                handler: fpdel
            },
            {
                itemId: "cmdnewdir",
                text: "新建目录",
                iconCls: "folder_new",
                handler: fpnewdir
            },
            {
                itemId: "webdiskcut",
                text: "剪切",
                iconCls: "folder_cut",
                handler: function() {fpcopy(1)}
            },
            {
                itemId: "webdiskcopy1",
                text: "复制",
                iconCls: "folder_copy",
                handler: function() {fpcopy(0)}
            },
            {
                itemId: "cmdpaste",
                text: "粘贴",
                iconCls: "folder_paste",
                handler: function() {
                    Ext.Ajax.request({
                        url: "../data/FactoryPhotoDo-JSON.php?cmd=paste&dirname=files",
                        success: function(A) {
                            var B = Ext.JSON.decode(A.responseText);
                            if (B.success == true) {
                                if (B.msg == "成功") {
    Ext.example.msg('粘贴:', '已粘贴到当前目录!');
                                    store.load({
                                        params: {cmd: "cmdrefresh"}
                                    })
                                } else{
    Ext.example.msg('粘贴:', B.msg)
                                }
                            } else {
    Ext.example.msg('粘贴:', '粘贴提交失败,请检查是否权限不够!')
                            }
                        },
                        failure: function(A) {
    Ext.example.msg('粘贴数据错误:', '请与管理员联系!')
                        }
                    })
                }
            },
            {
                itemId: "webdiskupload",
                text: "上传",
                iconCls: "folder_upload",
                handler: function() {
                    var A = new Ext.Window({
                        title: "新图片上传",
                        width: 700,
                        height: 530,
                        closeAction: "hide",
                        modal: true,
                        listeners: {
                            beforehide: function() {
                                store.load({
                                    params: {cmd: "cmdrefresh"}
                                })
                            }
                        },
                        html: ''
                    });
                    if (A.hidden == true) {
                        A.show()
                    } else {
                        A.hide()
                    }
                }
            },
            {
                itemId: "webdiskdownload",
                text: "下载",
                iconCls: "folder_download",
                handler: fpdownload
            }]
        }]
    });附上GRID。PANEL构建代码,DESKTOP核心代码是改写EXTJS官方样例。