Browse Source

加入邀请功能开发

hy 7 years ago
parent
commit
dc06ef5667

+ 34 - 6
frontend/saas-web/app/view/main/Main.js

@@ -114,6 +114,7 @@ Ext.define('saas.view.main.Main', {
                 {
                     //margin: '0 0 0 0',
                     xtype: 'tbtext',
+                    name:'realname',
                     cls:'sa-nav-button nav-realname',
                     bind: {
                         html: '{account.realname}'
@@ -121,14 +122,27 @@ Ext.define('saas.view.main.Main', {
                     style:{
                         cursor:'default',
                         textAlign:'center'
-                    }
+                    },
+                    listeners:{
+                        afterrender:function(b){
+                            var main = b.ownerCt.ownerCt;
+                            //调用
+                            var _localStorage = Ext.decode(localStorage.getItem('app-state-session'));
+                            var nowCompanyId = _localStorage.account.companyId;
+                            var rolesMap = _localStorage.account.rolesMap[nowCompanyId];
+                            for(var i = 0; i < rolesMap.length; i++) {
+                               if(rolesMap[i].type==0){
+                                    main.getController().loadInvitationMsg(1)
+                               }
+                            }
+                        }
+                    },
                 },
                 {
                     // ui: 'header',
-                    arrowVisible: false,
-                    cls:' sa-nav-button',   
+                    cls:' sa-nav-button', 
                     width: 50,
-                    height:50,    
+                    height:50,   
                     bind: {
                         html:'<img class="x-img x-box-item x-toolbar-item x-img-header" style="height:35px;width:35px;margin-top: 6px;margin-left: 14px;" src="{avatarUrl}" alt="">'
                     }, 
@@ -152,13 +166,27 @@ Ext.define('saas.view.main.Main', {
                             handler:'feedbackMsg'
                         }, {  
                             text: '加入邀请',
+                            name:'join',
                             iconCls:'x-fa fa-handshake-o sa-navicon',
-                            handler:'invitation'
+                            handler:function(b){
+                                saas.util.BaseUtil.openTab('sys-invitation-datalist','申请列表', 'sys-invitation-datalist');
+                            }
                         }, {
                             text: '退出',
                             iconCls:'x-fa fa-power-off sa-navicon',
                             handler: 'onLogout'
-                        }]
+                        }],
+                        listeners:{
+                            show:function(m){
+                                var name = m.ownerCmp.ownerCt.down('[name=realname]');
+                                var classList = name.getEl().dom.classList;
+                                if(classList.contains('x-header-redpoint')){
+                                    m.getEl().dom.classList.add('x-menu-redpoint')
+                                }else{
+                                    m.getEl().dom.classList.remove('x-menu-redpoint')
+                                }
+                            } 
+                        }
                     }
                 }
             ]

+ 28 - 0
frontend/saas-web/app/view/main/Main.scss

@@ -349,3 +349,31 @@ body > .x-mask {
         color: #34BAF6;
     }
 }
+
+.x-header-redpoint:after{
+    z-index: 100;
+    content: ' ';
+    display: block;
+    width: 8px;
+    height: 8px;
+    background-color: red;
+    border: 1px solid red;
+    border-radius: 12px;
+    position: absolute;
+    left: 76px;
+    top: -7px;
+}
+
+.x-menu-redpoint:after{
+    z-index: 100;
+    content: ' ';
+    display: block;
+    width: 5px;
+    height: 5px;
+    background-color: red;
+    border: 1px solid red;
+    border-radius: 12px;
+    position: absolute;
+    left: 88px;
+    top: 72px;
+}

+ 120 - 0
frontend/saas-web/app/view/main/MainController.js

@@ -115,5 +115,125 @@ Ext.define('saas.view.main.MainController', {
             }); 
         };
         win.show();
