Prechádzať zdrojové kódy

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!2916
蔡祥熠 5 rokov pred
rodič
commit
1910ed7ca9

+ 277 - 2
o2web/gulpfile.js

@@ -207,6 +207,133 @@ function createXFormConcatTask(path, isMin, thisOptions) {
     });
     });
 }
 }
 
 
+function createCMSXFormConcatTask(path, isMin, thisOptions) {
+    var processPath = "x_component_process_Xform";
+    gulp.task(path+" : concat", function(){
+        var option = thisOptions || options;
+        var src = [
+            'source/o2_core/o2/widget/AttachmentController.js',
+            // 'source/o2_core/o2/xScript/CMSEnvironment.js',
+            'source/o2_core/o2/xScript/CMSMacro.js',
+            'source/o2_core/o2/widget/Tab.js',
+            'source/o2_core/o2/widget/O2Identity.js',
+            'source/' + processPath + '/Form.js',
+            'source/' + processPath + '/$Module.js',
+            'source/' + processPath + '/$Input.js',
+            'source/' + processPath + '/Div.js',
+            //'source/' + processPath + '/Combox.js',
+            'source/' + processPath + '/DatagridMobile.js',
+            'source/' + processPath + '/DatagridPC.js',
+            'source/' + processPath + '/Textfield.js',
+            //'source/' + processPath + '/Personfield.js',
+            'source/' + processPath + '/Button.js',
+            //'source/' + processPath + '/ViewSelector.js',
+            'source/' + processPath + '/Org.js',
+            // 'source/' + processPath + '/*.js',
+            'source/' + processPath + '/Actionbar.js',
+            //'source/' + processPath + '/Address.js',
+            'source/' + processPath + '/Attachment.js',
+            'source/' + processPath + '/Calendar.js',
+            'source/' + processPath + '/Checkbox.js',
+            'source/' + processPath + '/Datagrid.js',
+            'source/' + processPath + '/Htmleditor.js',
+            //'source/' + processPath + '/Iframe.js',
+            'source/' + processPath + '/Label.js',
+            'source/' + processPath + '/Number.js',
+            'source/' + processPath + '/Common.js',
+            'source/' + processPath + '/Image.js',
+            'source/' + processPath + '/ImageClipper.js',
+            'source/' + processPath + '/Html.js',
+            'source/' + processPath + '/Radio.js',
+            'source/' + processPath + '/Select.js',
+            //'source/' + processPath + '/Stat.js',
+            //'source/' + processPath + '/Statement.js',
+            //'source/' + processPath + '/StatementSelector.js',
+            //'source/' + processPath + '/Subform.js',
+            'source/' + processPath + '/Tab.js',
+            'source/' + processPath + '/Table.js',
+            'source/' + processPath + '/Textarea.js',
+            //'source/' + processPath + '/Tree.js',
+            //'source/' + processPath + '/View.js',
+            // 'source/x_component_process_Work/Processor.js',
+            // '!source/' + processPath + '/Office.js'
+
+
+            'source/o2_core/o2/widget/SimpleToolbar.js',
+            'source/' + path + '/ModuleImplements.js',
+            'source/' + path + '/Package.js',
+            'source/' + path + '/Form.js',
+            //'source/' + path + '/widget/Comment.js',
+            'source/' + path + '/widget/Log.js',
+            'source/' + path + '/Org.js',
+            'source/' + path + '/Author.js',
+            'source/' + path + '/Reader.js',
+            'source/' + path + '/Textfield.js',
+            'source/' + path + '/Actionbar.js',
+            'source/' + path + '/Attachment.js',
+            'source/' + path + '/Button.js',
+            'source/' + path + '/Calendar.js',
+            'source/' + path + '/Checkbox.js',
+            'source/' + path + '/Datagrid.js',
+            'source/' + path + '/Htmleditor.js',
+            'source/' + path + '/ImageClipper.js',
+            'source/' + path + '/Label.js',
+            'source/' + path + '/Number.js',
+            'source/' + path + '/Radio.js',
+            'source/' + path + '/Select.js',
+            'source/' + path + '/Tab.js',
+            'source/' + path + '/Table.js',
+            'source/' + path + '/Textarea.js'
+
+            //'source/' + path + '/Personfield.js',
+            //'source/' + path + '/Readerfield.js',
+            //'source/' + path + '/Authorfield.js',
+            //'source/' + path + '/Orgfield.js',
+            // 'source/' + path + '/*.js',
+            // '!source/' + path + '/Office.js'
+        ];
+        var dest = option.dest+'/' + path + '/';
+        return gulp.src(src)
+            .pipe(sourceMap.init())
+            .pipe(concat('$all.js'))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+            .pipe(concat('$all.min.js'))
+            .pipe(uglify())
+            .pipe(sourceMap.write(""))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+    });
+}
+
 function createO2ConcatTask(path, isMin, thisOptions) {
 function createO2ConcatTask(path, isMin, thisOptions) {
     gulp.task(path+" : concat", function(){
     gulp.task(path+" : concat", function(){
         var option = thisOptions || options;
         var option = thisOptions || options;
@@ -719,6 +846,149 @@ function createBasePortalConcatTask(path, isMin, thisOptions){
     createBasePortalConcatDelTempTask(path);
     createBasePortalConcatDelTempTask(path);
     gulp.task( path+".base_portal", gulp.series(path+".base_portal : action", path+".base_portal : style", path+".base_portal : concat", path+".base_portal : clean"));
     gulp.task( path+".base_portal", gulp.series(path+".base_portal : action", path+".base_portal : style", path+".base_portal : concat", path+".base_portal : clean"));
 }
 }
+
+
+function createBaseDocumentConcatActionTask(path){
+    gulp.task(path+".base_document : action", function(){
+        return gulp.src([
+            "source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
+            "source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
+            "source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
+            "source/o2_core/o2/xAction/services/x_program_center.json",
+            "source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
+        ])
+            .pipe(concat_Actions())
+            .pipe(concat('js/base_document_actions_temp.js'))
+            .pipe(gulp.dest('source/x_desktop/'))
+    })
+}
+
+function createBaseDocumentConcatStyleTask(path){
+    gulp.task(path+".base_document : style", function(){
+        return gulp.src([
+            "source/x_component_cms_Document/$Main/default/css.wcss",
+            "source/x_component_cms_Xform/$Form/default/css.wcss",
+            "source/o2_core/o2/widget/$AttachmentController/default/css.wcss"
+        ])
+            .pipe(concat_Style())
+            .pipe(concat('js/base_document_style_temp.js'))
+            .pipe(gulp.dest('source/x_desktop/'))
+    })
+}
+
+function createBaseDocumentConcatBodyTask(path, isMin, thisOptions) {
+    gulp.task(path+".base_document : concat", function(){
+        var option = thisOptions || options;
+        var src = [
+            'source/' + path + '/js/base_concat_head.js',
+            'source/o2_core/o2/lp/'+(option.lp || 'zh-cn')+'.js',
+
+            'source/' + path + '/js/base_document_style_temp.js',
+
+            'source/o2_core/o2/widget/Common.js',
+            'source/o2_core/o2/widget/Dialog.js',
+            'source/o2_core/o2/widget/UUID.js',
+            'source/o2_core/o2/widget/Menu.js',
+            'source/o2_core/o2/widget/Mask.js',
+            'source/o2_core/o2/xDesktop/Common.js',
+            'source/o2_core/o2/xDesktop/Actions/RestActions.js',
+            'source/o2_core/o2/xAction/RestActions.js',
+            'source/o2_core/o2/xDesktop/Access.js',
+            'source/o2_core/o2/xDesktop/Dialog.js',
+            'source/o2_core/o2/xDesktop/Menu.js',
+            'source/o2_core/o2/xDesktop/UserData.js',
+            'source/x_component_Template/MPopupForm.js',
+            'source/o2_core/o2/xDesktop/Authentication.js',
+            'source/o2_core/o2/xDesktop/Window.js',
+
+            'source/x_component_Common/Main.js',
+
+            'source/x_component_cms_Document/lp/'+(option.lp || 'zh-cn')+'.js',
+            'source/x_component_process_Xform/lp/'+(option.lp || 'zh-cn')+'.js',
+            'source/x_component_Selector/lp/'+(option.lp || 'zh-cn')+'.js',
+            'source/x_component_cms_xform/lp/'+(option.lp || 'zh-cn')+'.js',
+
+            'source/x_component_cms_Document/Main.js',
+
+            'source/x_component_Selector/package.js',
+
+            'source/o2_core/o2/xScript/Actions/UnitActions.js',
+            'source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
+            'source/o2_core/o2/xScript/CMSEnvironment.js',
+
+            'source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
+            'source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
+            'source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
+            'source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
+
+            'source/' + path + '/js/base_document_actions_temp.js',
+
+            'source/' + path + '/js/base.js'
+        ];
+        var dest = option.dest+'/' + path + '/';
+        return gulp.src(src)
+            .pipe(sourceMap.init())
+            .pipe(concat('js/base_document.js'))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+            // .pipe(gulp.src(src))
+            .pipe(concat('js/base_document.min.js'))
+            .pipe(uglify())
+            .pipe( sourceMap.write("") )
+            // .pipe(rename({ extname: '.min.js' }))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+    });
+}
+
+function createBaseDocumentConcatDelTempTask(path) {
+    gulp.task(path+".base_document : clean", function(cb){
+        var dest = [
+            'source/'+path+'/js/base_document_actions_temp.js',
+            'source/'+path+'/js/base_document_style_temp.js'
+        ];
+        return del(dest, cb);
+    });
+}
+
+function createBaseDocumentConcatTask(path, isMin, thisOptions){
+    createBaseDocumentConcatActionTask(path);
+    createBaseDocumentConcatStyleTask(path);
+    createBaseDocumentConcatBodyTask(path, isMin, thisOptions);
+    createBaseDocumentConcatDelTempTask(path);
+    gulp.task( path+".base_document", gulp.series(path+".base_document : action", path+".base_document : style", path+".base_document : concat", path+".base_document : clean"));
+}
+
+
+
 function createBaseConcatTask(path, isMin, thisOptions){
 function createBaseConcatTask(path, isMin, thisOptions){
     gulp.task(path+".base", function(){
     gulp.task(path+".base", function(){
         var option = thisOptions || options;
         var option = thisOptions || options;
@@ -771,9 +1041,13 @@ function createBaseConcatTask(path, isMin, thisOptions){
 }
 }
 
 
 function getAppTask(path, isMin, thisOptions) {
 function getAppTask(path, isMin, thisOptions) {
-    if (path==="x_component_process_Xform"){
+    if (path==="x_component_process_Xform") {
         createDefaultTask(path, isMin, thisOptions);
         createDefaultTask(path, isMin, thisOptions);
         createXFormConcatTask(path, isMin, thisOptions);
         createXFormConcatTask(path, isMin, thisOptions);
+        return gulp.series(path, path + " : concat");
+    }else if (path==="x_component_cms_Xform"){
+        createDefaultTask(path, isMin, thisOptions);
+        createCMSXFormConcatTask(path, isMin, thisOptions);
         return gulp.series(path, path+" : concat");
         return gulp.series(path, path+" : concat");
     }else if (path==="o2_core"){
     }else if (path==="o2_core"){
         createDefaultTask(path, isMin, thisOptions);
         createDefaultTask(path, isMin, thisOptions);
@@ -783,8 +1057,9 @@ function getAppTask(path, isMin, thisOptions) {
         createDefaultTask(path, isMin, thisOptions);
         createDefaultTask(path, isMin, thisOptions);
         createBaseWorkConcatTask(path, isMin, thisOptions);
         createBaseWorkConcatTask(path, isMin, thisOptions);
         createBasePortalConcatTask(path, isMin, thisOptions);
         createBasePortalConcatTask(path, isMin, thisOptions);
+        createBaseDocumentConcatTask(path, isMin, thisOptions);
         createBaseConcatTask(path, isMin, thisOptions);
         createBaseConcatTask(path, isMin, thisOptions);
-        return gulp.series(path, path+".base_work", path+".base_portal", path+".base");
+        return gulp.series(path, path+".base_work", path+".base_portal", path+".base_document", path+".base");
         //return gulp.series(path, path+".base_work : concat");
         //return gulp.series(path, path+".base_work : concat");
     }else{
     }else{
         createDefaultTask(path, isMin, thisOptions);
         createDefaultTask(path, isMin, thisOptions);

+ 0 - 1
o2web/source/o2_core/o2/widget/Calendar.js

@@ -884,7 +884,6 @@ o2.widget.Calendar = o2.Calendar = new Class({
 		}
 		}
 	},
 	},
 	_setTimeDate: function(node, h, m, s){
 	_setTimeDate: function(node, h, m, s){
-		;
 		if( !this.options.secondEnable ){
 		if( !this.options.secondEnable ){
 			var div = this.contentTimeTable.getElement(".MWF_calendar_time_s");
 			var div = this.contentTimeTable.getElement(".MWF_calendar_time_s");
 			if( div )div.hide();
 			if( div )div.hide();

+ 51 - 10
o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.js

@@ -98,24 +98,45 @@ MWF.xAction.RestActions.Action["x_cms_assemble_control"] = new Class({
         }
         }
     },
     },
     updateForm: function(formData, mobileData, fieldList, success, failure){ 
     updateForm: function(formData, mobileData, fieldList, success, failure){ 
-        var data, mobileData;
+        var data, mobileDataStr;
         if (formData) data = MWF.encodeJsonString(JSON.encode(formData));
         if (formData) data = MWF.encodeJsonString(JSON.encode(formData));
-        if (mobileData) mobileData = MWF.encodeJsonString(JSON.encode(mobileData));
+        if (mobileData) mobileDataStr = MWF.encodeJsonString(JSON.encode(mobileData));
+
+        var relatedScriptMap = null;
+        if (formData && formData.json.includeScripts && formData.json.includeScripts.length){
+            relatedScriptMap = {};
+            formData.json.includeScripts.each(function(s){
+                relatedScriptMap[s.id] = ((s.appType==="process") ? "processPlatform" : s.appType);
+            });
+        }
+
+        var mobileRelatedScriptMap = null;
+        if (mobileData && mobileData.json.includeScripts && mobileData.json.includeScripts.length){
+            mobileRelatedScriptMap = {};
+            mobileData.json.includeScripts.each(function(s){
+                mobileRelatedScriptMap[s.id] = ((s.appType==="process") ? "processPlatform" : s.appType);
+            });
+        }
+
         var json = {
         var json = {
             "id": formData.json.id,
             "id": formData.json.id,
             "name": formData.json.name,
             "name": formData.json.name,
             "alias": formData.json.name,
             "alias": formData.json.name,
             "description": formData.json.description,
             "description": formData.json.description,
             "appId": formData.json.application,
             "appId": formData.json.application,
-            "formFieldList": fieldList
+            "formFieldList": fieldList,
+            "relatedScriptMap": relatedScriptMap,
+            "relatedFormList": (formData && formData.json.subformList) ? formData.json.subformList : [],
+            "mobileRelatedScriptMap": mobileRelatedScriptMap,
+            "mobileRelatedFormList": (mobileData && mobileData.json.subformList) ? mobileData.json.subformList : []
         };
         };
         if (formData) json.data = data;
         if (formData) json.data = data;
-        if (mobileData) json.mobileData = mobileData;
+        if (mobileData) json.mobileData = mobileDataStr;
 
 
         this.action.invoke({"name": "updataForm","data": json,"parameter": {"id": formData.json.id},"success": success,"failure": failure});
         this.action.invoke({"name": "updataForm","data": json,"parameter": {"id": formData.json.id},"success": success,"failure": failure});
     },
     },
     addForm: function(formData, mobileData, fieldList, success, failure){
     addForm: function(formData, mobileData, fieldList, success, failure){
-        var data, mobileData;
+        var data, mobileDataStr;
         if (!formData.json.id){
         if (!formData.json.id){
             this.getUUID(function(id){
             this.getUUID(function(id){
                 formData.json.id = id;
                 formData.json.id = id;
@@ -125,7 +146,23 @@ MWF.xAction.RestActions.Action["x_cms_assemble_control"] = new Class({
                 if ( mobileData && !mobileData.json.id ){
                 if ( mobileData && !mobileData.json.id ){
                     mobileData.json.id = id;
                     mobileData.json.id = id;
                 }
                 }
-                if (mobileData) mobileData = MWF.encodeJsonString(JSON.encode(mobileData));
+                if (mobileData) mobileDataStr = MWF.encodeJsonString(JSON.encode(mobileData));
+
+                var relatedScriptMap = null;
+                if (formData && formData.json.includeScripts && formData.json.includeScripts.length){
+                    relatedScriptMap = {};
+                    formData.json.includeScripts.each(function(s){
+                        relatedScriptMap[s.id] = ((s.appType==="process") ? "processPlatform" : s.appType);
+                    });
+                };
+
+                var mobileRelatedScriptMap = null;
+                if (mobileData && mobileData.json.includeScripts && mobileData.json.includeScripts.length){
+                    mobileRelatedScriptMap = {};
+                    mobileData.json.includeScripts.each(function(s){
+                        mobileRelatedScriptMap[s.id] = ((s.appType==="process") ? "processPlatform" : s.appType);
+                    });
+                }
 
 
                 var json = {
                 var json = {
                     "id": formData.json.id,
                     "id": formData.json.id,
@@ -133,10 +170,14 @@ MWF.xAction.RestActions.Action["x_cms_assemble_control"] = new Class({
                     "alias": formData.json.name,
                     "alias": formData.json.name,
                     "description": formData.json.description,
                     "description": formData.json.description,
                     "appId": formData.json.application,
                     "appId": formData.json.application,
-                    "formFieldList": fieldList
+                    "formFieldList": fieldList,
+                    "relatedScriptMap": relatedScriptMap,
+                    "relatedFormList": (formData && formData.json.subformList) ? formData.json.subformList : [],
+                    "mobileRelatedScriptMap": mobileRelatedScriptMap,
+                    "mobileRelatedFormList": (mobileData && mobileData.json.subformList) ? mobileData.json.subformList : []
                 };
                 };
                 if (formData) json.data = data;
                 if (formData) json.data = data;
-                if (mobileData) json.mobileData = mobileData;
+                if (mobileData) json.mobileData = mobileDataStr;
                 this.action.invoke({"name": "addForm","data": json, "parameter": {"id": formData.json.id }, "success": success,"failure": failure});
                 this.action.invoke({"name": "addForm","data": json, "parameter": {"id": formData.json.id }, "success": success,"failure": failure});
             }.bind(this));
             }.bind(this));
         }else{
         }else{
@@ -145,7 +186,7 @@ MWF.xAction.RestActions.Action["x_cms_assemble_control"] = new Class({
             if ( mobileData && !mobileData.json.id ){
             if ( mobileData && !mobileData.json.id ){
                 mobileData.json.id = formData.json.id;
                 mobileData.json.id = formData.json.id;
             }
             }
-            if (mobileData) mobileData = MWF.encodeJsonString(JSON.encode(mobileData));
+            if (mobileData) mobileDataStr = MWF.encodeJsonString(JSON.encode(mobileData));
 
 
             var json = {
             var json = {
                 "id": formData.json.id,
                 "id": formData.json.id,
@@ -156,7 +197,7 @@ MWF.xAction.RestActions.Action["x_cms_assemble_control"] = new Class({
                 "formFieldList": fieldList
                 "formFieldList": fieldList
             };
             };
             if (formData) json.data = data;
             if (formData) json.data = data;
-            if (mobileData) json.mobileData = mobileData;
+            if (mobileData) json.mobileData = mobileDataStr;
             this.action.invoke({"name": "addForm","data": json, "parameter": {"id": formData.json.categoryId}, "success": success,"failure": failure});
             this.action.invoke({"name": "addForm","data": json, "parameter": {"id": formData.json.categoryId}, "success": success,"failure": failure});
         }
         }
     },
     },

+ 13 - 1
o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.json

@@ -51,7 +51,19 @@
   "updataForm": {"uri": "/jaxrs/form/{id}","method": "PUT"},
   "updataForm": {"uri": "/jaxrs/form/{id}","method": "PUT"},
   "getFormByAnonymous": {"uri": "/jaxrs/anonymous/form/{id}"},
   "getFormByAnonymous": {"uri": "/jaxrs/anonymous/form/{id}"},
   "listFormFieldWithForm" : {"uri": "/jaxrs/form/list/{id}/formfield"},
   "listFormFieldWithForm" : {"uri": "/jaxrs/form/list/{id}/formfield"},
-  "listFormFieldWithColumn" : {"uri": "/jaxrs/form/list/formfield/appInfo/{appId}"},  
+  "listFormFieldWithColumn" : {"uri": "/jaxrs/form/list/formfield/appInfo/{appId}"},
+
+
+  "getFormV2": {"uri": "/jaxrs/form/v2/{id}?t={tag}"},
+  "getFormMobileV2": {"uri": "/jaxrs/form/v2/{id}/mobile?t={tag}"},
+  "getFormAnonymousV2": {"uri": "/jaxrs/anonymous/form/v2/{id}?t={tag}"},
+  "getFormMobileAnonymousV2": {"uri": "/jaxrs/anonymous/form/v2/{id}/mobile?t={tag}"},
+
+  "lookupFormWithDocV2":  {"uri": "/jaxrs/form/v2/lookup/document/{docId}"},
+  "lookupFormWithDocMobileV2":  {"uri": "/jaxrs/form/v2/lookup/document/{docId}/mobile"},
+  "lookupFormWithDocAnonymousV2":  {"uri": "/jaxrs/anonymous/form/v2/lookup/document/{docId}"},
+  "lookupFormWithDocMobileAnonymousV2":  {"uri": "/jaxrs/anonymous/form/v2/lookup/document/{docId}/mobile"},
+
 
 
   "getFormTemplate": {"uri": "/jaxrs/templateform/{id}"},
   "getFormTemplate": {"uri": "/jaxrs/templateform/{id}"},
   "deleteFormTemplate": {"uri": "/jaxrs/templateform/{id}","method": "DELETE"},
   "deleteFormTemplate": {"uri": "/jaxrs/templateform/{id}","method": "DELETE"},

+ 1 - 1
o2web/source/o2_core/o2/xScript/CMSMacro.js

@@ -1,5 +1,4 @@
 MWF.xScript = MWF.xScript || {};
 MWF.xScript = MWF.xScript || {};
-MWF.require("MWF.xScript.CMSEnvironment", null, false);
 MWF.xScript.CMSMacro = MWF.CMSMacro = {
 MWF.xScript.CMSMacro = MWF.CMSMacro = {
     "swapSpace": {},
     "swapSpace": {},
 
 
@@ -61,6 +60,7 @@ MWF.CMSMacro.CMSFormContext = new Class({
             "target": null,
             "target": null,
             "event": null
             "event": null
         };
         };
+        MWF.require("MWF.xScript.CMSEnvironment", null, false);
         this.environment = new MWF.xScript.CMSEnvironment(environment);
         this.environment = new MWF.xScript.CMSEnvironment(environment);
     },
     },
     setTarget: function(target){
     setTarget: function(target){

+ 5 - 2
o2web/source/o2_core/o2/xScript/Environment.js

@@ -147,7 +147,7 @@ MWF.xScript.Environment = function(ev){
          * orders.add(0, {name: "mobile", count: 10}, true);
          * orders.add(0, {name: "mobile", count: 10}, true);
          */
          */
 
 
-        /**保存data对象。
+        /**保存data对象。不触发事件
          * @method save
          * @method save
          * @static
          * @static
          * @memberOf module:data
          * @memberOf module:data
@@ -2796,6 +2796,9 @@ MWF.xScript.Environment = function(ev){
          * @param {Object} [options] - 其他参数,内容如下<br>
          * @param {Object} [options] - 其他参数,内容如下<br>
          * <pre><code class="language-js">{
          * <pre><code class="language-js">{
          *   "readonly": true, //是否以只读方式打开,默认为true
          *   "readonly": true, //是否以只读方式打开,默认为true
+         *   "forceFormId": "xxxxxx", //不管编辑还是阅读都用此表单id打开,优先使用,6.0版本之前使用 printFormId
+         *   "readFormId": "xxxxxx", //强制的阅读表单id,优先于表单的readFormId,6.0版本之前使用 formId
+         *   "editFormId": "xxxxxx", //强制的编辑表单id,优先于表单的formId,6.0版本之前使用 formEditId
          *    "saveOnClose" : true, //关闭的时候是否自动保存
          *    "saveOnClose" : true, //关闭的时候是否自动保存
          *    "onPostPublish" : function( documentData ){ //发布前执行方法,但数据已经准备好
          *    "onPostPublish" : function( documentData ){ //发布前执行方法,但数据已经准备好
          *       //documentData 为文档数据
          *       //documentData 为文档数据
@@ -3011,7 +3014,7 @@ MWF.xScript.Environment = function(ev){
          * @param {String} app  - 流程应用的名称、别名或ID。
          * @param {String} app  - 流程应用的名称、别名或ID。
          * @param {String} process  - 要启动的流程的名称、别名或ID。
          * @param {String} process  - 要启动的流程的名称、别名或ID。
          * @param {Object} [data]   - 流程启动时默认的业务数据。
          * @param {Object} [data]   - 流程启动时默认的业务数据。
-         * @param {String} [identity]  - 流程启动所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;否则使用默认身份。
+         * @param {String} [identity]  - 流程启动所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;否则使用默认身份。
          * @param {Function} [callback]  - 流程启动后的回调函数。
          * @param {Function} [callback]  - 流程启动后的回调函数。
          * @param {Boolean} [target]  - 为true时,在当前页面打开启动的流程实例;否则打开新窗口。默认false。
          * @param {Boolean} [target]  - 为true时,在当前页面打开启动的流程实例;否则打开新窗口。默认false。
          * @param {Boolean} [latest]  - 为true时,如果当前用户已经创建了此流程的实例,并且没有流转过,直接调用此实例为新流程实例;否则创建一个新实例。默认false。
          * @param {Boolean} [latest]  - 为true时,如果当前用户已经创建了此流程的实例,并且没有流转过,直接调用此实例为新流程实例;否则创建一个新实例。默认false。

+ 458 - 193
o2web/source/x_component_cms_Document/Main.js

@@ -1,7 +1,7 @@
 MWF.xApplication.cms = MWF.xApplication.cms || {};
 MWF.xApplication.cms = MWF.xApplication.cms || {};
 MWF.xApplication.cms.Document = MWF.xApplication.cms.Document || {};
 MWF.xApplication.cms.Document = MWF.xApplication.cms.Document || {};
+MWF.xApplication.cms.Document.options = MWF.xApplication.cms.Document.options || Object.clone(o2.xApplication.Common.options);
 MWF.xApplication.cms.Document.options.multitask = true;
 MWF.xApplication.cms.Document.options.multitask = true;
-MWF.xDesktop.requireApp("cms.Document", "HotLinkForm", null, false);
 MWF.xApplication.cms.Document.Main = new Class({
 MWF.xApplication.cms.Document.Main = new Class({
 	Extends: MWF.xApplication.Common.Main,
 	Extends: MWF.xApplication.Common.Main,
 	Implements: [Options, Events],
 	Implements: [Options, Events],
@@ -20,19 +20,33 @@ MWF.xApplication.cms.Document.Main = new Class({
         "saveOnClose" : true,
         "saveOnClose" : true,
         "postPublish" : null,
         "postPublish" : null,
         "postDelete" : null,
         "postDelete" : null,
-        "formId" : null,
-        "formEditId" : null
+        "forceFormId" : null, //不管编辑还是阅读都用此表单打开,优先使用
+        "printFormId" : null, //打印表单,不管编辑还是阅读都用此表单打开,仅此于forceFormId
+        "readFormId" : null, //强制的阅读表单,优先于表单的readFormId
+        "editFormId" : null //强制的编辑表单,优先于表单的formId
 	},
 	},
 	onQueryLoad: function(){
 	onQueryLoad: function(){
 		this.lp = MWF.xApplication.cms.Document.LP;
 		this.lp = MWF.xApplication.cms.Document.LP;
         if (this.status){
         if (this.status){
             this.options.documentId = this.status.documentId;
             this.options.documentId = this.status.documentId;
-            this.options.readonly = (this.status.readonly=="true" || this.status.readonly==true) ? true : false;
-            this.options.autoSave = (this.status.autoSave=="true" || this.status.autoSave==true) ? true : false;
-            this.options.saveOnClose = (this.status.saveOnClose=="true" || this.status.saveOnClose==true) ? true : false;
+            this.options.readonly = (this.status.readonly==="true" || this.status.readonly===true) ? true : false;
+            this.options.autoSave = (this.status.autoSave==="true" || this.status.autoSave===true) ? true : false;
+            this.options.saveOnClose = (this.status.saveOnClose==="true" || this.status.saveOnClose===true) ? true : false;
+
             this.options.formId = this.status.formId;
             this.options.formId = this.status.formId;
+            this.options.formEditId = this.status.formEditId;
+
             this.options.printFormId = this.status.printFormId;
             this.options.printFormId = this.status.printFormId;
+            this.options.forceFormId = this.status.forceFormId;
+            this.options.readFormId = this.status.readFormId;
+            this.options.editFormId = this.status.editFormId;
         }
         }
+
+        //兼容之前的 formEditId 和 formId
+        if( this.options.formId && !this.options.readFormId )this.options.readFormId = this.options.formId;
+        if( this.options.formEditId && !this.options.editFormId )this.options.editFormId = this.options.formEditId;
+
+        if( this.options.readonly === "false" )this.options.readonly = false;
         if( this.options.documentId && this.options.documentId!=""){
         if( this.options.documentId && this.options.documentId!=""){
             this.options.appId = "cms.Document"+this.options.documentId;
             this.options.appId = "cms.Document"+this.options.documentId;
         }
         }
@@ -50,11 +64,13 @@ MWF.xApplication.cms.Document.Main = new Class({
                 if (!this.options.isRefresh){
                 if (!this.options.isRefresh){
                     this.maxSize(function(){
                     this.maxSize(function(){
                         this.mask.loadNode(this.content);
                         this.mask.loadNode(this.content);
-                        this.loadDocument();
+                        // this.loadDocument();
+                        this.loadDocumentV2();
                     }.bind(this));
                     }.bind(this));
                 }else{
                 }else{
                     this.mask.loadNode(this.content);
                     this.mask.loadNode(this.content);
-                    this.loadDocument();
+                    // this.loadDocument();
+                    this.loadDocumentV2();
                 }
                 }
                 if (callback) callback();
                 if (callback) callback();
             //}.bind(this));
             //}.bind(this));
@@ -91,85 +107,200 @@ MWF.xApplication.cms.Document.Main = new Class({
             }
             }
         }
         }
     },
     },
-    reload: function(data){
+    reload: function(){
+        this.formNode.empty();
         if (this.form){
         if (this.form){
-            this.formNode.empty();
             MWF.release(this.form);
             MWF.release(this.form);
             this.form = null;
             this.form = null;
         }
         }
-        this.parseData(data);
-        this.openDocument();
+        // this.parseDocumentV2(data);
+        // this.openDocument();
+        this.loadDocumentV2();
+    },
+
+    loadDocumentV2 : function( callback ){
+	    debugger;
+
+        this.loadFormFlag = false;
+        this.loadDocumentFlag = false;
+        this.loadModuleFlag = false;
+
+        this.json_document = null;
+        this.json_form = null;
+
+        //只读或者匿名查看
+        var readonly = this.options.readonly !== false || this.options.anonymousAccess;
+
+        var formId = "";
+        if( this.options.forceFormId ) { //有确定的id
+            formId = this.options.forceFormId;
+        }else if( this.options.printFormId ){ //有确定的id
+            formId = this.options.printFormId;
+        }else if( readonly && this.options.readFormId ){ //只读,并且有只读表单id
+            formId = this.options.readFormId;
+        }
+
+        if( formId ){
+            this.getFormV2(formId);
+            this.getDocumentV2();
+        }else{
+            if( readonly ){ //只读情况,不需要判断是否有阅读权限
+                this.lookupFormV2( true );
+            }
+            this.getDocumentV2();
+        }
+
+        var cl = "$all";
+        MWF.xDesktop.requireApp("cms.Xform", cl, function(){
+            this.loadModuleFlag = true;
+            this.checkLoad();
+        }.bind(this));
     },
     },
-    getDocument : function( callback ){
-        var id = this.options.documentId;
-        //if( this.options.anonymousAccess ){
-        //    this.action.getDocumentByAnonymous(id, function(json){
-        //        callback(json)
-        //    }.bind(this), function( error ){
-        //        this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
-        //        this.close();
-        //    }.bind(this));
-        //}else if( this.options.readonly ){
-        //    this.action.viewDocument(id, function(json){
-        //        callback(json)
-        //    }.bind(this), function( error ){
-        //        this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
-        //        this.close();
-        //    }.bind(this));
-        //}else{
-        //    this.action.getDocument(id, function(json){
-        //        callback(json)
-        //    }.bind(this), function( error ){
-        //        this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
-        //        this.close();
-        //    }.bind(this));
-        //}
-
-        var documentMethod = "getDocument";
+    checkLoad : function ( toLoadForm ) {
+        if( toLoadForm ){
+            if( this.json_document ){
+                this.getFormV2( this.formId );
+            }else{
+                this.needLoadForm = true;
+            }
+        }
+
+        if( this.needLoadForm && !this.loadFormFlag && this.json_document ){
+            this.needLoadForm = false;
+            this.getFormV2( this.formId );
+        }
+
+        if( this.loadFormFlag && this.loadDocumentFlag && this.loadModuleFlag ){
+            this.parseFormV2( this.json_form.data );
+            if (layout.session && layout.session.user){
+                this.openDocument();
+                if (this.mask) this.mask.hide();
+            }else{
+                if (layout.sessionPromise){
+                    layout.sessionPromise.then(function(){
+                        this.openDocument();
+                        if (this.mask) this.mask.hide();
+                    }.bind(this), function(){});
+                }
+            }
+        }
+
+    },
+    getDocumentV2 : function(){
+        var id = this.options.documentId || this.options.id;
+        var readonly = this.options.readonly !== false;
+
+        var documentMethod;
         if( this.options.anonymousAccess ){
         if( this.options.anonymousAccess ){
             documentMethod = "getDocumentByAnonymous"
             documentMethod = "getDocumentByAnonymous"
-        }else if( this.options.readonly && !this.options.printFormId){
+        }else if( readonly && !this.options.printFormId){
             documentMethod = "viewDocument";
             documentMethod = "viewDocument";
+        }else{
+            documentMethod = "getDocument";
         }
         }
 
 
-        var attachmentMethod = "listAttachment";
-        if( this.options.anonymousAccess ){
-            attachmentMethod = "listAttachmentByAnonymous"
-        }
+        var attachmentMethod = this.options.anonymousAccess ? "listAttachmentByAnonymous" : "listAttachment";
 
 
         o2.Actions.invokeAsync([
         o2.Actions.invokeAsync([
             {"action": this.action, "name": documentMethod},
             {"action": this.action, "name": documentMethod},
-            {"action": this.action, "name": attachmentMethod }
-        ], {"success": function(json_document, json_att){
-            if (json_document ){
-                if( json_att && typeOf( json_att.data ) === "array" ){
-                    json_document.data.attachmentList = json_att.data ;
+            {"action": this.action, "name": attachmentMethod },
+        ], {"success": function(jsonDocument, jsonAtt){
+                if (jsonDocument ){
+                    if( jsonAtt && typeOf( jsonAtt.data ) === "array" ){
+                        jsonDocument.data.attachmentList = jsonAtt.data ;
+                    }else{
+                        jsonDocument.data.attachmentList = [];
+                    }
+                    this.json_document = jsonDocument;
+                    this.loadDocumentFlag = true;
+
+                    this.parseDocumentV2(this.json_document.data);
+
+                    //编辑状态要先获取document再判断有没有权限编辑
+                    var toLoadForm = this.options.readonly !== true && !this.options.anonymousAccess;
+                    this.checkLoad( toLoadForm )
                 }else{
                 }else{
-                    json_document.data.attachmentList = [];
+                    this.errorLoadingV2();
                 }
                 }
-                callback(json_document)
-            }else{
-                this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
-                this.close();
-            }
-        }.bind(this), "failure": function(){
-            this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
-            this.close();
-        }.bind(this)}, id);
+            }.bind(this), "failure": function(error){
+                this.errorLoadingV2( error );
+            }.bind(this)}, id, id);
     },
     },
-    loadDocument: function(){
-        this.getDocument( function(json){
-            json.data = json.data || [];
-            this.parseData(json.data);
-            this.loadForm( this.formId );
-        }.bind(this) );
+    getFormV2 : function( formId, cacheTag, ignoreFromCategory ){
+        var formMethod;
+        if( this.options.anonymousAccess ){
+            formMethod =  layout.mobile ? "getFormMobileAnonymousV2" : "getFormAnonymousV2";
+        }else{
+            formMethod = layout.mobile ? "getFormMobileV2" : "getFormV2";
+        }
+        this.action[formMethod](
+            formId,
+
+            cacheTag || "",
+
+            function( jsonForm ){
+                this.json_form = jsonForm;
+                this.loadFormFlag = true;
+                this.checkLoad();
+            }.bind(this),
+
+            function(error){
+                //没有表单,重新获取分类表单
+                if( !ignoreFromCategory && this.document && this.document.categoryId ){
+                    this.action.getCategory( this.document.categoryId, function(json){
+                        var d = json.data;
+                        if( this.readonly === true && d.readFormId && d.readFormId != "" ){
+                            this.formId  = d.readFormId;
+                        }else{
+                            this.formId = d.formId || d.readFormId;
+                        }
+                        this.getFormV2( this.formId, null,true );
+                    }.bind(this));
+                }else{
+                    this.errorLoadingV2( error , "form" );
+                }
+            }.bind(this)
+        )
     },
     },
-    errorDocument: function(){
-        if (this.mask) this.mask.hide();
-        this.node.set("text", "openError");
+    lookupFormV2 : function ( isReadonly ) {
+        var id = this.options.documentId || this.options.id;
+
+        var lookupMethod;
+        if( this.options.anonymousAccess ){
+            lookupMethod =  layout.mobile ? "lookupFormWithDocMobileAnonymousV2" : "lookupFormWithDocAnonymousV2";
+        }else{
+            lookupMethod = layout.mobile ? "lookupFormWithDocMobileV2" : "lookupFormWithDocV2";
+        }
+
+        this.action[lookupMethod](id, function(json){
+            var formId;
+            if( isReadonly ){
+                formId = json.data.readFormId || json.data.formId;
+            }else{
+                formId = json.data.formId || json.data.readFormId;
+            }
+            if (json.data.form){
+                this.json_form = json;
+                this.loadFormFlag = true;
+                this.checkLoad();
+            }else{
+                var cacheTag = json.data.cacheTag || "";
+                this.getFormV2( formId, cacheTag )
+            }
+
+        }.bind(this), function(){
+            this.checkLoad( true );
+        }.bind(this));
     },
     },
-    loadForm : function( formId, flag ){
-        var success = function(json){
+
+    parseFormV2: function( json ){
+        if (json.form){
+            this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
+            this.relatedFormMap = json.relatedFormMap;
+            this.relatedScriptMap = json.relatedScriptMap;
+            if( json.form.data )delete json.form.data;
+            this.formInfor = json.form;
+        }else{
             if( layout.mobile ){
             if( layout.mobile ){
                 this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
                 this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
                 if( !this.form ){
                 if( !this.form ){
@@ -178,77 +309,12 @@ MWF.xApplication.cms.Document.Main = new Class({
             }else{
             }else{
                 this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
                 this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
             }
             }
-            //this.listAttachment();
-            this.openDocument();
-            if (this.mask) this.mask.hide();
-        }.bind(this);
-        var failure = function(error){
-            //没有表单,重新获取分类表单
-            if( !flag ){
-                this.action.getCategory( this.document.categoryId, function(json){
-                    var d = json.data;
-                    this.formId = d.formId || d.readFormId;
-                    if( this.readonly == true && d.readFormId && d.readFormId != "" ){
-                        this.formId  = d.readFormId;
-                    }
-                    this.loadForm( this.formId, true );
-                }.bind(this));
-            }else{
-                this.notice(  this.lp.formGettedError + ":" + error.responseText , "error");
-                this.close();
-            }
-        }.bind(this);
-        if( this.options.printFormId){
-            this.action.getForm(this.options.printFormId, function( json ){
-                success(json);
-            }.bind(this), function(error){
-                failure(error)
-            }.bind(this));
-        }else{
-            if( this.options.anonymousAccess ){
-                this.action.getFormByAnonymous(formId, function( json ){
-                    success(json);
-                }.bind(this), function(error){
-                    failure(error)
-                }.bind(this));
-            }else{
-                this.action.getForm(formId, function( json ){
-                    success(json);
-                }.bind(this), function(error){
-                    failure(error)
-                }.bind(this));
-            }
-        }
-    },
-    //listAttachment: function(){
-    //    if( this.document.attachmentList && this.document.attachmentList.length > 0 ){
-    //        this.action.listAttachment(this.options.documentId, function( json ){
-    //            if (this.mask) this.mask.hide();
-    //            this.attachmentList = json.data;
-    //            this.attachmentList.each(function(att){
-    //                att.lastUpdateTime = att.updateTime;
-    //                att.person = att.creatorUid;
-    //            })
-    //            this.openDocument();
-    //        }.bind(this), function(error){
-    //            this.notice(  this.lp.attachmentGettedError  + ":" + error.responseText, "error");
-    //            this.close();
-    //        }.bind(this));
-    //    }else{
-    //        if (this.mask) this.mask.hide();
-    //        this.attachmentList = [];
-    //        this.openDocument();
-    //    }
-    //},
-    isEmptyObject: function( obj ) {
-        var name;
-        for ( name in obj ) {
-            return false;
+            if( json.data.data )delete json.data.data;
+            if( json.data.mobileData )delete json.data.mobileData;
+            this.formInfor = json.form;
         }
         }
-        return true;
     },
     },
-    parseData: function(data){
-
+    parseDocumentV2 : function( data ){
         var title = "";
         var title = "";
         title = data.document.title;
         title = data.document.title;
 
 
@@ -264,93 +330,289 @@ MWF.xApplication.cms.Document.Main = new Class({
             att.person = att.creatorUid;
             att.person = att.creatorUid;
         });
         });
 
 
-        if( this.isEmptyObject(this.data) ){
-            this.data.isNew = true;
-        }else{
-            this.data.isNew = false;
-        }
+        this.data.isNew = this.isEmptyObject(this.data) ? true : false;
 
 
         this.document = data.document;
         this.document = data.document;
 
 
         var isAdmin = false;
         var isAdmin = false;
 
 
-        if( MWF.AC.isCMSManager() ){
+        if( MWF.AC.isCMSManager() || data.isAppAdmin || data.isCategoryAdmin || data.isManager){
             this.options.isControl = true;
             this.options.isControl = true;
-            isAdmin = true;
+            this.isAdmin = true;
         }
         }
 
 
-        if( data.isAppAdmin ){
-            this.options.isControl = true;
-            isAdmin = true;
-        }
-        if( data.isCategoryAdmin ){
-            this.options.isControl = true;
-            isAdmin = true;
-        }
-        if( data.isManager ){
-            this.options.isControl = true;
-            isAdmin = true;
-        }
-        this.isAdmin = isAdmin;
-        ////系统管理员
-        //if( MWF.AC.isAdministrator() ){
-        //    this.options.isControl = true;
-        //    isAdmin = true;
-        //}
-        ////栏目管理员
-        //if(this.controllers && this.controllers.contains(this.desktop.session.user.name) ){
-        //    this.options.isControl = true;
-        //    isAdmin = true;
-        //}
         //文档创建人
         //文档创建人
         if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
         if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
             this.options.isControl = true;
             this.options.isControl = true;
         }
         }
 
 
-        if( data.isEditor ){ //作者权限
+        //作者权限
+        if( data.isEditor ){
             this.options.isControl = true;
             this.options.isControl = true;
         }
         }
 
 
         if( this.options.readonly ){ //强制只读
         if( this.options.readonly ){ //强制只读
             this.readonly = true;
             this.readonly = true;
         }else{
         }else{
-            this.readonly = true;
-            if(this.options.isControl && this.document.docStatus != "archived"){
+            if(this.options.isControl && this.document.docStatus != "archived"){ //有编辑权限并且不是归档状态
                 this.readonly = false;
                 this.readonly = false;
+            }else{
+                this.readonly = true;
             }
             }
         }
         }
 
 
-        this.formId = this.document.form || this.document.readFormId;
-        if( this.readonly == true && this.document.readFormId && this.document.readFormId != "" ){
-            this.formId  = this.document.readFormId;
-            if(this.options.formId){
-                this.formId = this.options.formId
-            }
-        }else {
-            if(this.options.formEditId){
-                this.formId = this.options.formEditId
-            }
+        var formId;
+        if( this.readonly === true ){
+            formId = this.options.forceFormId || this.options.printFormId  || this.options.readFormId || this.document.readFormId || this.options.editFormId || this.document.form;
+        }else{
+            formId = this.options.forceFormId || this.options.printFormId || this.options.editFormId || this.document.form || this.options.readFormId || this.document.readFormId;
         }
         }
+        this.formId = formId;
 
 
         if(this.readonly || this.document.docStatus == "published"){
         if(this.readonly || this.document.docStatus == "published"){
             this.options.autoSave = false;
             this.options.autoSave = false;
             this.options.saveOnClose = false;
             this.options.saveOnClose = false;
         }
         }
 
 
-        //this.attachmentList = data.attachmentList;
-
-        //this.inheritedAttachmentList = data.inheritedAttachmentList;
         var isControl = this.options.isControl;
         var isControl = this.options.isControl;
         this.control = data.control ||  {
         this.control = data.control ||  {
-                "allowRead": true,
-                "allowPublishDocument": isControl && this.document.docStatus == "draft",
-                "allowSave": isControl && this.document.docStatus == "published",
-                "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
-                "allowEditDocument":  isControl && !this.document.wf_workId,
-                "allowDeleteDocument":  isControl && !this.document.wf_workId
-            };
+            "allowRead": true,
+            "allowPublishDocument": isControl && this.document.docStatus == "draft",
+            "allowSave": isControl && this.document.docStatus == "published",
+            "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
+            "allowEditDocument":  isControl && !this.document.wf_workId,
+            "allowDeleteDocument":  isControl && !this.document.wf_workId
+        };
+    },
+    errorLoadingV2 : function( error, type ){
+        var text;
+        if( type === "form" ){
+            text = this.lp.formGettedError;
+        }else{
+            text = this.lp.documentGettedError;
+        }
+        if( error )text = text + ":" + error.responseText;
+        this.notice( text , "error");
+        layout.sessionPromise.then(function(){
+            if (this.mask) this.mask.hide();
+            this.close();
+        }.bind(this), function(){});
+    },
+
+    isEmptyObject: function( obj ) {
+        var name;
+        for ( name in obj ) {
+            return false;
+        }
+        return true;
     },
     },
+
+    // getDocument : function( callback ){
+    //     var id = this.options.documentId;
+    //
+    //     var documentMethod = "getDocument";
+    //     if( this.options.anonymousAccess ){
+    //         documentMethod = "getDocumentByAnonymous"
+    //     }else if( this.options.readonly && !this.options.printFormId){
+    //         documentMethod = "viewDocument";
+    //     }
+    //
+    //     var attachmentMethod = "listAttachment";
+    //     if( this.options.anonymousAccess ){
+    //         attachmentMethod = "listAttachmentByAnonymous"
+    //     }
+    //
+    //     o2.Actions.invokeAsync([
+    //         {"action": this.action, "name": documentMethod},
+    //         {"action": this.action, "name": attachmentMethod }
+    //     ], {"success": function(json_document, json_att){
+    //         if (json_document ){
+    //             if( json_att && typeOf( json_att.data ) === "array" ){
+    //                 json_document.data.attachmentList = json_att.data ;
+    //             }else{
+    //                 json_document.data.attachmentList = [];
+    //             }
+    //             callback(json_document)
+    //         }else{
+    //             this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
+    //             this.close();
+    //         }
+    //     }.bind(this), "failure": function(){
+    //         this.notice(  this.lp.documentGettedError + ":" + error.responseText , "error");
+    //         this.close();
+    //     }.bind(this)}, id);
+    // },
+    // loadDocument: function(){
+    //     this.getDocument( function(json){
+    //         json.data = json.data || [];
+    //         this.parseData(json.data);
+    //         this.loadForm( this.formId );
+    //     }.bind(this) );
+    // },
+    // errorDocument: function(){
+    //     if (this.mask) this.mask.hide();
+    //     this.node.set("text", "openError");
+    // },
+    // loadForm : function( formId, flag ){
+    //     var success = function(json){
+    //         if (json.form){
+    //             this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
+    //             this.relatedFormMap = json.relatedFormMap;
+    //             this.relatedScriptMap = json.relatedScriptMap;
+    //             if( json.form.data )delete json.form.data;
+    //             this.formInfor = json.form;
+    //         }else{
+    //             if( layout.mobile ){
+    //                 this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
+    //                 if( !this.form ){
+    //                     this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
+    //                 }
+    //             }else{
+    //                 this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
+    //             }
+    //             if( json.data.data )delete json.data.data;
+    //             if( json.data.mobileData )delete json.data.mobileData;
+    //             this.formInfor = json.form;
+    //         }
+    //         //this.listAttachment();
+    //         this.openDocument();
+    //         if (this.mask) this.mask.hide();
+    //     }.bind(this);
+    //     var failure = function(error){
+    //         //没有表单,重新获取分类表单
+    //         if( !flag ){
+    //             this.action.getCategory( this.document.categoryId, function(json){
+    //                 var d = json.data;
+    //                 this.formId = d.formId || d.readFormId;
+    //                 if( this.readonly == true && d.readFormId && d.readFormId != "" ){
+    //                     this.formId  = d.readFormId;
+    //                 }
+    //                 this.loadForm( this.formId, true );
+    //             }.bind(this));
+    //         }else{
+    //             this.notice(  this.lp.formGettedError + ":" + error.responseText , "error");
+    //             this.close();
+    //         }
+    //     }.bind(this);
+    //     if( this.options.printFormId){
+    //         this.action.getForm(this.options.printFormId, function( json ){
+    //             success(json);
+    //         }.bind(this), function(error){
+    //             failure(error)
+    //         }.bind(this));
+    //     }else{
+    //         if( this.options.anonymousAccess ){
+    //             this.action.getFormByAnonymous(formId, function( json ){
+    //                 success(json);
+    //             }.bind(this), function(error){
+    //                 failure(error)
+    //             }.bind(this));
+    //         }else{
+    //             this.action.getForm(formId, function( json ){
+    //                 success(json);
+    //             }.bind(this), function(error){
+    //                 failure(error)
+    //             }.bind(this));
+    //         }
+    //     }
+    // },
+    // parseData: function(data){
+    //
+    //     var title = "";
+    //     title = data.document.title;
+    //
+    //     this.setTitle(title);
+    //
+    //     data.document.subject = data.document.title;
+    //
+    //     this.data =  data.data;
+    //
+    //     this.attachmentList = data.attachmentList || [];
+    //     this.attachmentList.each(function(att){
+    //         att.lastUpdateTime = att.updateTime;
+    //         att.person = att.creatorUid;
+    //     });
+    //
+    //     if( this.isEmptyObject(this.data) ){
+    //         this.data.isNew = true;
+    //     }else{
+    //         this.data.isNew = false;
+    //     }
+    //
+    //     this.document = data.document;
+    //
+    //     var isAdmin = false;
+    //
+    //     if( MWF.AC.isCMSManager() ){
+    //         this.options.isControl = true;
+    //         isAdmin = true;
+    //     }
+    //
+    //     if( data.isAppAdmin ){
+    //         this.options.isControl = true;
+    //         isAdmin = true;
+    //     }
+    //     if( data.isCategoryAdmin ){
+    //         this.options.isControl = true;
+    //         isAdmin = true;
+    //     }
+    //     if( data.isManager ){
+    //         this.options.isControl = true;
+    //         isAdmin = true;
+    //     }
+    //     this.isAdmin = isAdmin;
+    //
+    //     //文档创建人
+    //     if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
+    //         this.options.isControl = true;
+    //     }
+    //
+    //     if( data.isEditor ){ //作者权限
+    //         this.options.isControl = true;
+    //     }
+    //
+    //     if( this.options.readonly ){ //强制只读
+    //         this.readonly = true;
+    //     }else{
+    //         this.readonly = true;
+    //         if(this.options.isControl && this.document.docStatus != "archived"){
+    //             this.readonly = false;
+    //         }
+    //     }
+    //
+    //     this.formId = this.document.form || this.document.readFormId;
+    //     if( this.readonly == true && this.document.readFormId && this.document.readFormId != "" ){
+    //         this.formId  = this.document.readFormId;
+    //         if(this.options.formId){
+    //             this.formId = this.options.formId
+    //         }
+    //     }else {
+    //         if(this.options.formEditId){
+    //             this.formId = this.options.formEditId
+    //         }
+    //     }
+    //
+    //     if(this.readonly || this.document.docStatus == "published"){
+    //         this.options.autoSave = false;
+    //         this.options.saveOnClose = false;
+    //     }
+    //
+    //     //this.attachmentList = data.attachmentList;
+    //
+    //     //this.inheritedAttachmentList = data.inheritedAttachmentList;
+    //     var isControl = this.options.isControl;
+    //     this.control = data.control ||  {
+    //             "allowRead": true,
+    //             "allowPublishDocument": isControl && this.document.docStatus == "draft",
+    //             "allowSave": isControl && this.document.docStatus == "published",
+    //             "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
+    //             "allowEditDocument":  isControl && !this.document.wf_workId,
+    //             "allowDeleteDocument":  isControl && !this.document.wf_workId
+    //         };
+    // },
+
     setPopularDocument: function(){
     setPopularDocument: function(){
+        MWF.xDesktop.requireApp("cms.Document", "HotLinkForm", null, false);
         var form = new MWF.xApplication.cms.Document.HotLinkForm(this, this.document, {
         var form = new MWF.xApplication.cms.Document.HotLinkForm(this, this.document, {
             documentId : this.options.documentId,
             documentId : this.options.documentId,
             summary :  this.data.explain || "",
             summary :  this.data.explain || "",
@@ -364,7 +626,8 @@ MWF.xApplication.cms.Document.Main = new Class({
     },
     },
     openDocument: function(){
     openDocument: function(){
         if (this.form){
         if (this.form){
-            MWF.xDesktop.requireApp("cms.Xform", "Form", function(){
+            // MWF.xDesktop.requireApp("cms.Xform", "Form", function(){
+            MWF.xDesktop.requireApp("cms.Xform", "$all", function(){
                 this.appForm = new MWF.CMSForm(this.formNode, this.form, {
                 this.appForm = new MWF.CMSForm(this.formNode, this.form, {
                     "readonly": this.readonly,
                     "readonly": this.readonly,
                     "autoSave" : this.options.autoSave,
                     "autoSave" : this.options.autoSave,
@@ -401,8 +664,10 @@ MWF.xApplication.cms.Document.Main = new Class({
             "autoSave" : this.options.autoSave,
             "autoSave" : this.options.autoSave,
             "saveOnClose" : this.options.saveOnClose
             "saveOnClose" : this.options.saveOnClose
         };
         };
-        if( this.options.formId )status.formId = this.options.formId;
+        if( this.options.readFormId )status.readFormId = this.options.readFormId;
+        if( this.options.editFormId )status.editFormId = this.options.editFormId;
         if( this.options.printFormId )status.printFormId = this.options.printFormId;
         if( this.options.printFormId )status.printFormId = this.options.printFormId;
+        if( this.options.forceFormId )status.forceFormId = this.options.forceFormId;
         if(this.options.appId && this.options.appId!="")status.appId = this.options.appId;
         if(this.options.appId && this.options.appId!="")status.appId = this.options.appId;
         return status;
         return status;
     },
     },

+ 0 - 218
o2web/source/x_component_cms_Document/Processor.js

@@ -1,218 +0,0 @@
-MWF.xApplication.process = MWF.xApplication.process || {};
-MWF.xApplication.cms.Document = MWF.xApplication.cms.Document || {};
-MWF.xDesktop.requireApp("cms.Document", "lp."+MWF.language, null, false);
-MWF.xApplication.cms.Document.Processor = new Class({
-	Extends: MWF.widget.Common,
-	Implements: [Options, Events],
-	options: {
-		"style": "default"
-	},
-	
-	initialize: function(node, task, options){
-		this.setOptions(options);
-		
-		this.path = "../x_component_cms_Document/$Processor/";
-		this.cssPath = "../x_component_cms_Document/$Processor/"+this.options.style+"/css.wcss";
-		this._loadCss();
-		
-		this.task = task;
-		this.node = $(node);
-        this.selectedRoute = null;
-
-        this.load();
-	},
-    load: function(){
-        this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.cms.Document.LP.selectRoute}).inject(this.node);
-        this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.node);
-        this.setRouteList();
-
-        this.routeOpinionTile = new Element("div", {"styles": this.css.routeOpinionTile, "text": MWF.xApplication.cms.Document.LP.inputOpinion}).inject(this.node);
-        this.routeOpinionArea = new Element("div", {"styles": this.css.routeOpinionArea}).inject(this.node);
-        this.setOpinion();
-
-        this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.node);
-        this.setButtons();
-    },
-
-    setRouteList: function(){
-        var _self = this;
-        //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"];
-        this.task.routeNameList.each(function(route){
-            var routeNode = new Element("div", {"styles": this.css.routeNode}).inject(this.routeSelectorArea);
-            var routeIconNode = new Element("div", {"styles": this.css.routeIconNode}).inject(routeNode);
-            var routeTextNode = new Element("div", {"styles": this.css.routeTextNode, "text": route}).inject(routeNode);
-
-            routeNode.addEvents({
-                "mouseover": function(e){_self.overRoute(this);},
-                "mouseout": function(e){_self.outRoute(this);},
-                "click": function(e){_self.selectRoute(this);}
-            });
-
-            if (this.task.routeNameList.length==1) this.selectRoute(routeNode);
-
-        }.bind(this));
-    },
-    overRoute: function(node){
-        if (this.selectedRoute){
-            if (this.selectedRoute.get("text") != node.get("text")){
-                node.setStyle("background-color", "#f7e1d0");
-            }
-        }else{
-            node.setStyle("background-color", "#f7e1d0");
-        }
-    },
-    outRoute: function(node){
-        if (this.selectedRoute){
-            if (this.selectedRoute.get("text") != node.get("text")){
-                node.setStyle("background-color", "#E3E3E3");
-            }
-        }else{
-            node.setStyle("background-color", "#E3E3E3");
-        }
-    },
-    selectRoute: function(node){
-        if (this.selectedRoute){
-            if (this.selectedRoute.get("text") != node.get("text")){
-                this.selectedRoute.setStyles(this.css.routeNode);
-                this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
-                this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
-
-                this.selectedRoute = node;
-                node.setStyle("background-color", "#da7429");
-                node.getFirst().setStyle("background-image", "url("+"../x_component_cms_Document/$Processor/default/checked.png)");
-                node.getLast().setStyle("color", "#FFF");
-            }else{
-                this.selectedRoute.setStyles(this.css.routeNode);
-                this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
-                this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
-
-                this.selectedRoute = null;
-            }
-        }else{
-            this.selectedRoute = node;
-            node.setStyle("background-color", "#da7429");
-            node.getFirst().setStyle("background-image", "url("+"../x_component_cms_Document/$Processor/default/checked.png)");
-            node.getLast().setStyle("color", "#FFF");
-        }
-        this.routeSelectorArea.setStyle("background-color", "#FFF");
-    },
-
-    setOpinion: function(){
-        this.selectIdeaNode = new Element("div", {"styles": this.css.selectIdeaNode}).inject(this.routeOpinionArea);
-        this.selectIdeaScrollNode = new Element("div", {"styles": this.css.selectIdeaScrollNode}).inject(this.selectIdeaNode);
-        this.selectIdeaAreaNode = new Element("div", {"styles": {
-            "overflow": "hidden"
-        }}).inject(this.selectIdeaScrollNode);
-
-        this.inputOpinionNode = new Element("div", {"styles": this.css.inputOpinionNode}).inject(this.routeOpinionArea);
-        this.inputTextarea = new Element("textarea", {"styles": this.css.inputTextarea, "value": MWF.xApplication.cms.Document.LP.inputText}).inject(this.inputOpinionNode);
-        this.inputTextarea.addEvents({
-            "focus": function(){if (this.get("value")==MWF.xApplication.cms.Document.LP.inputText) this.set("value", "");},
-            "blur": function(){if (!this.get("value")) this.set("value", MWF.xApplication.cms.Document.LP.inputText);}
-        });
-
-
-        MWF.require("MWF.widget.ScrollBar", function(){
-            new MWF.widget.ScrollBar(this.selectIdeaScrollNode, {
-                "style":"small", "where": "before", "distance": 30, "friction": 4, "indent": false,	"axis": {"x": false, "y": true}
-            });
-        }.bind(this));
-
-        MWF.require("MWF.widget.UUID", function(){
-            MWF.UD.getDataJson("idea", function(json){
-                if (json){
-                    if (json.ideas){
-                        this.setIdeaList(json.ideas);
-                    }
-                }else{
-                    MWF.UD.getPublicData("idea", function(pjson){
-                        if (pjson.ideas){
-                            this.setIdeaList(pjson.ideas);
-                        }
-                    }.bind(this));
-                }
-            }.bind(this));
-        }.bind(this));
-    },
-    setIdeaList: function(ideas){
-        var _self = this;
-        ideas.each(function(idea){
-            new Element("div", {
-                "styles": this.css.selectIdeaItemNode,
-                "text": idea,
-                "events": {
-                    "dblclick": function(){
-                        if (_self.inputTextarea.get("value")==MWF.xApplication.cms.Document.LP.inputText){
-                            _self.inputTextarea.set("value", this.get("text"));
-                        }else{
-                            _self.inputTextarea.set("value", _self.inputTextarea.get("value")+", "+this.get("text"));
-                        }
-                    },
-                    "mouseover": function(){this.setStyles(_self.css.selectIdeaItemNode_over);},
-                    "mouseout": function(){this.setStyles(_self.css.selectIdeaItemNode);}
-                }
-            }).inject(this.selectIdeaAreaNode);
-        }.bind(this));
-    },
-    setButtons: function(){
-        this.cancelButton = new Element("div", {"styles": this.css.cancelButton}).inject(this.buttonsArea);
-        var iconNode = new Element("div", {"styles": this.css.cancelIconNode}).inject(this.cancelButton);
-        var textNode = new Element("div", {"styles": this.css.cancelTextNode, "text": MWF.xApplication.cms.Document.LP.cancel}).inject(this.cancelButton);
-
-        this.okButton = new Element("div", {"styles": this.css.okButton}).inject(this.buttonsArea);
-        var iconNode = new Element("div", {"styles": this.css.okIconNode}).inject(this.okButton);
-        var textNode = new Element("div", {"styles": this.css.okTextNode, "text": MWF.xApplication.cms.Document.LP.ok}).inject(this.okButton);
-
-        this.cancelButton.addEvent("click", function(){
-            this.destroy();
-            this.fireEvent("cancel");
-        }.bind(this));
-
-        this.okButton.addEvent("click", function(){
-            if (!this.selectedRoute) {
-                this.routeSelectorArea.setStyle("background-color", "#ffe9e9");
-                new mBox.Notice({
-                    type: "error",
-                    position: {"x": "center", "y": "top"},
-                    move: false,
-                    target: this.routeSelectorArea,
-                    delayClose: 6000,
-                    content: MWF.xApplication.cms.Document.LP.mustSelectRoute
-                });
-                return false;
-            }
-            this.node.mask({
-                "inject": {"where": "bottom", "target": this.node},
-                "destroyOnHide": true,
-                "style": {
-                    "background-color": "#999",
-                    "opacity": 0.3,
-                    "z-index":600
-                }
-            });
-            var routeName = this.selectedRoute.get("text");
-            var opinion = this.inputTextarea.get("value");
-            if (opinion == MWF.xApplication.cms.Document.LP.inputText) opinion = "";
-            //this.destroy();
-            this.fireEvent("submit", [routeName, opinion]);
-
-        }.bind(this));
-    },
-
-
-    destroy: function(){
-        this.node.empty();
-        delete this.task;
-        delete this.node;
-        delete this.routeSelectorTile;
-        delete this.routeSelectorArea;
-        delete this.routeOpinionTile;
-        delete this.routeOpinionArea;
-        delete this.buttonsArea;
-        delete this.inputOpinionNode;
-        delete this.inputTextarea;
-        delete this.cancelButton;
-        delete this.okButton;
-    }
-
-});

+ 2 - 1
o2web/source/x_component_cms_Document/lp/zh-cn.js

@@ -40,4 +40,5 @@ MWF.xApplication.cms.Document.LP = {
     "unselectHotPic" : "请先选择图片",
     "unselectHotPic" : "请先选择图片",
     "cancelHotPicComfirmTitle" : "取消热点",
     "cancelHotPicComfirmTitle" : "取消热点",
     "cancelHotPicComfirmContent" : "确定取消该文档的热点?"
     "cancelHotPicComfirmContent" : "确定取消该文档的热点?"
-};
+};
+MWF.xApplication.cms.Document["lp."+o2.language] = MWF.xApplication.cms.Document.LP;

+ 25 - 9
o2web/source/x_component_cms_FormDesigner/Main.js

@@ -1329,11 +1329,15 @@ MWF.xApplication.cms.FormDesigner.Main = new Class({
         }.bind(this));
         }.bind(this));
         return fieldList;
         return fieldList;
     },
     },
-       checkSubform: function(){
+    checkSubform: function(){
         var pcSubforms = [];
         var pcSubforms = [];
         if (this.pcForm){
         if (this.pcForm){
+            this.pcForm.data.json.subformList = [];
             this.pcForm.moduleList.each(function(module){
             this.pcForm.moduleList.each(function(module){
                 if (module.moduleName==="subform"){
                 if (module.moduleName==="subform"){
+                    if (module.json.subformSelected && module.json.subformSelected!=="none" && module.json.subformType!=="script"){
+                        if (this.pcForm.data.json.subformList.indexOf(module.json.subformSelected) === -1) this.pcForm.data.json.subformList.push(module.json.subformSelected);
+                    }
                     if (module.regetSubformData()){
                     if (module.regetSubformData()){
                         module.subformData.updateTime = "";
                         module.subformData.updateTime = "";
                         var moduleNames = module.getConflictFields();
                         var moduleNames = module.getConflictFields();
@@ -1351,8 +1355,12 @@ MWF.xApplication.cms.FormDesigner.Main = new Class({
         }
         }
         var mobileSubforms = [];
         var mobileSubforms = [];
         if (this.mobileForm){
         if (this.mobileForm){
+            this.mobileForm.data.json.subformList = [];
             this.mobileForm.moduleList.each(function(module){
             this.mobileForm.moduleList.each(function(module){
                 if (module.moduleName==="subform"){
                 if (module.moduleName==="subform"){
+                    if (module.json.subformSelected && module.json.subformSelected!=="none" && module.json.subformType!=="script"){
+                        if (this.mobileForm.data.json.subformList.indexOf(module.json.subformSelected) === -1) this.mobileForm.data.json.subformList.push(module.json.subformSelected);
+                    }
                     if (module.regetSubformData()){
                     if (module.regetSubformData()){
                         module.subformData.updateTime = "";
                         module.subformData.updateTime = "";
                         var moduleNames = module.getConflictFields();
                         var moduleNames = module.getConflictFields();
@@ -1385,15 +1393,23 @@ MWF.xApplication.cms.FormDesigner.Main = new Class({
         return txt;
         return txt;
     },
     },
     saveForm: function(){
     saveForm: function(){
+        debugger;
         if (!this.isSave){
         if (!this.isSave){
+            var txt = this.checkSubform();
+            if (txt){
+                txt = this.lp.checkFormSaveError+txt;
+                this.notice(txt, "error", this.form.node);
+                return false;
+            }
+
             var pcData, mobileData;
             var pcData, mobileData;
             if (this.pcForm){
             if (this.pcForm){
-                this.pcForm._getFormData();
-                pcData = this.pcForm.data;
+                pcData = this.pcForm._getFormData();
+                // pcData = this.pcForm.data;
             }
             }
             if (this.mobileForm){
             if (this.mobileForm){
-                this.mobileForm._getFormData();
-                mobileData = this.mobileForm.data;
+                mobileData = this.mobileForm._getFormData();
+                // mobileData = this.mobileForm.data;
             }else{
             }else{
                 if (this.formMobileData) mobileData = this.formMobileData;
                 if (this.formMobileData) mobileData = this.formMobileData;
             }
             }
@@ -1558,12 +1574,12 @@ MWF.xApplication.cms.FormDesigner.Main = new Class({
     saveTemplate: function(markNode, areaNode, iconNode, nameNode, categorySelect, newCategoryNode, descriptionNode){
     saveTemplate: function(markNode, areaNode, iconNode, nameNode, categorySelect, newCategoryNode, descriptionNode){
         var pcData, mobileData;
         var pcData, mobileData;
         if (this.pcForm){
         if (this.pcForm){
-            this.pcForm._getFormData();
-            pcData = this.pcForm.data;
+            pcData = this.pcForm._getFormData();
+            //pcData = this.pcForm.data;
         }
         }
         if (this.mobileForm){
         if (this.mobileForm){
-            this.mobileForm._getFormData();
-            mobileData = this.mobileForm.data;
+            mobileData = this.mobileForm._getFormData();
+            //mobileData = this.mobileForm.data;
         }
         }
 
 
         var name = nameNode.get("value");
         var name = nameNode.get("value");

+ 30 - 5
o2web/source/x_component_cms_FormDesigner/Module/Form.js

@@ -167,13 +167,38 @@ MWF.xApplication.cms.FormDesigner.Module.Form = MWF.CMSFCForm = new Class({
 		//module.load(json, dom, parent);
 		//module.load(json, dom, parent);
 		//return module;
 		//return module;
 
 
-		if( MWF["CMSFC"+json.type] ){
-			var module = new MWF["CMSFC"+json.type](this);
-			module.load(json, dom, parent);
+		if( !json ){
+			var module;
+			var className = ( dom.get("MWFType") || "div" ).capitalize();
+			this.getTemplateData(className, function(data){
+				var moduleData = Object.clone(data);
+				moduleData.id = dom.get("id");
+				this.json.moduleList[dom.get("id")] = moduleData;
+				module = new MWF["CMSFC"+className](this);
+				module.load(moduleData, dom, parent);
+			}.bind(this), false);
+			return module;
+		}else if( MWF["CMSFC"+json.type] ){
+			var module;
+			var className = json.type.capitalize();
+			this.getTemplateData(className, function(data){
+			    var moduleData = Object.clone(data);
+				Object.merge(moduleData, json);
+				Object.merge(json, moduleData);
+			    module = new MWF["CMSFC"+json.type](this);
+			    module.load(json, dom, parent);
+			}.bind(this), false);
 			return module;
 			return module;
 		}else{
 		}else{
-			var module = new MWF["CMSFCDiv"](this);
-			module.load(json, dom, parent);
+		    var module;
+			var className = json.type.capitalize();
+			this.getTemplateData(className, function(data){
+				var moduleData = Object.clone(data);
+				Object.merge(moduleData, json);
+				Object.merge(json, moduleData);
+				module = new MWF["CMSFCDiv"](this);
+				module.load(json, dom, parent);
+			}.bind(this), false);
 			return module;
 			return module;
 		}
 		}
 	},
 	},

+ 11 - 0
o2web/source/x_component_cms_FormDesigner/Module/Form/form.html

@@ -37,6 +37,17 @@
             </tr>
             </tr>
         </table>
         </table>
 
 
+        <div style="height:24px; text-align: center; line-height: 24px; background-color: #EEE; border-top: 1px solid #999;font-weight:bold;">预加载脚本</div>
+        <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+            <tr>
+                <td class="editTableTitle">脚本:</td>
+                <td class="editTableValue">
+                    <div class="MWFScriptSelect" data-count=0 name="includeScripts"></div>
+                    <div class="MWFScriptSelectAction"><div style="color: #0b58a2; cursor: pointer; float: left">复制</div><div style="color: #0b58a2; cursor: pointer; float: left; margin-left:10px">粘贴</div></div>
+                </td>
+            </tr>
+        </table>
+
 		<!--<div class="MWFArraylist" name="cssLinks" title="CSS引用"></div>-->
 		<!--<div class="MWFArraylist" name="cssLinks" title="CSS引用"></div>-->
 		<!--<div class="MWFArraylist" name="scriptSrc" title="JS引用"></div>-->
 		<!--<div class="MWFArraylist" name="scriptSrc" title="JS引用"></div>-->
 		
 		

+ 17 - 1
o2web/source/x_component_cms_Xform/Form.js

@@ -2,7 +2,7 @@ MWF.xApplication.cms = MWF.xApplication.cms || {};
 MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
 MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
 
 
 MWF.require("MWF.widget.Common", null, false);
 MWF.require("MWF.widget.Common", null, false);
-MWF.require("MWF.xAction.org.express.RestActions", null, false);
+// MWF.require("MWF.xAction.org.express.RestActions", null, false);
 MWF.xDesktop.requireApp("Selector", "package", null, false);
 MWF.xDesktop.requireApp("Selector", "package", null, false);
 MWF.xDesktop.requireApp("process.Xform", "Form", null, false);
 MWF.xDesktop.requireApp("process.Xform", "Form", null, false);
 MWF.require("MWF.widget.O2Identity", null, false);
 MWF.require("MWF.widget.O2Identity", null, false);
@@ -214,6 +214,8 @@ MWF.xApplication.cms.Xform.Form = MWF.CMSForm = new Class(
         this.node = this.container.getFirst();
         this.node = this.container.getFirst();
 
 
         this._loadEvents();
         this._loadEvents();
+        this.loadRelatedScript();
+
         if (this.fireEvent("queryLoad")) {
         if (this.fireEvent("queryLoad")) {
 
 
             MWF.xDesktop.requireApp("cms.Xform", "lp." + MWF.language, null, false);
             MWF.xDesktop.requireApp("cms.Xform", "lp." + MWF.language, null, false);
@@ -225,6 +227,20 @@ MWF.xApplication.cms.Xform.Form = MWF.CMSForm = new Class(
             this.loadContent(callback)
             this.loadContent(callback)
         }
         }
     },
     },
+    loadRelatedScript: function () {
+        if (this.json.includeScripts && this.json.includeScripts.length) {
+            var includeScriptText = "";
+            var includedIds = [];
+            this.json.includeScripts.each(function (s) {
+                if (this.app.relatedScriptMap && this.app.relatedScriptMap[s.id]) {
+                    includeScriptText += "\n" + this.app.relatedScriptMap[s.id].text;
+                    includedIds.push(s.id);
+                }
+            }.bind(this));
+
+            if (includeScriptText) this.Macro.exec(includeScriptText, this);
+        }
+    },
     loadContent: function (callback) {
     loadContent: function (callback) {
         this.subformCount = 0;
         this.subformCount = 0;
         this.subformLoadedCount = 0;
         this.subformLoadedCount = 0;

+ 5 - 1
o2web/source/x_component_cms_Xform/ModuleImplements.js

@@ -105,4 +105,8 @@ if( !MWF.CMS$Input_Process ){
         }
         }
     });
     });
 
 
-}
+}
+
+MWF.xApplication.cms = MWF.xApplication.cms || {};
+MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
+MWF.xApplication.cms.Xform.ModuleImplements = {};

+ 4 - 2
o2web/source/x_component_cms_Xform/Package.js

@@ -88,7 +88,7 @@ MWF.xApplication.cms.Xform.Image = MWF.CMSImage =  new Class({
 //MWF.xDesktop.requireApp("cms.Xform", "Table", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "Table", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "Datagrid", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "Datagrid", null, false);
 
 
-MWF.xDesktop.requireApp("cms.Xform", "Html", null, false);
+MWF.xDesktop.requireApp("process.Xform", "Html", null, false);
 MWF.xApplication.cms.Xform.Html = MWF.CMSHtml =  new Class({
 MWF.xApplication.cms.Xform.Html = MWF.CMSHtml =  new Class({
 	Extends: MWF.APPHtml
 	Extends: MWF.APPHtml
 });
 });
@@ -112,4 +112,6 @@ MWF.xApplication.cms.Xform.Html = MWF.CMSHtml =  new Class({
 //MWF.xDesktop.requireApp("cms.Xform", "Log", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "Log", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "View", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "View", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "ViewSelector", null, false);
 //MWF.xDesktop.requireApp("cms.Xform", "ViewSelector", null, false);
-//MWF.xDesktop.requireApp("cms.Xform", "Stat", null, false);
+//MWF.xDesktop.requireApp("cms.Xform", "Stat", null, false);
+
+MWF.xApplication.cms.Xform.Package = {};

+ 16 - 10
o2web/source/x_component_cms_Xform/Subform.js

@@ -4,7 +4,7 @@ MWF.xApplication.cms.Xform.Subform = MWF.CMSSubform =  new Class({
 
 
     getSubform: function(callback){
     getSubform: function(callback){
         if (this.json.subformType==="script"){
         if (this.json.subformType==="script"){
-            if (this.json.subformScript.code){
+            if (this.json.subformScript && this.json.subformScript.code){
                 var data = this.form.Macro.exec(this.json.subformScript.code, this);
                 var data = this.form.Macro.exec(this.json.subformScript.code, this);
                 if (data){
                 if (data){
                     var formName, app;
                     var formName, app;
@@ -29,16 +29,22 @@ MWF.xApplication.cms.Xform.Subform = MWF.CMSSubform =  new Class({
             }
             }
         }else{
         }else{
             if (this.json.subformSelected && this.json.subformSelected!=="none"){
             if (this.json.subformSelected && this.json.subformSelected!=="none"){
-                var app;
-                if( this.json.subformAppSelected ){
-                    app = this.json.subformAppSelected;
-                }else{
-                    app = this.form.businessData.document.appId || this.form.businessData.document.application;
-                }
-                MWF.Actions.get("x_cms_assemble_control").getFormWithColumn(this.json.subformSelected, app, function(json){
-                    this.getSubformData(json.data);
+                var subformData = (this.form.app.relatedFormMap) ? this.form.app.relatedFormMap[this.json.subformSelected] : null;
+                if (subformData) {
+                    this.getSubformData({"data": subformData.data});
                     if (callback) callback();
                     if (callback) callback();
-                }.bind(this));
+                } else {
+                    var app;
+                    if( this.json.subformAppSelected ){
+                        app = this.json.subformAppSelected;
+                    }else{
+                        app = this.form.businessData.document.appId || this.form.businessData.document.application;
+                    }
+                    MWF.Actions.get("x_cms_assemble_control").getFormWithColumn(this.json.subformSelected, app, function(json){
+                        this.getSubformData(json.data);
+                        if (callback) callback();
+                    }.bind(this));
+                }
             }else{
             }else{
                 if (callback) callback();
                 if (callback) callback();
             }
             }

+ 4 - 1
o2web/source/x_component_cms_Xform/lp/zh-cn.js

@@ -1,6 +1,8 @@
 MWF.xApplication.process = MWF.xApplication.process || {};
 MWF.xApplication.process = MWF.xApplication.process || {};
 MWF.xApplication.process.Xform = MWF.xApplication.process.Xform || {};
 MWF.xApplication.process.Xform = MWF.xApplication.process.Xform || {};
 MWF.xDesktop.requireApp("process.Xform", "lp."+MWF.language, null, false);
 MWF.xDesktop.requireApp("process.Xform", "lp."+MWF.language, null, false);
+MWF.xApplication.cms = MWF.xApplication.cms || {};
+MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
 MWF.xApplication.cms.Xform.LP = Object.merge( MWF.xApplication.process.Xform.LP, {
 MWF.xApplication.cms.Xform.LP = Object.merge( MWF.xApplication.process.Xform.LP, {
     "dataSaved": "数据保存成功",
     "dataSaved": "数据保存成功",
     "documentPublished" : "发布成功" ,
     "documentPublished" : "发布成功" ,
@@ -59,4 +61,5 @@ MWF.xApplication.cms.Xform.LP = Object.merge( MWF.xApplication.process.Xform.LP,
     //"readdDocument" : ",",
     //"readdDocument" : ",",
     //"historyRead" : "共",
     //"historyRead" : "共",
     //"times" : "次"
     //"times" : "次"
-});
+});
+MWF.xApplication.cms.Xform["lp."+o2.language] = MWF.xApplication.cms.Xform.LP;

+ 2 - 1
o2web/source/x_component_cms_Xform/widget/Comment.js

@@ -603,13 +603,14 @@ O2CMSComment.Form = new Class({
         "hasTopIcon" : true,
         "hasTopIcon" : true,
         "hasTopContent" : true,
         "hasTopContent" : true,
         "hasBottom": true,
         "hasBottom": true,
-        "title": MWF.xApplication.cms.Xform.LP.commentFormTitle,
+        // "title": MWF.xApplication.cms.Xform.LP.commentFormTitle,
         "draggable": true,
         "draggable": true,
         "closeAction": true,
         "closeAction": true,
         "toMain" : true
         "toMain" : true
     },
     },
     _createTableContent: function(){
     _createTableContent: function(){
         this.lp = MWF.xApplication.cms.Xform.LP;
         this.lp = MWF.xApplication.cms.Xform.LP;
+        if( this.formTopTextNode )this.formTopTextNode.set("text", this.lp.commentFormTitle);
         if( this.isNew ){
         if( this.isNew ){
             MWF.Actions.get("x_cms_assemble_control").getUUID( function(id){
             MWF.Actions.get("x_cms_assemble_control").getUUID( function(id){
                 this.advanceCommentId = id;
                 this.advanceCommentId = id;

+ 23 - 0
o2web/source/x_desktop/cmsdoc.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+    <head>
+        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+        <link rel="stylesheet" type="text/css" href="css/style_all.css" charset="UTF-8" />
+        <link rel="icon" href="data:;">
+        <title></title>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    </head>
+
+    <body style="height: 100%; overflow: auto; margin:0px">
+        <div id="appContent" style="overflow: auto; height:100%">
+            <div id="loaddingArea" style="overflow: hidden;width:0px; height:2px; background-color:#4e82bd; position: absolute; top: 0; z-index: 100"></div>
+        </div>
+
+        <script src="../o2_core/o2.min.js"></script>
+        <script src="js/base_document.min.js"></script>
+        <script src="js/cmsDocMobile.min.js"></script>
+        <script src="../o2_lib/Decimal.js"></script>
+    </body>
+
+</html>

+ 2 - 2
o2web/source/x_desktop/cmsdocMobile.html

@@ -34,10 +34,10 @@
 
 
 <!--<script src="res/framework/htmleditor/ckeditor451/ckeditor.js"></script>-->
 <!--<script src="res/framework/htmleditor/ckeditor451/ckeditor.js"></script>-->
 <script src="../o2_core/o2.min.js"></script>
 <script src="../o2_core/o2.min.js"></script>
-<script src="../o2_lib/Decimal.js"></script>
-<script src="js/base.min.js"></script>
+<script src="js/base_document.min.js"></script>
 <script src="js/o2m.api.js"></script>
 <script src="js/o2m.api.js"></script>
 <script src="js/cmsDocMobile.min.js"></script>
 <script src="js/cmsDocMobile.min.js"></script>
+<script src="../o2_lib/Decimal.js"></script>
 <script>layout.mobile = true;</script>
 <script>layout.mobile = true;</script>
 </body>
 </body>
 
 

+ 4 - 0
o2web/source/x_desktop/cmspreview.html

@@ -40,6 +40,7 @@
                         MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
                         MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
                         (function(){
                         (function(){
                             layout.load = function(){
                             layout.load = function(){
+                                debugger;
                                 //        if (this.isAuthentication()){
                                 //        if (this.isAuthentication()){
                                 var preview = window.frameElement.retrieve("preview");
                                 var preview = window.frameElement.retrieve("preview");
                                 layout.desktop = window.frameElement.ownerDocument.window.layout.desktop;
                                 layout.desktop = window.frameElement.ownerDocument.window.layout.desktop;
@@ -54,6 +55,9 @@
                                         "addEvent" : function(){}
                                         "addEvent" : function(){}
                                     };
                                     };
                                     MWF.getJSON("res/preview/cmsdoc.json", function(data){
                                     MWF.getJSON("res/preview/cmsdoc.json", function(data){
+                                        if( preview.form && preview.form.designer && preview.form.designer.application && preview.form.designer.application.id ){
+                                            data.document.appId = preview.form.designer.application.id;
+                                        }
                                         layout.appForm.businessData = {
                                         layout.appForm.businessData = {
                                             "data": data.data,
                                             "data": data.data,
                                             "document": data.document,
                                             "document": data.document,

+ 23 - 0
o2web/source/x_desktop/js/base.js

@@ -262,6 +262,29 @@ o2.xDesktop.requireApp = function (module, clazz, callback, async) {
                     return window.open(o2.filterUrl(url), par);
                     return window.open(o2.filterUrl(url), par);
                 }
                 }
                 break;
                 break;
+            case "cms.Document":
+                // _openDocument(appNames, options, statusObj);
+                var url = "../x_desktop/cmsdoc.html".toURI();
+                url = url.setData(options).toString();
+                url +=((layout.debugger) ? "&debugger" : "");
+                if (layout.app.$openWithSelf) {
+                    return window.location = o2.filterUrl(url);
+                } else {
+                    return window.open(o2.filterUrl(url), par);
+                }
+                break;
+            // case "cms.Module":
+            //     _openCms(appNames, options, statusObj);
+            //     break;
+            // case "Meeting":
+            //     _openMeeting(appNames, options, statusObj);
+            //     break;
+            // case "Calendar":
+            //     _openCalendar(appNames, options, statusObj);
+            //     break;
+            // case "process.TaskCenter":
+            //     _openTaskCenter(appNames, options, statusObj);
+            //     break;
             default:
             default:
                 if (layout.app.$openWithSelf) {
                 if (layout.app.$openWithSelf) {
                     return window.location = o2.filterUrl("../x_desktop/app.html?" + par + ((layout.debugger) ? "&debugger" : ""));
                     return window.location = o2.filterUrl("../x_desktop/app.html?" + par + ((layout.debugger) ? "&debugger" : ""));

+ 1 - 1
o2web/source/x_desktop/js/cmsDocMobile.js

@@ -7,6 +7,7 @@ layout.addReady(function () {
             Cookie.write("x-token", options["x-token"]);
             Cookie.write("x-token", options["x-token"]);
         }
         }
         var _load = function () {
         var _load = function () {
+            debugger;
             this.options = uri.get("data");
             this.options = uri.get("data");
             if (!this.options.documentId) this.options.documentId = this.options.id;
             if (!this.options.documentId) this.options.documentId = this.options.id;
             this.options.name = "cms.Document";
             this.options.name = "cms.Document";
@@ -15,7 +16,6 @@ layout.addReady(function () {
             layout.openApplication(null, "cms.Document", this.options, null);
             layout.openApplication(null, "cms.Document", this.options, null);
         };
         };
 
 
-        debugger;
         if (layout.session && layout.session.user){
         if (layout.session && layout.session.user){
             _load();
             _load();
         }else{
         }else{