xiongzhu 4 anni fa
parent
commit
4c8fcf33de

+ 7 - 117
o2web/source/o2_core/o2/xDesktop/$Default/blue/layout-pc.html

@@ -10,124 +10,14 @@
                 <div id="app">
                     <el-menu class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" background-color="#092E59"
                         text-color="#fff" active-text-color="#ffd04b" unique-opened>
-                        <el-menu-item index="0" @click.native="open(null ,'Homepage')">
-                            <i class="fas fa-home"></i>
-                            <span slot="title">主页</span>
-                        </el-menu-item>
-                        <el-menu-item index="1" @click.native="open(null ,'Org')">
-                            <i class="fas fa-sitemap"></i>
-                            <span slot="title">组织管理</span>
-                        </el-menu-item>
-                        <el-menu-item index="2" @click.native="open(null ,'process.TaskCenter')">
-                            <i class="fas fa-suitcase"></i>
-                            <span slot="title">公文管理</span>
-                        </el-menu-item>
-                        <el-menu-item index="9" @click.native="open('公文模版')">
-                            <i class="fas fa-suitcase"></i>
-                            <span slot="title">公文模版管理</span>
-                        </el-menu-item>
-                        <el-submenu index="3">
-                            <template slot="title">
-                                <i class="fas fa-calendar-alt"></i>
-                                <span slot="title">工作事务处理</span>
-                            </template>
-                            <el-menu-item index="3-1" @click.native="open(null ,'TeamWork')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">工作计划</span>
-                            </el-menu-item>
-                            <el-menu-item index="3-2" @click.native="open(null ,'Meeting')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">接待管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="3-3" @click.native="open(null ,'Calendar')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">日常事务</span>
-                            </el-menu-item>
-                            <el-menu-item index="3-4" @click.native="open(null ,'Meeting')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">会议管理</span>
-                            </el-menu-item>
-                        </el-submenu>
-                        <el-submenu index="4">
-                            <template slot="title">
-                                <i class="fas fa-file-alt"></i>
-                                <span>公共信息服务</span>
-                            </template>
-                            <el-menu-item index="4-1" @click.native="open(null ,'cms.Column')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">内容管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="4-2" @click.native="open(null ,'cms.Index')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">信息平台</span>
-                            </el-menu-item>
-                        </el-submenu>
-                        <el-submenu index="5">
-                            <template slot="title">
-                                <i class="fas fa-box"></i>
-                                <span>内务管理</span>
-                            </template>
-                            <el-menu-item index="5-1" @click.native="open('车辆管理')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">车辆管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="5-2" @click.native="open(null ,'Meeting')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">会议管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="5-3" @click.native="open(null ,'portal.Portal', {portalId:'4f6c9f1f-432f-4836-9d42-0060b65634fe',appId:'portal.Portal4f6c9f1f-432f-4836-9d42-0060b65634fe',event:null})">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">资产管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="5-4" @click.native="open(null, 'Org', {}, {navi:3})">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">人事管理</span>
-                            </el-menu-item>
-                            <el-menu-item index="5-5" @click.native="open('绩效管理')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">绩效管理</span>
-                            </el-menu-item>
-                        </el-submenu>
-                        <el-menu-item index="6" @click.native="open(null ,'File')">
-                            <i class="fas fa-file"></i>
-                            <span slot="title">资料管理</span>
-                        </el-menu-item>
-                        <el-submenu index="7">
-                            <template slot="title">
-                                <i class="fas fa-file-alt"></i>
-                                <span>个人事物管理</span>
-                            </template>
-                            <el-menu-item index="7-1" @click.native="open(null ,'Calendar')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">事务提醒</span>
-                            </el-menu-item>
-                            <el-menu-item index="7-2" @click.native="open(null ,'portal.Portal', {appId: 'portal.Portal0e0d08d4-2435-481e-bb1d-25c79c614080', portalId: '0e0d08d4-2435-481e-bb1d-25c79c614080'})">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">通讯录</span>
-                            </el-menu-item>
-                            <el-menu-item index="7-3" @click.native="open(null ,'Calendar')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">日程安排</span>
-                            </el-menu-item>
-                            <el-menu-item index="7-4" @click.native="open(null ,'File')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">在线学习</span>
-                            </el-menu-item>
-                            <el-menu-item index="7-5" @click.native="open(null, 'Profile')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">个人资料</span>
-                            </el-menu-item>
-                            <el-menu-item index="7-9" @click.native="open(null ,'Attendance')">
-                                <i class="fas fa-suitcase"></i>
-                                <span slot="title">考勤管理</span>
-                            </el-menu-item>
-                        </el-submenu>
-                        <el-menu-item index="8" @click="open(null, 'Setting')">
-                            <i class="fas fa-user-cog"></i>
-                            <span slot="title">系统管理</span>
-                        </el-menu-item>
+                        <sys-menu
+                            v-for="item in menus"
+                            :menu="item"
+                            :key="item.id"
+                            @menuClick="menuClick"
+                        >
+                        </sys-menu>
                     </el-menu>
