Ejemplo n.º 1
0
 _.each(fileData,function(file){
     if (file.size < uploadFileSizeLimit * 1024 * 1024&&file.size>0) { //最大uploadFilesSizeLimit
         if(!_.find(typeFiles,function(existFile){
             return existFile.name==file.name;
         })){
             if (uploadType=="img"&&util.getFileType(file)=="jpg") {
                 passedFiles.push(file);
             }
             if(uploadType=="attach"){
                 passedFiles.push(file);
             }
         }
     } //最大20m
 });
Ejemplo n.º 2
0
 			_.each(items,function(item){
 				html += "<tr><td class = 'crm-attachment-simple-image-td'><img src='"+FS.BLANK_IMG+"' alt='icon' class='crm-attachment-simple-image fs-attach-"+util.getFileType({"name":item.attachName},true)+"-small-icon file-icon'/></td>";
 				html += "<td class = 'crm-attachment-simple-name-td'><div title='"+item.attachName+"' class = 'crm-attachment-simple-name-div fn-text-overflow'>"+item.attachName+"</div></td>";
 				html += "<td class = 'crm-attachment-simple-download-td'><a href = '"+ util.getDfLink(item.attachPath, item.attachName, true)+"' title = '"+item.attachName+"' target ='_blank'>下载</a></td>";
 				var str = "";
 				if(!item.canPreview){
 					str = "fn-hide";
 				}
 				html += "<td class = 'crm-attachment-simple-show-td'><a data-attachID = '"+item.attachID+"' data-attachName = '"+item.attachName+"' data-attachPath = '"+item.attachPath+"' class = 'crm-attachment-simple-preview "+str+"'>预览</a></td></tr>";
 			});
