Ver Fonte

feat:1、编辑弹窗增加字段验证;2:上传文件大小限制增加到300M;3、上传文件接口需登录验证

Zhenghanjv há 2 meses atrás
pai
commit
2f9cf67c12

+ 8 - 0
Platform/AI.Platform.Page/Pages/Media/Media.razor.cs

@@ -7,6 +7,7 @@ using AntDesign;
 using AntDesign.TableModels;
 using Dm.util;
 using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Forms;
 using Microsoft.JSInterop;
 using SqlSugar;
 using System.Data.Common;
@@ -94,6 +95,13 @@ public partial class Media
         model = new MediaDialogModel();
         model.Type = type;
         model.siteInfos = Sites;
+        var siteinfo = Sites.Find(it => it.Id == Global.CurrentUser.SiteId);
+        if (type ==1 && siteinfo != null)
+        {
+            model.GroupID = siteinfo.ParentId;
+            model.BusinessUnitID = siteinfo.Id;
+        }
+
         if (type == 2 || type == 3)
         {
             model.Id = media?.Id;

+ 41 - 5
Platform/AI.Platform.Page/Pages/Media/Model/MediaModel.cs

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Components;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Text;
 using System.Text.Json;
 
@@ -17,7 +18,7 @@ namespace AI.Platform.Page.Pages.Media.Model
     /// <summary>
     /// 用于新增/修改广告时传递弹窗数据
     /// </summary>
-    public class MediaDialogModel
+    public class MediaDialogModel: IValidatableObject
     {
         /// <summary>
         /// 表id
@@ -37,11 +38,13 @@ namespace AI.Platform.Page.Pages.Media.Model
         /// <summary>
         /// 站点ID
         /// </summary>
+        [Required(ErrorMessage = "请绑定油站")]
         public long BusinessUnitID { get; set; }
 
         /// <summary>
         /// 文件名
         /// </summary>
+        [Required(ErrorMessage = "请上传广告以获取文件名")]
         public string FileName { set; get; }
 
         /// <summary>
@@ -62,16 +65,19 @@ namespace AI.Platform.Page.Pages.Media.Model
         /// <summary>
         /// 文件开始播放时间
         /// </summary>
+        [Required(ErrorMessage = "请设置广告播放时段")]
         public int? StartTime { set; get; }
 
         /// <summary>
         /// 文件结束播放时间
         /// </summary>
+        [Required(ErrorMessage = "请设置广告播放时段")]
         public int? EndTime { set; get; }
 
         /// <summary>
         /// 文件生效时间
         /// </summary>
+        [Required(ErrorMessage = "请设置广告策略有效时间段")]
         public DateTime? EffecitiveTime { set; get; }
 
         /// <summary>
@@ -82,11 +88,13 @@ namespace AI.Platform.Page.Pages.Media.Model
         /// <summary>
         /// 文件油机状态
         /// </summary>
-        public List<string> MachineStateList { set; get; }
+        [Required(ErrorMessage = "请选择播放该广告的油机状态")]
+        public List<string> MachineStateList { set; get; } = new List<string>();
 
         /// <summary>
         /// 文件广告状态 0:禁用;1:可用
         /// </summary>
+        [Required(ErrorMessage = "请设置广告状态")]
         public int MediaState { set; get; }
 
         /// <summary>
@@ -104,6 +112,8 @@ namespace AI.Platform.Page.Pages.Media.Model
         /// </summary>
         public List<SiteInfo> siteInfos { set; get; }
 
+        
+
         public MediaEntity ToCompany()
         {
             var media = new MediaEntity()
@@ -137,13 +147,39 @@ namespace AI.Platform.Page.Pages.Media.Model
         {
             if (MachineStateList.IsNullOrEmpty())
             {
-                return new List<string>
+                return getAllMachineStateList();
+            }
+
+            return MachineStateList;
+        }
+
+        /// <summary>
+        /// 获取所有油枪状态
+        /// </summary>
+        /// <returns></returns>
+        public List<string> getAllMachineStateList()
+        {
+            return new List<string>
                 {
                     "idle","lock","offline","lift","authorised","start","fueling"
                 };
-            }
+        }
 
-            return MachineStateList;
+      
+        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
+        {
+            if (MachineStateList.IsNullOrEmpty())
+            {
+                yield return new ValidationResult("请选择播放该广告的油机状态", new[] { nameof(MachineStateList) });
+            }
+            //if(MediaState == -1)
+            //{
+            //    yield return new ValidationResult("请设置广告状态", new[] { nameof(MediaState) });
+            //}
+            if (BusinessUnitID <= 0)
+            {
+                yield return new ValidationResult("请选择下发油站", new[] { nameof(BusinessUnitID) });
+            }
         }
     }
 

+ 166 - 62
Platform/AI.Platform.Page/Pages/Media/UpdateMediaDialog.razor

@@ -2,81 +2,145 @@
 @using System.Threading.Tasks
 @using System.Text.Json
 
-@if (IsVisible)
+@if (IsVisible && Model != null)
 {
     <div class="modal-overlay">
         <div class="modal-content filter_box">
             @if (Model?.Type == 1 || Model?.Type == 2)
             {
-                <div class="filter_row">
-                    <span>文件名</span><Input Placeholder="文件名" @bind-Value="Model.FileName" Style="width:30%" Disabled />
-                    <span>上传人</span><Input Placeholder="上传人" @bind-Value="Model.MediaUploader" Style="width:30%" Disabled />
-                </div>
+                <EditForm Model="@Model" style="width:100%" Context="editContext" @key="Model">
+                    <DataAnnotationsValidator />
+
+                    <div class="filter_row">
+
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>文件名</span><Input Placeholder="文件名" @bind-Value="Model.FileName" Style="width:80%" Disabled />
+                            </div>
+                            <ValidationMessage For="@(() => Model.FileName)" style="color:red"/>
+                        </div>
+                        
+
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>上传人</span><Input Placeholder="上传人" @bind-Value="Model.MediaUploader" Style="width:80%" Disabled />
+                            </div>
+                            <ValidationMessage For="@(() => Model.MediaUploader)" style="color:red" />
+                        </div>
+                        
+                    </div>
 
-                <div class="filter_row">
-                    <span>广告状态</span>
-                    <SimpleSelect DefaultValue="@Model.MediaState.ToString()" OnSelectedItemChanged="@(data => OnSelectItemChange(1, data))" Style="width:30%">
-                        <SelectOptions>
-                            <SimpleSelectOption Value="0" Label="禁用" style="width:30%" />
-                            <SimpleSelectOption Value="1" Label="可用" style="width:30%" />
-                        </SelectOptions>
-                    </SimpleSelect>
-
-                    <span>油机状态</span>
-                    <SimpleSelect DefaultValues="@Model.getMachineStateList()" OnSelectedItemsChanged="OnSelectItemsChange" Mode="SelectMode.Multiple" style="width:30%">
-                        <SelectOptions>
-                            <SimpleSelectOption Value="idle" Label="空闲" />
-                            <SimpleSelectOption Value="lock" Label="锁枪" />
-                            <SimpleSelectOption Value="offline" Label="脱机" />
-                            <SimpleSelectOption Value="lift" Label="提枪" />
-                            <SimpleSelectOption Value="authorised" Label="授权" />
-                            <SimpleSelectOption Value="start" Label="开始" />
-                            <SimpleSelectOption Value="fueling" Label="加油中" />
-                        </SelectOptions>
-                    </SimpleSelect>
-                </div>
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>广告状态</span>
+                                <SimpleSelect DefaultValue="@Model.MediaState.ToString()" OnSelectedItemChanged="@(data => OnSelectItemChange(1, data, editContext))" Style="width:80%">
+                                    <SelectOptions>
+                                        <SimpleSelectOption Value="0" Label="禁用" style="width:80%" />
+                                        <SimpleSelectOption Value="1" Label="可用" style="width:80%" />
+                                    </SelectOptions>
+                                </SimpleSelect>
+                            </div>
+                            <ValidationMessage For="@(() => Model.MediaState)" style="color:red" />
+                        </div>
+                        
+
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>油机状态</span>
+                                <SimpleSelect DefaultValues="@Model.getMachineStateList()" OnSelectedItemsChanged="@(data => OnSelectItemsChange(data, editContext))" Mode="SelectMode.Multiple" style="width:80%">
+                                    <SelectOptions>
+                                        <SimpleSelectOption Value="idle" Label="空闲" />
+                                        <SimpleSelectOption Value="lock" Label="锁枪" />
+                                        <SimpleSelectOption Value="offline" Label="脱机" />
+                                        <SimpleSelectOption Value="lift" Label="提枪" />
+                                        <SimpleSelectOption Value="authorised" Label="授权" />
+                                        <SimpleSelectOption Value="start" Label="开始" />
+                                        <SimpleSelectOption Value="fueling" Label="加油中" />
+                                    </SelectOptions>
+                                </SimpleSelect>
+                            </div>
+                            <ValidationMessage For="@(() => Model.MachineStateList)" style="color:red" />
+                        </div>
+                        
+                    </div>
 
-                <div class="filter_row">
-                    <span>有效时间段</span><RangePicker TValue="DateTime?[]" Value="EffecitiveTime"  OnChange="@(date => onDateChage(date, 1))" />
-                    <span style="margin-right:5%">播放时段</span><RangePicker TValue="DateTime?[]" Value="playRange" Picker="DatePickerType.Time" Format="@("HH")" OnChange="@(date => onDateChage(date, 2))" />
-                </div>
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>有效时间段</span><RangePicker TValue="DateTime?[]" Value="EffecitiveTime" OnChange="@(date => onDateChage(date, 1))" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.EffecitiveTime)" style="color:red" />
+                        </div>
+                        
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span style="margin-right:5%">播放时段</span><RangePicker TValue="DateTime?[]" Value="playRange" Picker="DatePickerType.Time" Format="@("HH")" OnChange="@(date => onDateChage(date, 2))" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.StartTime)" style="color:red" />
+                        </div>
+                        
+                    </div>
 
-                <div class="filter_row">
-                    <span>下发油站</span>
-                    <SimpleSelect DefaultValue="@Model.BusinessUnitID.ToString()" OnSelectedItemChanged="@(data => OnSelectItemChange(2, data))" style="width:30%">
-                        <SelectOptions>
-                            @foreach (var department in Model.siteInfos)
-                            {
-                                <SimpleSelectOption Value="@department.Id.ToString()" Label="@department.Name" style="width:30%" />
-                            }
-                        </SelectOptions>
-                    </SimpleSelect>
-                    <span>备注</span><Input Placeholder="备注" @bind-Value="Model.Remark" style="width:30%" />
-                </div>
-            }
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>下发油站</span>
+                                <SimpleSelect DefaultValue="@Model.BusinessUnitID.ToString()" OnSelectedItemChanged="@(data => OnSelectItemChange(2, data, editContext))" style="width:80%">
+                                    <SelectOptions>
+                                        @foreach (var department in Model.siteInfos)
+                                        {
+                                            <SimpleSelectOption Value="@department.Id.ToString()" Label="@department.Name" style="width:80%" />
+                                        }
+                                    </SelectOptions>
+                                </SimpleSelect>
+                            </div>
+                            <ValidationMessage For="@(() => Model.BusinessUnitID)" style="color:red" />
+                        </div>
+                        
+
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>备注</span><Input Placeholder="备注" @bind-Value="Model.Remark" style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.Remark)" style="color:red" />
+                        </div>
+                    </div>
 
