From 4ec6b21af7c64827dd9524bb61d46db2d7953de7 Mon Sep 17 00:00:00 2001 From: liangkun Date: Tue, 23 Aug 2022 18:26:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/FormApi.cs | 64 +++++++++++++++++++ .../Scheme/FormSchemeBLL.cs | 63 +++++++++++++++++- .../pages/nworkflow/releasetask/single.vue | 5 +- .../pages/nworkflow/workflow.js | 33 +++++++++- 4 files changed, 160 insertions(+), 5 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs index a574ac806..4b5b15393 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs @@ -21,12 +21,47 @@ namespace Learun.Application.WebApi.Modules { Get["/scheme"] = GetScheme; Get["/data"] = GetData; + Get["/folderkey"] = GetFolderkey; Post["/save"] = Save; Post["/delete"] = DeleteForm; } private FormSchemeIBLL formSchemeIBLL = new FormSchemeBLL(); + + private Response GetFolderkey(dynamic _) + { + List req = this.GetReqData>();// 获取模板请求数据 + Dictionary schemeList = new Dictionary(); + Dictionary dic = new Dictionary(); + foreach (var item in req) + { + //FormSchemeInfoEntity schemeInfoEntity = formSchemeIBLL.GetSchemeInfoEntity(item.id); + //if (schemeInfoEntity != null) + //{ + // FormSchemeEntity schemeEntity = formSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId); + // if (schemeEntity != null) + // { + // if (schemeInfoEntity.F_SchemeId != item.ver) + // { + // schemeList.Add(item.id, schemeEntity); + // } + // } + //} + if (string.IsNullOrEmpty(item.processIdName)) + { + var data = formSchemeIBLL.GetInstanceForm(item.schemeInfoId, item.keyValue); + dic.Add(item.schemeInfoId, data); + } + else + { + var data = formSchemeIBLL.GetInstanceForm(item.schemeInfoId, item.processIdName, item.keyValue);// + dic.Add(item.schemeInfoId, data); + } + } + + return Success(schemeList); + } /// /// 获取表单模板数据 /// @@ -104,6 +139,35 @@ namespace Learun.Application.WebApi.Modules } #region 请求参数 + + private class FolderKeyReq + { + /// + /// 表单请求Id + /// + public string id { get; set; } + /// + /// 当前自定义表单版本号 + /// + public string ver { get; set; } + /// + /// 流程模板id + /// + public string schemeInfoId { get; set; } + /// + /// 关联字段名称 + /// + public string processIdName { get; set; } + /// + /// 数据主键值 + /// + public string keyValue { get; set; } + /// + /// 表单数据 + /// + public string formData { get; set; } + } + private class SchemeReq { /// /// 表单请求Id diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs index 1e3296b7e..cd910368d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs @@ -551,7 +551,68 @@ namespace Learun.Application.Form } } } - + + public Dictionary GetFolderKey(string schemeInfoId, string processIdName, string keyValue) + { + Dictionary res = new Dictionary(); + + try + { + FormSchemeInfoEntity formSchemeInfoEntity = GetSchemeInfoEntity(schemeInfoId); + FormSchemeEntity formSchemeEntity = GetSchemeEntity(formSchemeInfoEntity.F_SchemeId); + FormSchemeModel formSchemeModel = formSchemeEntity.F_Scheme.ToObject(); + + // 确定主从表之间的关系 + List> TableTree = new List>();// 从表 + foreach (var table in formSchemeModel.dbTable) + { + TreeModelEx treeone = new TreeModelEx(); + treeone.data = table; + treeone.id = table.name; + treeone.parentId = table.relationName; + if (string.IsNullOrEmpty(table.relationName)) + { + treeone.parentId = "0"; + } + TableTree.Add(treeone); + } + TableTree = TableTree.ToTree(); + + // 确定表与组件之间的关系 + Dictionary> tableComponts = new Dictionary>(); + foreach (var tab in formSchemeModel.data) + { + foreach (var compont in tab.componts) + { + if (!string.IsNullOrEmpty(compont.table)) + { + if (!tableComponts.ContainsKey(compont.table)) + { + tableComponts[compont.table] = new List(); + } + if (compont.type == "upload") + { + tableComponts[compont.table].Add(compont); + } + } + } + } + GetInstanceTableData(TableTree, tableComponts, formSchemeModel.dbId, keyValue, processIdName, null, res); + return res; + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// /// 保存自定义表单数据 /// diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue index cbe42cb02..59bd5647e 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue @@ -111,7 +111,8 @@ export default { this.needTitle = this.type !== 'again' && Number(currentNode.isTitle) === 1 const formData = await this.fetchFormData(currentNode, processId) - const schemeData = await this.fetchSchemeData(currentNode) + const schemeData = await this.fetchSchemeData(currentNode); + await this.fetchFolderkeyData(currentNode, processId); const { formValue, scheme, rel } = await this.getCustomForm({ schemeData, @@ -127,7 +128,7 @@ export default { this.formValue = formValue this.code = code this.processId = processId -console.log(this.formValue,'=====',this.scheme ,) + console.log(formData,'==',schemeData) this.ready = true this.HIDE_LOADING() diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js index 54918f6f3..3d560ba81 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js @@ -259,13 +259,26 @@ export default { */ async getPostData(originFormValue, scheme) { const formValue = this.COPY(originFormValue) - var guid =this.newguid(); // 依次按照 scheme 项目遍历 for (const item of scheme) { if (item.field) { // 不是表格的情况 const path = item.__valuePath__ const val = get(formValue, path) + + if(item.type=='upload'){ + // 先生成一个guid + var guid =this.newguid(); + // 取出当前列对应的labelId + var labeId = item.id + // 从缓存取出当前审批流程所有的guid + var guids = JSON.parse(uni.getStorageSync('guids')) + if(guids){ + guid = guids[labeId] + } + } + // debugger + const result = await this.convertToPostData(item, val, originFormValue, scheme, guid) set(formValue, path, result) @@ -381,6 +394,22 @@ export default { const formData = await this.HTTP_GET('learun/adms/form/data', reqData) return formData || {} - } + }, + async fetchFolderkeyData(currentNode, keyValue) { + const { + wfForms + } = currentNode + + const reqData = wfForms + .filter(t => t.formId) + .map(t => ({ + id: t.formId, + ver: '', + schemeInfoId: t.formId, + processIdName: t.field, + keyValue + })) + const schemeData = await this.HTTP_GET('learun/adms/form/folderkey', reqData) + }, } } From 584b17e0035bab9bc886de78816e7c663022f879 Mon Sep 17 00:00:00 2001 From: liangkun Date: Wed, 24 Aug 2022 11:43:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?app2.0=E9=99=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8D=89=E7=A8=BF=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/FormApi.cs | 29 +++-------------- .../Scheme/FormSchemeBLL.cs | 27 ++++++++++++++-- .../Scheme/FormSchemeIBLL.cs | 2 ++ .../pages/nworkflow/myflow/single.vue | 7 ++--- .../pages/nworkflow/releasetask/single.vue | 5 ++- .../pages/nworkflow/workflow.js | 31 +++++++++---------- 6 files changed, 52 insertions(+), 49 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs index 4b5b15393..0a2ac508e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FormApi.cs @@ -32,35 +32,16 @@ namespace Learun.Application.WebApi.Modules private Response GetFolderkey(dynamic _) { List req = this.GetReqData>();// 获取模板请求数据 - Dictionary schemeList = new Dictionary(); - Dictionary dic = new Dictionary(); + Dictionary dic = new Dictionary(); foreach (var item in req) { - //FormSchemeInfoEntity schemeInfoEntity = formSchemeIBLL.GetSchemeInfoEntity(item.id); - //if (schemeInfoEntity != null) - //{ - // FormSchemeEntity schemeEntity = formSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId); - // if (schemeEntity != null) - // { - // if (schemeInfoEntity.F_SchemeId != item.ver) - // { - // schemeList.Add(item.id, schemeEntity); - // } - // } - //} - if (string.IsNullOrEmpty(item.processIdName)) - { - var data = formSchemeIBLL.GetInstanceForm(item.schemeInfoId, item.keyValue); - dic.Add(item.schemeInfoId, data); - } - else + if (!string.IsNullOrEmpty(item.processIdName)) { - var data = formSchemeIBLL.GetInstanceForm(item.schemeInfoId, item.processIdName, item.keyValue);// - dic.Add(item.schemeInfoId, data); + var data = formSchemeIBLL.GetFolderKey(item.schemeInfoId, item.processIdName, item.keyValue);// + dic = data; } } - - return Success(schemeList); + return Success(dic); } /// /// 获取表单模板数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs index cd910368d..778209e76 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeBLL.cs @@ -552,7 +552,7 @@ namespace Learun.Application.Form } } - public Dictionary GetFolderKey(string schemeInfoId, string processIdName, string keyValue) + public Dictionary GetFolderKey(string schemeInfoId, string processIdName, string keyValue) { Dictionary res = new Dictionary(); @@ -594,11 +594,34 @@ namespace Learun.Application.Form { tableComponts[compont.table].Add(compont); } + if (compont.type == "guid") + { + tableComponts[compont.table].Add(compont); + } + } } } GetInstanceTableData(TableTree, tableComponts, formSchemeModel.dbId, keyValue, processIdName, null, res); - return res; + Dictionary < string,string> uploadfieldkeyvalue=new Dictionary(); + foreach (var itemCompont in tableComponts) + { + foreach (FormCompontModel formitem in itemCompont.Value) + { + if (formitem.type=="upload") + { + foreach (var resitem in res) + { + if (resitem.Value.Rows.Count>0) + { + if (resitem.Value.Rows[0][formitem.field] != null) + uploadfieldkeyvalue.Add(formitem.id, resitem.Value.Rows[0][formitem.field].ToString()); + } + } + } + } + } + return uploadfieldkeyvalue; } catch (Exception ex) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeIBLL.cs index 571d48c9d..72444597a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.Form/Scheme/FormSchemeIBLL.cs @@ -137,5 +137,7 @@ namespace Learun.Application.Form /// 数据主键值 void DeleteInstanceForm(string schemeInfoId, string keyValue); #endregion + + Dictionary GetFolderKey(string itemSchemeInfoId, string itemProcessIdName, string itemKeyValue); } } diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/single.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/single.vue index 3a505760c..4ac28bcab 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/single.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/single.vue @@ -95,7 +95,6 @@ export default { // t.formId 使用表单,根据这个 formId 来获取 scheme 等信息 // t.appurl 使用移动页面,直接跳转到本地的页面;表单结构等均写死在页面里 const { wfForms } = this.currentNode - // 处理没有有效表单的情况,停止加载 if (!wfForms || wfForms.every(t => !t.formId && !t.appurl)) { this.HIDE_LOADING() @@ -197,7 +196,7 @@ export default { return } this.LOADING(`提交${actionText}中…`) - this.HTTP_POST(`/newwf${actionUrl}`, actionData, `提交${actionText}失败`).then(success => { + this.HTTP_POST(`/learun/adms/newwf${actionUrl}`, actionData, `提交${actionText}失败`).then(success => { this.HIDE_LOADING() if (success) { this.EMIT('task-list-change') @@ -216,7 +215,7 @@ export default { this.LOADING('正在提交…') const draftFormValue = this.$refs.form.getFormValue() const draftPostData = await this.getPostData(draftFormValue, this.scheme) - this.HTTP_POST('/newwf​/draft', draftPostData, '提交草稿失败').then(success => { + this.HTTP_POST('/learun/adms/newwf/draft', draftPostData, '提交草稿失败').then(success => { this.HIDE_LOADING() if (success) { this.EMIT('task-list-change') @@ -245,7 +244,7 @@ export default { postData.parentTaskId = this.taskId } const errorTips = '流程发起失败' - this.HTTP_POST('/newwf/createchildflow', postData, errorTips).then(success => { + this.HTTP_POST('/learun/adms/newwf/createchildflow', postData, errorTips).then(success => { this.HIDE_LOADING() if (success) { this.EMIT('task-list-change') diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue index 59bd5647e..f8269c91d 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/releasetask/single.vue @@ -112,8 +112,8 @@ export default { const formData = await this.fetchFormData(currentNode, processId) const schemeData = await this.fetchSchemeData(currentNode); - await this.fetchFolderkeyData(currentNode, processId); - + const fetchFolderkeyData=await this.fetchFolderkeyData(currentNode, processId); + uni.setStorageSync('guids',JSON.stringify(fetchFolderkeyData)); const { formValue, scheme, rel } = await this.getCustomForm({ schemeData, processId, @@ -128,7 +128,6 @@ export default { this.formValue = formValue this.code = code this.processId = processId - console.log(formData,'==',schemeData) this.ready = true this.HIDE_LOADING() diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js index 3d560ba81..c9d2969d3 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/workflow.js @@ -135,7 +135,7 @@ export default { // 有表单值的情况,从表单值中获取数据 const val = [] for (const valueItem of get(formData, `${schemeItem.F_SchemeInfoId}.${t.table}`, - [])) { + [])) { const tableItemValue = {} for (const fieldItem of t.fieldsData.filter(t => t.field)) { const formDataValue = get(valueItem, fieldItem.field.toLowerCase()) @@ -243,13 +243,13 @@ export default { rel } }, - newguid(){ - return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random() * 16 | 0, - v = c == 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); - }, + newguid() { + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16 | 0, + v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + }, /** * 获取最终需要 POST 的数据 * 参数:formValue, scheme @@ -265,20 +265,18 @@ export default { // 不是表格的情况 const path = item.__valuePath__ const val = get(formValue, path) - - if(item.type=='upload'){ + + if (item.type == 'upload') { // 先生成一个guid - var guid =this.newguid(); + var guid = this.newguid(); // 取出当前列对应的labelId var labeId = item.id // 从缓存取出当前审批流程所有的guid var guids = JSON.parse(uni.getStorageSync('guids')) - if(guids){ + if (guids) { guid = guids[labeId] } } - // debugger - const result = await this.convertToPostData(item, val, originFormValue, scheme, guid) set(formValue, path, result) @@ -399,7 +397,7 @@ export default { const { wfForms } = currentNode - + const reqData = wfForms .filter(t => t.formId) .map(t => ({ @@ -409,7 +407,8 @@ export default { processIdName: t.field, keyValue })) - const schemeData = await this.HTTP_GET('learun/adms/form/folderkey', reqData) + const folderkeyData = await this.HTTP_GET('learun/adms/form/folderkey', reqData) + return folderkeyData || {} }, } }