Ejemplo n.º 3
0
        getMessageHtml = function (tmpl, msg) {
            var content = msg.content,
                messageTypes = constants.messageType,
                httpReg = new RegExp("(http[s]{0,1}|ftp)://[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&amp;*+?:_/=<>]*)?|www\\.[a-z0-9\\-]+(\\.[a-zA-Z]{2,4}){1,2}(:\\d+)?/?", "gi"), //用于判断文本内容超链接
                o = {
                    typeName: '',
                    senderId: msg.senderId,
                    senderName: msg.senderName,
                    messageId: msg.messageId,
                    messageTime: msg.messageTime,
                    profileImage: msg.profileImage,
                    createTime: util.getDateSummaryDesc(moment.unix(msg.messageTime/1000), moment.unix(msg.serviceTime), 1)
                };

            for (var i in messageTypes) {
                if (messageTypes.hasOwnProperty(i) && messageTypes[i] == msg.messageType) {
                    o.typeName = i;
                }
            }
            if(!content) return ;
            switch (msg.messageType) {
                case messageTypes.emotion://大表情
                    var objContent = json.parse(content);//转换为JSON对象
                    var directoryStr=objContent.PackId+'/';
                    var imgNameStr='fs_bee_'+(objContent.Index-1)+'.gif';
                    var imgStr='<img class="fs-img-emotion" src="'+FS.ASSETS_PATH+'/images/'+directoryStr+imgNameStr+'">';
                    o.content = imgStr;
                    break;
                case messageTypes.image:
                    content = json.parse(content);
                    content.FileSize = util.getFileSize(content.FileSize);
                    content.ThumbnailUrl = util.getFileUrl(content.Thumbnail);
                    content.fileName = content.N;
                    _.extend(o, content);
                    break;
                case messageTypes.document:
                    content = json.parse(content);
                    content.Size = util.getFileSize(content.Size);
                    content.FileType =  util.getFileType({"name": content.File}, true);
                    content.DownloadUrl = util.getFileUrl(content.File, content.Name, true);
                    _.extend(o, content);
                    break;
                case messageTypes.audio:
                    content = json.parse(content);
                    content.File = getMp3Url(content.File);
                    _.extend(o, content);
                    break;
                case messageTypes.location:
                    content = json.parse(content);
                    content.messageTime = parseInt(o.messageTime/1000, 10);
                    _.extend(o, content);
                    break;
                case messageTypes.workNotice: // 工作提醒
                    content = json.parse(content);
                    _.extend(o, {
                        "title": content.T,
                        "desc": content.C,
                        "feedid": content.F
                    });
                    break;
                case messageTypes.linkWorkItem: // 链接到工作项
                    content = json.parse(content);
                    var title = {
                        'P1': '日志',
                        'P2': '周计划',
                        'P3': '月计划',
                        'A1': '普通审批',
                        'A2': '请假单',
                        'A3': '报销单',
                        'A4': '差旅单',
                        'A5': '借款单',
                        'W': '指令'
                    };
                    var _t = '';
                    if(content.T == 'W'){
                        _t = title['W'];
                    }
                    else {
                        if(content.T == 'P' && content.ST == 1){
                            _t = moment(content.D).format('MM月DD日的日志');
                        }
                        else {
                            _t = title[content.T + content.ST];
                        }
                    }
                    _.extend(o, {
                        "title": _t,
                        "desc": content.C,
                        "feedid": content.F
                    });
                    break;
                case messageTypes.linkWorkSchdule: // 链接到日程
                    content = json.parse(content);
                    _.extend(o, {
                        "title": moment(content.ST).format('MM月DD日 HH:mm的日程'),
                        "desc": content.C,
                        "feedid": content.F
                    });
                    break;
                case messageTypes.systemPrompt:
                    content = json.parse(content);
                    var systemPrompt = constants.systemPrompt,
                        t = content.T,
                        u = content.U,
                        _html = [], _s = '';
                    switch (t) {
                        case systemPrompt.exit:
                            _s = '退出群对话';
                            break;
                        case systemPrompt.invite:
                            _s = '邀请';
                            _.each(content.A, function (id) {
                                if(id == u) return ;
                                var _n;
                                if(id == currentUserData.id){
                                    _n = '你';
                                }
                                else {
                                    var _e = util.getContactDataById(id, "p");
                                    if(_e){
                                        _n = _e.name;
                                    }
                                }
                                if(_n){
                                    _html.push(_n);
                                }
                            });
                            _s += _html.join("、") + "加入群对话";
                            break;
                        case systemPrompt.kick:
                            _s = '将';
                            _.each(content.A, function (id) {
                                if(id == u) return ;
                                var _n;
                                if(id == currentUserData.id){
                                    _n = '你';
                                }
                                else {
                                    var _e = util.getContactDataById(id, "p");
                                    if(_e){
                                        _n = _e.name;
                                    }
                                }
                                if(_n){
                                    _html.push(_n);
                                }
                            });
                            _s += _html.join("、") + "移出群对话";
                            break;
                        case systemPrompt.name:
                            if(content.V){
                                _s = "将群对话的名称修改为:" + content.V;
                            }
                            else {
                                _s = "取消了群对话名称";
                            }
                            break;
                    }
                    o.content = _s;
                    break;
                case messageTypes.systemTextPrompt: // 纯文本型系统提示
                    o.content = content;
                    break;
                case messageTypes.text:
                default:
                    content = content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/[\n\r]/g, '<br/>').replace(new RegExp(' ', 'g'), '&nbsp;');
                    content = content.replace(httpReg, function (httpText) {
                        var protocolReg = /https{0,1}|ftp/gi;
                        return '<a href="' + (protocolReg.test(httpText) ? '' : 'http://') + httpText + '" target="_blank">' + httpText + '</a>';
                    });
                    content = util.emoji(content);
                    o.content = content;
            }
            return tmpl[o.typeName](o);
        };