+    },
+
+    loadInvitationMsg: function(count) {
+        var me = this.view;//视图层
+        var hasInvitationMsg = false;
+        //查询后台
+        var param = [{
+            type:'condition',
+            value:"re_status=2"
+        }]
+        Ext.Ajax.request({  
+            url :'/api/commons/remind/apply/list',
+            timeout: 8000,  
+            async:false,
+            headers:{
+                'Access-Control-Allow-Origin': '*',
+                'Authorization':  saas.util.State.get('session').token,
+                "Content-Type": 'application/json;charset=UTF-8'
+            },
+            method: 'GET',
+            params:{
+                condition:JSON.stringify(param)
+            },
+            success: function(fp, o){
+                var res = Ext.decode(fp.responseText);
+                me.InvitationList = res.data.list;
+                if(res.data.list.length>0){
+                    hasInvitationMsg = true;
+                }else{
+                    hasInvitationMsg = false;
+                }
+            },
+            failure: function (response, opts) {}
+        });
+        var s = me.items.items[0].down('[name=realname]')
+        if(hasInvitationMsg){
+            s.getEl().dom.classList.add('x-header-redpoint')
+        }else{
+            s.getEl().dom.classList.remove('x-header-redpoint')
+        }
+        if(count==1){
+            //打开加入邀请窗口
+            setTimeout(function() {
+                me.getController().invitation();
+            }, 300);
+        }
+        setTimeout(function() {
+            me.getController().loadInvitationMsg(count+1);
+        }, 8000);
+    },
+
+    invitation:function(){
+        var me = this;
+        var data = me.view.InvitationList;
+        if(data.length>0){
+            var items = [{
+                margin:'0 0 0 60px',
+                xtype:'displayfield',
+                fieldStyle : 'font-weight: 800;font-size: 18px;color: #35baf6;',
+                value:'收到加入企业申请'
+            }];
+            Ext.each(data, function(item, index){
+                if(index<3){
+                    //最多3条
+                    var o = {
+                        margin:'10 0 0 0',
+                        xtype:'panel',
+                        layout: 'hbox',
+                        style:'border:1px solid #34BAF6;    padding-top: 3px;',
+                        items:[{
+                            labelWidth:60,
+                            fieldLabel:'申请人',
+                            xtype:'displayfield',
+                            fieldStyle : 'color: black;',
+                            value:item.username
+                        },{
+                            labelWidth:80,
+                            padding:'0 10 0 0',
+                            fieldLabel:'联系方式',
+                            xtype:'displayfield',
+                            fieldStyle : 'color: black;',
+                            value:item.mobile
+                        }]
+                    }
+                    items.push(o);
+                }
+            });
+            items.push({
+                width:128,
+                margin:'20 0 0 70',
+                xtype:'button',
+                text:'查 看',
+                handler:function(){
+                    saas.util.BaseUtil.openTab('sys-invitation-datalist','申请列表', 'sys-invitation-datalist');
+                    this.ownerCt.ownerCt.close()
+                }
+            });
+            var nowHeight = (items.length-2)*70+130;
+            //打开邀请窗口
+            var win = Ext.create('Ext.window.Window', {  
+                cls:'x-window-dbfind', 
+                height: nowHeight,
+                width: '50%',
+                modal:true,
+                title: '加入邀请',
+                bodyPadding: 10,
+                constrain: true,
+                closable: true,
+                layout: {
+                    type: 'vbox',
+                    align: 'center'
+                },
+                items:[{
+                    xtype:'panel',
+                    layout:'vbox',
+                    items:items
+                }]
+            });
+            win.show();
+        }
     }
 });

+ 378 - 0
frontend/saas-web/app/view/sys/invitation/DataList.js

