From 43da7d247f25caefa17b1c30462d117cd90000c3 Mon Sep 17 00:00:00 2001 From: tiansai Date: Tue, 2 Aug 2022 15:27:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E6=8F=90=E4=BA=A4=E6=8A=A5=E9=94=99=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=80=BC=E5=AF=B9=E8=B1=A1=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E5=8C=BA=E5=88=86=E9=A2=86=E5=9F=9F=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=80=BC=E5=AF=B9=E8=B1=A1=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/fast-develop/src/js/fastDevelop.js | 1 + .../src/js/module/domain/domain_design.js | 4 +- .../src/js/module/domain/domain_design_vo.js | 159 ++++++++++++++++++ .../src/js/module/editor/resource_tree.js | 49 +++++- .../src/js/module/editor/schema_render.js | 11 +- 5 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design_vo.js diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/fastDevelop.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/fastDevelop.js index 8fd8d01..755dc08 100644 --- a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/fastDevelop.js +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/fastDevelop.js @@ -22,6 +22,7 @@ layui.config({ domain_design: "domain/domain_design", domain_design_business: "domain/domain_design_business", domain_design_default: "domain/domain_design_default", + domain_design_vo: "domain/domain_design_vo", open_domain: "editor/open_domain", resource_properties: "editor/resource_properties", jqgrid: "jqgrid", // jq表格组件 diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design.js index 6a8fad5..660e81f 100644 --- a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design.js +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design.js @@ -10,7 +10,7 @@ layui.define(['element', 'api', 'fast_config', 'domain_design_business', 'domain fast_config = layui.fast_config, domain_design_business = layui.domain_design_business, domain_design_default = layui.domain_design_default, - resource_content = layui.resource_content, + // resource_content = layui.resource_content, utils = layui.utils, amis = layui.amis ; @@ -42,6 +42,8 @@ layui.define(['element', 'api', 'fast_config', 'domain_design_business', 'domain formObject["fieldList"] = grid_domain_design_businessData; formObject["defaultField"] = grid_domain_design_defaultData; + formObject["modelType"] = "domainmodel"; + var optionApi = { enableRootPath:true, type: "POST", diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design_vo.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design_vo.js new file mode 100644 index 0000000..abcb42d --- /dev/null +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/domain/domain_design_vo.js @@ -0,0 +1,159 @@ +layui.define(['element', 'api', 'fast_config', 'domain_design_business', 'amis', 'utils'], function(exports) { + "use strict"; + + /** + * Button component + * */ + var MOD_NAME = 'domain_design_vo', + $ = layui.jquery, + api = layui.api, + fast_config = layui.fast_config, + domain_design_business = layui.domain_design_business, + utils = layui.utils, + amis = layui.amis + ; + + var domain_design_vo = function(opt) { + this.option = opt; + }; + + function saveDesign(option){ + var grid_domain_vo_fields = option.grid_domain_design_business.option.grid.getData(); + // var formObject = option.amisObj.option.amisScoped.getComponentByName(getAmisId(option)).getValues(); + var formObject = {}; + + for(var field of grid_domain_vo_fields){ + var validation=[]; + if(field["Keyword"]){ + validation.push("Keyword"); + } + if(field["Repeat"]){ + validation.push("Repeat"); + } + if(field["NotEmpty"]){ + validation.push("NotEmpty"); + } + field["validationTypeList"] = validation; + } + + formObject["fieldList"] = grid_domain_vo_fields; + formObject["scope"] = "app"; + formObject["modelType"] = "vo"; + + var optionApi = { + enableRootPath:true, + type: "POST", + url: fast_config.moudle.domain.saveApi.format({nodeid:option.treeNode.id}), + data: JSON.stringify(formObject), + contentType : 'application/json;charset=UTF-8', + success: function(data){ + layer.msg('操作成功'); + if(option.callback && option.callback.reloadtree && typeof option.callback.reloadtree === 'function'){ + option.callback.reloadtree(data); + } + } + }; + + api.exec(optionApi) + } + + function getModelData(option){ + var modelJson=null; + var optionApi = { + enableRootPath:true, + type: "GET", + url: fast_config.moudle.domain.initApi.format({nodeid:option.treeNode.id}), + success: function(data){ + if(typeof data !== 'object' ){ + modelJson = JSON.parse(data); + } + } + }; + + api.exec(optionApi); + + return modelJson; + } + + function appendElem(option){ + + //debugger + var id = option.treeNode.tId; + var domainContainerId = 'domainContainer_' + id; + var saveId = "saveDesignVo_" + id; + + var domainContainer = ` +
+
+
    +
  • 基础字段
  • + + + +
+
+
+
+
+
+
+
+ +
+ `; + + $(option.elem).append(domainContainer); + + $('#' + saveId).click(function(){ + saveDesign(option); + }); + } + + function getDomainVoFields(option){ + var id = option.treeNode.tId; + return 'domainVoFields_' + id; + } + + /** + * Button start loading + * */ + domain_design_vo.prototype.render = function(opt) { + + var option = { + elem: opt.elem, + data: opt.data, + treeNode: opt.treeNode, + viewMode: opt.viewMode, + pearBody : opt.pearBody, + amisData: opt.amisData, + callback: opt.callback, + grid_domain_design_business: null + } + + render(option); + + return new domain_design_vo(option); + } + + function render(option){ + + appendElem(option); + var id = option.treeNode.tId; + var modelJson = getModelData(option); + // debugger + + var initVoFields; + if(modelJson !=null){ + initVoFields = modelJson.fieldList; + } + + // grid; + option.grid_domain_design_business = domain_design_business.render({ + elem: '#' + getDomainVoFields(option), + initData: initVoFields + }); + } + + exports(MOD_NAME, new domain_design_vo()); + +}); diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/resource_tree.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/resource_tree.js index 14fa84b..ee51ed1 100644 --- a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/resource_tree.js +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/resource_tree.js @@ -1,5 +1,5 @@ layui.define(['element', 'api', 'amis', 'schema', 'listener', 'api', 'jqgrid', 'open_domain', -'domain_design', 'edropdown', 'form', 'resource_content', 'ztree', 'resource_properties','fast_config', 'tab', 'utils', 'schema_render' +'domain_design','domain_design_vo', 'edropdown', 'form', 'resource_content', 'ztree', 'resource_properties','fast_config', 'tab', 'utils', 'schema_render' ], function(exports) { "use strict"; @@ -224,6 +224,45 @@ layui.define(['element', 'api', 'amis', 'schema', 'listener', 'api', 'jqgrid', ' }) } + function designDoamin(data, target) { + var treeNode = contextmenuData; + var id = target.id; + + domain_design.render({ + elem: utils.getTabElem(id), + data:data, + treeNode: treeNode, + viewMode: viewMode, + pearBody : pearBody, + amisData: utils.getGlobalEnv(treeNode.data), + callback: { + reloadtree: function reloadCallback(data){ + // reloadResource(); + selectedNode(data); + } + } + }) + } + + function designVo(data, target) { + var treeNode = contextmenuData; + var id = target.id; + + domain_design_vo.render({ + elem: utils.getTabElem(id), + data:data, + treeNode: treeNode, + viewMode: viewMode, + pearBody : pearBody, + amisData: utils.getGlobalEnv(treeNode.data), + callback: { + reloadtree: function reloadCallback(data){ + selectedNode(data); + } + } + }) + } + function getFilePath(value){ var path; @@ -323,6 +362,10 @@ layui.define(['element', 'api', 'amis', 'schema', 'listener', 'api', 'jqgrid', ' designDoamin(data, target) } + function designVoListener(data, target){ + designVo(data, target) + } + function createFolderListener(data) { createFolder() } @@ -345,6 +388,7 @@ layui.define(['element', 'api', 'amis', 'schema', 'listener', 'api', 'jqgrid', ' elem, open_domain = layui.open_domain, domain_design = layui.domain_design, + domain_design_vo = layui.domain_design_vo, edropdown = layui.edropdown, selectFileMetaData, form = layui.form, @@ -381,7 +425,8 @@ layui.define(['element', 'api', 'amis', 'schema', 'listener', 'api', 'jqgrid', ' createFolderListener:createFolderListener }, contentPanelListeners = { - designDomainListener:designDomainListener + designDomainListener:designDomainListener, + designVoListener:designVoListener } ; diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js index c8190da..dff587e 100644 --- a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js @@ -34,14 +34,15 @@ layui.define(['element', 'api', 'listener', 'amis'], function(exports) { // var formObject = amis.funcAmis.option.amisScoped.getComponentById("modelForm").getValues(); var optionApi = amis.funcAmis.option.schema.api; + // debugger if(optionApi.data!=undefined && optionApi.data!=null){ - optionApi["submitData"] = optionApi.data; - } - if( typeof optionApi.data =='string'){ - optionApi.data = optionApi.submitData; + if( typeof optionApi.data =='string'){ + optionApi.data = optionApi.submitData; + }else{ + optionApi["submitData"] = optionApi.data; + } } - debugger execApi({ optionApi : optionApi, execData : formObject, -- Gitee From 1b2b880fd47fa7b3f2214c8064b678434d5f065e Mon Sep 17 00:00:00 2001 From: tiansai Date: Tue, 2 Aug 2022 18:00:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4ajax=E8=AF=B7=E6=B1=82=20?= =?UTF-8?q?data=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/fast-develop/src/js/module/editor/schema_render.js | 1 + 1 file changed, 1 insertion(+) diff --git a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js index dff587e..efa1501 100644 --- a/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js +++ b/fast-develop-web/fast-develop-editor/src/fast-develop/src/js/module/editor/schema_render.js @@ -178,6 +178,7 @@ layui.define(['element', 'api', 'listener', 'amis'], function(exports) { var optionApiStr = schema.api; execApi({ optionApi : optionApiStr, + execData : option.data, contextData: option.contextData, success: function(data){ layer.msg('操作成功'); -- Gitee