Ejemplo n.º 4
0
                formatMessageData = function (msg, sessionData, tmpls) {
                    var content = msg.content,
                        messageTypes = constants.messageType,
                        httpReg = constants.httpReg,
                        o = {
                            typeName: '',
                            senderId: msg.senderId,
                            senderName: msg.senderName,
                            messageId: msg.messageId,
                            messageTime: msg.messageTime,
                            profileImage: msg.profileImage,
                            createTime: util.getDateSummaryDesc(moment.unix(msg.messageTime / 1000), moment.unix(msg.serviceTime), 1)
                        };

                    for (var i in messageTypes) {
                        if (messageTypes.hasOwnProperty(i) && messageTypes[i] == msg.messageType) {
                            o.typeName = i;
                        }
                    }
                    if (!content) return;
                    switch (msg.messageType) {
                        case messageTypes.image:
                            content = json.parse(content);
                            content.FileSize = util.getFileSize(content.FileSize);
                            content.ThumbnailUrl = util.getFileUrl(content.Thumbnail);
                            content.fileName = content.N;
                            _.extend(o, content);
                            break;
                        case messageTypes.document:
                            content = json.parse(content);
                            content.Size = util.getFileSize(content.Size);
                            content.FileType = util.getFileType({"name": content.File}, true);
                            content.DownloadUrl = util.getFileUrl(content.File, true, content.Name);
                            _.extend(o, content);
                            break;
                        case messageTypes.audio:
                            content = json.parse(content);
                            content.File = util.getFileUrl(content.File);
                            _.extend(o, content);
                            break;
                        case messageTypes.location:
                            content = json.parse(content);
                            content.messageTime = parseInt(o.messageTime / 1000, 10);
                            _.extend(o, content);
                            break;
                        case messageTypes.workNotice: // 工作提醒
                            content = json.parse(content);
                            _.extend(o, {
                                "title": content.T,
                                "desc": content.C,
                                "feedid": content.F
                            });
                            break;
                        case messageTypes.systemPrompt:
                            content = json.parse(content);
                            var systemPrompt = constants.systemPrompt,
                                t = content.T,
                                u = content.U,
                                _html = [], _s = '';
                            switch (t) {
                                case systemPrompt.exit:
                                    _s = '退出群对话';
                                    break;
                                case systemPrompt.invite:
                                    _s = '邀请';
                                    _.each(content.A, function (id) {
                                        var _n;
                                        if(id == loginUserData.id){
                                            _n = '你';
                                        }
                                        else {
                                            var _e = util.getContactDataById(id, "p");
                                            if(_e){
                                                _n = _e.name;
                                            }
                                        }
                                        if(_n){
                                            _html.push(_n);
                                        }
                                    });
                                    _s += _html.join("、") + "加入群对话";
                                    break;
                                case systemPrompt.kick:
                                    _s = '将';
                                    _.each(content.A, function (id) {
                                        var _n;
                                        if(id == loginUserData.id){
                                            _n = '你';
                                        }
                                        else {
                                            var _e = util.getContactDataById(id, "p");
                                            if(_e){
                                                _n = _e.name;
                                            }
                                        }
                                        if(_n){
                                            _html.push(_n);
                                        }
                                    });
                                    _s += _html.join("、") + "移出群对话";
                                    break;
                                case systemPrompt.name:
                                    if (content.V) {
                                        _s = "将群对话的名称修改为:" + content.V;
                                    }
                                    else {
                                        _s = "取消了群对话名称";
                                    }
                                    break;
                            }
                            o.content = _s;
                            break;
                        case messageTypes.text:
                        default:
                            content = content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/[\n\r]/g, '<br/>').replace(new RegExp(' ', 'g'), '&nbsp;');
                            content = content.replace(httpReg, function (httpText) {
                                var protocolReg = /https{0,1}|ftp/gi;
                                return '<a href="' + (protocolReg.test(httpText) ? '' : 'http://') + httpText + '" target="_blank">' + httpText + '</a>';
                            });
                            content = util.emoji(content);
                            o.content = content;
                    }
                    if (tmpls) {
                        return tmpls[o.typeName](o);
                    }
                    return o;
                },
Ejemplo n.º 5
0
            _.each(files,function(file){
            	var str = "";
                var tagHtml = "";
 				if(!file.canPreview){
 					str = "fn-hide";
 				}
                _.each(file.tags,function(tag){
                    tagHtml += "<a class = 'crm-attachment-tag' data-value = '"+tag+"'>"+tag+"</a>&nbsp;"
                });
          	    html += "<tr fileId = '"+file.attachID+"tr' class = 'crm-attachment-file-tr'><td><div class='mn-checkbox-box'><span class = 'mn-checkbox-item crm-attachment-checkbox-single' data-value = '"+file.attachID+"'></span></div></td>";
          	    html += "<td><img title = '"+file.attachName+"' src='"+FS.BLANK_IMG+"' alt='icon' class='crm-attachment-image fs-attach-"+util.getFileType({"name":file.attachName},true)+"-small-icon file-icon fn-left'/><div class ='crm-attachment-file-name fn-left fn-text-overflow' title = '"+file.attachName+"'>"+file.attachName+"</div></td>";
          	    html += "<td class = 'crm-attachment-file-td'>"+util.getFileSize(file.attachSize)+"</td>";
			    html += "<td class = 'crm-attachment-file-td'>"+tagHtml+"</td>";
			    html += "<td class = 'crm-attachment-file-td'>"+file.employee.name+"</td>";
			    html += "<td class = 'crm-attachment-file-td'>"+moment.unix(file.createTime).format('YYYY年MMMDD日')+"</td>";
			    html += "<td><a fileId = '"+file.attachID+"' data-name = '"+file.attachName+"' class = 'crm-attachment-file-rename'>重命名</a><a  href = '"+ util.getDfLink(file.attachPath, file.attachName, true)+"' title = '"+file.attachName+"' target ='_blank'>下载</a><a data-attachID = '"+file.attachID+"' data-attachName = '"+file.attachName+"' data-attachPath = '"+file.attachPath+"' class = 'crm-attachment-file-preview "+str+"'>预览</a></td></tr>";
            });