@@ -21,12 +21,47 @@ namespace Learun.Application.WebApi.Modules | |||||
{ | { | ||||
Get["/scheme"] = GetScheme; | Get["/scheme"] = GetScheme; | ||||
Get["/data"] = GetData; | Get["/data"] = GetData; | ||||
Get["/folderkey"] = GetFolderkey; | |||||
Post["/save"] = Save; | Post["/save"] = Save; | ||||
Post["/delete"] = DeleteForm; | Post["/delete"] = DeleteForm; | ||||
} | } | ||||
private FormSchemeIBLL formSchemeIBLL = new FormSchemeBLL(); | private FormSchemeIBLL formSchemeIBLL = new FormSchemeBLL(); | ||||
private Response GetFolderkey(dynamic _) | |||||
{ | |||||
List<FolderKeyReq> req = this.GetReqData<List<FolderKeyReq>>();// 获取模板请求数据 | |||||
Dictionary<string, FormSchemeEntity> schemeList = new Dictionary<string, FormSchemeEntity>(); | |||||
Dictionary<string, object> dic = new Dictionary<string, object>(); | |||||
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); | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 获取表单模板数据 | /// 获取表单模板数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -104,6 +139,35 @@ namespace Learun.Application.WebApi.Modules | |||||
} | } | ||||
#region 请求参数 | #region 请求参数 | ||||
private class FolderKeyReq | |||||
{ | |||||
/// <summary> | |||||
/// 表单请求Id | |||||
/// </summary> | |||||
public string id { get; set; } | |||||
/// <summary> | |||||
/// 当前自定义表单版本号 | |||||
/// </summary> | |||||
public string ver { get; set; } | |||||
/// <summary> | |||||
/// 流程模板id | |||||
/// </summary> | |||||
public string schemeInfoId { get; set; } | |||||
/// <summary> | |||||
/// 关联字段名称 | |||||
/// </summary> | |||||
public string processIdName { get; set; } | |||||
/// <summary> | |||||
/// 数据主键值 | |||||
/// </summary> | |||||
public string keyValue { get; set; } | |||||
/// <summary> | |||||
/// 表单数据 | |||||
/// </summary> | |||||
public string formData { get; set; } | |||||
} | |||||
private class SchemeReq { | private class SchemeReq { | ||||
/// <summary> | /// <summary> | ||||
/// 表单请求Id | /// 表单请求Id | ||||
@@ -551,7 +551,68 @@ namespace Learun.Application.Form | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public Dictionary<string, DataTable> GetFolderKey(string schemeInfoId, string processIdName, string keyValue) | |||||
{ | |||||
Dictionary<string, DataTable> res = new Dictionary<string, DataTable>(); | |||||
try | |||||
{ | |||||
FormSchemeInfoEntity formSchemeInfoEntity = GetSchemeInfoEntity(schemeInfoId); | |||||
FormSchemeEntity formSchemeEntity = GetSchemeEntity(formSchemeInfoEntity.F_SchemeId); | |||||
FormSchemeModel formSchemeModel = formSchemeEntity.F_Scheme.ToObject<FormSchemeModel>(); | |||||
// 确定主从表之间的关系 | |||||
List<TreeModelEx<FormTableModel>> TableTree = new List<TreeModelEx<FormTableModel>>();// 从表 | |||||
foreach (var table in formSchemeModel.dbTable) | |||||
{ | |||||
TreeModelEx<FormTableModel> treeone = new TreeModelEx<FormTableModel>(); | |||||
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<string, List<FormCompontModel>> tableComponts = new Dictionary<string, List<FormCompontModel>>(); | |||||
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<FormCompontModel>(); | |||||
} | |||||
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); | |||||
} | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 保存自定义表单数据 | /// 保存自定义表单数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -111,7 +111,8 @@ export default { | |||||
this.needTitle = this.type !== 'again' && Number(currentNode.isTitle) === 1 | this.needTitle = this.type !== 'again' && Number(currentNode.isTitle) === 1 | ||||
const formData = await this.fetchFormData(currentNode, processId) | 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({ | const { formValue, scheme, rel } = await this.getCustomForm({ | ||||
schemeData, | schemeData, | ||||
@@ -127,7 +128,7 @@ export default { | |||||
this.formValue = formValue | this.formValue = formValue | ||||
this.code = code | this.code = code | ||||
this.processId = processId | this.processId = processId | ||||
console.log(this.formValue,'=====',this.scheme ,) | |||||
console.log(formData,'==',schemeData) | |||||
this.ready = true | this.ready = true | ||||
this.HIDE_LOADING() | this.HIDE_LOADING() | ||||
@@ -259,13 +259,26 @@ export default { | |||||
*/ | */ | ||||
async getPostData(originFormValue, scheme) { | async getPostData(originFormValue, scheme) { | ||||
const formValue = this.COPY(originFormValue) | const formValue = this.COPY(originFormValue) | ||||
var guid =this.newguid(); | |||||
// 依次按照 scheme 项目遍历 | // 依次按照 scheme 项目遍历 | ||||
for (const item of scheme) { | for (const item of scheme) { | ||||
if (item.field) { | if (item.field) { | ||||
// 不是表格的情况 | // 不是表格的情况 | ||||
const path = item.__valuePath__ | const path = item.__valuePath__ | ||||
const val = get(formValue, path) | 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) | const result = await this.convertToPostData(item, val, originFormValue, scheme, guid) | ||||
set(formValue, path, result) | set(formValue, path, result) | ||||
@@ -381,6 +394,22 @@ export default { | |||||
const formData = await this.HTTP_GET('learun/adms/form/data', reqData) | const formData = await this.HTTP_GET('learun/adms/form/data', reqData) | ||||
return formData || {} | 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) | |||||
}, | |||||
} | } | ||||
} | } |