MWF.xApplication.process.Application.options.multitask = true;
o2.xDesktop.requireApp("Selector", "package", null, false);
MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
MWF.xDesktop.requireApp("Template", "MForm", null, false);
MWF.xApplication.process.Application.Main = new Class({
Extends: MWF.xApplication.Common.Main,
Implements: [Options, Events],
options: {
"style1": "default",
"style": "default",
"name": "process.Application",
"mvcStyle": "style.css",
"icon": "icon.png",
"application": "",
"id": "",
"navi" : "all",
"title": MWF.xApplication.process.Application.LP.title
},
onQueryLoad: function(){
this.lp = MWF.xApplication.process.Application.LP;
this.action = o2.Actions.load("x_processplatform_assemble_surface");
if (this.status) {
if(this.status.id)this.options.id = this.status.id;
if(this.status.navi){
this.options.navi = this.status.navi;
}
}
this._loadCss();
},
loadApplication: function(callback){
this.initAcl(function (){
this.loadProcessList(function (){
this.action.ApplicationAction.get(this.options.id).then(function (json){
if (json.data){
this.setTitle(this.lp.title+"-"+json.data.name);
this.application = json.data;
var url = this.path+this.options.style+"/view/view.html";
this.content.loadHtml(url, {"bind": {"acl":this.acl,"lp": this.lp,"data":{"application" : this.application}}, "module": this}, function(){
this.setLayout();
this.loadList(this.options.navi);
if (callback) callback();
}.bind(this));
}
}.bind(this));
}.bind(this));
}.bind(this));
},
loadApplicationIcon : function (e){
var node = e.currentTarget;
if (this.application.icon){
node.setStyle("background-image", "url(data:image/png;base64,"+this.application.icon+")");
}else{
node.setStyle("background-image", "url("+"../x_component_process_Application/$Main/default/icon/application.png)");
}
},
initAcl : function (callback){
this.acl = {
}
this.action.ApplicationAction.isManager(this.options.id).then(function (json){
this.acl.isAppManager = json.data.value;
this.action.ProcessAction.listControllableWithApplication(this.options.id).then(function (json){
var processList = json.data.valueList;
if(processList.length>0){
this.acl.isProcessManager = true;
}else {
this.acl.isProcessManager = false;
}
this.acl.processList = json.data.valueList;
if(callback) callback();
}.bind(this));
}.bind(this));
},
loadProcessList : function (callback){
this.action.ProcessAction.listWithPersonWithApplication(this.options.id).then(function (json){
this.processList = json.data;
if(callback) callback();
}.bind(this));
},
createCountData: function(){
var _self = this;
if (!this.countData){
this.countData = {"data": {}};
var createDefineObject = function(p){
return {
"get": function(){return this.data[p]},
"set": function(v){
this.data[p] = v;
_self[p+"CountNode"].set("text", v);
}
}
};
var o = {
"task": createDefineObject("task"),
"taskCompleted": createDefineObject("taskCompleted"),
"read": createDefineObject("read"),
"readCompleted": createDefineObject("readCompleted"),
"draft": createDefineObject("draft"),
};
MWF.defineProperties(this.countData, o);
}
},
loadCount: function(){
this.createCountData();
this.action.WorkAction.countWithPersonAndApplication(layout.session.user.id,this.application.id).then(function(json){
this.countData.task = json.data.task;
this.countData.taskCompleted = json.data.taskCompleted;
this.countData.read = json.data.read;
this.countData.readCompleted = json.data.readCompleted;
}.bind(this));
this.action.DraftAction.listMyPaging(1,1, {"applicationList":[this.application.id]}).then(function(json){
this.countData.draft = json.count;
}.bind(this));
},
loadList: function(type,ev,data){
if (this.currentMenu) this.setMenuItemStyleDefault(this.currentMenu);
this.setMenuItemStyleCurrent(this[type+"MenuNode"]);
this.currentMenu = this[type+"MenuNode"];
this._loadListContent(type);
this.loadCount();
},
_loadListContent: function(type){
this.mainNode.empty();
list = new MWF.xApplication.process.Application[type.capitalize() +"List"](this.mainNode,this, {
"onLoadData": function (){
this.hideSkeleton();
},
"type" : type,
"key" : this.options.key
});
this.currentList = list;
},
setLayout: function(){
var items = this.content.getElements(".menuItem");
items.addEvents({
"mouseover": function(){this.addClass("menuItem_over")},
"mouseout": function(){this.removeClass("menuItem_over")},
"click": function(){}
});
},
startProcess: function(){
this.action.ProcessAction.listWithPersonWithApplication(this.application.id).then(function (json){
var node = new Element("div");
var url = this.path+this.options.style+"/view/dlg/processList.html";
node.loadHtml(url, {"bind": {"lp": this.lp,"processList":json.data}, "module": this}, function(){
this.startProcessDlg = o2.DL.open({
"title": this.lp.startProcess,
"width": "400px",
"height": "260px",
"mask": true,
"content": node,
"container": null,
"positionNode": this.content,
"onQueryClose": function () {
node.destroy();
}.bind(this),
"buttonList": [
],
"onPostShow": function () {
this.startProcessDlg.reCenter();
}.bind(this)
});
}.bind(this));
}.bind(this));
},
startProcessItemOver: function(e){
var node = e.target;
while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
if (node){
node.addClass("menuItem_over");
node.removeClass("mainColor_bg");
}
},
startProcessItemOut: function(e){
var node = e.target;
while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
if (node){
node.removeClass("menuItem_over");
node.removeClass("mainColor_bg");
}
},
startProcessItemDown: function(e){
var node = e.target;
while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
if (node){
node.removeClass("menuItem_over");
node.addClass("mainColor_bg");
}
},
startProcessItemUp: function(e){
var node = e.target;
while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
if (node){
node.addClass("menuItem_over");
node.removeClass("mainColor_bg");
}
},
startProcessItemClick: function(e, data){
this.startProcessDlg.close();
MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(data, this, {
"onStarted": function(workdata, title, processName){
this.afterStartProcess(workdata, title, processName, data);
}.bind(this)
});
starter.load();
}.bind(this));
},
afterStartProcess: function(data, title, processName, processdata){
if (data.work){
this.startProcessDraft(data, title, processName);
}else{
this.startProcessInstance(data, title, processName);
}
},
startProcessDraft: function(data, title, processName){
var work = data.work;
var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false,
"onPostClose": function(){
if (this.currentList.refresh) this.currentList.refresh();
}.bind(this)
};
this.desktop.openApplication(null, "process.Work", options);
},
startProcessInstance: function(data, title, processName){
var workInfors = [];
var currentTask = [];
data.each(function(work){
if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
workInfors.push(this.getStartWorkInforObj(work));
}.bind(this));
if (currentTask.length===1){
var options = {"workId": currentTask[0], "appId": "process.Work"+currentTask[0],
"onPostClose": function(){
if (this.currentList.refresh) this.currentList.refresh();
}.bind(this)
};
this.desktop.openApplication(null, "process.Work", options);
if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
}else{
if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
}
},
getStartWorkInforObj: function(work){
var users = [];
var currentTask = "";
work.taskList.each(function(task, idx){
users.push(task.person+"("+task.department + ")");
if (work.currentTaskIndex===idx) currentTask = task.id;
}.bind(this));
return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
},
setMenuItemStyleDefault: function(node){
node.removeClass("mainColor_bg_opacity");
node.getFirst().removeClass("mainColor_color");
node.getLast().removeClass("mainColor_color");
},
setMenuItemStyleCurrent: function(node){
node.addClass("mainColor_bg_opacity");
node.getFirst().addClass("mainColor_color");
node.getLast().addClass("mainColor_color");
},
recordStatus: function(){
return { "id": this.options.id};
}
});
MWF.xApplication.process.Application.List = new Class({
Implements: [Options, Events],
options: {
"type": "all",
"itemHeight": 40,
},
initialize: function (node,app, options) {
this.setOptions(options);
this.app = app;
this.container = node;
this.lp = this.app.lp;
this.css = this.app.css;
this.action = app.action;
this.type = this.options.type;
this.application = app.application;
var url = this.app.path+this.app.options.style+"/view/content.html";
this.container.loadHtml(url, {"bind": {"lp": this.lp,"data":{"type":this.type}}, "module": this}, function(){
this.content = this.listContentNode;
this.bottomNode = this.listBottomNode;
this.pageNode = this.pageNumberAreaNode;
this.init();
this.load();
}.bind(this));
},
loadFilter: function () {
var lp = this.lp;
this.fileterNode = new Element("div.fileterNode", {
"styles": this.css.fileterNode
}).inject(this.searchNode);
var html = "
" + //style='width: 900px;'
"" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"
" +
"" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"
" +
"
";
this.fileterNode.set("html", html);
this.form = new MForm(this.fileterNode, {}, {
style: "attendance",
isEdited: true,
itemTemplate: {
title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
activityName: {text: lp.activity, "type": "text", "style": {"min-width": "150px"}},
processName: {
text: lp.process,
"type": "text",
"style": {"min-width": "150px"},
"event": {
"click": function (item, ev){
var v = item.getValue();
o2.xDesktop.requireApp("Selector", "package", function(){
var options = {
"type": "Process",
"values": v!==""?[item.getValue().split("|")[1]] : [],
"count": 1,
"onComplete": function (items) {
var arr = [];
var arr2 = [];
items.each(function (data) {
arr.push(data.data);
arr2.push(items[0].data.name+"|"+items[0].data.id);
});
item.setValue(arr2.join(","));
}.bind(this)
};
new o2.O2Selector(this.app.desktop.node, options);
}.bind(this),false);
}.bind(this)}
},
credentialList: {
"text": lp.creator,
"type": "org",
"orgType": "identity",
"orgOptions": {"resultType": "person"},
"style": {"min-width": "150px"},
"orgWidgetOptions": {"disableInfor": true}
},
creatorUnitList: {
"text": lp.createunit,
"type": "org",
"orgType": "unit",
"orgOptions": {"resultType": "person"},
"style": {"min-width": "150px"},
"orgWidgetOptions": {"disableInfor": true}
},
startTime: {
text: lp.begin,
"tType": "date",
"style": {"min-width":"150px"}
},
endTime: {
text: lp.end,
"tType": "date",
"style": {"min-width":"150px"}
},
action: {
"value": this.lp.query, type: "button", className: "filterButton", event: {
click: function () {
var result = this.form.getResult(false, null, false, false, false);
for (var key in result) {
if (!result[key]) {
delete result[key];
} else if (key === "activityName" && result[key].length > 0) {
//result[key] = result[key][0].split("@")[1];
result["activityNameList"] = [result[key]];
delete result[key];
}else if (key === "processName" && result[key] !== "") {
//result[key] = result[key][0].split("@")[1];
result["processList"] = [result[key].split("|")[1]];
delete result[key];
}else if (key === "endTime" && result[key] !== "") {
result[key] = result[key] + " 23:59:59"
}
}
result.applicationList = this.filterList.applicationList;
if(result.credentialList) {
result.creatorPersonList = result.credentialList;
}
this.filterList = result;
this.refresh();
}.bind(this)
}
},
reset: {
"value": this.lp.reset, type: "button", className: "filterButtonGrey", event: {
click: function () {
this.form.reset();
this._initFilter();
this.refresh();
}.bind(this)
}
},
}
}, this.app, this.css);
this.form.load();
},
showSkeleton: function(){
if (this.skeletonNode) this.skeletonNode.inject(this.listContentNode);
},
hideSkeleton: function(){
if (this.skeletonNode) this.skeletonNode.dispose();
},
loadListTitle : function (){
this.listTitleNode.empty();
this.listTitleNode.loadHtml(this.titleTempleteUrl, {"bind": {"lp": this.lp}, "module": this}, function(){
this.currentSortNode = this.sortUpdateTimeNode;
this.currentSortKey = "name";
}.bind(this));
},
selectAll : function (e){
if (e.currentTarget.get("disabled").toString()!="true"){
var itemNode = e.currentTarget.getParent(".listItem");
var iconNode = e.currentTarget.getElement(".selectFlagIcon");
if (itemNode){
if (itemNode.hasClass("mainColor_bg_opacity")){
itemNode.removeClass("mainColor_bg_opacity");
iconNode.removeClass("icon-xuanzhong");
iconNode.removeClass("selectFlagIcon_select");
iconNode.removeClass("mainColor_color");
this.listContentNode.getElements("tr").each(function (tr){
tr.removeClass("mainColor_bg_opacity");
var ss = tr.getElement(".selectFlagIcon");
tr.getElement(".selectFlag").hide();
ss.removeClass("icon-xuanzhong");
ss.removeClass("selectFlagIcon_select");
ss.removeClass("mainColor_color");
})
this.selectedList = [];
}else{
itemNode.addClass("mainColor_bg_opacity");
iconNode.addClass("icon-xuanzhong");
iconNode.addClass("selectFlagIcon_select");
iconNode.addClass("mainColor_color");
this.listContentNode.getElements("tr").each(function (tr){
tr.getElement(".selectFlag").show();
tr.addClass("mainColor_bg_opacity");
var ss = tr.getElement(".selectFlagIcon");
ss.addClass("icon-xuanzhong");
ss.addClass("selectFlagIcon_select");
ss.addClass("mainColor_color");
})
this.selectedList.append(this.dataList);
}
}
}
this._setToolBar();
},
loadItems: function(data){
this.dataList = data;
this.content.loadHtml(this.listTempleteUrl, {"bind": {"lp": this.lp, "type": this.options.type, "data": data}, "module": this}, function(){
this.node = this.content.getFirst();
}.bind(this));
},
init: function(){
this.listHeight = this.content.getSize().y - this.options.itemHeight - 60;
this.size = (this.listHeight/this.options.itemHeight).toInt();
this.size = 15;
this.page = 1;
this.loadFilter();
this._initFilter();
this.filterNameList = {};
},
_initFilter : function(){
this.filterList = {
applicationList : [this.application.id]
};
},
_initTempate: function () {
this.titleTempleteUrl = this.app.path + this.app.options.style + "/view/" + this.type + "/list_title.html";
this.listTempleteUrl = this.app.path + this.app.options.style + "/view/" + this.type + "/list.html";
},
load: function(){
var _self = this;
this._initToolBar();
this._initTempate();
this.loadListTitle();
if(this.toolbarItems.unSelect.length>0){
this.loadToolBar(this.toolbarItems.unSelect);
}else {
this.loadToolBar(this.toolbarItems.default,true);
}
this.selectedList = [];
this.loadData().then(function(data){
_self.hide();
_self.loadPage();
_self.loadItems(data);
});
},
_initToolBar : function (){
this.toolbarItems = {
"default":[
],
"unSelect":[
],
"selected":[
],
"mulSelect":[
]
}
},
loadToolBar : function (availableTool,disabled){
this.toolBarNode.empty();
this.toolbar = new MWF.xApplication.process.Application.Toolbar(this.toolBarNode, this, {
viewType : this.options.defaultViewType,
type : this.type,
disabled : !!disabled,
availableTool : availableTool
});
this.toolbar.load();
if(availableTool.length===0){
this.toolBarNode.hide();
}else {
this.toolBarNode.show();
}
},
refresh: function(){
this.hide();
this.load();
this.app.loadCount();
},
hide: function(){
if (this.node) this.node.destroy();
},
loadPage: function(){
var totalCount = this.total;
var pages = totalCount/this.size;
var pageCount = pages.toInt();
if (pages !== pageCount) pageCount = pageCount+1;
this.pageCount = pageCount;
var size = this.bottomNode.getSize();
var maxPageSize = 500;//size.x*0.8;
maxPageSize = maxPageSize - 80*2-24*2-10*3;
var maxPageCount = (maxPageSize/34).toInt();
this.loadPageNode(pageCount, maxPageCount);
},
loadPageNode: function(pageCount, maxPageCount){
var pageStart = 1;
var pageEnd = pageCount;
if (pageCount>maxPageCount){
var halfCount = (maxPageCount/2).toInt();
pageStart = Math.max(this.page-halfCount, 1);
pageEnd = pageStart+maxPageCount-1;
pageEnd = Math.min(pageEnd, pageCount);
pageStart = pageEnd - maxPageCount+1;
}
this.pageNode.empty();
var _self = this;
for (var i=pageStart; i<=pageEnd; i++){
var node = new Element("div.pageItem", {
"text": i,
"events": { "click": function(){_self.gotoPage(this.get("text"));} }
}).inject(this.pageNode);
if (i==this.page) node.addClass("mainColor_bg");
}
},
nextPage: function(){
this.page++;
if (this.page>this.pageCount) this.page = this.pageCount;
this.gotoPage(this.page);
},
prevPage: function(){
this.page--;
if (this.page<1) this.page = 1;
this.gotoPage(this.page);
},
firstPage: function(){
this.gotoPage(1);
},
lastPage: function(){
this.gotoPage(this.pageCount);
},
gotoPage: function(page){
this.page = page;
this.hide();
this.showSkeleton();
this.load();
},
loadData: function(){
},
_fixData : function (dataList){
dataList.each(function (data){
data.creatorPersonName = data.creatorPerson.split("@")[0];
data.creatorUnitName = data.creatorUnit.split("@")[0];
}.bind(this));
return dataList;
},
overTaskItem: function(e){
e.currentTarget.addClass("listItem_over");
var iconNode = e.currentTarget.getElement(".selectFlagIcon");
if (iconNode.hasClass("selectFlagIcon_select")){
}else{
e.currentTarget.getElement(".selectFlag").show();
}
},
outTaskItem: function(e){
e.currentTarget.removeClass("listItem_over");
var iconNode = e.currentTarget.getElement(".selectFlagIcon");
if (iconNode.hasClass("selectFlagIcon_select")){
}else{
e.currentTarget.getElement(".selectFlag").hide();
}
},
loadItemIcon: function(application, e){
return
this.app.loadItemIcon(application, e);
},
selectFile: function(id,e, dataList){
var data ;
for(var i = 0 ; i < this.dataList.length;i++){
if(this.dataList[i].id === id){
data = this.dataList[i];
break ;
}
}
if (e.currentTarget.get("disabled").toString()!="true"){
var itemNode = e.currentTarget.getParent(".listItem");
var iconNode = e.currentTarget.getElement(".selectFlagIcon");
if (itemNode){
if (itemNode.hasClass("mainColor_bg_opacity")){
itemNode.removeClass("mainColor_bg_opacity");
iconNode.removeClass("icon-xuanzhong");
iconNode.removeClass("selectFlagIcon_select");
iconNode.removeClass("mainColor_color");
this.unselectedFile(data);
}else{
itemNode.addClass("mainColor_bg_opacity");
iconNode.addClass("icon-xuanzhong");
iconNode.addClass("selectFlagIcon_select");
iconNode.addClass("mainColor_color");
this.selectedFile(data);
}
}
}
this._setToolBar();
},
_setToolBar : function (){
if(this.selectedList.length === 0 ){
if(this.toolbarItems.unSelect.length>0){
this.loadToolBar(this.toolbarItems.unSelect);
}else {
this.loadToolBar(this.toolbarItems.default,true);
}
} else if (this.selectedList.length === 1){
this.loadToolBar(this.toolbarItems.selected);
}else{
this.loadToolBar(this.toolbarItems.mulSelect);
}
},
selectedFile: function(data){
if (!this.selectedList) this.selectedList = [];
var idx = this.selectedList.findIndex(function(t){
return t.id == data.id;
});
if (idx===-1) this.selectedList.push(data);
},
unselectedFile: function(data){
// delete data._;
if (!this.selectedList) this.selectedList = [];
var idx = this.selectedList.findIndex(function(t){
return t.id == data.id;
});
if (idx!==-1) this.selectedList.splice(idx, 1);
},
open : function (work,workCompleted){
var options = {
"workId": work,
"workCompletedId": workCompleted,
"appId": "process.Work" + work
};
layout.desktop.openApplication(null, "process.Work", options);
}
});
MWF.xApplication.process.Application.AllList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
this.filterList.relateTask = true;
return this.action.ReviewAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
loadFilter: function () {
var lp = this.lp;
this.fileterNode = new Element("div.fileterNode", {
"styles": this.css.fileterNode
}).inject(this.searchNode);
var html = "" + //style='width: 900px;'
"" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"
" +
"" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"
" +
"
";
this.fileterNode.set("html", html);
var selectValue = [""];
var selectText = [""];
this.app.processList.each(function(d){
selectValue.push(d.id);
selectText.push(d.name);
})
this.form = new MForm(this.fileterNode, {}, {
style: "attendance",
isEdited: true,
itemTemplate: {
title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
processName: {
"text": lp.process,
"type": "select",
"selectValue" :selectValue,
"selectText" :selectText,
"style": {"min-width": "150px"},
},
credentialList: {
"text": lp.creator,
"type": "org",
"orgType": "identity",
"orgOptions": {"resultType": "person"},
"style": {"min-width": "150px"},
"orgWidgetOptions": {"disableInfor": true}
},
creatorUnitList: {
"text": lp.createunit,
"type": "org",
"orgType": "unit",
"orgOptions": {"resultType": "person"},
"style": {"min-width": "150px"},
"orgWidgetOptions": {"disableInfor": true}
},
startTime: {
text: lp.begin,
"tType": "date",
"style": {"min-width":"150px"}
},
endTime: {
text: lp.end,
"tType": "date",
"style": {"min-width":"150px"}
},
action: {
"value": this.lp.query, type: "button", className: "filterButton", event: {
click: function () {
var result = this.form.getResult(false, null, false, false, false);
for (var key in result) {
if (!result[key]) {
delete result[key];
} else if (key === "activityName" && result[key].length > 0) {
//result[key] = result[key][0].split("@")[1];
result["activityNameList"] = [result[key]];
delete result[key];
}else if (key === "processName" && result[key] !== "") {
//result[key] = result[key][0].split("@")[1];
result["processList"] = [result[key]];
delete result[key];
}else if (key === "endTime" && result[key] !== "") {
result[key] = result[key] + " 23:59:59"
}
}
result.applicationList = this.filterList.applicationList;
if(result.credentialList) {
result.creatorPersonList = result.credentialList;
}
this.filterList = result;
this.refresh();
}.bind(this)
}
},
reset: {
"value": this.lp.reset, type: "button", className: "filterButtonGrey", event: {
click: function () {
this.form.reset();
this._initFilter();
this.refresh();
}.bind(this)
}
},
}
}, this.app, this.css);
this.form.load();
},
_fixData : function (dataList){
dataList.each(function (data){
data.creatorPersonName = data.creatorPerson.split("@")[0];
data.creatorUnitName = data.creatorUnit.split("@")[0];
if(data.completed) {
data.activityName = "结束";
}else {
if(data.taskList.length >0){
data.activityName = data.taskList[0].activityName;
}
}
}.bind(this));
return dataList;
},
});
MWF.xApplication.process.Application.TaskList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
return this.action.TaskAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
});
MWF.xApplication.process.Application.TaskDoneList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
this.filterList = this.filterList||{};
this.filterList.latest = true;
return this.action.TaskCompletedAction.V2ListPaging(this.page, this.size, this.filterList).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
});
MWF.xApplication.process.Application.ReadList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
return this.action.ReadAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
});
MWF.xApplication.process.Application.ReadDoneList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
return this.action.ReadCompletedAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
});
MWF.xApplication.process.Application.DraftList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
return this.action.DraftAction.listMyPaging(this.page, this.size, this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
_fixData : function (dataList){
dataList.each(function(d){
if(d.title === "") d.title = this.lp.unnamed;
}.bind(this));
return dataList;
},
loadFilter: function () {
var lp = this.lp;
this.fileterNode = new Element("div.fileterNode", {
"styles": this.css.fileterNode
}).inject(this.searchNode);
var html = "" + //style='width: 900px;'
"" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"
" +
"
";
this.fileterNode.set("html", html);
var selectValue = [""];
var selectText = [""];
this.app.processList.each(function(d){
selectValue.push(d.id);
selectText.push(d.name);
})
this.form = new MForm(this.fileterNode, {}, {
style: "attendance",
isEdited: true,
itemTemplate: {
title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
processName: {
"text": lp.process,
"type": "select",
"selectValue" :selectValue,
"selectText" :selectText,
"style": {"min-width": "150px"},
},
startTime: {
text: lp.begin,
"tType": "date",
"style": {"min-width":"150px"}
},
endTime: {
text: lp.end,
"tType": "date",
"style": {"min-width":"150px"}
},
action: {
"value": lp.query, type: "button", className: "filterButton", event: {
click: function () {
var result = this.form.getResult(false, null, false, false, false);
for (var key in result) {
if (!result[key]) {
delete result[key];
} else if (key === "activityName" && result[key].length > 0) {
//result[key] = result[key][0].split("@")[1];
result["activityNameList"] = [result[key]];
delete result[key];
}else if (key === "processName" && result[key] !== "") {
//result[key] = result[key][0].split("@")[1];
result["processList"] = [result[key]];
delete result[key];
}else if (key === "endTime" && result[key] !== "") {
result[key] = result[key] + " 23:59:59"
}
}
this.filterList = result;
this.refresh();
}.bind(this)
}
},
reset: {
"value": lp.reset, type: "button", className: "filterButtonGrey", event: {
click: function () {
this.form.reset();
this._initFilter();
this.refresh();
}.bind(this)
}
},
}
}, this.app, this.css);
this.form.load();
},
open : function (id){
var options = {
"draftId": id,
"appId": "process.Work" + id
};
layout.desktop.openApplication(null, "process.Work", options);
}
});
MWF.xApplication.process.Application.WorkList = new Class({
Extends: MWF.xApplication.process.Application.List,
loadData: function(){
var _self = this;
this.filterList.relateEditionProcess = true;
return this.action.WorkAction.manageListWithApplicationPaging(this.page, this.size, this.application.id,this.filterList||{}).then(function(json){
_self.fireEvent("loadData");
_self.total = json.count;
return _self._fixData(json.data);
}.bind(this));
},
_initToolBar : function (){
this.toolbarItems = {
"default":[
["delWork","jump","sendRead"],
["processing","endWork","addReview"],
["manage"]
],
"unSelect":[
],
"selected":[
["delWork","jump","sendRead"],
["processing","endWork","addReview"],
["manage"]
],
"mulSelect":[
["delWork"],
["processing","endWork","addReview"]
]
}
},
open : function (id){
var options = {
"workId": id,
"appId": "process.Work" + id
};
layout.desktop.openApplication(null, "process.Work", options);
},
manage : function (id,ev,dataList){
var data ;
for(var i = 0 ; i < dataList.length;i++){
if(dataList[i].id === id){
data = dataList[i];
break ;
}
}
this._manage(data);
},
_manage : function (data){
var form;
form = new MWF.xApplication.process.Application.ManageWorkForm({app: this.app}, data );
form.open();
},
delete : function(id,e){
var _self = this;
this.app.confirm("warn", e,"删除确认!!", {
"html": "
请选择删除方式?
软删除(可恢复)" +
"
硬删除(不能恢复)"
}, 400, 200, function(){
var inputs = this.content.getElements("input");
var flag = "";
for (var i=0; i请选择删除方式?
软删除(可恢复)" +
"
硬删除(不能恢复)"
}, 400, 200, function(){
var inputs = this.content.getElements("input");
var flag = "";
for (var i=0; i请选择删除方式?
软删除(可恢复)" +
"
硬删除(不能恢复)"
}, 400, 200, function(){
var inputs = this.content.getElements("input");
var flag = "";
for (var i=0; i请选择删除方式?
软删除(可恢复)" +
"
硬删除(不能恢复)"
}, 400, 280, function(){
var inputs = this.content.getElements("input");
var flag = "";
for (var i=0; i请选择文件要回溯到的位置:";
html += "并尝试继续流转
";
html += "";
node.set("html", html);
var rollbackItemNode = node.getLast();
this.getRollbackLogs(rollbackItemNode,data.id);
//node.inject(this.app.content);
var dlg = o2.DL.open({
"title": "回溯",
"style": "user",
"isResize": false,
"content": node,
"width": 600,
"height" : 400,
"buttonList": [
{
"type": "ok",
"text": "确定",
"action": function (d, e) {
this.doRollback(node, e, dlg ,data.id);
}.bind(this)
},
{
"type": "cancel",
"text": "取消",
"action": function () { dlg.close(); }
}
]
});
},
doRollback: function (node, e, dlg ,workid) {
var rollbackItemNode = node.getLast();
var items = rollbackItemNode.getChildren();
var flowOption = (node.getElement(".rollback_flowOption").checked);
var _self = this;
for (var i = 0; i < items.length; i++) {
if (items[i].retrieve("isSelected")) {
var text = "您确定要将流程回溯到“{log}”状态吗?(流程回溯会清除此状态之后的所有信息)";
var log = items[i].retrieve("log");
var checks = items[i].getElements("input:checked");
var idList = [];
checks.each(function (check) {
var id = check.get("value");
if (idList.indexOf(id) == -1) idList.push(id);
});
text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
this.explorer.app.confirm("infor", e, "流程回溯确认", text, 450, 120, function () {
// console.log(log.id)
// console.log(flowOption)
// //console.log(dlg)
// console.log(idList)
_self.app.action.WorkCompletedAction.rollback(workid,{ "workLog": log.id },function (json){
_self.app.notice("回溯成功。");
_self.explorer.refresh();
},null,false);
dlg.close();
this.close();
}, function () {
this.close();
});
break;
}
}
},
getRollbackLogs: function (rollbackItemNode,id) {
var _self = this;
var data ;
this.app.action.WorkLogAction.listRollbackWithWorkOrWorkCompleted(id).then(function (json){
var dataList = json.data;
dataList.each(function (log) {
if (!log.splitting && log.connected) {
var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
node.store("log", log);
var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": "办理人: " }).inject(div);
if (log.taskCompletedList.length) {
log.taskCompletedList.each(function (o) {
var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
var check = new Element("input", {
"value": o.identity,
"type": "checkbox",
"disabled": true,
"styles": this.css.rollbackItemTaskCheckNode
}).inject(div);
check.addEvent("click", function (e) {
e.stopPropagation();
});
var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
}.bind(this));
} else {
var text = "系统自动处理";
var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
}
node.addEvents({
"mouseover": function () {
var isSelected = this.retrieve("isSelected");
if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
},
"mouseout": function () {
var isSelected = this.retrieve("isSelected");
if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
},
"click": function () {
var isSelected = this.retrieve("isSelected");
if (isSelected) {
_self.setRollBackUnchecked(this);
} else {
var items = rollbackItemNode.getChildren();
items.each(function (item) {
_self.setRollBackUnchecked(item);
});
_self.setRollBackChecked(this);
}
}
});
}
}.bind(this));
}.bind(this));
},
setRollBackChecked: function (item) {
item.store("isSelected", true);
item.setStyles(this.css.rollbackItemNode_current);
item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
var node = item.getLast().getFirst();
node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
node = item.getLast().getLast();
node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
var checkeds = item.getElements("input");
if (checkeds){
checkeds.set("checked", true);
checkeds.set("disabled", false);
}
},
setRollBackUnchecked: function (item) {
item.store("isSelected", false);
item.setStyles(this.css.rollbackItemNode);
item.getFirst().setStyles(this.css.rollbackItemIconNode);
var node = item.getLast().getFirst();
node.getFirst().setStyles(this.css.rollbackItemActivityNode);
node.getLast().setStyles(this.css.rollbackItemTimeNode);
node = item.getLast().getLast();
node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
node.getLast().setStyles(this.css.rollbackItemTaskNode);
var checkeds = item.getElements("input");
if (checkeds) {
checkeds.set("checked", false);
checkeds.set("disabled", true);
}
},
loadRightNode : function(){
this.toolabrRightNode = new Element("div.toolabrRightNode",{
"style": "float:right"
}).inject(this.node);
//this.loadSearch();
},
loadSearch : function (){
var searchNode = new Element("div.ft_titleSearchArea",{"style":"width:300px"}).inject(this.toolabrRightNode);
var searchIconNode = new Element("div.ft_filterIcon",{"html":''}).inject(searchNode);
var searchBtn = new Element("div",{"class":"ft_searchButton mainColor_bg","text":"搜索"}).inject(searchNode);
var searchInput = new Element("div.ft_titleInputArea").inject(searchNode);
new Element("input",{"placeholder" : "请输入关键字"}).inject(searchInput);
},
getListType : function(){
return this.viewType || this.options.viewType
},
loadListType : function(){
this.listViewTypeNode = new Element("div", {
"style" : "font-size:18px;float:left;margin-right:6px",
"class" : this.options.viewType == "list" ? "mainColor_color" : "",
events : {
click : function(){
this.viewType = "list";
this.explorer.options.defaultViewType = this.viewType;
this.explorer.refresh();
}.bind(this)
}
}).inject(this.toolabrRightNode);
new Element("icon",{"class":"o2Drive icon-list"}).inject(this.listViewTypeNode);
this.tileViewTypeNode = new Element("div", {
"style" : "font-size:18px;float:left",
"class" : this.options.viewType !== "list" ? "mainColor_color" : "",
events : {
click : function(){
this.viewType = "tile";
this.explorer.options.defaultViewType = this.viewType;
this.explorer.refresh();
}.bind(this)
}
}).inject(this.toolabrRightNode);
new Element("icon",{"class":"o2Drive icon-grid"}).inject(this.tileViewTypeNode);
}
});
MWF.xApplication.process.Application.AddSerSialForm = new Class({
Extends: MPopupForm,
Implements: [Options, Events],
options: {
"style": "attendanceV2",
"width": 500,
//"height": 300,
"height": "350",
"hasTop": true,
"hasIcon": false,
"draggable": true,
"title" : "新增流水号",
"id" : ""
},
_createTableContent: function () {
var html = "" +
" | " +
" | " +
"
" +
" | " +
" | " +
"
" +
" | " +
" |
" +
"
";
this.formTableArea.set("html", html);
this.form = new MForm(this.formTableArea, this.data || {}, {
isEdited: true,
style : "attendance",
hasColon : true,
itemTemplate: {
name: { text : "关键字", notEmpty : true },
serial: { text : "流水号", notEmpty : true },
process: {
"text": "流程",
"type": "text",
"notEmpty" : true,
"defaultValue":this.data.processName,
"event": {
"click": function (item, ev){
var v = item.getValue();
o2.xDesktop.requireApp("Selector", "package", function(){
var options = {
"type": "Process",
"values": [],
"count": 1,
"applicationId" : this.app.application.id,
"onComplete": function (items) {
if(items.length>0){
var d = items[0].data;
this.data.processId = d.id;
item.setValue(d.name);
}
}.bind(this)
};
new o2.O2Selector(this.app.desktop.node, options);
}.bind(this),false);
}.bind(this)}
}
}
}, this.app);
this.form.load();
},
_createBottomContent: function () {
if (this.isNew || this.isEdited) {
this.okActionNode = new Element("button.inputOkButton", {
"styles": this.css.inputOkButton,
"text": "确定"
}).inject(this.formBottomNode);
this.okActionNode.addEvent("click", function (e) {
this.save(e);
}.bind(this));
}
this.cancelActionNode = new Element("button.inputCancelButton", {
"styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
"text": "关闭"
}).inject(this.formBottomNode);
this.cancelActionNode.addEvent("click", function (e) {
this.close(e);
}.bind(this));
},
save: function(){
var data = this.form.getResult(true,null,true,false,true);
if( data ){
debugger
this.app.action.SerialNumberAction.create({
"application" : this.app.application.id,
"process" : data.processId,
"name" : data.name,
"serial" : data.serial
}).then(function (){
this.app.notice("添加成功");
this.explorer.refresh();
this.close();
}.bind(this));
}
}
});
MWF.xApplication.process.Application.SetSerSialForm = new Class({
Extends: MPopupForm,
Implements: [Options, Events],
options: {
"style": "attendanceV2",
"width": 500,
//"height": 300,
"height": "200",
"hasTop": true,
"hasIcon": false,
"draggable": true,
"title" : "设置流水号",
"id" : ""
},
_createTableContent: function () {
var html = "";
this.formTableArea.set("html", html);
this.form = new MForm(this.formTableArea, this.data || {}, {
isEdited: true,
style : "minder",
hasColon : true,
itemTemplate: {
serial: { text : "流水号", notEmpty : true }
}
}, this.app);
this.form.load();
},
_createBottomContent: function () {
if (this.isNew || this.isEdited) {
this.okActionNode = new Element("button.inputOkButton", {
"styles": this.css.inputOkButton,
"text": "确定"
}).inject(this.formBottomNode);
this.okActionNode.addEvent("click", function (e) {
this.save(e);
}.bind(this));
}
this.cancelActionNode = new Element("button.inputCancelButton", {
"styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
"text": "关闭"
}).inject(this.formBottomNode);
this.cancelActionNode.addEvent("click", function (e) {
this.close(e);
}.bind(this));
},
save: function(){
var data = this.form.getResult(true,null,true,false,true);
if( data ){
debugger
this.app.action.SerialNumberAction.update(data.id,{
"application" : data.application,
"process" : data.process,
"serial" : data.serial
}).then(function (){
this.app.notice("更新成功");
this.explorer.refresh();
this.close();
}.bind(this));
}
}
});
MWF.xApplication.process.Application.ManageWorkForm = new Class({
Extends: MPopupForm,
Implements: [Options, Events],
options: {
"style": "attendanceV2",
"width": "1000",
"height": "700",
"hasTop": true,
"hasIcon": false,
"hasTopIcon" : false,
"hasTopContent" : false,
"draggable": true,
"maxAction" : true,
"resizeable" : true,
"closeAction": true,
"title": MWF.xApplication.process.Application.LP.adminwork,
"hideBottomWhenReading": true,
"closeByClickMaskWhenReading": true,
},
_postLoad: function(){
if(this.data.completedTime){
this.isCompletedWork = true;
}
this._createTableContent_();
},
_createTableContent: function(){},
_createTableContent_: function () {
//this.formTableArea.set("html", this.getHtml());
this.formTableContainer.setStyle("width","95%");
this.formTableContainer.setStyle("margin","0px auto 10px");
this.loadTab();
},
loadTab : function (){
this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.formTableArea);
this.taskArea = new Element("div",{"style" : "height:500px;overflow:auto" }).inject(this.tabNode);
this.taskDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.readArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.readDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.reviewArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.attachementArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.recordArea = new Element("div",{"style" : "height:550px;overflow:auto" }).inject(this.tabNode);
this.businessDataArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
MWF.require("MWF.widget.Tab", function(){
this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
this.tabs.load();
this.taskPage = this.tabs.addTab(this.taskArea, this.lp.task, false);
this.taskPage.addEvent("show",function(){
if(!this.initTask) this.loadTask();
}.bind(this));
this.taskDonePage = this.tabs.addTab(this.taskDoneArea, this.lp.taskDone, false);
this.taskDonePage.addEvent("show",function(){
if(!this.initTaskDone) this.loadTaskDone();
}.bind(this));
this.readPage = this.tabs.addTab(this.readArea, this.lp.read, false);
this.readPage.addEvent("show",function(){
if(!this.initRead) this.loadRead();
}.bind(this));
this.readDonePage = this.tabs.addTab(this.readDoneArea, this.lp.readDone, false);
this.readDonePage.addEvent("show",function(){
if(!this.initReadDone) this.loadReadDone();
}.bind(this));
this.recordPage = this.tabs.addTab(this.recordArea, this.lp.workLog, false);
this.recordPage.addEvent("show",function(){
if(!this.initRecord) this.loadRecord();
}.bind(this));
this.reviewPage = this.tabs.addTab(this.reviewArea, this.lp.review, false);
this.reviewPage.addEvent("show",function(){
if(!this.initReview) this.loadReview();
}.bind(this));
this.attachementPage = this.tabs.addTab(this.attachementArea, this.lp.attachment, false);
this.attachementPage.addEvent("show",function(){
if(!this.initAttachement) this.loadAttachement();
}.bind(this));
this.businessDataPage = this.tabs.addTab(this.businessDataArea,this.lp.businessData, false);
this.businessDataPage.addEvent("show",function(){
if(!this.initBusinessData) this.loadBusinessData();
}.bind(this));
this.tabs.pages[0].showTab();
}.bind(this));
},
loadTask : function () {
this.app.action.TaskAction.listWithJob(this.data.job).then(function(json){
this.taskList = json.data;
this._loadTask();
this.initTask = true;
}.bind(this));
},
_loadTask : function (){
this.taskArea.empty();
this.taskContentNode = new Element("div").inject(this.taskArea);
var taskTableNode = new Element("table.table",{
"border" : 0,
"cellpadding" : 5,
"cellspacing" : 0
}).inject(this.taskContentNode);
var taskTableTheadNode = new Element("thead").inject(taskTableNode);
var taskTableTbodyNode = new Element("tbody").inject(taskTableNode);
var taskTableTheadTrNode = new Element("tr").inject(taskTableTheadNode);
Array.each([this.lp.currentPerson, this.lp.currentDept, this.lp.activity, this.lp.startTime, this.lp.action], function (text) {
new Element("th", {"text": text}).inject(taskTableTheadTrNode);
});
this.taskList.each(function (task) {
var trNode = new Element("tr").inject(taskTableTbodyNode);
trNode.store("data", task);
Array.each([task.person.split("@")[0], task.unit.split("@")[0], task.activityName, task.startTime], function (text) {
new Element("td", {
text: text
}).inject(trNode);
});
var tdOpNode = new Element("td").inject(trNode);
var restButton = new Element("button", {"text": this.lp.resetAction, "class": "button"}).inject(tdOpNode);
var deleteButton = new Element("button", {"text": this.lp.remove, "class": "button"}).inject(tdOpNode);
_self = this;
deleteButton.addEvent("click", function (e) {
_self.app.confirm("warn", e, _self.lp.tip, this.lp.tip_remove, 350, 120, function () {
_self.app.action.TaskAction.manageDelete(task.id,function (){},null,false);
_self.loadTask();
this.close();
}, function(){
this.close();
});
}.bind(this));
restButton.addEvent("click", function (ev) {
var opt = {
"type": "identity",
"count": 0,
"title": _self.lp.resetAction,
"onComplete": function (items) {
var _self = this;
var nameArr = [];
items.each(function(item){
nameArr.push(item.data.name)
});
this.explorer.app.confirm("warn", ev,_self.lp.tip_reset, {
"html": _self.lp.rest_content.replace("(name)",nameArr.join())
}, 400, 300, function(){
var inputs = this.content.getElements("input");
var opinion = this.content.getElement("textarea").get("value");
var flag = "";
for (var i=0; i" +
" | " +
" | " +
" | " +
" | " +
" | " +
" | " +
"" +
"" +
" | " +
" | " +
" | " +
"
" +
""
workDataContentNode.set("html", html);
this.form = new MForm(workDataContentNode, {}, {
style: "attendance",
isEdited: true,
itemTemplate: {
fieldList: {
"text": "字段列表",
"type": "select",
"style": {"max-width": "150px"},
"selectValue": function () {
var arr = [""];
arr.append(Object.keys(workData));
return arr;
},
"event": {
"change": function (item, ev) {
var type = typeof(workData[item.getValue()]);
item.form.getItem("fieldType").setValue(type);
item.form.getItem("fieldName").setValue(item.getValue());
if(type === "object" || type === "array"){
item.form.getItem("fieldValue").setValue(JSON.stringify(workData[item.getValue()]));
}else {
item.form.getItem("fieldValue").setValue(workData[item.getValue()]);
}
}.bind(this)
}
},
fieldType: {
"text": "字段类型",
"type": "select",
"style": {"max-width": "150px"},
"selectValue": function () {
var array = ["","array","boolean","string","number","object"];
return array;
},
"event": {
"change": function (item, ev) {
}.bind(this)
}
},
fieldName: {text: "字段名", "type": "text", "style": {"min-width": "100px"}},
fieldValue: {text: "字段值", "type": "textarea", "style": {"width": "100%","margin-left": "10px"}},
action: {
"value": "修改", type: "button", className: "filterButton", event: {
click: function (e) {
var result = this.form.getResult(false, null, false, false, false);
var fieldName = result["fieldName"];
var fieldType = result["fieldType"];
var fieldValue = result["fieldValue"];
if (!fieldName) return false;
workData[fieldName] = (fieldType === "object" ? JSON.parse(fieldValue) : fieldValue);
_self = this;
this.app.confirm("warn", e.node, "提示", "确认是否修改", 350, 120, function () {
if(_self.isCompletedWork){
_self.app.action.DataAction.updateWithWorkCompleted(_self.data.id,workData,function (json){},null,false);
}else{
_self.app.action.DataAction.updateWithWork(_self.data.id,workData,function (json){},null,false);
}
_self.app.notice("success");
_self.loadScriptEditor();
this.close();
}, function(){
this.close();
});
}.bind(this)
}
}
}
}, this.app, this.css);
this.form.load();
this.loadScriptEditor();
},
loadScriptEditor:function(){
if( !this.workData )return;
MWF.require("MWF.widget.JavascriptEditor", null, false);
var workDataNode = this.formTableContainer.getElement('[item="workData"]');
this.scriptEditor = new MWF.widget.JavascriptEditor(workDataNode, {
"forceType": "ace",
"option": { "mode" : "json" }
});
this.scriptEditor.load(function(){
this.scriptEditor.setValue(JSON.stringify(this.workData, null, "\t"));
this.scriptEditor.editor.setReadOnly(true);
this.addEvent("afterResize", function () {
this.resizeScript();
}.bind(this))
this.addEvent("queryClose", function () {
}.bind(this))
this.resizeScript();
}.bind(this));
},
resizeScript: function () {
var size = this.formTableContainer.getSize();
var tableSize = this.formTableContainer.getElement('table').getSize();
this.formTableContainer.getElement('[item="workData"]').setStyle("height", size.y - 200);
if (this.scriptEditor && this.scriptEditor.editor) this.scriptEditor.editor.resize();
},
getFileSize: function (size) {
if (!size)
return "";
var num = 1024.00; //byte
if (size < num)
return size + "B";
if (size < Math.pow(num, 2))
return (size / num).toFixed(2) + "K"; //kb
if (size < Math.pow(num, 3))
return (size / Math.pow(num, 2)).toFixed(2) + "M"; //M
if (size < Math.pow(num, 4))
return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G
},
});
MWF.xApplication.process.Application.ManageWorkCompletedForm = new Class({
Extends: MWF.xApplication.process.Application.ManageWorkForm,
loadTab : function (){
this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.formTableArea);
this.taskDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.readArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.readDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.reviewArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.attachementArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.recordArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
this.businessDataArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
MWF.require("MWF.widget.Tab", function(){
this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
this.tabs.load();
this.taskDonePage = this.tabs.addTab(this.taskDoneArea, this.lp.taskDone, false);
this.taskDonePage.addEvent("show",function(){
if(!this.initTaskDone) this.loadTaskDone();
}.bind(this));
this.readPage = this.tabs.addTab(this.readArea, this.lp.read, false);
this.readPage.addEvent("show",function(){
if(!this.initRead) this.loadRead();
}.bind(this));
this.readDonePage = this.tabs.addTab(this.readDoneArea, this.lp.readDone, false);
this.readDonePage.addEvent("show",function(){
if(!this.initReadDone) this.loadReadDone();
}.bind(this));
this.recordPage = this.tabs.addTab(this.recordArea, this.lp.workLog, false);
this.recordPage.addEvent("show",function(){
if(!this.initRecord) this.loadRecord();
}.bind(this));
this.reviewPage = this.tabs.addTab(this.reviewArea, this.lp.review, false);
this.reviewPage.addEvent("show",function(){
if(!this.initReview) this.loadReview();
}.bind(this));
this.attachementPage = this.tabs.addTab(this.attachementArea, this.lp.attachment, false);
this.attachementPage.addEvent("show",function(){
if(!this.initAttachement) this.loadAttachement();
}.bind(this));
this.businessDataPage = this.tabs.addTab(this.businessDataArea, this.lp.businessData, false);
this.businessDataPage.addEvent("show",function(){
if(!this.initBusinessData) this.loadBusinessData();
}.bind(this));
this.tabs.pages[0].showTab();
}.bind(this));
}
});