-            @if(Model?.Type == 1)
-            {
-                <Upload class="filter_row" Name="file" style="justify-content:center" Action="@Global.MediaUploadUrl" 
-                @bind-FileList="fileList" ListType="UploadListType.PictureCard"
-                ShowUploadList="true" ShowDownloadIcon="true" ShowPreviewIcon="true" ShowRemoveIcon="true" ShowButton="fileList.Count < 1"
-                OnCompleted="OnUploadCompleted" OnRemove="OnRemove">
-                    <div>
-                        <Icon Type="plus" />
-                        <div className="ant-upload-text">上传文件</div>
+                    @if (Model?.Type == 1)
+                    {
+                        <Upload class="filter_row" Name="file" style="justify-content:center" Action="@Global.MediaUploadUrl"
+                                Headers="uploadFileHeader"
+                                @bind-FileList="fileList" ListType="UploadListType.PictureCard"
+                                ShowUploadList="true" ShowDownloadIcon="true" ShowPreviewIcon="true" ShowRemoveIcon="true" ShowButton="fileList.Count < 1"
+                                OnCompleted="OnUploadCompleted" OnRemove="OnRemove">
+                            <div>
+                                <Icon Type="plus" />
+                                <div className="ant-upload-text">上传文件</div>
+                            </div>
+                        </Upload>
+                    }
+
+                    <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                        <button Icon="plus" type="button" @onclick="() => HandleSubmit(editContext)" style="margin-right:2%">确定</button>
+                        <button Icon="reload" @onclick="Close" style="margin-right:2%">取消</button>
                     </div>
-                </Upload>
+                </EditForm>
+                
             }
 
