123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065 |
- 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,
- "zIndex": "",
- //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;
- }
- if (typeOf(options.saveOnClose) !== "boolean" && typeOf(this.columnData.config.saveDraftOnClose) === "boolean") {
- this.options.saveOnClose = this.columnData.config.saveDraftOnClose;
- }
- }
- },
- 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 () {
- if( this.options.zIndex ){
- this.formMaskNode.setStyle('z-index', this.options.zIndex);
- this.formAreaNode.setStyle('z-index', this.options.zIndex);
- }
- 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);
- var handle = this._openDocument( j.data[0].id );
- this.fireEvent("started", [j.data[0].id, j.data[0], handle]);
- 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 ) {
- 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 );
- }
- });
|