using System; using System.Collections.Generic; using System.Web.Mvc; using Infrastructure; using LeaRun.Util.WebControl; using OpenAuth.App; using OpenAuth.App.SSO; using OpenAuth.Domain; using OpenAuth.Mvc.Controllers; namespace OpenAuth.Mvc.Areas.FlowManage.Controllers { public class FormDesignController : BaseController { private readonly WFFormService _wfFrmMainBll; public FormDesignController() { _wfFrmMainBll = AutofacExt.GetFromFac(); } #region 视图功能 /// /// 管理 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 预览表单 /// /// [HttpGet] public ActionResult FormPreview() { return View(); } /// /// 创建表单 /// /// [HttpGet] public ActionResult FrmBuider() { return View(); } #endregion #region 获取数据 public string Load(int pageCurrent = 1, int pageSize = 30) { return JsonHelper.Instance.Serialize(_wfFrmMainBll.Load(pageCurrent, pageSize)); } /// /// 返回表单列表树 /// /// 关键字 /// 返回树形Json [HttpGet] public ActionResult GetTreeJson() { var data = _wfFrmMainBll.GetAllList(); var treeList = new List(); foreach (var item in data) { TreeEntity tree = new TreeEntity { id = item.Id.ToString(), text = item.FrmName, value = item.Id.ToString(), isexpand = true, complete = true, hasChildren = false, parentId = "0", Attribute = "Sort", AttributeValue = "Frm" }; treeList.Add(tree); } return Content(treeList.TreeToJson()); } /// /// 设置表单 /// /// 主键 /// [HttpGet] public ActionResult GetFormJson(Guid keyValue) { var data = _wfFrmMainBll.GetForm(keyValue); return Content(data.ToJson()); } /// /// 获取表单数据all /// /// [HttpGet] public ActionResult GetAllListJson() { var data = _wfFrmMainBll.GetAllList(); return Content(data.ToJson()); } #endregion #region 提交数据 /// /// 删除表单模板 /// /// 主键值 /// [HttpPost] public string RemoveForm(Guid[] ids) { _wfFrmMainBll.RemoveForm(ids); return Result.ToJson(); } ///// ///// 保存用户表单(新增、修改) ///// ///// 主键值 ///// 用户实体 ///// [HttpPost] public string SaveForm(string keyValue, WFFrmMain userEntity) { try { var user = AuthUtil.GetCurrentUser(); userEntity.ModifyUserId = user.User.Account; userEntity.ModifyUserName = user.User.Name; _wfFrmMainBll.SaveForm(keyValue, userEntity); } catch (Exception e) { Result.Status = false; Result.Message = e.Message; } return Result.ToJson(); } #endregion } }