@@ -0,0 +1,378 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.sys.invitation.DataList', {
+    extend: 'Ext.grid.Panel',
+    xtype: 'sys-invitation-datalist',
+    controller: 'sys-invitation-datalist',
+    viewModel: 'sys-invitation-datalist',
+    autoScroll: true,
+    frame:true,
+    layout:'fit',
+    dataUrl:'/api/commons/remind/apply/list',   
+    
+    plugins: [{
+        ptype: 'cellediting',
+        clicksToEdit: 1
+    }],
+
+    tbar: [{
+        width: 110,
+        name: 'username',
+        xtype: 'textfield',
+        emptyText : '姓名'
+    },{
+        width: 140,
+        name: 're_status',
+        emptyText : '批准状态',
+        xtype: 'combobox',
+        queryMode: 'local',
+        displayField: 'display',
+        valueField: 'value',
+        editable:false,
+        store: Ext.create('Ext.data.ArrayStore', {
+        fields: ['display', 'value'],
+        data: [
+            ["全部", "ALL"],
+            ["待批准", "2"],
+            ["已批准", "1"],
+            ["未批准", "0"]
+        ]
+        }),
+        getCondition: function(value) {
+            if(value == 'ALL') {
+                return '1=1';
+            }else {
+                return 're_status=\'' + value + '\'';
+            }
+        }
+    },{
+        xtype:'button',
+        text:'查询',
+        listeners: {
+            click:function(b){
+                var grid = b.ownerCt.ownerCt;
+                var tbar = b.ownerCt;
+                grid.condition = '';
+                var items = [];
+                var fields = tbar.items.items.map(f => f.name);
+                Ext.each(fields, function(f, index){
+                    var field = tbar.down('[name='+f+']');
+                    if(field){
+                        items.push(field);
+                    }
+                });
+                grid.condition = grid.getCondition(items);
+                grid.store.loadPage(1);
+            }
+        }
+    },'->',{
+        xtype:'button',
+        text:'刷新',
+        listeners: {
+            click: 'onRefresh'
+        }
+    }],
+
+    columns : [{
+        text : '操作', 
+        dataIndex : 'status', 
+        width:110,
+        renderer:function(v,atr,rec,index){
+            var grid = this;
+            if(typeof(window.showWin)!='function'){
+                window.showWin = function(x){
+                    var record = grid.store.getAt(x);
+                    grid.dialog = grid.add({
+                        xtype: 'sys-invitation-editwindow',
+                        bind: {
+                            title: '批准信息'
+                        },
+                        _parent:grid,
+                        record:record,
+                        session: true
+                    });
+                    grid.dialog.show();
+                }
+            }
+            if(typeof(window.disagree)!='function'){
+                window.disagree = function(x){
+                    grid.setLoading(true);
+                    var record = grid.store.getAt(x);
+                    var _params = {
+                        id:Number(record.get('id')),
+                        status:0
+                    };
+                    saas.util.BaseUtil.request({
+                        url: '/api/commons/remind/apply/confirm',
+                        params: JSON.stringify(_params),
+                        method: 'POST',
+                    })
+                    .then(function(localJson) {
+                        grid.setLoading(false);
+                        if(localJson.success){
+                            saas.util.BaseUtil.showSuccessToast('保存成功');
+                            grid.store.load();
+                        }
+                    })
+                    .catch(function(res) {
+                        grid.setLoading(false);
+                        console.error(res);
+                        saas.util.BaseUtil.showErrorToast('保存失败: ' + res.message);
+                    });
+                }
+            }
+            if(v&&v!=''){
+                if(v=='2'){
+                    return "<input type='button' value='批准'  style='padding:2px;color:white;font-size:13px;cursor:pointer;height:22px;background-color: #35baf6;border-color: #35baf6;display: inline-block;cursor: pointer;text-align: center;border-radius: 3px;border: 1px solid transparent;' onClick='window.showWin(\""+index+"\")'></input>"+"<span style='font-size: 19px;'> | </span>"+
+                           "<input type='button' value='不批准'  style='padding:2px;color:white;font-size:13px;cursor:pointer;height:22px;background-color: #35baf6;border-color: #35baf6;display: inline-block;cursor: pointer;text-align: center;border-radius: 3px;border: 1px solid transparent;' onClick='window.disagree(\""+index+"\")'></input>";
+                }else if(v=='1'){
+                    return '已批准';
+                }else if(v=='0'){
+                    return '未批准'
+                }
+            }
+            return v;
+        }
+    },{
+        text : 'id', 
+        hidden:true,
+        dataIndex : 'id', 
+        xtype : 'numbercolumn',   
+    },{
+        text : 'accountId', 
+        hidden:true,
+        dataIndex : 'accountId', 
+        xtype : 'numbercolumn',   
+    },{
+        text : '姓名', 
+        width : 90.0, 
+        dataIndex : 'username', 
+    },{
+        text : '手机号码', 
+        dataIndex : 'mobile', 
+        width : 150.0,
+    },{
+        text : '岗位角色id', 
+        hidden:true,
+        dataIndex : 'roles'
+    },{
+        text : '岗位角色', 
+        dataIndex : 'roleNames', 
+        width : 220.0,
+    }],
+
+    dbSearchFields: [],
+    condition:'',
+
+    initComponent: function() {
+        var me = this;
+        if(me.columns){
+            var fields = me.columns.map(column => column.dataIndex);
+            me.store = Ext.create('Ext.data.Store',{
+                fields:fields,
+                autoLoad: true,
+                pageSize: 11,
+                data: [],
+                proxy: {
+                    timeout:8000,
+                    type: 'ajax',
+                    url: me.dataUrl,
+                    actionMethods: {
+                        read: 'GET'
+                    },
+                    reader: {
+                        type: 'json',
+                        rootProperty: 'data.list',
+                        totalProperty: 'data.total',
+                    },
+                    listeners: {
+                        exception: function(proxy, response, operation, eOpts) {
+                            if(operation.success) {
+                                if(response.timedout) {
+                                    saas.util.BaseUtil.showErrorToast('请求超时');
+                                }
+                            }else {
+                                if(response.timedout) {
+                                    saas.util.BaseUtil.showErrorToast('请求超时');
+                                }else{
+                                    if(proxy.showPowerMessage){
+                                        saas.util.BaseUtil.showErrorToast('查询失败:' + response.responseJson?response.responseJson.message:'请求超时');
+                                    }
+                                }
+                            }
+                        }
+                    }
+                },
+                listeners: {
+                    beforeload: function (store, op) {
+                        var condition = me.condition;
+                        if (Ext.isEmpty(condition)) {
+                            condition = '';
+                        }
+                        Ext.apply(store.proxy.extraParams, {
+                            number: op._page,
+                            size: store.pageSize,
+                            condition: JSON.stringify(condition)
+                        });
+                    }
+                }
+            });
+
+            Ext.apply(me, {
+                dockedItems:[{
+                    xtype: 'pagingtoolbar',
+                    dock: 'bottom',
+                    displayInfo: true,
+                    store: me.store
+                }]
+            });
+        }
+        me.callParent(arguments);
+    },
+
+    listeners:{
+        boxready: function(grid, width, height, eOpts) {
+            var store = grid.getStore(),
+            gridBodyBox = grid.body.dom.getBoundingClientRect(),
+            gridBodyBoxHeight = gridBodyBox.height;
+            var pageSize = Math.floor(gridBodyBoxHeight / 35);
+            store.setPageSize(pageSize);
+        }
+    },
+
+    getGridSelected:function(type){
+        var isErrorSelect = false;
+        var checkField = this.statusCodeField;
+        var me = this,
+        items = me.selModel.getSelection(),
+        data = new Array() ;
+        Ext.each(items, function(item, index){
+            if(!Ext.isEmpty(item.data[me.idField])){
+                var o = new Object();
+                if(me.idField){
+                    o['id'] = item.data[me.idField];
+                }
+                if(me.codeField){
+                    o['code'] = item.data[me.codeField];
+                }
+                if(type&&type==item.data[checkField]){
+                    isErrorSelect = true
+                }
+                data.push(o);
+            }
+        });
+        if(isErrorSelect){
+            return false;
+        }
+		return data;
+    },
+
+    /**
+     * 获得过滤条件
+     */
+    getCondition: function(items) {
+        var me = this,
+        conditions = [];
+
+        for(var i = 0; i < items.length; i++) {
+            var item = items[i];
+            var field = item.name,
+            func = item.getCondition,
+            value = item.value,
+            condition;
+
+            if(value&&value!=''){
+                if(typeof func == 'function') {
+                    condition = {
+                        type: 'condition',
+                        value: func(value)
+                    }
+                }else {
+                    var xtype = item.xtype || 'textfield',
+                    type = item.fieldType || me.getDefaultFieldType(xtype),
+                    operation = item.operation || me.getDefaultFieldOperation(xtype),
+                    conditionValue = me.getConditionValue(xtype, value);
+        
+                    if(!conditionValue) {
+                        continue;
+                    }
+                    condition = {
+                        type: type,
+                        field: field,
+                        operation: operation,
+                        value: conditionValue
+                    }
+                }
+                conditions.push(condition);
+            }
+        };
+        return conditions;
+    },
+
+    getDefaultFieldType: function(xtype) {
+        var type;
+
+        if(Ext.Array.contains(['numberfield'], xtype)) {
+            type = 'number';
+        }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
+            type = 'date';
+        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
+            type = 'enum';
+        }else {
+            type = 'string';
+        }
+
+        return type;
+    },
+
+    getDefaultFieldOperation: function(xtype) {
+        var operation;
+
+        if(Ext.Array.contains(['numberfield'], xtype)) {
+            operation = '=';
+        }else if(Ext.Array.contains(['datefield'], xtype)) {
+            operation = '=';
+        }else if(Ext.Array.contains(['condatefield'], xtype)) {
+            operation = 'between';
+        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
+            operation = 'in';
+        }else {
+            operation = 'like';
+        }
+
+        return operation;
+    },
+
+    /**
+     * 处理部分字段值
+     */
+    getConditionValue: function(xtype, value) {
+        var conditionValue;
+        if(xtype == 'datefield') {
+            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
+        }else if(xtype == 'condatefield') {
+            var from = value.from,
+            to = value.to;
+
+            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
+        }else if(xtype == 'combobox' || xtype == 'combo') {
+            conditionValue = '\'' + value + '\'';
+        }else if(xtype == 'multicombo') {
+            conditionValue = value.map(function(v) {
+                return '\'' + v.value + '\'';
+            }).join(',');
+        }else {
+            conditionValue = value;
+        }
+
+        return conditionValue;
+    },
+
+    refresh:function(){
+        this.store.load()
+    }
+
+})
+
+

