Ejemplo n.º 1
0
        public static IHtmlString BuliderFormView(this HtmlHelper htmlHelper, IEnumerable <DyncField> dyncField, SQLDynamicRow row)
        {
            if (dyncField.IsNull() && !dyncField.Any())
            {
                return(htmlHelper.Raw(string.Empty));
            }

            var content = string.Empty;

            foreach (var item in dyncField)
            {
                var vaule = GetDyncFieldValueByRow(item.Name, row);
                content += BuliderFormView(item, vaule);
            }
            var html = FormTemp.GetTempByKey("form", content);

            return(htmlHelper.Raw(html));
        }
Ejemplo n.º 2
0
        private static string BuliderFormView(DyncField dyncField, string value)
        {
            var html = string.Empty;

            if (dyncField.Type == "name" && dyncField.Fmt == "extend")
            {
                var surname = string.Empty;
                var name    = string.Empty;

                if (value.IsNotNullOrEmpty())
                {
                    var val = value.Split('.');
                    if (val.Length > 1)
                    {
                        surname = val[0];
                        name    = val[1];
                    }
                }
                html = FormTemp.GetTempByKey("formItemName", dyncField.Lbl,
                                             dyncField.Name, dyncField.Reqd, dyncField.Uuiq, surname, name
                                             );
            }
            else if (dyncField.Type == "file")
            {
                html = FormTemp.GetTempByKey("formFileItem", dyncField.Lbl,
                                             dyncField.Name,
                                             FormItemView.BuliderFormItemView(dyncField, value));
            }
            else if (dyncField.Type == "section")
            {
                html = FormTemp.GetTempByKey("section", dyncField.Lbl, dyncField.Instr);
            }
            else
            {
                html = FormTemp.GetTempByKey("formItem", dyncField.Lbl, FormItemView.BuliderFormItemView(dyncField, value),
                                             (dyncField.Instr ?? string.Empty));
            }
            return(html);
        }
Ejemplo n.º 3
0
 public static IHtmlString BuildByKey(this HtmlHelper htmlHelper, string key, params string[] param)
 {
     return(htmlHelper.Raw(FormTemp.GetTempByKey(key, param)));
 }
Ejemplo n.º 4
0
        public static string BuliderFormItemView(DyncField dyncField, string value)
        {
            SetSourceValue(dyncField);
            var builder = CreateTagBuilder(dyncField.Type);

            var htmlAttributes = new Dictionary <string, string>()
            {
                { "data-name", dyncField.Name },
                { "name", dyncField.Name },
                { "id", dyncField.Name },
                { "data-lbl", dyncField.Lbl },
                { "data-reqd", dyncField.Reqd },
                { "data-uuid", dyncField.Uuiq ?? "0" }
            };

            var defalutValue = value ?? dyncField.DefaultValue ?? string.Empty;

            if (dyncField.Type == "date" && defalutValue.IsNullOrEmpty())
            {
                defalutValue = DateTime.Now.ToString("yyyy-MM-dd");
            }
            if (dyncField.Type == "datetime" && defalutValue.IsNullOrEmpty())
            {
                defalutValue = DateTime.Now.ToString("yyyy-MM-dd HH:ss");
            }
            if (dyncField.Type == "time" && defalutValue.IsNullOrEmpty())
            {
                defalutValue = DateTime.Now.ToString("HH:ss");
            }
            if (dyncField.Type == "number" ||
                dyncField.Type == "text" ||
                dyncField.Type == "url" ||
                dyncField.Type == "email" ||
                dyncField.Type == "map" ||
                dyncField.Type == "phone" ||
                dyncField.Type == "name" ||
                dyncField.Type == "address" ||
                dyncField.Type == "time" ||
                dyncField.Type == "date" ||
                dyncField.Type == "datetime")
            {
                htmlAttributes.Add("value", defalutValue);
                htmlAttributes.Add("placeholder", "请入输" + dyncField.Lbl);
            }

            if (dyncField.Type == "file")
            {
                htmlAttributes.Add("value", defalutValue);
            }

            if (dyncField.Type == "name")
            {
                htmlAttributes.Add("data-fmt", dyncField.Fmt);
            }

            if (dyncField.Type == "textarea")
            {
                builder.SetInnerText(defalutValue);
                htmlAttributes.Add("placeholder", "请入输" + dyncField.Lbl);
            }

            if (dyncField.Type == "dropdown2")
            {
                htmlAttributes.Add("data-pn", dyncField.PN ?? "2");
                htmlAttributes.Add("data-select", dyncField.Name);
            }

            if (dyncField.Type == "dropdown")
            {
                builder.InnerHtml = GetDropdownElement(dyncField, "<option value='" + _checked + "'>" + _value + "</option>", string.Empty);
                htmlAttributes.Add("value", defalutValue);
            }

            if (dyncField.Type == "checkbox" || dyncField.Type == "radio")
            {
                builder.InnerHtml = GetDropdownElement(dyncField, FormTemp.GetTempByKey(dyncField.Type, dyncField.Id.ToString(),
                                                                                        _isChecked, _checked, _value), defalutValue);
            }

            var required = string.Empty;

            //if (dyncField.Reqd == "1")
            //{
            //	htmlAttributes.Add("required", "");
            //	htmlAttributes.Add("oninvalid", "setCustomValidity('请入输" + dyncField.Name + "!');");
            //	htmlAttributes.Add("oninput", "setCustomValidity('');");
            //}
            //builder.IdAttributeDotReplacement = "-";
            //builder.GenerateId(dyncField.Id.ToString());
            builder.MergeAttributes(htmlAttributes);

            return(builder.TagName == "input"
                ? builder.ToString(TagRenderMode.SelfClosing)
                : builder.ToString(TagRenderMode.Normal));
        }
