diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 2eb1a44a..19788ddf 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -610,6 +610,58 @@ namespace AMESCoreStudio.Web.Controllers } #endregion + #region CheckboxList + private void GetCheckboxPrintMode() + { + var q = Enum.GetValues(typeof(Enums.EnumPrintMode)).Cast() + .Select(s => new SelectListItem + { + Text = Enums.GetDisplayName(s).ToString(), + Value = s.ToString() + }).ToList(); + + //TempData["GetLockReasonTypeList"] = LockReasonType; + ViewBag.GetCheckboxPrintMode = q; + } + + private void GetCheckboxApproveLogo() + { + var q = Enum.GetValues(typeof(Enums.EnumApproveLogo)).Cast() + .Select(s => new SelectListItem + { + Text = Enums.GetDisplayName(s).ToString(), + Value = s.ToString() + }).ToList(); + + ViewBag.GetCheckboxApproveLogo = q; + } + + private void GetCheckboxCompanyLogo() + { + var q = Enum.GetValues(typeof(Enums.EnumCompanyLogo)).Cast() + .Select(s => new SelectListItem + { + Text = Enums.GetDisplayName(s).ToString(), + Value = s.ToString() + }).ToList(); + + //TempData["GetLockReasonTypeList"] = LockReasonType; + ViewBag.GetCheckboxCompanyLogo = q; + } + + private void GetCheckboxWipAttr() + { + var q = Enum.GetValues(typeof(Enums.EnumWipAttr)).Cast() + .Select(s => new SelectListItem + { + Text = Enums.GetDisplayName(s).ToString(), + Value = s.ToString() + }).ToList(); + + //TempData["GetLockReasonTypeList"] = LockReasonType; + ViewBag.GetCheckboxWipAttr = q; + } + #endregion [ResponseCache(Duration = 0)] [HttpGet] public async Task GetWipInfoAsync() @@ -628,6 +680,9 @@ namespace AMESCoreStudio.Web.Controllers #region PCS001 工單資料維護 public async Task PCS001(WipViewModel model = null) { + + + //await GetUnitList(); await GetProductType(); await GetFactoryInfo(); @@ -649,6 +704,10 @@ namespace AMESCoreStudio.Web.Controllers GetPCSList1(); GetPCSOPList(); + GetCheckboxApproveLogo(); + GetCheckboxCompanyLogo(); + GetCheckboxPrintMode(); + GetCheckboxWipAttr(); //var result = new WipAllViewModel(); //return View(result); return View(model); diff --git a/AMESCoreStudio.Web/Enums/EnumPCS.cs b/AMESCoreStudio.Web/Enums/EnumPCS.cs new file mode 100644 index 00000000..b1f073c4 --- /dev/null +++ b/AMESCoreStudio.Web/Enums/EnumPCS.cs @@ -0,0 +1,116 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace AMESCoreStudio.Web +{ + public class Enums + { + /// + /// 列印方式 + /// + public enum EnumPrintMode + { + /// + /// ON Line列印 + /// + [Display(Name = "ON Line列印")] + ON = 1, + + /// + /// OFF Line列印 + /// + [Display(Name = "OFF Line列印")] + OFF = 2 + } + + /// + /// 認證Logo + /// + public enum EnumApproveLogo + { + /// + /// CE + /// + [Display(Name = "CE")] + CE, + + /// + /// FCC + /// + [Display(Name = "FCC")] + FCC, + + /// + /// ROHS + /// + [Display(Name = "ROHS")] + ROHS, + + /// + /// UL + /// + [Display(Name = "UL")] + UL, + + /// + /// 皆無 + /// + [Display(Name = "皆無")] + Default = 0 + } + + /// + /// 公司Logo + /// + public enum EnumCompanyLogo + { + /// + /// A VALUE + /// + [Display(Name = "A VALUE")] + A, + + /// + /// 無 + /// + [Display(Name = "無")] + Default = 0 + } + + /// + /// WipAttr + /// + public enum EnumWipAttr + { + /// + /// 正常工單 + /// + [Display(Name = "正常工單")] + A, + + /// + /// 非標96工單 + /// + [Display(Name = "非標96工單-非標單據:人員輸入")] + B, + } + + /// + /// Get Enum Display + /// + /// + /// + public static string GetDisplayName(Enum enumValue) + { + return enumValue.GetType()? + .GetMember(enumValue.ToString())?.First()? + .GetCustomAttribute()? + .Name; + } + } +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Helper/CheckBoxTagHelper.cs b/AMESCoreStudio.Web/Helper/CheckBoxTagHelper.cs new file mode 100644 index 00000000..c75c8698 --- /dev/null +++ b/AMESCoreStudio.Web/Helper/CheckBoxTagHelper.cs @@ -0,0 +1,119 @@ +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AMESCoreStudio.Web.Helper +{ + /// + /// 复选框 + /// + /// + /// 当Items为空时显示单个,且选择后值为true + /// + [HtmlTargetElement(CheckboxTagName)] + public class CheckBoxTagHelper : TagHelper + { + private const string CheckboxTagName = "cl-checkbox"; + private const string ForAttributeName = "asp-for"; + private const string ItemsAttributeName = "asp-items"; + private const string SkinAttributeName = "asp-skin"; + private const string SignleTitleAttributeName = "asp-title"; + protected IHtmlGenerator Generator { get; } + public CheckBoxTagHelper(IHtmlGenerator generator) + { + Generator = generator; + } + + [ViewContext] + public ViewContext ViewContext { get; set; } + + [HtmlAttributeName(ForAttributeName)] + public ModelExpression For { get; set; } + + [HtmlAttributeName(ItemsAttributeName)] + public IEnumerable Items { get; set; } + + [HtmlAttributeName(SkinAttributeName)] + public CheckboxSkin Skin { get; set; } = CheckboxSkin.defult; + + [HtmlAttributeName(SignleTitleAttributeName)] + public string SignleTitle { get; set; } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + //获取绑定的生成的Name属性 + string inputName = ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(For?.Name); + string skin = string.Empty; + #region 风格 + switch (Skin) + { + case CheckboxSkin.defult: + skin = ""; + break; + case CheckboxSkin.primary: + skin = "primary"; + break; + } + #endregion + #region 单个复选框 + if (Items == null) + { + output.TagName = "input"; + output.TagMode = TagMode.SelfClosing; + output.Attributes.Add("type", "checkbox"); + output.Attributes.Add("id", inputName); + output.Attributes.Add("name", inputName); + output.Attributes.Add("lay-skin", skin); + output.Attributes.Add("title", SignleTitle); + output.Attributes.Add("value", "true"); + if (For?.Model?.ToString().ToLower() == "true") + { + output.Attributes.Add("checked", "checked"); + } + return; + } + #endregion + #region 复选框组 + var currentValues = Generator.GetCurrentValues(ViewContext, For.ModelExplorer, expression: For.Name, allowMultiple: true); + foreach (var item in Items) + { + var checkbox = new TagBuilder("input"); + checkbox.TagRenderMode = TagRenderMode.SelfClosing; + checkbox.Attributes["type"] = "checkbox"; + checkbox.Attributes["id"] = inputName; + checkbox.Attributes["name"] = inputName; + checkbox.Attributes["lay-skin"] = skin; + checkbox.Attributes["title"] = item.Text; + checkbox.Attributes["value"] = item.Value; + if (item.Disabled) + { + checkbox.Attributes.Add("disabled", "disabled"); + } + if (item.Selected || (currentValues != null && currentValues.Contains(item.Value))) + { + checkbox.Attributes.Add("checked", "checked"); + } + + output.Content.AppendHtml(checkbox); + } + output.TagName = ""; + #endregion + } + } + public enum CheckboxSkin + { + /// + /// 默認 + /// + defult, + /// + /// 原始 + /// + primary + } +} diff --git a/AMESCoreStudio.Web/Helper/DisplayTitleTagHelper.cs b/AMESCoreStudio.Web/Helper/DisplayTitleTagHelper.cs new file mode 100644 index 00000000..ca1da93d --- /dev/null +++ b/AMESCoreStudio.Web/Helper/DisplayTitleTagHelper.cs @@ -0,0 +1,70 @@ +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TagHelperForModel.Helper +{ + public class DisplayTitleTagHelper : TagHelper + { + public ModelExpression aspFor { get; set; } + + [ViewContext] + [HtmlAttributeNotBound] + public ViewContext ViewContext { get; set; } + + protected IHtmlGenerator _generator { get; set; } + + public DisplayTitleTagHelper(IHtmlGenerator generator) + { + _generator = generator; + } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.TagName = ""; + var propMetadata = aspFor.Metadata; + var @class = context.AllAttributes["class"].Value; + + var label = _generator.GenerateLabel(ViewContext, aspFor.ModelExplorer, + propMetadata.Name, propMetadata.Name, new { @class }); + + var strong = new TagBuilder("strong"); + strong.InnerHtml.Append(propMetadata.DisplayName); + label.InnerHtml.Clear(); + label.InnerHtml.AppendHtml(strong); + + if (propMetadata.IsRequired) + { + var span = new TagBuilder("span"); + span.AddCssClass("text-danger"); + span.InnerHtml.Append("*"); + + label.InnerHtml.AppendHtml(span); + } + + output.Content.AppendHtml(label); + + + if (string.IsNullOrEmpty(propMetadata.Description) == false) + { + var span = new TagBuilder("span"); + span.AddCssClass("text-success"); + span.InnerHtml.Append(propMetadata.Description); + + output.Content.AppendHtml(span); + } + + var validation = _generator.GenerateValidationMessage(ViewContext, aspFor.ModelExplorer, + propMetadata.Name, string.Empty, string.Empty, new { @class = "text-danger" }); + + output.Content.AppendHtml(validation); + + base.Process(context, output); + } + } +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs index f1b08576..c083f266 100644 --- a/AMESCoreStudio.Web/ViewModels/WipViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/WipViewModel.cs @@ -41,5 +41,6 @@ namespace AMESCoreStudio.Web.ViewModels public WipSopLog wipSopLog { get; set; } + public WipLabel wipLabel { get; set; } } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index cca30755..10ffa46f 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -2,7 +2,8 @@ @{ ViewData["Title"] = "PCS001C"; - Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + Layout = "~/Views/Shared/_AMESLayout.cshtml"; + }