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.
 
 
 
 
 
 

471 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. if (item.F_Id == "3a9e9db8-a928-435b-a9d2-4a4660b4cdeb")
  241. {
  242. item.F_Name = "采购申请(普通)";
  243. item.F_CodeUrl = "/AssetManagementSystem/Ass_AssetsInfoApply/IndexJY";
  244. item.F_Code = "caigoupt";
  245. }
  246. else if (item.F_Id == "307b2c75-174f-424d-84d8-e0f8374ec6d1")
  247. {
  248. item.F_Name = "采购申请(耗材)";
  249. item.F_CodeUrl = "/AssetManagementSystem/Ass_AssetsInfoApply/IndexJYHC";
  250. item.F_Code = "caigouhc";
  251. }
  252. }
  253. return Success(data);
  254. }
  255. /// <summary>
  256. /// 获取流程模板数据
  257. /// </summary>
  258. /// <param name="code">流程编码</param>
  259. /// <returns></returns>
  260. [HttpGet]
  261. [AjaxOnly]
  262. public ActionResult GetFormData(string code)
  263. {
  264. NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code);
  265. if (schemeInfoEntity == null)
  266. {
  267. return Success(new { });
  268. }
  269. NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId);
  270. var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id);
  271. var jsonData = new
  272. {
  273. info = schemeInfoEntity,
  274. scheme = schemeEntity,
  275. authList = nWFSchemeAuthList
  276. };
  277. return Success(jsonData);
  278. }
  279. /// <summary>
  280. /// 获取模板分页数据
  281. /// </summary>
  282. /// <param name="pagination">分页参数</param>
  283. /// <param name="schemeInfoId"></param>
  284. /// <returns></returns>
  285. [HttpGet]
  286. [AjaxOnly]
  287. public ActionResult GetSchemePageList(string pagination, string schemeInfoId)
  288. {
  289. Pagination paginationobj = pagination.ToObject<Pagination>();
  290. var data = nWFSchemeIBLL.GetSchemePageList(paginationobj, schemeInfoId);
  291. var jsonData = new
  292. {
  293. rows = data,
  294. total = paginationobj.total,
  295. page = paginationobj.page,
  296. records = paginationobj.records,
  297. };
  298. return Success(jsonData);
  299. }
  300. /// <summary>
  301. /// 获取流程模板数据
  302. /// </summary>
  303. /// <param name="schemeId">模板主键</param>
  304. /// <returns></returns>
  305. [HttpGet]
  306. [AjaxOnly]
  307. public ActionResult GetScheme(string schemeId)
  308. {
  309. var data = nWFSchemeIBLL.GetSchemeEntity(schemeId);
  310. return Success(data);
  311. }
  312. /// <summary>
  313. /// 获取流程模板数据
  314. /// </summary>
  315. /// <param name="code">流程编码</param>
  316. /// <returns></returns>
  317. [HttpPost, ValidateInput(false)]
  318. public void ExportScheme(string code)
  319. {
  320. NWFSchemeInfoEntity schemeInfoEntity = nWFSchemeIBLL.GetInfoEntityByCode(code);
  321. if (schemeInfoEntity != null)
  322. {
  323. NWFSchemeEntity schemeEntity = nWFSchemeIBLL.GetSchemeEntity(schemeInfoEntity.F_SchemeId);
  324. var nWFSchemeAuthList = nWFSchemeIBLL.GetAuthList(schemeInfoEntity.F_Id);
  325. var jsonData = new
  326. {
  327. info = schemeInfoEntity,
  328. scheme = schemeEntity,
  329. authList = nWFSchemeAuthList
  330. };
  331. string data = jsonData.ToJson();
  332. FileDownHelper.DownLoadString(data, schemeInfoEntity.F_Name + ".lrscheme");
  333. }
  334. }
  335. /// <summary>
  336. /// excel文件导入(通用)
  337. /// </summary>
  338. /// <param name="templateId">模板Id</param>
  339. /// <param name="fileId">文件主键</param>
  340. /// <param name="chunks">分片数</param>
  341. /// <param name="ext">文件扩展名</param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ValidateAntiForgeryToken]
  345. public ActionResult ExecuteImportScheme(string templateId, string fileId, int chunks, string ext)
  346. {
  347. UserInfo userInfo = LoginUserInfo.Get();
  348. string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo);
  349. if (!string.IsNullOrEmpty(path))
  350. {
  351. // 读取导入文件
  352. string data = DirFileHelper.ReadText(path);
  353. // 删除临时文件
  354. DirFileHelper.DeleteFile2(path);
  355. if (!string.IsNullOrEmpty(data))
  356. {
  357. NWFSchemeModel nWFSchemeModel = data.ToObject<NWFSchemeModel>();
  358. // 验证流程编码是否重复
  359. NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(nWFSchemeModel.info.F_Code);
  360. if (schemeInfoEntityTmp != null)
  361. {
  362. nWFSchemeModel.info.F_Code = Guid.NewGuid().ToString();
  363. }
  364. nWFSchemeIBLL.SaveEntity("", nWFSchemeModel.info, nWFSchemeModel.scheme, nWFSchemeModel.authList);
  365. }
  366. return Success("导入成功");
  367. }
  368. else
  369. {
  370. return Fail("导入模板失败!");
  371. }
  372. }
  373. #endregion
  374. #region 提交数据
  375. /// <summary>
  376. /// 保存流程模板
  377. /// </summary>
  378. /// <param name="keyValue">主键</param>
  379. /// <param name="schemeInfo">表单设计模板信息</param>
  380. /// <param name="shcemeAuth">模板权限信息</param>
  381. /// <param name="scheme">模板内容</param>
  382. /// <param name="type">类型1.正式2.草稿</param>
  383. /// <returns></returns>
  384. [HttpPost]
  385. [ValidateAntiForgeryToken]
  386. [AjaxOnly]
  387. public ActionResult SaveForm(string keyValue, string schemeInfo, string shcemeAuth, string scheme, int type)
  388. {
  389. NWFSchemeInfoEntity schemeInfoEntity = schemeInfo.ToObject<NWFSchemeInfoEntity>();
  390. List<NWFSchemeAuthEntity> nWFSchemeAuthList = shcemeAuth.ToObject<List<NWFSchemeAuthEntity>>();
  391. NWFSchemeEntity schemeEntity = new NWFSchemeEntity();
  392. schemeEntity.F_Content = scheme;
  393. schemeEntity.F_Type = type;
  394. // 验证流程编码是否重复
  395. NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(schemeInfoEntity.F_Code);
  396. if (schemeInfoEntityTmp != null && schemeInfoEntityTmp.F_Id != keyValue)
  397. {
  398. return Fail("流程编码重复");
  399. }
  400. nWFSchemeIBLL.SaveEntity(keyValue, schemeInfoEntity, schemeEntity, nWFSchemeAuthList);
  401. return Success("保存成功!");
  402. }
  403. /// <summary>
  404. /// 删除模板数据
  405. /// </summary>
  406. /// <param name="keyValue">主键</param>
  407. /// <returns></returns>
  408. [HttpPost]
  409. [AjaxOnly]
  410. public ActionResult DeleteForm(string keyValue)
  411. {
  412. nWFSchemeIBLL.DeleteEntity(keyValue);
  413. return Success("删除成功!");
  414. }
  415. /// <summary>
  416. /// 启用/停用表单
  417. /// </summary>
  418. /// <param name="keyValue">主键</param>
  419. /// <param name="state">状态1启用0禁用</param>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [AjaxOnly]
  423. public ActionResult UpDateSate(string keyValue, int state)
  424. {
  425. nWFSchemeIBLL.UpdateState(keyValue, state);
  426. return Success((state == 1 ? "启用" : "禁用") + "成功!");
  427. }
  428. /// <summary>
  429. /// 更新表单模板版本
  430. /// </summary>
  431. /// <param name="keyValue">主键</param>
  432. /// <param name="state">状态1启用0禁用</param>
  433. /// <returns></returns>
  434. [HttpPost]
  435. [AjaxOnly]
  436. public ActionResult UpdateScheme(string schemeInfoId, string schemeId)
  437. {
  438. nWFSchemeIBLL.UpdateScheme(schemeInfoId, schemeId);
  439. return Success("更新成功!");
  440. }
  441. #endregion
  442. }
  443. }