12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
- MWF.xApplication.cms = MWF.xApplication.cms || {};
- MWF.xApplication.cms.Index = MWF.xApplication.cms.Index || {};
- //MWF.xDesktop.requireApp("cms.Index", "Actions.RestActions", null, false);
- MWF.require("MWF.xAction.org.express.RestActions", null, false);
- MWF.require("MWF.widget.Mask", null, false);
- MWF.xApplication.cms.Index.Newer = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "popupStyle" : "o2platform",
- "width": "850",
- "height": "510",
- "hasTop": true,
- "hasIcon": false,
- "hasTopContent" : true,
- "hasBottom": false,
- //"title": MWF.xApplication.cms.Index.LP.createDocument,
- "draggable": true,
- "closeAction": true,
- "latest" : true,
- "ignoreTitle" : false,
- "ignoreDrafted" : false,
- "selectColumnEnable" : true,
- "restrictToColumn" : false,
- "documentData" : null,
- "identity" : null,
- "searchEnable": true,
- //autoSave : "",
- //saveOnClose : "",
- "categoryFlag" : "", //category id or name
- "columnFlag" : "",//column id or name
- "appFlag" : "" //column id or name
- },
- initialize: function (columnData, categoryData, app, view, options) {
- debugger;
- this.path = "../x_component_cms_Index/$Newer/";
- this.cssPath = "../x_component_cms_Index/$Newer/"+this.options.style+"/css.wcss";
- this._loadCss();
- MWF.xDesktop.requireApp("cms.Index", "$Newer.lp."+MWF.language, null, false);
- this.lp = MWF.xApplication.cms.Index.Newer.lp;
- this.options.title = this.lp.createDocument;
- this.orginOptions = {};
- if(o2.typeOf(options)==="object"){
- this.orginOptions = Object.clone(options);
- }
- this.setOptions(options);
- this.columnData = columnData;
- this.categoryData = categoryData;
- this.app = app;
- this.view = view;
- this.container = this.app.content;
- if( !this.columnData ){
- this.initData();
- }
- this.parseConfig();
- this.documentAction = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Index.Actions.RestActions();
- //this.orgAction = new MWF.xAction.org.express.RestActions();
- },
- initData : function(){
- var appId = this.options.appFlag || this.options.columnFlag;
- if( !this.columnData && appId){
- MWF.Actions.get("x_cms_assemble_control").getColumn( appId, function( json ){
- this.columnData = json.data
- }.bind(this), null, false)
- }
- var categoryId = this.options.categoryFlag;
- if( !this.categoryData && categoryId ){
- MWF.Actions.get("x_cms_assemble_control").getCategory( categoryId, function(js){
- this.categoryData = js.data;
- if( !this.columnData ){
- MWF.Actions.get("x_cms_assemble_control").getColumn( this.categoryData.appId, function( json ){
- this.columnData = json.data;
- }.bind(this), null, false)
- }
- }.bind(this), null, false)
- }
- },
- parseConfig: function(){
- if( this.columnData ) {
- this.columnData.config = this.columnData.config || {};
- if (typeOf(this.columnData.config) === "string") {
- this.columnData.config = JSON.parse(this.columnData.config || "{}");
- } else {
- this.columnData.config = Object.clone(this.columnData.config || {});
- }
- var options = this.orginOptions;
- if (typeOf(options.ignoreTitle) !== "boolean" && typeOf(this.columnData.config.ignoreTitle) === "boolean") {
- this.options.ignoreTitle = this.columnData.config.ignoreTitle;
- }
- if (typeOf(options.latest) !== "boolean" && typeOf(this.columnData.config.latest) === "boolean") {
- this.options.latest = this.columnData.config.latest;
- }
- }
- },
- load : function(){
- this.initData();
- this.identityList = this.getIdentities();
- if( !this.categoryData ) { //如果未限定分类
- this._load();
- this.fireEvent("postLoad");
- }else if(this.categoryData.workflowAppId && this.categoryData.workflowFlag ){ //发起审批流程
- this._load();
- this.fireEvent( "postLoad" );
- }else if( this.options.ignoreDrafted ){
- this._load();
- this.fireEvent( "postLoad" );
- }else{
- var fielter = {
- "categoryIdList": [this.categoryData.id ],
- "creatorList": [layout.desktop.session.user.distinguishedName]
- };
- debugger
- this.documentAction.listDraftNext("(0)", 1, fielter, function(json){
- if( json.data.length > 0 ){
- var handle = this._openDocument(json.data[0].id);
- this.fireEvent("started", [json.data[0].id, json.data[0], handle]);
- this.fireEvent( "postLoad" );
- }else{
- this._load();
- this.fireEvent( "postLoad" );
- }
- }.bind(this));
- }
- },
- _load : function(){
- if( this.categoryData && this.isIgnoreTitle() && this.identityList.length == 1 ) { //信息需要输入标题,数据不需要输入标题
- this.okStart();
- }else{
- this.isNew = true;
- this.isEdited = true;
- this._open();
- this.checkSubject();
- if( this.options.selectColumnEnable ){
- this.openSel();
- }
- }
- },
- openSel : function(){
- this.formTopTextNode.set("text", this.lp.selCategory);
- if( this.sel ){
- this.sel.load();
- }else{
- this.sel = new MWF.xApplication.cms.Index.Newer.CategorySel(this.app, this.formContentNode, this, this.columnData, this.categoryData, {
- restrictToColumn : this.options.restrictToColumn
- });
- this.sel.load();
- }
- },
- _loadCss: function(){
- var key = encodeURIComponent(this.cssPath);
- if (MWF.widget.css[key]){
- this.css = MWF.widget.css[key];
- }else{
- this.cssPath = (this.cssPath.indexOf("?")!=-1) ? this.cssPath+"&v="+COMMON.version : this.cssPath+"?v="+COMMON.version;
- var r = new Request.JSON({
- url: this.cssPath,
- secure: false,
- async: false,
- method: "get",
- noCache: false,
- onSuccess: function(responseJSON, responseText){
- this.css = responseJSON;
- MWF.widget.css[key] = responseJSON;
- }.bind(this),
- onError: function(text, error){
- alert(error + text);
- }
- });
- r.send();
- }
- },
- _createTableContent: function () {
- var categoryName = this.categoryData ? ( this.categoryData.name || this.categoryData.categoryName ) : this.lp.selectCategory;
- var html = "";
- if( this.options.selectColumnEnable ){
- this.selectArea = new Element("div",{styles:this.css.selectArea}).inject( this.formTableArea );
- this.selectContainer = new Element("div",{styles:this.css.selectContainer}).inject( this.selectArea );
- //html = "<table width='100%' height='90%' border='0' cellPadding='0' cellSpacing='0'>" +
- //"<tr>" +
- //"<td style='height: 40px; line-height: 40px; text-align: left; width: 40%' id='form_startColumn'></td>" +
- //"<td style='text-align: left;' id='form_startCategory'></td>" +
- //"</tr>" +
- //"</table>"
- html = "<div id='form_startColumn' style='float:left'></div><div id='form_startCategory' style='float:left'></div>";
- this.selectContainer.set("html", html);
- this.setSelectContent();
- }
- this.inputContainer = new Element("div",{styles:this.css.inputContainer}).inject( this.formTableArea );
- html = "<table width='100%' height='90%' border='0' cellPadding='0' cellSpacing='0'; >" +
- "<tr><td colSpan='2' style='height: 60px; line-height: 60px; text-align: center; font-size: 24px; ' id='form_startTitle'>" +
- this.lp.start+" - "+categoryName+"</td></tr>" +
- "<tr><td style='height: 38px; line-height: 38px; text-align: left; font-size:16px;color:#333;min-width: 100px;'>"+this.lp.department+":</td>" +
- "<td style='; text-align: left;' id='form_startDepartment'></td></tr>" +
- "<tr><td style='height: 38px; line-height: 38px; text-align: left; font-size:16px;color:#333'>"+this.lp.identity+":</td>" +
- "<td style='; text-align: left;'><div id='form_startIdentity'></div></td></tr>" +
- "<tr><td style='height: 38px; line-height: 38px; text-align: left; font-size:16px;color:#333'>"+this.lp.date+":</td>" +
- "<td style='; text-align: left;'><div id='form_startDate'></div></td></tr>" +
- "<tr><td style='height: 38px; line-height: 38px; text-align: left; font-size:16px;color:#333'>"+this.lp.subject+":</td>" +
- "<td style='; text-align: left;'><input type='text' id='form_startSubject' " +
- "style='width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC;height: 26px;'/></td></tr>" +
- "<tr><td style='height: 38px; line-height: 38px; text-align: left; font-size:16px;color:#333'></td>" +
- "<td style='text-align: left;' id='form_startAction'></td></tr>" +
- "</table>";
- this.inputContainer.set("html", html);
- this.setStartFormContent();
- this.startActionContainer = this.inputContainer.getElementById("form_startAction");
- this.startTitleNode = this.inputContainer.getElementById("form_startTitle");
- this.startOkActionNode = new Element("div", {
- "styles": this.css.startOkActionNode,
- "text": this.lp.ok
- }).inject(this.startActionContainer);
- this.startOkActionNode.addClass("mainColor_bg");
- this.startOkActionNode.addClass("mainColor_border");
- this.cancelActionNode = new Element("div", {
- "styles": this.css.cancelActionNode,
- "text": this.lp.cancel
- }).inject(this.startActionContainer);
- this.cancelActionNode.addEvent("click", function(e){
- this.cancelStart(e);
- }.bind(this));
- this.startOkActionNode.addEvent("click", function(e){
- this.okStart(e);
- }.bind(this));
- },
- isIgnoreTitle : function(){
- if( this.options.ignoreTitle )return true;
- return this.categoryData && ( ![this.lp.documentTypeInfor, "信息"].contains(this.categoryData.documentType));
- },
- checkSubject: function(){
- if( this.categoryData ){
- if( this.isIgnoreTitle() ){
- if(this.subjectInput)this.subjectInput.getParent("tr").setStyle("display","none");
- }else{
- if(this.subjectInput)this.subjectInput.getParent("tr").setStyle("display","");
- }
- }
- },
- setSelectContent: function(){
- this.columnContainer = this.selectContainer.getElementById("form_startColumn");
- this.columnContainer.setStyles( this.css.columnContainer );
- this.selectContainer.addEvents({
- mouseover : function(){
- this.columnSelectNode.setStyles( this.css.columnSelectNode_over );
- }.bind(this),
- mouseout : function(){
- this.columnSelectNode.setStyles( this.css.columnSelectNode );
- }.bind(this),
- click : function(){
- this.openSel();
- }.bind(this)
- });
- this.columnIconNode = new Element("img", {styles : this.css.columnIconNode }).inject( this.columnContainer );
- if( this.columnData ){
- if (this.columnData.appIcon){
- this.columnIconNode.set("src", "data:image/png;base64,"+this.columnData.appIcon+"");
- }else{
- this.columnIconNode.set("src", "../x_component_cms_Index/$Main/default/icon/column.png");
- }
- }else{
- this.columnIconNode.set("src","../x_component_cms_Index/$Main/default/icon/all_40.png");
- }
- this.columnTextNode = new Element("div", {
- styles : this.css.columnTextNode,
- text : this.lp.all
- } ).inject( this.columnContainer );
- this.columnSelectNode = new Element("div", {styles : this.css.columnSelectNode }).inject( this.columnContainer );
- this.categoryContainer = this.selectContainer.getElementById("form_startCategory");
- this.categoryContainer.setStyles( this.css.categoryContainer );
- this.categoryTextNode = new Element("div", {
- styles : this.css.categoryTextNode,
- text : this.lp.clickForSelect
- }).inject( this.categoryContainer );
- },
- setCurrentColumn: function( column ){
- if( this.currentColumn && this.currentColumn != column ){
- this.currentColumn.node.setStyles( this.css.columnItemNode );
- this.currentColumn.node.removeClass("mainColor_color");
- this.currentColumn.options.isCurrent = false;
- }
- this.currentColumn = column;
- },
- setCurrentCategory: function( category ){
- debugger;
- if( this.currentCategory && this.currentCategory != category ){
- this.currentCategory.node.setStyles( this.css.categoryItemNode );
- this.currentCategory.node.removeClass("mainColor_color");
- this.currentCategory.node.removeClass("mainColor_border");
- this.currentCategory.options.isCurrent = false;
- }
- this.currentCategory = category;
- var fielter = {
- "categoryIdList": [ category.data.id ],
- "creatorList": [layout.desktop.session.user.distinguishedName]
- };
- this.documentAction.getColumn( category.data.appId , function( json ) {
- this.columnData = json.data;
- this.parseConfig();
- this.documentAction.listDraftNext("(0)", 1, fielter, function (j) {
- if (j.data && j.data.length > 0 && this.options.latest) {
- this._openDocument(j.data[0].id);
- this.close();
- } else {
- if (this.columnData.appIcon) {
- this.columnIconNode.set("src", "data:image/png;base64," + this.columnData.appIcon + "");
- } else {
- this.columnIconNode.set("src", "../x_component_cms_Index/$Main/default/icon/column.png");
- }
- this.columnTextNode.set("text", this.columnData.appName);
- this.formTopTextNode.set("text", this.lp.createDocument);
- this.categoryData = category.data;
- this.checkSubject();
- this.categoryTextNode.set("text", this.categoryData.categoryName);
- this.startTitleNode.set("text", this.lp.start + " - " + this.categoryData.categoryName);
- if(this.sel){
- this.sel.closeArea();
- }
- if (this.isIgnoreTitle() && this.identityList.length == 1) {
- this.okStart();
- }
- }
- }.bind(this));
- }.bind(this));
- },
- setStartFormContent: function(){
- this.dateArea = this.formTableArea.getElementById("form_startDate");
- var d = new Date();
- this.dateArea.set("text", d.format("%Y-%m-%d %H:%M"));
- this.departmentSelArea = this.formTableArea.getElementById("form_startDepartment");
- this.identityArea = this.formTableArea.getElementById("form_startIdentity");
- this.subjectInput = this.formTableArea.getElementById("form_startSubject");
- this.loadDepartments();
- },
- getIdentities: function(){
- var identities = [];
- MWF.Actions.get("x_organization_assemble_personal").getPerson(function(json){
- var identities1 = (json.data && json.data.woIdentityList) ? json.data.woIdentityList : [];
- var identityList = typeOf( this.options.identity ) === "array" ? this.options.identity : [this.options.identity];
- identityList = identityList.filter(function( i ){ return !!i });
- identities1.each( function(i){
- if( identityList.length ){
- for( var j=0; j<identityList.length; j++ ){
- var identity = identityList[j] || "";
- var dn = (typeOf(identity)==="string") ? identity : identity.distinguishedName;
- if( dn && i.distinguishedName===dn ){
- i.index = j;
- identities.push(i);
- return;
- }
- }
- // if( this.options.identity == i.distinguishedName ){
- // if( i.distinguishedName )identities.push(i);
- // }
- }else{
- if( i.distinguishedName )identities.push(i);
- }
- }.bind(this));
- if(identityList.length){
- identities.sort( function (a, b) {
- return a.index - b.index;
- });
- }
- }.bind(this), null, false );
- return identities;
- },
- loadDepartments: function(){
- //MWF.Actions.get("x_organization_assemble_personal").getPerson(function(json){
- // var identities1 = (json.data && json.data.woIdentityList) ? json.data.woIdentityList : [];
- // var identities = [];
- // identities1.each( function(i){
- // if( i.distinguishedName )identities.push(i);
- // }.bind(this));
- // var selected = (identities.length==1) ? true : false;
- // identities.each(function(id){
- // var departSel = new MWF.xApplication.cms.Index.Newer.DepartmentSel(id, this, this.departmentSelArea, this.identityArea);
- // if (selected) departSel.selected();
- // }.bind(this));
- //}.bind(this), null )
- var identities = this.identityList || this.getIdentities() || [];
- var selected = (identities.length==1) ? true : false;
- identities.each(function(id){
- var departSel = new MWF.xApplication.cms.Index.Newer.DepartmentSel(id, this, this.departmentSelArea, this.identityArea);
- if (selected) departSel.selected();
- }.bind(this));
- },
- cancelStart: function(e){
- var _self = this;
- if ( this.subjectInput && this.subjectInput.get("value")){
- this.app.confirm("warn", e, this.lp.start_cancel_title, this.lp.start_cancel, "320", "120", function(){
- _self.close();
- this.close();
- },function(){
- this.close();
- });
- }else{
- this.close();
- }
- },
- okStart: function(){
- if( !this.categoryData ){
- this.app.notice(this.lp.selectCategory, "error");
- }else{
- if( this.categoryData.workflowAppId && this.categoryData.workflowFlag ){
- this._createProcessDocument();
- }else{
- this._createDocument();
- }
- }
- },
- _createDocument: function(e){
- var title = this.subjectInput ? this.subjectInput.get("value") : "";
- if( !title && this.options.documentData ){
- title = this.options.documentData.title || this.options.documentData.subject || "";
- }
- var identity = "";
- var identityList = typeOf( this.options.identity ) === "array" ? this.options.identity : [this.options.identity];
- identityList = identityList.filter(function( i ){ return !!i });
- if( identityList.length === 1 && identityList[0] ){
- identity = typeOf( identityList[0] ) === "string" ? identityList[0] : identityList[0].distinguishedName;
- }else if( this.identityArea ){
- identity = this.identityArea.get("value");
- }else if( this.identityList.length > 0 ){
- identity = this.identityList[0].distinguishedName;
- }
- var data = {
- "id" : this.documentAction.getUUID(),
- "isNewDocument" : true,
- "title": title,
- "creatorIdentity": identity,
- "identity" : identity,
- "appId" :this.categoryData.appId,
- "categoryId" : this.categoryData.id,
- "form" : this.categoryData.formId,
- "formName" :this.categoryData.formName,
- "docStatus" : "draft",
- "categoryName" : this.categoryData.name || this.categoryData.categoryName,
- "categoryAlias" : this.categoryData.alias || this.categoryData.categoryAlias,
- "attachmentList" : []
- };
- if( this.options.documentData ){
- data.docData = this.options.documentData;
- }
- if (!data.title && !this.isIgnoreTitle()){
- if(this.subjectInput)this.subjectInput.setStyle("border-color", "red");
- if(this.subjectInput)this.subjectInput.focus();
- this.app.notice(this.lp.inputSubject, "error");
- }else if (!data.creatorIdentity){
- this.departmentSelArea.setStyle("border-color", "red");
- this.app.notice(this.lp.selectStartId, "error");
- }else{
- if( this.isIgnoreTitle() && !data.title )data.title = this.lp.untitled;
- if( this.formAreaNode ){
- this.mask = new MWF.widget.Mask({"style": "desktop"});
- this.mask.loadNode(this.formAreaNode);
- }
- this.documentAction.addDocument( data, function(json){
- if( this.mask )this.mask.hide();
- //this.markNode.destroy();
- debugger;
- var handle = this._openDocument( json.data.id );
- this.fireEvent("started", [json.data.id, data, handle]);
- this.close();
- //this.fireEvent("started", [json.data, title, this.categoryData.name]);
- //this.app.refreshAll();
- this.app.notice(this.lp.Started, "success");
- // this.app.processConfig();
- }.bind(this), function(xhr, text, error){
- if( xhr && xhr.response && typeOf(xhr.response)==="string" ){
- try{
- var eObj = JSON.parse(xhr.response);
- this.app.notice( eObj.message, "error");
- }catch (e) {}
- }
- if( this.mask )this.mask.hide();
- }.bind(this));
- }
- },
- _openDocument: function(id,el){
- var _self = this;
- var appId = "cms.Document"+id;
- if (_self.app.desktop && _self.app.desktop.apps && _self.app.desktop.apps[appId]){
- _self.app.desktop.apps[appId].setCurrent();
- }else {
- var options = {
- "readonly" :false,
- "documentId": id,
- "appId": appId,
- "onPostPublish" : function( args ){
- this.fireEvent( "postPublish", args );
- }.bind(this),
- "onAfterPublish" : function ( args ) {
- debugger;
- if(_self.view && _self.view.reload )_self.view.reload();
- _self.fireEvent( "afterPublish", args );
- }
- };
- if( typeOf(this.options.autoSave) == "boolean" )options.autoSave = this.options.autoSave;
- if( typeOf(this.options.saveOnClose) == "boolean" )options.saveOnClose = this.options.saveOnClose;
- if( layout.inBrowser ){
- debugger;
- if( !window.o2RefreshCMSView ){
- window.o2CreateCMSDocumentCount = ( window.o2CreateCMSDocumentCount || 0 ) + 1;
- window.o2RefreshCMSView = function () {
- try{
- if(_self.view && _self.view.reload )_self.view.reload();
- }catch (e) {}
- if( window.o2CreateCMSDocumentCount )window.o2CreateCMSDocumentCount--;
- if( !window.o2CreateCMSDocumentCount || window.o2CreateCMSDocumentCount<0 ){
- window.o2RefreshCMSView = null;
- }
- }.bind(this)
- }
- return this.app.desktop.openApplication(el, "cms.Document", options);
- }else{
- return this.app.desktop.openApplication(el, "cms.Document", options);
- }
- }
- },
- _createProcessDocument:function(e){
- var title = this.subjectInput ? this.subjectInput.get("value") : "";
- if( !title && this.options.documentData ){
- title = this.options.documentData.title || this.options.documentData.subject || "";
- }
- var identity = "";
- if( this.options.identity ){
- identity = this.options.identity;
- }else if( this.identityArea ){
- identity = this.identityArea.get("value");
- }else if( this.identityList.length > 0 ){
- identity = this.identityList[0].distinguishedName;
- }
- var processId = this.categoryData.workflowFlag;
- var data = {
- "title":title,
- "identity": identity
- };
- if (!data.title && !this.isIgnoreTitle() ){
- this.subjectInput.setStyle("border-color", "red");
- this.subjectInput.focus();
- this.app.notice(this.lp.inputSubject, "error");
- }else if (!data.identity){
- this.departmentSelArea.setStyle("border-color", "red");
- this.app.notice(this.lp.selectStartId, "error");
- }else{
- if( this.isIgnoreTitle() && !title )title = this.lp.untitled; //"无标题";
- var workData;
- if( this.options.documentData ){
- workData = Object.clone(this.options.documentData);
- }else{
- workData = {};
- }
- workData.cmsDocument = {
- "isNewDocument" : true,
- "title": title,
- "creatorIdentity": data.identity,
- "identity": data.identity,
- "appId" :this.categoryData.appId,
- "categoryId" : this.categoryData.id,
- //"form" : this.categoryData.formId,
- //"formName" :this.categoryData.formName,
- "docStatus" : "draft",
- "categoryName" : this.categoryData.name,
- "categoryAlias" : this.categoryData.alias,
- "createTime": new Date().format("db"),
- "attachmentList" : []
- };
- if( this.formAreaNode ){
- this.mask = new MWF.widget.Mask({"style": "desktop"});
- this.mask.loadNode(this.formAreaNode);
- }
- MWF.Actions.get("x_processplatform_assemble_surface").startWork( function( json ){
- if(this.mask)this.mask.hide();
- //this.markNode.destroy();
- this.close();
- this.afterStartProcess( json.data, data.title, this.categoryData.workflowName, workData );
- //this.fireEvent("started", [json.data, title, this.categoryData.name]);
- //this.app.refreshAll();
- this.app.notice(this.lp.Started, "success");
- }.bind(this), null, processId, data)
- }
- },
- afterStartProcess: function(data, title, processName, workData){
- if (data.work){
- this.startProcessDraft(data, title, processName, workData);
- }else{
- this.startProcessInstance(data, title, processName, workData);
- }
- },
- startProcessDraft: function(data, title, processName, workData){
- var work = data.work;
- if(workData){
- delete workData.identity;
- delete workData.attachmentList;
- }
- var options = {
- "draft": work,
- "draftData": workData,
- "appId": "process.Work"+(new o2.widget.UUID).toString(),
- "desktopReload": false
- };
- var win = this.app.desktop.openApplication(null, "process.Work", options);
- this.fireEvent("started", ["", workData, win]);
- },
- startProcessInstance: function(data, title, processName, workData){
- 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));
- var workId = currentTask[0];
- MWF.Actions.get("x_processplatform_assemble_surface").saveData(function(){
- if (currentTask.length==1){
- var options = {"workId": workId};
- var handle = this.app.desktop.openApplication(null, "process.Work", options);
- this.fireEvent("started", [workId, workData, handle]);
- this.createStartWorkResault(workInfors, title, processName, false);
- }else{
- this.fireEvent("started", [workId, workData]);
- this.createStartWorkResault(workInfors, title, processName, true);
- }
- }.bind(this), null, workId, workData)
- },
- getStartWorkInforObj: function(work){
- var users = [];
- var currentTask = "";
- work.taskList.each(function(task, idx){
- users.push(task.identity.split("@")[0]+"("+task.unit.split("@")[0] + ")");
- if (work.currentTaskIndex==idx) currentTask = task.id;
- }.bind(this));
- return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
- },
- createStartWorkResault: function(workInfors, title, processName, isopen){
- var content = "";
- workInfors.each(function(infor){
- content += "<div><b>"+this.lp.nextActivity+"<font style='color: #ea621f'>"+infor.activity+"</font>, "+this.lp.nextUser+"<font style='color: #ea621f'>"+infor.users.join(", ")+"</font></b>";
- if (infor.currentTask && isopen){
- content += " <span value='"+infor.currentTask+"'>"+this.lp.deal+"</span></div>";
- }else{
- content += "</div>";
- }
- }.bind(this));
- var msg = {
- "subject": this.lp.processStarted,
- "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
- };
- var tooltip = layout.desktop.message.addTooltip(msg);
- var item = layout.desktop.message.addMessage(msg);
- this.setStartWorkResaultAction(tooltip);
- this.setStartWorkResaultAction(item);
- },
- setStartWorkResaultAction: function(item){
- var node = item.node.getElements("span");
- node.setStyles(this.css.dealStartedWorkAction);
- var _self = this;
- node.addEvent("click", function(e){
- var options = {"taskId": this.get("value")};
- _self.app.desktop.openApplication(e, "process.Work", options);
- });
- }
- });
- MWF.xApplication.cms.Index.Newer.DepartmentSel = new Class({
- initialize: function(data, starter, container, idArea){
- this.data = data;
- this.starter = starter;
- this.container = container;
- this.idArea = idArea;
- this.css = this.starter.css;
- this.isSelected = false;
- this.load();
- },
- load: function(){
- this.node = new Element("div", {"styles": this.css.departSelNode}).inject(this.container);
- //this.starter.documentAction.listDepartmentWithIdentity(function(department){
- // var unitList = department.data && department.data.unitList ? department.data.unitList : [""];
- // this.node.set("text", unitList[0]);
- //}.bind(this), null, { "identityList" : [ this.data.distinguishedName ] } );
- var unit = this.data.woUnit ? this.data.woUnit.name : this.lp.unnamedUnit;
- this.node.set("text",this.data.woUnit.name);
- this.node.addEvents({
- "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.departSelNode_over);}.bind(this),
- "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.departSelNode_out);}.bind(this),
- "click": function(){
- this.selected();
- }.bind(this)
- });
- },
- selected: function(){
- if (!this.isSelected){
- if (this.starter.currentDepartment) this.starter.currentDepartment.unSelected();
- this.node.setStyles(this.css.departSelNode_selected);
- this.isSelected = true;
- this.starter.currentDepartment = this;
- this.idArea.set({
- "text": this.data.name,
- "value": this.data.distinguishedName
- });
- }
- },
- unSelected: function(){
- if (this.isSelected){
- if (this.starter.currentDepartment) this.starter.currentDepartment = null;
- this.node.setStyles(this.css.departSelNode);
- this.isSelected = false;
- }
- }
- });
- MWF.xApplication.cms.Index.Newer.CategorySel = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "restrictToColumn" : false
- },
- initialize: function(app, node, newer, columnData, categoryData, options){
- this.setOptions(options);
- this.node = node;
- this.newer = newer;
- this.lp = newer.lp;
- this.css = newer.css;
- this.action = newer.documentAction;
- this.columnData = columnData;
- this.categoryData = categoryData;
- },
- load: function(){
- if (!this.areaNode){
- this.createArea();
- }else{
- if(this.searchNode)this.searchNode.show();
- }
- this.areaNode.fade("1");
- },
- closeArea: function(){
- if (this.searchNode){
- this.searchNode.hide();
- }
- if (this.areaNode) this.areaNode.fade("out");
- },
- createArea: function(){
- if( this.newer.options.searchEnable ){
- this.searchNode = new Element("div").inject( this.newer.formTopContentNode );
- this.searchInputNode = new Element("input", {
- "styles": this.css.formTopSearchInputNode,
- "placeholder": this.lp.searchPlacholder,
- "events": {
- "keydown": function(e){ if (e.code===13) this.searchCategory(); }.bind(this)
- }
- }).inject( this.searchNode );
- this.searchActionNode = new Element("div", {
- "styles": this.css.formTopSearchActionNode,
- "events": {
- "click": function(e){ this.searchCategory(); }.bind(this)
- }
- }).inject( this.searchNode );
- }
- this.areaNode = new Element("div.categorySelAreaNode", {"styles": this.css.categorySelAreaNode}).inject(this.node );
- this.areaNode.addEvent("click", function(e){
- //this.closeArea();
- }.bind(this));
- this.columnContainer = new Element("div", {"styles": this.css.selColumnAreaNode}).inject( this.areaNode );
- this.columnScrollNode = new Element("div.columnScrollNode", {"styles": this.css.selColumnScrollNode}).inject(this.columnContainer);
- this.setScrollBar( this.columnScrollNode );
- this.columnContentNode = new Element("div.selColumnContentNode", {"styles": this.css.selColumnContentNode}).inject(this.columnScrollNode);
- this.categoryContainer = new Element("div", {"styles": this.css.selCategoryAreaNode}).inject( this.areaNode );
- this.categoryScrollNode = new Element("div", {"styles": this.css.selCategoryScrollNode}).inject(this.categoryContainer);
- this.setScrollBar( this.categoryScrollNode );
- this.categoryContentNode = new Element("div", {"styles": this.css.selCategoryContentNode}).inject(this.categoryScrollNode);
- if( this.options.restrictToColumn && this.columnData ){
- new MWF.xApplication.cms.Index.Newer.CategorySel.Column(this.columnData, this.app, this.newer, this.columnContentNode, this.categoryContentNode, {
- "needGetCategorys": true,
- "isCurrent": true,
- "currentCategory" : this.categoryData ? this.categoryData.id : "",
- "restrictToColumn" : this.options.restrictToColumn
- });
- }else{
- this.listColumns();
- }
- },
- searchCategory: function(){
- var value = this.searchInputNode.get("value");
- if( value ){
- ( this.newer.categoryList || [] ).each(function(category){
- if (category.data.categoryName.indexOf(value)!==-1){
- category.node.show();
- }else{
- category.node.hide();
- }
- })
- }else{
- ( this.newer.categoryList || [] ).each(function(category){
- category.node.show();
- })
- }
- },
- listColumns: function(){
- var c = { wrapOutCategoryList : [] };
- this.action.listColumnByPublish(function(json){
- json.data.each(function(column){
- if(!column.name)column.name = column.appName;
- if( column.wrapOutCategoryList && column.wrapOutCategoryList.length ){
- column.wrapOutCategoryList.each(function(category){
- c.wrapOutCategoryList.push(category);
- }.bind(this));
- }
- }.bind(this));
- new MWF.xApplication.cms.Index.Newer.CategorySel.Column(c, this.app, this.newer, this.columnContentNode, this.categoryContentNode, {
- "needGetCategorys": false,
- "isAll" : true,
- "isCurrent" : this.columnData ? false : true,
- "currentCategory" : this.categoryData ? this.categoryData.id : "",
- "restrictToColumn" : this.options.restrictToColumn
- });
- json.data.each( function(column) {
- if(!column.name)column.name = column.appName;
- new MWF.xApplication.cms.Index.Newer.CategorySel.Column(column, this.app, this.newer, this.columnContentNode, this.categoryContentNode, {
- "needGetCategorys": false,
- "isCurrent": ( this.columnData && this.columnData.id == column.id) ? true : false,
- "currentCategory" : this.categoryData ? this.categoryData.id : "",
- "restrictToColumn" : this.options.restrictToColumn
- });
- }.bind(this) )
- }.bind(this));
- }
- });
- MWF.xApplication.cms.Index.Newer.CategorySel.Column = new Class({
- Implements: [Options],
- options: {
- "needGetCategorys": false,
- "isAll" : false,
- "isCurrent" : false,
- "currentCategory" : "",
- "restrictToColumn" : false
- },
- initialize: function(data, app, newer, container, categoryContainer, options ){
- this.setOptions( options );
- this.data = data;
- this.app = app;
- this.newer = newer;
- this.lp = newer.lp;
- this.css = newer.css;
- this.action = newer.documentAction;
- this.container = container;
- this.categoryContainer = categoryContainer;
- this.load();
- },
- load: function(){
- this.node = new Element("div", {"styles": this.css.columnItemNode}).inject(this.container);
- var iconNode = this.iconNode = new Element("img",{
- "styles" : this.css.columnItemIconNode
- }).inject(this.node);
- if( this.options.isAll ){
- this.iconNode.set("src", "../x_component_cms_Index/$Main/default/icon/all_40.png")
- }else if (this.data.appIcon){
- this.iconNode.set("src", "data:image/png;base64,"+this.data.appIcon+"");
- }else{
- this.iconNode.set("src", "../x_component_cms_Index/$Main/default/icon/column.png")
- }
- this.textNode = new Element("div", {"styles": this.css.columnItemTextNode}).inject(this.node);
- if( this.options.isAll ){
- this.textNode.set("text", this.lp.all);
- }else{
- this.textNode.set("text", (this.data.name || this.data.appName) );
- }
- if( this.options.isAll ){
- //new Element("div", {"styles": this.css.columnSelectNode}).inject(this.node);
- }
- this.node.addEvents({
- "mouseover" : function(){ if( !this.options.isCurrent )this.node.setStyles( this.css.columnItemNode_over ) }.bind(this),
- "mouseout" : function(){ if( !this.options.isCurrent )this.node.setStyles( this.css.columnItemNode ) }.bind(this),
- "click" : function(){ this.setCurrent(); }.bind(this)
- });
- if( this.options.isCurrent )this.setCurrent();
- },
- setCurrent: function(){
- this.options.isCurrent = true;
- this.node.setStyles( this.css.columnItemNode_current );
- this.node.addClass("mainColor_color");
- this.newer.setCurrentColumn( this );
- this.loadCategory();
- },
- loadCategory: function(){
- this.categoryContainer.empty();
- this.newer.categoryList = [];
- if( this.options.needGetCategorys ){
- this.action.listCategoryByPublisher(this.data.id,function(json){
- if (json.data.length){
- var isSetCurrentImmediately = ( json.data.length == 1 && ( this.options.restrictToColumn || this.options.isAll ) );
- json.data.each(function(category){
- var category = new MWF.xApplication.cms.Index.Newer.CategorySel.Category(category, this, this.categoryContainer, {
- isCurrent : ( this.options.currentCategory == category.id ) || isSetCurrentImmediately
- });
- this.newer.categoryList.push(category);
- }.bind(this));
- }else{
- this.node.setStyle("display", "none");
- }
- }.bind(this), null, this.data.id);
- }else{
- if( this.data.wrapOutCategoryList && this.data.wrapOutCategoryList.length ){
- var isSetCurrentImmediately = ( this.data.wrapOutCategoryList.length == 1 && ( this.options.restrictToColumn || this.options.isAll ) );
- this.data.wrapOutCategoryList.each(function(category){
- var category = new MWF.xApplication.cms.Index.Newer.CategorySel.Category(category, this, this.categoryContainer,{
- isCurrent : ( this.options.currentCategory == category.id ) || isSetCurrentImmediately
- });
- this.newer.categoryList.push(category);
- }.bind(this));
- }else{
- this.node.setStyle("display", "none");
- }
- }
- }
- });
- MWF.xApplication.cms.Index.Newer.CategorySel.Category = new Class({
- Implements: [Options],
- options: {
- "isCurrent" : false
- },
- initialize: function(data, column, container, options){
- this.setOptions( options );
- this.data = data;
- this.column = column;
- this.app = this.column.app;
- this.newer = this.column.newer;
- this.container = container;
- this.css = this.newer.css;
- this.load();
- },
- load: function(){
- if( !this.data.name )this.data.name = this.data.categoryName;
- this.node = new Element("div.categoryItem", {"styles": this.css.categoryItemNode}).inject(this.container);
- if( this.options.isCurrent )this.node.setStyles( this.css.categoryItemNode_over );
- this.textNode = new Element("div", {"styles": this.css.categoryItemTextNode}).inject(this.node);
- this.textNode.set({
- "text": this.data.categoryName
- });
- var _self = this;
- this.node.addEvents({
- "mouseover": function(e){if( !this.options.isCurrent )this.node.setStyles(this.css.categoryItemNode_over); }.bind(this),
- "mouseout": function(e){if( !this.options.isCurrent )this.node.setStyles(this.css.categoryItemNode);}.bind(this),
- "click": function(e){
- this.setCurrent();
- }.bind(this)
- });
- if( this.options.isCurrent )this.setCurrent();
- },
- setCurrent: function(){
- this.options.isCurrent = true;
- this.node.setStyles( this.css.categoryItemNode_current );
- this.node.addClass("mainColor_color");
- this.node.addClass("mainColor_border");
- this.newer.setCurrentCategory( this );
- }
- });
|