@@ -21,12 +21,28 @@ 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<FolderKeyReq> req = this.GetReqData<List<FolderKeyReq>>();// 获取模板请求数据 | |||
Dictionary<string, string> dic = new Dictionary<string, string>(); | |||
foreach (var item in req) | |||
{ | |||
if (!string.IsNullOrEmpty(item.processIdName)) | |||
{ | |||
var data = formSchemeIBLL.GetFolderKey(item.schemeInfoId, item.processIdName, item.keyValue);// | |||
dic = data; | |||
} | |||
} | |||
return Success(dic); | |||
} | |||
/// <summary> | |||
/// 获取表单模板数据 | |||
/// </summary> | |||
@@ -104,6 +120,35 @@ namespace Learun.Application.WebApi.Modules | |||
} | |||
#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 { | |||
/// <summary> | |||
/// 表单请求Id | |||
@@ -551,7 +551,91 @@ namespace Learun.Application.Form | |||
} | |||
} | |||
} | |||
public Dictionary<string, string> 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); | |||
} | |||
if (compont.type == "guid") | |||
{ | |||
tableComponts[compont.table].Add(compont); | |||
} | |||
} | |||
} | |||
} | |||
GetInstanceTableData(TableTree, tableComponts, formSchemeModel.dbId, keyValue, processIdName, null, res); | |||
Dictionary < string,string> uploadfieldkeyvalue=new Dictionary<string, string>(); | |||
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) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 保存自定义表单数据 | |||
/// </summary> | |||
@@ -137,5 +137,7 @@ namespace Learun.Application.Form | |||
/// <param name="keyValue">数据主键值</param> | |||
void DeleteInstanceForm(string schemeInfoId, string keyValue); | |||
#endregion | |||
Dictionary<string, string> GetFolderKey(string itemSchemeInfoId, string itemProcessIdName, string itemKeyValue); | |||
} | |||
} |
@@ -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') | |||
@@ -111,8 +111,9 @@ 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); | |||
const fetchFolderkeyData=await this.fetchFolderkeyData(currentNode, processId); | |||
uni.setStorageSync('guids',JSON.stringify(fetchFolderkeyData)); | |||
const { formValue, scheme, rel } = await this.getCustomForm({ | |||
schemeData, | |||
processId, | |||
@@ -127,7 +128,6 @@ export default { | |||
this.formValue = formValue | |||
this.code = code | |||
this.processId = processId | |||
console.log(this.formValue,'=====',this.scheme ,) | |||
this.ready = true | |||
this.HIDE_LOADING() | |||
@@ -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 | |||
@@ -259,13 +259,24 @@ 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] | |||
} | |||
} | |||
const result = await this.convertToPostData(item, val, originFormValue, scheme, guid) | |||
set(formValue, path, result) | |||
@@ -381,6 +392,23 @@ 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 folderkeyData = await this.HTTP_GET('learun/adms/form/folderkey', reqData) | |||
return folderkeyData || {} | |||
}, | |||
} | |||
} |