Ejemplo n.º 5
0
        public static IHtmlString BuildFormTable(this HtmlHelper htmlHelper, PagedList <SQLDynamicRow> sQLDynamicRow, int page, string code)
        {
            if (!sQLDynamicRow.Any())
            {
                return(htmlHelper.BuildByKey("formEmpty"));
            }

            var dynamicDataservices = Common.Injection.Core.IoC.Container.Resolve <IDynamicDataservices>();
            var field = dynamicDataservices.GetDyncFieldByFormCode(code);

            var row  = sQLDynamicRow.FirstOrDefault().Row.ToList();
            var head = new List <string>();

            for (int i = 0; i < row.Count(); i++)
            {
                if (row[i].Name == "Id")
                {
                    continue;
                }

                var item = field.Where(t => t.Name == row[i].Name).FirstOrDefault();
                if (item.IsNull())
                {
                    continue;
                }

                head.Add(item.Lbl);
            }

            var tuple = new List <Tuple <IList <string>, Func <string> > >();

            for (int i = 0; i < sQLDynamicRow.Count; i++)
            {
                var content = new List <string>();
                var item    = sQLDynamicRow[i].Row.ToList();
                var id      = string.Empty;
                for (int j = 0; j < item.Count(); j++)
                {
                    if (item[j].Name == "Id")
                    {
                        id = item[j].Value;
                        continue;
                    }

                    var v = field.Where(t => t.Name == item[j].Name).FirstOrDefault();
                    if (v.IsNull())
                    {
                        continue;
                    }

                    if (v.SourceValue.IsNotNullOrEmpty() && (v.Type == "radio" || v.Type == "checkbox"))
                    {
                        content.Add(GetLabel(v, item[j]));
                    }
                    else
                    {
                        content.Add(item[j].Value);
                    }
                }
                tuple.Add(new Tuple <IList <string>, Func <string> >(content, () =>
                {
                    return(FormTemp.GetTempByKey("formInfoLink", id, code, page.ToString()));
                }));
            }

            return(htmlHelper.BuildByTable(new Tuple <IList <string>, IList <Tuple <IList <string>, Func <string> > >, bool>(head,
                                                                                                                             tuple, true)));
        }