using Learun.Application.Base.SystemModule; using Learun.Application.WorkFlow; using Learun.Util; using System; using System.Collections.Generic; using System.Web.Mvc; namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers { /// /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架 /// Copyright (c) 2013-2018 上海力软信息技术有限公司 /// 创建人:力软-框架开发组 /// 日 期:2018.12.06 /// 描 述:工作流模板(新) /// public class NWFSchemeController : MvcControllerBase { private NWFSchemeIBLL nWFSchemeIBLL = new NWFSchemeBLL(); private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 表单页面 /// /// [HttpGet] public ActionResult Form() { return View(); } /// /// 流程模板设计历史记录 /// /// [HttpGet] public ActionResult HistoryForm() { return View(); } /// /// 预览流程模板 /// /// [HttpGet] public ActionResult PreviewForm() { return View(); } /// /// 节点信息设置 /// /// [HttpGet] public ActionResult NodeForm() { return View(); } #region 审核人员添加 /// /// 添加岗位 /// /// [HttpGet] public ActionResult PostForm() { return View(); } /// /// 添加角色 /// /// [HttpGet] public ActionResult RoleForm() { return View(); } /// /// 添加用户 /// /// [HttpGet] public ActionResult UserForm() { return View(); } /// /// 添加上下级 /// /// [HttpGet] public ActionResult LevelForm() { return View(); } /// /// 添加某节点执行人 /// /// [HttpGet] public ActionResult AuditorNodeForm() { return View(); } /// /// 添加表单字段 /// /// [HttpGet] public ActionResult AuditorFieldForm() { return View(); } #endregion #region 表单添加 /// /// 表单添加 /// /// [HttpGet] public ActionResult WorkformForm() { return View(); } #endregion #region 条件字段 /// /// 条件字段添加 /// /// [HttpGet] public ActionResult ConditionFieldForm() { return View(); } #endregion #region 按钮设置 /// /// 表单添加 /// /// [HttpGet] public ActionResult ButtonForm() { return View(); } #endregion /// /// 线段信息设置 /// /// [HttpGet] public ActionResult LineForm() { return View(); } /// /// 导入页面 /// /// [HttpGet] public ActionResult ImportForm() { return View(); } #endregion #region 获取数据 /// /// 获取分页数据 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetInfoPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = nWFSchemeIBLL.GetInfoPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取流程列表 /// /// [HttpGet] [AjaxOnly] public ActionResult GetList() { var data = nWFSchemeIBLL.GetInfoList(); return Success(data); } /// /// 获取自定义流程列表 /// /// [HttpGet] [AjaxOnly] public ActionResult GetMyInfoList() { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFSchemeIBLL.GetInfoList(userInfo); return Success(data); } /// /// 获取自定义流程列表 /// /// [HttpGet] [AjaxOnly] public ActionResult GetMyInfoListHasImg() { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFSchemeIBLL.GetInfoList(userInfo); foreach (var item in data) { var annexes = annexesFileIBLL.GetEntityByFolderId(item.imgUrl); if (null != annexes) { item.imgUrl = "\\"+ annexes.F_FilePath.Substring(annexes.F_FilePath.IndexOf("Resource")); } else { item.imgUrl = null; } } return Success(data); } /// /// 获取流程模板数据 /// /// 流程编码 /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string code) { NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code); if (schemeInfoEntity == null) { return Success(new { }); } NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId); var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id); var jsonData = new { info = schemeInfoEntity, scheme = schemeEntity, authList = nWFSchemeAuthList }; return Success(jsonData); } /// /// 获取模板分页数据 /// /// 分页参数 /// /// [HttpGet] [AjaxOnly] public ActionResult GetSchemePageList(string pagination, string schemeInfoId) { Pagination paginationobj = pagination.ToObject(); var data = nWFSchemeIBLL.GetSchemePageList(paginationobj, schemeInfoId); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取流程模板数据 /// /// 模板主键 /// [HttpGet] [AjaxOnly] public ActionResult GetScheme(string schemeId) { var data = nWFSchemeIBLL.GetSchemeEntity(schemeId); return Success(data); } /// /// 获取流程模板数据 /// /// 流程编码 /// [HttpPost, ValidateInput(false)] public void ExportScheme(string code) { NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code); if (schemeInfoEntity != null) { NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId); var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id); var jsonData = new { info = schemeInfoEntity, scheme = schemeEntity, authList = nWFSchemeAuthList }; string data = jsonData.ToJson(); FileDownHelper.DownLoadString(data, schemeInfoEntity.F_Name + ".lrscheme"); } } /// /// excel文件导入(通用) /// /// 模板Id /// 文件主键 /// 分片数 /// 文件扩展名 /// [HttpPost] [ValidateAntiForgeryToken] public ActionResult ExecuteImportScheme(string templateId, string fileId, int chunks, string ext) { UserInfo userInfo = LoginUserInfo.Get(); string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); if (!string.IsNullOrEmpty(path)) { // 读取导入文件 string data = DirFileHelper.ReadText(path); // 删除临时文件 DirFileHelper.DeleteFile2(path); if (!string.IsNullOrEmpty(data)) { NWFSchemeModel nWFSchemeModel = data.ToObject(); // 验证流程编码是否重复 NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(nWFSchemeModel.info.F_Code); if (schemeInfoEntityTmp != null) { nWFSchemeModel.info.F_Code = Guid.NewGuid().ToString(); } nWFSchemeIBLL.SaveEntity("", nWFSchemeModel.info, nWFSchemeModel.scheme, nWFSchemeModel.authList); } return Success("导入成功"); } else { return Fail("导入模板失败!"); } } #endregion #region 提交数据 /// /// 保存流程模板 /// /// 主键 /// 表单设计模板信息 /// 模板权限信息 /// 模板内容 /// 类型1.正式2.草稿 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string schemeInfo, string shcemeAuth, string scheme, int type) { NWFSchemeInfoEntity schemeInfoEntity = schemeInfo.ToObject(); List nWFSchemeAuthList = shcemeAuth.ToObject>(); NWFSchemeEntity schemeEntity = new NWFSchemeEntity(); schemeEntity.F_Content = scheme; schemeEntity.F_Type = type; // 验证流程编码是否重复 NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(schemeInfoEntity.F_Code); if (schemeInfoEntityTmp != null && schemeInfoEntityTmp.F_Id != keyValue) { return Fail("流程编码重复"); } nWFSchemeIBLL.SaveEntity(keyValue, schemeInfoEntity, schemeEntity, nWFSchemeAuthList); return Success("保存成功!"); } /// /// 删除模板数据 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { nWFSchemeIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } /// /// 启用/停用表单 /// /// 主键 /// 状态1启用0禁用 /// [HttpPost] [AjaxOnly] public ActionResult UpDateSate(string keyValue, int state) { nWFSchemeIBLL.UpdateState(keyValue, state); return Success((state == 1 ? "启用" : "禁用") + "成功!"); } /// /// 更新表单模板版本 /// /// 主键 /// 状态1启用0禁用 /// [HttpPost] [AjaxOnly] public ActionResult UpdateScheme(string schemeInfoId, string schemeId) { nWFSchemeIBLL.UpdateScheme(schemeInfoId, schemeId); return Success("更新成功!"); } #endregion } }