From 534a8760d5f2c8456a10c04f0418db97aaac4eb9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Jul 2020 16:35:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/x_component_Selector/FormStyle.js | 206 ++++++++++++++++++ o2web/source/x_component_Selector/Script.js | 49 ++++- o2web/source/x_component_Selector/lp/zh-cn.js | 1 + .../Module/Form.js | 52 +++-- .../Module/Form/form.html | 40 ++-- .../Property.js | 94 +++++++- .../lp/zh-cn.js | 1 + .../widget/PersonSelector.js | 2 + 8 files changed, 384 insertions(+), 61 deletions(-) create mode 100644 o2web/source/x_component_Selector/FormStyle.js diff --git a/o2web/source/x_component_Selector/FormStyle.js b/o2web/source/x_component_Selector/FormStyle.js new file mode 100644 index 0000000000..f6a603e153 --- /dev/null +++ b/o2web/source/x_component_Selector/FormStyle.js @@ -0,0 +1,206 @@ +MWF.xApplication.Selector = MWF.xApplication.Selector || {}; +MWF.xDesktop.requireApp("Selector", "Person", null, false); +MWF.xApplication.Selector.FormStyle = new Class({ + Extends: MWF.xApplication.Selector.Person, + options: { + "style": "default", + "count": 0, + "title": MWF.xApplication.Selector.LP.selectFormStyle, + "values": [], + "names": [], + "expand": false, + "mode" : "pc", + "forceSearchInItem" : true + }, + loadSelectItems: function(addToNext){ + var stylesUrl = "../x_component_process_FormDesigner/Module/Form/skin/config.json"; + MWF.getJSON(stylesUrl,{ + "onSuccess": function(json){ + var category = this._newItemCategory({ + name : "系统样式", + id : "stystem" + }, this, this.itemAreaNode); + Object.each(json, function(s, key){ + if( s.mode.contains( this.options.mode ) ){ + var d = { + name : s.name, + id : key + }; + var item = this._newItem(d, this, category.children); + this.items.push(item); + } + }.bind(this)); + + var category = this._newItemCategory({ + name : "脚本", + id : "script" + }, this, this.itemAreaNode); + + var json = {}; + var appJs = {}; + o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.listNext("(0)", 500, function (scriptJson) { + o2.Actions.load("x_processplatform_assemble_designer").ApplicationAction.list(function (appJson) { + appJson.data.each( function (app) { + appJs[ app.id ] = app; + }); + scriptJson.data.each( function (script) { + if( !json[script.application] ){ + json[script.application] = appJs[ script.application ]; + json[script.application].scriptList = []; + } + script.appName = appJs[ script.application ].name; + script.appId = script.application; + script.type = "script"; + json[script.application].scriptList.push( script ) + }.bind(this)); + for( var application in json ){ + var category = this._newItemCategory(json[application], this, category.children); + json[application].scriptList.each(function(d){ + var item = this._newItem(d, this, category.children); + this.items.push(item); + }.bind(this)); + } + }.bind(this)) + }.bind(this)); + }.bind(this) + } + ); + // this.processAction.listApplications(function(json){ + // json.data.each(function(data){ + // if (!data.scriptList){ + // this.designerAction.listScript(data.id, function(scriptJson){ + // data.scriptList = scriptJson.data; + // }.bind(this), null, false); + // } + // if (data.scriptList && data.scriptList.length){ + // var category = this._newItemCategory(data, this, this.itemAreaNode); + // data.scriptList.each(function(d){ + // d.applicationName = data.name; + // var item = this._newItem(d, this, category.children); + // this.items.push(item); + // }.bind(this)); + // } + // }.bind(this)); + // }.bind(this)); + }, + _scrollEvent: function(y){ + return true; + }, + _getChildrenItemIds: function(data){ + return data.scriptList || []; + }, + _newItemCategory: function(data, selector, item, level){ + return new MWF.xApplication.Selector.FormStyle.ItemCategory(data, selector, item, level) + }, + + _listItemByKey: function(callback, failure, key){ + return false; + }, + _getItem: function(callback, failure, id, async){ + this.queryAction.getTable(function(json){ + if (callback) callback.apply(this, [json]); + }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async); + }, + _newItemSelected: function(data, selector, item){ + return new MWF.xApplication.Selector.FormStyle.ItemSelected(data, selector, item) + }, + _listItemByPinyin: function(callback, failure, key){ + return false; + }, + _newItem: function(data, selector, container, level){ + return new MWF.xApplication.Selector.FormStyle.Item(data, selector, container, level); + } +}); +MWF.xApplication.Selector.FormStyle.Item = new Class({ + Extends: MWF.xApplication.Selector.Person.Item, + _getShowName: function(){ + return this.data.name; + }, + _setIcon: function(){ + this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/attr.png)"); + }, + loadSubItem: function(){ + return false; + }, + checkSelectedSingle: function(){ + var selectedItem = this.selector.options.values.filter(function(item, index){ + if (typeOf(item)==="object"){ + if( this.data.id && item.id ){ + return this.data.id === item.id; + } + //return (this.data.id === item.id) || (this.data.name === item.name) ; + } + //if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ; + if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item); + return false; + }.bind(this)); + if (selectedItem.length){ + this.selectedSingle(); + } + }, + checkSelected: function(){ + + var selectedItem = this.selector.selectedItems.filter(function(item, index){ + if( item.data.id && this.data.id){ + return item.data.id === this.data.id; + }else{ + return item.data.name === this.data.name; + } + //return (item.data.id === this.data.id) || (item.data.name === this.data.name); + }.bind(this)); + if (selectedItem.length){ + //selectedItem[0].item = this; + selectedItem[0].addItem(this); + this.selectedItem = selectedItem[0]; + this.setSelected(); + } + } +}); + +MWF.xApplication.Selector.FormStyle.ItemSelected = new Class({ + Extends: MWF.xApplication.Selector.Person.ItemSelected, + _getShowName: function(){ + return this.data.name; + }, + _setIcon: function(){ + this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/attr.png)"); + }, + check: function(){ + if (this.selector.items.length){ + var items = this.selector.items.filter(function(item, index){ + //return (item.data.id === this.data.id) || (item.data.name === this.data.name); + if( item.data.id && this.data.id){ + return item.data.id === this.data.id; + }else{ + return item.data.name === this.data.name; + } + }.bind(this)); + this.items = items; + if (items.length){ + items.each(function(item){ + item.selectedItem = this; + item.setSelected(); + }.bind(this)); + } + } + } +}); + +MWF.xApplication.Selector.FormStyle.ItemCategory = new Class({ + Extends: MWF.xApplication.Selector.Person.ItemCategory, + _getShowName: function(){ + return this.data.name; + }, + createNode: function(){ + this.node = new Element("div", { + "styles": this.selector.css.selectorItemCategory_department + }).inject(this.container); + }, + _setIcon: function(){ + this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)"); + }, + _hasChild: function(){ + return (this.data.scriptList && this.data.scriptList.length); + }, + check: function(){} +}); diff --git a/o2web/source/x_component_Selector/Script.js b/o2web/source/x_component_Selector/Script.js index b372cdc5c1..770abe5a4f 100644 --- a/o2web/source/x_component_Selector/Script.js +++ b/o2web/source/x_component_Selector/Script.js @@ -12,23 +12,48 @@ MWF.xApplication.Selector.Script = new Class({ "forceSearchInItem" : true }, loadSelectItems: function(addToNext){ - this.processAction.listApplications(function(json){ - json.data.each(function(data){ - if (!data.scriptList){ - this.designerAction.listScript(data.id, function(scriptJson){ - data.scriptList = scriptJson.data; - }.bind(this), null, false); - } - if (data.scriptList && data.scriptList.length){ - var category = this._newItemCategory(data, this, this.itemAreaNode); - data.scriptList.each(function(d){ - d.applicationName = data.name; + var json = {}; + var appJs = {}; + o2.Actions.load("x_processplatform_assemble_designer").ScriptAction.listNext("(0)", 500, function (scriptJson) { + o2.Actions.load("x_processplatform_assemble_designer").ApplicationAction.list(function (appJson) { + appJson.data.each( function (app) { + appJs[ app.id ] = app; + }); + scriptJson.data.each( function (script) { + if( !json[script.application] ){ + json[script.application] = appJs[ script.application ]; + json[script.application].scriptList = []; + } + script.appName = appJs[ script.application ].name; + script.appId = script.application; + json[script.application].scriptList.push( script ) + }.bind(this)); + for( var application in json ){ + var category = this._newItemCategory(json[application], this, this.itemAreaNode); + json[application].scriptList.each(function(d){ var item = this._newItem(d, this, category.children); this.items.push(item); }.bind(this)); } - }.bind(this)); + }.bind(this)) }.bind(this)); + // this.processAction.listApplications(function(json){ + // json.data.each(function(data){ + // if (!data.scriptList){ + // this.designerAction.listScript(data.id, function(scriptJson){ + // data.scriptList = scriptJson.data; + // }.bind(this), null, false); + // } + // if (data.scriptList && data.scriptList.length){ + // var category = this._newItemCategory(data, this, this.itemAreaNode); + // data.scriptList.each(function(d){ + // d.applicationName = data.name; + // var item = this._newItem(d, this, category.children); + // this.items.push(item); + // }.bind(this)); + // } + // }.bind(this)); + // }.bind(this)); }, _scrollEvent: function(y){ return true; diff --git a/o2web/source/x_component_Selector/lp/zh-cn.js b/o2web/source/x_component_Selector/lp/zh-cn.js index d0e6ce7d93..04f0dc99dd 100644 --- a/o2web/source/x_component_Selector/lp/zh-cn.js +++ b/o2web/source/x_component_Selector/lp/zh-cn.js @@ -13,6 +13,7 @@ MWF.xApplication.Selector.LP = MWF.SelectorLP = { "selectProcess": "选择流程", "selectView": "选择视图", "selectTable": "选择数据表", + "selectFormStyle" : "选择表单样式", "selectCMSApplication": "选择内容管理应用", "selectCMSCategory": "选择内容管理栏目", "noSelectableItemText" : "无待选项", diff --git a/o2web/source/x_component_process_FormDesigner/Module/Form.js b/o2web/source/x_component_process_FormDesigner/Module/Form.js index ff0a9a1c0d..4d33cd5883 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Form.js +++ b/o2web/source/x_component_process_FormDesigner/Module/Form.js @@ -106,27 +106,31 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({ this.container.set("html", this.html); this.loadStylesList(function(){ - if( typeOf(this.json.currentFormStyle) === "object" ){ //如果是自定义表单样式 - this.loadCustomTemplateStyles( this.json.currentFormStyle, function ( templateStyles ) { + var formStyleType = this.json.formStyleType; + if( typeOf( formStyleType ) === "object" && formStyleType.type === "script" ){ //如果是自定义表单样式 + this.loadCustomTemplateStyles( formStyleType, function ( templateStyles ) { this._load( templateStyles ); }.bind(this)) }else { + if( typeOf( formStyleType ) === "object" )formStyleType = formStyleType.id; + var oldStyleValue = ""; - if ((!this.json.formStyleType) || !this.stylesList[this.json.formStyleType]){ + if ((!formStyleType) || !this.stylesList[formStyleType]){ this.json.formStyleType = "blue-simple"; + formStyleType = "blue-simple"; } if (this.options.mode == "Mobile") { - if (this.json.formStyleType != "defaultMobile") { - var styles = this.stylesList[this.json.formStyleType]; + if ( formStyleType != "defaultMobile") { + var styles = this.stylesList[formStyleType]; if (!styles || typeOf(styles.mode) !== "array" || !styles.mode.contains("mobile")) { - oldStyleValue = this.json.formStyleType; + oldStyleValue = formStyleType; this.json.formStyleType = "defaultMobile"; + formStyleType = "defaultMobile"; } } } - if( !this.json.currentFormStyle )this.json.currentFormStyle = this.json.formStyleType; - this.loadTemplateStyles(this.stylesList[this.json.formStyleType].file, this.stylesList[this.json.formStyleType].extendFile, function (templateStyles) { + this.loadTemplateStyles(this.stylesList[formStyleType].file, this.stylesList[formStyleType].extendFile, function (templateStyles) { //this.templateStyles = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType] : null; this._load(templateStyles, oldStyleValue); }.bind(this)); @@ -1158,39 +1162,42 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({ this.treeNode.setTitle(this.json.id); this.node.set("id", this.json.id); } - if (name=="formStyleType" || name=="formStyleCustom" ){ + if ( name=="formStyleType" ){ var loadOldTemplateStyle = function () { - if( typeOf(this.json.currentFormStyle) === "object" ){ //如果原来是自定义表单样式 - this.loadCustomTemplateStyles( this.json.currentFormStyle , function (oldTemplateStyles) { + if( typeOf(oldValue) === "object" && oldValue.type === "script" ){ //如果原来是自定义表单样式 + this.loadCustomTemplateStyles( oldValue , function (oldTemplateStyles) { this.switchTemplateStyles( oldTemplateStyles ); - this.setCurrentFormStyle( name ); }.bind(this)) }else{ - if( !oldValue )oldValue = this.json.currentFormStyle; var oldFile, oldExtendFile; + if( typeOf(oldValue) === "object" )oldValue === oldValue.id; if( oldValue && this.stylesList[oldValue] ){ oldFile = this.stylesList[oldValue].file; oldExtendFile = this.stylesList[oldValue].extendFile; } this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){ this.switchTemplateStyles( oldTemplateStyles ); - this.setCurrentFormStyle( name ); }.bind(this)) } }.bind(this); - if( name=="formStyleCustom" ){ - this.loadCustomTemplateStyles( this.json.formStyleCustom , function (templateStyles) { + var formStyleType = this.json.formStyleType; + if( typeOf(formStyleType) === "object" && formStyleType.type === "script" ){ + this.loadCustomTemplateStyles( formStyleType , function (templateStyles) { this.templateStyles = templateStyles; loadOldTemplateStyle(); + this.json.styleConfig = formStyleType; }.bind(this)) }else{ - var file = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType].file : null; - var extendFile = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType].extendFile : null; + if( typeOf(formStyleType) === "object" )formStyleType = formStyleType.id; + + var file = (this.stylesList && formStyleType) ? this.stylesList[formStyleType].file : null; + var extendFile = (this.stylesList && formStyleType) ? this.stylesList[formStyleType].extendFile : null; this.loadTemplateStyles( file, extendFile, function( templateStyles ){ this.templateStyles = templateStyles; loadOldTemplateStyle(); + this.json.styleConfig = (this.stylesList && formStyleType) ? this.stylesList[formStyleType] : null; }.bind(this)) } } @@ -1213,15 +1220,6 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({ module.setAllStyles(); }.bind(this)); }, - setCurrentFormStyle : function ( name ) { - if( name=="formStyleCustom" ){ - this.json.styleConfig = this.json.formStyleCustom; - this.json.currentFormStyle = this.json.formStyleCustom; - }else{ - this.json.styleConfig = (this.stylesList && this.json.formStyleType) ? this.stylesList[this.json.formStyleType] : null; - this.json.currentFormStyle = this.json.formStyleType; - } - }, parseCSS: function(css){ var rex = /(url\(.*\))/g; diff --git a/o2web/source/x_component_process_FormDesigner/Module/Form/form.html b/o2web/source/x_component_process_FormDesigner/Module/Form/form.html index 739b3666f0..f91138a657 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Form/form.html +++ b/o2web/source/x_component_process_FormDesigner/Module/Form/form.html @@ -23,27 +23,29 @@ - - 表单样式: - - 系统 - 自定义 - - + + + + + + + + + + + + + + + + + + + - - - - - -
+ +
diff --git a/o2web/source/x_component_process_FormDesigner/Property.js b/o2web/source/x_component_process_FormDesigner/Property.js index 132d5a262b..2634e2430a 100644 --- a/o2web/source/x_component_process_FormDesigner/Property.js +++ b/o2web/source/x_component_process_FormDesigner/Property.js @@ -1135,7 +1135,7 @@ debugger; }.bind(this)); }, loadStylesList: function(){ - var _self = this; + var _self = this; var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle"); styleSelNodes.each(function(node){ if (this.module.form.stylesList){ @@ -1160,6 +1160,32 @@ debugger; }.bind(node)); }.bind(this)); }, + // loadStylesList: function(){ + // var _self = this; + // var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle"); + // styleSelNodes.each(function(node){ + // if (this.module.form.stylesList){ + // if (!this.data.formStyleType) this.data.formStyleType = "default"; + // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc"; + // Object.each(this.module.form.stylesList, function(s, key){ + // if( s.mode.contains( mode ) ){ + // new Element("option", { + // "text": s.name, + // "value": key, + // "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key)) + // }).inject(node) + // } + // }.bind(this)); + // }else{ + // node.getParent("tr").setStyle("display", "none"); + // } + // + // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after"); + // refreshNode.addEvent("click", function(e){ + // _self.changeData(this.get("name"), this ); + // }.bind(node)); + // }.bind(this)); + // }, loadDivTemplateType: function(){ var nodes = this.propertyContent.getElements(".MWFDivTemplate"); if (nodes.length){ @@ -1217,6 +1243,7 @@ debugger; var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect"); var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect"); var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect"); + var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect"); MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){ personIdentityNodes.each(function(node){ @@ -1285,13 +1312,46 @@ debugger; }); }.bind(this)); - var _self = this; scriptNodes.each(function(node){ new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, { "type": "Script", "count": 1, "names": [this.data[node.get("name")]], - "onChange": function(ids){this.saveScriptSelectItem(node, ids);}.bind(this) + "onChange": function(ids){ + this.saveScriptSelectItem(node, ids); + }.bind(this) + }); + }.bind(this)); + + var _self = this; + formStyleNodes.each(function(node){ + var data = this.data[node.get("name")]; + if( typeOf( data ) === "string" ){ + for( var key in this.module.form.stylesList ){ + var s = this.module.form.stylesList[key]; + if( ((!data && key=="default") || (data==key)) ){ + data = { + name : s.name, + id : key + }; + break; + } + } + } + new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, { + "type": "FormStyle", + "count": 1, + "names": [data], + "onChange": function(ids){ + if( ids.length === 0 ){ + this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error", this.module.form.designer.propertyContentArea, { + x: "right", + y: "bottom" + }); + }else{ + this.saveFormStyleItem(node, ids); + } + }.bind(this) }); var next = node.getNext(); @@ -1399,6 +1459,34 @@ debugger; // this.data[node.get("name")] = null; } }, + saveFormStyleItem: function(node, ids){ + debugger; + if (ids[0]){ + var d = ids[0].data; + if( d.type === "script" ){ + var data = d; + }else{ + var data = { + "type" : "script", + "name": d.name, + "alias": d.alias, + "id": d.id, + "appName" : d.appName || d.applicationName, + "appId": d.appId, + "application": d.application + }; + } + + var name = node.get("name"); + var oldValue = this.data[name]; + this.data[name] = data; + + // this.changeJsonDate(name, data ); + this.changeData(name, node, oldValue); + }else{ + // this.data[node.get("name")] = null; + } + }, removeDutyItem: function(node, item){ if (item.data.id){ var values = JSON.decode(this.data[node.get("name")] || []); diff --git a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js index 93d605c2e0..264f9909a5 100644 --- a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js @@ -145,6 +145,7 @@ MWF.xApplication.process.FormDesigner.LP = { "save": "保存", "cancel": "取消", "newCategory": "新分类", + "mustSelectFormStyle" : "必须选择一种表单样式", "imageClipper" : "图片编辑", diff --git a/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js b/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js index 59c3a90318..cc8b60abd6 100644 --- a/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js +++ b/o2web/source/x_component_process_ProcessDesigner/widget/PersonSelector.js @@ -89,6 +89,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ if (this.options.type.toLowerCase()==="processfile") this.identitys.push(new MWF.widget.O2File(data, this.node)); if (this.options.type.toLowerCase()==="script") this.identitys.push(new MWF.widget.O2Other(data, this.node)); + if (this.options.type.toLowerCase()==="formStyle") this.identitys.push(new MWF.widget.O2Other(data, this.node)); }.bind(this)); } }.bind(this)); @@ -151,6 +152,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({ if (this.options.type.toLowerCase()==="processfile") this.identitys.push(new MWF.widget.O2File(item.data, this.node)); if (this.options.type.toLowerCase()==="script") this.identitys.push(new MWF.widget.O2Other(item.data, this.node)); + if (this.options.type.toLowerCase()==="formStyle") this.identitys.push(new MWF.widget.O2Other(item.data, this.node)); }.bind(this)); if (this.options.type.toLowerCase()==="duty") { items.each(function(item){ -- GitLab