123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- using System.Web.Mvc.Html;
- using Autofac;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common;
- using Bowin.Common.JSON;
- using EMIS.Utility;
- using EMIS.Entities;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.Web.Controls
- {
- public static class ConditionExtensions
- {
- // public IConfiguretermsInfoServices iConfiguretermsInfoServices { get; set; }
- /// <summary>
- /// 动态查询控件,需要通过数据库配置具体的查询项
- /// </summary>
- /// <param name="htmlHelper"></param>
- /// <param name="menuClass">页面标识,默认为List,同一菜单内的不同页面可通过该字段区分,对应数据库中的MUNClass字段</param>
- /// <param name="mnuNo">菜单编号,对应数据库中的MNUID字段</param>
- /// <returns></returns>
- public static MvcHtmlString PositionCondition(this HtmlHelper htmlHelper, string menuClass = "List", string mnuNo = "")
- {
- var positionConditionId = "ul_" + Guid.NewGuid().ToString().Replace("-", "");
- var request = htmlHelper.ViewContext.RequestContext.HttpContext.Request;
- var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
- if (mnuNo == "")
- {
- mnuNo = request["MNU"];
- }
- StringBuilder sb = new StringBuilder();
- sb.Append("<div class=\"search_keyword\">");
- sb.Append(" <div class=\"search_input\" style=\"overflow: hidden;\">");
- sb.Append(" <ul id=\"" + positionConditionId + "\" dynamicWhere=\"true\">");
- sb.Append(" <li class=\"sn\" style=\"padding-left: 5px;\">查询:</li>");
- sb.Append(" <li class=\"sv\"></li>");
- sb.Append(" <li class=\"sv\"></li>");
- sb.Append(" <li class=\"sv\"></li>");
- sb.Append(" <li class=\"sn\" style=\"padding-right: 10px;\">");
- sb.Append(" <a class=\"easyui-linkbutton l-btn\" onclick=\"reload();\" href=\"javascript:void(0)\" data-options=\"iconCls:'icon-search'\">");
- sb.Append("查询");
- sb.Append(" </a>");
- sb.Append(" </li>");
- sb.Append(" </ul>");
- sb.Append(" </div>");
- sb.Append("</div>");
- sb.Append("<script type = \"text/javascript\" language = \"javascript\"> $(function () { EMISFunction.LoadPositionCondition('" + positionConditionId + "','" + menuClass + "'," + (mnuNo == null ? "null" : "'" + mnuNo + "'") + ",'" + urlHelper.Action("GetPositionConditionData", "Common") + "'); });</script>");
- return MvcHtmlString.Create(sb.ToString());
- }
- ///// <summary>
- /////
- ///// </summary>
- ///// <param name="htmlHelper"></param>
- ///// <param name="menuClass"></param>
- ///// <param name="htmlAttributes"></param>
- ///// <param name="mnuNo"></param>
- ///// <returns></returns>
- //public static MvcHtmlString PositionCondition(this HtmlHelper htmlHelper, string menuClass = "List", IDictionary<string, string> htmlAttributes = null, string mnuNo = "")
- //{
- // string menuNo = HttpContext.Current.Request["MNU"];
- // string html = "";
- // string columnName = string.Empty;
- // List<Sys_ConfiguretermsInfo> listAttribute = null;
- // if (!string.IsNullOrEmpty(mnuNo))
- // {
- // menuNo = mnuNo;
- // }
- // using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- // {
- // IConfiguretermsInfoServices configuretermsInfoServices = scope.Resolve<IConfiguretermsInfoServices>();
- // listAttribute = configuretermsInfoServices.GetConfiguretermsInfo(menuNo, menuClass);
- // foreach (var item in listAttribute)
- // {
- // columnName += item.Value.Replace(".", "") + "Query" + item.ControlType + "_div" + ",";
- // if (htmlAttributes == null)
- // {
- // htmlAttributes = new Dictionary<string, string> { { "data-condition", item.listControl } };
- // }
- // }
- // }
- // DropdownListOptions dropdownListOptions = new DropdownListOptions();
- // dropdownListOptions.BindType = DropdownListBindType.None;
- // dropdownListOptions.ItemSourceUrl = UrlHelper.GenerateContentUrl("~/Common/DynamicConditionDropDown?menuNo="
- // + menuNo + "&formClass=" + menuClass, htmlHelper.ViewContext.HttpContext);
- // dropdownListOptions.BindType = DropdownListBindType.None;
- // dropdownListOptions.Name = "Attribute";
- // dropdownListOptions.ID = "Attribute";
- // dropdownListOptions.OnSelect = "SystemQueryControl.QueryControl";
- // DropdownListOptions dropdownListOptions1 = new DropdownListOptions();
- // List<DropdownListItem> listdlt = new List<DropdownListItem>{
- // new DropdownListItem{ Text = "=", Value = "=" },
- // new DropdownListItem{ Text = ">=", Value = ">=" },
- // new DropdownListItem{ Text = ">", Value = ">" },
- // new DropdownListItem{ Text = "<=", Value = "<=" },
- // new DropdownListItem{ Text = "<", Value = "<" },
- // new DropdownListItem{ Text = "<>", Value = "<>" },
- // new DropdownListItem{ Text = "左", Value = "左" },
- // new DropdownListItem{ Text = "右", Value = "右" },
- // new DropdownListItem{ Text = "中", Value = "中" },
- // };
- // dropdownListOptions1.BindType = DropdownListBindType.None;
- // dropdownListOptions1.ItemList = listdlt;
- // dropdownListOptions1.Name = "Condition";
- // dropdownListOptions1.ID = "Condition";
- // html = "<div class=\"search_keyword\">\n";
- // html += "<div class=\"search_input\">" +
- // "<input type=\"hidden\" id='QuerycolumnName' value='" + columnName + "'>" +
- // "<ul>" +
- // "<li class=\"sn\" style=\"padding-left: 5px;\">查询:</li>" +
- // "<li class=\"sv\">" +
- // Bowin.Web.Controls.Mvc.DropdownList.CreateControl(dropdownListOptions, htmlAttributes).Render() +
- // "</li>" +
- // "<li class=\"sv\">" +
- // Bowin.Web.Controls.Mvc.DropdownList.CreateControl(dropdownListOptions1, htmlAttributes).Render() +
- // "</li>" +
- // "<li class=\"sv\" id=\"liquery\">" +
- // GetQueryControl(htmlHelper, listAttribute) +
- // "</li>" +
- // "<li class=\"sn\" style=\"padding-left: 20px;\"><a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-search'\" onclick=\"reload();\">查询</a></li>" +
- // "</ul>" +
- // "</div>";
- // html += "</div>";
- // return MvcHtmlString.Create(html);
- //}
- /// <summary>
- /// 获取查询控件
- /// </summary>
- /// <param name="htmlHelper"></param>
- /// <param name="listAttribute"></param>
- /// <returns></returns>
- private static string GetQueryControl(HtmlHelper htmlHelper, List<Sys_ConfiguretermsInfo> listAttribute)
- {
- string control = string.Empty;
- int i = 0;
- string cl = string.Empty;
- foreach (var item in listAttribute)
- {
- string controlName = item.Value.Replace(".", "");
- cl = i == 0 ? "" : "class='divquery'";
- IDictionary<string, string> htmlAttributes = new Dictionary<string, string> { { "data-condition", item.listControl } };
- if (item.ControlType == "TextBox")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = controlName + "_QueryTextBox",
- Name = controlName + "_QueryTextBox"
- };
- var ss = htmlHelper.TextBox(tbop, htmlAttributes);
- control += "<div id='" + controlName + "QueryTextBox_div' " + cl + ">" + htmlHelper.TextBox(tbop, htmlAttributes) + "</div>";
- }
- else if (item.ControlType == "DropdownList")
- {
- DropdownListOptions dropdownListOptions = new DropdownListOptions();
- dropdownListOptions.BindType = DropdownListBindType.SelectAll;
- dropdownListOptions.ID = controlName + "_QueryDropdownList";
- dropdownListOptions.Name = controlName + "_QueryDropdownList";
- dropdownListOptions.ItemSourceUrl = item.PostUrl;
- dropdownListOptions.TextField = item.ControlTextFiled;
- dropdownListOptions.ValueField = item.ControlValueFiled;
- var ss = htmlHelper.DropdownList(dropdownListOptions, htmlAttributes);
- control += "<div id='" + controlName + "QueryDropdownList_div' " + cl + ">" + htmlHelper.DropdownList(dropdownListOptions, htmlAttributes) + "</div>";
- }
- else if (item.ControlType == "DictionaryDropDownList")
- {
- DropdownListOptions dropdownListOptions = new DropdownListOptions();
- dropdownListOptions.BindType = DropdownListBindType.SelectAll;
- dropdownListOptions.ID = controlName + "_QueryDictionaryDropDownList";
- dropdownListOptions.Name = controlName + "_QueryDictionaryDropDownList";
- dropdownListOptions.TextField = item.ControlTextFiled;
- dropdownListOptions.ValueField = item.ControlValueFiled;
- var ss = htmlHelper.DictionaryDropDownList(item.DictionaryCode, dropdownListOptions, htmlAttributes).ToHtmlString();
- control += "<div id='" + controlName + "QueryDictionaryDropDownList_div' " + cl + ">" + htmlHelper.DictionaryDropDownList(item.DictionaryCode, dropdownListOptions, htmlAttributes).ToHtmlString() + "</div>";
- }
- else if (item.ControlType == "CheckBox")
- {
- var ss = htmlHelper.CheckBox(controlName + "_QueryCheckBox", true, new { ID = controlName + "_QueryCheckBox" }) + "是/否";
- control += "<div id='" + controlName + "QueryCheckBox_div' " + cl + ">" +
- htmlHelper.CheckBox(controlName + "_QueryCheckBox", true, new { ID = controlName + "_QueryCheckBox" }) + "是/否" +
- "</div>";
- }
- else if (item.ControlType == "ComboGrid")
- {
- List<DataGridColumn> lstgridColumn = new List<DataGridColumn>();
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- IConfiguretermsInfoServices configuretermsServices = scope.Resolve<IConfiguretermsInfoServices>();
- List<Sys_ConfiguretermsExpand> listBModify = configuretermsServices.GetConfiguretermsExpand(item.ID);
- foreach (var bmitem in listBModify)
- {
- BoundFieldColumn bfc = new BoundFieldColumn { FieldName = bmitem.ColumnValue, HeaderText = bmitem.ColumnName, Width = 0.1, Align = AlignStyle.Center };
- lstgridColumn.Add(bfc);
- }
- }
- ComboGridOptions cgop = new ComboGridOptions
- {
- TextField = item.ControlTextFiled,
- ValueField = item.ControlValueFiled,
- ID = controlName + "_QueryComboGrid",
- Name = controlName + "_QueryComboGrid",
- GridOptions = new DataGridOptions
- {
- Columns = lstgridColumn,
- IsCheckOnSelect = true,
- DataSourceUrl = UrlHelper.GenerateContentUrl(item.PostUrl, htmlHelper.ViewContext.HttpContext),
- IsPagination = true,
- IsShowRowNumbers = true,
- IsSingleSelect = false
- }
- };
- control += "<div id='" + controlName + "QueryComboGrid_div' " + cl + ">" + htmlHelper.ComboGrid(cgop, htmlAttributes) + "</div>";
- }
- else if (item.ControlType == "TextBoxDate")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = controlName + "_QueryTextBoxDate",
- Name = controlName + "_QueryTextBoxDate",
- TextBoxType = TextBoxType.Date
- };
- var ss = htmlHelper.TextBox(tbop, htmlAttributes);
- control += "<div id='" + controlName + "QueryTextBoxDate_div' " + cl + ">" + htmlHelper.TextBox(tbop, htmlAttributes) + "</div>";
- }
- i++;
- }
- return control;
- }
- /// <summary>
- /// 批量修改控件,需要通过数据库配置具体的修改项
- /// </summary>
- /// <param name="htmlHelper"></param>
- /// <param name="htmlAttributes">自定义Html属性扩展,用Dictionary的方式定义,例如:new Dictionary<string, string> {
- /// { "style", "width: 100%;" }, { "name", "ddlUsers" }
- /// }
- /// </param>
- /// <returns></returns>
- public static MvcHtmlString PositionBatchModify(this HtmlHelper htmlHelper, IDictionary<string, string> htmlAttributes = null)
- {
- var request = htmlHelper.ViewContext.RequestContext.HttpContext.Request;
- var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
- string menuNo = request["MNU"];
- string html = "";
- string listControlID = string.Empty;
- string columnName = string.Empty;
- List<Sys_BatchModify> listAttribute = null;
- IBatchModifyServices catchModifyServices = AutofacHelper.Container.Resolve<IBatchModifyServices>();
- listAttribute = catchModifyServices.GetBatchModifyList(menuNo);
- foreach (var item in listAttribute)
- {
- listControlID = item.listControl;
- columnName += item.Value + item.ControlType + "_div" + ",";
- }
- DropdownListOptions dropdownListOptions = new DropdownListOptions();
- dropdownListOptions.BindType = DropdownListBindType.PleaseSelect;
- dropdownListOptions.ItemSourceUrl = UrlHelper.GenerateContentUrl("~/Common/BatchUpdateDropDown?menuNo="
- + menuNo, htmlHelper.ViewContext.HttpContext);
- dropdownListOptions.BindType = DropdownListBindType.None;
- dropdownListOptions.Name = "DropdownBatchModify";
- dropdownListOptions.ID = "DropdownBatchModify";
- dropdownListOptions.OnSelect = "SystemBatchModifyControl.BatchModifyControl";
- //if (!string.IsNullOrEmpty(postFormUrl))
- // postFormUrl = "method=\"post\" action='" + postFormUrl + "'";
- html = "<div class=\"search_keyword\" id=\"BatchModifydiv\">\n";
- html += "<div class=\"search_input\">" +
- "<form id=\"formBatchModify\" method='post' action='" + urlHelper.Action("BatchModify", "Common").AddMenuParameter() + "' >" +
- "<ul>" +
- "<li class=\"sn\" style=\"padding-left: 5px;\">批量修改:</li>" +
- "<li class=\"sv\">" +
- Bowin.Web.Controls.Mvc.DropdownList.CreateControl(dropdownListOptions, htmlAttributes).Render() +
- "</li>" +
- "<li class=\"sv\" id=\"li_div\">" +
- GetBatchControl(htmlHelper, listAttribute) +
- "</li>" +
- "<li class=\"sn\" style=\"padding-left: 20px;\"><a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-confirm'\" onclick=\"SystemBatchModifyControl.BatchModifysubmit();\">确定</a> <a href=\"javascript:void(0)\" class=\"easyui-linkbutton\" data-options=\"iconCls:'icon-cancel'\" onclick=\"SystemBatchModifyControl.closeBatchModifydiv();\">取消</a></li>" +
- "</ul>" +
- "<input type=\"hidden\" id='PL_hiddenBatchModify' name='PL_hiddenBatchModify' value='' />" +
- "<input type=\"hidden\" id='PL_hiddenBatchModifycolumnName' value='" + columnName + "' />" +
- "<input type=\"hidden\" id='PL_hiddenBatchModifylistControl' name='PL_hiddenBatchModifylistControl' value='" + listControlID + "' />" +
- "</form>" +
- "</div>";
- html += "</div>";
- return MvcHtmlString.Create(html);
- }
- /// <summary>
- /// 批量修改控件
- /// </summary>
- /// <param name="htmlHelper"></param>
- /// <param name="listAttribute"></param>
- /// <returns></returns>
- private static string GetBatchControl(HtmlHelper htmlHelper, List<Sys_BatchModify> listAttribute)
- {
- string control = string.Empty;
- int i = 0;
- foreach (var item in listAttribute)
- {
- if (item.ControlType == "TextBox")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = item.Value + "_TextBox",
- Name = item.Value + "_TextBox"
- };
- control += "<div id='" + item.Value + "TextBox_div' class='divbatchmodify'>" + htmlHelper.TextBox(tbop) + "</div>";
- }
- else if (item.ControlType == "DropdownList")
- {
- DropdownListOptions dropdownListOptions = new DropdownListOptions();
- dropdownListOptions.BindType = DropdownListBindType.PleaseSelect;
- dropdownListOptions.ID = item.Value + "_DropdownList";
- dropdownListOptions.Name = item.Value + "_DropdownList";
- dropdownListOptions.ItemSourceUrl = item.PostUrl;
- dropdownListOptions.TextField = item.ControlTextFiled;
- dropdownListOptions.ValueField = item.ControlValueFiled;
- control += "<div id='" + item.Value + "DropdownList_div' class='divbatchmodify'>" + htmlHelper.DropdownList(dropdownListOptions) + "</div>";
- }
- else if (item.ControlType == "DictionaryDropDownList")
- {
- DropdownListOptions dropdownListOptions = new DropdownListOptions();
- dropdownListOptions.BindType = DropdownListBindType.PleaseSelect;
- dropdownListOptions.ID = item.Value + "_DictionaryDropDownList";
- dropdownListOptions.Name = item.Value + "_DictionaryDropDownList";
- dropdownListOptions.TextField = item.ControlTextFiled;
- dropdownListOptions.ValueField = item.ControlValueFiled;
- control += "<div id='" + item.Value + "DictionaryDropDownList_div' class='divbatchmodify'>" + htmlHelper.DictionaryDropDownList(item.DictionaryCode, dropdownListOptions).ToHtmlString() + "</div>";
- }
- else if (item.ControlType == "CheckBox")
- {
- control += "<div id='" + item.Value + "CheckBox_div' class='divbatchmodify'>" +
- //"<input name='" + item.Value + "_CheckBox' type='checkbox' style='display:none' checked value='false'>" +
- "<input name='" + item.Value + "_CheckBox' class='batchUpdateCheckbox' id='" + item.Value + "_CheckBox' type='checkbox' value='true'>是/否" +
- //htmlHelper.CheckBox(item.Value + "_CheckBox") + "是/否" +
- "</div>";
- }
- else if (item.ControlType == "ComboGrid")
- {
- List<DataGridColumn> lstgridColumn = new List<DataGridColumn>();
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- IBatchModifyServices bcatchModifyServices = scope.Resolve<IBatchModifyServices>();
- List<Sys_BatchModifyExpand> listBModify = bcatchModifyServices.GetBatchModifyExpandList(item.BatchModifyID);
- foreach (var bmitem in listBModify)
- {
- BoundFieldColumn bfc = new BoundFieldColumn { FieldName = bmitem.ColumnValue, HeaderText = bmitem.ColumnName, Width = 0.1, Align = AlignStyle.Center };
- lstgridColumn.Add(bfc);
- }
- }
- ComboGridOptions cgop = new ComboGridOptions
- {
- TextField = item.ControlTextFiled,
- ValueField = item.ControlValueFiled,
- ID = item.Value + "_ComboGrid",
- Name = item.Value + "_ComboGrid",
- GridOptions = new DataGridOptions
- {
- Columns = lstgridColumn,
- IsCheckOnSelect = true,
- DataSourceUrl = UrlHelper.GenerateContentUrl(item.PostUrl, htmlHelper.ViewContext.HttpContext),
- IsPagination = true,
- IsShowRowNumbers = true,
- IsSingleSelect = false
- }
- };
- control += "<div id='" + item.Value + "ComboGrid_div' class='divbatchmodify'>" + htmlHelper.ComboGrid(cgop) + "</div>";
- }
- else if (item.ControlType == "TextBoxDate")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = item.Value + "_TextBoxDate",
- Name = item.Value + "_TextBoxDate",
- TextBoxType = TextBoxType.Date
- };
- control += "<div id='" + item.Value + "TextBoxDate_div' class='divbatchmodify'>" + htmlHelper.TextBox(tbop) + "</div>";
- }
- else if (item.ControlType == "TextBoxDateTime")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = item.Value + "_TextBoxDateTime",
- Name = item.Value + "_TextBoxDateTime",
- TextBoxType = TextBoxType.DateTime
- };
- control += "<div id='" + item.Value + "TextBoxDateTime_div' class='divbatchmodify'>" + htmlHelper.TextBox(tbop) + "</div>";
- }
- else if (item.ControlType == "NumberBox")
- {
- TextBoxOptions tbop = new TextBoxOptions
- {
- ID = item.Value + "_NumberBox",
- Name = item.Value + "_NumberBox",
- TextBoxType = TextBoxType.Normal
- };
- control += "<div id='" + item.Value + "NumberBox_div' class='divbatchmodify'>" + htmlHelper.TextBox(tbop, new Dictionary<string, string> { { "number", "true" } }) + "</div>";
- }
- i++;
- }
- return control;
- }
- }
- }
|