+            
+
             @if(Model?.Type == 3)
             {
                 <h3>是否删除广告?@(Model.FileName)</h3>
+                <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                    <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
+                    <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
+                </div>
             }
 
-            <div class="filter_row" style="justify-content:end;margin-top:5%;">
-                <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
-                <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
-            </div>
+            
         </div>
         
     </div>
@@ -130,10 +194,12 @@
     /// </summary>
     private DateTime?[] playRange = new DateTime?[2];
 
+    private Dictionary<string, string> uploadFileHeader = new Dictionary<string, string>();
 
     protected override void OnParametersSet()
     {
         fileList.Clear();
+        uploadFileHeader["Authorization"] = Global.GetToken();
         EffecitiveTime = new DateTime?[]
         {
             Model?.EffecitiveTime,
@@ -176,6 +242,7 @@
         }
     }
 
+
     /// <summary>
     /// 上传文件完毕
     /// </summary>
@@ -204,7 +271,7 @@
     /// </summary>
     /// <param name="type">1:油机状态;2:站点</param>
     /// <param name="value">选择的值</param>
-    private void OnSelectItemChange(int type, string value)
+    private void OnSelectItemChange(int type, string value, EditContext editContext)
     {
         Console.WriteLine(value);
         switch (type)
@@ -213,6 +280,7 @@
                 int state = -1;
                 int.TryParse(value, out state);
                 Model.MediaState = state;
+                editContext.NotifyFieldChanged(FieldIdentifier.Create(() => Model.MediaState));
                 break;
             case 2:
                 var siteinfo = Model.siteInfos.Find(it => it.Id.ToString().Equals(value));
@@ -220,22 +288,31 @@
                 {
                     Model.GroupID = siteinfo.ParentId;
                     Model.BusinessUnitID = siteinfo.Id;
+
+                    editContext.NotifyFieldChanged(FieldIdentifier.Create(() => Model.BusinessUnitID));
                 }
 
                 break;
         }
-        
+
     }
 
     /// <summary>
     /// 多选选择器选择事件
     /// </summary>
     /// <param name="values">选择的值</param>
-    private void OnSelectItemsChange(IEnumerable<string> values)
+    private void OnSelectItemsChange(IEnumerable<string> values ,EditContext editContext)
     {
         Console.WriteLine(values);
-        Model.MachineStateList = values.ToList();
+        if (values.Count() <= 0)
+        {
+            Model.MachineStateList = Model.getAllMachineStateList();
+        } else
+        {
+            Model.MachineStateList = values.ToList();
+        }
         
+        editContext.NotifyFieldChanged(FieldIdentifier.Create(() => Model.MachineStateList));
     }
 
     /// <summary>
@@ -270,6 +347,15 @@
         }
     }
 
+    private async Task HandleSubmit(EditContext editContext)
+    {
+        
+        if(editContext.Validate())
+        {
+            await onSure();
+        }
+    }
+
     /// <summary>
     /// 确定按钮事件
     /// </summary>
@@ -333,4 +419,22 @@
         width: 100%;
         margin-top: 2%;
     }
+
+    .filter_row_around {
+        display: flex;
+        flex-direction: row;
+        justify-content: space-around;
+        align-items: center;
+        width: 100%;
+        margin-top: 2%;
+    }
+
+    .filter_colume {
+        display: flex;
+        flex-direction: column;
+        justify-content: center;
+        align-items: end;
+        width: 100%;
+        margin-top: 2%;
+    }
 </style>

+ 6 - 0
Platform/AI.Platform.Page/Pages/Site/Model/SiteModel.cs

@@ -4,6 +4,7 @@ using AI.Platform.Core.Entity.Site;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Text;
 
 namespace AI.Platform.Page.Pages.Site.Model
@@ -71,6 +72,7 @@ namespace AI.Platform.Page.Pages.Site.Model
         /// <summary>
         /// 站名
         /// </summary>
+        [Required(ErrorMessage = "请填写站名")]
         public string Name { get; set; }
 
         /// <summary>
@@ -86,11 +88,13 @@ namespace AI.Platform.Page.Pages.Site.Model
         /// <summary>
         /// 油站地址
         /// </summary>
+        [Required(ErrorMessage = "请填写油站地址")]
         public string Address { get; set; }
 
         /// <summary>
         /// 联系方式
         /// </summary>
+        [Required(ErrorMessage = "请填写联系方式")]
         public string Contact { get; set; }
 
         public SiteEntity ToCompany()
@@ -189,6 +193,7 @@ namespace AI.Platform.Page.Pages.Site.Model
         /// <summary>
         /// 站点id
         /// </summary>
+        [Required(ErrorMessage = "请绑定站点")]
         public long SiteId { get; set; }
 
         /// <summary>
@@ -199,6 +204,7 @@ namespace AI.Platform.Page.Pages.Site.Model
         /// <summary>
         /// 设备SN
         /// </summary>
+        [Required(ErrorMessage = "请输入设备码")]
         public string sn { get; set; }
 
         /// <summary>

+ 66 - 24
Platform/AI.Platform.Page/Pages/Site/UpdateScreenDialog.razor

@@ -8,29 +8,52 @@
         <div class="modal-content filter_box">
             @if (Model?.Type == 1 || Model?.Type == 2)
             {
-                <div class="filter_row">
-                    <span>设备码</span><Input Placeholder="设备码" @bind-Value="Model.sn" Style="width:30%" />
+                <EditForm Model="@Model" OnValidSubmit="onSure" style="width:100%">
+                    <DataAnnotationsValidator />
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>设备码</span><Input Placeholder="设备码" @bind-Value="Model.sn" Style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(()=>Model.sn)" style="color:red" />
+                        </div>
+                        
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>站点</span>
+                                <Select @bind-Value="Model.SiteId"
+                                        Style="width:80%"
+                                        TItemValue="long"
+                                        TItem="string"
+                                        DefaultActiveFirstOption="true" EnableSearch AllowClear>
+                                    <SelectOptions>
+                                        @foreach (var department in Model.Sites)
+                                        {
+                                            <SelectOption TItemValue="long" TItem="string" Value="@department.Id" Label="@department.Name" />
+                                        }
+                                    </SelectOptions>
+                                </Select>
+                            </div>
+                            <ValidationMessage For="@(() => Model.SiteId)" style="color:red" />
+                        </div>
+                    </div>
 
-                    <span>站点</span>
-                    <Select @bind-Value="Model.SiteId"
-                            Style="width:30%"
-                            TItemValue="long"
-                            TItem="string"
-                            DefaultActiveFirstOption="true" EnableSearch AllowClear>
-                        <SelectOptions>
-                            @foreach (var department in Model.Sites)
-                            {
-                                <SelectOption TItemValue="long" TItem="string" Value="@department.Id" Label="@department.Name" />
-                            }
-                        </SelectOptions>
-                    </Select>
-                    
-                </div>
+                    <div class="filter_row" style="justify-content:start">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>备注</span><Input Placeholder="备注" @bind-Value="Model.Remark" Style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.Remark)" style="color:red" />
+                        </div>
+                    </div>
 
