From e00de72ffcfb4c62c742f486e6fd4185b91ee42b Mon Sep 17 00:00:00 2001 From: yubaolee Date: Mon, 26 Mar 2018 14:11:07 +0800 Subject: [PATCH] check bugs --- OpenAuth.App/FormUtil.cs | 115 +++++++++++++----- OpenAuth.App/OpenAuth.App.csproj | 1 + OpenAuth.App/Response/FlowVerificationResp.cs | 12 ++ OpenAuth.App/Response/FormResp.cs | 2 +- .../Controllers/FlowInstancesController.cs | 8 +- OpenAuth.Mvc/Views/FlowInstances/Index.cshtml | 3 +- .../Views/FlowInstances/Verification.cshtml | 10 +- OpenAuth.Mvc/js/flow/GooFlow.js | 3 +- OpenAuth.Mvc/userJs/flowInstanceEdit.js | 7 +- OpenAuth.Mvc/userJs/flowInstanceOp.js | 14 +-- OpenAuth.Mvc/userJs/flowInstances.js | 8 ++ OpenAuth.Mvc/userJs/flowSchemeDesign.js | 4 +- OpenAuth.Mvc/userJs/flowSchemes.js | 6 +- 13 files changed, 134 insertions(+), 59 deletions(-) create mode 100644 OpenAuth.App/Response/FlowVerificationResp.cs diff --git a/OpenAuth.App/FormUtil.cs b/OpenAuth.App/FormUtil.cs index 079c6faf..6b7cca0b 100644 --- a/OpenAuth.App/FormUtil.cs +++ b/OpenAuth.App/FormUtil.cs @@ -16,9 +16,13 @@ namespace OpenAuth.App private static string temp_view = "
{1}
"; - public static string GetHtml(string contentData, string contentParse, string action) + public static string GetHtml(string contentData, string contentParse,string frmData, string action) { - var tableData = new Dictionary();//表单数据 + JObject tableData = null;//表单数据 + if (!string.IsNullOrEmpty(frmData)) + { + tableData = JsonHelper.Instance.Deserialize(frmData); + } string html = contentParse; foreach (var json in contentData.ToList()) @@ -67,44 +71,67 @@ namespace OpenAuth.App return html; } - - /** - * - * 功能: html - */ - public static string GetHtml(FormResp form, string action){ + + /// + /// 只显示编辑框 + /// + /// The form. + /// System.String. + public static string GetHtml(FormResp form){ - //action=action!=null && !""==(action)?action:"view"; - return GetHtml(form.ContentData, form.ContentParse, action); + return GetHtml(form.ContentData, form.ContentParse,null, ""); } - + + /// + /// 显示编辑框和里面的用户数据 + /// + /// The contentdata. + /// The content parse. + /// The FRM data. + /// System.String. + public static string Preview(string contentdata, string contentParse, string frmData) + { + return GetHtml(contentdata, contentParse, frmData, "view"); + } + //text - private static string GetTextBox(JObject item, Dictionary formData,string action) + private static string GetTextBox(JObject item, JObject formData,string action) { string temp = ""; string name = item.GetValue("name").ToString(); - string value = formData.ContainsKey(name)?formData[name].ToString():null; + var data = formData.GetValue(name); + string value =null; + if (data != null) + { + value = data.ToString(); + } + if (value == null) value = item.GetValue("value") == null ? "" : item.GetValue("value").ToString(); string style =item.GetValue("style") == null ? "" : item.GetValue("style").ToString(); string temp_html = string.Format(temp, value, name, style); if("view"==(action)) return string.Format(temp_view,style,value); - else - return temp_html; + return temp_html; } //TextArea - private static string GetTextArea(JObject item, Dictionary formData,string action) + private static string GetTextArea(JObject item, JObject formData,string action) { string script = ""; if (item.GetValue("orgrich") != null && "1"==(item.GetValue("orgrich").ToString())) script = "orgrich=\"true\" "; string name = item.GetValue("name").ToString(); - string value = formData.ContainsKey(name)?formData[name].ToString():null; + var data = formData.GetValue(name); + string value = null; + if (data != null) + { + value = data.ToString(); + } + if (value == null) value = item.GetValue("value")== null ? "" : item.GetValue("value").ToString(); string style = item.GetValue("style") == null ? "" : item.GetValue("style").ToString(); @@ -116,20 +143,26 @@ namespace OpenAuth.App if("view"==(action)) return string.Format(temp_view,style,value); - else - return temp_html; + return temp_html; } //Radios - private static string GetRadios(JObject item, Dictionary formData,string action) + private static string GetRadios(JObject item, JObject formData,string action) { var radiosOptions = JArray.Parse(item.GetValue("options").ToString()); //JArray radiosOptions = item["options"] as JArray; string temp = "{3} "; string temp_html = ""; string name = item.GetValue("name").ToString(); - string value = formData.ContainsKey(name)?formData[name].ToString():null; - + + var data = formData.GetValue(name); + string value = null; + if (data != null) + { + value = data.ToString(); + } + + string cvalue_=""; foreach (var json in radiosOptions) { @@ -152,12 +185,11 @@ namespace OpenAuth.App if("view"==(action)) return string.Format(temp_view," ",cvalue_); - else - return temp_html; + return temp_html; } //Checkboxs - private static string GetCheckboxs(JObject item, Dictionary formData,string action){ + private static string GetCheckboxs(JObject item, JObject formData,string action){ string temp_html = ""; string temp = "{3} "; @@ -167,7 +199,14 @@ namespace OpenAuth.App foreach (var json in checkOptions) { string name = json["name"].ToString(); - string value = formData.ContainsKey(name) ? formData[name].ToString() : null; + + var data = formData.GetValue(name); + string value = null; + if (data != null) + { + value = data.ToString(); + } + string cvalue = json["value"].ToString(); string Ischecked = ""; if (value == null) @@ -191,16 +230,21 @@ namespace OpenAuth.App if("view"==(action)) return string.Format(temp_view," ",view_value); - else - return temp_html; + return temp_html; } //Select(比较特殊) - private static string GetSelect(JObject item, Dictionary formData, string action) + private static string GetSelect(JObject item, JObject formData, string action) { string name = item.GetValue("name").ToString(); - string value = formData.ContainsKey(name)?formData[name].ToString():null; + + var data = formData.GetValue(name); + string value = null; + if (data != null) + { + value = data.ToString(); + } string temp_html =item.GetValue("content").ToString(); if (value != null)//用户设置过值 @@ -216,10 +260,17 @@ namespace OpenAuth.App //Qrcode 二维码 - private static string GetQrcode(JObject item, Dictionary formData, string action) + private static string GetQrcode(JObject item, JObject formData, string action) { string name = item.GetValue("name").ToString(); - string value = formData.ContainsKey(name)?formData[name].ToString():null; + + var data = formData.GetValue(name); + string value = null; + if (data != null) + { + value = data.ToString(); + } + string temp_html = ""; string temp = ""; string orgType = item.GetValue("orgtype").ToString(); diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj index 22df6fa4..1324924d 100644 --- a/OpenAuth.App/OpenAuth.App.csproj +++ b/OpenAuth.App/OpenAuth.App.csproj @@ -121,6 +121,7 @@ + diff --git a/OpenAuth.App/Response/FlowVerificationResp.cs b/OpenAuth.App/Response/FlowVerificationResp.cs new file mode 100644 index 00000000..04787d73 --- /dev/null +++ b/OpenAuth.App/Response/FlowVerificationResp.cs @@ -0,0 +1,12 @@ +using OpenAuth.Repository.Domain; + +namespace OpenAuth.App.Response +{ + public class FlowVerificationResp :FlowInstance + { + public string FrmDataHtml + { + get { return FormUtil.Preview(FrmContentData, FrmContentParse, FrmData); } + } + } +} diff --git a/OpenAuth.App/Response/FormResp.cs b/OpenAuth.App/Response/FormResp.cs index c3d6201e..c6aa48f6 100644 --- a/OpenAuth.App/Response/FormResp.cs +++ b/OpenAuth.App/Response/FormResp.cs @@ -46,7 +46,7 @@ namespace OpenAuth.App.Response /// public string Html { - get { return FormUtil.GetHtml(this, ""); } + get { return FormUtil.GetHtml(this); } } } diff --git a/OpenAuth.Mvc/Controllers/FlowInstancesController.cs b/OpenAuth.Mvc/Controllers/FlowInstancesController.cs index cff18bc4..d27dc34a 100644 --- a/OpenAuth.Mvc/Controllers/FlowInstancesController.cs +++ b/OpenAuth.Mvc/Controllers/FlowInstancesController.cs @@ -5,6 +5,7 @@ using Infrastructure; using Newtonsoft.Json.Linq; using OpenAuth.App; using OpenAuth.App.Request; +using OpenAuth.App.Response; using OpenAuth.Mvc.Models; using OpenAuth.Repository.Domain; @@ -51,7 +52,12 @@ namespace OpenAuth.Mvc.Controllers { try { - var result = new Response { Result = App.Get(id) }; + var flowinstance = App.Get(id); + + var result = new Response + { + Result = flowinstance.MapTo() + }; return JsonHelper.Instance.Serialize(result); } catch (Exception ex) diff --git a/OpenAuth.Mvc/Views/FlowInstances/Index.cshtml b/OpenAuth.Mvc/Views/FlowInstances/Index.cshtml index a9779457..b81a040e 100644 --- a/OpenAuth.Mvc/Views/FlowInstances/Index.cshtml +++ b/OpenAuth.Mvc/Views/FlowInstances/Index.cshtml @@ -15,9 +15,8 @@ 主键Id - 流程实例模板Id + 实例名称 实例编号 - 自定义名称 当前节点ID 当前节点类型(0会签节点) 当前节点名称 diff --git a/OpenAuth.Mvc/Views/FlowInstances/Verification.cshtml b/OpenAuth.Mvc/Views/FlowInstances/Verification.cshtml index aaed2e43..90f51a74 100644 --- a/OpenAuth.Mvc/Views/FlowInstances/Verification.cshtml +++ b/OpenAuth.Mvc/Views/FlowInstances/Verification.cshtml @@ -26,20 +26,20 @@ - +
- - - + + +
-
diff --git a/OpenAuth.Mvc/js/flow/GooFlow.js b/OpenAuth.Mvc/js/flow/GooFlow.js index a9ab5159..c217ff14 100644 --- a/OpenAuth.Mvc/js/flow/GooFlow.js +++ b/OpenAuth.Mvc/js/flow/GooFlow.js @@ -1601,7 +1601,8 @@ GooFlow.prototype={ }, //载入一组数据 - loadData:function(data){ + loadData: function (data) { + this.clearData(); //载入之前先清空数据 yubaolee var t=this.$editable; this.$editable=false; if(data.title) this.setTitle(data.title); diff --git a/OpenAuth.Mvc/userJs/flowInstanceEdit.js b/OpenAuth.Mvc/userJs/flowInstanceEdit.js index bb1de401..6e74e800 100644 --- a/OpenAuth.Mvc/userJs/flowInstanceEdit.js +++ b/OpenAuth.Mvc/userJs/flowInstanceEdit.js @@ -79,8 +79,11 @@ callback: { onClick: function (event, treeId, treeNode) { //预览表单 - $.get("/forms/previewdata?id=" + treeNode.FrmId, function (data) { - $("#frmPreview").html(data); + //取表单的结构数据 + $.getJSON("/forms/get?id=" + treeNode.FrmId, function (data) { + if (data.Code != 500) { + $("#frmPreview").html(data.Result.Html); + } }); //预览流程 diff --git a/OpenAuth.Mvc/userJs/flowInstanceOp.js b/OpenAuth.Mvc/userJs/flowInstanceOp.js index 4522b7ec..1eba3145 100644 --- a/OpenAuth.Mvc/userJs/flowInstanceOp.js +++ b/OpenAuth.Mvc/userJs/flowInstanceOp.js @@ -8,11 +8,7 @@ var openauth = layui.openauth; var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 - var vm = new Vue({ - el: "#formEdit" - }); - - var id = $.getUrlParam("id"); //ID + var id = $.getUrlParam("id"); //ID $("#FlowInstanceId").val(id); //标签切换 @@ -32,13 +28,7 @@ function (data) { var obj = data.Result; flowDesignPanel.loadData(JSON.parse(obj.SchemeContent)); - - //取表单的结构数据 - $.getJSON("/forms/get?id=" + obj.FrmId, function (data) { - if (data.Code != 500) { - $("#frmPreview").html(data.Result.Html); - } - }); + $("#frmPreview").html(data.Result.FrmDataHtml); }); //提交数据 diff --git a/OpenAuth.Mvc/userJs/flowInstances.js b/OpenAuth.Mvc/userJs/flowInstances.js index d9fcbe7d..6a81be48 100644 --- a/OpenAuth.Mvc/userJs/flowInstances.js +++ b/OpenAuth.Mvc/userJs/flowInstances.js @@ -78,6 +78,10 @@ var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); iframeWin.submit(); }, + btn2: function (index) { + layer.close(index); + mainList(); + }, cancel: function (index) { layer.close(index); mainList(); @@ -147,6 +151,10 @@ var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); iframeWin.submit(); }, + btn2: function (index) { + layer.close(index); + mainList(); + }, cancel: function (index) { layer.close(index); mainList(); diff --git a/OpenAuth.Mvc/userJs/flowSchemeDesign.js b/OpenAuth.Mvc/userJs/flowSchemeDesign.js index c24a4e58..9b56ab07 100644 --- a/OpenAuth.Mvc/userJs/flowSchemeDesign.js +++ b/OpenAuth.Mvc/userJs/flowSchemeDesign.js @@ -76,8 +76,8 @@ var node = zTreeObj.getNodeByParam("Id", id, null); zTreeObj.checkNode(node, true, false); - $.get("/forms/previewdata?id=" + id, function (data) { - $("#frmPreview").html(data); + $.getJSON("/forms/get?id=" + id, function (data) { + $("#frmPreview").html(data.Result.Html); }); } diff --git a/OpenAuth.Mvc/userJs/flowSchemes.js b/OpenAuth.Mvc/userJs/flowSchemes.js index 945879f3..d81952ff 100644 --- a/OpenAuth.Mvc/userJs/flowSchemes.js +++ b/OpenAuth.Mvc/userJs/flowSchemes.js @@ -80,7 +80,11 @@ var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); iframeWin.submit(); }, - no: function (index) { + btn2: function (index) { + layer.close(index); + mainList(); + }, + cancel: function (index) { layer.close(index); mainList(); }