-        
                 </div>
             </div>
             <div class="layout_menu_setting deepColor_bg">

+ 528 - 1
o2web/source/o2_core/o2/xDesktop/Default.js

@@ -161,10 +161,530 @@ o2.xDesktop.Default = new Class({
 
             this.fireEvent("load");
             MWF.require("MWF.xDesktop.shortcut");
+
+
+            var CustomMenuService = new Class({
+                Implements: [Options, Events],
+                options : {
+                    tableFlag : ""
+                },
+                initialize : function( options ){
+                    this.setOptions( options || {});
+                    this.action = new _self.Action("x_query_assemble_surface", {
+                        "listPaging" : {
+                            "uri" : "/jaxrs/table/list/{tableFlag}/row/{id}/next/{count}",
+                            "method": "POST"
+                        },
+                        "listRowNext" : {
+                            "uri" : "/jaxrs/table/list/{tableFlag}/row/{id}/next/{count}",
+                            "method": "GET"
+                        },
+                        "listRowPrev" : {
+                            "uri" : "/jaxrs/table/list/{tableFlag}/row/{id}/prev/{count}",
+                            "method": "GET"
+                        },
+                        //通过where 获取表中的数据,格式为jpa jpql语法,o.name='zhangsan'
+                        "listRowSelectWhere" : {
+                            "uri" : "/jaxrs/table/list/{tableFlag}/row/select/where/{where}",
+                            "method": "GET"
+                        },
+                        "rowGet" : {
+                            "uri": "/jaxrs/table/{tableFlag}/row/{id}", //获取表中某一行数据
+                            "method": "GET"
+                        },
+                        "rowUpdate":{
+                            "uri": "/jaxrs/table/{tableFlag}/row/{id}", //更新指定表中指定行数据.
+                            "method": "PUT"
+                        },
+                        "rowInsert":{
+                            "uri": "/jaxrs/table/{tableFlag}/row", //插入一行
+                            "method": "POST"
+                        },
+                        "rowCountWhere" : {
+                            "uri": "/jaxrs/table/{tableFlag}/row/count/where/{where}", //通过where 统计数量
+                            "method": "GET"
+                        },
+                        "rowDelete" : {
+                            "uri": "/jaxrs/table/{tableFlag}/row/{id}", //更新指定表中指定行数据.
+                            "method": "DELETE"
+                        },
+                        "rowDeleteAll" : {
+                            "uri": "/jaxrs/table/{tableFlag}/row/delete/all", //通过where 统计数量
+                            "method": "DELETE"
+                        }
+                    });
+                },
+                listNext : function(rowId, count, callback_success, callback_fail, async){
+                    var opt = {
+                        "name": "listRowNext",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "id" : rowId,
+                            "count" : count || 20
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke( opt );
+                },
+                listPrev : function(rowId, count, callback_success, callback_fail, async){
+                    var opt = {
+                        "name": "listRowPrev",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "id" : rowId,
+                            "count" : count || 20
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    }
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                listByWhere : function(where, callback_success, callback_fail, async){
+                    var opt = {
+                        "name": "listRowSelectWhere",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "where" : where
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                get : function( rowId, callback_success, callback_fail, async ){
+                    var opt = {
+                        "name": "rowGet",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "id" : rowId
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                create : function( data, callback_success, callback_fail, async ){
+                    data.o2_createPerson = layout.desktop.session.user.distinguishedName;
+                    data.o2_createUnit = Utils.getCurrentDepartment();
+                    var opt = {
+                        "name": "rowInsert",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag
+                        },
+                        "data" : data,
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                update : function( rowId, data, callback_success, callback_fail, async ){
+                    data.o2_updatePerson = layout.desktop.session.user.distinguishedName;
+                    var opt = {
+                        "name": "rowUpdate",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "id" : rowId
+                        },
+                        "data" : data,
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                save : function( data, callback_success, callback_fail, async ){
+                    var opt = {
+                        "name": data.id ? "rowUpdate" : "rowInsert",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag
+                        },
+                        "data" : data,
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    if(data.id)opt.parameter.id = data.id;
+                    this.action.invoke(opt);
+                },
+                count : function( where, callback_success, callback_fail, async ){
+                    var opt = {
+                        "name": "rowGet",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "where" : where
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                delete : function( rowId, callback_success, callback_fail, async ){
+                    var opt = {
+                        "name": "rowDelete",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag,
+                            "id" : rowId
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                },
+                deleteAll : function( callback_success, callback_fail, async ){
+                    var opt = {
+                        "name": "rowDelete",
+                        "parameter": {
+                            "tableFlag": this.options.tableFlag
+                        },
+                        "success": function(json){
+                            if(callback_success)callback_success(json);
+                        }.bind(this),
+                        "async" : async
+                    };
+                    if( callback_fail ){
+                        opt.failure = function(xhr, text, error){
+                            callback_fail( xhr, text, error );
+                        }
+                    }
+                    this.action.invoke(opt);
+                }
+            });
+            var service = new CustomMenuService({ tableFlag : "customMenu" });
+            Vue.component('SysMenu', {
+                template: `
+                    <el-menu-item v-if="isLeaf" :index="menu.id" @click="menuClick(menu.params)">
+                        <i :class="menu.icon" v-if="menu.icon"></i
+                        ><span slot="title">{{ menu.name }}</span>
+                    </el-menu-item>
+                    <el-submenu v-else :index="menu.id">
+                        <template slot="title">
+                            <i :class="menu.icon" v-if="menu.icon"></i>
+                            <span slot="title">{{ menu.name }}</span>
+                        </template>
+                        <sys-menu
+                            v-for="item in menu.children"
+                            :menu="item"
+                            :key="item.id"
+                            @menuClick="menuClick"
+                        ></sys-menu>
+                    </el-submenu>`,
+                props: {
+                    menu: {
+                        type: Object,
+                        required: true
+                    }
+                },
+                data() {
+                    return {};
+                },
+                methods: {
+                    menuClick(param) {
+                        this.$emit("menuClick", param);
+                    }
+                },
+                computed: {
+                    isLeaf() {
+                        return !(
+                            this.menu.children instanceof Array && this.menu.children.length
+                        );
+                    }
+                }
+            });
+            var _self = this;
             new Vue({
                 el: '#app',
                 data: function () {
-                    return { visible: false }
+                    return {
+                        visible: false,
+                        userMenus: [],
+                        menus: [
+                            {
+                                id: "0",
+                                name: "主页",
+                                params: [null, "Homepage"],
+                                icon: "fas fa-home",
+                            },
+                            {
+                                id: "1",
+                                name: "组织管理",
+                                params: [null, "Org"],
+                                icon: "fas fa-sitemap",
+                            },
+                            {
+                                id: "2",
+                                name: "公文管理",
+                                params: [null, "process.TaskCenter"],
+                                icon: "fas fa-suitcase",
+                            },
+                            {
+                                id: "3",
+                                name: "公文模版管理",
+                                params: "公文模版",
+                                icon: "fas fa-suitcase",
+                            },
+                            {
+                                id: "4",
+                                name: "工作事务处理",
+                                icon: "fas fa-calendar-alt",
+                                children: [
+                                    {
+                                        id: "4-1",
+                                        name: "工作计划",
+                                        params: [null, "TeamWork"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "4-2",
+                                        name: "接待管理",
+                                        params: [null, "Meeting"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "4-3",
+                                        name: "日常事务",
+                                        params: [null, "Calendar"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "4-4",
+                                        name: "会议管理",
+                                        params: [null, "Meeting"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                ],
+                            },
+                            {
+                                id: "5",
+                                name: "公共信息服务",
+                                icon: "fas fa-file-alt",
+                                children: [
+                                    {
+                                        id: "5-1",
+                                        name: "内容管理",
+                                        params: [null, "cms.Column"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "5-2",
+                                        name: "信息平台",
+                                        params: [null, "cms.Index"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                ],
+                            },
+                            {
+                                id: "6",
+                                name: "内务管理",
+                                icon: "fas fa-file-alt",
+                                children: [
+                                    {
+                                        id: "6-1",
+                                        name: "车辆管理",
+                                        params: "车辆管理",
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "6-2",
+                                        name: "会议管理",
+                                        params: [null, "Meeting"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "6-3",
+                                        name: "资产管理",
+                                        params: [
+                                            null,
+                                            "portal.Portal",
+                                            {
+                                                portalId:
+                                                    "4f6c9f1f-432f-4836-9d42-0060b65634fe",
+                                                appId: "portal.Portal4f6c9f1f-432f-4836-9d42-0060b65634fe",
+                                                event: null,
+                                            },
+                                        ],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "6-4",
+                                        name: "人事管理",
+                                        params: [null, "Org", {}, { navi: 3 }],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "6-5",
+                                        name: "绩效管理",
+                                        params: "绩效管理",
+                                        icon: "fas fa-suitcase",
+                                    },
+                                ],
+                            },
+                            {
+                                id: "7",
+                                name: "资料管理",
+                                params: [null, "File"],
+                                icon: "fas fa-file",
+                            },
+                            {
+                                id: "8",
+                                name: "个人事务管理",
+                                icon: "fas fa-file-alt",
+                                children: [
+                                    {
+                                        id: "8-1",
+                                        name: "事务提醒",
+                                        params: [null, "Calendar"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "8-2",
+                                        name: "通讯录",
+                                        params: [
+                                            null,
+                                            "portal.Portal",
+                                            {
+                                                appId: "portal.Portal0e0d08d4-2435-481e-bb1d-25c79c614080",
+                                                portalId:
+                                                    "0e0d08d4-2435-481e-bb1d-25c79c614080",
+                                            },
+                                        ],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "8-3",
+                                        name: "日程安排",
+                                        params: [null, "Calendar"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "8-4",
+                                        name: "在线学习",
+                                        params: [null, "File"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "8-5",
+                                        name: "个人资料",
+                                        params: [null, "Profile"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                    {
+                                        id: "8-6",
+                                        name: "考勤管理",
+                                        params: [null, "Attendance"],
+                                        icon: "fas fa-suitcase",
+                                    },
+                                ],
+                            },
+                            {
+                                id: "9",
+                                name: "系统管理",
+                                params: [null, "Setting"],
+                                icon: "fas fa-user-cog",
+                            },
+                        ],
+                    };
+                },
+                created: function() {
+                    _self.org.listRoleWithPerson(_self.session.user.id, true).then(function(res){
+                        let where = res.map(function(i) {
+                            return "o.role = '" + i.unique + "'"
+                        }).join(' or ');
+                        if(!where) {
+                            where = "o.role = 'NormalUser'"
+                        }
+                        service.listByWhere(where, function(res) {
+                            let menus = [];
+                            if(res.data){
+                                res.data.forEach(function(item){
+                                    if(item.menu){
+                                        item.menu.split(',').forEach(function(m){
+                                            if(!menus.includes(m)){
+                                                menus.push(m);
+                                            }
+                                        });
+                                    }
+                                })
+                            }
+
+                            function filterMenu(data) {
+                                let filterd = [];
+                                data.forEach(function(item){
+                                    if(item.children && item.children.length){
+                                        item.children = filterMenu(item.children);
+                                        if(item.children.length > 0){
+                                            filterd.push(item);
+                                        }
+                                    } else if(menus.includes(item.id)){
+                                        filterd.push(item);
+                                    }
+                                });
+                                return filterd;
+                            }
+                            this.userMenus = filterMenu(this.menus);
+                        }.bind(this), null, false);
+                    }.bind(this))
                 },
                 methods: {
                     handleOpen(key, keyPath) {
@@ -173,6 +693,13 @@ o2.xDesktop.Default = new Class({
                     handleClose(key, keyPath) {
                         console.log(key, keyPath);
                     },
+                    menuClick(e) {
+                        if (e instanceof Array) {
+                            this.open(e[0], e[1], e[2], e[3]);
+                        } else {
+                            this.open(e);
+                        }
+                    },
                     open(e, appNames, options, statusObj) {
                         console.log(e, appNames, options, statusObj);
                         if (e === "车辆管理") {