-                <div class="filter_row" style="justify-content:start">
-                    <span>备注</span><Input Placeholder="备注" @bind-Value="Model.Remark" Style="width:30%" />
+                    <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                        <button Icon="plus" type="submit" style="margin-right:2%">确定</button>
+                        <button Icon="reload" type="button" @onclick="Close" style="margin-right:2%">取消</button>
+                    </div>
 
-                </div>
+                </EditForm>
+                
             }
 
             
@@ -38,12 +61,13 @@
             @if (Model?.Type == 3)
             {
                 <h3>是否删除设备?@(Model.sn)</h3>
+                <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                    <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
+                    <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
+                </div>
             }
 
-            <div class="filter_row" style="justify-content:end;margin-top:5%;">
-                <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
-                <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
-            </div>
+            
         </div>
 
     </div>
@@ -89,4 +113,22 @@
         width: 100%;
         margin-top: 2%;
     }
+
+    .filter_row_around {
+        display: flex;
+        flex-direction: row;
+        justify-content: space-around;
+        align-items: center;
+        width: 100%;
+        margin-top: 2%;
+    }
+
+    .filter_colume {
+        display: flex;
+        flex-direction: column;
+        justify-content: center;
+        align-items: end;
+        width: 100%;
+        margin-top: 2%;
+    }
 </style>

+ 79 - 26
Platform/AI.Platform.Page/Pages/Site/UpdateSiteDialog.razor

@@ -8,29 +8,62 @@
         <div class="modal-content filter_box">
             @if (Model?.Type == 1 || Model?.Type == 2)
             {
-                <div class="filter_row">
-                    <span>站名</span><Input Placeholder="站名" @bind-Value="Model.Name" Style="width:30%" />
-
-                    <span>归属集团</span>
-                    <Select @bind-Value="Model.ParentId"
-                            Style="width:30%"
-                            TItemValue="long"
-                            TItem="string"
-                            DefaultActiveFirstOption="true" EnableSearch AllowClear>
-                        <SelectOptions>
-                            @foreach (var department in Model.Sites)
-                            {
-                                <SelectOption TItemValue="long" TItem="string" Value="@department.Id" Label="@department.Name" />
-                            }
-                        </SelectOptions>
-                    </Select>
-                    
-                </div>
+                <EditForm Model="@Model" OnValidSubmit="onSure" style="width:100%">
+                    <DataAnnotationsValidator />
+                    @* <ValidationSummary /> *@
 
-                <div class="filter_row">
-                    <span>联系方式</span><Input Placeholder="联系方式" @bind-Value="Model.Contact" Style="width:30%" />
-                    <span>地址</span><Input Placeholder="地址" @bind-Value="Model.Address" Style="width:30%" />
-                </div>
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>站名</span><Input Placeholder="站名" @bind-Value="Model.Name" Style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.Name)" style="color:red" />
+                        </div>
+                        
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>归属集团</span>
+                                <Select @bind-Value="Model.ParentId"
+                                        Style="width:80%"
+                                        TItemValue="long"
+                                        TItem="string"
+                                        DefaultActiveFirstOption="true" EnableSearch AllowClear>
+                                    <SelectOptions>
+                                        @foreach (var department in Model.Sites)
+                                        {
+                                            <SelectOption TItemValue="long" TItem="string" Value="@department.Id" Label="@department.Name" />
+                                        }
+                                    </SelectOptions>
+                                </Select>
+                            </div>
+                            <ValidationMessage For="@(() => Model.ParentId)" style="color:red" />
+                        </div>
+                    </div>
+
+                    <div class="filter_row">
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>联系方式</span><Input Placeholder="联系方式" @bind-Value="Model.Contact" Style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.Address)" style="color:red" />
+                        </div>
+
+                        <div class="filter_colume">
+                            <div class="filter_row_around">
+                                <span>地址</span><Input Placeholder="地址" @bind-Value="Model.Address" Style="width:80%" />
+                            </div>
+                            <ValidationMessage For="@(() => Model.Address)" style="color:red" />
+                        </div>
+                         
+                    </div>
+
+                    <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                        <button Icon="plus" type="submit"  style="margin-right:2%">确定</button>
+                        <button Icon="reload" type="button" @onclick="Close" style="margin-right:2%">取消</button>
+                    </div>
+
+                </EditForm>
+                
             }
 
             
