8 changed files with 617 additions and 158 deletions
@ -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 |
|||
{ |
|||
/// <summary>
|
|||
/// 列印方式
|
|||
/// </summary>
|
|||
public enum EnumPrintMode |
|||
{ |
|||
/// <summary>
|
|||
/// ON Line列印
|
|||
/// </summary>
|
|||
[Display(Name = "ON Line列印")] |
|||
ON = 1, |
|||
|
|||
/// <summary>
|
|||
/// OFF Line列印
|
|||
/// </summary>
|
|||
[Display(Name = "OFF Line列印")] |
|||
OFF = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 認證Logo
|
|||
/// </summary>
|
|||
public enum EnumApproveLogo |
|||
{ |
|||
/// <summary>
|
|||
/// CE
|
|||
/// </summary>
|
|||
[Display(Name = "CE")] |
|||
CE, |
|||
|
|||
/// <summary>
|
|||
/// FCC
|
|||
/// </summary>
|
|||
[Display(Name = "FCC")] |
|||
FCC, |
|||
|
|||
/// <summary>
|
|||
/// ROHS
|
|||
/// </summary>
|
|||
[Display(Name = "ROHS")] |
|||
ROHS, |
|||
|
|||
/// <summary>
|
|||
/// UL
|
|||
/// </summary>
|
|||
[Display(Name = "UL")] |
|||
UL, |
|||
|
|||
/// <summary>
|
|||
/// 皆無
|
|||
/// </summary>
|
|||
[Display(Name = "皆無")] |
|||
Default = 0 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 公司Logo
|
|||
/// </summary>
|
|||
public enum EnumCompanyLogo |
|||
{ |
|||
/// <summary>
|
|||
/// A VALUE
|
|||
/// </summary>
|
|||
[Display(Name = "A VALUE")] |
|||
A, |
|||
|
|||
/// <summary>
|
|||
/// 無
|
|||
/// </summary>
|
|||
[Display(Name = "無")] |
|||
Default = 0 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// WipAttr
|
|||
/// </summary>
|
|||
public enum EnumWipAttr |
|||
{ |
|||
/// <summary>
|
|||
/// 正常工單
|
|||
/// </summary>
|
|||
[Display(Name = "正常工單")] |
|||
A, |
|||
|
|||
/// <summary>
|
|||
/// 非標96工單
|
|||
/// </summary>
|
|||
[Display(Name = "非標96工單-非標單據:人員輸入")] |
|||
B, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Get Enum Display
|
|||
/// </summary>
|
|||
/// <param name="enumValue"></param>
|
|||
/// <returns></returns>
|
|||
public static string GetDisplayName(Enum enumValue) |
|||
{ |
|||
return enumValue.GetType()? |
|||
.GetMember(enumValue.ToString())?.First()? |
|||
.GetCustomAttribute<DisplayAttribute>()? |
|||
.Name; |
|||
} |
|||
} |
|||
} |
@ -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 |
|||
{ |
|||
/// <summary>
|
|||
/// 复选框
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 当Items为空时显示单个,且选择后值为true
|
|||
/// </remarks>
|
|||
[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<SelectListItem> 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 |
|||
{ |
|||
/// <summary>
|
|||
/// 默認
|
|||
/// </summary>
|
|||
defult, |
|||
/// <summary>
|
|||
/// 原始
|
|||
/// </summary>
|
|||
primary |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
|||
} |
@ -1,3 +1,4 @@ |
|||
@using AMESCoreStudio.Web |
|||
@using AMESCoreStudio.Web.Models |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@addTagHelper AMESCoreStudio.Web.Helper.*, AMESCoreStudio.Web |
@ -0,0 +1,99 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.ComponentModel.DataAnnotations.Schema; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System.Runtime.Serialization; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace AMESCoreStudio.WebApi.Models.AMES |
|||
{ |
|||
/// <summary>
|
|||
/// 工單資料-標籤
|
|||
/// </summary>
|
|||
[Table("WIP_LABEL", Schema = "JHAMES")] |
|||
[DataContract] |
|||
public partial class WipLabel |
|||
{ |
|||
/// <summary>
|
|||
/// WIP_ID
|
|||
/// </summary>
|
|||
[Key] |
|||
[Column("WIP_ID", Order = 0)] |
|||
[DataMember] |
|||
public int WipID { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 列印方式
|
|||
/// </summary>
|
|||
[Column("PRINT_MODE")] |
|||
[DataMember] |
|||
public string PrintMode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 列印張數
|
|||
/// </summary>
|
|||
[Column("PRINT_PAGE")] |
|||
[DataMember] |
|||
public int PrintPage { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 認證LOGO
|
|||
/// </summary>
|
|||
[Column("APPROVE_LOGO")] |
|||
[Required] |
|||
[DataMember] |
|||
public string ApproveLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 公司LOGO
|
|||
/// </summary>
|
|||
[Column("COMPANY_LOGO")] |
|||
[Required] |
|||
[DataMember] |
|||
public string CompanyLogo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 工單屬性
|
|||
/// </summary>
|
|||
[Column(" WIP_ATTR")] |
|||
[Required] |
|||
[DataMember] |
|||
public string WipAttr { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 建立日期
|
|||
/// </summary>
|
|||
[Required] |
|||
[Column("CREATE_DATE")] |
|||
[DataMember] |
|||
public DateTime CreateDate { get; set; } = System.DateTime.Now; |
|||
|
|||
/// <summary>
|
|||
/// 更新UserID
|
|||
/// </summary>
|
|||
[Column("UPDATE_USERID")] |
|||
[DataMember] |
|||
public int UpdateUserID { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新日期
|
|||
/// </summary>
|
|||
[Column("UPDATE_DATE")] |
|||
[DataMember] |
|||
public DateTime? UpdateDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 工單資料
|
|||
/// </summary>
|
|||
[ForeignKey("WipID")] |
|||
public virtual WipInfo GetWipInfo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// SOP資料
|
|||
/// </summary>
|
|||
[ForeignKey("WipSopID")] |
|||
public virtual WipSop GetWipSop { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue