From 9acbffb57af62079e15daf3de916dcb9b8bc3fe7 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 5 Jan 2023 18:42:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9weblogo=E4=B8=8A=E5=82=B3,=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=80=E5=9F=9F=E6=9D=B1=E5=88=A5=E7=84=A1?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9,=20=E4=BF=AE=E6=94=B9=E6=8C=89?= =?UTF-8?q?=E9=88=95=E6=A0=BC=E5=BC=8F(=E7=A8=8B=E5=BA=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/VariableController.cs | 25 +- Backend/Models/Mybase.cs | 5 +- Backend/Views/BuildMenu/Index.cshtml | 42 ++-- Backend/Views/Variable/Index.cshtml | 100 +++++--- .../18979486-b05f-4617-973d-2e8d89019ef8.jpg | Bin 0 -> 4377 bytes Frontend/_alert.html | 218 +++++++++++++----- Frontend/index.html | 8 +- Frontend/login.html | 2 +- 8 files changed, 292 insertions(+), 108 deletions(-) create mode 100644 Backend/wwwroot/img/18979486-b05f-4617-973d-2e8d89019ef8.jpg diff --git a/Backend/Controllers/VariableController.cs b/Backend/Controllers/VariableController.cs index 31c7309..ccaee2a 100644 --- a/Backend/Controllers/VariableController.cs +++ b/Backend/Controllers/VariableController.cs @@ -6,15 +6,18 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.IO; namespace Backend.Controllers { public class VariableController : MybaseController { private readonly IBackendRepository backendRepository; + private string variableFilePath = ""; public VariableController(IBackendRepository backendRepository) { this.backendRepository = backendRepository; + variableFilePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img"); } @@ -119,7 +122,7 @@ namespace Backend.Controllers /// /// [HttpPost] - public async Task> SaveVariable(VariableInfo post) + public async Task> SaveVariable([FromForm] VariableInfo post) { ApiResult apiResult = new ApiResult(); @@ -130,7 +133,23 @@ namespace Backend.Controllers object param = new { Id = post.id }; var variableInfo = await backendRepository.GetOneAsync("variable", sWhere, param); + Guid file_guid = Guid.Empty; + if (post.file != null) + { + file_guid = Guid.NewGuid(); + var fileName = file_guid + "." + post.extName; + var fullPath = Path.Combine(variableFilePath, fileName); + + if (!System.IO.Directory.Exists(variableFilePath)) + System.IO.Directory.CreateDirectory(variableFilePath); + + using (var stream = new FileStream(fullPath, FileMode.Create)) + { + post.file.CopyTo(stream); + } + } + if (variableInfo == null) { //新增 @@ -139,7 +158,7 @@ namespace Backend.Controllers { { "@system_type", post.System_type}, { "@system_key", post.System_key}, - { "@system_value", post.system_value}, + { "@system_value", file_guid != Guid.Empty ? file_guid.ToString() + "." + post.extName : post.system_value}, { "@system_remark", post.system_remark}, { "@system_priority", post.system_priority}, { "@system_parent_id", post.system_parent_id}, @@ -156,7 +175,7 @@ namespace Backend.Controllers { { "@system_type", post.System_type}, { "@system_key", post.System_key}, - { "@system_value", post.system_value}, + { "@system_value", file_guid != Guid.Empty ? file_guid.ToString() + "." + post.extName : post.system_value}, { "@system_remark", post.system_remark}, { "@system_priority", post.system_priority}, { "@system_parent_id", post.system_parent_id}, diff --git a/Backend/Models/Mybase.cs b/Backend/Models/Mybase.cs index bdc8b69..254ec07 100644 --- a/Backend/Models/Mybase.cs +++ b/Backend/Models/Mybase.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.AspNetCore.Http; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -67,6 +68,8 @@ namespace Backend.Models public string system_remark { get; set; } public int system_priority { get; set; } public int system_parent_id { get; set; } + public IFormFile file { get; set; } + public string extName { get; set; } } public class PostVariableInfoFilter diff --git a/Backend/Views/BuildMenu/Index.cshtml b/Backend/Views/BuildMenu/Index.cshtml index 625704e..b780a8f 100644 --- a/Backend/Views/BuildMenu/Index.cshtml +++ b/Backend/Views/BuildMenu/Index.cshtml @@ -510,7 +510,9 @@ }, { "data": null, - "defaultContent": ' ' + "render": function (data, type, row, meta){ + return ' '; + } } ], 'createdRow': function (row, data, dataIndex) { @@ -886,9 +888,9 @@ $('#buildMenu_table').on("click", "button.edit-btn", function () { var url = "/BuildMenu/GetBuildMenu"; var send_data = { - building_tag: $(this).parents('tr').attr('bg-guid'), - main_system_tag: $(this).parents('tr').attr('ms-guid'), - sub_system_tag: $(this).parents('tr').attr('ss-guid') + building_tag: $(this).attr('bg-guid'), + main_system_tag: $(this).attr('ms-guid'), + sub_system_tag: $(this).attr('ss-guid') }; $.post(url, send_data, function (rel) { if (rel.code != "0000") { @@ -1007,10 +1009,11 @@ } $('#buildMenu_table').on("click", "button.del-btn", function () { + var send_data = { - building_tag: $(this).parents('tr').attr('bg-guid'), - main_system_tag: $(this).parents('tr').attr('ms-guid'), - sub_system_tag: $(this).parents('tr').attr('ss-guid') + building_tag: $(this).attr('bg-guid'), + main_system_tag: $(this).attr('ms-guid'), + sub_system_tag: $(this).attr('ss-guid') }; Swal.fire( { @@ -1048,18 +1051,21 @@ }); }); $('#buildMenu_table').on("click", "tbody>tr", function () { - $(this).parents().find('tr').css('background-color', '#fff'); - $(this).css('background-color', '#67B4AC'); - SelectBuild = $(this).attr('bg-guid'); - SelectMainSys = $(this).attr('ms-guid'); - SelectSubSys = $(this).attr('ss-guid'); - @*$('#menu_floor_main_modal').append($("