@@ -38,12 +71,14 @@
             @if (Model?.Type == 3)
             {
                 <h3>是否删除站点?@(Model.Name)</h3>
+
+                <div class="filter_row" style="justify-content:end;margin-top:5%;">
+                    <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
+                    <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
+                </div>
             }
 
-            <div class="filter_row" style="justify-content:end;margin-top:5%;">
-                <Button Icon="plus" OnClick="onSure" Style="margin-right:2%">确定</Button>
-                <Button Icon="reload" OnClick="Close" Style="margin-right:2%">取消</Button>
-            </div>
+            
         </div>
 
     </div>
@@ -89,4 +124,22 @@
         width: 100%;
         margin-top: 2%;
     }
+
+    .filter_row_around {
+        display: flex;
+        flex-direction: row;
+        justify-content: space-around;
+        align-items: center;
+        width: 100%;
+        margin-top: 2%;
+    }
+
+    .filter_colume {
+        display: flex;
+        flex-direction: column;
+        justify-content: center;
+        align-items: end;
+        width: 100%;
+        margin-top: 2%;
+    }
 </style>

+ 1 - 2
Platform/AI.Platform.Page/Pages/Site/UpdateSiteDialog.razor.cs

@@ -75,6 +75,7 @@ public partial class UpdateSiteDialog
     /// <returns></returns>
     private async Task onSure()
     {
+       
         if (ModelChanged.HasDelegate)
         {
             await ModelChanged.InvokeAsync(Model);
@@ -86,6 +87,4 @@ public partial class UpdateSiteDialog
         }
         await OnlyClose();
     }
-
-    
 }

+ 41 - 1
Platform/AI.Platform.Service/AuthService.cs

@@ -15,6 +15,7 @@ using ZhonTai.Admin.Contracts.Domain.VehicleTerminal.Company;
 using ZhonTai.Admin.Contracts.Domain.VehicleTerminal.ElectronicAccount;
 using ZhonTai.Admin.Contracts.Domain.VehicleTerminal.UserInfo;
 using static AI.Platform.Core.Entity.PublicEnum;
+using AI.Platform.Service.Output;
 
 namespace AI.Platform.Service;
 
@@ -80,7 +81,7 @@ public class AuthService : BaseService
                 UserType = PublicEnum.UserType.Admin,
             });
             string Buid = "c75b2e74-d51e-42ae-bc89-2d39312c9c30";
-            _contextAccessor.HttpContext.Response.Headers["access-token"] = token;
+            //_contextAccessor.HttpContext.Response.Headers["access-token"] = token;
             return new { token , Buid };
         }
         catch (Exception ex)
@@ -89,6 +90,45 @@ public class AuthService : BaseService
         }
     }
 
+    /// <summary>
+    /// 登录
+    /// {"username":"admin","password":"123456"}
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    /// <remarks><code>{"username":"admin","password":"123456"}</code></remarks>
+    [HttpPost]
+    public async Task<LoginOutput> LoginForBack(LoginInput input)
+    {
+        try
+        {
+            var Password = Crypto.MD5Encrypt(input.Password);
+            var user = await _user.AsQueryable()
+                .Where(x => x.Account.Equals(input.Account) && x.Password.Equals(Password))
+                .FirstAsync();
+            _ = user ?? throw Oops.Oh(ErrorCode.E1000);
+
+            //生成Token令牌
+            var token = Jwt.Serialize(new TokenModelJwt
+            {
+                UserId = user.Id,
+                Name = user.Account,
+                UserType = PublicEnum.UserType.Admin,
+            });
+            string Buid = "c75b2e74-d51e-42ae-bc89-2d39312c9c30";
+            //_contextAccessor.HttpContext.Response.Headers["access-token"] = token;
+            return new LoginOutput()
+            { 
+                Token = token,
+                Buid = Buid
+            };
+        }
+        catch (Exception ex)
+        {
+            throw Oops.Oh(ex.Message);
+        }
+    }
+
     /// <summary>
     /// 获取企业密钥
     /// </summary>

