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($("