+ 15 - 0
frontend/saas-web/app/view/sys/invitation/DataListController.js

@@ -0,0 +1,15 @@
+Ext.define('saas.view.sys.invitation.DataListController', {
+    extend: 'saas.view.core.base.BasePanelController',
+    alias: 'controller.sys-invitation-datalist',
+
+    init: function (form) {
+        var me = this;
+        this.control({
+        });
+    },
+
+    onRefresh:function(){
+        var me = this;
+        me.view.items.items[0].store.load();
+    },
+});

+ 4 - 0
frontend/saas-web/app/view/sys/invitation/DataListlModel.js

@@ -0,0 +1,4 @@
+Ext.define('saas.view.sys.invitation.DataListModel', {
+    extend: 'saas.view.core.base.BasePanelModel',
+    alias: 'viewmodel.sys-invitation-datalist'
+});

+ 84 - 0
frontend/saas-web/app/view/sys/invitation/EditWindow.js

@@ -0,0 +1,84 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.sys.invitation.EditWindow', {
+    extend: 'saas.view.document.kind.ChildForm',
+    xtype: 'sys-invitation-editwindow',
+    dataKind:'invitation',//类型标识
+    belong:{
+        columns:[{
+            dataIndex:'id',
+        },{
+            dataIndex: 'status',
+            width: 150
+        },{
+            dataIndex: 'roles',
+            hidden:true
+        }],
+        reqUrl:'/api/commons/remind/apply/confirm',
+    },
+    etc:{
+        invitation:{
+            items:[{
+                xtype:'hidden',
+                name:'id',
+                hidden:true,
+            },{
+                xtype:'datamulticombo',
+                dataUrl:'/api/account/role/list',
+                fieldLabel: '岗位角色',
+                name: 'roles',
+                allowBlank:false
+            }]
+        }
+    },
+    onSave:function(){
+        var me = this;
+        var belong = this.belong;
+        me.setLoading(true);
+        var form=this.down('form');
+        var params = {};
+        var names = belong.columns.map(column => column.dataIndex);
+
+        Ext.Array.each(names,function(name) {
+            if(name){
+                var dataField = form.down('[name='+name+']');
+                if(dataField&&dataField.value){
+                    params[name] = dataField.value;
+                }
+            }
+        });
+
+        //更改参数
+        var o = '';
+        Ext.Array.each(params.roles,function(item) {
+            o+=item+','
+        });
+        o = o.substring(0,o.length-1);
+        var _params = {
+            id:Number(params['id']),
+            roles:o,
+            status:1
+        };
+
+        //保存接口
+        saas.util.BaseUtil.request({
+            url: belong.reqUrl,
+            params: JSON.stringify(_params),
+            method: 'POST',
+        })
+        .then(function(localJson) {
+            me.setLoading(false);
+            if(localJson.success){
+                saas.util.BaseUtil.showSuccessToast('保存成功');
+                form.ownerCt._parent.store.load()
+                form.ownerCt.close();
+            }
+        })
+        .catch(function(res) {
+            me.setLoading(false);
+            console.error(res);
+            saas.util.BaseUtil.showErrorToast('保存失败: ' + res.message);
+        });
+    }
+});