You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

458 lines
14 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.WorkFlow;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Web.Mvc;
  7. namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  11. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  12. /// 创建人:力软-框架开发组
  13. /// 日 期:2018.12.06
  14. /// 描 述:工作流模板(新)
  15. /// </summary>
  16. public class NWFSchemeController : MvcControllerBase
  17. {
  18. private NWFSchemeIBLL nWFSchemeIBLL = new NWFSchemeBLL();
  19. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  20. #region 视图功能
  21. /// <summary>
  22. /// 主页面
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult Index()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 表单页面
  32. /// </summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult Form()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 流程模板设计历史记录
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult HistoryForm()
  45. {
  46. return View();
  47. }
  48. /// <summary>
  49. /// 预览流程模板
  50. /// </summary>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public ActionResult PreviewForm()
  54. {
  55. return View();
  56. }
  57. /// <summary>
  58. /// 节点信息设置
  59. /// </summary>
  60. /// <returns></returns>
  61. [HttpGet]
  62. public ActionResult NodeForm()
  63. {
  64. return View();
  65. }
  66. #region 审核人员添加
  67. /// <summary>
  68. /// 添加岗位
  69. /// </summary>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult PostForm()
  73. {
  74. return View();
  75. }
  76. /// <summary>
  77. /// 添加角色
  78. /// </summary>
  79. /// <returns></returns>
  80. [HttpGet]
  81. public ActionResult RoleForm()
  82. {
  83. return View();
  84. }
  85. /// <summary>
  86. /// 添加用户
  87. /// </summary>
  88. /// <returns></returns>
  89. [HttpGet]
  90. public ActionResult UserForm()
  91. {
  92. return View();
  93. }
  94. /// <summary>
  95. /// 添加上下级
  96. /// </summary>
  97. /// <returns></returns>
  98. [HttpGet]
  99. public ActionResult LevelForm()
  100. {
  101. return View();
  102. }
  103. /// <summary>
  104. /// 添加某节点执行人
  105. /// </summary>
  106. /// <returns></returns>
  107. [HttpGet]
  108. public ActionResult AuditorNodeForm()
  109. {
  110. return View();
  111. }
  112. /// <summary>
  113. /// 添加表单字段
  114. /// </summary>
  115. /// <returns></returns>
  116. [HttpGet]
  117. public ActionResult AuditorFieldForm()
  118. {
  119. return View();
  120. }
  121. #endregion
  122. #region 表单添加
  123. /// <summary>
  124. /// 表单添加
  125. /// </summary>
  126. /// <returns></returns>
  127. [HttpGet]
  128. public ActionResult WorkformForm()
  129. {
  130. return View();
  131. }
  132. #endregion
  133. #region 条件字段
  134. /// <summary>
  135. /// 条件字段添加
  136. /// </summary>
  137. /// <returns></returns>
  138. [HttpGet]
  139. public ActionResult ConditionFieldForm()
  140. {
  141. return View();
  142. }
  143. #endregion
  144. #region 按钮设置
  145. /// <summary>
  146. /// 表单添加
  147. /// </summary>
  148. /// <returns></returns>
  149. [HttpGet]
  150. public ActionResult ButtonForm()
  151. {
  152. return View();
  153. }
  154. #endregion
  155. /// <summary>
  156. /// 线段信息设置
  157. /// </summary>
  158. /// <returns></returns>
  159. [HttpGet]
  160. public ActionResult LineForm()
  161. {
  162. return View();
  163. }
  164. /// <summary>
  165. /// 导入页面
  166. /// </summary>
  167. /// <returns></returns>
  168. [HttpGet]
  169. public ActionResult ImportForm()
  170. {
  171. return View();
  172. }
  173. #endregion
  174. #region 获取数据
  175. /// <summary>
  176. /// 获取分页数据
  177. /// </summary>
  178. /// <param name="pagination">分页参数</param>
  179. /// <param name="queryJson">查询条件</param>
  180. /// <returns></returns>
  181. [HttpGet]
  182. [AjaxOnly]
  183. public ActionResult GetInfoPageList(string pagination, string queryJson)
  184. {
  185. Pagination paginationobj = pagination.ToObject<Pagination>();
  186. var data = nWFSchemeIBLL.GetInfoPageList(paginationobj, queryJson);
  187. var jsonData = new
  188. {
  189. rows = data,
  190. total = paginationobj.total,
  191. page = paginationobj.page,
  192. records = paginationobj.records,
  193. };
  194. return Success(jsonData);
  195. }
  196. /// <summary>
  197. /// 获取流程列表
  198. /// </summary>
  199. /// <returns></returns>
  200. [HttpGet]
  201. [AjaxOnly]
  202. public ActionResult GetList()
  203. {
  204. var data = nWFSchemeIBLL.GetInfoList();
  205. return Success(data);
  206. }
  207. /// <summary>
  208. /// 获取自定义流程列表
  209. /// </summary>
  210. /// <returns></returns>
  211. [HttpGet]
  212. [AjaxOnly]
  213. public ActionResult GetMyInfoList()
  214. {
  215. UserInfo userInfo = LoginUserInfo.Get();
  216. var data = nWFSchemeIBLL.GetInfoList(userInfo);
  217. return Success(data);
  218. }
  219. /// <summary>
  220. /// 获取自定义流程列表
  221. /// </summary>
  222. /// <returns></returns>
  223. [HttpGet]
  224. [AjaxOnly]
  225. public ActionResult GetMyInfoListHasImg()
  226. {
  227. UserInfo userInfo = LoginUserInfo.Get();
  228. var data = nWFSchemeIBLL.GetInfoList(userInfo);
  229. foreach (var item in data)
  230. {
  231. var annexes = annexesFileIBLL.GetEntityByFolderId(item.imgUrl);
  232. if (null != annexes)
  233. {
  234. item.imgUrl = "\\"+ annexes.F_FilePath.Substring(annexes.F_FilePath.IndexOf("Resource"));
  235. }
  236. else
  237. {
  238. item.imgUrl = null;
  239. }
  240. }
  241. return Success(data);
  242. }
  243. /// <summary>
  244. /// 获取流程模板数据
  245. /// </summary>
  246. /// <param name="code">流程编码</param>
  247. /// <returns></returns>
  248. [HttpGet]
  249. [AjaxOnly]
  250. public ActionResult GetFormData(string code)
  251. {
  252. NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code);
  253. if (schemeInfoEntity == null)
  254. {
  255. return Success(new { });
  256. }
  257. NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId);
  258. var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id);
  259. var jsonData = new
  260. {
  261. info = schemeInfoEntity,
  262. scheme = schemeEntity,
  263. authList = nWFSchemeAuthList
  264. };
  265. return Success(jsonData);
  266. }
  267. /// <summary>
  268. /// 获取模板分页数据
  269. /// </summary>
  270. /// <param name="pagination">分页参数</param>
  271. /// <param name="schemeInfoId"></param>
  272. /// <returns></returns>
  273. [HttpGet]
  274. [AjaxOnly]
  275. public ActionResult GetSchemePageList(string pagination, string schemeInfoId)
  276. {
  277. Pagination paginationobj = pagination.ToObject<Pagination>();
  278. var data = nWFSchemeIBLL.GetSchemePageList(paginationobj, schemeInfoId);
  279. var jsonData = new
  280. {
  281. rows = data,
  282. total = paginationobj.total,
  283. page = paginationobj.page,
  284. records = paginationobj.records,
  285. };
  286. return Success(jsonData);
  287. }
  288. /// <summary>
  289. /// 获取流程模板数据
  290. /// </summary>
  291. /// <param name="schemeId">模板主键</param>
  292. /// <returns></returns>
  293. [HttpGet]
  294. [AjaxOnly]
  295. public ActionResult GetScheme(string schemeId)
  296. {
  297. var data = nWFSchemeIBLL.GetSchemeEntity(schemeId);
  298. return Success(data);
  299. }
  300. /// <summary>
  301. /// 获取流程模板数据
  302. /// </summary>
  303. /// <param name="code">流程编码</param>
  304. /// <returns></returns>
  305. [HttpPost, ValidateInput(false)]
  306. public void ExportScheme(string code)
  307. {
  308. NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code);
  309. if (schemeInfoEntity != null)
  310. {
  311. NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId);
  312. var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id);
  313. var jsonData = new
  314. {
  315. info = schemeInfoEntity,
  316. scheme = schemeEntity,
  317. authList = nWFSchemeAuthList
  318. };
  319. string data = jsonData.ToJson();
  320. FileDownHelper.DownLoadString(data, schemeInfoEntity.F_Name + ".lrscheme");
  321. }
  322. }
  323. /// <summary>
  324. /// excel文件导入(通用)
  325. /// </summary>
  326. /// <param name="templateId">模板Id</param>
  327. /// <param name="fileId">文件主键</param>
  328. /// <param name="chunks">分片数</param>
  329. /// <param name="ext">文件扩展名</param>
  330. /// <returns></returns>
  331. [HttpPost]
  332. [ValidateAntiForgeryToken]
  333. public ActionResult ExecuteImportScheme(string templateId, string fileId, int chunks, string ext)
  334. {
  335. UserInfo userInfo = LoginUserInfo.Get();
  336. string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo);
  337. if (!string.IsNullOrEmpty(path))
  338. {
  339. // 读取导入文件
  340. string data = DirFileHelper.ReadText(path);
  341. // 删除临时文件
  342. DirFileHelper.DeleteFile2(path);
  343. if (!string.IsNullOrEmpty(data))
  344. {
  345. NWFSchemeModel nWFSchemeModel = data.ToObject<NWFSchemeModel>();
  346. // 验证流程编码是否重复
  347. NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(nWFSchemeModel.info.F_Code);
  348. if (schemeInfoEntityTmp != null)
  349. {
  350. nWFSchemeModel.info.F_Code = Guid.NewGuid().ToString();
  351. }
  352. nWFSchemeIBLL.SaveEntity("", nWFSchemeModel.info, nWFSchemeModel.scheme, nWFSchemeModel.authList);
  353. }
  354. return Success("导入成功");
  355. }
  356. else
  357. {
  358. return Fail("导入模板失败!");
  359. }
  360. }
  361. #endregion
  362. #region 提交数据
  363. /// <summary>
  364. /// 保存流程模板
  365. /// </summary>
  366. /// <param name="keyValue">主键</param>
  367. /// <param name="schemeInfo">表单设计模板信息</param>
  368. /// <param name="shcemeAuth">模板权限信息</param>
  369. /// <param name="scheme">模板内容</param>
  370. /// <param name="type">类型1.正式2.草稿</param>
  371. /// <returns></returns>
  372. [HttpPost]
  373. [ValidateAntiForgeryToken]
  374. [AjaxOnly]
  375. public ActionResult SaveForm(string keyValue, string schemeInfo, string shcemeAuth, string scheme, int type)
  376. {
  377. NWFSchemeInfoEntity schemeInfoEntity = schemeInfo.ToObject<NWFSchemeInfoEntity>();
  378. List<NWFSchemeAuthEntity> nWFSchemeAuthList = shcemeAuth.ToObject<List<NWFSchemeAuthEntity>>();
  379. NWFSchemeEntity schemeEntity = new NWFSchemeEntity();
  380. schemeEntity.F_Content = scheme;
  381. schemeEntity.F_Type = type;
  382. // 验证流程编码是否重复
  383. NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(schemeInfoEntity.F_Code);
  384. if (schemeInfoEntityTmp != null && schemeInfoEntityTmp.F_Id != keyValue)
  385. {
  386. return Fail("流程编码重复");
  387. }
  388. nWFSchemeIBLL.SaveEntity(keyValue, schemeInfoEntity, schemeEntity, nWFSchemeAuthList);
  389. return Success("保存成功!");
  390. }
  391. /// <summary>
  392. /// 删除模板数据
  393. /// </summary>
  394. /// <param name="keyValue">主键</param>
  395. /// <returns></returns>
  396. [HttpPost]
  397. [AjaxOnly]
  398. public ActionResult DeleteForm(string keyValue)
  399. {
  400. nWFSchemeIBLL.DeleteEntity(keyValue);
  401. return Success("删除成功!");
  402. }
  403. /// <summary>
  404. /// 启用/停用表单
  405. /// </summary>
  406. /// <param name="keyValue">主键</param>
  407. /// <param name="state">状态1启用0禁用</param>
  408. /// <returns></returns>
  409. [HttpPost]
  410. [AjaxOnly]
  411. public ActionResult UpDateSate(string keyValue, int state)
  412. {
  413. nWFSchemeIBLL.UpdateState(keyValue, state);
  414. return Success((state == 1 ? "启用" : "禁用") + "成功!");
  415. }
  416. /// <summary>
  417. /// 更新表单模板版本
  418. /// </summary>
  419. /// <param name="keyValue">主键</param>
  420. /// <param name="state">状态1启用0禁用</param>
  421. /// <returns></returns>
  422. [HttpPost]
  423. [AjaxOnly]
  424. public ActionResult UpdateScheme(string schemeInfoId, string schemeId)
  425. {
  426. nWFSchemeIBLL.UpdateScheme(schemeInfoId, schemeId);
  427. return Success("更新成功!");
  428. }
  429. #endregion
  430. }
  431. }