# Conflicts: # Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js临城职教中职
@@ -32,8 +32,8 @@ | |||
<input id="StuNum" type="text" class="form-control" readonly="readonly" /> | |||
</div> | |||
<div class="col-xs-6 lr-form-item" data-table="ClassInfo"> | |||
<div class="lr-form-item-title">班主任</div> | |||
<div id="ClassDiredctorNo"></div> | |||
<div class="lr-form-item-title">班主任<font face="宋体">*</font></div> | |||
<div id="ClassDiredctorNo" isvalid="yes" checkexpession="NotNull"></div> | |||
</div> | |||
<div class="col-xs-6 lr-form-item" data-table="ClassInfo"> | |||
<div class="lr-form-item-title">辅导员</div> | |||
@@ -47,7 +47,7 @@ | |||
@*<a id="lr_classType" class="btn btn-default"><i class="fa fa-unlock"></i> 班级类型设定</a>*@ | |||
</div> | |||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | |||
<a id="lr_stu" class="btn btn-default"><i class="fa fa-eye"></i> 查看学生</a> | |||
@*<a id="lr_stu" class="btn btn-default"><i class="fa fa-eye"></i> 查看学生</a>*@ | |||
<a id="lr_arrange" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 班主任/辅导员安排</a> | |||
</div> | |||
</div> | |||
@@ -7,6 +7,27 @@ | |||
<div class="lr-layout-wrap lr-layout-wrap-notitle "> | |||
<div class="lr-layout-tool"> | |||
<div class="lr-layout-tool-left"> | |||
<div class="lr-layout-tool-item"> | |||
<div id="datesearch"></div> | |||
</div> | |||
<div class="lr-layout-tool-item"> | |||
<div id="multiple_condition_query"> | |||
<div class="lr-query-formcontent"> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">学号</div> | |||
<input id="StuNo" type="text" class="form-control"/> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">姓名</div> | |||
<input id="StuName" type="text" class="form-control"/> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">奖励名称</div> | |||
<input id="EncourgeName" type="text" class="form-control"/> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="lr-layout-tool-right"> | |||
<div class=" btn-group btn-group-sm"> | |||
@@ -7,12 +7,44 @@ | |||
var refreshGirdData; | |||
var bootstrap = function ($, learun) { | |||
"use strict"; | |||
var startTime; | |||
var endTime; | |||
var page = { | |||
init: function () { | |||
page.initGird(); | |||
page.bind(); | |||
}, | |||
bind: function () { | |||
// 时间搜索框 | |||
$('#datesearch').lrdate({ | |||
dfdata: [ | |||
{ name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } } | |||
], | |||
// 月 | |||
mShow: false, | |||
premShow: false, | |||
// 季度 | |||
jShow: false, | |||
prejShow: false, | |||
// 年 | |||
ysShow: false, | |||
yxShow: false, | |||
preyShow: false, | |||
yShow: false, | |||
// 默认 | |||
dfvalue: '3', | |||
selectfn: function (begin, end) { | |||
startTime = begin; | |||
endTime = end; | |||
page.search(); | |||
} | |||
}); | |||
$('#multiple_condition_query').lrMultipleQuery(function (queryJson) { | |||
page.search(queryJson); | |||
}, 200, 400); | |||
// 刷新 | |||
$('#lr_refresh').on('click', function () { | |||
location.reload(); | |||
@@ -65,12 +97,12 @@ var bootstrap = function ($, learun) { | |||
$('#gridtable').lrAuthorizeJfGrid({ | |||
url: top.$.rootUrl + '/EducationalAdministration/StuEncourgement/GetPageList', | |||
headData: [ | |||
{ label: "学号", name: "StuNo", width: 100, align: "left"}, | |||
{ label: "姓名", name: "StuName", width: 100, align: "left"}, | |||
{ label: "奖励名称", name: "EncourgeName", width: 100, align: "left"}, | |||
{ label: "奖励原因", name: "Reason", width: 100, align: "left"}, | |||
{ label: "奖励金额", name: "Fee", width: 100, align: "left"}, | |||
{ label: "奖励日期", name: "EncourgeDate", width: 100, align: "left"}, | |||
{ label: "学号", name: "StuNo", width: 200, align: "left"}, | |||
{ label: "姓名", name: "StuName", width: 200, align: "left"}, | |||
{ label: "奖励名称", name: "EncourgeName", width: 200, align: "left"}, | |||
{ label: "奖励原因", name: "Reason", width: 200, align: "left"}, | |||
{ label: "奖励金额", name: "Fee", width: 200, align: "left"}, | |||
{ label: "奖励日期", name: "EncourgeDate", width: 200, align: "left"}, | |||
], | |||
mainId:'ID', | |||
isPage: true | |||
@@ -79,6 +111,8 @@ var bootstrap = function ($, learun) { | |||
}, | |||
search: function (param) { | |||
param = param || {}; | |||
param.StartTime = startTime; | |||
param.EndTime = endTime; | |||
$('#gridtable').jfGridSet('reload',{ queryJson: JSON.stringify(param) }); | |||
} | |||
}; | |||
@@ -19,7 +19,7 @@ | |||
<input id="StuName" type="text" class="form-control" /> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">第几级</div> | |||
<div class="lr-form-item-title">年级</div> | |||
<input id="Grade" type="text" class="form-control" /> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
@@ -5,14 +5,14 @@ | |||
<div class="lr-layout lr-layout-left-center" id="lr_layout"> | |||
<div class="lr-layout-left"> | |||
<div class="lr-layout-wrap"> | |||
<div class="lr-layout-title lrlt ">树形列表</div> | |||
<div class="lr-layout-title lrlt ">班级列表</div> | |||
<div id="dataTree" class="lr-layout-body"></div> | |||
</div> | |||
</div> | |||
<div class="lr-layout-center"> | |||
<div class="lr-layout-wrap "> | |||
<div class="lr-layout-title"> | |||
<span id="titleinfo" class="lrlt">列表信息</span> | |||
<span id="titleinfo" class="lrlt">学生列表信息</span> | |||
</div> | |||
<div class="lr-layout-tool"> | |||
<div class="lr-layout-tool-left"> | |||
@@ -48,7 +48,8 @@ var bootstrap = function ($, learun) { | |||
label: "出生日期", name: "Birthday", width: 100, align: "left", | |||
formatter: function (cellvalue) { | |||
return learun.formatDate(cellvalue, 'yyyy-MM-dd'); | |||
} }, | |||
} | |||
}, | |||
{ label: "身份证号", name: "IdentityCardNo", width: 150, align: "left" }, | |||
{ | |||
label: "民族", name: "NationalityNo", width: 100, align: "left", | |||
@@ -170,6 +171,12 @@ var bootstrap = function ($, learun) { | |||
page.search(); | |||
}, | |||
search: function (param) { | |||
if (learun.clientdata.get(['userinfo']).account.toLowerCase() != "system") {//登录用户是system时,列表展示所有学生;其他用户登录时,必须选择左侧班级才能查看学生; | |||
if (Class == "" || Class == undefined || Class == null) { | |||
learun.alert.warning("请选择左侧班级!"); | |||
return false; | |||
} | |||
} | |||
param = param || {}; | |||
param.ClassNo = Class; | |||
$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); | |||
@@ -7,6 +7,27 @@ | |||
<div class="lr-layout-wrap lr-layout-wrap-notitle "> | |||
<div class="lr-layout-tool"> | |||
<div class="lr-layout-tool-left"> | |||
<div class="lr-layout-tool-item"> | |||
<div id="datesearch"></div> | |||
</div> | |||
<div class="lr-layout-tool-item"> | |||
<div id="multiple_condition_query"> | |||
<div class="lr-query-formcontent"> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">学号</div> | |||
<input id="StuNo" type="text" class="form-control" /> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">姓名</div> | |||
<input id="StuName" type="text" class="form-control" /> | |||
</div> | |||
<div class="col-xs-12 lr-form-item"> | |||
<div class="lr-form-item-title">处分名称</div> | |||
<div id="PunishNo"></div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="lr-layout-tool-right"> | |||
<div class=" btn-group btn-group-sm"> | |||
@@ -7,12 +7,46 @@ | |||
var refreshGirdData; | |||
var bootstrap = function ($, learun) { | |||
"use strict"; | |||
var startTime; | |||
var endTime; | |||
var page = { | |||
init: function () { | |||
page.initGird(); | |||
page.bind(); | |||
}, | |||
bind: function () { | |||
// 时间搜索框 | |||
$('#datesearch').lrdate({ | |||
dfdata: [ | |||
{ name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } }, | |||
{ name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } } | |||
], | |||
// 月 | |||
mShow: false, | |||
premShow: false, | |||
// 季度 | |||
jShow: false, | |||
prejShow: false, | |||
// 年 | |||
ysShow: false, | |||
yxShow: false, | |||
preyShow: false, | |||
yShow: false, | |||
// 默认 | |||
dfvalue: '3', | |||
selectfn: function (begin, end) { | |||
startTime = begin; | |||
endTime = end; | |||
page.search(); | |||
} | |||
}); | |||
$('#multiple_condition_query').lrMultipleQuery(function (queryJson) { | |||
page.search(queryJson); | |||
}, 200, 400); | |||
$('#PunishNo').lrDataItemSelect({ code: 'Punishment' }); | |||
// 刷新 | |||
$('#lr_refresh').on('click', function () { | |||
location.reload(); | |||
@@ -132,6 +166,8 @@ var bootstrap = function ($, learun) { | |||
}, | |||
search: function (param) { | |||
param = param || {}; | |||
param.StartTime = startTime; | |||
param.EndTime = endTime; | |||
$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); | |||
} | |||
}; | |||
@@ -6,6 +6,7 @@ | |||
*/ | |||
var selectedRow; | |||
var refreshGirdData; | |||
var refreshGirdData2; | |||
//课程列 | |||
var LessonTemp = []; | |||
var bootstrap = function ($, learun) { | |||
@@ -46,12 +47,8 @@ var bootstrap = function ($, learun) { | |||
learun.layerConfirm('是否准许 ' + stuName + ' 毕业?', function (res) { | |||
if (res) { | |||
learun.getForm(top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/AllowGraduate?stuNo=' + keyValue +'&status=1', function () { | |||
refreshGirdData(); | |||
//$('#btn_Search').trigger('click'); | |||
refreshGirdData2(); | |||
}); | |||
//learun.httpAsync('get', top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/AllowGraduate', { stuNo: keyValue, status: '1' }, function () { | |||
// $('#btn_Search').trigger('click'); | |||
//}); | |||
} | |||
}); | |||
} | |||
@@ -64,7 +61,7 @@ var bootstrap = function ($, learun) { | |||
learun.layerConfirm('是否不准 ' + stuName + ' 毕业?', function (res) { | |||
if (res) { | |||
learun.getForm(top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/AllowGraduate?stuNo=' + keyValue + '&status=0', function () { | |||
$('#btn_Search').trigger('click'); | |||
refreshGirdData2(); | |||
}); | |||
} | |||
}); | |||
@@ -185,5 +182,18 @@ var bootstrap = function ($, learun) { | |||
refreshGirdData = function () { | |||
page.search(); | |||
}; | |||
refreshGirdData2 = function () { | |||
var p = {}; | |||
p.DeptNo = $('#DeptNo').lrselectGet(); | |||
p.MajorNo = $('#MajorNo').lrselectGet(); | |||
p.ClassNo = $('#ClassNo').lrselectGet(); | |||
p.StuNo = $('#StuNo').lrselectGet(); | |||
if (p.ClassNo == null || p.ClassNo == "") { | |||
learun.alert.warning("请选择班级!"); | |||
return; | |||
} | |||
//page.initGird(); | |||
page.search(p); | |||
}; | |||
page.init(); | |||
} |
@@ -3,25 +3,25 @@ | |||
Layout = "~/Views/Shared/_Form.cshtml"; | |||
} | |||
<div class="lr-form-wrap"> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords" > | |||
<div class="lr-form-item-title">系</div> | |||
<div id="DeptNo" ></div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords"> | |||
<div class="lr-form-item-title">系<font face="宋体">*</font></div> | |||
<div id="DeptNo" isvalid="yes" checkexpession="NotNull"></div> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords" > | |||
<div class="lr-form-item-title">专业</div> | |||
<div id="MajorNo" ></div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords"> | |||
<div class="lr-form-item-title">专业<font face="宋体">*</font></div> | |||
<div id="MajorNo" isvalid="yes" checkexpession="NotNull"></div> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords" > | |||
<div class="lr-form-item-title">班级</div> | |||
<div id="ClassNo" ></div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords"> | |||
<div class="lr-form-item-title">班级<font face="宋体">*</font></div> | |||
<div id="ClassNo" isvalid="yes" checkexpession="NotNull"></div> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords" > | |||
<div class="lr-form-item-title">学生</div> | |||
<div id="Stuno" ></div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords"> | |||
<div class="lr-form-item-title">学生<font face="宋体">*</font></div> | |||
<div id="Stuno" isvalid="yes" checkexpession="NotNull"></div> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords" > | |||
<div class="col-xs-12 lr-form-item" data-table="APStuHealthRecords"> | |||
<div class="lr-form-item-title">描述</div> | |||
<textarea id="Remark" class="form-control" style="height:100px;" ></textarea> | |||
<textarea id="Remark" class="form-control" style="height:100px;"></textarea> | |||
</div> | |||
</div> | |||
@Html.AppendJsFile("/Areas/LogisticsManagement/Views/APStuHealthRecords/Form.js") |
@@ -4,12 +4,12 @@ | |||
} | |||
<div class="lr-form-wrap"> | |||
<div class="col-xs-12 lr-form-item" data-table="MSRIntentionManagement"> | |||
<div class="lr-form-item-title">联系方式</div> | |||
<input id="Mobile" type="text" class="form-control" /> | |||
<div class="lr-form-item-title">联系方式<font face="宋体">*</font></div> | |||
<input id="Mobile" type="text" class="form-control" isvalid="yes" checkexpession="Mobile"/> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="MSRIntentionManagement"> | |||
<div class="lr-form-item-title">年龄</div> | |||
<input id="Age" type="text" class="form-control" /> | |||
<div class="lr-form-item-title">年龄<font face="宋体">*</font></div> | |||
<input id="Age" type="number" class="form-control" isvalid="yes" checkexpession="NotNull"/> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="MSRIntentionManagement"> | |||
<div class="lr-form-item-title">身高</div> | |||
@@ -4,8 +4,8 @@ | |||
} | |||
<div class="lr-form-wrap"> | |||
<div class="col-xs-12 lr-form-item" data-table="MSRMilitaryRecord"> | |||
<div class="lr-form-item-title">参军记录</div> | |||
<input id="Record" type="text" class="form-control" /> | |||
<div class="lr-form-item-title">参军记录<font face="宋体">*</font></div> | |||
<input id="Record" type="text" class="form-control" isvalid="yes" checkexpession="NotNull"/> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="MSRMilitaryRecord"> | |||
<div class="lr-form-item-title">备注</div> | |||
@@ -7,136 +7,135 @@ using System.IO; | |||
namespace Learun.Application.WebApi.Modules | |||
{ | |||
public class AnnexesApiWx : BaseApi | |||
{ | |||
public AnnexesApiWx() | |||
: base("/learun/adms/annexes") | |||
public class AnnexesApiWx : BaseApi | |||
{ | |||
Get["/wxlist"] = WxGetList; | |||
Get["/wxdown"] = WxDownload; | |||
Get["/wxfileinfo"] = WxFileInfo; | |||
Post["/wxupload"] = WxUpload; | |||
Post["/wxdelete"] = WxDeleteFile; | |||
public AnnexesApiWx() | |||
: base("/learun/adms/annexes") | |||
{ | |||
Get["/wxlist"] = WxGetList; | |||
Get["/wxdown"] = WxDownload; | |||
Get["/wxfileinfo"] = WxFileInfo; | |||
Post["/wxupload"] = WxUpload; | |||
Post["/wxdelete"] = WxDeleteFile; | |||
} | |||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||
/// <summary> | |||
/// 获取附件列表 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxGetList(dynamic _) | |||
{ | |||
var keyValue = this.GetReqData(); | |||
var list = annexesFileIBLL.GetList(keyValue); | |||
return Success(list); | |||
} | |||
/// <summary> | |||
/// 上传附件图片文件 | |||
/// <summary> | |||
/// <returns></returns> | |||
public Response WxUpload(dynamic _) | |||
{ | |||
var files = (List<HttpFile>)this.Context.Request.Files; | |||
string folderId = Request.Form["folderId"]; | |||
string filePath = Config.GetValue("AnnexesFile"); | |||
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); | |||
string fileEextension = Path.GetExtension(files[0].Name); | |||
string fileType = fileEextension.Replace(".", ""); | |||
string fileGuid = Guid.NewGuid().ToString(); | |||
string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension); | |||
//创建文件夹 | |||
string path = Path.GetDirectoryName(virtualPath); | |||
Directory.CreateDirectory(path); | |||
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); | |||
if (!System.IO.File.Exists(virtualPath)) | |||
{ | |||
byte[] bytes = new byte[files[0].Value.Length]; | |||
files[0].Value.Read(bytes, 0, bytes.Length); | |||
FileInfo file = new FileInfo(virtualPath); | |||
FileStream fs = file.Create(); | |||
fs.Write(bytes, 0, bytes.Length); | |||
fs.Close(); | |||
//文件信息写入数据库 | |||
fileAnnexesEntity.F_Id = fileGuid; | |||
fileAnnexesEntity.F_FileName = files[0].Name; | |||
fileAnnexesEntity.F_FilePath = virtualPath; | |||
fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString(); | |||
fileAnnexesEntity.F_FileExtensions = fileEextension; | |||
fileAnnexesEntity.F_FileType = fileType; | |||
fileAnnexesEntity.F_CreateUserId = userInfo.userId; | |||
fileAnnexesEntity.F_CreateUserName = userInfo.realName; | |||
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); | |||
} | |||
return SuccessString(folderId); | |||
} | |||
/// <summary> | |||
/// 获取文件信息 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxFileInfo(dynamic _) | |||
{ | |||
var fileId = this.GetReqData(); | |||
var fileEntity = annexesFileIBLL.GetEntity(fileId); | |||
return Success(fileEntity); | |||
} | |||
/// <summary> | |||
/// 删除文件 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxDeleteFile(dynamic _) | |||
{ | |||
var fileId = this.GetReqData(); | |||
AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId); | |||
annexesFileIBLL.DeleteEntity(fileId); | |||
//删除文件 | |||
if (System.IO.File.Exists(fileInfoEntity.F_FilePath)) | |||
{ | |||
System.IO.File.Delete(fileInfoEntity.F_FilePath); | |||
} | |||
return Success("删除成功"); | |||
} | |||
/// <summary> | |||
/// 下载文件,微信小程序用 | |||
/// | |||
/// 微信小程序可以预览图片、文档 | |||
/// 支持的图片格式:.jpg .png .webp .gif | |||
/// 支持的文档格式:.doc(x) .xls(x) .ppt(x) .pdf | |||
/// | |||
/// 对于其他格式的文件,微信小程序官方未提供打开或预览的 API,文件对用户来说不可访问 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxDownload(dynamic _) | |||
{ | |||
string name = this.GetReqData(); | |||
string fileId = name.Split('.')[0]; | |||
var fileEntity = annexesFileIBLL.GetEntity(fileId); | |||
string filepath = fileEntity.F_FilePath; | |||
if (!FileDownHelper.FileExists(filepath)) | |||
{ | |||
return 404; | |||
} | |||
FileDownHelper.DownLoadWx(filepath, fileEntity.F_FileType); | |||
return Success(""); | |||
} | |||
} | |||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||
/// <summary> | |||
/// 获取附件列表 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxGetList(dynamic _) | |||
{ | |||
var keyValue = this.GetReqData(); | |||
var list = annexesFileIBLL.GetList(keyValue); | |||
return Success(list); | |||
} | |||
/// <summary> | |||
/// 上传附件图片文件 | |||
/// <summary> | |||
/// <returns></returns> | |||
public Response WxUpload(dynamic _) | |||
{ | |||
var files = (List<HttpFile>)this.Context.Request.Files; | |||
var folderId = this.GetReqData(); | |||
string filePath = Config.GetValue("AnnexesFile"); | |||
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); | |||
string fileEextension = Path.GetExtension(files[0].Name); | |||
string fileType = fileEextension.Replace(".", ""); | |||
string fileGuid = Guid.NewGuid().ToString(); | |||
string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension); | |||
//创建文件夹 | |||
string path = Path.GetDirectoryName(virtualPath); | |||
Directory.CreateDirectory(path); | |||
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); | |||
if (!System.IO.File.Exists(virtualPath)) | |||
{ | |||
byte[] bytes = new byte[files[0].Value.Length]; | |||
files[0].Value.Read(bytes, 0, bytes.Length); | |||
FileInfo file = new FileInfo(virtualPath); | |||
FileStream fs = file.Create(); | |||
fs.Write(bytes, 0, bytes.Length); | |||
fs.Close(); | |||
//文件信息写入数据库 | |||
fileAnnexesEntity.F_Id = fileGuid; | |||
fileAnnexesEntity.F_FileName = files[0].Name; | |||
fileAnnexesEntity.F_FilePath = virtualPath; | |||
fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString(); | |||
fileAnnexesEntity.F_FileExtensions = fileEextension; | |||
fileAnnexesEntity.F_FileType = fileType; | |||
fileAnnexesEntity.F_CreateUserId = userInfo.userId; | |||
fileAnnexesEntity.F_CreateUserName = userInfo.realName; | |||
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); | |||
} | |||
return SuccessString(fileGuid); | |||
} | |||
/// <summary> | |||
/// 获取文件信息 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxFileInfo(dynamic _) | |||
{ | |||
var fileId = this.GetReqData(); | |||
var fileEntity = annexesFileIBLL.GetEntity(fileId); | |||
return Success(fileEntity); | |||
} | |||
/// <summary> | |||
/// 删除文件 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxDeleteFile(dynamic _) | |||
{ | |||
var fileId = this.GetReqData(); | |||
AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId); | |||
annexesFileIBLL.DeleteEntity(fileId); | |||
//删除文件 | |||
if (System.IO.File.Exists(fileInfoEntity.F_FilePath)) | |||
{ | |||
System.IO.File.Delete(fileInfoEntity.F_FilePath); | |||
} | |||
return Success("删除成功"); | |||
} | |||
/// <summary> | |||
/// 下载文件,微信小程序用 | |||
/// | |||
/// 微信小程序可以预览图片、文档 | |||
/// 支持的图片格式:.jpg .png .webp .gif | |||
/// 支持的文档格式:.doc(x) .xls(x) .ppt(x) .pdf | |||
/// | |||
/// 对于其他格式的文件,微信小程序官方未提供打开或预览的 API,文件对用户来说不可访问 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response WxDownload(dynamic _) | |||
{ | |||
string name = this.GetReqData(); | |||
string fileId = name.Split('.')[0]; | |||
var fileEntity = annexesFileIBLL.GetEntity(fileId); | |||
string filepath = fileEntity.F_FilePath; | |||
if (!FileDownHelper.FileExists(filepath)) | |||
{ | |||
return 404; | |||
} | |||
FileDownHelper.DownLoadWx(filepath, fileEntity.F_FileType); | |||
return Success(""); | |||
} | |||
} | |||
} |
@@ -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 | |||
@@ -48,6 +48,7 @@ namespace Learun.Application.WebApi | |||
{ | |||
ReqPageParam parameter = this.GetReqData<ReqPageParam>(); | |||
var data = mealCardRunTabIBLL.GetPageList(parameter.pagination, parameter.queryJson); | |||
data = data.OrderByDescending(x => x.centralTm); | |||
var jsonData = new | |||
{ | |||
rows = data, | |||
@@ -20,6 +20,7 @@ namespace Learun.Application.WebApi.Modules | |||
: base("/learun/news") | |||
{ | |||
Get["/list"] = GetList; | |||
Get["/shList"] = GetshList; | |||
} | |||
@@ -85,6 +86,24 @@ namespace Learun.Application.WebApi.Modules | |||
}; | |||
return Success(jsonData); | |||
} | |||
/// <summary> | |||
/// 获取页面显示列表数据 | |||
/// <summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response GetshList(dynamic _) | |||
{ | |||
NoticeEntity parameter = this.GetReqData<NoticeEntity>(); | |||
var shlist = noticeIBLL.GetEntityByProcessId(parameter.ProgressId); | |||
return Success(shlist); | |||
} | |||
#region 私有类 | |||
private class NoticeEntity | |||
{ | |||
public string ProgressId { get; set; } | |||
} | |||
#endregion | |||
} | |||
@@ -89,7 +89,7 @@ namespace Learun.Application.WebApi.Modules | |||
public Response GetStuLessonInfo(dynamic _) | |||
{ | |||
var param = this.GetReqData<TimeParameter>(); | |||
var lessonInfos = stuAttendanceIBLL.GetStuLessonInfo(userInfo.account,param.StartDate,param.EndDate); | |||
var lessonInfos = stuAttendanceIBLL.GetStuLessonInfo(userInfo.account, param.StartDate, param.EndDate); | |||
var empNos = lessonInfos.Select(a => a.EmpNo).ToList(); | |||
var lessonTerms = arrangeLessonTermIBLL.GetListByEmpNo(empNos); | |||
@@ -223,10 +223,10 @@ namespace Learun.Application.WebApi.Modules | |||
else if (param.Description == "教师") | |||
{ | |||
//教师 | |||
var empInfo = empInfoIbll.GetAllList().Where(x => x.EmpNo == userInfo.account).FirstOrDefault().EmpNo; | |||
var empInfo = empInfoIbll.GetAllList().Where(x => x.EmpNo == param.Account).FirstOrDefault().EmpNo; | |||
if (empInfo != null) | |||
{ | |||
Data = arrangeLessonTermIBLL.GetTimeTableInEducation(param.StartDate, param.EndDate, "", param.EmpNo, ""); | |||
Data = arrangeLessonTermIBLL.GetTimeTableInEducation(param.StartDate, param.EndDate, "", param.Account, ""); | |||
} | |||
} | |||
@@ -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); | |||
} | |||
} |
@@ -164,11 +164,19 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
} | |||
if (!queryParam["accountName"].IsEmpty()) | |||
{ | |||
var IsPhone = queryParam["IsPhone"].ToString(); | |||
if (IsPhone == "0") | |||
var IsPhone = ""; | |||
if (!queryParam["IsPhone"].IsEmpty()) | |||
{ | |||
dp.Add("accountName", queryParam["accountName"].ToString(), DbType.String); | |||
strSql.Append(" AND t.accountName = @accountName "); | |||
IsPhone = queryParam["IsPhone"].ToString(); | |||
if (IsPhone == "0") | |||
{ | |||
var accountName = queryParam["accountName"].ToString(); | |||
if (accountName != "超级管理员") | |||
{ | |||
dp.Add("accountName", queryParam["accountName"].ToString(), DbType.String); | |||
strSql.Append(" AND t.accountName = @accountName "); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
@@ -77,7 +77,17 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String); | |||
strSql.Append(" AND t.ClassNo = @ClassNo "); | |||
} | |||
if (!queryParam["EncourgeName"].IsEmpty()) | |||
{ | |||
dp.Add("EncourgeName", "%" + queryParam["EncourgeName"].ToString() + "%", DbType.String); | |||
strSql.Append(" AND t.EncourgeName Like @EncourgeName "); | |||
} | |||
if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) | |||
{ | |||
dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime); | |||
dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime); | |||
strSql.Append(" AND ( t.EncourgeDate >= @startTime AND t.EncourgeDate <= @endTime ) "); | |||
} | |||
return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
@@ -71,6 +71,18 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String); | |||
strSql.Append(" AND t.ClassNo = @ClassNo "); | |||
} | |||
if (!queryParam["PunishNo"].IsEmpty()) | |||
{ | |||
dp.Add("PunishNo", queryParam["PunishNo"].ToString(), DbType.String); | |||
strSql.Append(" AND t.PunishNo = @PunishNo "); | |||
} | |||
if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty()) | |||
{ | |||
dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime); | |||
dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime); | |||
strSql.Append(" AND ( t.PunishDate >= @startTime AND t.PunishDate <= @endTime ) "); | |||
} | |||
return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
@@ -44,8 +44,8 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop | |||
{ | |||
try | |||
{ | |||
var refresh_token = _redis.Read<string>("refresh_token"); | |||
var access_token = _redis.Read<string>("access_token"); | |||
var refresh_token = _redis.Read<string>("refresh_token") == "null" ? "" : _redis.Read<string>("refresh_token"); | |||
var access_token = _redis.Read<string>("access_token") == "null" ? "" : _redis.Read<string>("access_token"); | |||
if (string.IsNullOrEmpty(refresh_token) || string.IsNullOrEmpty(_redis.Read<string>("access_token"))) | |||
{ | |||
//用户授权 | |||
@@ -75,12 +75,15 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop | |||
private void login() | |||
{ | |||
var login_url = InsUrl + "/prod-api/api/web/collect/oauth2/login?grant_type=password&client_id=" + client_id + "&username=" + username + "&password=" + password; | |||
var login_res_str = HttpMethods.Get(login_url); | |||
var login_res_str = HttpMethods.Post(login_url); | |||
var login_res = JsonConvert.DeserializeObject<InsResult>(login_res_str); | |||
var login_data = login_res.data; | |||
_redis.Write($"access_token", ((dynamic)login_data)?.access_token, TimeSpan.FromSeconds(200)); | |||
_redis.Write($"client_secret", ((dynamic)login_data)?.client_secret, TimeSpan.FromSeconds(160000)); | |||
_redis.Write($"refresh_token", ((dynamic)login_data)?.refresh_token, TimeSpan.FromSeconds(250)); | |||
string access_token = ((dynamic)login_data)?.access_token; | |||
string client_secret = ((dynamic)login_data)?.client_secret; | |||
string refresh_token = ((dynamic)login_data)?.refresh_token; | |||
_redis.Write($"access_token", access_token, TimeSpan.FromSeconds(200)); | |||
_redis.Write($"client_secret", client_secret, TimeSpan.FromSeconds(160000)); | |||
_redis.Write($"refresh_token", refresh_token, TimeSpan.FromSeconds(250)); | |||
} | |||
/// <summary> | |||
/// 刷新token | |||
@@ -92,7 +95,7 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop | |||
var refresh_url = | |||
InsUrl + "/prod-api/api/web/collect/oauth2/refresh?grant_type=refresh_token&client_id=" + | |||
client_id + "&client_secret=" + client_secret + "&refresh_token=" + refresh_token; | |||
var refresh_res_str = HttpMethods.Get(refresh_url); | |||
var refresh_res_str = HttpMethods.Post(refresh_url); | |||
var refresh_res = JsonConvert.DeserializeObject<InsResult>(refresh_res_str); | |||
if (refresh_res == null || ((dynamic)refresh_res)?.code != 200) | |||
{ | |||
@@ -101,8 +104,10 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop | |||
login(); | |||
return; | |||
} | |||
_redis.Write($"access_token", ((dynamic)refresh_res)?.access_token, TimeSpan.FromSeconds(200)); | |||
_redis.Write($"refresh_token", ((dynamic)refresh_res)?.refresh_token, TimeSpan.FromSeconds(250)); | |||
string atoken = ((dynamic)refresh_res)?.access_token; | |||
string rtoken = ((dynamic)refresh_res)?.refresh_token; | |||
_redis.Write($"access_token", atoken, TimeSpan.FromSeconds(200)); | |||
_redis.Write($"refresh_token", rtoken, TimeSpan.FromSeconds(250)); | |||
} | |||
/// <summary> | |||
/// 校区基础数据 | |||
@@ -24,274 +24,310 @@ import moment from 'moment' | |||
*/ | |||
export default { | |||
methods: { | |||
/** | |||
* 获取一个 scheme 表单项的源数据 (加载表单时使用) | |||
* 参数: 单个 schemeItem | |||
* | |||
* radio、select、checkbox、layer 这四种表单项,需要加载额外的选单数据 | |||
* 选单数据有两种获取方式: | |||
* 1、来自数据字典: | |||
* 数据字典在 this.GET_GLOBAL('dataDictionary') | |||
* 表单使用的字段在 schemeItem.itemCode | |||
* 选单数据中的 text 字段作为显示, value 字段作为值 | |||
* | |||
* 2、来自数据源: | |||
* 将 schemeItem.dataSourceId 按符号「,」逗号分割为数组,分割为: [code, displayField, valueField] | |||
* 数据源需要请求 API 来获取,请求需要带上数据源的编号 code | |||
* displayField、valueField 分别为展示字段和值绑定字段 | |||
* | |||
* 选单数据有两种格式: | |||
* 1、对于 radio、select、checkbox 来说: | |||
* 只需要一个数组,数组形如: [{ text: '选项文字', value: '选项值' }, ...] | |||
* 将获取的数据绑定到组件的 range 属性上即可 | |||
* 全局数据中默认是对象形式,使用 Object.values() 转化即可 | |||
* | |||
* 2、对于 layer 来说: | |||
* 返回一个对象,形如 { source, layerData, selfField } | |||
* source: 为弹层中列出的数据,是一个数组 | |||
* layerData: 需要在弹层窗口中展示的字段及标题文字,形如: [{ name:'要展示的字段名', label:'标题文字' }] | |||
* selfField: 该表单值绑定哪个字段,默认为绑定到自身的字段 | |||
*/ | |||
async getSourceData(schemeItem) { | |||
if (['radio', 'select', 'checkbox'].includes(schemeItem.type)) { | |||
// radio select checkbox 三种情况 | |||
if (!schemeItem.dataSource || Number(schemeItem.dataSource) === 0) { | |||
// dataSource 为 0,使用 clientData | |||
return Object | |||
.values(this.GET_GLOBAL('dataDictionary')[schemeItem.itemCode]) | |||
.map(t => ({ value: t.value, text: t.text })) | |||
} else { | |||
// dataSource 不为 0,使用数据源,需要请求接口,并且提取出显示字段和实际字段 | |||
const [code, displayField = schemeItem.showField, valueField = schemeItem.saveField] = schemeItem.dataSourceId | |||
.split(',') | |||
const sourceData = await this.FETCH_DATASOURCE(code) | |||
if (!sourceData) { return [] } | |||
return sourceData.data.map(t => ({ text: t[displayField], value: t[valueField] })) | |||
} | |||
} else if (['layer'].includes(schemeItem.type)) { | |||
// layer 需要更多属性 | |||
if (!schemeItem.dataSource || Number(schemeItem.dataSource) === 0) { | |||
// dataSource 为 0,使用 clientData | |||
// clientData 对象转数组后,隐含 key:item.text 和 value:item.value 的关系 | |||
const [keyItem, valueItem] = schemeItem.layerData | |||
const source = Object | |||
.values(this.GET_GLOBAL('dataDictionary')[schemeItem.itemCode]) | |||
.map(t => ({ value: t.value, text: t.text })) | |||
return { | |||
source, | |||
layerData: [ | |||
{ name: 'text', label: keyItem.label || '', value: keyItem.value || '' }, | |||
{ name: 'value', label: valueItem.label || '', value: valueItem.value || '' } | |||
] | |||
} | |||
} else { | |||
// dataSource 不为 0,使用数据源,需要请求接口,并且提取出显示字段和实际字段 | |||
const [code] = schemeItem.dataSourceId.split(',') | |||
const sourceData = await this.FETCH_DATASOURCE(code) | |||
if (!sourceData) { return [] } | |||
const source = sourceData.data | |||
return { source, layerData: schemeItem.layerData.filter(t => (!t.hide) && (t.value || t.label)) } | |||
} | |||
} | |||
return [] | |||
}, | |||
/** | |||
* 获取一个 scheme 表单项的默认值 (用户新建表单时使用,或是编辑草稿) | |||
* 参数: 单个 schemeItem , { processId } | |||
* | |||
* 每种类别的表单项分别获取的默认值: | |||
* | |||
* currentInfo: 根据类别取当前用户/部门/公司/时间日期 | |||
* datetime: 根据 dfValue 字段表示昨天/今天/明天,格式化为字符串 | |||
* radio、select: 有 dfValue 则使用,否则取第一条 | |||
* checkbox: 有 dfValue 则使用,否则为空数组 | |||
* encode: 根据 rulecode 请求表单编码 | |||
* upload: 空数组 | |||
* guid: 赋值第二个参数中的 processId,但是如果在子表格中,赋空字符串 | |||
* girdtable: 递归所有表格项 scheme 依次为它们生成默认值 | |||
* datetimerange: 字符串 0 | |||
*/ | |||
async getDefaultData(item, prop) { | |||
const { processId } = prop | |||
switch (item.type) { | |||
case 'currentInfo': | |||
switch (item.dataType) { | |||
case 'user': | |||
return this.GET_GLOBAL('loginUser').userId | |||
case 'department': | |||
return this.GET_GLOBAL('loginUser').departmentId | |||
case 'company': | |||
return this.GET_GLOBAL('loginUser').companyId | |||
case 'time': | |||
return moment().format('YYYY-MM-DD HH:mm:ss') | |||
default: | |||
return '' | |||
} | |||
case 'datetime': | |||
const datetimeFormat = item.table ? | |||
(Number(item.dateformat) === 0 ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss') : | |||
(item.datetime === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD') | |||
const today = moment() | |||
const dfDatetime = [ | |||
today.subtract(1, 'day'), | |||
today, | |||
today.add(1, 'day') | |||
][Number(item.dfvalue)] || today | |||
return dfDatetime.format(datetimeFormat) || '' | |||
case 'radio': | |||
case 'select': | |||
const radioItem = item.__sourceData__.find(t => t.value === item.dfvalue) || item.__sourceData__[0] | |||
return item.type === 'radio' ? radioItem.value : '' | |||
case 'checkbox': | |||
if (!item.dfvalue) { | |||
return [] | |||
} | |||
return item.dfvalue.split(',').filter(t => item.__sourceData__.find(s => s.value === t)) | |||
case 'encode': | |||
const result = await this.FETCH_ENCODE(item.rulecode) | |||
return result | |||
case 'upload': | |||
return [] | |||
case 'guid': | |||
return item.table ? processId : '' | |||
case 'girdtable': | |||
const tableItemObj = {} | |||
for (const fieldItem of item.fieldsData) { | |||
tableItemObj[fieldItem.field] = await this.getDefaultData(fieldItem, prop) | |||
} | |||
return this.COPY(tableItemObj) | |||
case 'datetimerange': | |||
return '0' | |||
default: | |||
return item.dfvalue || '' | |||
} | |||
}, | |||
/** | |||
* 将单条 formData 值转化为 formValue 值 (拉取表单数据时使用) | |||
* 参数: 单个 schemeItem , 数据值 | |||
* | |||
* 具体执行逻辑: | |||
* radio、select: 剔除无效值 | |||
* checkbox: 分割成数组并剔除无效值 | |||
* upload: 分割成数组,拉取其中所有文件的信息 | |||
* datetime: 按照时间日期格式进行格式化字符串 | |||
* 其他类型: 保留原值 | |||
*/ | |||
async convertToFormValue(item, val) { | |||
switch (item.type) { | |||
case 'upload': | |||
if (!val) { return [] } | |||
const uidList = val.split(',') | |||
const fileList = [] | |||
for (const uid of uidList || []) { | |||
const fileInfo = await this.FETCH_FILEINFO(uid) | |||
if (!fileInfo) { continue } | |||
const fileType = fileInfo.F_FileType | |||
const fileSize = fileInfo.F_FileSize | |||
const path = this.API + '/annexes/wxdown?' + this.URL_QUERY(uid, true) | |||
fileList.push({ path, type: fileType, uid, size: fileSize }) | |||
} | |||
return fileList | |||
case 'select': | |||
case 'radio': | |||
if (!val || !item.__sourceData__.map(t => t.value).includes(val)) { | |||
return '' | |||
} | |||
return val | |||
case 'checkbox': | |||
const validValue = item.__sourceData__.map(t => t.value) | |||
const checkboxVal = val.split(',') || [] | |||
return checkboxVal.filter(t => validValue.includes(t)) | |||
case 'datetime': | |||
if (!val) { | |||
return '' | |||
} | |||
return moment(val).format( | |||
Number(item.dateformat) === 0 || item.datetime === 'date' ? | |||
'YYYY-MM-DD' : | |||
'YYYY-MM-DD HH:mm:ss' | |||
) | |||
default: | |||
return val || '' | |||
} | |||
}, | |||
/** | |||
* 将一个 formValue 值转化为 post 提交值(提交表单数据时使用) | |||
* 参数: 单个 schemeItem , 表单项值 , 所有 formValue , scheme | |||
* | |||
* 具体执行逻辑: | |||
* checkbox: 将数组使用符号「,」逗号拼接成字符串 | |||
* datetimerange: 获取开始日期、结束日期,计算差值天数并保留整数 | |||
* datetime: 格式化为完整时间日期字符串 | |||
* upload: 依次上传文件,将返回的文件 ID 使用符号「,」逗号拼接成字符串 | |||
* 其他类型: 保留原值 | |||
*/ | |||
async convertToPostData(item, val, formValue, scheme) { | |||
switch (item.type) { | |||
case 'checkbox': | |||
return val ? val.join(',') : '' | |||
case 'datetimerange': | |||
const startTime = get(formValue, scheme.find(t => t.id === item.startTime).__valuePath__, null) | |||
const endTime = get(formValue, scheme.find(t => t.id === item.endTime).__valuePath__, null) | |||
if (!startTime || !endTime || moment(endTime).isBefore(startTime)) { | |||
return '' | |||
} else { | |||
return moment.duration(moment(endTime).diff(moment(startTime))).asDays().toFixed(0) | |||
} | |||
case 'datetime': | |||
return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '' | |||
case 'upload': | |||
const uploadUid = [] | |||
for (const item of val) { | |||
if (item.uid) { | |||
uploadUid.push(item.uid) | |||
continue | |||
} | |||
const fileId = await this.HTTP_UPLOAD(item.path||item) | |||
if (fileId) { | |||
uploadUid.push(fileId) | |||
} | |||
} | |||
return uploadUid.join(',') | |||
default: | |||
return val || '' | |||
} | |||
} | |||
} | |||
methods: { | |||
/** | |||
* 获取一个 scheme 表单项的源数据 (加载表单时使用) | |||
* 参数: 单个 schemeItem | |||
* | |||
* radio、select、checkbox、layer 这四种表单项,需要加载额外的选单数据 | |||
* 选单数据有两种获取方式: | |||
* 1、来自数据字典: | |||
* 数据字典在 this.GET_GLOBAL('dataDictionary') | |||
* 表单使用的字段在 schemeItem.itemCode | |||
* 选单数据中的 text 字段作为显示, value 字段作为值 | |||
* | |||
* 2、来自数据源: | |||
* 将 schemeItem.dataSourceId 按符号「,」逗号分割为数组,分割为: [code, displayField, valueField] | |||
* 数据源需要请求 API 来获取,请求需要带上数据源的编号 code | |||
* displayField、valueField 分别为展示字段和值绑定字段 | |||
* | |||
* 选单数据有两种格式: | |||
* 1、对于 radio、select、checkbox 来说: | |||
* 只需要一个数组,数组形如: [{ text: '选项文字', value: '选项值' }, ...] | |||
* 将获取的数据绑定到组件的 range 属性上即可 | |||
* 全局数据中默认是对象形式,使用 Object.values() 转化即可 | |||
* | |||
* 2、对于 layer 来说: | |||
* 返回一个对象,形如 { source, layerData, selfField } | |||
* source: 为弹层中列出的数据,是一个数组 | |||
* layerData: 需要在弹层窗口中展示的字段及标题文字,形如: [{ name:'要展示的字段名', label:'标题文字' }] | |||
* selfField: 该表单值绑定哪个字段,默认为绑定到自身的字段 | |||
*/ | |||
async getSourceData(schemeItem) { | |||
if (['radio', 'select', 'checkbox'].includes(schemeItem.type)) { | |||
// radio select checkbox 三种情况 | |||
if (!schemeItem.dataSource || Number(schemeItem.dataSource) === 0) { | |||
// dataSource 为 0,使用 clientData | |||
return Object | |||
.values(this.GET_GLOBAL('dataDictionary')[schemeItem.itemCode]) | |||
.map(t => ({ | |||
value: t.value, | |||
text: t.text | |||
})) | |||
} else { | |||
// dataSource 不为 0,使用数据源,需要请求接口,并且提取出显示字段和实际字段 | |||
const [code, displayField = schemeItem.showField, valueField = schemeItem.saveField] = | |||
schemeItem.dataSourceId | |||
.split(',') | |||
const sourceData = await this.FETCH_DATASOURCE(code) | |||
if (!sourceData) { | |||
return [] | |||
} | |||
return sourceData.data.map(t => ({ | |||
text: t[displayField], | |||
value: t[valueField] | |||
})) | |||
} | |||
} else if (['layer'].includes(schemeItem.type)) { | |||
// layer 需要更多属性 | |||
if (!schemeItem.dataSource || Number(schemeItem.dataSource) === 0) { | |||
// dataSource 为 0,使用 clientData | |||
// clientData 对象转数组后,隐含 key:item.text 和 value:item.value 的关系 | |||
const [keyItem, valueItem] = schemeItem.layerData | |||
const source = Object | |||
.values(this.GET_GLOBAL('dataDictionary')[schemeItem.itemCode]) | |||
.map(t => ({ | |||
value: t.value, | |||
text: t.text | |||
})) | |||
return { | |||
source, | |||
layerData: [{ | |||
name: 'text', | |||
label: keyItem.label || '', | |||
value: keyItem.value || '' | |||
}, | |||
{ | |||
name: 'value', | |||
label: valueItem.label || '', | |||
value: valueItem.value || '' | |||
} | |||
] | |||
} | |||
} else { | |||
// dataSource 不为 0,使用数据源,需要请求接口,并且提取出显示字段和实际字段 | |||
const [code] = schemeItem.dataSourceId.split(',') | |||
const sourceData = await this.FETCH_DATASOURCE(code) | |||
if (!sourceData) { | |||
return [] | |||
} | |||
const source = sourceData.data | |||
return { | |||
source, | |||
layerData: schemeItem.layerData.filter(t => (!t.hide) && (t.value || t.label)) | |||
} | |||
} | |||
} | |||
return [] | |||
}, | |||
/** | |||
* 获取一个 scheme 表单项的默认值 (用户新建表单时使用,或是编辑草稿) | |||
* 参数: 单个 schemeItem , { processId } | |||
* | |||
* 每种类别的表单项分别获取的默认值: | |||
* | |||
* currentInfo: 根据类别取当前用户/部门/公司/时间日期 | |||
* datetime: 根据 dfValue 字段表示昨天/今天/明天,格式化为字符串 | |||
* radio、select: 有 dfValue 则使用,否则取第一条 | |||
* checkbox: 有 dfValue 则使用,否则为空数组 | |||
* encode: 根据 rulecode 请求表单编码 | |||
* upload: 空数组 | |||
* guid: 赋值第二个参数中的 processId,但是如果在子表格中,赋空字符串 | |||
* girdtable: 递归所有表格项 scheme 依次为它们生成默认值 | |||
* datetimerange: 字符串 0 | |||
*/ | |||
async getDefaultData(item, prop) { | |||
const { | |||
processId | |||
} = prop | |||
switch (item.type) { | |||
case 'currentInfo': | |||
switch (item.dataType) { | |||
case 'user': | |||
return this.GET_GLOBAL('loginUser').userId | |||
case 'department': | |||
return this.GET_GLOBAL('loginUser').departmentId | |||
case 'company': | |||
return this.GET_GLOBAL('loginUser').companyId | |||
case 'time': | |||
return moment().format('YYYY-MM-DD HH:mm:ss') | |||
default: | |||
return '' | |||
} | |||
case 'datetime': | |||
const datetimeFormat = item.table ? | |||
(Number(item.dateformat) === 0 ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss') : | |||
(item.datetime === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD') | |||
const today = moment() | |||
const dfDatetime = [ | |||
today.subtract(1, 'day'), | |||
today, | |||
today.add(1, 'day') | |||
][Number(item.dfvalue)] || today | |||
return dfDatetime.format(datetimeFormat) || '' | |||
case 'radio': | |||
case 'select': | |||
const radioItem = item.__sourceData__.find(t => t.value === item.dfvalue) || item | |||
.__sourceData__[0] | |||
return item.type === 'radio' ? radioItem.value : '' | |||
case 'checkbox': | |||
if (!item.dfvalue) { | |||
return [] | |||
} | |||
return item.dfvalue.split(',').filter(t => item.__sourceData__.find(s => s.value === t)) | |||
case 'encode': | |||
const result = await this.FETCH_ENCODE(item.rulecode) | |||
return result | |||
case 'upload': | |||
return [] | |||
case 'guid': | |||
return item.table ? processId : '' | |||
case 'girdtable': | |||
const tableItemObj = {} | |||
for (const fieldItem of item.fieldsData) { | |||
tableItemObj[fieldItem.field] = await this.getDefaultData(fieldItem, prop) | |||
} | |||
return this.COPY(tableItemObj) | |||
case 'datetimerange': | |||
return '0' | |||
default: | |||
return item.dfvalue || '' | |||
} | |||
}, | |||
/** | |||
* 将单条 formData 值转化为 formValue 值 (拉取表单数据时使用) | |||
* 参数: 单个 schemeItem , 数据值 | |||
* | |||
* 具体执行逻辑: | |||
* radio、select: 剔除无效值 | |||
* checkbox: 分割成数组并剔除无效值 | |||
* upload: 分割成数组,拉取其中所有文件的信息 | |||
* datetime: 按照时间日期格式进行格式化字符串 | |||
* 其他类型: 保留原值 | |||
*/ | |||
async convertToFormValue(item, val) { | |||
switch (item.type) { | |||
case 'upload': | |||
if (!val) { | |||
return [] | |||
} | |||
const uidList = val; | |||
const fileList = [] | |||
const wxlist = await this.FETCH_FILEList(uidList); | |||
for (const wxfile of wxlist) { | |||
const fileInfo = await this.FETCH_FILEINFO(wxfile.F_Id) | |||
if (!fileInfo) { | |||
continue | |||
} | |||
const fileType = fileInfo.F_FileType | |||
const fileSize = fileInfo.F_FileSize | |||
const path = this.API + '/learun/adms/annexes/wxdown?' + this.URL_QUERY(wxfile.F_Id, true) | |||
fileList.push({ | |||
path, | |||
type: fileType, | |||
uid:wxfile.F_Id, | |||
folderId:wxfile.F_FolderId, | |||
size: fileSize | |||
}) | |||
} | |||
return fileList | |||
case 'select': | |||
case 'radio': | |||
if (!val || !item.__sourceData__.map(t => t.value).includes(val)) { | |||
return '' | |||
} | |||
return val | |||
case 'checkbox': | |||
const validValue = item.__sourceData__.map(t => t.value) | |||
const checkboxVal = val.split(',') || [] | |||
return checkboxVal.filter(t => validValue.includes(t)) | |||
case 'datetime': | |||
if (!val) { | |||
return '' | |||
} | |||
return moment(val).format( | |||
Number(item.dateformat) === 0 || item.datetime === 'date' ? | |||
'YYYY-MM-DD' : | |||
'YYYY-MM-DD HH:mm:ss' | |||
) | |||
default: | |||
return val || '' | |||
} | |||
}, | |||
/** | |||
* 将一个 formValue 值转化为 post 提交值(提交表单数据时使用) | |||
* 参数: 单个 schemeItem , 表单项值 , 所有 formValue , scheme | |||
* | |||
* 具体执行逻辑: | |||
* checkbox: 将数组使用符号「,」逗号拼接成字符串 | |||
* datetimerange: 获取开始日期、结束日期,计算差值天数并保留整数 | |||
* datetime: 格式化为完整时间日期字符串 | |||
* upload: 依次上传文件,将返回的文件 ID 使用符号「,」逗号拼接成字符串 | |||
* 其他类型: 保留原值 | |||
*/ | |||
async convertToPostData(item, val, formValue, scheme, guid) { | |||
switch (item.type) { | |||
case 'checkbox': | |||
return val ? val.join(',') : '' | |||
case 'datetimerange': | |||
const startTime = get(formValue, scheme.find(t => t.id === item.startTime).__valuePath__, null) | |||
const endTime = get(formValue, scheme.find(t => t.id === item.endTime).__valuePath__, null) | |||
if (!startTime || !endTime || moment(endTime).isBefore(startTime)) { | |||
return '' | |||
} else { | |||
return moment.duration(moment(endTime).diff(moment(startTime))).asDays().toFixed(0) | |||
} | |||
case 'datetime': | |||
return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '' | |||
case 'upload': | |||
var uploadUid = ''; | |||
for (const item of val) { | |||
if (item.uid) { | |||
uploadUid = item.uid | |||
continue | |||
} | |||
const fileId = await this.HTTP_UPLOAD(item.path || item, undefined, guid || '') | |||
if (fileId) { | |||
uploadUid = fileId; | |||
} | |||
} | |||
return uploadUid; | |||
default: | |||
return val || '' | |||
} | |||
} | |||
} | |||
} |
@@ -257,7 +257,6 @@ export default { | |||
const fileSize = fileInfo.F_FileSize | |||
const path = this.API + '/learun/adms/annexes/wxdown?' + this.URL_QUERY(uid, true) | |||
fileList.push({ path, type: fileType, uid, size: fileSize }) | |||
} | |||
return fileList | |||
@@ -229,6 +229,14 @@ export default { | |||
return await this.HTTP_GET('learun/adms/annexes/wxfileinfo', fileId) | |||
}, | |||
//获取文件夹下文件列表 | |||
async FETCH_FILEList(folderId) { | |||
if (!folderId) { | |||
return null | |||
} | |||
return await this.HTTP_GET('learun/adms/annexes/wxlist', folderId) | |||
}, | |||
// 封装的 GET 请求,集成了验证信息 | |||
// 返回请求结果或 null | |||
@@ -258,8 +266,8 @@ export default { | |||
// url 为请求地址 | |||
// filePath 为临时文件的路径 | |||
// formData 为请求附带的提交数据 | |||
async HTTP_UPLOAD(filePath, formData) { | |||
const [err, res] = await this.UPLOAD('/learun/adms/annexes/wxupload', filePath, formData) | |||
async HTTP_UPLOAD(filePath, formData,guid) { | |||
const [err, res] = await this.UPLOAD('/learun/adms/annexes/wxupload', filePath, formData,guid) | |||
return this.handleResult(err, res) | |||
}, | |||
@@ -308,11 +316,12 @@ export default { | |||
// 返回结果是一个数组: [error, result] | |||
// error 表示错误,一般是网络错误,请求很可能根本没有发出 | |||
// result 包含 { statusCode, data } 分别表示状态码、接口返回的数据 | |||
async UPLOAD(url, filePath, formData) { | |||
async UPLOAD(url, filePath, formData,guid) { | |||
const uploadUrl = this.handleUrl(url) | |||
const query = { | |||
loginMark: this.getLoginMark(), | |||
token: this.GET_GLOBAL('token') | |||
token: this.GET_GLOBAL('token'), | |||
folderId:guid | |||
} | |||
if (formData && typeof formData === 'object') { | |||
@@ -89,7 +89,7 @@ export default { | |||
// #endif | |||
// #ifndef MP-DINGTALK | |||
uni.chooseImage({ | |||
uni.chooseFile({ | |||
count: Number(this.number), | |||
sizeType: ['original', 'compressed'], | |||
sourceType: ['album', 'camera'], | |||
@@ -188,7 +188,9 @@ | |||
let _postParam = { | |||
pagination: { | |||
rows: _this.rows, | |||
page: _this.page | |||
page: _this.page, | |||
sidx: 'centralTm', | |||
sord: 'desc', | |||
}, | |||
queryJson: JSON.stringify(_this.multipleData) | |||
}; | |||
@@ -132,7 +132,7 @@ export default { | |||
return null | |||
} | |||
return this.API + `/user/img?data=${item.F_OtherUserId}` | |||
return this.API + `/learun/adms/user/img?data=${item.F_OtherUserId}` | |||
} | |||
}, | |||
@@ -186,7 +186,7 @@ export default { | |||
// 获取用户头像图片 url | |||
avatar(id) { | |||
return id === this.chatUserId && this.isSystem ? null : this.API + `/user/img?data=${id}` | |||
return id === this.chatUserId && this.isSystem ? null : this.API + `/learun/adms/user/img?data=${id}` | |||
} | |||
}, | |||
@@ -156,7 +156,7 @@ export default { | |||
return '' | |||
} | |||
return this.API + `/user/img?data=${this.currentUser.userId}` | |||
return this.API + `/learun/adms/user/img?data=${this.currentUser.userId}` | |||
} | |||
}, | |||
@@ -34,7 +34,7 @@ export default { | |||
// 头像图片 url | |||
avatarSrc() { | |||
return this.API + `/user/img?data=${this.currentUser.userId}` | |||
return this.API + `/learun/adms/user/img?data=${this.currentUser.userId}` | |||
} | |||
} | |||
} | |||
@@ -30,7 +30,7 @@ export default { | |||
// 头像图片 url | |||
avatar() { | |||
return this.API + `/user/img?data=${this.currentUser.userId}` | |||
return this.API + `/learun/adms/user/img?data=${this.currentUser.userId}` | |||
}, | |||
// 用户公司部门 tag | |||
@@ -95,8 +95,6 @@ export default { | |||
// t.formId 使用表单,根据这个 formId 来获取 scheme 等信息 | |||
// t.appurl 使用移动页面,直接跳转到本地的页面;表单结构等均写死在页面里 | |||
const { wfForms } = this.currentNode | |||
console.log(wfForms); | |||
// 处理没有有效表单的情况,停止加载 | |||
if (!wfForms || wfForms.every(t => !t.formId && !t.appurl)) { | |||
this.HIDE_LOADING() | |||
@@ -145,7 +143,6 @@ export default { | |||
code: this.code, | |||
useDefault: true | |||
}) | |||
console.log("formValue",formValue,"scheme",scheme) | |||
this.scheme = scheme | |||
this.formValue = formValue | |||
this.rel = rel | |||
@@ -153,8 +150,6 @@ export default { | |||
// 不是子流程,可以直接渲染 | |||
const schemeData = await this.fetchSchemeData(this.currentNode) | |||
const formData = await this.fetchFormData(this.currentNode, this.processId) | |||
console.log(schemeData) | |||
console.log(formData) | |||
const { formValue, scheme, rel } = await this.getCustomForm({ | |||
formData, | |||
schemeData, | |||
@@ -162,7 +157,6 @@ export default { | |||
processId: this.processId, | |||
code: null | |||
}) | |||
console.log("formValue",formValue,"scheme",scheme) | |||
this.scheme = scheme | |||
this.formValue = formValue | |||
this.rel = rel | |||
@@ -203,7 +197,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') | |||
@@ -222,7 +216,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') | |||
@@ -251,7 +245,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') | |||
@@ -110,7 +110,10 @@ 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, | |||
@@ -119,14 +122,15 @@ export default { | |||
code: this.type === 'again' ? null : code, | |||
useDefault: true | |||
}) | |||
this.rel = rel | |||
this.scheme = scheme | |||
this.formValue = formValue | |||
this.code = code | |||
this.processId = processId | |||
this.ready = true | |||
this.HIDE_LOADING() | |||
}, | |||
// 提交草稿按钮 | |||
@@ -194,7 +198,6 @@ export default { | |||
verifyValue() { | |||
const errList = this.$refs.form.verifyValue() | |||
console.log(errList,'errList') | |||
if (this.needTitle && !this.title) { | |||
errList.push(`流程的标题不能为空`) | |||
} | |||
@@ -32,301 +32,383 @@ import customForm from '@/common/customform.js' | |||
* (以上只是简单介绍;实际使用中,如果打开子流程,需要拉取父/子两个流程信息) | |||
*/ | |||
export default { | |||
mixins: [customForm], | |||
methods: { | |||
/** | |||
* 从流程信息中生成 scheme、formValue | |||
* 参数: { schemeData (必填), processId, currentNode, formData (新建时为 null), code, useDefault } | |||
* 返回: { scheme, formValue, rel } | |||
* | |||
* 参数: | |||
* schemeData: 使用 fetchSchemeData 方法拉取到的原始 scheme 数据,未经过格式化处理 | |||
* processId: 表单 GUID;如果是新建表单,可以用 this.GUID('-') 生成一个 | |||
* currentNode: 使用 getCurrentNode 方法拉取到的当前节点信息,用于权限控制 | |||
* formData: 填入表单的表单值,新建表单时此项为 null 即可 | |||
* code: 表单编号 code,会被赋值到返回的 formValue.code;重新发起流程的场合赋 null | |||
* useDefault: 如果 formData 中某一项为空,是否对这一项填入默认值;通常在编辑草稿时启用 | |||
* | |||
* 该方法返回的 scheme 项可能带有以下属性: | |||
* __valuePath__: 表单值在 formValue 中的路径,使用 lodash 的 get、set 方法即可读写 | |||
* __sourceData__: 表单值的选单数据 | |||
* __defaultItem__: 类型为 girdtable 的表单项带有此属性,表示添加一行表格时候表格项的默认值 | |||
* __schemeIndex__: (暂时用不到)表单项位于 schemeData 根级内的第几个子项中 | |||
* __dataIndex__: (暂时用不到)表单项位于 F_Scheme.data 中的第几个子项中 | |||
*/ | |||
async getCustomForm(prop) { | |||
const { schemeData, formData, currentNode, code, processId, useDefault } = prop | |||
console.log(prop,'prop') | |||
// 处理字段之间的级联、绑定关系 | |||
// 需要绑定 change 事件的: | |||
// datetime: 修改后重新计算 datetimerange | |||
// organize: 修改后重设级联到该组件的其他组件的值,user 一级无需处理 | |||
// 需要绑定某值的: | |||
// organize: 级联到某个组件,company 一级无需处理 | |||
const schemeRef = {} | |||
const refList = [] | |||
// 最终返回值:scheme、rel、formValue | |||
const scheme = [] | |||
const rel = {} | |||
const formValue = { processId, formreq: [] } | |||
if (code) { | |||
formValue.code = code | |||
} | |||
// 遍历 schemeData 中所有的 scheme | |||
const schemeList = Array.isArray(schemeData) ? schemeData : Object.values(schemeData) | |||
for (let schemeIndex = 0; schemeIndex < schemeList.length; ++schemeIndex) { | |||
const schemeItem = schemeList[schemeIndex] | |||
schemeItem.F_Scheme = JSON.parse(schemeItem.F_Scheme) | |||
// 已有表单值的时候,舍弃掉不存在表单值中的 scheme | |||
if (formData && !formData[schemeItem.F_SchemeInfoId]) { | |||
continue | |||
} | |||
// 设置 formreq 的内容,非新建模式下需要设置 keyValue | |||
const { formId, field } = get(currentNode, `wfForms.${schemeIndex}`, {}) | |||
const formreqObj = { schemeInfoId: formId, processIdName: field, formData: {} } | |||
if (formData) { | |||
if (Object.values(get(formData, `${schemeItem.F_SchemeInfoId}`, {})).some(t => t && t.length > 0)) { | |||
formreqObj.keyValue = processId | |||
} | |||
} | |||
formValue.formreq[schemeIndex] = formreqObj | |||
for (let dataIndex = 0; dataIndex < schemeItem.F_Scheme.data.length; ++dataIndex) { | |||
const { componts } = schemeItem.F_Scheme.data[dataIndex] | |||
for (const t of componts) { | |||
// 之后的 t 即表示每个 scheme 项 | |||
t.__valuePath__ = `formreq.${schemeIndex}.formData.${t.id}` | |||
// 以下两个属性暂时用不到 | |||
t.__schemeIndex__ = schemeIndex | |||
t.__dataIndex__ = dataIndex | |||
if (t.type === 'girdtable' && t.table) { | |||
// 数据项是表格的情况 | |||
// 先设置源数据,不然无法获取默认值 | |||
for (const fieldItem of t.fieldsData) { | |||
fieldItem.__sourceData__ = await this.getSourceData(fieldItem) | |||
} | |||
t.__defaultItem__ = await this.getDefaultData(t, prop) | |||
if (formData) { | |||
// 有表单值的情况,从表单值中获取数据 | |||
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()) | |||
tableItemValue[fieldItem.field] = await this.convertToFormValue(fieldItem, formDataValue) | |||
} | |||
val.push(tableItemValue) | |||
} | |||
// useDefault 表示在从 formData 取不到值的时候使用默认值 | |||
if ((!val || val.length <= 0) && useDefault) { | |||
set(formValue, t.__valuePath__, [this.COPY(t.__defaultItem__)]) | |||
} else { | |||
set(formValue, t.__valuePath__, val) | |||
} | |||
} else { | |||
// 无表单值的情况,默认值 | |||
set(formValue, t.__valuePath__, [this.COPY(t.__defaultItem__)]) | |||
} | |||
} else if (t.field) { | |||
// 数据项不是表格的情况 | |||
// 先设置源数据,不然无法获取默认值 | |||
t.__sourceData__ = await this.getSourceData(t) | |||
if (formData) { | |||
// 有表单值的情况,从表单值中获取数据 | |||
const path = `${schemeItem.F_SchemeInfoId}.${t.table}.${dataIndex}.${t.field.toLowerCase()}` | |||
const formDataValue = get(formData, path) | |||
// useDefault 表示在从 formData 取不到值的时候使用默认值 | |||
if (!formDataValue && useDefault) { | |||
set(formValue, t.__valuePath__, await this.getDefaultData(t, prop)) | |||
} else { | |||
set(formValue, t.__valuePath__, await this.convertToFormValue(t, formDataValue)) | |||
} | |||
} else { | |||
// 无表单值的情况,默认值 | |||
set(formValue, t.__valuePath__, await this.getDefaultData(t, prop)) | |||
} | |||
} | |||
// 权限控制 | |||
const authObj = get(currentNode, `wfForms.${schemeIndex}.authorize.${t.id}`, {}) | |||
t.edit = authObj.isEdit | |||
if (Number(t.isHide) !== 1 && authObj.isLook !== 0) { | |||
// 加入 scheme | |||
scheme.push(t) | |||
// organize、datetime 可能作为其他 organize 或 datetimerange 的依赖项,引用它们 | |||
if (['organize', 'datetime'].includes(t.type)) { | |||
schemeRef[t.id] = t | |||
} | |||
// datetimerange、带有 relation 级联字段的 organize,依赖其他项 | |||
if ((t.type === 'datetimerange' && t.startTime && t.endTime) || (t.type === 'organize' && t.relation)) { | |||
refList.push(t) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// 依次处理表单关联 | |||
refList.forEach(t => { | |||
if (t.type === 'organize') { | |||
// 处理组件结构级联 | |||
// 给当前组件赋上级级联的值路径 __relationPath__ | |||
const parent = schemeRef[t.relation] | |||
t.__relationPath__ = parent.__valuePath__ | |||
// 给上级级联的组件注册自动重置当前组件的 change 事件 | |||
const relItem = { type: 'organize', id: t.id, path: t.__valuePath__ } | |||
rel[parent.id] = rel[parent.id] ? rel[parent.id].concat(relItem) : [relItem] | |||
} else if (t.type === 'datetimerange') { | |||
// 处理日期区间 | |||
const start = schemeRef[t.startTime] | |||
const end = schemeRef[t.endTime] | |||
const relItem = { | |||
type: 'datetimerange', | |||
path: t.__valuePath__, | |||
id: t.id, | |||
startPath: start.__valuePath__, | |||
endPath: end.__valuePath__, | |||
} | |||
rel[start.id] = rel[start.id] ? rel[start.id].concat(relItem) : [relItem] | |||
rel[end.id] = rel[end.id] ? rel[end.id].concat(relItem) : [relItem] | |||
} | |||
}) | |||
return { scheme, formValue, rel } | |||
}, | |||
/** | |||
* 获取最终需要 POST 的数据 | |||
* 参数:formValue, scheme | |||
* 返回:用于提交的数据 | |||
* | |||
* 遍历 formValue,将其中的表单值依次使用 convertToPostData 这个方法转化为提交值 | |||
*/ | |||
async getPostData(originFormValue, scheme) { | |||
const formValue = this.COPY(originFormValue) | |||
// 依次按照 scheme 项目遍历 | |||
for (const item of scheme) { | |||
if (item.field) { | |||
// 不是表格的情况 | |||
const path = item.__valuePath__ | |||
const val = get(formValue, path) | |||
console.log(val,'val=======') | |||
const result = await this.convertToPostData(item, val, originFormValue, scheme) | |||
set(formValue, path, result) | |||
} else if (item.table && item.fieldsData) { | |||
// 是表格的情况 | |||
const tableValue = get(formValue, item.__valuePath__, []) | |||
for (let valueIndex = 0; valueIndex < tableValue.length; ++valueIndex) { | |||
for (const schemeItem of item.fieldsData) { | |||
const path = `${item.__valuePath__}.${valueIndex}.${schemeItem.field}` | |||
const val = get(formValue, path) | |||
const result = await this.convertToPostData(schemeItem, val, originFormValue, scheme) | |||
set(formValue, path, result) | |||
} | |||
} | |||
} | |||
} | |||
formValue.formreq.forEach(t => { t.formData = JSON.stringify(t.formData) }) | |||
formValue.formreq = JSON.stringify(formValue.formreq) | |||
return formValue | |||
}, | |||
/** | |||
* 获取流程信息 | |||
* 参数: { code, processId, taskId } | |||
* | |||
*/ | |||
async fetchProcessInfo({ code, processId, taskId }) { | |||
const url = processId ? 'learun/adms/newwf/processinfo' : 'learun/adms/newwf/scheme' | |||
const reqObj = { processId } | |||
if (taskId) { | |||
reqObj.taskId = taskId | |||
} | |||
const data = processId ? reqObj : code | |||
const result = await this.HTTP_GET(url, data) | |||
if (!result) { return {} } | |||
if (result.info) { | |||
result.info.Scheme = JSON.parse(result.info.Scheme) | |||
} else if (result.F_Content) { | |||
result.F_Content = JSON.parse(result.F_Content) | |||
} | |||
return result | |||
}, | |||
/** | |||
* 从 processInfo 流程信息中,提取出 currentNode | |||
* 参数: processInfo | |||
* | |||
*/ | |||
getCurrentNode(processInfo) { | |||
if (processInfo.info) { | |||
return processInfo.info.Scheme.nodes.find(t => t.id === processInfo.info.CurrentNodeId) | |||
} else if (processInfo.F_Content) { | |||
return processInfo.F_Content.nodes.find(t => t.type === 'startround') | |||
} | |||
return {} | |||
}, | |||
/** | |||
* 拉取表单的 schemeData | |||
* 参数: currentNode | |||
* | |||
* 从当前节点 currentNode 中提取出表单 id,然后自 API 地址 /form/scheme 中拉取表单数据并返回 | |||
*/ | |||
async fetchSchemeData(currentNode, currentTask, type) { | |||
const { wfForms } = currentNode | |||
const data = wfForms.filter(t => t.formId).map(t => ({ id: t.formId, ver: '' })) | |||
const schemeData = await this.HTTP_GET('learun/adms/form/scheme', data) | |||
return schemeData || {} | |||
}, | |||
/** | |||
* 拉取表单的 formData | |||
* 参数: currentNode, keyValue | |||
* | |||
* 提取当前节点信息、表单主键信息,从 API 地址 /form/data 中拉取表单数据 | |||
*/ | |||
async fetchFormData({ wfForms }, keyValue) { | |||
const reqData = wfForms | |||
.filter(t => t.formId) | |||
.map(t => ({ | |||
schemeInfoId: t.formId, | |||
processIdName: t.field, | |||
keyValue | |||
})) | |||
const formData = await this.HTTP_GET('learun/adms/form/data', reqData) | |||
return formData || {} | |||
} | |||
} | |||
mixins: [customForm], | |||
methods: { | |||
/** | |||
* 从流程信息中生成 scheme、formValue | |||
* 参数: { schemeData (必填), processId, currentNode, formData (新建时为 null), code, useDefault } | |||
* 返回: { scheme, formValue, rel } | |||
* | |||
* 参数: | |||
* schemeData: 使用 fetchSchemeData 方法拉取到的原始 scheme 数据,未经过格式化处理 | |||
* processId: 表单 GUID;如果是新建表单,可以用 this.GUID('-') 生成一个 | |||
* currentNode: 使用 getCurrentNode 方法拉取到的当前节点信息,用于权限控制 | |||
* formData: 填入表单的表单值,新建表单时此项为 null 即可 | |||
* code: 表单编号 code,会被赋值到返回的 formValue.code;重新发起流程的场合赋 null | |||
* useDefault: 如果 formData 中某一项为空,是否对这一项填入默认值;通常在编辑草稿时启用 | |||
* | |||
* 该方法返回的 scheme 项可能带有以下属性: | |||
* __valuePath__: 表单值在 formValue 中的路径,使用 lodash 的 get、set 方法即可读写 | |||
* __sourceData__: 表单值的选单数据 | |||
* __defaultItem__: 类型为 girdtable 的表单项带有此属性,表示添加一行表格时候表格项的默认值 | |||
* __schemeIndex__: (暂时用不到)表单项位于 schemeData 根级内的第几个子项中 | |||
* __dataIndex__: (暂时用不到)表单项位于 F_Scheme.data 中的第几个子项中 | |||
*/ | |||
async getCustomForm(prop) { | |||
const { | |||
schemeData, | |||
formData, | |||
currentNode, | |||
code, | |||
processId, | |||
useDefault | |||
} = prop | |||
// 处理字段之间的级联、绑定关系 | |||
// 需要绑定 change 事件的: | |||
// datetime: 修改后重新计算 datetimerange | |||
// organize: 修改后重设级联到该组件的其他组件的值,user 一级无需处理 | |||
// 需要绑定某值的: | |||
// organize: 级联到某个组件,company 一级无需处理 | |||
const schemeRef = {} | |||
const refList = [] | |||
// 最终返回值:scheme、rel、formValue | |||
const scheme = [] | |||
const rel = {} | |||
const formValue = { | |||
processId, | |||
formreq: [] | |||
} | |||
if (code) { | |||
formValue.code = code | |||
} | |||
// 遍历 schemeData 中所有的 scheme | |||
const schemeList = Array.isArray(schemeData) ? schemeData : Object.values(schemeData) | |||
for (let schemeIndex = 0; schemeIndex < schemeList.length; ++schemeIndex) { | |||
const schemeItem = schemeList[schemeIndex] | |||
schemeItem.F_Scheme = JSON.parse(schemeItem.F_Scheme) | |||
// 已有表单值的时候,舍弃掉不存在表单值中的 scheme | |||
if (formData && !formData[schemeItem.F_SchemeInfoId]) { | |||
continue | |||
} | |||
// 设置 formreq 的内容,非新建模式下需要设置 keyValue | |||
const { | |||
formId, | |||
field | |||
} = get(currentNode, `wfForms.${schemeIndex}`, {}) | |||
const formreqObj = { | |||
schemeInfoId: formId, | |||
processIdName: field, | |||
formData: {} | |||
} | |||
if (formData) { | |||
if (Object.values(get(formData, `${schemeItem.F_SchemeInfoId}`, {})).some(t => t && t.length > | |||
0)) { | |||
formreqObj.keyValue = processId | |||
} | |||
} | |||
formValue.formreq[schemeIndex] = formreqObj | |||
for (let dataIndex = 0; dataIndex < schemeItem.F_Scheme.data.length; ++dataIndex) { | |||
const { | |||
componts | |||
} = schemeItem.F_Scheme.data[dataIndex] | |||
for (const t of componts) { | |||
// 之后的 t 即表示每个 scheme 项 | |||
t.__valuePath__ = `formreq.${schemeIndex}.formData.${t.id}` | |||
// 以下两个属性暂时用不到 | |||
t.__schemeIndex__ = schemeIndex | |||
t.__dataIndex__ = dataIndex | |||
if (t.type === 'girdtable' && t.table) { | |||
// 数据项是表格的情况 | |||
// 先设置源数据,不然无法获取默认值 | |||
for (const fieldItem of t.fieldsData) { | |||
fieldItem.__sourceData__ = await this.getSourceData(fieldItem) | |||
} | |||
t.__defaultItem__ = await this.getDefaultData(t, prop) | |||
if (formData) { | |||
// 有表单值的情况,从表单值中获取数据 | |||
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()) | |||
tableItemValue[fieldItem.field] = await this.convertToFormValue(fieldItem, | |||
formDataValue) | |||
} | |||
val.push(tableItemValue) | |||
} | |||
// useDefault 表示在从 formData 取不到值的时候使用默认值 | |||
if ((!val || val.length <= 0) && useDefault) { | |||
set(formValue, t.__valuePath__, [this.COPY(t.__defaultItem__)]) | |||
} else { | |||
set(formValue, t.__valuePath__, val) | |||
} | |||
} else { | |||
// 无表单值的情况,默认值 | |||
set(formValue, t.__valuePath__, [this.COPY(t.__defaultItem__)]) | |||
} | |||
} else if (t.field) { | |||
// 数据项不是表格的情况 | |||
// 先设置源数据,不然无法获取默认值 | |||
t.__sourceData__ = await this.getSourceData(t) | |||
if (formData) { | |||
// 有表单值的情况,从表单值中获取数据 | |||
const path = | |||
`${schemeItem.F_SchemeInfoId}.${t.table}.${dataIndex}.${t.field.toLowerCase()}` | |||
const formDataValue = get(formData, path) | |||
// useDefault 表示在从 formData 取不到值的时候使用默认值 | |||
if (!formDataValue && useDefault) { | |||
set(formValue, t.__valuePath__, await this.getDefaultData(t, prop)) | |||
} else { | |||
set(formValue, t.__valuePath__, await this.convertToFormValue(t, formDataValue)) | |||
} | |||
} else { | |||
// 无表单值的情况,默认值 | |||
set(formValue, t.__valuePath__, await this.getDefaultData(t, prop)) | |||
} | |||
} | |||
// 权限控制 | |||
const authObj = get(currentNode, `wfForms.${schemeIndex}.authorize.${t.id}`, {}) | |||
t.edit = authObj.isEdit | |||
if (Number(t.isHide) !== 1 && authObj.isLook !== 0) { | |||
// 加入 scheme | |||
scheme.push(t) | |||
// organize、datetime 可能作为其他 organize 或 datetimerange 的依赖项,引用它们 | |||
if (['organize', 'datetime'].includes(t.type)) { | |||
schemeRef[t.id] = t | |||
} | |||
// datetimerange、带有 relation 级联字段的 organize,依赖其他项 | |||
if ((t.type === 'datetimerange' && t.startTime && t.endTime) || (t.type === | |||
'organize' && t.relation)) { | |||
refList.push(t) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// 依次处理表单关联 | |||
refList.forEach(t => { | |||
if (t.type === 'organize') { | |||
// 处理组件结构级联 | |||
// 给当前组件赋上级级联的值路径 __relationPath__ | |||
const parent = schemeRef[t.relation] | |||
t.__relationPath__ = parent.__valuePath__ | |||
// 给上级级联的组件注册自动重置当前组件的 change 事件 | |||
const relItem = { | |||
type: 'organize', | |||
id: t.id, | |||
path: t.__valuePath__ | |||
} | |||
rel[parent.id] = rel[parent.id] ? rel[parent.id].concat(relItem) : [relItem] | |||
} else if (t.type === 'datetimerange') { | |||
// 处理日期区间 | |||
const start = schemeRef[t.startTime] | |||
const end = schemeRef[t.endTime] | |||
const relItem = { | |||
type: 'datetimerange', | |||
path: t.__valuePath__, | |||
id: t.id, | |||
startPath: start.__valuePath__, | |||
endPath: end.__valuePath__, | |||
} | |||
rel[start.id] = rel[start.id] ? rel[start.id].concat(relItem) : [relItem] | |||
rel[end.id] = rel[end.id] ? rel[end.id].concat(relItem) : [relItem] | |||
} | |||
}) | |||
return { | |||
scheme, | |||
formValue, | |||
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); | |||
}); | |||
}, | |||
/** | |||
* 获取最终需要 POST 的数据 | |||
* 参数:formValue, scheme | |||
* 返回:用于提交的数据 | |||
* | |||
* 遍历 formValue,将其中的表单值依次使用 convertToPostData 这个方法转化为提交值 | |||
*/ | |||
async getPostData(originFormValue, scheme) { | |||
const formValue = this.COPY(originFormValue) | |||
// 依次按照 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) | |||
} else if (item.table && item.fieldsData) { | |||
// 是表格的情况 | |||
const tableValue = get(formValue, item.__valuePath__, []) | |||
for (let valueIndex = 0; valueIndex < tableValue.length; ++valueIndex) { | |||
for (const schemeItem of item.fieldsData) { | |||
const path = `${item.__valuePath__}.${valueIndex}.${schemeItem.field}` | |||
const val = get(formValue, path) | |||
const result = await this.convertToPostData(schemeItem, val, originFormValue, scheme, | |||
guid) | |||
set(formValue, path, result) | |||
} | |||
} | |||
} | |||
} | |||
formValue.formreq.forEach(t => { | |||
t.formData = JSON.stringify(t.formData) | |||
}) | |||
formValue.formreq = JSON.stringify(formValue.formreq) | |||
return formValue | |||
}, | |||
/** | |||
* 获取流程信息 | |||
* 参数: { code, processId, taskId } | |||
* | |||
*/ | |||
async fetchProcessInfo({ | |||
code, | |||
processId, | |||
taskId | |||
}) { | |||
const url = processId ? 'learun/adms/newwf/processinfo' : 'learun/adms/newwf/scheme' | |||
const reqObj = { | |||
processId | |||
} | |||
if (taskId) { | |||
reqObj.taskId = taskId | |||
} | |||
const data = processId ? reqObj : code | |||
const result = await this.HTTP_GET(url, data) | |||
if (!result) { | |||
return {} | |||
} | |||
if (result.info) { | |||
result.info.Scheme = JSON.parse(result.info.Scheme) | |||
} else if (result.F_Content) { | |||
result.F_Content = JSON.parse(result.F_Content) | |||
} | |||
return result | |||
}, | |||
/** | |||
* 从 processInfo 流程信息中,提取出 currentNode | |||
* 参数: processInfo | |||
* | |||
*/ | |||
getCurrentNode(processInfo) { | |||
if (processInfo.info) { | |||
return processInfo.info.Scheme.nodes.find(t => t.id === processInfo.info.CurrentNodeId) | |||
} else if (processInfo.F_Content) { | |||
return processInfo.F_Content.nodes.find(t => t.type === 'startround') | |||
} | |||
return {} | |||
}, | |||
/** | |||
* 拉取表单的 schemeData | |||
* 参数: currentNode | |||
* | |||
* 从当前节点 currentNode 中提取出表单 id,然后自 API 地址 /form/scheme 中拉取表单数据并返回 | |||
*/ | |||
async fetchSchemeData(currentNode, currentTask, type) { | |||
const { | |||
wfForms | |||
} = currentNode | |||
const data = wfForms.filter(t => t.formId).map(t => ({ | |||
id: t.formId, | |||
ver: '' | |||
})) | |||
const schemeData = await this.HTTP_GET('learun/adms/form/scheme', data) | |||
return schemeData || {} | |||
}, | |||
/** | |||
* 拉取表单的 formData | |||
* 参数: currentNode, keyValue | |||
* | |||
* 提取当前节点信息、表单主键信息,从 API 地址 /form/data 中拉取表单数据 | |||
*/ | |||
async fetchFormData({ | |||
wfForms | |||
}, keyValue) { | |||
const reqData = wfForms | |||
.filter(t => t.formId) | |||
.map(t => ({ | |||
schemeInfoId: t.formId, | |||
processIdName: t.field, | |||
keyValue | |||
})) | |||
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 || {} | |||
}, | |||
} | |||
} |