|
|
@@ -7,6 +7,7 @@ using Dm.util;
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
using Microsoft.JSInterop;
|
|
|
using SqlSugar;
|
|
|
+using System.Data.Common;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
@@ -66,17 +67,32 @@ public partial class Media
|
|
|
/// </summary>
|
|
|
private UpdateMediaDialog updateMediaDialog { set; get; } = new();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 标识弹窗是否显示
|
|
|
+ /// </summary>
|
|
|
private bool isOpen { set; get; } = false;
|
|
|
|
|
|
private MediaDialogModel model = new MediaDialogModel();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 打开编辑弹窗
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="type">类型:1:新增;2:编辑;3:删除</param>
|
|
|
+ /// <param name="media">广告信息</param>
|
|
|
+ /// <returns></returns>
|
|
|
private async Task ShowDialog(int type,MediaEntity? media)
|
|
|
{
|
|
|
model = new MediaDialogModel();
|
|
|
model.Type = type;
|
|
|
- if(type == 2)
|
|
|
+ if(type == 2 || type == 3)
|
|
|
{
|
|
|
+ model.Id = media?.Id;
|
|
|
+ model.GroupID = media?.GroupID ?? "";
|
|
|
+ model.BusinessUnitID = media?.BusinessUnitID ?? "";
|
|
|
model.FileName = media?.FileName ?? "";
|
|
|
+ model.GuidFileName = media?.GuidFileName ?? "";
|
|
|
+ model.FileExtension = media?.FileExtension ?? "";
|
|
|
+ model.SavePath = media?.LocalPath ?? "";
|
|
|
model.MediaUploader = media?.Uploader ?? "";
|
|
|
model.StartTime = media?.StartTime;
|
|
|
model.EndTime = media?.EndTime;
|
|
|
@@ -84,31 +100,58 @@ public partial class Media
|
|
|
model.FailureTime = media?.FailureTime;
|
|
|
model.MediaState = media?.MediaState ?? 0;
|
|
|
model.MachineStateList = JsonSerializer.Deserialize<List<string>>(media?.MachineState ?? "[]");
|
|
|
+ model.Remark = media?.Remark ?? "";
|
|
|
}
|
|
|
|
|
|
isOpen = true;
|
|
|
}
|
|
|
- private void OnUploadChange(UploadInfo info)
|
|
|
- {
|
|
|
- // 处理上传逻辑
|
|
|
- }
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 弹窗信息回调
|
|
|
+ /// 编辑弹窗信息回调
|
|
|
/// </summary>
|
|
|
/// <param name="model"></param>
|
|
|
private async Task OnDialogCallback(MediaDialogModel model)
|
|
|
{
|
|
|
Console.WriteLine(model);
|
|
|
- await _Repository.InsertAsync(model.ToCompany());
|
|
|
-
|
|
|
-
|
|
|
+ switch (model.Type)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ await _Repository.InsertAsync(model.ToCompany());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ MediaEntity mediaEntity = model.ToCompany();
|
|
|
+ await _Repository.Context.Updateable(mediaEntity).
|
|
|
+ UpdateColumns(it => new { it.MediaState,it.MachineState, it.StartTime, it.EndTime ,it.EffectiveTime,it.FailureTime,it.Remark })
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ await _Repository.DeleteByIdAsync(model.Id);
|
|
|
+ if(model.SavePath.IsNotNullOrEmpty())
|
|
|
+ {
|
|
|
+ File.Delete(model.SavePath);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ await Query();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 编辑弹窗是否显示回调
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="isOpen"></param>
|
|
|
private void OnDialogVisibleCallback(bool isOpen)
|
|
|
{
|
|
|
this.isOpen = isOpen;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 表格查询
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="query"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task OnChange(QueryModel<MediaEntity> query)
|
|
|
+ => await Query();
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 查
|
|
|
/// </summary>
|
|
|
@@ -117,22 +160,44 @@ public partial class Media
|
|
|
{
|
|
|
Loading = true;
|
|
|
|
|
|
- _DataSource = await _Repository.AsQueryable()
|
|
|
+ var query = _Repository.AsQueryable()
|
|
|
.WhereIF(filterData.searchFileName != null, it => it.FileName.Contains(filterData.searchFileName))
|
|
|
.WhereIF(filterData.searchMediaUploader != null, it => it.Uploader.Contains(filterData.searchMediaUploader))
|
|
|
.WhereIF(filterData.searchMediaState != null && filterData.searchMediaState != -1, it => it.MediaState == filterData.searchMediaState)
|
|
|
- .WhereIF(filterData.searchMachineStateList.IsNotNullOrEmpty(), it => SqlFunc.ContainsArray(filterData.searchMachineStateList, it.MachineState))
|
|
|
.WhereIF(filterData.searchStartTime != null && filterData.searchEndTime != null, it => it.StartTime >= filterData.searchStartTime && it.EndTime <= filterData.searchEndTime)
|
|
|
.WhereIF(filterData.searchEffecitiveTime != null && filterData.searchFailureTime != null, it => it.EffectiveTime >= filterData.searchEffecitiveTime && it.FailureTime <= filterData.searchFailureTime)
|
|
|
- .WhereIF(filterData.searchStartEditTime != null && filterData.searchEndEditTime != null, it => it.EditTime >= filterData.searchStartEditTime && it.EditTime <= filterData.searchEndEditTime)
|
|
|
- .OrderByDescending(it => it.EditTime)
|
|
|
- .ToPageListAsync(filterData.currentPage,filterData.pageSize);
|
|
|
+ .WhereIF(filterData.searchStartEditTime != null && filterData.searchEndEditTime != null, it => it.EditTime >= filterData.searchStartEditTime && it.EditTime <= filterData.searchEndEditTime);
|
|
|
|
|
|
- Total = _DataSource.size();
|
|
|
+ if (filterData.searchMachineStateList.IsNotNullOrEmpty())
|
|
|
+ {
|
|
|
+ Expressionable<MediaEntity> expressionable = Expressionable.Create<MediaEntity>();
|
|
|
+ foreach (var state in filterData.searchMachineStateList)
|
|
|
+ {
|
|
|
+ var jsonQuoted = $"\"{state}\"";
|
|
|
+ expressionable.Or(m => m.MachineState.Contains(jsonQuoted));
|
|
|
+ }
|
|
|
+ query = query.Where(expressionable.ToExpression());
|
|
|
+ }
|
|
|
+
|
|
|
+ Total = await query.CountAsync();
|
|
|
+ _DataSource = await query
|
|
|
+ .OrderByDescending(it => it.EditTime)
|
|
|
+ .Skip((filterData.currentPage - 1) * filterData.pageSize)
|
|
|
+ .Take(filterData.pageSize)
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
Loading = false;
|
|
|
}
|
|
|
|
|
|
+ Func<PaginationTotalContext, string> showTotal = ctx => $"总数 {ctx.Total} ";
|
|
|
+
|
|
|
+ private async Task OnPageChange(PaginationEventArgs args)
|
|
|
+ {
|
|
|
+ filterData.pageSize = args.PageSize;
|
|
|
+ filterData.currentPage = args.Page;
|
|
|
+ await Query();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 清空查询条件
|
|
|
/// </summary>
|