+ 2 - 1
Platform/AI.Platform.Service/FileService.cs

@@ -74,7 +74,8 @@ public class FileService : BaseService
     /// </summary>
     /// <param name="classification"></param>
     /// <returns></returns>
-    [HttpPost, AllowAnonymous]
+    [HttpPost]
+    [RequestSizeLimit(307_200_000)]
     public async Task<MediaFileUploadOutput> UploadMedia(IFormFile file)
     {
        

+ 12 - 0
Platform/AI.Platform.Service/Output/LoginOutput.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace AI.Platform.Service.Output
+{
+    public class LoginOutput
+    {
+        public string Token { get; set; } = string.Empty;
+        public string Buid { get; set; } = string.Empty;
+    }
+}

+ 7 - 0
Platform/AI.Platform.Tool/Util/Global.cs

@@ -77,6 +77,13 @@ public static class Global
     /// 
     /// </summary>
     public static List<SystemMenu> Menus { get; set; } = new List<SystemMenu>();
+
+    public static string Token { get; set; }
+
+    public static string GetToken()
+    {
+        return "Bearer " + Token;
+    }
     
     /// <summary>
     /// 获取host

+ 28 - 1
Platform/AI.Platform.Web/Components/Pages/Account/Login/Login.razor.cs

@@ -1,6 +1,8 @@
 using AI.Platform.Core;
 using AI.Platform.Core.Util;
 using AI.Platform.Page.Pages.Media;
+using AI.Platform.Service;
+using AI.Platform.Service.Output;
 using AI.Platform.Web.Common;
 using Microsoft.JSInterop;
 using System.Collections.Generic;
@@ -10,6 +12,9 @@ namespace AI.Platform.Web.Components.Pages.Account.Login;
 //https://www.cnblogs.com/j4587698/p/16531294.html
 public partial class Login
 {
+    [Inject]
+    public AuthService authService { get; set; }
+
     protected override async void OnInitialized()
     {
         base.OnInitialized();
@@ -86,7 +91,8 @@ public partial class Login
             }
             await localStorageHelper.SetLocalStorage(LocalStorage.UserInfo, Crypto.AESEncrypt(new { user.Id, user.Account, user.Password, Expired = DateTime.Now.AddDays(Global.Expired) }.ToJson()));
 
-            ExecuteLogin(user);
+            await ExecuteLogin(user);
+            await GetToken();
         }
         catch (Exception ex)
         {
@@ -117,6 +123,27 @@ public partial class Login
         NavigationManager.NavigateTo("/media/list");
     }
 
+    private async Task GetToken()
+    {
+        try
+        {
+           LoginOutput result = await authService.LoginForBack(new LoginInput()
+            {
+                Account = Model.Account,
+                Password = Model.Password
+            });
+            
+            Console.WriteLine(result.Token);
+            Global.Token = result.Token;
+
+
+        }
+        catch(Exception e)
+        {
+            Console.WriteLine(e);
+        }
+    }
+
     /// <summary>
     /// 发送短信验证码
     /// </summary>

+ 24 - 1
Platform/AI.Platform.Web/Program.cs

@@ -1,3 +1,26 @@
+using AI.Platform.Service;
 using AI.Platform.Web.Common;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Http.Features;
+
+WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder(args);
 
-WebApplication.CreateBuilder(args).RegistService().RegistApp();
+
+
+//设置请求大小最大值,用于上传文件
+webApplicationBuilder.WebHost.ConfigureKestrel(options =>
+ {
+     options.Limits.MaxRequestBodySize = 307_200_000; //300M
+ });
+webApplicationBuilder.Services.Configure<FormOptions>(options =>
+{
+    options.MultipartBodyLengthLimit = 307_200_000; //300M
+});
+
+webApplicationBuilder.Services.AddScoped<AuthService>();
+
+webApplicationBuilder.RegistService().RegistApp();
+
+var app = webApplicationBuilder.Build();
+
+app.Run();