size.x){
if (!this.flowInforScrollFx) this.flowInforScrollFx = new Fx.Scroll(this.flowInforScrollNode, {"wheelStops": false});
this.flowInforScrollFx.toRight();
this.flowInforLeftNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/processor/left.png)");
this.flowInforLeftNode.addEvent("click", function(){this.toFlowInforLeft();}.bind(this));
this.flowInforRightNode.addEvent("click", function(){this.toFlowInforRight();}.bind(this));
}
},
createFlowInforWorklogNode: function(activityName, taskCompleteList, taskList, idx, isCurrent){
if (idx!=0) var logLineNode = new Element("div", {"styles": this.list.css.logLineNode}).inject(this.flowInforContentNode);
var logActivityNode = new Element("div", {"styles": this.list.css.logActivityNode}).inject(this.flowInforContentNode);
var logActivityIconNode = new Element("div", {"styles": this.list.css.logActivityIconNode}).inject(logActivityNode);
var logActivityTextNode = new Element("div", {"styles": this.list.css.logActivityTextNode, "text": activityName}).inject(logActivityNode);
var iconName = "user";
var iconSuffix = "";
if ((taskCompleteList.length+taskList.length)>1) iconName = "users";
if (isCurrent) iconSuffix = "_red";
var inforNode = new Element("div", {"styles": this.list.css.logInforNode});
taskCompleteList.each(function(route){
var routeNode = new Element("div", {"styles": this.list.css.logRouteNode}).inject(inforNode);
routeNode.set("text", route.person.substring(0, route.person.indexOf("@"))+": ");
var opinionNode = new Element("div", {"styles": this.list.css.logOpinionNode}).inject(inforNode);
if (!route.opinion) route.opinion = "";
opinionNode.set("text", "["+route.routeName+"] "+route.opinion);
var timeNode = new Element("div", {"styles": this.list.css.logTimeNode}).inject(inforNode);
timeNode.set("text", route.completedTime);
if (this.list.app.desktop.session.user.distinguishedName === route.person) if (!iconSuffix) iconSuffix = "_yellow";
}.bind(this));
taskList.each(function(task){
var taskTextNode = new Element("div", {"styles": this.list.css.taskTextNode}).inject(inforNode);
taskTextNode.set("text", task.person.substring(0, task.person.indexOf("@"))+" "+this.list.app.lp.processing);
}.bind(this));
var icon = "url("+"../x_component_process_TaskCenter/$Main/default/processor/"+iconName+iconSuffix+".png)";
logActivityIconNode.setStyle("background-image", icon);
if (taskList.length){
var countNode = new Element("div", {"styles": this.list.css.logTaskCountNode}).inject(logActivityNode);
//var text = (taskList.length>99) ? "99+" : taskList.length;
var text = taskList.length;
countNode.set("text", text);
}
new mBox.Tooltip({
content: inforNode,
setStyles: {content: {padding: 10, lineHeight: 20}},
attach: logActivityNode,
transition: 'flyin',
offset: {
x: this.list.app.contentNode.getScroll().x,
y: this.list.listScrollAreaNode.getScroll().y
}
});
},
setProcessor: function(){
var _self = this;
MWF.xDesktop.requireApp("process.Work", "Processor", function(){
new MWF.xApplication.process.Work.Processor(this.processNode, this.data, {
"style": "task",
"mediaNode": this.mainContentNode,
"onCancel": function(){
_self.closeEditTask();
delete this;
},
"onSubmit": function(routeName, opinion, medias){
_self.submitTask(routeName, opinion, medias, this);
delete this;
}
})
}.bind(this));
},
addMessage: function(data){
if (layout.desktop.message){
var content = "";
if (data.length){
data.each(function(work){
var users = [];
work.taskList.each(function(task){
users.push(task.person+"("+task.department+")");
}.bind(this));
content += ""+this.list.app.lp.nextActivity+""+work.fromActivityName+", "+this.list.app.lp.nextUser+""+users.join(", ")+"
"
}.bind(this));
}else{
content += this.list.app.lp.workCompleted;
}
var msg = {
"subject": this.list.app.lp.taskProcessed,
"content": ""+this.list.app.lp.taskProcessedMessage+"“"+this.data.title+"”
"+content
};
layout.desktop.message.addTooltip(msg);
layout.desktop.message.addMessage(msg);
}
},
submitTask: function(routeName, opinion, medias, processor, flag){
if (!opinion) opinion = routeName;
this.data.routeName = routeName;
this.data.opinion = opinion;
var mediaIds = [];
if (medias.length){
medias.each(function(file){
var formData = new FormData();
formData.append("file", file);
//formData.append("fileName", (new MWF.UUID()).toString()+".wav");
formData.append("site", "$mediaOpinion");
this.list.app.action.uploadAttachment(this.data.work, formData, file, function(json){
mediaIds.push(json.data.id);
}.bind(this), null, false);
}.bind(this));
}
if (mediaIds.length) this.data.mediaOpinion = mediaIds.join(",");
this.list.app.action.processTask(function(json){
// this.list.app.notice(this.list.app.lp.taskProcessed, "success");
if (processor) processor.destroy();
if (!flag){
this.closeEditTask(function(){
this.node.destroy();
this.list.refresh();
this.addMessage(json.data);
delete this;
}.bind(this));
}else{
this.node.destroy();
this.list.refresh();
this.addMessage(json.data);
delete this;
}
}.bind(this), null, this.data.id, this.data);
},
resizeEditNode: function(){
var p = this.getEditNodePosition();
var size = this.list.app.content.getSize();
var maskNode = this.list.app.window.node.getElement("#mask_"+this.data.id);
if (maskNode) maskNode.setStyles({"width": ""+size.x+"px", "height": ""+size.y+"px"});
this.mainContentNode.setStyles({"top": ""+ p.y+"px", "left": ""+ p.x +"px"});
},
getEditNodePosition: function(){
var size = this.list.app.content.getSize();
var p = this.node.getPosition(this.list.app.content);
var top = p.y;
var left = p.x;
var w = this.list.css.itemNode_edit.width.toInt();
var h = this.list.css.itemNode_edit.height.toInt();
if (top+h>size.y){
top = size.y-h;
if (top<0) top=0;
}
if (left+w>size.x){
left = size.x-w;
if (left<0) left=0;
}
// var top = size.y/2-230;
// var left = size.x/2-260;
// if (top<0) top = 0;
return {"x": left, "y": top};
},
showEditNode: function(data, callback){
if (layout.mobile){
this.showEditNode_mobile(data, callback);
}else{
this.showEditNode_pc(data, callback);
}
},
showEditNode_mobile: function(data, callback){
var p = this.list.app.tabAreaNode.getPosition(this.list.app.content);
var contentSize = this.list.app.contentNode.getSize();
var tabSize = this.list.app.tabAreaNode.getSize();
var y = contentSize.y+tabSize.y;
this.list.css.itemNode_edit.top = ""+ p.y+"px";
this.list.css.itemNode_edit.left = ""+ p.x+"px";
this.list.css.itemNode_edit.width = ""+ contentSize.x+"px";
this.list.css.itemNode_edit.height = ""+ y+"px";
document.body.setStyle("-webkit-overflow-scrolling", "auto");
this.editNode.setStyle("display", "none");
var morph = new Fx.Morph(this.mainContentNode, {
"duration": 200,
"transition": Fx.Transitions.Expo.easeOut,
"onComplete": function(){
this.resizeEditNodeFun = this.resizeEditNode.bind(this);
this.list.app.addEvent("resize", this.resizeEditNodeFun);
this.setEditTaskNodes(data);
this.closeNode.setStyle("display", "block");
if (callback) callback();
}.bind(this)
});
morph.start(this.list.css.itemNode_edit);
},
showEditNode_pc: function(data, callback){
var p = this.getEditNodePosition();
this.list.css.itemNode_edit.top = ""+ p.y+"px";
this.list.css.itemNode_edit.left = ""+ p.x+"px";
this.editNode.setStyle("display", "none");
var morph = new Fx.Morph(this.mainContentNode, {
"duration": 200,
"transition": Fx.Transitions.Expo.easeOut,
"onComplete": function(){
this.resizeEditNodeFun = this.resizeEditNode.bind(this);
this.list.app.addEvent("resize", this.resizeEditNodeFun);
this.setEditTaskNodes(data);
this.closeNode.setStyle("display", "block");
if (callback) callback();
}.bind(this)
});
morph.start(this.list.css.itemNode_edit);
},
_getJobByTask: function(callback){
this.list.app.action.getSimpleJobByTask(function(json){
if (callback) callback(json.data);
}.bind(this), null, this.data.id);
},
setContent: function(){
this.applicationTitleNode.set("text", this.data.applicationName);
this.titleNode.set("html", "["+this.data.processName+"] "+o2.txt(this.data.title));
this.titleNode.set("title", this.data.title);
this.activityNode.set("text", "( "+(this.data.activityName || this.list.app.lp.completed)+" )");
this.timeContentNode.set("text", this.list.app.lp.list_comedate+": "+this.data.startTime);
this.loadActions();
this.loadApplicationIcon();
//this.setTimeIconNode();
},
loadActions: function(){
if (this.data.allowRapid){
this.editNode = new Element("div", {"styles": this.list.css.titleActionEditNode}).inject(this.actionContentNode);
this.closeNode = new Element("div", {"styles": this.list.css.titleActionCloseNode}).inject(this.actionContentNode);
}
},
loadApplicationIcon: function(){
this.getApplicationIcon(function(icon){
if (icon.icon){
//this.mainContentNode.setStyle("border-top", "4px solid "+icon.iconHue);
this.applicationIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon.icon+")");
}else{
this.mainContentNode.setStyle("border-top", "4px solid #4e82bd");
this.applicationIconNode.setStyle("background-image", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
}
}.bind(this));
},
getApplicationIcon: function(callback){
var icon = this.list.app.appIcons[this.data.application];
if (!icon) {
this.list.app.action.getApplicationIcon(function (json) {
if (json.data){
if (json.data){
this.list.app.appIcons[this.data.application] = json.data;
if (callback) callback(json.data);
}
}else{
this.invalidItem = true;
if (callback) callback({
"icon": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEgElEQVR4Xu1aPXMTSRB9vUaGQqs6iCgi4Bfgq7I2lqWrSwgQMQHyPzAJIeguvOT4BxbBxYjgkquTrFiiCvkXYCKKCFMSFEjs9tWsrEKWvTtfuyvXrTbd6ZnuN69fz842IecP5Tx+rAFYMyDnCKxTYBUE4MrWta9UuLu49hWeHlJveJy1P6kzQAT7eWPzPgN1MFeI6FpckMx8DKIeAe2iP3mVNiipADALuvAIQAOgLbtd5SGAVtGfvkgDjMQB+Fz1ngXgPdlO64IimOGAnhe7/d90bePGJwbAuOY9AqMJwu0kHTwzF+MIhKbb6b9IYh1rAATdxxub+yRyPMOHgbbrT3Zt08IKgHGlvIUN7NvnuSlyPISPXbc3EDph9BgDMPplu4KAXiad67pRhFXD4Qelf1/3dG3FeCMARPDEzoHJgmnZMAU7JiBoAyBozw4OVr3zy0AKJlCAHd100ALgpL4frC7nZfzhYdGf7ugIoxYAo5r3Mmu1l4V8hglAu9TpP1C1UwZgXC03QLSvOvFKxzHvut1BS8UHDQC8t6kfclQ8VhnDOHK7/TsqQ5UAGFW9JhGeqUy4PIZu3AR/eG9iChtbcPDY7b5+LltYCkB40nMKb01U/9Kv93D5yVN8++N3fP/nb5kvp97b2IqJRFVwg+kdmSBKARhXt/dAzp9a3gOYBzC30wHBxvaUnwoskANQK7/RLXvLAeiAYGN7dpN46HYGP8dtXiwAJ5cZH3V2X+Tt1b/akSZxTIgKfj7Zl4d1bT0p+pPrcWkQC4Bp6ZMFch4IJjZKGyMpibEAjGpem4D7SgstDdIJSGesri8MvCp1+pGf6vEAVMsfTdR/7qRKYGKsqBRRj454njeHqAal7uB61PzxKVDzWBfx5fEyEOLmtw1+Prfb6UfGGfnCRACjgjEBIanghU9GACT9za8DQpLBh4eimLuCSAYkDYBwRAWEpINfA3BRGKCy+zonRh1xNkqB3IugQHic5zIoABjVyscE+kmHbotjZbQXgpf6QQj8qdQZRP6QXR+F43Y39x9DJkL4v/ocDoWw6g1BONXNIdMEm0sNG9szfjEO3W4/tj9BfiOU9yux2e/vwpFJNbC52LSxDY+/4E+uP71tfSkalsM8X4vP82pc9URnxi1Z/l+I94x3brev1Kki1YAfAOT819jsZGh+R5gVM2R3gMt+KDMgFBbR/uZs9nTLYlbBg3FYDCYVmfAt+qMFQHguEA0SG+iZVIU0gRCqTz4qqTZIzANI47bIFpzMWmQWQQBTe9VMEDsP4rpJf5CIRTsFFncqbJNzqLUyTWAcIuCGLu2tNGCZqieNki3TP0im1Bdq7/qTho7gnbeWFQNOsUG00IBEq2y6hyXGO4Cbqi0wMoATA+DHgWl7j4maSWtDqPIsApd3fciCTjQFzltsdl641ACchrU+iDxH0CoG31u2dE81BaJQn4FRqDNRXRylZMwIVR3UI+Z2MZi20wg6dQaoUDDsNV54TMuYylpxYxLXAFuHsrZfA5A14hdtvTUDLtqOZO1P7hnwH8CljF98DV13AAAAAElFTkSuQmCC",
"iconHue": "#4e82bd"
});
}
}.bind(this), function(){
this.invalidItem = true;
if (callback) callback({
"icon": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEgElEQVR4Xu1aPXMTSRB9vUaGQqs6iCgi4Bfgq7I2lqWrSwgQMQHyPzAJIeguvOT4BxbBxYjgkquTrFiiCvkXYCKKCFMSFEjs9tWsrEKWvTtfuyvXrTbd6ZnuN69fz842IecP5Tx+rAFYMyDnCKxTYBUE4MrWta9UuLu49hWeHlJveJy1P6kzQAT7eWPzPgN1MFeI6FpckMx8DKIeAe2iP3mVNiipADALuvAIQAOgLbtd5SGAVtGfvkgDjMQB+Fz1ngXgPdlO64IimOGAnhe7/d90bePGJwbAuOY9AqMJwu0kHTwzF+MIhKbb6b9IYh1rAATdxxub+yRyPMOHgb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0CoG31u2dE81BaJQn4FRqDNRXRylZMwIVR3UI+Z2MZi20wg6dQaoUDDsNV54TMuYylpxYxLXAFuHsrZfA5A14hdtvTUDLtqOZO1P7hnwH8CljF98DV13AAAAAElFTkSuQmCC",
"iconHue": "#f44336"
});
}.bind(this), this.data.application);
}else{
if (callback) callback(icon);
}
},
setNewIcon: function(){
var start = new Date().parse(this.data.startTime);
var now = new Date();
if (now.getTime()-start.getTime()<86400000){
this.newIconNode.setStyle("background-image", "url("+"../x_component_process_TaskCenter/$Main/default/time/new.png)");
}
},
setTimeIconNode: function(){
var colors = ["#FF0000", "#00d400", "#f6ff0c"];
var idx = (Math.random()*3).toInt();
var color = colors[idx];
this.timeIconNode.setStyle("background-color", color);
//timeIconNode
}
//load: function(){
// this.node = this.table.insertRow(this.table.rows.length || 0);
// this.node.setStyles(this.list.css.itemLine);
//
// this.appNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.applicationName}).inject(this.node);
// this.titleNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.title}).inject(this.node);
// this.processNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.processName}).inject(this.node);
// this.activityNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.activityName}).inject(this.node);
// this.dateNode = new Element("td", {"styles": this.list.css.itemCell, "text": this.data.updateTime}).inject(this.node);
//
//
// //this.titleNode = this.node.insertCell(this.node.cells.length || 0);
// //this.titleNode.setStyles(this.list.css.itemCell);
// //this.titleNode.set("text", this.data.title);
//}
});